From 215723ceb1e43e6afa7309766fc65cebf27649e2 Mon Sep 17 00:00:00 2001 From: S2kael Date: Thu, 21 Nov 2024 18:48:43 +0700 Subject: [PATCH 1/2] [Issue-3852] Fix some error with foreign asset on asset hub (cherry picked from commit 09933d03f582eb72d8d07eacfedc784f3f09438f) --- packages/extension-base/src/core/substrate/xcm-parser.ts | 7 ++++--- .../balance-service/helpers/subscribe/substrate/index.ts | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/extension-base/src/core/substrate/xcm-parser.ts b/packages/extension-base/src/core/substrate/xcm-parser.ts index 4799c230f6..6ff9d36633 100644 --- a/packages/extension-base/src/core/substrate/xcm-parser.ts +++ b/packages/extension-base/src/core/substrate/xcm-parser.ts @@ -227,18 +227,19 @@ function _getAssetIdentifier (tokenInfo: _ChainAsset, version: number) { const assetIdentifier = ['statemint-LOCAL-KSM', 'statemine-LOCAL-DOT'].includes(tokenInfo.slug) // todo: hotfix for ksm statemint recheck all chain ? _assetIdentifier - : _adaptX1Interior(structuredClone(_assetIdentifier), version); + : _adaptX1Interior(_assetIdentifier, version); return version >= 4 // from V4, Concrete is removed ? assetIdentifier : { Concrete: assetIdentifier }; } -export function _adaptX1Interior (assetIdentifier: Record, version: number): Record { +export function _adaptX1Interior (_assetIdentifier: Record, version: number): Record { + const assetIdentifier = structuredClone(_assetIdentifier); const interior = assetIdentifier.interior as Record; const isInteriorObj = typeof interior === 'object' && interior !== null; const isX1 = isInteriorObj && 'X1' in interior; - const needModifyX1 = version <= 4 && Array.isArray(interior.X1); + const needModifyX1 = version < 4 && Array.isArray(interior.X1); if (isInteriorObj && isX1 && needModifyX1) { // X1 is an object for version < 4. From V4, it's an array // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access diff --git a/packages/extension-base/src/services/balance-service/helpers/subscribe/substrate/index.ts b/packages/extension-base/src/services/balance-service/helpers/subscribe/substrate/index.ts index dc8662aa9e..dc3dc726b0 100644 --- a/packages/extension-base/src/services/balance-service/helpers/subscribe/substrate/index.ts +++ b/packages/extension-base/src/services/balance-service/helpers/subscribe/substrate/index.ts @@ -211,12 +211,13 @@ const subscribeForeignAssetBalance = async ({ addresses, assetMap, callback, cha const unsubList = await Promise.all(Object.values(tokenMap).map((tokenInfo) => { try { if (_isBridgedToken(tokenInfo)) { + const version: number = ['statemint', 'statemine'].includes(chainInfo.slug) ? 4 : 3; const params: _SubstrateAdapterSubscriptionArgs[] = [ { section: 'query', module: foreignAssetsAccountKey.split('_')[1], method: foreignAssetsAccountKey.split('_')[2], - args: addresses.map((address) => [_getTokenOnChainInfo(tokenInfo) || _adaptX1Interior(_getXcmAssetMultilocation(tokenInfo), 3), address]) + args: addresses.map((address) => [_getTokenOnChainInfo(tokenInfo) || _adaptX1Interior(_getXcmAssetMultilocation(tokenInfo), version), address]) } ]; From 2421e63a99ab03292daffce7830129a78b2b09e5 Mon Sep 17 00:00:00 2001 From: S2kael Date: Wed, 8 Jan 2025 19:47:35 +0700 Subject: [PATCH 2/2] [Issue-3979] Update chain-list --- package.json | 2 +- packages/extension-base/package.json | 2 +- packages/extension-koni-ui/package.json | 2 +- packages/extension-web-ui/package.json | 2 +- packages/webapp/package.json | 2 +- yarn.lock | 14 +++++++------- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index fc61522823..5f8d15cd8d 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "@polkadot/types-support": "^12.0.2", "@polkadot/util": "^12.6.2", "@polkadot/util-crypto": "^12.6.2", - "@subwallet/chain-list": "0.2.88", + "@subwallet/chain-list": "0.2.88-webapp", "@subwallet/keyring": "^0.1.7", "@subwallet/react-ui": "5.1.2-b79", "@subwallet/ui-keyring": "^0.1.7", diff --git a/packages/extension-base/package.json b/packages/extension-base/package.json index 81a654934e..dca3b86510 100644 --- a/packages/extension-base/package.json +++ b/packages/extension-base/package.json @@ -55,7 +55,7 @@ "@reduxjs/toolkit": "^1.9.1", "@sora-substrate/type-definitions": "^1.17.7", "@substrate/connect": "^0.8.9", - "@subwallet/chain-list": "0.2.88", + "@subwallet/chain-list": "0.2.88-webapp", "@subwallet/extension-base": "^1.2.32-0", "@subwallet/extension-chains": "^1.2.32-0", "@subwallet/extension-dapp": "^1.2.32-0", diff --git a/packages/extension-koni-ui/package.json b/packages/extension-koni-ui/package.json index 6172f2b261..270cba7fef 100644 --- a/packages/extension-koni-ui/package.json +++ b/packages/extension-koni-ui/package.json @@ -34,7 +34,7 @@ "@polkadot/util-crypto": "^12.6.2", "@ramonak/react-progress-bar": "^5.0.3", "@reduxjs/toolkit": "^1.9.1", - "@subwallet/chain-list": "0.2.88", + "@subwallet/chain-list": "0.2.88-webapp", "@subwallet/extension-base": "^1.2.32-0", "@subwallet/extension-chains": "^1.2.32-0", "@subwallet/extension-dapp": "^1.2.32-0", diff --git a/packages/extension-web-ui/package.json b/packages/extension-web-ui/package.json index 953f0e78f1..a565adfd6a 100644 --- a/packages/extension-web-ui/package.json +++ b/packages/extension-web-ui/package.json @@ -35,7 +35,7 @@ "@polkadot/util-crypto": "^12.6.2", "@ramonak/react-progress-bar": "^5.0.3", "@reduxjs/toolkit": "^1.9.1", - "@subwallet/chain-list": "0.2.88", + "@subwallet/chain-list": "0.2.88-webapp", "@subwallet/extension-base": "^1.2.32-0", "@subwallet/extension-chains": "^1.2.32-0", "@subwallet/extension-dapp": "^1.2.32-0", diff --git a/packages/webapp/package.json b/packages/webapp/package.json index be72147d8b..b5f85cd14a 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -49,4 +49,4 @@ "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.0.4" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 33856b80fb..cf06ef0e25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6268,14 +6268,14 @@ __metadata: languageName: node linkType: hard -"@subwallet/chain-list@npm:0.2.88": - version: 0.2.88 - resolution: "@subwallet/chain-list@npm:0.2.88" +"@subwallet/chain-list@npm:0.2.88-webapp": + version: 0.2.88-webapp + resolution: "@subwallet/chain-list@npm:0.2.88-webapp" dependencies: "@polkadot/dev": 0.67.167 "@polkadot/util": ^12.5.1 eventemitter3: ^5.0.1 - checksum: 80640b5b555c238398ecaf9d6a5ae0c27680b67e3352408da5c1b0e3da79e792eb5f75ca1db866e529655071c7a158cae55fc90086b77908218f19e3deeca338 + checksum: 80267a73a42ae2f9160450bb72dc01e92255e4fea15cfba6b3a2889223d210c4b97e02b902ee82dc9e53e66711afcc323ca4a76819161d4fd9dc91fb0a967ccc languageName: node linkType: hard @@ -6318,7 +6318,7 @@ __metadata: "@reduxjs/toolkit": ^1.9.1 "@sora-substrate/type-definitions": ^1.17.7 "@substrate/connect": ^0.8.9 - "@subwallet/chain-list": 0.2.88 + "@subwallet/chain-list": 0.2.88-webapp "@subwallet/extension-base": ^1.2.32-0 "@subwallet/extension-chains": ^1.2.32-0 "@subwallet/extension-dapp": ^1.2.32-0 @@ -6451,7 +6451,7 @@ __metadata: "@polkadot/util-crypto": ^12.6.2 "@ramonak/react-progress-bar": ^5.0.3 "@reduxjs/toolkit": ^1.9.1 - "@subwallet/chain-list": 0.2.88 + "@subwallet/chain-list": 0.2.88-webapp "@subwallet/extension-base": ^1.2.32-0 "@subwallet/extension-chains": ^1.2.32-0 "@subwallet/extension-dapp": ^1.2.32-0 @@ -6591,7 +6591,7 @@ __metadata: "@polkadot/util-crypto": ^12.6.2 "@ramonak/react-progress-bar": ^5.0.3 "@reduxjs/toolkit": ^1.9.1 - "@subwallet/chain-list": 0.2.88 + "@subwallet/chain-list": 0.2.88-webapp "@subwallet/extension-base": ^1.2.32-0 "@subwallet/extension-chains": ^1.2.32-0 "@subwallet/extension-dapp": ^1.2.32-0