From 00da0958983ea14fa54e4f10e18676e5e863f56b Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 12 Dec 2024 17:29:16 +1000 Subject: [PATCH 1/7] fix: Fix type --- .../src/modules/transfer/components/Button/TransferButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/canonical-bridge-widget/src/modules/transfer/components/Button/TransferButton.tsx b/packages/canonical-bridge-widget/src/modules/transfer/components/Button/TransferButton.tsx index dfc3e557..efd65ea0 100644 --- a/packages/canonical-bridge-widget/src/modules/transfer/components/Button/TransferButton.tsx +++ b/packages/canonical-bridge-widget/src/modules/transfer/components/Button/TransferButton.tsx @@ -250,7 +250,7 @@ export function TransferButton({ } else if (transferActionInfo.bridgeType === 'deBridge') { try { let deBridgeHash: string | undefined; - const isValidToken = await await bridgeSDK.deBridge.validateDeBridgeToken({ + const isValidToken = await bridgeSDK.deBridge.validateDeBridgeToken({ fromChainId: fromChain?.id, toChainId: toChain?.id, fromTokenSymbol: selectedToken.symbol, From 63c1a6a783f9077de941971a28845a07d5efbe99 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 12 Dec 2024 18:35:05 +1000 Subject: [PATCH 2/7] chore: Release doc --- .release/.changeset/many-houses-leave.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .release/.changeset/many-houses-leave.md diff --git a/.release/.changeset/many-houses-leave.md b/.release/.changeset/many-houses-leave.md new file mode 100644 index 00000000..66f0127c --- /dev/null +++ b/.release/.changeset/many-houses-leave.md @@ -0,0 +1,6 @@ +--- +"@bnb-chain/canonical-bridge-sdk": patch +"@bnb-chain/canonical-bridge-widget": patch +--- + +Token transfer parameters validation From e636e983f2b2d70c8b45c8b029227b6adab87de5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 12 Dec 2024 08:38:26 +0000 Subject: [PATCH 3/7] chore: Update versions --- .release/.changeset/many-houses-leave.md | 6 ------ packages/canonical-bridge-sdk/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-sdk/package.json | 2 +- packages/canonical-bridge-widget/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-widget/package.json | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 .release/.changeset/many-houses-leave.md diff --git a/.release/.changeset/many-houses-leave.md b/.release/.changeset/many-houses-leave.md deleted file mode 100644 index 66f0127c..00000000 --- a/.release/.changeset/many-houses-leave.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-sdk": patch -"@bnb-chain/canonical-bridge-widget": patch ---- - -Token transfer parameters validation diff --git a/packages/canonical-bridge-sdk/CHANGELOG.md b/packages/canonical-bridge-sdk/CHANGELOG.md index 30b32f8a..ef1291af 100644 --- a/packages/canonical-bridge-sdk/CHANGELOG.md +++ b/packages/canonical-bridge-sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-sdk +## 0.4.3 + +### Patch Changes + +- 63c1a6a: Token transfer parameters validation + ## 0.4.2 ### Patch Changes diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index 3e4fa486..8556c33a 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-sdk", - "version": "0.4.2", + "version": "0.4.3", "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 12e52512..dd4b7769 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-widget +## 0.5.10 + +### Patch Changes + +- 63c1a6a: Token transfer parameters validation + ## 0.5.9 ### Patch Changes diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index d2c6686b..ab0d33e4 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", - "version": "0.5.9", + "version": "0.5.10", "description": "canonical bridge widget", "author": "bnb-chain", "private": false, From 3c0f3148cdd1328873ae088485ea2a1ed2b9ab68 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 13 Dec 2024 14:03:20 +1000 Subject: [PATCH 4/7] chore: Update meson validation for tron token --- .../__tests__/meson/index.test.ts | 57 +++++++++++++++++++ .../canonical-bridge-sdk/src/meson/index.ts | 11 ++-- .../src/meson/types/index.ts | 4 +- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/packages/canonical-bridge-sdk/__tests__/meson/index.test.ts b/packages/canonical-bridge-sdk/__tests__/meson/index.test.ts index 1ed1cc60..f9cdc636 100644 --- a/packages/canonical-bridge-sdk/__tests__/meson/index.test.ts +++ b/packages/canonical-bridge-sdk/__tests__/meson/index.test.ts @@ -257,4 +257,61 @@ describe('Meson SDK validation', () => { }) ).toBe(true); }); + + it('Test 14: Meson validation with from tron token', async () => { + expect( + await bridge.validateMesonToken({ + fromChainId: 728126428, + fromTokenAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', + fromTokenSymbol: 'usdt', + fromTokenDecimals: 6, + fromChainType: 'tron', + toChainId: 56, + toTokenAddress: '0x55d398326f99059ff775485246999027b3197955', + toTokenDecimals: 18, + toChainType: 'evm', + toTokenSymbol: 'usdt', + amount: 5, + mesonEndpoint: 'https://relayer.meson.fi/api/v1', + }) + ).toBe(true); + }); + + it('Test 15: Meson validation with to tron token', async () => { + expect( + await bridge.validateMesonToken({ + fromChainId: 56, + fromTokenAddress: '0x55d398326f99059ff775485246999027b3197955', + fromTokenSymbol: 'usdt', + fromTokenDecimals: 18, + fromChainType: 'evm', + toChainId: 728126428, + toTokenAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', + toTokenDecimals: 6, + toChainType: 'tron', + toTokenSymbol: 'usdt', + amount: 5, + mesonEndpoint: 'https://relayer.meson.fi/api/v1', + }) + ).toBe(true); + }); + + it('Test 16: Meson validation with wrong to tron token', async () => { + expect( + await bridge.validateMesonToken({ + fromChainId: 56, + fromTokenAddress: '0x55d398326f99059ff775485246999027b3197955', + fromTokenSymbol: 'usdt', + fromTokenDecimals: 18, + fromChainType: 'evm', + toChainId: 728126428, + toTokenAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6txx', + toTokenDecimals: 6, + toChainType: 'tron', + toTokenSymbol: 'usdt', + amount: 5, + mesonEndpoint: 'https://relayer.meson.fi/api/v1', + }) + ).toBe(false); + }); }); diff --git a/packages/canonical-bridge-sdk/src/meson/index.ts b/packages/canonical-bridge-sdk/src/meson/index.ts index 44749cf8..fbfda7fd 100644 --- a/packages/canonical-bridge-sdk/src/meson/index.ts +++ b/packages/canonical-bridge-sdk/src/meson/index.ts @@ -192,8 +192,11 @@ export class Meson { const { data: mesonConfig } = await axios.get<{ result: IMesonTokenList[]; }>(`${mesonEndpoint}/limits`, { timeout: VALIDATION_API_TIMEOUT }); - const fromHexNum = fromChainId?.toString(16); - const toHexNum = toChainId?.toString(16); + + const fromHexNum = + fromChainType === 'tron' ? 'tron' : `0x${fromChainId?.toString(16)}`; + const toHexNum = + toChainType === 'tron' ? 'tron' : `0x${toChainId?.toString(16)}`; // from token validation const validFromToken = mesonConfig.result.filter((chainInfo) => { const fromTokenInfo = chainInfo.tokens.filter( @@ -211,7 +214,7 @@ export class Meson { console.log('Meson from token info', fromTokenInfo); } return ( - chainInfo.chainId === `0x${fromHexNum}` && + chainInfo.chainId === fromHexNum && fromTokenInfo?.length > 0 && !!fromTokenInfo ); @@ -232,7 +235,7 @@ export class Meson { console.log('Meson to token info', toTokenInfo); } return ( - chainInfo.chainId === `0x${toHexNum}` && + chainInfo.chainId === toHexNum && toTokenInfo?.length > 0 && !!toTokenInfo ); diff --git a/packages/canonical-bridge-sdk/src/meson/types/index.ts b/packages/canonical-bridge-sdk/src/meson/types/index.ts index 9789a982..11bd9dbe 100644 --- a/packages/canonical-bridge-sdk/src/meson/types/index.ts +++ b/packages/canonical-bridge-sdk/src/meson/types/index.ts @@ -25,10 +25,10 @@ export interface IMesonTokenValidateParams { fromChainId?: number; toChainId?: number; fromTokenSymbol: string; - fromTokenAddress: `0x${string}`; + fromTokenAddress: string; fromTokenDecimals: number; fromChainType?: string; - toTokenAddress?: `0x${string}`; + toTokenAddress?: string; toTokenDecimals?: number; toChainType?: string; toTokenSymbol?: string; From d81727c7296ad4538661f72245982c3e1b41fa75 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 13 Dec 2024 14:05:46 +1000 Subject: [PATCH 5/7] feat: Release version --- .release/.changeset/cool-insects-walk.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .release/.changeset/cool-insects-walk.md diff --git a/.release/.changeset/cool-insects-walk.md b/.release/.changeset/cool-insects-walk.md new file mode 100644 index 00000000..41445392 --- /dev/null +++ b/.release/.changeset/cool-insects-walk.md @@ -0,0 +1,5 @@ +--- +"@bnb-chain/canonical-bridge-sdk": patch +--- + +Update meson token validation From 4d52f8ab9447753fcc46a201fe756193a1d5e15a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Dec 2024 04:12:02 +0000 Subject: [PATCH 6/7] chore: Update versions --- .release/.changeset/cool-insects-walk.md | 5 ----- packages/canonical-bridge-sdk/CHANGELOG.md | 6 ++++++ packages/canonical-bridge-sdk/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .release/.changeset/cool-insects-walk.md diff --git a/.release/.changeset/cool-insects-walk.md b/.release/.changeset/cool-insects-walk.md deleted file mode 100644 index 41445392..00000000 --- a/.release/.changeset/cool-insects-walk.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-sdk": patch ---- - -Update meson token validation diff --git a/packages/canonical-bridge-sdk/CHANGELOG.md b/packages/canonical-bridge-sdk/CHANGELOG.md index ef1291af..23c8d470 100644 --- a/packages/canonical-bridge-sdk/CHANGELOG.md +++ b/packages/canonical-bridge-sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-sdk +## 0.4.4 + +### Patch Changes + +- d81727c: Update meson token validation + ## 0.4.3 ### Patch Changes diff --git a/packages/canonical-bridge-sdk/package.json b/packages/canonical-bridge-sdk/package.json index 8556c33a..3792a777 100644 --- a/packages/canonical-bridge-sdk/package.json +++ b/packages/canonical-bridge-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-sdk", - "version": "0.4.3", + "version": "0.4.4", "description": "canonical bridge sdk", "author": "bnb-chain", "private": false, From c1aefab09fb4897f46e996e83d0f17c0c3167f56 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 13 Dec 2024 14:33:36 +1000 Subject: [PATCH 7/7] chore: Update meson vadliation --- .release/.changeset/few-seals-press.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .release/.changeset/few-seals-press.md diff --git a/.release/.changeset/few-seals-press.md b/.release/.changeset/few-seals-press.md new file mode 100644 index 00000000..3a7bfd71 --- /dev/null +++ b/.release/.changeset/few-seals-press.md @@ -0,0 +1,5 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +--- + +Update meson validation