Skip to content

Commit

Permalink
Merge pull request #3981 from Koniverse/koni/dev/issue-3979
Browse files Browse the repository at this point in the history
[Issue-3979] WebApp - Some update for WebApp
  • Loading branch information
lw-cdm authored Jan 14, 2025
2 parents d09a613 + 2421e63 commit 1786d0a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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.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",
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 @@ -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<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 @@ -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])
}
];

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.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",
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.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",
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
}
}
}
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 1786d0a

Please sign in to comment.