@subwallet/extension-base 1.1.65-0 → 1.1.67-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/cjs/koni/api/dotsama/transfer.js +11 -0
- package/cjs/koni/api/staking/bonding/relayChain.js +6 -0
- package/cjs/koni/api/tokens/wasm/utils.js +5 -3
- package/cjs/koni/background/cron.js +13 -0
- package/cjs/koni/background/handlers/State.js +2 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +67 -0
- package/cjs/services/chain-service/constants.js +8 -1
- package/cjs/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +15 -9
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +76 -57
- package/cjs/services/chain-service/index.js +45 -30
- package/cjs/services/chain-service/types.js +1 -1
- package/cjs/services/chain-service/utils/index.js +38 -15
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +1 -0
- package/cjs/services/earning-service/service.js +2 -2
- package/cjs/services/price-service/index.js +31 -17
- package/cjs/stores/CurrentCurrencyStore.js +18 -0
- package/cjs/stores/index.js +8 -1
- package/cjs/utils/gear/grc20.js +141 -0
- package/cjs/utils/gear/index.js +16 -0
- package/cjs/utils/index.js +40 -28
- package/koni/api/dotsama/transfer.js +13 -2
- package/koni/api/staking/bonding/relayChain.d.ts +1 -2
- package/koni/api/staking/bonding/relayChain.js +6 -0
- package/koni/api/tokens/wasm/utils.js +5 -3
- package/koni/background/cron.d.ts +2 -0
- package/koni/background/cron.js +14 -1
- package/koni/background/handlers/State.js +2 -0
- package/package.json +32 -15
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/index.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +67 -2
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +8 -1
- package/services/chain-service/handler/EvmChainHandler.d.ts +1 -1
- package/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/services/chain-service/handler/SubstrateApi.js +6 -0
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +4 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +76 -57
- package/services/chain-service/index.js +17 -8
- package/services/chain-service/types.js +1 -1
- package/services/chain-service/utils/index.d.ts +4 -0
- package/services/chain-service/utils/index.js +30 -15
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.js +2 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +3 -0
- package/services/earning-service/handlers/nomination-pool/index.js +1 -0
- package/services/earning-service/service.js +2 -2
- package/services/price-service/index.d.ts +4 -1
- package/services/price-service/index.js +31 -17
- package/stores/CurrentCurrencyStore.d.ts +5 -0
- package/stores/CurrentCurrencyStore.js +10 -0
- package/stores/index.d.ts +1 -0
- package/stores/index.js +2 -1
- package/utils/gear/grc20.d.ts +29 -0
- package/utils/gear/grc20.js +131 -0
- package/utils/gear/index.d.ts +1 -0
- package/utils/gear/index.js +4 -0
- package/utils/index.d.ts +6 -5
- package/utils/index.js +7 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { GearApi } from '@gear-js/api';
|
|
4
5
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
6
|
import { APIItemState } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
7
|
import { SUB_TOKEN_REFRESH_BALANCE_INTERVAL } from '@subwallet/extension-base/constants';
|
|
@@ -8,10 +9,11 @@ import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/toke
|
|
|
8
9
|
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
9
10
|
import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
10
11
|
import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
|
-
import { filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
|
|
12
|
+
import { filterAssetsByChainAndType, getGRC20ContractPromise } from '@subwallet/extension-base/utils';
|
|
12
13
|
import BigN from 'bignumber.js';
|
|
13
14
|
import { combineLatest, Observable } from 'rxjs';
|
|
14
|
-
import { BN, BN_ZERO } from '@polkadot/util';
|
|
15
|
+
import { BN, BN_ZERO, noop, u8aToHex } from '@polkadot/util';
|
|
16
|
+
import { decodeAddress } from '@polkadot/util-crypto';
|
|
15
17
|
import { subscribeERC20Interval } from "../evm.js";
|
|
16
18
|
import { subscribeEquilibriumTokenBalance } from "./equilibrium.js";
|
|
17
19
|
export const subscribeSubstrateBalance = async (addresses, chainInfo, assetMap, substrateApi, evmApi, callback) => {
|
|
@@ -20,6 +22,7 @@ export const subscribeSubstrateBalance = async (addresses, chainInfo, assetMap,
|
|
|
20
22
|
let unsubEvmContractToken;
|
|
21
23
|
let unsubWasmContractToken;
|
|
22
24
|
let unsubBridgedToken;
|
|
25
|
+
let unsubGrcToken;
|
|
23
26
|
const chain = chainInfo.slug;
|
|
24
27
|
const baseParams = {
|
|
25
28
|
addresses,
|
|
@@ -71,15 +74,21 @@ export const subscribeSubstrateBalance = async (addresses, chainInfo, assetMap,
|
|
|
71
74
|
// Get sub-token for substrate-based chains
|
|
72
75
|
unsubWasmContractToken = subscribePSP22Balance(substrateParams);
|
|
73
76
|
}
|
|
77
|
+
if (_checkSmartContractSupportByChain(chainInfo, _AssetType.GRC20)) {
|
|
78
|
+
// Get sub-token for substrate-based chains
|
|
79
|
+
unsubGrcToken = subscribeGRC20Balance(substrateParams);
|
|
80
|
+
}
|
|
74
81
|
} catch (err) {
|
|
75
82
|
console.warn(err);
|
|
76
83
|
}
|
|
77
84
|
return () => {
|
|
85
|
+
var _unsubGrcToken;
|
|
78
86
|
unsubNativeToken && unsubNativeToken();
|
|
79
87
|
unsubLocalToken && unsubLocalToken();
|
|
80
88
|
unsubEvmContractToken && unsubEvmContractToken();
|
|
81
89
|
unsubWasmContractToken && unsubWasmContractToken();
|
|
82
90
|
unsubBridgedToken && unsubBridgedToken();
|
|
91
|
+
(_unsubGrcToken = unsubGrcToken) === null || _unsubGrcToken === void 0 ? void 0 : _unsubGrcToken();
|
|
83
92
|
};
|
|
84
93
|
};
|
|
85
94
|
|
|
@@ -461,4 +470,60 @@ const subscribeOrmlTokensPallet = async ({
|
|
|
461
470
|
}).catch(console.error);
|
|
462
471
|
});
|
|
463
472
|
};
|
|
473
|
+
};
|
|
474
|
+
const subscribeGRC20Balance = ({
|
|
475
|
+
addresses,
|
|
476
|
+
assetMap,
|
|
477
|
+
callback,
|
|
478
|
+
chainInfo,
|
|
479
|
+
substrateApi
|
|
480
|
+
}) => {
|
|
481
|
+
if (!(substrateApi instanceof GearApi)) {
|
|
482
|
+
console.warn('Cannot subscribe GRC20 balance without GearApi instance');
|
|
483
|
+
return noop;
|
|
484
|
+
}
|
|
485
|
+
const chain = chainInfo.slug;
|
|
486
|
+
const psp22ContractMap = {};
|
|
487
|
+
const tokenList = filterAssetsByChainAndType(assetMap, chain, [_AssetType.GRC20]);
|
|
488
|
+
Object.entries(tokenList).forEach(([slug, tokenInfo]) => {
|
|
489
|
+
psp22ContractMap[slug] = getGRC20ContractPromise(substrateApi, _getContractAddressOfToken(tokenInfo));
|
|
490
|
+
});
|
|
491
|
+
const getTokenBalances = () => {
|
|
492
|
+
Object.values(tokenList).map(async tokenInfo => {
|
|
493
|
+
try {
|
|
494
|
+
const contract = psp22ContractMap[tokenInfo.slug];
|
|
495
|
+
const balances = await Promise.all(addresses.map(async address => {
|
|
496
|
+
try {
|
|
497
|
+
const actor = u8aToHex(decodeAddress(address));
|
|
498
|
+
const _balanceOf = await contract.balanceOf(actor, address);
|
|
499
|
+
return {
|
|
500
|
+
address: address,
|
|
501
|
+
tokenSlug: tokenInfo.slug,
|
|
502
|
+
free: _balanceOf.toString(10),
|
|
503
|
+
locked: '0',
|
|
504
|
+
state: APIItemState.READY
|
|
505
|
+
};
|
|
506
|
+
} catch (err) {
|
|
507
|
+
console.error(`Error on get balance of account ${address} for token ${tokenInfo.slug}`, err);
|
|
508
|
+
return {
|
|
509
|
+
address: address,
|
|
510
|
+
tokenSlug: tokenInfo.slug,
|
|
511
|
+
free: '0',
|
|
512
|
+
locked: '0',
|
|
513
|
+
state: APIItemState.READY
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
}));
|
|
517
|
+
callback(balances);
|
|
518
|
+
} catch (err) {
|
|
519
|
+
console.warn(tokenInfo.slug, err); // TODO: error createType
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
getTokenBalances();
|
|
525
|
+
const interval = setInterval(getTokenBalances, SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
|
|
526
|
+
return () => {
|
|
527
|
+
clearInterval(interval);
|
|
528
|
+
};
|
|
464
529
|
};
|
|
@@ -7,6 +7,7 @@ export declare const _API_OPTIONS_CHAIN_GROUP: {
|
|
|
7
7
|
turing: string[];
|
|
8
8
|
avail: string[];
|
|
9
9
|
goldberg: string[];
|
|
10
|
+
gear: string[];
|
|
10
11
|
};
|
|
11
12
|
export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
|
|
12
13
|
export declare const _PURE_EVM_CHAINS: string[];
|
|
@@ -11,7 +11,8 @@ export const _API_OPTIONS_CHAIN_GROUP = {
|
|
|
11
11
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
12
12
|
turing: ['turingStaging', 'turing'],
|
|
13
13
|
avail: ['kate', 'availTuringTest', 'avail_mainnet'],
|
|
14
|
-
goldberg: ['goldberg_testnet']
|
|
14
|
+
goldberg: ['goldberg_testnet'],
|
|
15
|
+
gear: ['vara_network', 'vara_testnet']
|
|
15
16
|
};
|
|
16
17
|
export const _PREDEFINED_SINGLE_MODES = {
|
|
17
18
|
subspace: {
|
|
@@ -86,6 +87,7 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
86
87
|
kate: 6,
|
|
87
88
|
creditcoin: 24,
|
|
88
89
|
vara_network: 12,
|
|
90
|
+
vara_testnet: 12,
|
|
89
91
|
goldberg_testnet: 24,
|
|
90
92
|
manta_network: 6,
|
|
91
93
|
krest_network: 4,
|
|
@@ -109,6 +111,7 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
109
111
|
edgeware: 6,
|
|
110
112
|
creditcoin: 12,
|
|
111
113
|
vara_network: 3,
|
|
114
|
+
vara_testnet: 3,
|
|
112
115
|
goldberg_testnet: 20,
|
|
113
116
|
polimec: 12,
|
|
114
117
|
bifrost: 13,
|
|
@@ -212,6 +215,10 @@ export const _KNOWN_CHAIN_INFLATION_PARAMS = {
|
|
|
212
215
|
vara_network: {
|
|
213
216
|
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
214
217
|
stakeTarget: 0.8
|
|
218
|
+
},
|
|
219
|
+
vara_testnet: {
|
|
220
|
+
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
221
|
+
stakeTarget: 0.8
|
|
215
222
|
}
|
|
216
223
|
};
|
|
217
224
|
|
|
@@ -18,5 +18,5 @@ export declare class EvmChainHandler extends AbstractChainHandler {
|
|
|
18
18
|
sleep(): Promise<void>;
|
|
19
19
|
wakeUp(): Promise<void>;
|
|
20
20
|
getChainSpec(evmApi: _EvmApi): Promise<_EvmChainSpec>;
|
|
21
|
-
|
|
21
|
+
getEvmContractTokenInfo(contractAddress: string, tokenType: _AssetType, originChain: string): Promise<_SmartContractTokenInfo>;
|
|
22
22
|
}
|
|
@@ -101,7 +101,7 @@ export class EvmChainHandler extends AbstractChainHandler {
|
|
|
101
101
|
}
|
|
102
102
|
return result;
|
|
103
103
|
}
|
|
104
|
-
async
|
|
104
|
+
async getEvmContractTokenInfo(contractAddress, tokenType, originChain) {
|
|
105
105
|
let tokenContract;
|
|
106
106
|
let name = '';
|
|
107
107
|
let decimals = -1;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import '@polkadot/types-augment';
|
|
5
5
|
import { options as acalaOptions } from '@acala-network/api';
|
|
6
|
+
import { GearApi } from '@gear-js/api';
|
|
6
7
|
import { rpc as oakRpc, types as oakTypes } from '@oak-foundation/types';
|
|
7
8
|
import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_CONNECT_TIMEOUT } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
9
|
import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
|
|
@@ -97,6 +98,11 @@ export class SubstrateApi {
|
|
|
97
98
|
signedExtensions: availSpec.signedExtensions,
|
|
98
99
|
noInitWarn: true
|
|
99
100
|
});
|
|
101
|
+
} else if (_API_OPTIONS_CHAIN_GROUP.gear.includes(this.chainSlug)) {
|
|
102
|
+
api = new GearApi({
|
|
103
|
+
provider,
|
|
104
|
+
noInitWarn: true
|
|
105
|
+
});
|
|
100
106
|
} else {
|
|
101
107
|
api = new ApiPromise(apiOption);
|
|
102
108
|
}
|
|
@@ -16,7 +16,10 @@ export declare class SubstrateChainHandler extends AbstractChainHandler {
|
|
|
16
16
|
sleep(): Promise<void>;
|
|
17
17
|
recoverApi(chainSlug: string): Promise<void>;
|
|
18
18
|
getChainSpec(substrateApi: _SubstrateApi): Promise<_SubstrateChainSpec>;
|
|
19
|
-
|
|
19
|
+
private getPsp22TokenInfo;
|
|
20
|
+
private getPsp34TokenInfo;
|
|
21
|
+
private getGrc20TokenInfo;
|
|
22
|
+
getSubstrateContractTokenInfo(contractAddress: string, tokenType: _AssetType, originChain: string, contractCaller?: string): Promise<_SmartContractTokenInfo>;
|
|
20
23
|
setSubstrateApi(chainSlug: string, substrateApi: SubstrateApi): void;
|
|
21
24
|
destroySubstrateApi(chainSlug: string): void;
|
|
22
25
|
initApi(chainSlug: string, apiUrl: string, { externalApiPromise, onUpdateStatus, providerName }?: Omit<_ApiOptions, 'metadata'>): Promise<SubstrateApi>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { GearApi } from '@gear-js/api';
|
|
4
5
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
6
|
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
6
7
|
import { AbstractChainHandler } from '@subwallet/extension-base/services/chain-service/handler/AbstractChainHandler';
|
|
7
8
|
import { SubstrateApi } from '@subwallet/extension-base/services/chain-service/handler/SubstrateApi';
|
|
9
|
+
import { DEFAULT_GEAR_ADDRESS, getGRC20ContractPromise } from '@subwallet/extension-base/utils';
|
|
8
10
|
import { ContractPromise } from '@polkadot/api-contract';
|
|
9
11
|
import { BN } from '@polkadot/util';
|
|
10
12
|
import { logger as createLogger } from '@polkadot/util/logger';
|
|
@@ -86,69 +88,86 @@ export class SubstrateChainHandler extends AbstractChainHandler {
|
|
|
86
88
|
result.existentialDeposit = substrateApi.api.consts.balances.existentialDeposit.toString();
|
|
87
89
|
return result;
|
|
88
90
|
}
|
|
89
|
-
async
|
|
90
|
-
|
|
91
|
+
async getPsp22TokenInfo(apiPromise, contractAddress, contractCaller) {
|
|
92
|
+
const tokenContract = new ContractPromise(apiPromise, _PSP22_ABI, contractAddress);
|
|
93
|
+
const [nameResp, symbolResp, decimalsResp] = await Promise.all([tokenContract.query['psp22Metadata::tokenName'](contractCaller || contractAddress, {
|
|
94
|
+
gasLimit: getDefaultWeightV2(apiPromise)
|
|
95
|
+
}),
|
|
96
|
+
// read-only operation so no gas limit
|
|
97
|
+
tokenContract.query['psp22Metadata::tokenSymbol'](contractCaller || contractAddress, {
|
|
98
|
+
gasLimit: getDefaultWeightV2(apiPromise)
|
|
99
|
+
}), tokenContract.query['psp22Metadata::tokenDecimals'](contractCaller || contractAddress, {
|
|
100
|
+
gasLimit: getDefaultWeightV2(apiPromise)
|
|
101
|
+
})]);
|
|
102
|
+
if (!(nameResp.result.isOk && symbolResp.result.isOk && decimalsResp.result.isOk) || !nameResp.output || !decimalsResp.output || !symbolResp.output) {
|
|
103
|
+
return ['', 1, '', true];
|
|
104
|
+
} else {
|
|
105
|
+
var _symbolResp$output, _decimalsResp$output, _nameResp$output;
|
|
106
|
+
let contractError = false;
|
|
107
|
+
const symbolObj = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
|
|
108
|
+
const decimalsObj = (_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman();
|
|
109
|
+
const nameObj = (_nameResp$output = nameResp.output) === null || _nameResp$output === void 0 ? void 0 : _nameResp$output.toHuman();
|
|
110
|
+
const name = nameResp.output ? nameObj.Ok || nameObj.ok : '';
|
|
111
|
+
const decimals = decimalsResp.output ? new BN(decimalsObj.Ok || decimalsObj.ok).toNumber() : 0;
|
|
112
|
+
const symbol = decimalsResp.output ? symbolObj.Ok || symbolObj.ok : '';
|
|
113
|
+
if (!name || !symbol || typeof name === 'object' || typeof symbol === 'object') {
|
|
114
|
+
contractError = true;
|
|
115
|
+
}
|
|
116
|
+
return [name, decimals, symbol, contractError];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async getPsp34TokenInfo(apiPromise, contractAddress, contractCaller) {
|
|
120
|
+
const tokenContract = new ContractPromise(apiPromise, _PSP34_ABI, contractAddress);
|
|
121
|
+
const collectionIdResp = await tokenContract.query['psp34::collectionId'](contractCaller || contractAddress, {
|
|
122
|
+
gasLimit: getDefaultWeightV2(apiPromise)
|
|
123
|
+
}); // read-only operation so no gas limit
|
|
124
|
+
|
|
125
|
+
if (!collectionIdResp.result.isOk || !collectionIdResp.output) {
|
|
126
|
+
return ['', -1, '', true];
|
|
127
|
+
} else {
|
|
128
|
+
var _collectionIdResp$out;
|
|
129
|
+
let contractError = false;
|
|
130
|
+
const collectionIdDict = (_collectionIdResp$out = collectionIdResp.output) === null || _collectionIdResp$out === void 0 ? void 0 : _collectionIdResp$out.toHuman();
|
|
131
|
+
if (collectionIdDict.Bytes === '') {
|
|
132
|
+
contractError = true;
|
|
133
|
+
}
|
|
134
|
+
return ['', -1, '', contractError];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async getGrc20TokenInfo(apiPromise, contractAddress) {
|
|
138
|
+
if (!(apiPromise instanceof GearApi)) {
|
|
139
|
+
console.warn('Cannot subscribe GRC20 balance without GearApi instance');
|
|
140
|
+
return ['', -1, '', true];
|
|
141
|
+
}
|
|
142
|
+
let contractError = false;
|
|
143
|
+
const tokenContract = getGRC20ContractPromise(apiPromise, contractAddress);
|
|
144
|
+
const [nameRes, symbolRes, decimalsRes] = await Promise.all([tokenContract.name(DEFAULT_GEAR_ADDRESS.ALICE), tokenContract.symbol(DEFAULT_GEAR_ADDRESS.ALICE), tokenContract.decimals(DEFAULT_GEAR_ADDRESS.ALICE)]);
|
|
145
|
+
const decimals = typeof decimalsRes === 'string' ? parseInt(decimalsRes) : decimalsRes;
|
|
146
|
+
if (!nameRes || !symbolRes) {
|
|
147
|
+
contractError = true;
|
|
148
|
+
}
|
|
149
|
+
return [nameRes, decimals, symbolRes, contractError];
|
|
150
|
+
}
|
|
151
|
+
async getSubstrateContractTokenInfo(contractAddress, tokenType, originChain, contractCaller) {
|
|
152
|
+
// todo: improve this funtion later
|
|
153
|
+
|
|
91
154
|
let name = '';
|
|
92
155
|
let decimals = -1;
|
|
93
156
|
let symbol = '';
|
|
94
157
|
let contractError = false;
|
|
95
|
-
const
|
|
158
|
+
const apiPromise = this.getSubstrateApiByChain(originChain).api;
|
|
96
159
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})]);
|
|
108
|
-
if (!(nameResp.result.isOk && symbolResp.result.isOk && decimalsResp.result.isOk) || !nameResp.output || !decimalsResp.output || !symbolResp.output) {
|
|
109
|
-
return {
|
|
110
|
-
name: '',
|
|
111
|
-
decimals: -1,
|
|
112
|
-
symbol: '',
|
|
113
|
-
contractError: true
|
|
114
|
-
};
|
|
115
|
-
} else {
|
|
116
|
-
var _symbolResp$output, _decimalsResp$output, _nameResp$output;
|
|
117
|
-
const symbolObj = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
|
|
118
|
-
const decimalsObj = (_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman();
|
|
119
|
-
const nameObj = (_nameResp$output = nameResp.output) === null || _nameResp$output === void 0 ? void 0 : _nameResp$output.toHuman();
|
|
120
|
-
name = nameResp.output ? nameObj.Ok || nameObj.ok : '';
|
|
121
|
-
decimals = decimalsResp.output ? new BN(decimalsObj.Ok || decimalsObj.ok).toNumber() : 0;
|
|
122
|
-
symbol = decimalsResp.output ? symbolObj.Ok || symbolObj.ok : '';
|
|
123
|
-
if (!name || !symbol || typeof name === 'object' || typeof symbol === 'object') {
|
|
124
|
-
contractError = true;
|
|
125
|
-
}
|
|
126
|
-
console.log('validate PSP22', name, symbol, decimals);
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
tokenContract = new ContractPromise(substrateApi.api, _PSP34_ABI, contractAddress);
|
|
130
|
-
const collectionIdResp = await tokenContract.query['psp34::collectionId'](contractCaller || contractAddress, {
|
|
131
|
-
gasLimit: getDefaultWeightV2(substrateApi.api)
|
|
132
|
-
}); // read-only operation so no gas limit
|
|
133
|
-
|
|
134
|
-
if (!collectionIdResp.result.isOk || !collectionIdResp.output) {
|
|
135
|
-
return {
|
|
136
|
-
name: '',
|
|
137
|
-
decimals: -1,
|
|
138
|
-
symbol: '',
|
|
139
|
-
contractError: true
|
|
140
|
-
};
|
|
141
|
-
} else {
|
|
142
|
-
var _collectionIdResp$out;
|
|
143
|
-
const collectionIdDict = (_collectionIdResp$out = collectionIdResp.output) === null || _collectionIdResp$out === void 0 ? void 0 : _collectionIdResp$out.toHuman();
|
|
144
|
-
if (collectionIdDict.Bytes === '') {
|
|
145
|
-
contractError = true;
|
|
146
|
-
} else {
|
|
147
|
-
name = ''; // no function to get collection name, let user manually put in the name
|
|
148
|
-
}
|
|
149
|
-
}
|
|
160
|
+
switch (tokenType) {
|
|
161
|
+
case _AssetType.PSP22:
|
|
162
|
+
[name, decimals, symbol, contractError] = await this.getPsp22TokenInfo(apiPromise, contractAddress, contractCaller);
|
|
163
|
+
break;
|
|
164
|
+
case _AssetType.PSP34:
|
|
165
|
+
[name, decimals, symbol, contractError] = await this.getPsp34TokenInfo(apiPromise, contractAddress, contractCaller);
|
|
166
|
+
break;
|
|
167
|
+
case _AssetType.GRC20:
|
|
168
|
+
[name, decimals, symbol, contractError] = await this.getGrc20TokenInfo(apiPromise, contractAddress);
|
|
169
|
+
break;
|
|
150
170
|
}
|
|
151
|
-
|
|
152
171
|
return {
|
|
153
172
|
name,
|
|
154
173
|
decimals,
|
|
@@ -15,6 +15,12 @@ import { addLazy, fetchStaticData, filterAssetsByChainAndType, MODULE_SUPPORT }
|
|
|
15
15
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
16
16
|
import Web3 from 'web3';
|
|
17
17
|
import { logger as createLogger } from '@polkadot/util/logger';
|
|
18
|
+
const filterChainInfoMap = data => {
|
|
19
|
+
return Object.fromEntries(Object.entries(data).filter(([, info]) => !info.bitcoinInfo));
|
|
20
|
+
};
|
|
21
|
+
const filterAssetInfoMap = (chainInfo, assets) => {
|
|
22
|
+
return Object.fromEntries(Object.entries(assets).filter(([, info]) => chainInfo[info.originChain]));
|
|
23
|
+
};
|
|
18
24
|
export class ChainService {
|
|
19
25
|
dataMap = {
|
|
20
26
|
chainInfoMap: {},
|
|
@@ -209,7 +215,7 @@ export class ChainService {
|
|
|
209
215
|
return Object.entries(this.dataMap.chainStateMap).filter(([, chainState]) => _isChainEnabled(chainState)).map(([key]) => key);
|
|
210
216
|
}
|
|
211
217
|
getSupportedSmartContractTypes() {
|
|
212
|
-
return [_AssetType.ERC20, _AssetType.ERC721, _AssetType.PSP22, _AssetType.PSP34];
|
|
218
|
+
return [_AssetType.ERC20, _AssetType.ERC721, _AssetType.PSP22, _AssetType.PSP34, _AssetType.GRC20, _AssetType.GRC721];
|
|
213
219
|
}
|
|
214
220
|
getActiveChainInfoMap() {
|
|
215
221
|
const result = {};
|
|
@@ -517,10 +523,10 @@ export class ChainService {
|
|
|
517
523
|
if (latestAssetInfo) {
|
|
518
524
|
const latestAssetPatch = JSON.stringify(latestAssetInfo);
|
|
519
525
|
if (this.assetMapPatch !== latestAssetPatch) {
|
|
520
|
-
const assetRegistry = {
|
|
526
|
+
const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), {
|
|
521
527
|
...ChainAssetMap,
|
|
522
528
|
...latestAssetInfo
|
|
523
|
-
};
|
|
529
|
+
});
|
|
524
530
|
this.assetMapPatch = latestAssetPatch;
|
|
525
531
|
this.dataMap.assetRegistry = assetRegistry;
|
|
526
532
|
this.assetRegistrySubject.next(assetRegistry);
|
|
@@ -825,7 +831,7 @@ export class ChainService {
|
|
|
825
831
|
}
|
|
826
832
|
async initChains() {
|
|
827
833
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
828
|
-
const defaultChainInfoMap = ChainInfoMap;
|
|
834
|
+
const defaultChainInfoMap = filterChainInfoMap(ChainInfoMap);
|
|
829
835
|
const storedChainSettingMap = {};
|
|
830
836
|
storedChainSettings.forEach(chainStoredSetting => {
|
|
831
837
|
storedChainSettingMap[chainStoredSetting.slug] = chainStoredSetting;
|
|
@@ -935,6 +941,7 @@ export class ChainService {
|
|
|
935
941
|
deprecatedChainMap[storedSlug] = duplicatedDefaultSlug;
|
|
936
942
|
deprecatedChains.push(storedSlug);
|
|
937
943
|
} else {
|
|
944
|
+
var _storedChainInfo$bitc;
|
|
938
945
|
mergedChainInfoMap[storedSlug] = {
|
|
939
946
|
slug: storedSlug,
|
|
940
947
|
name: storedChainInfo.name,
|
|
@@ -942,6 +949,7 @@ export class ChainService {
|
|
|
942
949
|
// TODO: review
|
|
943
950
|
evmInfo: storedChainInfo.evmInfo,
|
|
944
951
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
952
|
+
bitcoinInfo: (_storedChainInfo$bitc = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc !== void 0 ? _storedChainInfo$bitc : null,
|
|
945
953
|
isTestnet: storedChainInfo.isTestnet,
|
|
946
954
|
chainStatus: storedChainInfo.chainStatus,
|
|
947
955
|
icon: storedChainInfo.icon,
|
|
@@ -994,7 +1002,7 @@ export class ChainService {
|
|
|
994
1002
|
}
|
|
995
1003
|
async initAssetRegistry(deprecatedCustomChainMap) {
|
|
996
1004
|
const storedAssetRegistry = await this.dbService.getAllAssetStore();
|
|
997
|
-
const latestAssetRegistry = ChainAssetMap;
|
|
1005
|
+
const latestAssetRegistry = filterAssetInfoMap(this.getChainInfoMap(), ChainAssetMap);
|
|
998
1006
|
const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
|
|
999
1007
|
|
|
1000
1008
|
// Fill out zk assets from latestAssetRegistry if not supported
|
|
@@ -1149,6 +1157,7 @@ export class ChainService {
|
|
|
1149
1157
|
providers: params.chainEditInfo.providers,
|
|
1150
1158
|
substrateInfo,
|
|
1151
1159
|
evmInfo,
|
|
1160
|
+
bitcoinInfo: null,
|
|
1152
1161
|
isTestnet: false,
|
|
1153
1162
|
chainStatus: _ChainStatus.ACTIVE,
|
|
1154
1163
|
icon: '',
|
|
@@ -1393,9 +1402,9 @@ export class ChainService {
|
|
|
1393
1402
|
}
|
|
1394
1403
|
async getSmartContractTokenInfo(contractAddress, tokenType, originChain, contractCaller) {
|
|
1395
1404
|
if ([_AssetType.ERC721, _AssetType.ERC20].includes(tokenType)) {
|
|
1396
|
-
return await this.evmChainHandler.
|
|
1397
|
-
} else if ([_AssetType.PSP34, _AssetType.PSP22].includes(tokenType)) {
|
|
1398
|
-
return await this.substrateChainHandler.
|
|
1405
|
+
return await this.evmChainHandler.getEvmContractTokenInfo(contractAddress, tokenType, originChain);
|
|
1406
|
+
} else if ([_AssetType.PSP34, _AssetType.PSP22, _AssetType.GRC20].includes(tokenType)) {
|
|
1407
|
+
return await this.substrateChainHandler.getSubstrateContractTokenInfo(contractAddress, tokenType, originChain, contractCaller);
|
|
1399
1408
|
}
|
|
1400
1409
|
return {
|
|
1401
1410
|
decimals: -1,
|
|
@@ -12,6 +12,6 @@ export let _ChainConnectionStatus;
|
|
|
12
12
|
_ChainConnectionStatus["CONNECTING"] = "CONNECTING";
|
|
13
13
|
})(_ChainConnectionStatus || (_ChainConnectionStatus = {}));
|
|
14
14
|
export const _CUSTOM_PREFIX = 'custom-';
|
|
15
|
-
export const _FUNGIBLE_CONTRACT_STANDARDS = [_AssetType.ERC20, _AssetType.PSP22];
|
|
15
|
+
export const _FUNGIBLE_CONTRACT_STANDARDS = [_AssetType.ERC20, _AssetType.PSP22, _AssetType.GRC20];
|
|
16
16
|
export const _NFT_CONTRACT_STANDARDS = [_AssetType.PSP34, _AssetType.ERC721];
|
|
17
17
|
export const _SMART_CONTRACT_STANDARDS = [..._FUNGIBLE_CONTRACT_STANDARDS, ..._NFT_CONTRACT_STANDARDS];
|
|
@@ -45,6 +45,9 @@ export declare function _getChainSubstrateAddressPrefix(chainInfo: _ChainInfo):
|
|
|
45
45
|
export declare function _isChainSupportNativeNft(chainInfo: _ChainInfo): boolean;
|
|
46
46
|
export declare function _isChainSupportEvmNft(chainInfo: _ChainInfo): boolean;
|
|
47
47
|
export declare function _isChainSupportWasmNft(chainInfo: _ChainInfo): boolean;
|
|
48
|
+
export declare function _isChainSupportEvmERC20(chainInfo: _ChainInfo): boolean;
|
|
49
|
+
export declare function _isChainSupportWasmPSP22(chainInfo: _ChainInfo): boolean;
|
|
50
|
+
export declare function _isChainSupportGRC20(chainInfo: _ChainInfo): boolean;
|
|
48
51
|
export declare const _isSupportOrdinal: (chain: string) => boolean;
|
|
49
52
|
export declare function _getNftTypesSupportedByChain(chainInfo: _ChainInfo): _AssetType[];
|
|
50
53
|
export declare function _getTokenTypesSupportedByChain(chainInfo: _ChainInfo): _AssetType[];
|
|
@@ -54,6 +57,7 @@ export declare function _isLocalToken(tokenInfo: _ChainAsset): boolean;
|
|
|
54
57
|
export declare function _isTokenEvmSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
55
58
|
export declare function _isTokenWasmSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
56
59
|
export declare function _isAssetSmartContractNft(assetInfo: _ChainAsset): boolean;
|
|
60
|
+
export declare function _isTokenGearSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
57
61
|
export declare function _parseAssetRefKey(originTokenSlug: string, destinationTokenSlug: string): string;
|
|
58
62
|
export declare function _isXcmPathSupported(originTokenSlug: string, destinationTokenSlug: string, assetRefMap: Record<string, _AssetRef>): boolean;
|
|
59
63
|
export declare function _getXcmAssetType(tokenInfo: _ChainAsset): string;
|
|
@@ -169,6 +169,18 @@ export function _isChainSupportWasmNft(chainInfo) {
|
|
|
169
169
|
var _chainInfo$substrateI8, _chainInfo$substrateI9;
|
|
170
170
|
return ((_chainInfo$substrateI8 = chainInfo.substrateInfo) === null || _chainInfo$substrateI8 === void 0 ? void 0 : (_chainInfo$substrateI9 = _chainInfo$substrateI8.supportSmartContract) === null || _chainInfo$substrateI9 === void 0 ? void 0 : _chainInfo$substrateI9.includes(_AssetType.PSP34)) || false;
|
|
171
171
|
}
|
|
172
|
+
export function _isChainSupportEvmERC20(chainInfo) {
|
|
173
|
+
var _chainInfo$evmInfo3, _chainInfo$evmInfo3$s;
|
|
174
|
+
return ((_chainInfo$evmInfo3 = chainInfo.evmInfo) === null || _chainInfo$evmInfo3 === void 0 ? void 0 : (_chainInfo$evmInfo3$s = _chainInfo$evmInfo3.supportSmartContract) === null || _chainInfo$evmInfo3$s === void 0 ? void 0 : _chainInfo$evmInfo3$s.includes(_AssetType.ERC20)) || false;
|
|
175
|
+
}
|
|
176
|
+
export function _isChainSupportWasmPSP22(chainInfo) {
|
|
177
|
+
var _chainInfo$substrateI10, _chainInfo$substrateI11;
|
|
178
|
+
return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_AssetType.PSP22)) || false;
|
|
179
|
+
}
|
|
180
|
+
export function _isChainSupportGRC20(chainInfo) {
|
|
181
|
+
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
182
|
+
return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_AssetType.GRC20)) || false;
|
|
183
|
+
}
|
|
172
184
|
export const _isSupportOrdinal = chain => {
|
|
173
185
|
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
174
186
|
return chains.includes(chain);
|
|
@@ -195,7 +207,7 @@ export function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
195
207
|
const result = [];
|
|
196
208
|
if (chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract) {
|
|
197
209
|
chainInfo.substrateInfo.supportSmartContract.forEach(assetType => {
|
|
198
|
-
if ([_AssetType.PSP22].includes(assetType)) {
|
|
210
|
+
if ([_AssetType.PSP22, _AssetType.GRC20].includes(assetType)) {
|
|
199
211
|
result.push(assetType);
|
|
200
212
|
}
|
|
201
213
|
});
|
|
@@ -251,6 +263,9 @@ export function _isTokenWasmSmartContract(tokenInfo) {
|
|
|
251
263
|
export function _isAssetSmartContractNft(assetInfo) {
|
|
252
264
|
return [_AssetType.PSP34, _AssetType.ERC721].includes(assetInfo.assetType);
|
|
253
265
|
}
|
|
266
|
+
export function _isTokenGearSmartContract(tokenInfo) {
|
|
267
|
+
return [_AssetType.GRC20, _AssetType.GRC721].includes(tokenInfo.assetType);
|
|
268
|
+
}
|
|
254
269
|
export function _parseAssetRefKey(originTokenSlug, destinationTokenSlug) {
|
|
255
270
|
return `${originTokenSlug}___${destinationTokenSlug}`;
|
|
256
271
|
}
|
|
@@ -278,16 +293,16 @@ export function _getXcmTransferType(originChainInfo, destinationChainInfo) {
|
|
|
278
293
|
return `${((_originChainInfo$subs = originChainInfo.substrateInfo) === null || _originChainInfo$subs === void 0 ? void 0 : _originChainInfo$subs.chainType) || ''}-${((_destinationChainInfo = destinationChainInfo.substrateInfo) === null || _destinationChainInfo === void 0 ? void 0 : _destinationChainInfo.chainType) || ''}`;
|
|
279
294
|
}
|
|
280
295
|
export function _isSubstrateRelayChain(chainInfo) {
|
|
281
|
-
var _chainInfo$
|
|
282
|
-
return ((_chainInfo$
|
|
296
|
+
var _chainInfo$substrateI14;
|
|
297
|
+
return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : _chainInfo$substrateI14.chainType) === _SubstrateChainType.RELAYCHAIN;
|
|
283
298
|
}
|
|
284
299
|
export function _isSubstrateParaChain(chainInfo) {
|
|
285
|
-
var _chainInfo$
|
|
286
|
-
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$
|
|
300
|
+
var _chainInfo$substrateI15;
|
|
301
|
+
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI15 = chainInfo.substrateInfo) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.chainType) === _SubstrateChainType.PARACHAIN;
|
|
287
302
|
}
|
|
288
303
|
export function _getEvmAbiExplorer(chainInfo) {
|
|
289
|
-
var _chainInfo$
|
|
290
|
-
return ((_chainInfo$
|
|
304
|
+
var _chainInfo$evmInfo4;
|
|
305
|
+
return ((_chainInfo$evmInfo4 = chainInfo.evmInfo) === null || _chainInfo$evmInfo4 === void 0 ? void 0 : _chainInfo$evmInfo4.abiExplorer) || '';
|
|
291
306
|
}
|
|
292
307
|
export function _isAssetValuable(assetInfo) {
|
|
293
308
|
return assetInfo.hasValue;
|
|
@@ -325,11 +340,11 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
325
340
|
return;
|
|
326
341
|
}
|
|
327
342
|
if (_isPureEvmChain(chainInfo)) {
|
|
328
|
-
var _chainInfo$
|
|
329
|
-
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
343
|
+
var _chainInfo$evmInfo5;
|
|
344
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo5 = chainInfo.evmInfo) === null || _chainInfo$evmInfo5 === void 0 ? void 0 : _chainInfo$evmInfo5.blockExplorer;
|
|
330
345
|
} else {
|
|
331
|
-
var _chainInfo$
|
|
332
|
-
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
346
|
+
var _chainInfo$substrateI16;
|
|
347
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.blockExplorer;
|
|
333
348
|
}
|
|
334
349
|
if (!blockExplorer) {
|
|
335
350
|
return undefined;
|
|
@@ -355,8 +370,8 @@ export const _isAssetAutoEnable = chainAsset => {
|
|
|
355
370
|
return chainAsset.metadata ? !!chainAsset.metadata.autoEnable : false;
|
|
356
371
|
};
|
|
357
372
|
export function _getCrowdloanUrlFromChain(chainInfo) {
|
|
358
|
-
var _chainInfo$
|
|
359
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
373
|
+
var _chainInfo$substrateI17;
|
|
374
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.crowdloanUrl) || '';
|
|
360
375
|
}
|
|
361
376
|
export function _isCustomProvider(providerKey) {
|
|
362
377
|
return providerKey.startsWith(_CUSTOM_PREFIX);
|
|
@@ -381,8 +396,8 @@ export const findChainInfoByChainId = (chainMap, chainId) => {
|
|
|
381
396
|
return null;
|
|
382
397
|
}
|
|
383
398
|
for (const chainInfo of Object.values(chainMap)) {
|
|
384
|
-
var _chainInfo$
|
|
385
|
-
if (((_chainInfo$
|
|
399
|
+
var _chainInfo$evmInfo6;
|
|
400
|
+
if (((_chainInfo$evmInfo6 = chainInfo.evmInfo) === null || _chainInfo$evmInfo6 === void 0 ? void 0 : _chainInfo$evmInfo6.evmChainId) === chainId) {
|
|
386
401
|
return chainInfo;
|
|
387
402
|
}
|
|
388
403
|
}
|
|
@@ -5,7 +5,7 @@ import fetch from 'cross-fetch';
|
|
|
5
5
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
6
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
7
7
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.62';
|
|
9
9
|
export async function fetchPatchData(slug) {
|
|
10
10
|
try {
|
|
11
11
|
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export const _STAKING_CHAIN_GROUP = {
|
|
5
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet'],
|
|
5
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet', 'vara_testnet'],
|
|
6
6
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network', 'polimec'],
|
|
7
7
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
8
8
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
|
|
9
9
|
// amplitude and kilt only share some common logic
|
|
10
10
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
11
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet'],
|
|
11
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet', 'vara_testnet'],
|
|
12
12
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
13
13
|
aleph: ['aleph', 'alephTest'],
|
|
14
14
|
// A0 has distinct tokenomics
|
|
@@ -502,6 +502,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
502
502
|
if (paramsCount === 2) {
|
|
503
503
|
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
504
504
|
} else {
|
|
505
|
+
// @ts-ignore
|
|
505
506
|
bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
|
|
506
507
|
}
|
|
507
508
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
@@ -512,6 +513,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
512
513
|
if (paramsCount === 2) {
|
|
513
514
|
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
514
515
|
} else {
|
|
516
|
+
// @ts-ignore
|
|
515
517
|
bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
|
|
516
518
|
}
|
|
517
519
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
@@ -619,6 +621,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
619
621
|
const slashingSpanCount = _slashingSpans !== null ? _slashingSpans.spanIndex : '0';
|
|
620
622
|
return chainApi.api.tx.staking.withdrawUnbonded(slashingSpanCount);
|
|
621
623
|
} else {
|
|
624
|
+
// @ts-ignore
|
|
622
625
|
return chainApi.api.tx.staking.withdrawUnbonded();
|
|
623
626
|
}
|
|
624
627
|
}
|