From 92c6adf4a109ba91073405ab27e4350c8eedf312 Mon Sep 17 00:00:00 2001 From: Kai Hirota <34954529+kaihirota@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:25:28 +1100 Subject: [PATCH] CORE-2065 Add v4 registration contract address (#439) * select v4 registration contract address based on starkex version * update version * update test --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/config/config.test.ts | 8 ++++++++ src/config/config.ts | 7 +++++++ src/utils/formatError.test.ts | 1 + src/workflows/withdrawal/completeERC20Withdrawal.ts | 4 ++-- src/workflows/withdrawal/completeERC721Withdrawal.ts | 4 ++-- src/workflows/withdrawal/completeEthWithdrawal.ts | 4 ++-- 8 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8cb8b44..1cad33ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.6.0] - 2024-02-28 + +### Added + +- Add V4 registration contract addresses. + ## [3.5.0] - 2024-02-28 ### Added diff --git a/package.json b/package.json index 35814ccd..962e391d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@imtbl/core-sdk", - "version": "3.5.0", + "version": "3.6.0", "description": "Immutable Core SDK", "main": "dist/index.cjs.js", "module": "dist/index.es.js", diff --git a/src/config/config.test.ts b/src/config/config.test.ts index 3cabdc17..3f66c229 100644 --- a/src/config/config.test.ts +++ b/src/config/config.test.ts @@ -10,6 +10,7 @@ describe('createConfig', () => { Config.createConfig({ coreContractAddress: '0x1', registrationContractAddress: '0x2', + registrationV4ContractAddress: '0x3', chainID: 3, basePath: ' ', }), @@ -21,6 +22,7 @@ describe('createConfig', () => { Config.createConfig({ coreContractAddress: '0x1', registrationContractAddress: '0x2', + registrationV4ContractAddress: '0x3', chainID: 3, basePath: '', }), @@ -31,6 +33,7 @@ describe('createConfig', () => { const basePath = 'https://api.sandbox.x.immutable.com'; const coreContractAddress = '0x1'; const registrationContractAddress = '0x2'; + const registrationV4ContractAddress = '0x3'; const chainID = 3; const customHeaders = { 'x-custom-headers': 'x values', @@ -47,12 +50,14 @@ describe('createConfig', () => { chainID, coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, }, }; const actual = Config.createConfig({ coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, chainID, basePath, headers: customHeaders, @@ -66,6 +71,7 @@ describe('createConfig', () => { const basePath = 'https://api.sandbox.x.immutable.com'; const coreContractAddress = '0x1'; const registrationContractAddress = '0x2'; + const registrationV4ContractAddress = '0x3'; const chainID = 3; const customHeaders = { 'x-custom-headers': 'x values', @@ -85,12 +91,14 @@ describe('createConfig', () => { chainID, coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, }, }; const actual = Config.createConfig({ coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, chainID, basePath, headers: customHeaders, diff --git a/src/config/config.ts b/src/config/config.ts index 3ab83ae6..70aea7b5 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -12,6 +12,7 @@ const defaultHeaders = { 'x-sdk-version': `imx-core-sdk-ts-${version}` }; export interface EthConfiguration { coreContractAddress: string; registrationContractAddress: string; + registrationV4ContractAddress: string; chainID: number; } @@ -38,6 +39,7 @@ interface Environment extends EthConfiguration { const createConfig = ({ coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, chainID, basePath, headers, @@ -62,6 +64,7 @@ const createConfig = ({ ethConfiguration: { coreContractAddress, registrationContractAddress, + registrationV4ContractAddress, chainID, }, }; @@ -78,6 +81,8 @@ export const Config = { chainID: 1, coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9', registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c', + registrationV4ContractAddress: + '0xac88a57943b5BBa1ecd931F8494cAd0B7F717590', }); }, @@ -87,6 +92,8 @@ export const Config = { chainID: 11155111, coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98', registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97', + registrationV4ContractAddress: + '0xD1527C65c6287EC5ab816D328Eb83bb4CB690e92', }); }, diff --git a/src/utils/formatError.test.ts b/src/utils/formatError.test.ts index d25ccaa5..97d6f456 100644 --- a/src/utils/formatError.test.ts +++ b/src/utils/formatError.test.ts @@ -28,6 +28,7 @@ describe('formatError', () => { ethConfiguration: { coreContractAddress: '', registrationContractAddress: '', + registrationV4ContractAddress: '', chainID: 3, }, }; diff --git a/src/workflows/withdrawal/completeERC20Withdrawal.ts b/src/workflows/withdrawal/completeERC20Withdrawal.ts index c32cc6a9..86d70553 100644 --- a/src/workflows/withdrawal/completeERC20Withdrawal.ts +++ b/src/workflows/withdrawal/completeERC20Withdrawal.ts @@ -140,7 +140,7 @@ export async function completeAllERC20WithdrawalWorkflow( }); const registrationContract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, signer, ); @@ -168,7 +168,7 @@ export async function registerAndCompleteAllERC20WithdrawalWorkflow( }); const registrationContract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, walletConnection.ethSigner, ); diff --git a/src/workflows/withdrawal/completeERC721Withdrawal.ts b/src/workflows/withdrawal/completeERC721Withdrawal.ts index 1739cf4a..2205e0d1 100644 --- a/src/workflows/withdrawal/completeERC721Withdrawal.ts +++ b/src/workflows/withdrawal/completeERC721Withdrawal.ts @@ -353,7 +353,7 @@ async function registerAndCompleteMintableERC721WithdrawalV2( ); const mintingBlob = getMintingBlob(token); const contract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, signer, ); @@ -383,7 +383,7 @@ async function registerAndCompleteERC721WithdrawalV2( }); const contract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, signer, ); diff --git a/src/workflows/withdrawal/completeEthWithdrawal.ts b/src/workflows/withdrawal/completeEthWithdrawal.ts index bdd71318..8fe5aa39 100644 --- a/src/workflows/withdrawal/completeEthWithdrawal.ts +++ b/src/workflows/withdrawal/completeEthWithdrawal.ts @@ -131,7 +131,7 @@ export async function completeAllEthWithdrawalWorkflow( const assetType = await getEncodeAssetInfo('asset', 'ETH', encodingApi); const registrationContract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, signer, ); @@ -156,7 +156,7 @@ export async function registerAndCompleteAllEthWithdrawalWorkflow( const assetType = await getEncodeAssetInfo('asset', 'ETH', encodingApi); const registrationContract = RegistrationV4__factory.connect( - config.ethConfiguration.registrationContractAddress, + config.ethConfiguration.registrationV4ContractAddress, walletConnection.ethSigner, );