From 09933d03f582eb72d8d07eacfedc784f3f09438f 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 --- 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 0b06612152..9b14fc6bef 100644 --- a/packages/extension-base/src/core/substrate/xcm-parser.ts +++ b/packages/extension-base/src/core/substrate/xcm-parser.ts @@ -241,18 +241,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 a4f077cfe4..f9c5c91950 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 @@ -225,12 +225,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 4b381db3041f8aa1313c6063284ffb768f0a5699 Mon Sep 17 00:00:00 2001 From: S2kael Date: Fri, 22 Nov 2024 11:19:14 +0700 Subject: [PATCH 2/2] [Issue-3852] Update metadata for case KSM and DOT --- package.json | 2 +- packages/extension-base/package.json | 2 +- packages/extension-koni-ui/package.json | 2 +- packages/extension-web-ui/package.json | 2 +- yarn.lock | 14 +++++++------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 34e7a3175f..2f2373782b 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "@polkadot/types-support": "^12.0.2", "@polkadot/util": "^12.6.2", "@polkadot/util-crypto": "^12.6.2", - "@subwallet/chain-list": "0.2.94", + "@subwallet/chain-list": "0.2.95-beta.0", "@subwallet/keyring": "^0.1.8-beta.0", "@subwallet/react-ui": "5.1.2-b79", "@subwallet/ui-keyring": "0.1.8-beta.0", diff --git a/packages/extension-base/package.json b/packages/extension-base/package.json index 9d2d29dfef..1c8285c7a4 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.94", + "@subwallet/chain-list": "0.2.95-beta.0", "@subwallet/extension-base": "^1.3.6-1", "@subwallet/extension-chains": "^1.3.6-1", "@subwallet/extension-dapp": "^1.3.6-1", diff --git a/packages/extension-koni-ui/package.json b/packages/extension-koni-ui/package.json index 95e39b951b..ddb46ecbab 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.94", + "@subwallet/chain-list": "0.2.95-beta.0", "@subwallet/extension-base": "^1.3.6-1", "@subwallet/extension-chains": "^1.3.6-1", "@subwallet/extension-dapp": "^1.3.6-1", diff --git a/packages/extension-web-ui/package.json b/packages/extension-web-ui/package.json index f6388c3515..67b50a586d 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.94", + "@subwallet/chain-list": "0.2.95-beta.0", "@subwallet/extension-base": "^1.3.6-1", "@subwallet/extension-chains": "^1.3.6-1", "@subwallet/extension-dapp": "^1.3.6-1", diff --git a/yarn.lock b/yarn.lock index 65e003f1ce..082ac522da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6265,14 +6265,14 @@ __metadata: languageName: node linkType: hard -"@subwallet/chain-list@npm:0.2.94": - version: 0.2.94 - resolution: "@subwallet/chain-list@npm:0.2.94" +"@subwallet/chain-list@npm:0.2.95-beta.0": + version: 0.2.95-beta.0 + resolution: "@subwallet/chain-list@npm:0.2.95-beta.0" dependencies: "@polkadot/dev": 0.67.167 "@polkadot/util": ^12.5.1 eventemitter3: ^5.0.1 - checksum: cf285d30673bf98dc577baccffbaac96e49d5c5d718bb8c9fd9fe116318e753b16940907e143bfc1c212e5f3185713d82509fba85d42cbdd33a7177628e3bae4 + checksum: 23710027b2df62ff33eb5cbfe38fe82b254354d2cf67dc5a284233dfc2269e0691c357cd47a2fc7c2ff5bb4d8d1f8a8b7d492b9ac30344f5b594f4bc53335847 languageName: node linkType: hard @@ -6315,7 +6315,7 @@ __metadata: "@reduxjs/toolkit": ^1.9.1 "@sora-substrate/type-definitions": ^1.17.7 "@substrate/connect": ^0.8.9 - "@subwallet/chain-list": 0.2.94 + "@subwallet/chain-list": 0.2.95-beta.0 "@subwallet/extension-base": ^1.3.6-1 "@subwallet/extension-chains": ^1.3.6-1 "@subwallet/extension-dapp": ^1.3.6-1 @@ -6453,7 +6453,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.94 + "@subwallet/chain-list": 0.2.95-beta.0 "@subwallet/extension-base": ^1.3.6-1 "@subwallet/extension-chains": ^1.3.6-1 "@subwallet/extension-dapp": ^1.3.6-1 @@ -6593,7 +6593,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.94 + "@subwallet/chain-list": 0.2.95-beta.0 "@subwallet/extension-base": ^1.3.6-1 "@subwallet/extension-chains": ^1.3.6-1 "@subwallet/extension-dapp": ^1.3.6-1