@subwallet/extension-base 1.0.1 → 1.0.2-1b
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/KoniTypes.d.ts +25 -36
- package/background/KoniTypes.js +12 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +14 -8
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +13 -28
- package/cjs/koni/api/dotsama/balance.js +60 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
- package/cjs/koni/api/staking/bonding/astar.js +37 -238
- package/cjs/koni/api/staking/bonding/index.js +26 -14
- package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
- package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
- package/cjs/koni/api/staking/bonding/utils.js +55 -10
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +3 -5
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +179 -77
- package/cjs/koni/background/handlers/Extension.js +231 -195
- package/cjs/koni/background/handlers/State.js +147 -111
- package/cjs/koni/background/handlers/Tabs.js +48 -39
- package/cjs/koni/background/subscription.js +64 -56
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +39 -6
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +75 -0
- package/cjs/services/event-service/types.js +11 -0
- package/cjs/services/history-service/index.js +46 -21
- package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +15 -3
- package/cjs/services/price-service/index.js +15 -18
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +53 -34
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +8 -18
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +66 -22
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +30 -26
- package/constants/index.d.ts +8 -13
- package/constants/index.js +8 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +33 -197
- package/koni/api/dotsama/transfer.js +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +167 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +1 -2
- package/koni/api/staking/bonding/amplitude.js +22 -13
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +39 -231
- package/koni/api/staking/bonding/index.d.ts +5 -2
- package/koni/api/staking/bonding/index.js +27 -17
- package/koni/api/staking/bonding/paraChain.d.ts +4 -1
- package/koni/api/staking/bonding/paraChain.js +101 -14
- package/koni/api/staking/bonding/relayChain.d.ts +6 -2
- package/koni/api/staking/bonding/relayChain.js +172 -17
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +53 -11
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +3 -3
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +5 -7
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +179 -76
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +161 -125
- package/koni/background/handlers/State.d.ts +21 -20
- package/koni/background/handlers/State.js +144 -111
- package/koni/background/handlers/Tabs.js +30 -20
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +64 -58
- package/package.json +63 -18
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +40 -9
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +63 -0
- package/services/event-service/types.d.ts +28 -0
- package/services/event-service/types.js +4 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +46 -21
- package/services/history-service/subsquid-multi-chain-history.js +22 -13
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +15 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -18
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +44 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +53 -34
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +3 -3
- package/services/storage-service/db-stores/Nft.js +8 -17
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +66 -22
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +2 -1
- package/utils/index.js +26 -23
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
+
import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { _KNOWN_CHAIN_INFLATION_PARAMS, _STAKING_CHAIN_GROUP, _SUBSTRATE_DEFAULT_INFLATION_PARAMS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
6
|
import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
7
|
-
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO } from '@polkadot/util';
|
|
7
|
+
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
|
8
8
|
export let PalletParachainStakingRequestType;
|
|
9
9
|
(function (PalletParachainStakingRequestType) {
|
|
10
10
|
PalletParachainStakingRequestType["REVOKE"] = "revoke";
|
|
11
11
|
PalletParachainStakingRequestType["DECREASE"] = "decrease";
|
|
12
12
|
PalletParachainStakingRequestType["BOND_LESS"] = "bondLess";
|
|
13
13
|
})(PalletParachainStakingRequestType || (PalletParachainStakingRequestType = {}));
|
|
14
|
+
export function parsePoolStashAddress(api, index, poolId, poolsPalletId) {
|
|
15
|
+
const ModPrefix = stringToU8a('modl');
|
|
16
|
+
const U32Opts = {
|
|
17
|
+
bitLength: 32,
|
|
18
|
+
isLe: true
|
|
19
|
+
};
|
|
20
|
+
const EmptyH256 = new Uint8Array(32);
|
|
21
|
+
return api.registry.createType('AccountId32', u8aConcat(ModPrefix, poolsPalletId, new Uint8Array([index]), bnToU8a(new BN(poolId.toString()), U32Opts), EmptyH256)).toString();
|
|
22
|
+
}
|
|
14
23
|
export function transformPoolName(input) {
|
|
15
24
|
return input.replace(/[^\x20-\x7E]/g, '');
|
|
16
25
|
}
|
|
@@ -116,11 +125,8 @@ export function getBondedValidators(nominations) {
|
|
|
116
125
|
const bondedValidators = [];
|
|
117
126
|
let nominationCount = 0;
|
|
118
127
|
for (const nomination of nominations) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
nominationCount += 1;
|
|
122
|
-
bondedValidators.push(reformatAddress(nomination.validatorAddress, 0));
|
|
123
|
-
}
|
|
128
|
+
nominationCount += 1;
|
|
129
|
+
bondedValidators.push(reformatAddress(nomination.validatorAddress, 0));
|
|
124
130
|
}
|
|
125
131
|
return {
|
|
126
132
|
nominationCount,
|
|
@@ -130,7 +136,9 @@ export function getBondedValidators(nominations) {
|
|
|
130
136
|
export function isUnstakeAll(selectedValidator, nominations, unstakeAmount) {
|
|
131
137
|
let isUnstakeAll = false;
|
|
132
138
|
for (const nomination of nominations) {
|
|
133
|
-
|
|
139
|
+
const parsedValidatorAddress = reformatAddress(nomination.validatorAddress, 0);
|
|
140
|
+
const parsedSelectedValidator = reformatAddress(selectedValidator, 0);
|
|
141
|
+
if (parsedValidatorAddress === parsedSelectedValidator) {
|
|
134
142
|
if (unstakeAmount === nomination.activeStake) {
|
|
135
143
|
isUnstakeAll = true;
|
|
136
144
|
}
|
|
@@ -147,13 +155,28 @@ export let StakingAction;
|
|
|
147
155
|
StakingAction["CLAIM_REWARD"] = "CLAIM_REWARD";
|
|
148
156
|
StakingAction["CANCEL_UNSTAKE"] = "CANCEL_UNSTAKE";
|
|
149
157
|
})(StakingAction || (StakingAction = {}));
|
|
150
|
-
export function
|
|
158
|
+
export function getStakingAvailableActionsByChain(chain, type) {
|
|
159
|
+
if (type === StakingType.POOLED) {
|
|
160
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CLAIM_REWARD];
|
|
161
|
+
}
|
|
162
|
+
if (_STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
163
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CANCEL_UNSTAKE];
|
|
164
|
+
} else if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
165
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CLAIM_REWARD];
|
|
166
|
+
} else if (_STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
167
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW];
|
|
168
|
+
}
|
|
169
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CANCEL_UNSTAKE];
|
|
170
|
+
}
|
|
171
|
+
export function getStakingAvailableActionsByNominator(nominatorMetadata, unclaimedReward) {
|
|
151
172
|
const result = [StakingAction.STAKE];
|
|
152
173
|
const bnActiveStake = new BN(nominatorMetadata.activeStake);
|
|
153
174
|
if (nominatorMetadata.activeStake && bnActiveStake.gt(BN_ZERO)) {
|
|
154
175
|
result.push(StakingAction.UNSTAKE);
|
|
155
|
-
const
|
|
156
|
-
|
|
176
|
+
const isAstarNetwork = _STAKING_CHAIN_GROUP.astar.includes(nominatorMetadata.chain);
|
|
177
|
+
const isAmplitudeNetwork = _STAKING_CHAIN_GROUP.amplitude.includes(nominatorMetadata.chain);
|
|
178
|
+
const bnUnclaimedReward = new BN(unclaimedReward || '0');
|
|
179
|
+
if ((nominatorMetadata.type === StakingType.POOLED || isAmplitudeNetwork) && bnUnclaimedReward.gt(BN_ZERO) || isAstarNetwork) {
|
|
157
180
|
result.push(StakingAction.CLAIM_REWARD);
|
|
158
181
|
}
|
|
159
182
|
}
|
|
@@ -195,4 +218,23 @@ export function getWithdrawalInfo(nominatorMetadata) {
|
|
|
195
218
|
}
|
|
196
219
|
}
|
|
197
220
|
return result;
|
|
221
|
+
}
|
|
222
|
+
export function getStakingStatusByNominations(bnTotalActiveStake, nominationList) {
|
|
223
|
+
let stakingStatus = StakingStatus.EARNING_REWARD;
|
|
224
|
+
if (bnTotalActiveStake.isZero()) {
|
|
225
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
226
|
+
} else {
|
|
227
|
+
let invalidDelegationCount = 0;
|
|
228
|
+
for (const nomination of nominationList) {
|
|
229
|
+
if (nomination.status === StakingStatus.NOT_EARNING) {
|
|
230
|
+
invalidDelegationCount += 1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (invalidDelegationCount > 0 && invalidDelegationCount < nominationList.length) {
|
|
234
|
+
stakingStatus = StakingStatus.PARTIALLY_EARNING;
|
|
235
|
+
} else if (invalidDelegationCount === nominationList.length) {
|
|
236
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return stakingStatus;
|
|
198
240
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
4
5
|
import { _PSP22_ABI, _PSP34_ABI } from '@subwallet/extension-base/services/chain-service/helper';
|
|
5
6
|
import { ContractPromise } from '@polkadot/api-contract';
|
|
6
7
|
export function getPSP22ContractPromise(apiPromise, contractAddress) {
|
|
@@ -14,10 +15,10 @@ export async function getPSP34TransferExtrinsic(networkKey, substrateApi, sender
|
|
|
14
15
|
const onChainOption = params.onChainOption;
|
|
15
16
|
try {
|
|
16
17
|
const contractPromise = getPSP34ContractPromise(substrateApi.api, contractAddress);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const gasLimit = await getWasmContractGasLimit(substrateApi.api, senderAddress, 'psp34::transfer', contractPromise, {}, [recipientAddress, onChainOption, {}]);
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
21
22
|
return contractPromise.tx['psp34::transfer']({
|
|
22
23
|
gasLimit
|
|
23
24
|
}, recipientAddress, onChainOption, {});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import { ContractPromise } from '@polkadot/api-contract';
|
|
3
|
+
import { WeightV2 } from '@polkadot/types/interfaces';
|
|
4
|
+
import { Codec } from '@polkadot/types/types';
|
|
5
|
+
export declare function getWasmContractGasLimit(api: ApiPromise, callerAddress: string, message: string, contract: ContractPromise, options?: {}, args?: never[]): Promise<Codec>;
|
|
6
|
+
export declare function getDefaultWeightV2(apiPromise: ApiPromise, isFallback?: boolean): WeightV2;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BN } from '@polkadot/util';
|
|
5
|
+
const MAX_CALL_WEIGHT = '5000000000000';
|
|
6
|
+
const DEFAULT_REF_TIME = '1000000000000';
|
|
7
|
+
const toContractAbiMessage = (contractPromise, message) => {
|
|
8
|
+
const value = contractPromise.abi.messages.find(m => m.method === message);
|
|
9
|
+
if (!value) {
|
|
10
|
+
const messages = contractPromise === null || contractPromise === void 0 ? void 0 : contractPromise.abi.messages.map(m => m.method).join(', ');
|
|
11
|
+
const error = `"${message}" not found in metadata.spec.messages: [${messages}]`;
|
|
12
|
+
console.error(error);
|
|
13
|
+
return {
|
|
14
|
+
ok: false,
|
|
15
|
+
error
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
ok: true,
|
|
20
|
+
value
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export async function getWasmContractGasLimit(api, callerAddress, message, contract, options = {}, args = []) {
|
|
24
|
+
try {
|
|
25
|
+
var _abiMessage$value;
|
|
26
|
+
const abiMessage = toContractAbiMessage(contract, message);
|
|
27
|
+
if (!abiMessage.ok) {
|
|
28
|
+
return getDefaultWeightV2(api, true);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const {
|
|
33
|
+
gasLimit,
|
|
34
|
+
storageDepositLimit,
|
|
35
|
+
value
|
|
36
|
+
} = options;
|
|
37
|
+
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
const {
|
|
40
|
+
gasRequired
|
|
41
|
+
} = await api.call.contractsApi.call(callerAddress, contract.address, value !== null && value !== void 0 ? value : new BN(0), gasLimit !== null && gasLimit !== void 0 ? gasLimit : null, storageDepositLimit !== null && storageDepositLimit !== void 0 ? storageDepositLimit : null, abiMessage === null || abiMessage === void 0 ? void 0 : (_abiMessage$value = abiMessage.value) === null || _abiMessage$value === void 0 ? void 0 : _abiMessage$value.toU8a(args));
|
|
42
|
+
return gasRequired;
|
|
43
|
+
} catch {
|
|
44
|
+
return getDefaultWeightV2(api, true);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getDefaultWeightV2(apiPromise, isFallback) {
|
|
48
|
+
const proofSize = isFallback ? 3407872 : MAX_CALL_WEIGHT; // TODO: handle error better
|
|
49
|
+
const refTime = isFallback ? 32490000000 : DEFAULT_REF_TIME;
|
|
50
|
+
return apiPromise.registry.createType('WeightV2', {
|
|
51
|
+
refTime,
|
|
52
|
+
proofSize
|
|
53
|
+
});
|
|
54
|
+
}
|
package/koni/api/xcm/index.js
CHANGED
|
@@ -27,115 +27,4 @@ export const createXcmExtrinsic = async ({
|
|
|
27
27
|
}
|
|
28
28
|
console.log('XCM extrinsic: ', extrinsic.toHex());
|
|
29
29
|
return extrinsic;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// TODO: add + refine logic for more chains
|
|
33
|
-
// export function updateXcmResponseTxResult (
|
|
34
|
-
// networkKey: string,
|
|
35
|
-
// tokenInfo: _ChainAsset,
|
|
36
|
-
// response: TransactionResponse,
|
|
37
|
-
// records: EventRecord[]
|
|
38
|
-
// ) {
|
|
39
|
-
// if (!response.txResult) {
|
|
40
|
-
// response.txResult = { change: '0' };
|
|
41
|
-
// }
|
|
42
|
-
//
|
|
43
|
-
// let isFeeUseMainTokenSymbol = true;
|
|
44
|
-
//
|
|
45
|
-
// for (let index = 0; index < records.length; index++) {
|
|
46
|
-
// const record = records[index];
|
|
47
|
-
//
|
|
48
|
-
// if (_XCM_CHAIN_GROUP.acala.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
49
|
-
// if (record.event.section === 'currencies' &&
|
|
50
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
51
|
-
// if (index === 0) {
|
|
52
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
53
|
-
// response.txResult.fee = record.event.data[3]?.toString() || '0';
|
|
54
|
-
// response.txResult.feeSymbol = tokenInfo.symbol;
|
|
55
|
-
//
|
|
56
|
-
// isFeeUseMainTokenSymbol = false;
|
|
57
|
-
// } else {
|
|
58
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
59
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
60
|
-
// }
|
|
61
|
-
// }
|
|
62
|
-
//
|
|
63
|
-
// if (record.event.section === 'tokens' &&
|
|
64
|
-
// record.event.method.toLowerCase() === 'withdrawn') {
|
|
65
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
66
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
67
|
-
// }
|
|
68
|
-
// } else if (_XCM_CHAIN_GROUP.kintsugi.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
69
|
-
// if (record.event.section === 'tokens' &&
|
|
70
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
71
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
72
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
73
|
-
// }
|
|
74
|
-
// } else if (_XCM_CHAIN_GROUP.genshiro.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
75
|
-
// if (record.event.section === 'eqBalances' &&
|
|
76
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
77
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
78
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
79
|
-
// }
|
|
80
|
-
// } else if (_XCM_CHAIN_GROUP.bifrost.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
81
|
-
// if (record.event.section === 'tokens' &&
|
|
82
|
-
// record.event.method.toLowerCase() === 'withdrawn') {
|
|
83
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
84
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
85
|
-
// } else if (record.event.section === 'balances' &&
|
|
86
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
87
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
88
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
89
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
90
|
-
// }
|
|
91
|
-
// } else if (_XCM_CHAIN_GROUP.astar.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
92
|
-
// if (record.event.section === 'assets' &&
|
|
93
|
-
// record.event.method.toLowerCase() === 'burned') {
|
|
94
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
95
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
96
|
-
// }
|
|
97
|
-
// } else if (_XCM_CHAIN_GROUP.moonbeam.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
98
|
-
// if (record.event.section === 'assets' &&
|
|
99
|
-
// record.event.method.toLowerCase() === 'burned') {
|
|
100
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
101
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
102
|
-
// }
|
|
103
|
-
// } else if (_XCM_CHAIN_GROUP.statemine.includes(networkKey)) {
|
|
104
|
-
// if (!_isNativeToken(tokenInfo)) {
|
|
105
|
-
// if (record.event.section === 'assets' &&
|
|
106
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
107
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
108
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
109
|
-
// }
|
|
110
|
-
// } else {
|
|
111
|
-
// if (record.event.section === 'balances' &&
|
|
112
|
-
// record.event.method.toLowerCase() === 'withdraw') {
|
|
113
|
-
// response.txResult.change = record.event.data[1]?.toString() || '0';
|
|
114
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
115
|
-
// }
|
|
116
|
-
// }
|
|
117
|
-
// } else {
|
|
118
|
-
// if (record.event.section === 'balances' &&
|
|
119
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
120
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
121
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
122
|
-
// } else if (record.event.section === 'xTokens' &&
|
|
123
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
124
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
125
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
//
|
|
129
|
-
// if (isFeeUseMainTokenSymbol && record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
130
|
-
// if (!response.txResult.fee) {
|
|
131
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
132
|
-
// response.txResult.fee = record.event.data[1]?.toString() || '0';
|
|
133
|
-
// }
|
|
134
|
-
// } else if (isFeeUseMainTokenSymbol && record.event.section === 'tokens' && record.event.method.toLowerCase() === 'withdrawn') {
|
|
135
|
-
// if (!response.txResult.fee) {
|
|
136
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
137
|
-
// response.txResult.fee = record.event.data[2]?.toString() || '0';
|
|
138
|
-
// }
|
|
139
|
-
// }
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
30
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getBeneficiary, getDestWeight } from '@subwallet/extension-base/koni/api/xcm/utils';
|
|
5
5
|
import { _getSubstrateParaId, _getXcmAssetMultilocation, _isSubstrateParaChain, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
function getDestinationChainLocation(destinationChainInfo) {
|
|
7
7
|
if (_isSubstrateParaChain(destinationChainInfo)) {
|
|
@@ -36,13 +36,13 @@ function getAssetLocation(tokenInfo, sendingValue) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
export function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
39
|
-
const weightParam =
|
|
39
|
+
const weightParam = getDestWeight();
|
|
40
40
|
const beneficiary = getBeneficiary(originChainInfo, destinationChainInfo, recipientAddress);
|
|
41
41
|
const destination = getDestinationChainLocation(destinationChainInfo);
|
|
42
42
|
const assetLocation = getAssetLocation(tokenInfo, value);
|
|
43
43
|
let method = 'limitedReserveTransferAssets';
|
|
44
44
|
if (['astar', 'shiden'].includes(originChainInfo.slug)) {
|
|
45
|
-
method = '
|
|
45
|
+
method = 'limitedReserveWithdrawAssets';
|
|
46
46
|
} else if (_isSubstrateRelayChain(destinationChainInfo)) {
|
|
47
47
|
method = 'limitedTeleportAssets';
|
|
48
48
|
}
|
package/koni/api/xcm/utils.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
-
export declare const FOUR_INSTRUCTIONS_WEIGHT
|
|
2
|
+
export declare const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
|
|
3
|
+
export declare const FOUR_INSTRUCTIONS_LIMITED_WEIGHT: {
|
|
3
4
|
Limited: number;
|
|
4
5
|
};
|
|
5
|
-
export declare const POLKADOT_LIMITED_WEIGHT = 1000000000;
|
|
6
|
-
export declare const POLKADOT_UNLIMITED_WEIGHT = "Unlimited";
|
|
7
6
|
export declare function getReceiverLocation(originChainInfo: _ChainInfo, destinationChainInfo: _ChainInfo, toAddress: string): Record<string, any>;
|
|
8
|
-
export declare function getBeneficiary(originChainInfo: _ChainInfo, destinationChainInfo: _ChainInfo, recipientAddress: string): {
|
|
9
|
-
|
|
7
|
+
export declare function getBeneficiary(originChainInfo: _ChainInfo, destinationChainInfo: _ChainInfo, recipientAddress: string, version?: string): {
|
|
8
|
+
[x: string]: {
|
|
10
9
|
parents: number;
|
|
11
10
|
interior: {
|
|
12
11
|
X1: Record<string, any>;
|
|
13
12
|
};
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
|
-
export declare
|
|
15
|
+
export declare function getDestWeight(): string;
|
package/koni/api/xcm/utils.js
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
|
-
import {
|
|
5
|
+
import { _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
|
|
7
|
-
export const FOUR_INSTRUCTIONS_WEIGHT =
|
|
7
|
+
export const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
|
|
8
|
+
export const FOUR_INSTRUCTIONS_LIMITED_WEIGHT = {
|
|
8
9
|
Limited: 5000000000
|
|
9
10
|
};
|
|
10
|
-
export const POLKADOT_LIMITED_WEIGHT = 1000000000;
|
|
11
|
-
export const POLKADOT_UNLIMITED_WEIGHT = 'Unlimited';
|
|
12
11
|
|
|
13
12
|
// get multilocation for destination chain from a parachain
|
|
14
13
|
|
|
15
14
|
export function getReceiverLocation(originChainInfo, destinationChainInfo, toAddress) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (destinationChainInfo.slug === COMMON_CHAIN_SLUGS.ASTAR_EVM) {
|
|
16
|
+
const ss58Address = evmToAddress(toAddress, 2006); // TODO: shouldn't pass addressPrefix directly
|
|
17
|
+
|
|
19
18
|
return {
|
|
20
19
|
AccountId32: {
|
|
21
20
|
network: 'Any',
|
|
@@ -38,10 +37,10 @@ export function getReceiverLocation(originChainInfo, destinationChainInfo, toAdd
|
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
|
-
export function getBeneficiary(originChainInfo, destinationChainInfo, recipientAddress) {
|
|
40
|
+
export function getBeneficiary(originChainInfo, destinationChainInfo, recipientAddress, version = 'V1') {
|
|
42
41
|
const receiverLocation = getReceiverLocation(originChainInfo, destinationChainInfo, recipientAddress);
|
|
43
42
|
return {
|
|
44
|
-
|
|
43
|
+
[version]: {
|
|
45
44
|
parents: 0,
|
|
46
45
|
interior: {
|
|
47
46
|
X1: receiverLocation
|
|
@@ -49,4 +48,10 @@ export function getBeneficiary(originChainInfo, destinationChainInfo, recipientA
|
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
export
|
|
51
|
+
export function getDestWeight() {
|
|
52
|
+
return 'Unlimited';
|
|
53
|
+
// return api.tx.xTokens.transfer.meta.args[3].type.toString() ===
|
|
54
|
+
// 'XcmV2WeightLimit'
|
|
55
|
+
// ? 'Unlimited'
|
|
56
|
+
// : FOUR_INSTRUCTIONS_WEIGHT;
|
|
57
|
+
}
|
package/koni/api/xcm/xTokens.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { FOUR_INSTRUCTIONS_WEIGHT,
|
|
4
|
+
import { FOUR_INSTRUCTIONS_WEIGHT, getDestWeight, getReceiverLocation } from '@subwallet/extension-base/koni/api/xcm/utils';
|
|
5
5
|
import { _XCM_TYPE } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
|
-
import { _getSubstrateParaId, _getXcmAssetId, _getXcmAssetMultilocation, _getXcmAssetType, _getXcmTransferType, _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
|
+
import { _getSubstrateParaId, _getTokenOnChainInfo, _getXcmAssetId, _getXcmAssetMultilocation, _getXcmAssetType, _getXcmTransferType, _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
7
|
function getCurrencyId(tokenInfo) {
|
|
8
|
-
var _tokenInfo$metadata2;
|
|
9
8
|
if (['acala', 'karura'].includes(tokenInfo.originChain) && _isNativeToken(tokenInfo)) {
|
|
10
9
|
return _getXcmAssetMultilocation(tokenInfo);
|
|
11
10
|
} else if (['moonbeam', 'moonbase', 'moonriver'].includes(tokenInfo.originChain)) {
|
|
@@ -15,10 +14,9 @@ function getCurrencyId(tokenInfo) {
|
|
|
15
14
|
[tokenType]: assetId
|
|
16
15
|
};
|
|
17
16
|
} else if (['pioneer'].includes(tokenInfo.originChain)) {
|
|
18
|
-
|
|
19
|
-
return (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.multilocation;
|
|
17
|
+
return _getXcmAssetMultilocation(tokenInfo);
|
|
20
18
|
}
|
|
21
|
-
return (
|
|
19
|
+
return _getTokenOnChainInfo(tokenInfo);
|
|
22
20
|
}
|
|
23
21
|
function getMultiLocationForXtokensPallet(originChainInfo, destinationChainInfo, toAddress) {
|
|
24
22
|
const xcmType = _getXcmTransferType(originChainInfo, destinationChainInfo);
|
|
@@ -50,6 +48,6 @@ function getMultiLocationForXtokensPallet(originChainInfo, destinationChainInfo,
|
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
export function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
53
|
-
const weightParam =
|
|
51
|
+
const weightParam = ['pioneer'].includes(originChainInfo.slug) ? FOUR_INSTRUCTIONS_WEIGHT : getDestWeight();
|
|
54
52
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, getMultiLocationForXtokensPallet(originChainInfo, destinationChainInfo, recipientAddress), weightParam);
|
|
55
53
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getBeneficiary, getDestWeight } from '@subwallet/extension-base/koni/api/xcm/utils';
|
|
5
5
|
import { _getSubstrateParaId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
|
-
function getDestinationChainLocation(destinationChainInfo) {
|
|
6
|
+
function getDestinationChainLocation(destinationChainInfo, version = 'V1') {
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
[version]: {
|
|
9
9
|
parents: 0,
|
|
10
10
|
interior: {
|
|
11
11
|
X1: {
|
|
@@ -15,10 +15,10 @@ function getDestinationChainLocation(destinationChainInfo) {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function getTokenLocation(sendingValue) {
|
|
18
|
+
function getTokenLocation(sendingValue, version = 'V2') {
|
|
19
19
|
return {
|
|
20
20
|
// always native token of relaychain
|
|
21
|
-
|
|
21
|
+
[version]: [{
|
|
22
22
|
id: {
|
|
23
23
|
Concrete: {
|
|
24
24
|
parents: 0,
|
|
@@ -34,10 +34,11 @@ function getTokenLocation(sendingValue) {
|
|
|
34
34
|
|
|
35
35
|
// this pallet is only used by Relaychains
|
|
36
36
|
export function getExtrinsicByXcmPalletPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
37
|
-
const weightParam =
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
37
|
+
const weightParam = getDestWeight();
|
|
38
|
+
const xcmVer = ['kusama'].includes(originChainInfo.slug) ? 'V2' : 'V1';
|
|
39
|
+
const destination = getDestinationChainLocation(destinationChainInfo, xcmVer);
|
|
40
|
+
const beneficiary = getBeneficiary(originChainInfo, destinationChainInfo, recipientAddress, xcmVer);
|
|
41
|
+
const tokenLocation = getTokenLocation(value, xcmVer);
|
|
41
42
|
let method = 'limitedReserveTransferAssets';
|
|
42
43
|
if (['statemint', 'statemine'].includes(destinationChainInfo.slug)) {
|
|
43
44
|
method = 'limitedTeleportAssets';
|
|
@@ -15,15 +15,16 @@ export declare class KoniCron {
|
|
|
15
15
|
constructor(state: KoniState, subscriptions: KoniSubscription, dbService: DatabaseService);
|
|
16
16
|
private cronMap;
|
|
17
17
|
private subjectMap;
|
|
18
|
+
private eventHandler?;
|
|
18
19
|
getCron: (name: string) => any;
|
|
19
20
|
getSubjectMap: (name: string) => any;
|
|
20
21
|
addCron: (name: string, callback: (param?: any) => void, interval: number, runFirst?: boolean) => void;
|
|
21
22
|
addSubscribeCron: <T>(name: string, callback: (subject: Subject<T>) => void, interval: number) => void;
|
|
22
23
|
removeCron: (name: string) => void;
|
|
23
24
|
removeAllCrons: () => void;
|
|
24
|
-
init: () => void;
|
|
25
25
|
start: () => void;
|
|
26
26
|
stop: () => void;
|
|
27
|
+
updateApiMapStatus: () => void;
|
|
27
28
|
recoverApiMap: () => void;
|
|
28
29
|
refreshNft: (address: string, apiMap: ApiMap, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>) => () => void;
|
|
29
30
|
resetNft: (newAddress: string) => void;
|
|
@@ -34,4 +35,8 @@ export declare class KoniCron {
|
|
|
34
35
|
checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
|
|
35
36
|
updateChainStakingMetadata: (chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>) => () => void;
|
|
36
37
|
updateNominatorMetadata: (address: string, chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>) => () => void;
|
|
38
|
+
reloadNft(): Promise<boolean>;
|
|
39
|
+
reloadStaking(): Promise<boolean>;
|
|
40
|
+
private needUpdateNft;
|
|
41
|
+
private needUpdateStaking;
|
|
37
42
|
}
|