@subwallet/extension-base 1.1.33-beta.0 → 1.1.34-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/KoniTypes.d.ts +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +16 -19
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +17 -10
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +21 -3
- package/cjs/koni/background/handlers/Extension.js +69 -368
- package/cjs/koni/background/handlers/State.js +12 -18
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +104 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +19 -2
- package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
- package/cjs/services/chain-service/index.js +101 -40
- package/cjs/services/chain-service/utils.js +69 -7
- package/cjs/services/event-service/index.js +0 -5
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -6
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -63
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -249
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +2 -6
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +10 -13
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +18 -11
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +4 -0
- package/koni/background/cron.js +22 -4
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -327
- package/koni/background/handlers/State.d.ts +1 -6
- package/koni/background/handlers/State.js +12 -17
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +104 -8
- package/package.json +7 -320
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +13 -0
- package/services/chain-service/constants.js +15 -0
- package/services/chain-service/handler/SubstrateApi.js +10 -5
- package/services/chain-service/index.d.ts +9 -1
- package/services/chain-service/index.js +97 -37
- package/services/chain-service/utils.d.ts +10 -2
- package/services/chain-service/utils.js +67 -6
- package/services/event-service/index.d.ts +0 -2
- package/services/event-service/index.js +0 -5
- package/services/event-service/types.d.ts +0 -9
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -6
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -22
- package/services/storage-service/DatabaseService.js +0 -63
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +13 -6
- package/services/transaction-service/index.js +73 -247
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +0 -52
- package/utils/number.d.ts +1 -2
- package/utils/number.js +1 -2
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -30
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -262
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -81
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
- package/cjs/services/earning-service/handlers/special.js +0 -493
- package/cjs/services/earning-service/service.js +0 -740
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -15
- package/services/earning-service/constants/chains.js +0 -22
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -113
- package/services/earning-service/handlers/base.js +0 -256
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -8
- package/services/earning-service/handlers/lending/base.js +0 -73
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -184
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
- package/services/earning-service/handlers/liquid-staking/base.js +0 -89
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -456
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -152
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -556
- package/services/earning-service/handlers/special.d.ts +0 -64
- package/services/earning-service/handlers/special.js +0 -485
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -729
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -58
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -47
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -252
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
import { AssetLogoMap, AssetRefMap, ChainAssetMap, ChainInfoMap, ChainLogoMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
5
|
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
6
|
-
import {
|
|
6
|
+
import { _DEFAULT_ACTIVE_CHAINS, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
|
|
8
8
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
9
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
11
11
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
12
|
-
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
14
|
-
import { MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
14
|
+
import { fetchStaticData, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
15
15
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
16
16
|
import Web3 from 'web3';
|
|
17
17
|
import { logger as createLogger } from '@polkadot/util/logger';
|
|
@@ -213,9 +213,8 @@ export class ChainService {
|
|
|
213
213
|
getActiveChainInfos() {
|
|
214
214
|
const result = {};
|
|
215
215
|
Object.values(this.getChainStateMap()).forEach(chainState => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
result[chainState.slug] = chainInfo;
|
|
216
|
+
if (chainState.active) {
|
|
217
|
+
result[chainState.slug] = this.getChainInfoByKey(chainState.slug);
|
|
219
218
|
}
|
|
220
219
|
});
|
|
221
220
|
return result;
|
|
@@ -396,9 +395,8 @@ export class ChainService {
|
|
|
396
395
|
await this.eventService.waitDatabaseReady;
|
|
397
396
|
|
|
398
397
|
// TODO: reconsider the flow of initiation
|
|
399
|
-
|
|
400
|
-
this.
|
|
401
|
-
this.dataMap.assetRefMap = latestAssetRefMap;
|
|
398
|
+
this.multiChainAssetMapSubject.next(MultiChainAssetMap);
|
|
399
|
+
this.dataMap.assetRefMap = AssetRefMap;
|
|
402
400
|
await this.initChains();
|
|
403
401
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
404
402
|
this.updateChainStateMapSubscription();
|
|
@@ -406,7 +404,54 @@ export class ChainService {
|
|
|
406
404
|
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
407
405
|
await this.initApis();
|
|
408
406
|
await this.initAssetSettings();
|
|
407
|
+
this.checkLatestData();
|
|
409
408
|
}
|
|
409
|
+
checkLatestData() {
|
|
410
|
+
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
411
|
+
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestData.bind(this), LATEST_CHAIN_DATA_FETCHING_INTERVAL);
|
|
412
|
+
}
|
|
413
|
+
stopCheckLatestChainData() {
|
|
414
|
+
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
415
|
+
}
|
|
416
|
+
handleLatestProviderData(latestChainInfo) {
|
|
417
|
+
try {
|
|
418
|
+
if (latestChainInfo && latestChainInfo.length > 0) {
|
|
419
|
+
const {
|
|
420
|
+
needUpdateChainApiList,
|
|
421
|
+
storedChainInfoList
|
|
422
|
+
} = updateLatestChainInfo(this.dataMap, latestChainInfo);
|
|
423
|
+
this.dbService.bulkUpdateChainStore(storedChainInfoList).catch(console.error);
|
|
424
|
+
this.updateChainSubscription();
|
|
425
|
+
needUpdateChainApiList.forEach(chainInfo => {
|
|
426
|
+
console.log('Updating chain API for', chainInfo.slug);
|
|
427
|
+
this.initApiForChain(chainInfo).catch(console.error);
|
|
428
|
+
});
|
|
429
|
+
this.logger.log('Finished updating latest RPC providers');
|
|
430
|
+
}
|
|
431
|
+
} catch (e) {
|
|
432
|
+
console.error('Error fetching latest chain data');
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
handleLatestPriceId(latestPriceIds) {
|
|
436
|
+
Object.entries(latestPriceIds).forEach(([slug, priceId]) => {
|
|
437
|
+
if (this.dataMap.assetRegistry[slug]) {
|
|
438
|
+
this.dataMap.assetRegistry[slug].priceId = priceId;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
442
|
+
this.eventService.emit('asset.updateState', '');
|
|
443
|
+
this.logger.log('Finished updating latest price IDs');
|
|
444
|
+
}
|
|
445
|
+
handleLatestData() {
|
|
446
|
+
this.fetchLatestChainData().then(latestChainInfo => {
|
|
447
|
+
this.handleLatestProviderData(latestChainInfo);
|
|
448
|
+
}).catch(console.error);
|
|
449
|
+
|
|
450
|
+
// this.fetchLatestPriceIdsData().then((latestPriceIds) => {
|
|
451
|
+
// this.handleLatestPriceId(latestPriceIds);
|
|
452
|
+
// }).catch(console.error);
|
|
453
|
+
}
|
|
454
|
+
|
|
410
455
|
async initApis() {
|
|
411
456
|
const chainInfoMap = this.getChainInfoMap();
|
|
412
457
|
const chainStateMap = this.getChainStateMap();
|
|
@@ -562,8 +607,8 @@ export class ChainService {
|
|
|
562
607
|
}
|
|
563
608
|
return duplicatedSlug;
|
|
564
609
|
}
|
|
565
|
-
async
|
|
566
|
-
return
|
|
610
|
+
async fetchLatestChainData() {
|
|
611
|
+
return await fetchStaticData('chains');
|
|
567
612
|
// try {
|
|
568
613
|
// const timeout = new Promise((resolve) => {
|
|
569
614
|
// const id = setTimeout(() => {
|
|
@@ -600,9 +645,13 @@ export class ChainService {
|
|
|
600
645
|
// }
|
|
601
646
|
}
|
|
602
647
|
|
|
648
|
+
// @ts-ignore
|
|
649
|
+
async fetchLatestPriceIdsData() {
|
|
650
|
+
return await fetchStaticData('chain-assets/price-map');
|
|
651
|
+
}
|
|
603
652
|
async initChains() {
|
|
604
653
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
605
|
-
const
|
|
654
|
+
const defaultChainInfoMap = ChainInfoMap;
|
|
606
655
|
const storedChainSettingMap = {};
|
|
607
656
|
storedChainSettings.forEach(chainStoredSetting => {
|
|
608
657
|
storedChainSettingMap[chainStoredSetting.slug] = chainStoredSetting;
|
|
@@ -611,10 +660,13 @@ export class ChainService {
|
|
|
611
660
|
const deprecatedChains = [];
|
|
612
661
|
const deprecatedChainMap = {};
|
|
613
662
|
if (storedChainSettings.length === 0) {
|
|
614
|
-
this.dataMap.chainInfoMap =
|
|
615
|
-
Object.values(
|
|
663
|
+
this.dataMap.chainInfoMap = defaultChainInfoMap;
|
|
664
|
+
Object.values(defaultChainInfoMap).forEach(chainInfo => {
|
|
665
|
+
const {
|
|
666
|
+
providerKey
|
|
667
|
+
} = randomizeProvider(chainInfo.providers);
|
|
616
668
|
this.dataMap.chainStateMap[chainInfo.slug] = {
|
|
617
|
-
currentProvider:
|
|
669
|
+
currentProvider: providerKey,
|
|
618
670
|
slug: chainInfo.slug,
|
|
619
671
|
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
620
672
|
active: _DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug)
|
|
@@ -624,15 +676,15 @@ export class ChainService {
|
|
|
624
676
|
newStorageData.push({
|
|
625
677
|
...chainInfo,
|
|
626
678
|
active: _DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug),
|
|
627
|
-
currentProvider:
|
|
679
|
+
currentProvider: providerKey
|
|
628
680
|
});
|
|
629
681
|
});
|
|
630
682
|
} else {
|
|
631
|
-
const mergedChainInfoMap =
|
|
683
|
+
const mergedChainInfoMap = defaultChainInfoMap;
|
|
632
684
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
633
|
-
const chainInfo =
|
|
685
|
+
const chainInfo = defaultChainInfoMap[storedSlug];
|
|
634
686
|
|
|
635
|
-
// Network
|
|
687
|
+
// Network existed on change list
|
|
636
688
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
637
689
|
if (chainInfo) {
|
|
638
690
|
// Keep customer provider only
|
|
@@ -647,23 +699,27 @@ export class ChainService {
|
|
|
647
699
|
}
|
|
648
700
|
}
|
|
649
701
|
mergedChainInfoMap[storedSlug].providers = providers;
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
702
|
+
const {
|
|
703
|
+
providerKey
|
|
704
|
+
} = randomizeProvider(providers);
|
|
705
|
+
let selectedProvider = providerKey;
|
|
706
|
+
const storedProviderKey = storedChainInfo.currentProvider;
|
|
707
|
+
const storedProviderValue = storedChainInfo.providers[storedProviderKey] || '';
|
|
708
|
+
if (storedProviderValue !== null && storedProviderValue !== void 0 && storedProviderValue.startsWith('light') || storedProviderKey !== null && storedProviderKey !== void 0 && storedProviderKey.startsWith(_CUSTOM_PREFIX)) {
|
|
709
|
+
const savedProviderKey = Object.keys(providers).find(key => providers[key] === storedProviderValue);
|
|
710
|
+
if (savedProviderKey) {
|
|
711
|
+
selectedProvider = savedProviderKey;
|
|
661
712
|
}
|
|
662
713
|
}
|
|
714
|
+
|
|
715
|
+
// Merge current provider
|
|
716
|
+
// let currentProvider = storedChainInfo.currentProvider;
|
|
717
|
+
// const providerValue = storedChainInfo.providers[selectedProvider] || '';
|
|
718
|
+
|
|
663
719
|
const hasProvider = Object.values(providers).length > 0;
|
|
664
720
|
const canActive = hasProvider && chainInfo.chainStatus === _ChainStatus.ACTIVE;
|
|
665
721
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
666
|
-
currentProvider:
|
|
722
|
+
currentProvider: selectedProvider,
|
|
667
723
|
slug: storedSlug,
|
|
668
724
|
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
669
725
|
active: canActive && storedChainInfo.active
|
|
@@ -671,13 +727,13 @@ export class ChainService {
|
|
|
671
727
|
newStorageData.push({
|
|
672
728
|
...mergedChainInfoMap[storedSlug],
|
|
673
729
|
active: canActive && storedChainInfo.active,
|
|
674
|
-
currentProvider:
|
|
730
|
+
currentProvider: selectedProvider
|
|
675
731
|
});
|
|
676
732
|
} else if (_isCustomChain(storedSlug)) {
|
|
677
733
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
678
734
|
// only custom chains are left
|
|
679
735
|
// check custom chain duplicated with predefined chain => merge into predefined chain
|
|
680
|
-
const duplicatedDefaultSlug = this.checkExistedPredefinedChain(
|
|
736
|
+
const duplicatedDefaultSlug = this.checkExistedPredefinedChain(defaultChainInfoMap, (_storedChainInfo$subs = storedChainInfo.substrateInfo) === null || _storedChainInfo$subs === void 0 ? void 0 : _storedChainInfo$subs.genesisHash, (_storedChainInfo$evmI = storedChainInfo.evmInfo) === null || _storedChainInfo$evmI === void 0 ? void 0 : _storedChainInfo$evmI.evmChainId);
|
|
681
737
|
if (duplicatedDefaultSlug.length > 0) {
|
|
682
738
|
// merge custom chain with existed chain
|
|
683
739
|
mergedChainInfoMap[duplicatedDefaultSlug].providers = {
|
|
@@ -702,6 +758,7 @@ export class ChainService {
|
|
|
702
758
|
slug: storedSlug,
|
|
703
759
|
name: storedChainInfo.name,
|
|
704
760
|
providers: storedChainInfo.providers,
|
|
761
|
+
// TODO: review
|
|
705
762
|
evmInfo: storedChainInfo.evmInfo,
|
|
706
763
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
707
764
|
isTestnet: storedChainInfo.isTestnet,
|
|
@@ -711,6 +768,7 @@ export class ChainService {
|
|
|
711
768
|
};
|
|
712
769
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
713
770
|
currentProvider: storedChainInfo.currentProvider,
|
|
771
|
+
// TODO: review
|
|
714
772
|
slug: storedSlug,
|
|
715
773
|
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
716
774
|
active: storedChainInfo.active
|
|
@@ -718,7 +776,7 @@ export class ChainService {
|
|
|
718
776
|
newStorageData.push({
|
|
719
777
|
...mergedChainInfoMap[storedSlug],
|
|
720
778
|
active: storedChainInfo.active,
|
|
721
|
-
currentProvider: storedChainInfo.currentProvider
|
|
779
|
+
currentProvider: storedChainInfo.currentProvider // TODO: review
|
|
722
780
|
});
|
|
723
781
|
}
|
|
724
782
|
} else {
|
|
@@ -750,7 +808,7 @@ export class ChainService {
|
|
|
750
808
|
}
|
|
751
809
|
async initAssetRegistry(deprecatedCustomChainMap) {
|
|
752
810
|
const storedAssetRegistry = await this.dbService.getAllAssetStore();
|
|
753
|
-
const latestAssetRegistry =
|
|
811
|
+
const latestAssetRegistry = ChainAssetMap;
|
|
754
812
|
const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
|
|
755
813
|
|
|
756
814
|
// Fill out zk assets from latestAssetRegistry if not supported
|
|
@@ -1200,9 +1258,11 @@ export class ChainService {
|
|
|
1200
1258
|
}
|
|
1201
1259
|
async stopAllChainApis() {
|
|
1202
1260
|
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep()]);
|
|
1261
|
+
this.stopCheckLatestChainData();
|
|
1203
1262
|
}
|
|
1204
1263
|
async resumeAllChainApis() {
|
|
1205
1264
|
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp()]);
|
|
1265
|
+
this.checkLatestData();
|
|
1206
1266
|
}
|
|
1207
1267
|
checkAndUpdateStatusMapForChain(chainSlug) {
|
|
1208
1268
|
const substrateApiMap = this.getSubstrateApiMap();
|
|
@@ -1337,10 +1397,10 @@ export class ChainService {
|
|
|
1337
1397
|
return this.assetSettingSubject;
|
|
1338
1398
|
}
|
|
1339
1399
|
async getChainLogoMap() {
|
|
1340
|
-
return
|
|
1400
|
+
return Promise.resolve(ChainLogoMap);
|
|
1341
1401
|
}
|
|
1342
1402
|
async getAssetLogoMap() {
|
|
1343
|
-
return
|
|
1403
|
+
return Promise.resolve(AssetLogoMap);
|
|
1344
1404
|
}
|
|
1345
1405
|
resetWallet(resetAll) {
|
|
1346
1406
|
if (resetAll) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { BasicTokenInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
-
import { _ChainState } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
|
+
import { _ChainState, _DataMap } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
|
+
import { IChain } from '@subwallet/extension-base/services/storage-service/databases';
|
|
4
5
|
export declare function _isCustomChain(slug: string): boolean;
|
|
5
6
|
export declare function _isCustomAsset(slug: string): boolean;
|
|
6
7
|
export declare function _getCustomAssets(assetRegistry: Record<string, _ChainAsset>): Record<string, _ChainAsset>;
|
|
@@ -30,7 +31,6 @@ export declare function _getChainSubstrateAddressPrefix(chainInfo: _ChainInfo):
|
|
|
30
31
|
export declare function _isChainSupportNativeNft(chainInfo: _ChainInfo): boolean;
|
|
31
32
|
export declare function _isChainSupportEvmNft(chainInfo: _ChainInfo): boolean;
|
|
32
33
|
export declare function _isChainSupportWasmNft(chainInfo: _ChainInfo): boolean;
|
|
33
|
-
export declare const _isSupportOrdinal: (chain: string) => boolean;
|
|
34
34
|
export declare function _getNftTypesSupportedByChain(chainInfo: _ChainInfo): _AssetType[];
|
|
35
35
|
export declare function _getTokenTypesSupportedByChain(chainInfo: _ChainInfo): _AssetType[];
|
|
36
36
|
export declare function _getChainNativeTokenBasicInfo(chainInfo: _ChainInfo): BasicTokenInfo;
|
|
@@ -67,3 +67,11 @@ export declare function _generateCustomProviderKey(index: number): string;
|
|
|
67
67
|
export declare const findChainInfoByHalfGenesisHash: (chainMap: Record<string, _ChainInfo>, halfGenesisHash?: string) => _ChainInfo | null;
|
|
68
68
|
export declare const findChainInfoByChainId: (chainMap: Record<string, _ChainInfo>, chainId?: number) => _ChainInfo | null;
|
|
69
69
|
export declare function _isMantaZkAsset(chainAsset: _ChainAsset): boolean;
|
|
70
|
+
export declare function randomizeProvider(providers: Record<string, string>, excludedKeys?: string[]): {
|
|
71
|
+
providerKey: string;
|
|
72
|
+
providerValue: string;
|
|
73
|
+
};
|
|
74
|
+
export declare function updateLatestChainInfo(currentDataMap: _DataMap, latestChainInfoList: _ChainInfo[]): {
|
|
75
|
+
storedChainInfoList: IChain[];
|
|
76
|
+
needUpdateChainApiList: _ChainInfo[];
|
|
77
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { _AssetRefPath, _AssetType, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
4
|
+
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
5
5
|
import { _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
6
|
import { _CUSTOM_PREFIX, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
7
7
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -92,7 +92,7 @@ export function _getTokenMinAmount(tokenInfo) {
|
|
|
92
92
|
return tokenInfo.minAmount || '0';
|
|
93
93
|
}
|
|
94
94
|
export function _isChainEvmCompatible(chainInfo) {
|
|
95
|
-
return
|
|
95
|
+
return chainInfo.evmInfo !== undefined && chainInfo.evmInfo !== null;
|
|
96
96
|
}
|
|
97
97
|
export function _isNativeToken(tokenInfo) {
|
|
98
98
|
return tokenInfo.assetType === _AssetType.NATIVE;
|
|
@@ -147,10 +147,6 @@ export function _isChainSupportWasmNft(chainInfo) {
|
|
|
147
147
|
var _chainInfo$substrateI8, _chainInfo$substrateI9;
|
|
148
148
|
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;
|
|
149
149
|
}
|
|
150
|
-
export const _isSupportOrdinal = chain => {
|
|
151
|
-
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
152
|
-
return chains.includes(chain);
|
|
153
|
-
};
|
|
154
150
|
export function _getNftTypesSupportedByChain(chainInfo) {
|
|
155
151
|
const result = [];
|
|
156
152
|
if (chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract) {
|
|
@@ -362,4 +358,69 @@ export const findChainInfoByChainId = (chainMap, chainId) => {
|
|
|
362
358
|
};
|
|
363
359
|
export function _isMantaZkAsset(chainAsset) {
|
|
364
360
|
return _MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_ZK_ASSET_PREFIX);
|
|
361
|
+
}
|
|
362
|
+
export function randomizeProvider(providers, excludedKeys) {
|
|
363
|
+
if (Object.keys(providers).length === 0) {
|
|
364
|
+
return {
|
|
365
|
+
providerKey: '',
|
|
366
|
+
providerValue: ''
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
let isValid = false;
|
|
370
|
+
let selectedProviderKey = '';
|
|
371
|
+
let selectedProviderValue = '';
|
|
372
|
+
while (!isValid) {
|
|
373
|
+
var _selectedProviderValu, _selectedProviderKey;
|
|
374
|
+
const randomProvider = Math.floor(Math.random() * Object.keys(providers).length);
|
|
375
|
+
selectedProviderKey = Object.keys(providers)[randomProvider];
|
|
376
|
+
selectedProviderValue = providers[selectedProviderKey];
|
|
377
|
+
if (!((_selectedProviderValu = selectedProviderValue) !== null && _selectedProviderValu !== void 0 && _selectedProviderValu.startsWith('light')) && !((_selectedProviderKey = selectedProviderKey) !== null && _selectedProviderKey !== void 0 && _selectedProviderKey.startsWith(_CUSTOM_PREFIX)) && !(excludedKeys !== null && excludedKeys !== void 0 && excludedKeys.includes(selectedProviderKey))) {
|
|
378
|
+
// if it's light client, then re-randomize
|
|
379
|
+
isValid = true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
providerKey: selectedProviderKey,
|
|
384
|
+
providerValue: selectedProviderValue
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
export function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
|
|
388
|
+
const currentChainInfoMap = currentDataMap.chainInfoMap;
|
|
389
|
+
const currentChainStateMap = currentDataMap.chainStateMap;
|
|
390
|
+
const storedChainInfoList = [];
|
|
391
|
+
const needUpdateChainApiList = [];
|
|
392
|
+
latestChainInfoList.forEach(latestChainInfo => {
|
|
393
|
+
const currentChainInfo = currentChainInfoMap[latestChainInfo.slug];
|
|
394
|
+
const currentChainState = currentChainStateMap[latestChainInfo.slug];
|
|
395
|
+
const currentChainProviderValue = currentChainInfo === null || currentChainInfo === void 0 ? void 0 : currentChainInfo.providers[currentChainState === null || currentChainState === void 0 ? void 0 : currentChainState.currentProvider];
|
|
396
|
+
if (currentChainInfo && currentChainState) {
|
|
397
|
+
const preservedProvider = {};
|
|
398
|
+
Object.entries(currentChainInfo.providers).forEach(([providerKey, providerValue]) => {
|
|
399
|
+
if (providerValue !== null && providerValue !== void 0 && providerValue.startsWith('light') || providerKey !== null && providerKey !== void 0 && providerKey.startsWith(_CUSTOM_PREFIX)) {
|
|
400
|
+
preservedProvider[providerKey] = providerValue;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
currentChainInfo.providers = {
|
|
404
|
+
...latestChainInfo.providers,
|
|
405
|
+
...preservedProvider
|
|
406
|
+
};
|
|
407
|
+
const currentProviderNotFound = !Object.keys(currentChainInfo.providers).includes(currentChainState.currentProvider);
|
|
408
|
+
const currentProviderUpdated = Object.keys(currentChainInfo.providers).includes(currentChainState.currentProvider) && !Object.values(currentChainInfo.providers).includes(currentChainProviderValue);
|
|
409
|
+
if (currentChainInfo.chainStatus === _ChainStatus.ACTIVE && (currentProviderNotFound || currentProviderUpdated)) {
|
|
410
|
+
const {
|
|
411
|
+
providerKey
|
|
412
|
+
} = randomizeProvider(currentChainInfo.providers);
|
|
413
|
+
currentChainState.currentProvider = providerKey;
|
|
414
|
+
needUpdateChainApiList.push(currentChainInfo);
|
|
415
|
+
}
|
|
416
|
+
storedChainInfoList.push({
|
|
417
|
+
...currentChainInfo,
|
|
418
|
+
...currentChainState
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return {
|
|
423
|
+
storedChainInfoList,
|
|
424
|
+
needUpdateChainApiList
|
|
425
|
+
};
|
|
365
426
|
}
|
|
@@ -8,14 +8,12 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
8
8
|
readonly waitDatabaseReady: Promise<boolean>;
|
|
9
9
|
readonly waitKeyringReady: Promise<boolean>;
|
|
10
10
|
readonly waitAccountReady: Promise<boolean>;
|
|
11
|
-
readonly waitInjectReady: Promise<boolean>;
|
|
12
11
|
readonly waitChainReady: Promise<boolean>;
|
|
13
12
|
readonly waitAssetReady: Promise<boolean>;
|
|
14
13
|
readonly waitMigrateReady: Promise<boolean>;
|
|
15
14
|
readonly waitCampaignReady: Promise<boolean>;
|
|
16
15
|
readonly waitBuyTokenReady: Promise<boolean>;
|
|
17
16
|
readonly waitBuyServiceReady: Promise<boolean>;
|
|
18
|
-
readonly waitEarningReady: Promise<boolean>;
|
|
19
17
|
constructor();
|
|
20
18
|
private generateWaitPromise;
|
|
21
19
|
private setLazyTimeout;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
// Stateless service handle runtime event on background
|
|
5
5
|
|
|
6
|
-
import { TARGET_ENV } from '@subwallet/extension-base/utils';
|
|
7
6
|
import EventEmitter from 'eventemitter3';
|
|
8
7
|
const DEFAULT_LAZY_TIME = 300;
|
|
9
8
|
const LONG_LAZY_TIME = 900;
|
|
@@ -18,20 +17,16 @@ export class EventService extends EventEmitter {
|
|
|
18
17
|
this.waitDatabaseReady = this.generateWaitPromise('database.ready');
|
|
19
18
|
this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
|
|
20
19
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
21
|
-
// TODO: Need to merge logic on web-runner file
|
|
22
|
-
this.waitInjectReady = TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
|
|
23
20
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
24
21
|
this.waitAssetReady = this.generateWaitPromise('asset.ready');
|
|
25
22
|
this.waitMigrateReady = this.generateWaitPromise('migration.done');
|
|
26
23
|
this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
|
|
27
24
|
this.waitBuyTokenReady = this.generateWaitPromise('buy.tokens.ready');
|
|
28
25
|
this.waitBuyServiceReady = this.generateWaitPromise('buy.services.ready');
|
|
29
|
-
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
30
26
|
}
|
|
31
27
|
generateWaitPromise(eventType) {
|
|
32
28
|
return new Promise(resolve => {
|
|
33
29
|
this.once(eventType, isReady => {
|
|
34
|
-
console.log('===LOG generateWaitPromise eventType', eventType);
|
|
35
30
|
resolve(isReady);
|
|
36
31
|
});
|
|
37
32
|
});
|
|
@@ -5,20 +5,12 @@ export interface EventRegistry {
|
|
|
5
5
|
'general.wakeup': [boolean];
|
|
6
6
|
'crypto.ready': [boolean];
|
|
7
7
|
'database.ready': [boolean];
|
|
8
|
-
/** Password state ready */
|
|
9
8
|
'keyring.ready': [boolean];
|
|
10
|
-
/** Update current account */
|
|
11
9
|
'account.updateCurrent': [CurrentAccountInfo];
|
|
12
|
-
/** Account list loaded */
|
|
13
10
|
'account.ready': [boolean];
|
|
14
|
-
/** Add a new account */
|
|
15
11
|
'account.add': [string];
|
|
16
|
-
/** Update account */
|
|
17
12
|
'account.update': [string];
|
|
18
|
-
/** Remove a account */
|
|
19
13
|
'account.remove': [string];
|
|
20
|
-
/** Inject account done */
|
|
21
|
-
'inject.ready': [boolean];
|
|
22
14
|
'chain.ready': [boolean];
|
|
23
15
|
'chain.add': [string];
|
|
24
16
|
'chain.updateState': [string];
|
|
@@ -36,7 +28,6 @@ export interface EventRegistry {
|
|
|
36
28
|
'campaign.ready': [boolean];
|
|
37
29
|
'buy.tokens.ready': [boolean];
|
|
38
30
|
'buy.services.ready': [boolean];
|
|
39
|
-
'earning.ready': [boolean];
|
|
40
31
|
}
|
|
41
32
|
export declare type EventType = keyof EventRegistry;
|
|
42
33
|
export declare const COMMON_RELOAD_EVENTS: EventType[];
|
|
@@ -10,7 +10,6 @@ export declare class KeyringService {
|
|
|
10
10
|
readonly addressesSubject: BehaviorSubject<SubjectInfo>;
|
|
11
11
|
readonly accountSubject: BehaviorSubject<SubjectInfo>;
|
|
12
12
|
private beforeAccount;
|
|
13
|
-
private injected;
|
|
14
13
|
readonly keyringStateSubject: BehaviorSubject<KeyringState>;
|
|
15
14
|
constructor(eventService: EventService);
|
|
16
15
|
private subscribeAccounts;
|
|
@@ -22,6 +21,6 @@ export declare class KeyringService {
|
|
|
22
21
|
setCurrentAccount(currentAccountData: CurrentAccountInfo): void;
|
|
23
22
|
lock(): void;
|
|
24
23
|
addInjectAccounts(accounts: InjectedAccountWithMeta[]): void;
|
|
25
|
-
removeInjectAccounts(
|
|
24
|
+
removeInjectAccounts(addresses: string[]): void;
|
|
26
25
|
resetWallet(resetAll: boolean): Promise<void>;
|
|
27
26
|
}
|
|
@@ -22,7 +22,6 @@ export class KeyringService {
|
|
|
22
22
|
});
|
|
23
23
|
constructor(eventService) {
|
|
24
24
|
this.eventService = eventService;
|
|
25
|
-
this.injected = false;
|
|
26
25
|
this.eventService.waitCryptoReady.then(() => {
|
|
27
26
|
this.currentAccountStore.get('CurrentAccountInfo', rs => {
|
|
28
27
|
rs && this.currentAccountSubject.next(rs);
|
|
@@ -134,19 +133,8 @@ export class KeyringService {
|
|
|
134
133
|
currentGenesisHash: null
|
|
135
134
|
});
|
|
136
135
|
}
|
|
137
|
-
if (!this.injected) {
|
|
138
|
-
this.eventService.emit('inject.ready', true);
|
|
139
|
-
this.injected = true;
|
|
140
|
-
}
|
|
141
136
|
}
|
|
142
|
-
removeInjectAccounts(
|
|
143
|
-
const addresses = _addresses.map(address => {
|
|
144
|
-
try {
|
|
145
|
-
return keyring.getPair(address).address;
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return address;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
137
|
+
removeInjectAccounts(addresses) {
|
|
150
138
|
const currentAddress = this.currentAccountSubject.value.address;
|
|
151
139
|
const afterAccounts = Object.keys(this.accounts).filter(address => addresses.indexOf(address) < 0);
|
|
152
140
|
if (afterAccounts.length === 1) {
|
|
@@ -171,7 +159,7 @@ export class KeyringService {
|
|
|
171
159
|
await new Promise(resolve => {
|
|
172
160
|
setTimeout(() => {
|
|
173
161
|
resolve();
|
|
174
|
-
},
|
|
162
|
+
}, 500);
|
|
175
163
|
});
|
|
176
164
|
this.updateKeyringState();
|
|
177
165
|
this.currentAccountSubject.next({
|
|
@@ -11,7 +11,7 @@ export default class MigrateLedgerAccount extends BaseMigrationJob {
|
|
|
11
11
|
const store = new AccountsStore();
|
|
12
12
|
const update = (key, value) => {
|
|
13
13
|
var _value$meta;
|
|
14
|
-
if (key.startsWith('account:') && value
|
|
14
|
+
if (key.startsWith('account:') && value.meta && isString((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.originGenesisHash)) {
|
|
15
15
|
const newValue = {
|
|
16
16
|
...value
|
|
17
17
|
};
|
|
@@ -12,7 +12,7 @@ export default class MigrateTransactionHistory extends BaseMigrationJob {
|
|
|
12
12
|
const chainInfoMap = state.getChainInfoMap();
|
|
13
13
|
const assetList = Object.values(state.getAssetRegistry());
|
|
14
14
|
try {
|
|
15
|
-
const db = new Dexie('
|
|
15
|
+
const db = new Dexie('SubWalletDB');
|
|
16
16
|
const dexieDB = await db.open();
|
|
17
17
|
const transactionTable = dexieDB.table('transactions');
|
|
18
18
|
const oldTransactionData = await transactionTable.toArray();
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import DeleteEarningData from '@subwallet/extension-base/services/migration-service/scripts/DeleteEarningData';
|
|
5
|
-
import MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
|
|
6
4
|
import MigrateEthProvider from "./providers/MigrateEthProvider.js";
|
|
7
5
|
import MigratePioneerProvider from "./providers/MigratePioneerProvider.js";
|
|
8
6
|
import MigrateProvidersV1M1P24 from "./providers/MigrateProvidersV1M1P24.js";
|
|
@@ -35,12 +33,9 @@ export default {
|
|
|
35
33
|
'1.1.6-01': MigrateWalletReference,
|
|
36
34
|
'1.1.7': DeleteChain,
|
|
37
35
|
'1.1.13-01': MigrateTokenDecimals,
|
|
38
|
-
// '1.1.13-02-2': EnableEarningChains,
|
|
39
|
-
'1.1.13-03': DeleteEarningData,
|
|
40
36
|
'1.1.17-01': MigratePioneerProvider,
|
|
41
37
|
'1.1.17-03': EnableVaraChain,
|
|
42
38
|
'1.1.24-01': MigrateProvidersV1M1P24,
|
|
43
|
-
'1.1.26-01': MigratePolygonUSDCProvider
|
|
44
|
-
'1.1.28-01': MigrateEarningVersion
|
|
39
|
+
'1.1.26-01': MigratePolygonUSDCProvider
|
|
45
40
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
46
41
|
};
|
|
@@ -8,9 +8,7 @@ import ChainStakingMetadataStore from '@subwallet/extension-base/services/storag
|
|
|
8
8
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
9
9
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
10
10
|
import { HistoryQuery } from '@subwallet/extension-base/services/storage-service/db-stores/Transaction';
|
|
11
|
-
import
|
|
12
|
-
import YieldPositionStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore';
|
|
13
|
-
import { BalanceItem, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
11
|
+
import { BalanceItem } from '@subwallet/extension-base/types';
|
|
14
12
|
import { Subscription } from 'dexie';
|
|
15
13
|
import { DexieExportJsonStructure } from 'dexie-export-import';
|
|
16
14
|
export declare const DEXIE_BACKUP_TABLES: string[];
|
|
@@ -29,8 +27,6 @@ export default class DatabaseService {
|
|
|
29
27
|
metadata: MetadataStore;
|
|
30
28
|
chain: ChainStore;
|
|
31
29
|
asset: AssetStore;
|
|
32
|
-
yieldPoolInfo: YieldPoolStore;
|
|
33
|
-
yieldPosition: YieldPositionStore;
|
|
34
30
|
chainStakingMetadata: ChainStakingMetadataStore;
|
|
35
31
|
nominatorMetadata: NominatorMetadataStore;
|
|
36
32
|
mantaPay: MantaPayStore;
|
|
@@ -39,7 +35,6 @@ export default class DatabaseService {
|
|
|
39
35
|
private logger;
|
|
40
36
|
private nftSubscription;
|
|
41
37
|
private stakingSubscription;
|
|
42
|
-
private yieldInfoSubscription;
|
|
43
38
|
constructor(eventService: EventService);
|
|
44
39
|
updatePriceStore(priceData: PriceJson): Promise<void>;
|
|
45
40
|
getPriceStore(): Promise<PriceJson | undefined>;
|
|
@@ -88,22 +83,6 @@ export default class DatabaseService {
|
|
|
88
83
|
subscribeMantaPayConfig(chain: string, callback: (data: MantaPayConfig[]) => void): void;
|
|
89
84
|
getMantaPayConfig(chain: string): Promise<any[]>;
|
|
90
85
|
getMantaPayFirstConfig(chain: string): Promise<any>;
|
|
91
|
-
removeOldEarningData(): Promise<void>;
|
|
92
|
-
updateYieldPoolStore(data: YieldPoolInfo): Promise<void>;
|
|
93
|
-
updateYieldPoolsStore(data: YieldPoolInfo[]): Promise<void>;
|
|
94
|
-
deleteYieldPoolInfo(slugs: string[]): Promise<void>;
|
|
95
|
-
getYieldPools(): Promise<YieldPoolInfo[]>;
|
|
96
|
-
getYieldPoolStakingInfo(chain: string, poolType: YieldPoolType): Promise<YieldPoolInfo | undefined>;
|
|
97
|
-
getYieldPool(slug: string): Promise<YieldPoolInfo | undefined>;
|
|
98
|
-
getYieldPositionByAddressAndSlug(address: string, slug: string): Promise<YieldPositionInfo | undefined>;
|
|
99
|
-
subscribeYieldPoolInfo(chains: string[], callback: (data: YieldPoolInfo[]) => void): Subscription;
|
|
100
|
-
removeYieldPositionByAddresses(addresses: string[]): import("dexie").PromiseExtended<number>;
|
|
101
|
-
removeYieldPositionByChains(chains: string[]): import("dexie").PromiseExtended<number>;
|
|
102
|
-
updateYieldPosition(data: YieldPositionInfo): Promise<void>;
|
|
103
|
-
updateYieldPositions(data: YieldPositionInfo[]): Promise<void>;
|
|
104
|
-
getYieldPositionByAddress(addresses: string[]): Promise<YieldPositionInfo[]>;
|
|
105
|
-
subscribeYieldPosition(addresses: string[], callback: (data: YieldPositionInfo[]) => void): Subscription;
|
|
106
|
-
getYieldNominationPoolPosition(addresses: string[], chains: string[]): Promise<YieldPositionInfo[]>;
|
|
107
86
|
getAllCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
108
87
|
subscribeProcessingCampaign(): import("dexie").Observable<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
109
88
|
getProcessingCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|