Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
CORE-2065 Add v4 registration contract address (#439)
Browse files Browse the repository at this point in the history
* select v4 registration contract address based on starkex version

* update version

* update test
  • Loading branch information
kaihirota authored Feb 28, 2024
1 parent 7b33e2d commit 92c6adf
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('createConfig', () => {
Config.createConfig({
coreContractAddress: '0x1',
registrationContractAddress: '0x2',
registrationV4ContractAddress: '0x3',
chainID: 3,
basePath: ' ',
}),
Expand All @@ -21,6 +22,7 @@ describe('createConfig', () => {
Config.createConfig({
coreContractAddress: '0x1',
registrationContractAddress: '0x2',
registrationV4ContractAddress: '0x3',
chainID: 3,
basePath: '',
}),
Expand All @@ -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',
Expand All @@ -47,12 +50,14 @@ describe('createConfig', () => {
chainID,
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
},
};

const actual = Config.createConfig({
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
chainID,
basePath,
headers: customHeaders,
Expand All @@ -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',
Expand All @@ -85,12 +91,14 @@ describe('createConfig', () => {
chainID,
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
},
};

const actual = Config.createConfig({
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
chainID,
basePath,
headers: customHeaders,
Expand Down
7 changes: 7 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -38,6 +39,7 @@ interface Environment extends EthConfiguration {
const createConfig = ({
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
chainID,
basePath,
headers,
Expand All @@ -62,6 +64,7 @@ const createConfig = ({
ethConfiguration: {
coreContractAddress,
registrationContractAddress,
registrationV4ContractAddress,
chainID,
},
};
Expand All @@ -78,6 +81,8 @@ export const Config = {
chainID: 1,
coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
registrationV4ContractAddress:
'0xac88a57943b5BBa1ecd931F8494cAd0B7F717590',
});
},

Expand All @@ -87,6 +92,8 @@ export const Config = {
chainID: 11155111,
coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
registrationV4ContractAddress:
'0xD1527C65c6287EC5ab816D328Eb83bb4CB690e92',
});
},

Expand Down
1 change: 1 addition & 0 deletions src/utils/formatError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('formatError', () => {
ethConfiguration: {
coreContractAddress: '',
registrationContractAddress: '',
registrationV4ContractAddress: '',
chainID: 3,
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/workflows/withdrawal/completeERC20Withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export async function completeAllERC20WithdrawalWorkflow(
});

const registrationContract = RegistrationV4__factory.connect(
config.ethConfiguration.registrationContractAddress,
config.ethConfiguration.registrationV4ContractAddress,
signer,
);

Expand Down Expand Up @@ -168,7 +168,7 @@ export async function registerAndCompleteAllERC20WithdrawalWorkflow(
});

const registrationContract = RegistrationV4__factory.connect(
config.ethConfiguration.registrationContractAddress,
config.ethConfiguration.registrationV4ContractAddress,
walletConnection.ethSigner,
);

Expand Down
4 changes: 2 additions & 2 deletions src/workflows/withdrawal/completeERC721Withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ async function registerAndCompleteMintableERC721WithdrawalV2(
);
const mintingBlob = getMintingBlob(token);
const contract = RegistrationV4__factory.connect(
config.ethConfiguration.registrationContractAddress,
config.ethConfiguration.registrationV4ContractAddress,
signer,
);

Expand Down Expand Up @@ -383,7 +383,7 @@ async function registerAndCompleteERC721WithdrawalV2(
});

const contract = RegistrationV4__factory.connect(
config.ethConfiguration.registrationContractAddress,
config.ethConfiguration.registrationV4ContractAddress,
signer,
);

Expand Down
4 changes: 2 additions & 2 deletions src/workflows/withdrawal/completeEthWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand All @@ -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,
);

Expand Down

0 comments on commit 92c6adf

Please sign in to comment.