@subwallet/extension-base 1.2.13-0 → 1.2.15-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/errors/SwapError.js +5 -1
- package/cjs/background/errors/SwapError.js +5 -1
- package/cjs/core/logic-validation/swap.js +56 -3
- package/cjs/core/substrate/nominationpools-pallet.js +2 -1
- package/cjs/koni/api/nft/config.js +37 -23
- package/cjs/koni/api/nft/index.js +9 -1
- package/cjs/koni/api/nft/unique_network_nft/index.js +12 -20
- package/cjs/koni/background/handlers/Extension.js +12 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/xcm/utils.js +2 -2
- package/cjs/services/chain-service/constants.js +2 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +6 -0
- package/cjs/services/chain-service/health-check/constants/index.js +4 -4
- package/cjs/services/chain-service/health-check/utils/asset-info.js +23 -6
- package/cjs/services/chain-service/health-check/utils/chain-info.js +25 -2
- package/cjs/services/chain-service/health-check/utils/new-utils/asset-asset-validate.js +160 -0
- package/cjs/services/chain-service/health-check/utils/new-utils/asset-validate.js +45 -0
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +73 -0
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-validate.js +34 -0
- package/cjs/services/chain-service/index.js +47 -5
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +49 -19
- package/cjs/services/migration-service/scripts/databases/ReloadMetadata.js +35 -0
- package/cjs/services/migration-service/scripts/index.js +4 -2
- package/cjs/services/price-service/coingecko.js +57 -32
- package/cjs/services/price-service/index.js +30 -11
- package/cjs/services/storage-service/db-stores/BaseStore.js +4 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +343 -0
- package/cjs/services/swap-service/handler/asset-hub/index.js +12 -0
- package/cjs/services/swap-service/handler/asset-hub/router.js +93 -0
- package/cjs/services/swap-service/handler/asset-hub/utils.js +158 -0
- package/cjs/services/swap-service/index.js +10 -1
- package/cjs/services/swap-service/utils.js +10 -1
- package/cjs/types/swap/index.js +5 -1
- package/core/logic-validation/swap.d.ts +3 -1
- package/core/logic-validation/swap.js +55 -4
- package/core/substrate/nominationpools-pallet.js +2 -1
- package/koni/api/nft/config.d.ts +1 -0
- package/koni/api/nft/config.js +31 -19
- package/koni/api/nft/index.js +9 -1
- package/koni/api/nft/unique_network_nft/index.js +12 -20
- package/koni/background/handlers/Extension.js +12 -0
- package/package.json +56 -11
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/xcm/utils.js +2 -2
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +2 -1
- package/services/chain-service/handler/SubstrateApi.js +6 -0
- package/services/chain-service/health-check/constants/index.js +4 -4
- package/services/chain-service/health-check/utils/asset-info.d.ts +1 -0
- package/services/chain-service/health-check/utils/asset-info.js +20 -4
- package/services/chain-service/health-check/utils/chain-info.d.ts +4 -2
- package/services/chain-service/health-check/utils/chain-info.js +20 -0
- package/services/chain-service/health-check/utils/new-utils/asset-asset-validate.d.ts +10 -0
- package/services/chain-service/health-check/utils/new-utils/asset-asset-validate.js +146 -0
- package/services/chain-service/health-check/utils/new-utils/asset-validate.d.ts +3 -0
- package/services/chain-service/health-check/utils/new-utils/asset-validate.js +38 -0
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.d.ts +5 -0
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +64 -0
- package/services/chain-service/health-check/utils/new-utils/chain-validate.d.ts +4 -0
- package/services/chain-service/health-check/utils/new-utils/chain-validate.js +26 -0
- package/services/chain-service/index.js +47 -5
- package/services/chain-service/types.d.ts +5 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +46 -17
- package/services/migration-service/scripts/databases/ReloadMetadata.d.ts +5 -0
- package/services/migration-service/scripts/databases/ReloadMetadata.js +27 -0
- package/services/migration-service/scripts/index.js +4 -2
- package/services/price-service/coingecko.js +54 -32
- package/services/price-service/index.js +29 -11
- package/services/storage-service/db-stores/BaseStore.d.ts +3 -0
- package/services/storage-service/db-stores/BaseStore.js +4 -0
- package/services/swap-service/handler/asset-hub/handler.d.ts +31 -0
- package/services/swap-service/handler/asset-hub/handler.js +335 -0
- package/services/swap-service/handler/asset-hub/index.d.ts +1 -0
- package/services/swap-service/handler/asset-hub/index.js +4 -0
- package/services/swap-service/handler/asset-hub/router.d.ts +16 -0
- package/services/swap-service/handler/asset-hub/router.js +85 -0
- package/services/swap-service/handler/asset-hub/utils.d.ts +18 -0
- package/services/swap-service/handler/asset-hub/utils.js +133 -0
- package/services/swap-service/index.js +10 -1
- package/services/swap-service/utils.d.ts +1 -0
- package/services/swap-service/utils.js +9 -1
- package/types/swap/index.d.ts +15 -2
- package/types/swap/index.js +5 -1
- /package/cjs/services/migration-service/scripts/{ClearMetadataDatabase.js → databases/ClearMetadataDatabase.js} +0 -0
- /package/services/migration-service/scripts/{ClearMetadataDatabase.d.ts → databases/ClearMetadataDatabase.d.ts} +0 -0
- /package/services/migration-service/scripts/{ClearMetadataDatabase.js → databases/ClearMetadataDatabase.js} +0 -0
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.2.
|
|
20
|
+
"version": "1.2.15-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -719,6 +719,26 @@
|
|
|
719
719
|
"require": "./cjs/services/chain-service/health-check/utils/chain-info.js",
|
|
720
720
|
"default": "./services/chain-service/health-check/utils/chain-info.js"
|
|
721
721
|
},
|
|
722
|
+
"./services/chain-service/health-check/utils/new-utils/asset-asset-validate": {
|
|
723
|
+
"types": "./services/chain-service/health-check/utils/new-utils/asset-asset-validate.d.ts",
|
|
724
|
+
"require": "./cjs/services/chain-service/health-check/utils/new-utils/asset-asset-validate.js",
|
|
725
|
+
"default": "./services/chain-service/health-check/utils/new-utils/asset-asset-validate.js"
|
|
726
|
+
},
|
|
727
|
+
"./services/chain-service/health-check/utils/new-utils/asset-validate": {
|
|
728
|
+
"types": "./services/chain-service/health-check/utils/new-utils/asset-validate.d.ts",
|
|
729
|
+
"require": "./cjs/services/chain-service/health-check/utils/new-utils/asset-validate.js",
|
|
730
|
+
"default": "./services/chain-service/health-check/utils/new-utils/asset-validate.js"
|
|
731
|
+
},
|
|
732
|
+
"./services/chain-service/health-check/utils/new-utils/chain-asset-validate": {
|
|
733
|
+
"types": "./services/chain-service/health-check/utils/new-utils/chain-asset-validate.d.ts",
|
|
734
|
+
"require": "./cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js",
|
|
735
|
+
"default": "./services/chain-service/health-check/utils/new-utils/chain-asset-validate.js"
|
|
736
|
+
},
|
|
737
|
+
"./services/chain-service/health-check/utils/new-utils/chain-validate": {
|
|
738
|
+
"types": "./services/chain-service/health-check/utils/new-utils/chain-validate.d.ts",
|
|
739
|
+
"require": "./cjs/services/chain-service/health-check/utils/new-utils/chain-validate.js",
|
|
740
|
+
"default": "./services/chain-service/health-check/utils/new-utils/chain-validate.js"
|
|
741
|
+
},
|
|
722
742
|
"./services/chain-service/health-check/utils/provider": {
|
|
723
743
|
"types": "./services/chain-service/health-check/utils/provider.d.ts",
|
|
724
744
|
"require": "./cjs/services/chain-service/health-check/utils/provider.js",
|
|
@@ -956,11 +976,6 @@
|
|
|
956
976
|
"require": "./cjs/services/migration-service/scripts/AutoEnableChainsTokens.js",
|
|
957
977
|
"default": "./services/migration-service/scripts/AutoEnableChainsTokens.js"
|
|
958
978
|
},
|
|
959
|
-
"./services/migration-service/scripts/ClearMetadataDatabase": {
|
|
960
|
-
"types": "./services/migration-service/scripts/ClearMetadataDatabase.d.ts",
|
|
961
|
-
"require": "./cjs/services/migration-service/scripts/ClearMetadataDatabase.js",
|
|
962
|
-
"default": "./services/migration-service/scripts/ClearMetadataDatabase.js"
|
|
963
|
-
},
|
|
964
979
|
"./services/migration-service/scripts/ClearOldStorage": {
|
|
965
980
|
"types": "./services/migration-service/scripts/ClearOldStorage.d.ts",
|
|
966
981
|
"require": "./cjs/services/migration-service/scripts/ClearOldStorage.js",
|
|
@@ -971,6 +986,11 @@
|
|
|
971
986
|
"require": "./cjs/services/migration-service/scripts/databases/AutoEnableSomeTokens.js",
|
|
972
987
|
"default": "./services/migration-service/scripts/databases/AutoEnableSomeTokens.js"
|
|
973
988
|
},
|
|
989
|
+
"./services/migration-service/scripts/databases/ClearMetadataDatabase": {
|
|
990
|
+
"types": "./services/migration-service/scripts/databases/ClearMetadataDatabase.d.ts",
|
|
991
|
+
"require": "./cjs/services/migration-service/scripts/databases/ClearMetadataDatabase.js",
|
|
992
|
+
"default": "./services/migration-service/scripts/databases/ClearMetadataDatabase.js"
|
|
993
|
+
},
|
|
974
994
|
"./services/migration-service/scripts/databases/MigrateAssetSetting": {
|
|
975
995
|
"types": "./services/migration-service/scripts/databases/MigrateAssetSetting.d.ts",
|
|
976
996
|
"require": "./cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js",
|
|
@@ -986,6 +1006,11 @@
|
|
|
986
1006
|
"require": "./cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js",
|
|
987
1007
|
"default": "./services/migration-service/scripts/databases/MigrateEarningVersion.js"
|
|
988
1008
|
},
|
|
1009
|
+
"./services/migration-service/scripts/databases/ReloadMetadata": {
|
|
1010
|
+
"types": "./services/migration-service/scripts/databases/ReloadMetadata.d.ts",
|
|
1011
|
+
"require": "./cjs/services/migration-service/scripts/databases/ReloadMetadata.js",
|
|
1012
|
+
"default": "./services/migration-service/scripts/databases/ReloadMetadata.js"
|
|
1013
|
+
},
|
|
989
1014
|
"./services/migration-service/scripts/DeleteChain": {
|
|
990
1015
|
"types": "./services/migration-service/scripts/DeleteChain.d.ts",
|
|
991
1016
|
"require": "./cjs/services/migration-service/scripts/DeleteChain.js",
|
|
@@ -1396,6 +1421,26 @@
|
|
|
1396
1421
|
"require": "./cjs/services/swap-service/index.js",
|
|
1397
1422
|
"default": "./services/swap-service/index.js"
|
|
1398
1423
|
},
|
|
1424
|
+
"./services/swap-service/handler/asset-hub": {
|
|
1425
|
+
"types": "./services/swap-service/handler/asset-hub/index.d.ts",
|
|
1426
|
+
"require": "./cjs/services/swap-service/handler/asset-hub/index.js",
|
|
1427
|
+
"default": "./services/swap-service/handler/asset-hub/index.js"
|
|
1428
|
+
},
|
|
1429
|
+
"./services/swap-service/handler/asset-hub/handler": {
|
|
1430
|
+
"types": "./services/swap-service/handler/asset-hub/handler.d.ts",
|
|
1431
|
+
"require": "./cjs/services/swap-service/handler/asset-hub/handler.js",
|
|
1432
|
+
"default": "./services/swap-service/handler/asset-hub/handler.js"
|
|
1433
|
+
},
|
|
1434
|
+
"./services/swap-service/handler/asset-hub/router": {
|
|
1435
|
+
"types": "./services/swap-service/handler/asset-hub/router.d.ts",
|
|
1436
|
+
"require": "./cjs/services/swap-service/handler/asset-hub/router.js",
|
|
1437
|
+
"default": "./services/swap-service/handler/asset-hub/router.js"
|
|
1438
|
+
},
|
|
1439
|
+
"./services/swap-service/handler/asset-hub/utils": {
|
|
1440
|
+
"types": "./services/swap-service/handler/asset-hub/utils.d.ts",
|
|
1441
|
+
"require": "./cjs/services/swap-service/handler/asset-hub/utils.js",
|
|
1442
|
+
"default": "./services/swap-service/handler/asset-hub/utils.js"
|
|
1443
|
+
},
|
|
1399
1444
|
"./services/swap-service/handler/base-handler": {
|
|
1400
1445
|
"types": "./services/swap-service/handler/base-handler.d.ts",
|
|
1401
1446
|
"require": "./cjs/services/swap-service/handler/base-handler.js",
|
|
@@ -1948,11 +1993,11 @@
|
|
|
1948
1993
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1949
1994
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1950
1995
|
"@substrate/connect": "^0.8.9",
|
|
1951
|
-
"@subwallet/chain-list": "0.2.
|
|
1952
|
-
"@subwallet/extension-base": "^1.2.
|
|
1953
|
-
"@subwallet/extension-chains": "^1.2.
|
|
1954
|
-
"@subwallet/extension-dapp": "^1.2.
|
|
1955
|
-
"@subwallet/extension-inject": "^1.2.
|
|
1996
|
+
"@subwallet/chain-list": "0.2.74",
|
|
1997
|
+
"@subwallet/extension-base": "^1.2.15-0",
|
|
1998
|
+
"@subwallet/extension-chains": "^1.2.15-0",
|
|
1999
|
+
"@subwallet/extension-dapp": "^1.2.15-0",
|
|
2000
|
+
"@subwallet/extension-inject": "^1.2.15-0",
|
|
1956
2001
|
"@subwallet/keyring": "^0.1.5",
|
|
1957
2002
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
1958
2003
|
"@walletconnect/keyvaluestorage": "^1.1.1",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.2.
|
|
10
|
+
version: '1.2.15-0'
|
|
11
11
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
export const STABLE_XCM_VERSION = 3;
|
|
5
5
|
export function isUseTeleportProtocol(originChainInfo, destChainInfo) {
|
|
6
|
-
const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug);
|
|
7
|
-
const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug);
|
|
6
|
+
const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug) || ['rococo'].includes(originChainInfo.slug) && ['rococo_assethub'].includes(destChainInfo.slug);
|
|
7
|
+
const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug) || ['rococo'].includes(destChainInfo.slug) && ['rococo_assethub'].includes(originChainInfo.slug);
|
|
8
8
|
return relayChainToSystemChain || systemChainToRelayChain;
|
|
9
9
|
}
|
|
@@ -48,6 +48,7 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
48
48
|
statemine: ['statemine'],
|
|
49
49
|
statemint: ['statemint'],
|
|
50
50
|
unique_network: ['unique_network', 'quartz', 'opal'],
|
|
51
|
+
unique_evm: ['unique_evm'],
|
|
51
52
|
bitcountry: ['bitcountry', 'pioneer', 'continuum_network'],
|
|
52
53
|
vara: ['vara_network']
|
|
53
54
|
};
|
|
@@ -250,7 +251,7 @@ export const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
|
250
251
|
|
|
251
252
|
export const _XCM_CHAIN_GROUP = {
|
|
252
253
|
polkadotXcm: ['astar', 'shiden', 'statemine', 'statemint', 'equilibrium_parachain', 'rococo_assethub'],
|
|
253
|
-
xcmPallet: ['polkadot', 'kusama']
|
|
254
|
+
xcmPallet: ['polkadot', 'kusama', 'rococo']
|
|
254
255
|
// default is xTokens pallet
|
|
255
256
|
};
|
|
256
257
|
|
|
@@ -25,8 +25,14 @@ const typesBundle = {
|
|
|
25
25
|
const _availSpec = {
|
|
26
26
|
signedExtensions: availSpec.signedExtensions
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
// Override avail goldberg spec for signedExtensions
|
|
30
|
+
const _goldbergSpec = {
|
|
31
|
+
signedExtensions: availSpec.signedExtensions
|
|
32
|
+
};
|
|
28
33
|
if (typesBundle.spec) {
|
|
29
34
|
typesBundle.spec.avail = _availSpec;
|
|
35
|
+
typesBundle.spec['data-avail'] = _goldbergSpec;
|
|
30
36
|
}
|
|
31
37
|
export class SubstrateApi {
|
|
32
38
|
useLightClient = false;
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import BigN from 'bignumber.js';
|
|
5
5
|
export const chainProvider = {
|
|
6
6
|
default: 0,
|
|
7
|
-
ethereum:
|
|
7
|
+
ethereum: 0,
|
|
8
8
|
polygon: 2,
|
|
9
|
-
shidenEvm:
|
|
10
|
-
shiden:
|
|
11
|
-
ajunaPolkadot:
|
|
9
|
+
shidenEvm: 1,
|
|
10
|
+
shiden: 1,
|
|
11
|
+
ajunaPolkadot: 0,
|
|
12
12
|
crabParachain: 1,
|
|
13
13
|
astarEvm: 1,
|
|
14
14
|
shibuya: 1,
|
|
@@ -12,3 +12,4 @@ export declare const getPsp22AssetInfo: (asset: _ChainAsset, api: ApiPromise) =>
|
|
|
12
12
|
export declare const getEvmNativeInfo: (api: _EvmApi) => Promise<AssetSpec>;
|
|
13
13
|
export declare const getErc20AssetInfo: (asset: _ChainAsset, api: _EvmApi) => Promise<AssetSpec>;
|
|
14
14
|
export declare const compareAsset: (assetInfo: AssetSpec, asset: _ChainAsset, errors: string[]) => void;
|
|
15
|
+
export declare const validateAsset: (onchainAsset: AssetSpec, chainlistAsset: _ChainAsset) => boolean;
|
|
@@ -109,13 +109,12 @@ const getByAssetManagerWithAssetIdPallet = async (asset, api) => {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
const getByAssetRegistryWithAssetIdPallet = async (asset, api) => {
|
|
112
|
-
const [_info
|
|
112
|
+
const [_info] = await api.queryMulti([[api.query.assetRegistry.assets, _getTokenOnChainAssetId(asset)]]);
|
|
113
113
|
const info = _info.toPrimitive();
|
|
114
|
-
const metadata = _metadata.toPrimitive();
|
|
115
114
|
return {
|
|
116
|
-
decimals:
|
|
115
|
+
decimals: info.decimals,
|
|
117
116
|
minAmount: info.existentialDeposit.toString(),
|
|
118
|
-
symbol:
|
|
117
|
+
symbol: info.symbol
|
|
119
118
|
};
|
|
120
119
|
};
|
|
121
120
|
export const getLocalAssetInfo = async (chain, asset, api) => {
|
|
@@ -264,4 +263,21 @@ export const compareAsset = (assetInfo, asset, errors) => {
|
|
|
264
263
|
var _asset$decimals;
|
|
265
264
|
errors.push(`Wrong decimals: current - ${(_asset$decimals = asset.decimals) !== null && _asset$decimals !== void 0 ? _asset$decimals : 'null'}, onChain - ${decimals}`);
|
|
266
265
|
}
|
|
266
|
+
};
|
|
267
|
+
export const validateAsset = (onchainAsset, chainlistAsset) => {
|
|
268
|
+
const {
|
|
269
|
+
decimals,
|
|
270
|
+
minAmount,
|
|
271
|
+
symbol
|
|
272
|
+
} = onchainAsset;
|
|
273
|
+
const chainlistMinAmount = chainlistAsset.minAmount || '0';
|
|
274
|
+
const chainlistDecimals = chainlistAsset.decimals || 0;
|
|
275
|
+
const chainlistSymbol = chainlistAsset.symbol;
|
|
276
|
+
console.log(`[i] minAmount: current - ${chainlistMinAmount}, onchain - ${minAmount}`);
|
|
277
|
+
console.log(`[i] decimals: current - ${chainlistDecimals}, onchain - ${decimals}`);
|
|
278
|
+
console.log(`[i] symbol: current - ${chainlistSymbol}, onchain - ${symbol}`);
|
|
279
|
+
const isValidSymbol = symbol === chainlistSymbol ? true : 'zk' + symbol === chainlistSymbol;
|
|
280
|
+
const isValidMinAmount = minAmount === chainlistMinAmount;
|
|
281
|
+
const isValidDecimal = decimals === chainlistDecimals;
|
|
282
|
+
return isValidSymbol && isValidMinAmount && isValidDecimal;
|
|
267
283
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AssetSpec } from '@subwallet/extension-base/services/chain-service/health-check/utils/asset-info';
|
|
2
|
-
interface NativeAssetInfo {
|
|
2
|
+
export interface NativeAssetInfo {
|
|
3
3
|
decimals: number;
|
|
4
4
|
existentialDeposit: string;
|
|
5
5
|
symbol: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const compareNativeAsset: (assetInfo: AssetSpec, nativeAsset: NativeAssetInfo, errors: string[]) => void;
|
|
8
|
-
export
|
|
8
|
+
export declare const checkNativeAsset: (assetInfo: AssetSpec, nativeAsset: NativeAssetInfo) => boolean;
|
|
9
|
+
export declare const checkSs58Prefix: (onchainPrefix: number, chainlistPrefix: number) => boolean;
|
|
10
|
+
export declare const checkParachainId: (onchainPrefix: number | null, chainlistPrefix: number | null) => boolean;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { BIG_TEN } from '@subwallet/extension-base/services/chain-service/health-check/constants';
|
|
5
5
|
import BigN from 'bignumber.js';
|
|
6
|
+
// function for old health-check chain
|
|
6
7
|
export const compareNativeAsset = (assetInfo, nativeAsset, errors) => {
|
|
7
8
|
const {
|
|
8
9
|
decimals: _decimals,
|
|
@@ -25,4 +26,23 @@ export const compareNativeAsset = (assetInfo, nativeAsset, errors) => {
|
|
|
25
26
|
if (decimals !== _decimals) {
|
|
26
27
|
errors.push(`Wrong decimals: current - ${_decimals}, onChain - ${decimals}`);
|
|
27
28
|
}
|
|
29
|
+
};
|
|
30
|
+
export const checkNativeAsset = (assetInfo, nativeAsset) => {
|
|
31
|
+
const {
|
|
32
|
+
decimals: _decimals,
|
|
33
|
+
existentialDeposit: _minAmount,
|
|
34
|
+
symbol: _symbol
|
|
35
|
+
} = nativeAsset;
|
|
36
|
+
const {
|
|
37
|
+
decimals,
|
|
38
|
+
minAmount,
|
|
39
|
+
symbol
|
|
40
|
+
} = assetInfo;
|
|
41
|
+
return minAmount === _minAmount && symbol === _symbol && decimals === _decimals;
|
|
42
|
+
};
|
|
43
|
+
export const checkSs58Prefix = (onchainPrefix, chainlistPrefix) => {
|
|
44
|
+
return onchainPrefix === chainlistPrefix;
|
|
45
|
+
};
|
|
46
|
+
export const checkParachainId = (onchainPrefix, chainlistPrefix) => {
|
|
47
|
+
return onchainPrefix === chainlistPrefix;
|
|
28
48
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { _AssetRef, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
export declare function validateAssetGroupPrice(multiChainAsset: _MultiChainAsset, chainAsset: _ChainAsset): boolean;
|
|
3
|
+
export declare function validateAssetsGroupPrice(chainAsset1: _ChainAsset, chainAsset2: _ChainAsset): boolean;
|
|
4
|
+
export declare function checkMultichainAssetValid(chainAsset: _ChainAsset): boolean;
|
|
5
|
+
export declare function checkSwapAssetRef(slug: string, assetRef: _AssetRef): boolean;
|
|
6
|
+
export declare function validateNotDuplicateSmartcontract(chainAsset: _ChainAsset): boolean;
|
|
7
|
+
export declare function validateNativeLocalTransferMetadata(chainAsset: _ChainAsset): boolean;
|
|
8
|
+
export declare function validateSwapAlterAsset(assetRef: _AssetRef): boolean;
|
|
9
|
+
export declare function validateXcmMetadata(assetRef: _AssetRef): {};
|
|
10
|
+
export declare function checkValidSupportStaking(chainInfo: _ChainInfo): true | undefined;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ChainAssetMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
|
+
import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
|
+
|
|
7
|
+
// Check priceId valid in group asset
|
|
8
|
+
|
|
9
|
+
export function validateAssetGroupPrice(multiChainAsset, chainAsset) {
|
|
10
|
+
if (chainAsset.multiChainAsset !== multiChainAsset.slug) {
|
|
11
|
+
throw new Error(`Asset ${chainAsset.slug} are not in ${multiChainAsset.slug} group asset`);
|
|
12
|
+
}
|
|
13
|
+
return multiChainAsset.priceId === chainAsset.priceId;
|
|
14
|
+
}
|
|
15
|
+
export function validateAssetsGroupPrice(chainAsset1, chainAsset2) {
|
|
16
|
+
if (chainAsset1.multiChainAsset !== chainAsset2.multiChainAsset) {
|
|
17
|
+
throw new Error(`Asset ${chainAsset1.slug} and asset ${chainAsset2.slug} are not in a group asset`);
|
|
18
|
+
}
|
|
19
|
+
return chainAsset1.priceId === chainAsset2.priceId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check priceId valid in group asset
|
|
23
|
+
|
|
24
|
+
// Check multichainAsset valid
|
|
25
|
+
|
|
26
|
+
export function checkMultichainAssetValid(chainAsset) {
|
|
27
|
+
if (!chainAsset.multiChainAsset) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(MultiChainAssetMap).includes(chainAsset.multiChainAsset);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check multichainAsset valid
|
|
34
|
+
|
|
35
|
+
// Check slug asset ref
|
|
36
|
+
|
|
37
|
+
export function checkSwapAssetRef(slug, assetRef) {
|
|
38
|
+
return slug === `${assetRef.srcAsset}___${assetRef.destAsset}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check slug asset ref
|
|
42
|
+
|
|
43
|
+
// Check duplicate smartcontract
|
|
44
|
+
|
|
45
|
+
export function validateNotDuplicateSmartcontract(chainAsset) {
|
|
46
|
+
if (!['ERC20', 'ERC721', 'PSP22', 'PSP34', 'GRC20', 'GRC721'].includes(chainAsset.assetType)) {
|
|
47
|
+
throw new Error(`${chainAsset.slug} is not smart contract asset`);
|
|
48
|
+
}
|
|
49
|
+
const slug = chainAsset.slug;
|
|
50
|
+
const isDuplicate = Object.entries(ChainAssetMap).some(([key, tokenInfo]) => {
|
|
51
|
+
var _chainAsset$metadata, _tokenInfo$metadata;
|
|
52
|
+
return slug !== key && (chainAsset === null || chainAsset === void 0 ? void 0 : (_chainAsset$metadata = chainAsset.metadata) === null || _chainAsset$metadata === void 0 ? void 0 : _chainAsset$metadata.contractAddress) === (tokenInfo === null || tokenInfo === void 0 ? void 0 : (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.contractAddress);
|
|
53
|
+
});
|
|
54
|
+
return !isDuplicate;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Check duplicate smartcontract
|
|
58
|
+
|
|
59
|
+
// ---------------------
|
|
60
|
+
|
|
61
|
+
// TRANSFER
|
|
62
|
+
|
|
63
|
+
export function validateNativeLocalTransferMetadata(chainAsset) {
|
|
64
|
+
if (!chainAsset.metadata) {
|
|
65
|
+
// recheck this
|
|
66
|
+
throw new Error(`Asset ${chainAsset.slug} is lack of metadata`);
|
|
67
|
+
}
|
|
68
|
+
const moonbeamGroup = ['moonbeam, moonbase, moonriver'];
|
|
69
|
+
const onChainInfoLocalGroup = [_TRANSFER_CHAIN_GROUP.centrifuge, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.kintsugi, 'pendulum', 'amplitude'];
|
|
70
|
+
const onChainInfoNativeGroup = [_TRANSFER_CHAIN_GROUP.centrifuge, ..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.kintsugi];
|
|
71
|
+
const assetIdLocalGroup = [..._TRANSFER_CHAIN_GROUP.statemine, ..._TRANSFER_CHAIN_GROUP.genshiro, ...moonbeamGroup, 'hydradx'];
|
|
72
|
+
const assetIdNativeGroup = [..._TRANSFER_CHAIN_GROUP.sora_substrate, 'hydradx'];
|
|
73
|
+
const chain = chainAsset.originChain;
|
|
74
|
+
const isLocal = chainAsset.assetType === 'LOCAL';
|
|
75
|
+
const isNative = chainAsset.assetType === 'NATIVE';
|
|
76
|
+
if (isLocal && onChainInfoLocalGroup.includes(chain)) {
|
|
77
|
+
return !!chainAsset.metadata.onChainInfo;
|
|
78
|
+
}
|
|
79
|
+
if (isNative && onChainInfoNativeGroup.includes(chain)) {
|
|
80
|
+
return !!chainAsset.metadata.onChainInfo;
|
|
81
|
+
}
|
|
82
|
+
if (isLocal && assetIdLocalGroup.includes(chain)) {
|
|
83
|
+
return !!chainAsset.metadata.assetId;
|
|
84
|
+
}
|
|
85
|
+
if (isNative && assetIdNativeGroup.includes(chain)) {
|
|
86
|
+
return !!chainAsset.metadata.assetId;
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`${chainAsset.slug} is not local or native asset`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// TRANSFER
|
|
92
|
+
|
|
93
|
+
// SWAP
|
|
94
|
+
|
|
95
|
+
export function validateSwapAlterAsset(assetRef) {
|
|
96
|
+
var _assetRef$metadata;
|
|
97
|
+
if (assetRef.path !== 'SWAP') {
|
|
98
|
+
throw new Error(`${assetRef.srcAsset}___${assetRef.destAsset} is not SWAP`);
|
|
99
|
+
}
|
|
100
|
+
const srcAsset = assetRef.srcAsset;
|
|
101
|
+
const alterAsset = (_assetRef$metadata = assetRef.metadata) === null || _assetRef$metadata === void 0 ? void 0 : _assetRef$metadata.alternativeAsset;
|
|
102
|
+
if (!alterAsset) {
|
|
103
|
+
throw new Error(`${assetRef.srcAsset}___${assetRef.destAsset} does not has alternativeAsset`);
|
|
104
|
+
}
|
|
105
|
+
if (!ChainAssetMap[srcAsset] || !ChainAssetMap[alterAsset]) {
|
|
106
|
+
throw new Error(`${srcAsset} or ${alterAsset} do not exist`);
|
|
107
|
+
}
|
|
108
|
+
return ChainAssetMap[srcAsset].multiChainAsset === ChainAssetMap[alterAsset].multiChainAsset;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// SWAP
|
|
112
|
+
|
|
113
|
+
// XCM
|
|
114
|
+
|
|
115
|
+
export function validateXcmMetadata(assetRef) {
|
|
116
|
+
var _ChainAssetMap$srcAss, _ChainAssetMap$destAs;
|
|
117
|
+
if (assetRef.path !== 'XCM') {
|
|
118
|
+
throw new Error(`${assetRef.srcAsset}___${assetRef.destAsset} is not XCM`);
|
|
119
|
+
}
|
|
120
|
+
const srcAsset = assetRef.srcAsset;
|
|
121
|
+
const destAsset = assetRef.destAsset;
|
|
122
|
+
if (!ChainAssetMap[srcAsset] || !ChainAssetMap[destAsset]) {
|
|
123
|
+
throw new Error(`${srcAsset} or ${destAsset} do not exist`);
|
|
124
|
+
}
|
|
125
|
+
return ((_ChainAssetMap$srcAss = ChainAssetMap[srcAsset].metadata) === null || _ChainAssetMap$srcAss === void 0 ? void 0 : _ChainAssetMap$srcAss.multilocation) && ((_ChainAssetMap$destAs = ChainAssetMap[destAsset].metadata) === null || _ChainAssetMap$destAs === void 0 ? void 0 : _ChainAssetMap$destAs.multilocation) || false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// XCM
|
|
129
|
+
|
|
130
|
+
// EARNING
|
|
131
|
+
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
export function checkValidSupportStaking(chainInfo) {
|
|
134
|
+
if (!chainInfo.substrateInfo) {
|
|
135
|
+
throw new Error(`chain ${chainInfo.slug} is not substrate chain`);
|
|
136
|
+
}
|
|
137
|
+
if (!chainInfo.substrateInfo.supportStaking) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// todo: check has related pallet staking
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// todo: check alternativeAsset
|
|
145
|
+
|
|
146
|
+
// EARNING
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
|
+
export function validateAssetSlug(chainAsset) {
|
|
6
|
+
const slug = chainAsset.slug;
|
|
7
|
+
const originChain = chainAsset.originChain;
|
|
8
|
+
const assetType = chainAsset.assetType;
|
|
9
|
+
const symbol = chainAsset.symbol;
|
|
10
|
+
if ([_AssetType.LOCAL, _AssetType.NATIVE, _AssetType.BRC20].includes(assetType)) {
|
|
11
|
+
return slug === `${originChain}-${assetType}-${symbol}`;
|
|
12
|
+
}
|
|
13
|
+
if ([_AssetType.RUNE].includes(assetType)) {
|
|
14
|
+
var _chainAsset$metadata;
|
|
15
|
+
const runeId = (_chainAsset$metadata = chainAsset.metadata) === null || _chainAsset$metadata === void 0 ? void 0 : _chainAsset$metadata.runeId;
|
|
16
|
+
if (!runeId) {
|
|
17
|
+
throw new Error(`${slug} is ${assetType} but lack of runeId metadata`);
|
|
18
|
+
}
|
|
19
|
+
return slug === `${originChain}-${assetType}-${symbol}-${runeId}`;
|
|
20
|
+
}
|
|
21
|
+
if ([_AssetType.ERC20, _AssetType.ERC721, _AssetType.PSP22, _AssetType.PSP34, _AssetType.GRC20, _AssetType.GRC721].includes(assetType)) {
|
|
22
|
+
var _chainAsset$metadata2;
|
|
23
|
+
const contractAddress = (_chainAsset$metadata2 = chainAsset.metadata) === null || _chainAsset$metadata2 === void 0 ? void 0 : _chainAsset$metadata2.contractAddress;
|
|
24
|
+
if (!contractAddress) {
|
|
25
|
+
throw new Error(`${slug} is ${assetType} but lack of contractAddress metadata`);
|
|
26
|
+
}
|
|
27
|
+
return slug === `${originChain}-${assetType}-${symbol}-${contractAddress}`;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`${slug} has unknown token type ${assetType}`);
|
|
30
|
+
}
|
|
31
|
+
export function validateBrigeToken(chainAsset) {
|
|
32
|
+
var _chainAsset$metadata3, _chainAsset$metadata4;
|
|
33
|
+
const isBridged = (_chainAsset$metadata3 = chainAsset.metadata) === null || _chainAsset$metadata3 === void 0 ? void 0 : _chainAsset$metadata3.isBridged;
|
|
34
|
+
if (!isBridged) {
|
|
35
|
+
throw new Error(`${chainAsset.slug} is not bridged token`);
|
|
36
|
+
}
|
|
37
|
+
return !!((_chainAsset$metadata4 = chainAsset.metadata) !== null && _chainAsset$metadata4 !== void 0 && _chainAsset$metadata4.onChainInfo);
|
|
38
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
export declare function validateTokenHasValueByChain(chainAsset: _ChainAsset): boolean;
|
|
3
|
+
export declare function validateNativeInfoByChain(chainAsset: _ChainAsset): boolean;
|
|
4
|
+
export declare function validateAssetTypeSupportByChain(chainAsset: _ChainAsset): boolean;
|
|
5
|
+
export declare function validateChainDisableEvmTransfer(chainAsset: _ChainAsset): boolean | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ChainInfoMap } from '@subwallet/chain-list';
|
|
5
|
+
import { _AssetType } from '@subwallet/chain-list/types';
|
|
6
|
+
export function validateTokenHasValueByChain(chainAsset) {
|
|
7
|
+
const chainInfo = ChainInfoMap[chainAsset.originChain];
|
|
8
|
+
const isTestnet = chainInfo && chainInfo.isTestnet;
|
|
9
|
+
if (!chainInfo) {
|
|
10
|
+
throw new Error(`${chainAsset.originChain} is not existed`);
|
|
11
|
+
}
|
|
12
|
+
return isTestnet !== chainAsset.hasValue; // todo: also check multichainAsset hasValue if has.
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function validateNativeInfoByChain(chainAsset) {
|
|
16
|
+
var _chainInfo$evmInfo, _chainInfo$substrateI, _chainInfo$bitcoinInf, _chainInfo$evmInfo2, _chainInfo$substrateI2, _chainInfo$bitcoinInf2, _chainInfo$evmInfo3, _chainInfo$substrateI3, _chainInfo$bitcoinInf3;
|
|
17
|
+
const chainInfo = ChainInfoMap[chainAsset.originChain];
|
|
18
|
+
if (!chainInfo) {
|
|
19
|
+
throw new Error(`${chainAsset.originChain} is not existed`);
|
|
20
|
+
}
|
|
21
|
+
const nativeSymbol = chainInfo !== null && chainInfo !== void 0 && chainInfo.evmInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.symbol : chainInfo !== null && chainInfo !== void 0 && chainInfo.substrateInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.symbol : chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf === void 0 ? void 0 : _chainInfo$bitcoinInf.symbol;
|
|
22
|
+
const nativeDecimal = chainInfo !== null && chainInfo !== void 0 && chainInfo.evmInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo2 = chainInfo.evmInfo) === null || _chainInfo$evmInfo2 === void 0 ? void 0 : _chainInfo$evmInfo2.decimals : chainInfo !== null && chainInfo !== void 0 && chainInfo.substrateInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI2 = chainInfo.substrateInfo) === null || _chainInfo$substrateI2 === void 0 ? void 0 : _chainInfo$substrateI2.decimals : chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf2 = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf2 === void 0 ? void 0 : _chainInfo$bitcoinInf2.decimals;
|
|
23
|
+
const nativeED = chainInfo !== null && chainInfo !== void 0 && chainInfo.evmInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo3 = chainInfo.evmInfo) === null || _chainInfo$evmInfo3 === void 0 ? void 0 : _chainInfo$evmInfo3.existentialDeposit : chainInfo !== null && chainInfo !== void 0 && chainInfo.substrateInfo ? chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI3 = chainInfo.substrateInfo) === null || _chainInfo$substrateI3 === void 0 ? void 0 : _chainInfo$substrateI3.existentialDeposit : chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf3 = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf3 === void 0 ? void 0 : _chainInfo$bitcoinInf3.existentialDeposit;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
25
|
+
const nativeTokenSlug = `${chainInfo.slug}-NATIVE-${nativeSymbol}`;
|
|
26
|
+
return nativeSymbol === chainAsset.symbol && nativeDecimal === chainAsset.decimals && nativeED === chainAsset.minAmount && nativeTokenSlug === chainAsset.slug;
|
|
27
|
+
}
|
|
28
|
+
export function validateAssetTypeSupportByChain(chainAsset) {
|
|
29
|
+
const chainInfo = ChainInfoMap[chainAsset.originChain];
|
|
30
|
+
if (!chainInfo) {
|
|
31
|
+
throw new Error(`${chainAsset.originChain} is not existed`);
|
|
32
|
+
}
|
|
33
|
+
const bitcoinSupportAssetTypes = [_AssetType.NATIVE, _AssetType.RUNE, _AssetType.BRC20];
|
|
34
|
+
const evmSupportAssetTypes = [_AssetType.NATIVE, _AssetType.ERC20, _AssetType.ERC721];
|
|
35
|
+
const substrateSupportAssetTypes = [_AssetType.NATIVE, _AssetType.LOCAL, _AssetType.PSP22, _AssetType.PSP34, _AssetType.GRC20, _AssetType.GRC721];
|
|
36
|
+
|
|
37
|
+
// recheck chain with two types.
|
|
38
|
+
if (chainInfo.substrateInfo) {
|
|
39
|
+
return substrateSupportAssetTypes.includes(chainAsset.assetType);
|
|
40
|
+
}
|
|
41
|
+
if (chainInfo.evmInfo) {
|
|
42
|
+
return evmSupportAssetTypes.includes(chainAsset.assetType);
|
|
43
|
+
}
|
|
44
|
+
if (chainInfo.bitcoinInfo) {
|
|
45
|
+
return bitcoinSupportAssetTypes.includes(chainAsset.assetType);
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`${chainAsset.originChain} does not has a suitable chainInfo`);
|
|
48
|
+
}
|
|
49
|
+
export function validateChainDisableEvmTransfer(chainAsset) {
|
|
50
|
+
var _chainInfo$evmInfo4;
|
|
51
|
+
const chainInfo = ChainInfoMap[chainAsset.originChain];
|
|
52
|
+
if (!chainInfo) {
|
|
53
|
+
throw new Error(`${chainAsset.originChain} is not existed`);
|
|
54
|
+
}
|
|
55
|
+
if (!chainInfo.evmInfo) {
|
|
56
|
+
throw new Error(`${chainAsset.originChain} is not Evm chain`);
|
|
57
|
+
}
|
|
58
|
+
const isChainMatchCondition = ((_chainInfo$evmInfo4 = chainInfo.evmInfo) === null || _chainInfo$evmInfo4 === void 0 ? void 0 : _chainInfo$evmInfo4.evmChainId) === -1 && chainInfo.substrateInfo;
|
|
59
|
+
if (isChainMatchCondition) {
|
|
60
|
+
var _chainAsset$metadata;
|
|
61
|
+
return (_chainAsset$metadata = chainAsset.metadata) === null || _chainAsset$metadata === void 0 ? void 0 : _chainAsset$metadata.disableEvmTransfer;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
export declare function validateChainHasProvider(chainInfo: _ChainInfo): boolean;
|
|
3
|
+
export declare function validateParaId(chainInfo: _ChainInfo): boolean;
|
|
4
|
+
export declare function checkEvmSupportSmartContract(chainInfo: _ChainInfo): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
5
|
+
export function validateChainHasProvider(chainInfo) {
|
|
6
|
+
const chainStatus = chainInfo.chainStatus;
|
|
7
|
+
const providers = Object.keys(chainInfo.providers);
|
|
8
|
+
const validChainLive = chainStatus === _ChainStatus.ACTIVE && providers.length > 0;
|
|
9
|
+
const chainNotLive = chainStatus !== _ChainStatus.ACTIVE;
|
|
10
|
+
return validChainLive || chainNotLive;
|
|
11
|
+
}
|
|
12
|
+
export function validateParaId(chainInfo) {
|
|
13
|
+
if (!chainInfo.substrateInfo) {
|
|
14
|
+
throw new Error('Not substrate chain');
|
|
15
|
+
}
|
|
16
|
+
const paraId = chainInfo.substrateInfo.paraId;
|
|
17
|
+
const chainType = chainInfo.substrateInfo.chainType;
|
|
18
|
+
const relaySlug = chainInfo.substrateInfo.relaySlug;
|
|
19
|
+
return paraId ? chainType === _SubstrateChainType.PARACHAIN && !!relaySlug : chainType === _SubstrateChainType.RELAYCHAIN && !relaySlug;
|
|
20
|
+
}
|
|
21
|
+
export function checkEvmSupportSmartContract(chainInfo) {
|
|
22
|
+
if (!chainInfo.evmInfo) {
|
|
23
|
+
throw new Error('Not Evm chain');
|
|
24
|
+
}
|
|
25
|
+
return !!chainInfo.evmInfo.supportSmartContract;
|
|
26
|
+
}
|