Skip to content

Commit

Permalink
Merge pull request #3858 from Koniverse/koni/dev/issue-3852
Browse files Browse the repository at this point in the history
[Issue-3852] Extension - Re-check transaction on Polkadot Asset Hub
  • Loading branch information
saltict authored Nov 22, 2024
2 parents ef316a5 + 4b381db commit 2bf7bb2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions packages/extension-base/src/core/substrate/xcm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>, version: number): Record<string, any> {
export function _adaptX1Interior (_assetIdentifier: Record<string, any>, version: number): Record<string, any> {
const assetIdentifier = structuredClone(_assetIdentifier);
const interior = assetIdentifier.interior as Record<string, any>;
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
];

Expand Down
2 changes: 1 addition & 1 deletion packages/extension-koni-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

3 comments on commit 2bf7bb2

@saltict
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saltict
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saltict
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.