@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
|
@@ -226,9 +226,8 @@ class ChainService {
|
|
|
226
226
|
getActiveChainInfos() {
|
|
227
227
|
const result = {};
|
|
228
228
|
Object.values(this.getChainStateMap()).forEach(chainState => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
result[chainState.slug] = chainInfo;
|
|
229
|
+
if (chainState.active) {
|
|
230
|
+
result[chainState.slug] = this.getChainInfoByKey(chainState.slug);
|
|
232
231
|
}
|
|
233
232
|
});
|
|
234
233
|
return result;
|
|
@@ -410,9 +409,8 @@ class ChainService {
|
|
|
410
409
|
await this.eventService.waitDatabaseReady;
|
|
411
410
|
|
|
412
411
|
// TODO: reconsider the flow of initiation
|
|
413
|
-
|
|
414
|
-
this.
|
|
415
|
-
this.dataMap.assetRefMap = latestAssetRefMap;
|
|
412
|
+
this.multiChainAssetMapSubject.next(_chainList.MultiChainAssetMap);
|
|
413
|
+
this.dataMap.assetRefMap = _chainList.AssetRefMap;
|
|
416
414
|
await this.initChains();
|
|
417
415
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
418
416
|
this.updateChainStateMapSubscription();
|
|
@@ -420,16 +418,64 @@ class ChainService {
|
|
|
420
418
|
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
421
419
|
await this.initApis();
|
|
422
420
|
await this.initAssetSettings();
|
|
421
|
+
this.checkLatestData();
|
|
423
422
|
}
|
|
423
|
+
checkLatestData() {
|
|
424
|
+
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
425
|
+
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestData.bind(this), _constants.LATEST_CHAIN_DATA_FETCHING_INTERVAL);
|
|
426
|
+
}
|
|
427
|
+
stopCheckLatestChainData() {
|
|
428
|
+
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
429
|
+
}
|
|
430
|
+
handleLatestProviderData(latestChainInfo) {
|
|
431
|
+
try {
|
|
432
|
+
if (latestChainInfo && latestChainInfo.length > 0) {
|
|
433
|
+
const {
|
|
434
|
+
needUpdateChainApiList,
|
|
435
|
+
storedChainInfoList
|
|
436
|
+
} = (0, _utils.updateLatestChainInfo)(this.dataMap, latestChainInfo);
|
|
437
|
+
this.dbService.bulkUpdateChainStore(storedChainInfoList).catch(console.error);
|
|
438
|
+
this.updateChainSubscription();
|
|
439
|
+
needUpdateChainApiList.forEach(chainInfo => {
|
|
440
|
+
console.log('Updating chain API for', chainInfo.slug);
|
|
441
|
+
this.initApiForChain(chainInfo).catch(console.error);
|
|
442
|
+
});
|
|
443
|
+
this.logger.log('Finished updating latest RPC providers');
|
|
444
|
+
}
|
|
445
|
+
} catch (e) {
|
|
446
|
+
console.error('Error fetching latest chain data');
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
handleLatestPriceId(latestPriceIds) {
|
|
450
|
+
Object.entries(latestPriceIds).forEach(_ref3 => {
|
|
451
|
+
let [slug, priceId] = _ref3;
|
|
452
|
+
if (this.dataMap.assetRegistry[slug]) {
|
|
453
|
+
this.dataMap.assetRegistry[slug].priceId = priceId;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
457
|
+
this.eventService.emit('asset.updateState', '');
|
|
458
|
+
this.logger.log('Finished updating latest price IDs');
|
|
459
|
+
}
|
|
460
|
+
handleLatestData() {
|
|
461
|
+
this.fetchLatestChainData().then(latestChainInfo => {
|
|
462
|
+
this.handleLatestProviderData(latestChainInfo);
|
|
463
|
+
}).catch(console.error);
|
|
464
|
+
|
|
465
|
+
// this.fetchLatestPriceIdsData().then((latestPriceIds) => {
|
|
466
|
+
// this.handleLatestPriceId(latestPriceIds);
|
|
467
|
+
// }).catch(console.error);
|
|
468
|
+
}
|
|
469
|
+
|
|
424
470
|
async initApis() {
|
|
425
471
|
const chainInfoMap = this.getChainInfoMap();
|
|
426
472
|
const chainStateMap = this.getChainStateMap();
|
|
427
|
-
await Promise.all(Object.entries(chainInfoMap).filter(
|
|
473
|
+
await Promise.all(Object.entries(chainInfoMap).filter(_ref4 => {
|
|
428
474
|
var _chainStateMap$slug;
|
|
429
|
-
let [slug] =
|
|
475
|
+
let [slug] = _ref4;
|
|
430
476
|
return (_chainStateMap$slug = chainStateMap[slug]) === null || _chainStateMap$slug === void 0 ? void 0 : _chainStateMap$slug.active;
|
|
431
|
-
}).map(
|
|
432
|
-
let [, chainInfo] =
|
|
477
|
+
}).map(_ref5 => {
|
|
478
|
+
let [, chainInfo] = _ref5;
|
|
433
479
|
try {
|
|
434
480
|
return this.initApiForChain(chainInfo);
|
|
435
481
|
} catch (e) {
|
|
@@ -578,8 +624,8 @@ class ChainService {
|
|
|
578
624
|
}
|
|
579
625
|
return duplicatedSlug;
|
|
580
626
|
}
|
|
581
|
-
async
|
|
582
|
-
return
|
|
627
|
+
async fetchLatestChainData() {
|
|
628
|
+
return await (0, _utils2.fetchStaticData)('chains');
|
|
583
629
|
// try {
|
|
584
630
|
// const timeout = new Promise((resolve) => {
|
|
585
631
|
// const id = setTimeout(() => {
|
|
@@ -616,9 +662,13 @@ class ChainService {
|
|
|
616
662
|
// }
|
|
617
663
|
}
|
|
618
664
|
|
|
665
|
+
// @ts-ignore
|
|
666
|
+
async fetchLatestPriceIdsData() {
|
|
667
|
+
return await (0, _utils2.fetchStaticData)('chain-assets/price-map');
|
|
668
|
+
}
|
|
619
669
|
async initChains() {
|
|
620
670
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
621
|
-
const
|
|
671
|
+
const defaultChainInfoMap = _chainList.ChainInfoMap;
|
|
622
672
|
const storedChainSettingMap = {};
|
|
623
673
|
storedChainSettings.forEach(chainStoredSetting => {
|
|
624
674
|
storedChainSettingMap[chainStoredSetting.slug] = chainStoredSetting;
|
|
@@ -627,10 +677,13 @@ class ChainService {
|
|
|
627
677
|
const deprecatedChains = [];
|
|
628
678
|
const deprecatedChainMap = {};
|
|
629
679
|
if (storedChainSettings.length === 0) {
|
|
630
|
-
this.dataMap.chainInfoMap =
|
|
631
|
-
Object.values(
|
|
680
|
+
this.dataMap.chainInfoMap = defaultChainInfoMap;
|
|
681
|
+
Object.values(defaultChainInfoMap).forEach(chainInfo => {
|
|
682
|
+
const {
|
|
683
|
+
providerKey
|
|
684
|
+
} = (0, _utils.randomizeProvider)(chainInfo.providers);
|
|
632
685
|
this.dataMap.chainStateMap[chainInfo.slug] = {
|
|
633
|
-
currentProvider:
|
|
686
|
+
currentProvider: providerKey,
|
|
634
687
|
slug: chainInfo.slug,
|
|
635
688
|
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
636
689
|
active: _constants._DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug)
|
|
@@ -640,15 +693,15 @@ class ChainService {
|
|
|
640
693
|
newStorageData.push({
|
|
641
694
|
...chainInfo,
|
|
642
695
|
active: _constants._DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug),
|
|
643
|
-
currentProvider:
|
|
696
|
+
currentProvider: providerKey
|
|
644
697
|
});
|
|
645
698
|
});
|
|
646
699
|
} else {
|
|
647
|
-
const mergedChainInfoMap =
|
|
700
|
+
const mergedChainInfoMap = defaultChainInfoMap;
|
|
648
701
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
649
|
-
const chainInfo =
|
|
702
|
+
const chainInfo = defaultChainInfoMap[storedSlug];
|
|
650
703
|
|
|
651
|
-
// Network
|
|
704
|
+
// Network existed on change list
|
|
652
705
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
653
706
|
if (chainInfo) {
|
|
654
707
|
// Keep customer provider only
|
|
@@ -663,23 +716,27 @@ class ChainService {
|
|
|
663
716
|
}
|
|
664
717
|
}
|
|
665
718
|
mergedChainInfoMap[storedSlug].providers = providers;
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
719
|
+
const {
|
|
720
|
+
providerKey
|
|
721
|
+
} = (0, _utils.randomizeProvider)(providers);
|
|
722
|
+
let selectedProvider = providerKey;
|
|
723
|
+
const storedProviderKey = storedChainInfo.currentProvider;
|
|
724
|
+
const storedProviderValue = storedChainInfo.providers[storedProviderKey] || '';
|
|
725
|
+
if (storedProviderValue !== null && storedProviderValue !== void 0 && storedProviderValue.startsWith('light') || storedProviderKey !== null && storedProviderKey !== void 0 && storedProviderKey.startsWith(_types3._CUSTOM_PREFIX)) {
|
|
726
|
+
const savedProviderKey = Object.keys(providers).find(key => providers[key] === storedProviderValue);
|
|
727
|
+
if (savedProviderKey) {
|
|
728
|
+
selectedProvider = savedProviderKey;
|
|
677
729
|
}
|
|
678
730
|
}
|
|
731
|
+
|
|
732
|
+
// Merge current provider
|
|
733
|
+
// let currentProvider = storedChainInfo.currentProvider;
|
|
734
|
+
// const providerValue = storedChainInfo.providers[selectedProvider] || '';
|
|
735
|
+
|
|
679
736
|
const hasProvider = Object.values(providers).length > 0;
|
|
680
737
|
const canActive = hasProvider && chainInfo.chainStatus === _types._ChainStatus.ACTIVE;
|
|
681
738
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
682
|
-
currentProvider:
|
|
739
|
+
currentProvider: selectedProvider,
|
|
683
740
|
slug: storedSlug,
|
|
684
741
|
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
685
742
|
active: canActive && storedChainInfo.active
|
|
@@ -687,13 +744,13 @@ class ChainService {
|
|
|
687
744
|
newStorageData.push({
|
|
688
745
|
...mergedChainInfoMap[storedSlug],
|
|
689
746
|
active: canActive && storedChainInfo.active,
|
|
690
|
-
currentProvider:
|
|
747
|
+
currentProvider: selectedProvider
|
|
691
748
|
});
|
|
692
749
|
} else if ((0, _utils._isCustomChain)(storedSlug)) {
|
|
693
750
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
694
751
|
// only custom chains are left
|
|
695
752
|
// check custom chain duplicated with predefined chain => merge into predefined chain
|
|
696
|
-
const duplicatedDefaultSlug = this.checkExistedPredefinedChain(
|
|
753
|
+
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);
|
|
697
754
|
if (duplicatedDefaultSlug.length > 0) {
|
|
698
755
|
// merge custom chain with existed chain
|
|
699
756
|
mergedChainInfoMap[duplicatedDefaultSlug].providers = {
|
|
@@ -718,6 +775,7 @@ class ChainService {
|
|
|
718
775
|
slug: storedSlug,
|
|
719
776
|
name: storedChainInfo.name,
|
|
720
777
|
providers: storedChainInfo.providers,
|
|
778
|
+
// TODO: review
|
|
721
779
|
evmInfo: storedChainInfo.evmInfo,
|
|
722
780
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
723
781
|
isTestnet: storedChainInfo.isTestnet,
|
|
@@ -727,6 +785,7 @@ class ChainService {
|
|
|
727
785
|
};
|
|
728
786
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
729
787
|
currentProvider: storedChainInfo.currentProvider,
|
|
788
|
+
// TODO: review
|
|
730
789
|
slug: storedSlug,
|
|
731
790
|
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
732
791
|
active: storedChainInfo.active
|
|
@@ -734,7 +793,7 @@ class ChainService {
|
|
|
734
793
|
newStorageData.push({
|
|
735
794
|
...mergedChainInfoMap[storedSlug],
|
|
736
795
|
active: storedChainInfo.active,
|
|
737
|
-
currentProvider: storedChainInfo.currentProvider
|
|
796
|
+
currentProvider: storedChainInfo.currentProvider // TODO: review
|
|
738
797
|
});
|
|
739
798
|
}
|
|
740
799
|
} else {
|
|
@@ -743,8 +802,8 @@ class ChainService {
|
|
|
743
802
|
}
|
|
744
803
|
|
|
745
804
|
// Fill in the missing chainState and storageData (new chains never before seen)
|
|
746
|
-
Object.entries(mergedChainInfoMap).forEach(
|
|
747
|
-
let [slug, chainInfo] =
|
|
805
|
+
Object.entries(mergedChainInfoMap).forEach(_ref6 => {
|
|
806
|
+
let [slug, chainInfo] = _ref6;
|
|
748
807
|
if (!(slug in this.dataMap.chainStateMap)) {
|
|
749
808
|
this.dataMap.chainStateMap[slug] = {
|
|
750
809
|
currentProvider: Object.keys(chainInfo.providers)[0],
|
|
@@ -767,7 +826,7 @@ class ChainService {
|
|
|
767
826
|
}
|
|
768
827
|
async initAssetRegistry(deprecatedCustomChainMap) {
|
|
769
828
|
const storedAssetRegistry = await this.dbService.getAllAssetStore();
|
|
770
|
-
const latestAssetRegistry =
|
|
829
|
+
const latestAssetRegistry = _chainList.ChainAssetMap;
|
|
771
830
|
const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _types._ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
|
|
772
831
|
|
|
773
832
|
// Fill out zk assets from latestAssetRegistry if not supported
|
|
@@ -1217,9 +1276,11 @@ class ChainService {
|
|
|
1217
1276
|
}
|
|
1218
1277
|
async stopAllChainApis() {
|
|
1219
1278
|
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep()]);
|
|
1279
|
+
this.stopCheckLatestChainData();
|
|
1220
1280
|
}
|
|
1221
1281
|
async resumeAllChainApis() {
|
|
1222
1282
|
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp()]);
|
|
1283
|
+
this.checkLatestData();
|
|
1223
1284
|
}
|
|
1224
1285
|
checkAndUpdateStatusMapForChain(chainSlug) {
|
|
1225
1286
|
const substrateApiMap = this.getSubstrateApiMap();
|
|
@@ -1355,10 +1416,10 @@ class ChainService {
|
|
|
1355
1416
|
return this.assetSettingSubject;
|
|
1356
1417
|
}
|
|
1357
1418
|
async getChainLogoMap() {
|
|
1358
|
-
return
|
|
1419
|
+
return Promise.resolve(_chainList.ChainLogoMap);
|
|
1359
1420
|
}
|
|
1360
1421
|
async getAssetLogoMap() {
|
|
1361
|
-
return
|
|
1422
|
+
return Promise.resolve(_chainList.AssetLogoMap);
|
|
1362
1423
|
}
|
|
1363
1424
|
resetWallet(resetAll) {
|
|
1364
1425
|
if (resetAll) {
|
|
@@ -60,7 +60,6 @@ exports._isSmartContractToken = _isSmartContractToken;
|
|
|
60
60
|
exports._isSubstrateChain = _isSubstrateChain;
|
|
61
61
|
exports._isSubstrateParaChain = _isSubstrateParaChain;
|
|
62
62
|
exports._isSubstrateRelayChain = _isSubstrateRelayChain;
|
|
63
|
-
exports._isSupportOrdinal = void 0;
|
|
64
63
|
exports._isTokenEvmSmartContract = _isTokenEvmSmartContract;
|
|
65
64
|
exports._isTokenTransferredByEvm = _isTokenTransferredByEvm;
|
|
66
65
|
exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
|
|
@@ -68,6 +67,8 @@ exports._isXcmPathSupported = _isXcmPathSupported;
|
|
|
68
67
|
exports._parseAssetRefKey = _parseAssetRefKey;
|
|
69
68
|
exports._parseMetadataForSmartContractAsset = _parseMetadataForSmartContractAsset;
|
|
70
69
|
exports.findChainInfoByHalfGenesisHash = exports.findChainInfoByChainId = void 0;
|
|
70
|
+
exports.randomizeProvider = randomizeProvider;
|
|
71
|
+
exports.updateLatestChainInfo = updateLatestChainInfo;
|
|
71
72
|
var _types = require("@subwallet/chain-list/types");
|
|
72
73
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
73
74
|
var _types2 = require("@subwallet/extension-base/services/chain-service/types");
|
|
@@ -162,7 +163,7 @@ function _getTokenMinAmount(tokenInfo) {
|
|
|
162
163
|
return tokenInfo.minAmount || '0';
|
|
163
164
|
}
|
|
164
165
|
function _isChainEvmCompatible(chainInfo) {
|
|
165
|
-
return
|
|
166
|
+
return chainInfo.evmInfo !== undefined && chainInfo.evmInfo !== null;
|
|
166
167
|
}
|
|
167
168
|
function _isNativeToken(tokenInfo) {
|
|
168
169
|
return tokenInfo.assetType === _types._AssetType.NATIVE;
|
|
@@ -217,11 +218,6 @@ function _isChainSupportWasmNft(chainInfo) {
|
|
|
217
218
|
var _chainInfo$substrateI8, _chainInfo$substrateI9;
|
|
218
219
|
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(_types._AssetType.PSP34)) || false;
|
|
219
220
|
}
|
|
220
|
-
const _isSupportOrdinal = chain => {
|
|
221
|
-
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
222
|
-
return chains.includes(chain);
|
|
223
|
-
};
|
|
224
|
-
exports._isSupportOrdinal = _isSupportOrdinal;
|
|
225
221
|
function _getNftTypesSupportedByChain(chainInfo) {
|
|
226
222
|
const result = [];
|
|
227
223
|
if (chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract) {
|
|
@@ -435,4 +431,70 @@ const findChainInfoByChainId = (chainMap, chainId) => {
|
|
|
435
431
|
exports.findChainInfoByChainId = findChainInfoByChainId;
|
|
436
432
|
function _isMantaZkAsset(chainAsset) {
|
|
437
433
|
return _constants._MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_constants._ZK_ASSET_PREFIX);
|
|
434
|
+
}
|
|
435
|
+
function randomizeProvider(providers, excludedKeys) {
|
|
436
|
+
if (Object.keys(providers).length === 0) {
|
|
437
|
+
return {
|
|
438
|
+
providerKey: '',
|
|
439
|
+
providerValue: ''
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
let isValid = false;
|
|
443
|
+
let selectedProviderKey = '';
|
|
444
|
+
let selectedProviderValue = '';
|
|
445
|
+
while (!isValid) {
|
|
446
|
+
var _selectedProviderValu, _selectedProviderKey;
|
|
447
|
+
const randomProvider = Math.floor(Math.random() * Object.keys(providers).length);
|
|
448
|
+
selectedProviderKey = Object.keys(providers)[randomProvider];
|
|
449
|
+
selectedProviderValue = providers[selectedProviderKey];
|
|
450
|
+
if (!((_selectedProviderValu = selectedProviderValue) !== null && _selectedProviderValu !== void 0 && _selectedProviderValu.startsWith('light')) && !((_selectedProviderKey = selectedProviderKey) !== null && _selectedProviderKey !== void 0 && _selectedProviderKey.startsWith(_types2._CUSTOM_PREFIX)) && !(excludedKeys !== null && excludedKeys !== void 0 && excludedKeys.includes(selectedProviderKey))) {
|
|
451
|
+
// if it's light client, then re-randomize
|
|
452
|
+
isValid = true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
providerKey: selectedProviderKey,
|
|
457
|
+
providerValue: selectedProviderValue
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
|
|
461
|
+
const currentChainInfoMap = currentDataMap.chainInfoMap;
|
|
462
|
+
const currentChainStateMap = currentDataMap.chainStateMap;
|
|
463
|
+
const storedChainInfoList = [];
|
|
464
|
+
const needUpdateChainApiList = [];
|
|
465
|
+
latestChainInfoList.forEach(latestChainInfo => {
|
|
466
|
+
const currentChainInfo = currentChainInfoMap[latestChainInfo.slug];
|
|
467
|
+
const currentChainState = currentChainStateMap[latestChainInfo.slug];
|
|
468
|
+
const currentChainProviderValue = currentChainInfo === null || currentChainInfo === void 0 ? void 0 : currentChainInfo.providers[currentChainState === null || currentChainState === void 0 ? void 0 : currentChainState.currentProvider];
|
|
469
|
+
if (currentChainInfo && currentChainState) {
|
|
470
|
+
const preservedProvider = {};
|
|
471
|
+
Object.entries(currentChainInfo.providers).forEach(_ref => {
|
|
472
|
+
let [providerKey, providerValue] = _ref;
|
|
473
|
+
if (providerValue !== null && providerValue !== void 0 && providerValue.startsWith('light') || providerKey !== null && providerKey !== void 0 && providerKey.startsWith(_types2._CUSTOM_PREFIX)) {
|
|
474
|
+
preservedProvider[providerKey] = providerValue;
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
currentChainInfo.providers = {
|
|
478
|
+
...latestChainInfo.providers,
|
|
479
|
+
...preservedProvider
|
|
480
|
+
};
|
|
481
|
+
const currentProviderNotFound = !Object.keys(currentChainInfo.providers).includes(currentChainState.currentProvider);
|
|
482
|
+
const currentProviderUpdated = Object.keys(currentChainInfo.providers).includes(currentChainState.currentProvider) && !Object.values(currentChainInfo.providers).includes(currentChainProviderValue);
|
|
483
|
+
if (currentChainInfo.chainStatus === _types._ChainStatus.ACTIVE && (currentProviderNotFound || currentProviderUpdated)) {
|
|
484
|
+
const {
|
|
485
|
+
providerKey
|
|
486
|
+
} = randomizeProvider(currentChainInfo.providers);
|
|
487
|
+
currentChainState.currentProvider = providerKey;
|
|
488
|
+
needUpdateChainApiList.push(currentChainInfo);
|
|
489
|
+
}
|
|
490
|
+
storedChainInfoList.push({
|
|
491
|
+
...currentChainInfo,
|
|
492
|
+
...currentChainState
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
return {
|
|
497
|
+
storedChainInfoList,
|
|
498
|
+
needUpdateChainApiList
|
|
499
|
+
};
|
|
438
500
|
}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.EventService = void 0;
|
|
8
|
-
var _utils = require("@subwallet/extension-base/utils");
|
|
9
8
|
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
10
9
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
11
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -25,20 +24,16 @@ class EventService extends _eventemitter.default {
|
|
|
25
24
|
this.waitDatabaseReady = this.generateWaitPromise('database.ready');
|
|
26
25
|
this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
|
|
27
26
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
28
|
-
// TODO: Need to merge logic on web-runner file
|
|
29
|
-
this.waitInjectReady = _utils.TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
|
|
30
27
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
31
28
|
this.waitAssetReady = this.generateWaitPromise('asset.ready');
|
|
32
29
|
this.waitMigrateReady = this.generateWaitPromise('migration.done');
|
|
33
30
|
this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
|
|
34
31
|
this.waitBuyTokenReady = this.generateWaitPromise('buy.tokens.ready');
|
|
35
32
|
this.waitBuyServiceReady = this.generateWaitPromise('buy.services.ready');
|
|
36
|
-
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
37
33
|
}
|
|
38
34
|
generateWaitPromise(eventType) {
|
|
39
35
|
return new Promise(resolve => {
|
|
40
36
|
this.once(eventType, isReady => {
|
|
41
|
-
console.log('===LOG generateWaitPromise eventType', eventType);
|
|
42
37
|
resolve(isReady);
|
|
43
38
|
});
|
|
44
39
|
});
|
|
@@ -28,7 +28,6 @@ class KeyringService {
|
|
|
28
28
|
});
|
|
29
29
|
constructor(eventService) {
|
|
30
30
|
this.eventService = eventService;
|
|
31
|
-
this.injected = false;
|
|
32
31
|
this.eventService.waitCryptoReady.then(() => {
|
|
33
32
|
this.currentAccountStore.get('CurrentAccountInfo', rs => {
|
|
34
33
|
rs && this.currentAccountSubject.next(rs);
|
|
@@ -141,19 +140,8 @@ class KeyringService {
|
|
|
141
140
|
currentGenesisHash: null
|
|
142
141
|
});
|
|
143
142
|
}
|
|
144
|
-
if (!this.injected) {
|
|
145
|
-
this.eventService.emit('inject.ready', true);
|
|
146
|
-
this.injected = true;
|
|
147
|
-
}
|
|
148
143
|
}
|
|
149
|
-
removeInjectAccounts(
|
|
150
|
-
const addresses = _addresses.map(address => {
|
|
151
|
-
try {
|
|
152
|
-
return _uiKeyring.keyring.getPair(address).address;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
return address;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
144
|
+
removeInjectAccounts(addresses) {
|
|
157
145
|
const currentAddress = this.currentAccountSubject.value.address;
|
|
158
146
|
const afterAccounts = Object.keys(this.accounts).filter(address => addresses.indexOf(address) < 0);
|
|
159
147
|
if (afterAccounts.length === 1) {
|
|
@@ -178,7 +166,7 @@ class KeyringService {
|
|
|
178
166
|
await new Promise(resolve => {
|
|
179
167
|
setTimeout(() => {
|
|
180
168
|
resolve();
|
|
181
|
-
},
|
|
169
|
+
}, 500);
|
|
182
170
|
});
|
|
183
171
|
this.updateKeyringState();
|
|
184
172
|
this.currentAccountSubject.next({
|
|
@@ -18,7 +18,7 @@ class MigrateLedgerAccount extends _Base.default {
|
|
|
18
18
|
const store = new _stores.AccountsStore();
|
|
19
19
|
const update = (key, value) => {
|
|
20
20
|
var _value$meta;
|
|
21
|
-
if (key.startsWith('account:') && value
|
|
21
|
+
if (key.startsWith('account:') && value.meta && (0, _util.isString)((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.originGenesisHash)) {
|
|
22
22
|
const newValue = {
|
|
23
23
|
...value
|
|
24
24
|
};
|
|
@@ -19,7 +19,7 @@ class MigrateTransactionHistory extends _Base.default {
|
|
|
19
19
|
const chainInfoMap = state.getChainInfoMap();
|
|
20
20
|
const assetList = Object.values(state.getAssetRegistry());
|
|
21
21
|
try {
|
|
22
|
-
const db = new _dexie.default('
|
|
22
|
+
const db = new _dexie.default('SubWalletDB');
|
|
23
23
|
const dexieDB = await db.open();
|
|
24
24
|
const transactionTable = dexieDB.table('transactions');
|
|
25
25
|
const oldTransactionData = await transactionTable.toArray();
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.EVERYTIME = void 0;
|
|
8
|
-
var _DeleteEarningData = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/DeleteEarningData"));
|
|
9
|
-
var _MigrateEarningVersion = _interopRequireDefault(require("./databases/MigrateEarningVersion"));
|
|
10
8
|
var _MigrateEthProvider = _interopRequireDefault(require("./providers/MigrateEthProvider"));
|
|
11
9
|
var _MigratePioneerProvider = _interopRequireDefault(require("./providers/MigratePioneerProvider"));
|
|
12
10
|
var _MigrateProvidersV1M1P = _interopRequireDefault(require("./providers/MigrateProvidersV1M1P24"));
|
|
@@ -43,13 +41,10 @@ var _default = {
|
|
|
43
41
|
'1.1.6-01': _MigrateWalletReference.default,
|
|
44
42
|
'1.1.7': _DeleteChain.default,
|
|
45
43
|
'1.1.13-01': _MigrateTokenDecimals.default,
|
|
46
|
-
// '1.1.13-02-2': EnableEarningChains,
|
|
47
|
-
'1.1.13-03': _DeleteEarningData.default,
|
|
48
44
|
'1.1.17-01': _MigratePioneerProvider.default,
|
|
49
45
|
'1.1.17-03': _EnableVaraChain.default,
|
|
50
46
|
'1.1.24-01': _MigrateProvidersV1M1P.default,
|
|
51
|
-
'1.1.26-01': _MigratePolygonUSDCProvider.default
|
|
52
|
-
'1.1.28-01': _MigrateEarningVersion.default
|
|
47
|
+
'1.1.26-01': _MigratePolygonUSDCProvider.default
|
|
53
48
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
54
49
|
};
|
|
55
50
|
exports.default = _default;
|
|
@@ -12,8 +12,6 @@ var _Campaign = _interopRequireDefault(require("@subwallet/extension-base/servic
|
|
|
12
12
|
var _ChainStakingMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata"));
|
|
13
13
|
var _MantaPay = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/MantaPay"));
|
|
14
14
|
var _NominatorMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata"));
|
|
15
|
-
var _YieldPoolStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore"));
|
|
16
|
-
var _YieldPositionStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore"));
|
|
17
15
|
var _utils = require("@subwallet/extension-base/utils");
|
|
18
16
|
var _dexieExportImport = require("dexie-export-import");
|
|
19
17
|
var _util = require("@polkadot/util");
|
|
@@ -44,9 +42,6 @@ class DatabaseService {
|
|
|
44
42
|
metadata: new _dbStores.MetadataStore(this._db.metadata),
|
|
45
43
|
chain: new _dbStores.ChainStore(this._db.chain),
|
|
46
44
|
asset: new _dbStores.AssetStore(this._db.asset),
|
|
47
|
-
// yield
|
|
48
|
-
yieldPoolInfo: new _YieldPoolStore.default(this._db.yieldPoolInfo),
|
|
49
|
-
yieldPosition: new _YieldPositionStore.default(this._db.yieldPosition),
|
|
50
45
|
// staking
|
|
51
46
|
chainStakingMetadata: new _ChainStakingMetadata.default(this._db.chainStakingMetadata),
|
|
52
47
|
nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata),
|
|
@@ -286,64 +281,6 @@ class DatabaseService {
|
|
|
286
281
|
return this.stores.mantaPay.getFirstConfig(chain);
|
|
287
282
|
}
|
|
288
283
|
|
|
289
|
-
/* Earning */
|
|
290
|
-
|
|
291
|
-
async removeOldEarningData() {
|
|
292
|
-
await this.stores.yieldPoolInfo.clear();
|
|
293
|
-
await this.stores.yieldPosition.clear();
|
|
294
|
-
}
|
|
295
|
-
async updateYieldPoolStore(data) {
|
|
296
|
-
await this.stores.yieldPoolInfo.upsert(data);
|
|
297
|
-
}
|
|
298
|
-
async updateYieldPoolsStore(data) {
|
|
299
|
-
await this.stores.yieldPoolInfo.bulkUpsert(data);
|
|
300
|
-
}
|
|
301
|
-
async deleteYieldPoolInfo(slugs) {
|
|
302
|
-
await this.stores.yieldPoolInfo.bulkDelete(slugs);
|
|
303
|
-
}
|
|
304
|
-
async getYieldPools() {
|
|
305
|
-
return this.stores.yieldPoolInfo.getAll();
|
|
306
|
-
}
|
|
307
|
-
async getYieldPoolStakingInfo(chain, poolType) {
|
|
308
|
-
return this.stores.yieldPoolInfo.getByChainAndType(chain, poolType);
|
|
309
|
-
}
|
|
310
|
-
async getYieldPool(slug) {
|
|
311
|
-
return this.stores.yieldPoolInfo.getBySlug(slug);
|
|
312
|
-
}
|
|
313
|
-
async getYieldPositionByAddressAndSlug(address, slug) {
|
|
314
|
-
return this.stores.yieldPosition.getByAddressAndSlug(address, slug);
|
|
315
|
-
}
|
|
316
|
-
subscribeYieldPoolInfo(chains, callback) {
|
|
317
|
-
this.yieldInfoSubscription && this.yieldInfoSubscription.unsubscribe();
|
|
318
|
-
this.yieldInfoSubscription = this.stores.yieldPoolInfo.subscribeYieldPoolInfo(chains).subscribe({
|
|
319
|
-
next: data => callback && callback(data)
|
|
320
|
-
});
|
|
321
|
-
return this.yieldInfoSubscription;
|
|
322
|
-
}
|
|
323
|
-
removeYieldPositionByAddresses(addresses) {
|
|
324
|
-
return this.stores.yieldPosition.removeByAddresses(addresses);
|
|
325
|
-
}
|
|
326
|
-
removeYieldPositionByChains(chains) {
|
|
327
|
-
return this.stores.yieldPosition.removeByChains(chains);
|
|
328
|
-
}
|
|
329
|
-
async updateYieldPosition(data) {
|
|
330
|
-
await this.stores.yieldPosition.upsert(data);
|
|
331
|
-
}
|
|
332
|
-
async updateYieldPositions(data) {
|
|
333
|
-
await this.stores.yieldPosition.bulkUpsert(data);
|
|
334
|
-
}
|
|
335
|
-
async getYieldPositionByAddress(addresses) {
|
|
336
|
-
return this.stores.yieldPosition.getByAddress(addresses);
|
|
337
|
-
}
|
|
338
|
-
subscribeYieldPosition(addresses, callback) {
|
|
339
|
-
return this.stores.yieldPosition.subscribeYieldPositions(addresses).subscribe({
|
|
340
|
-
next: data => callback && callback(data)
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
async getYieldNominationPoolPosition(addresses, chains) {
|
|
344
|
-
return this.stores.yieldPosition.getByAddressAndChains(addresses, chains);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
284
|
/* Campaign */
|
|
348
285
|
|
|
349
286
|
getAllCampaign() {
|
|
@@ -40,10 +40,6 @@ class KoniDatabase extends _dexie.default {
|
|
|
40
40
|
mantaPay: 'key, chain'
|
|
41
41
|
});
|
|
42
42
|
this.conditionalVersion(4, {
|
|
43
|
-
yieldPoolInfo: 'slug, chain, type',
|
|
44
|
-
yieldPosition: '[slug+chain+address], [address+slug], address, chain'
|
|
45
|
-
});
|
|
46
|
-
this.conditionalVersion(5, {
|
|
47
43
|
campaign: 'slug'
|
|
48
44
|
});
|
|
49
45
|
}
|
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
9
|
var _BaseStoreWithAddressAndChain = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain"));
|
|
9
|
-
var _types = require("@subwallet/extension-base/types");
|
|
10
10
|
var _dexie = require("dexie");
|
|
11
11
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
12
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
13
|
|
|
14
14
|
class NominatorMetadataStore extends _BaseStoreWithAddressAndChain.default {
|
|
15
15
|
async getAll() {
|
|
16
|
-
return this.table.filter(item => item.status !==
|
|
16
|
+
return this.table.filter(item => item.status !== _KoniTypes.StakingStatus.NOT_STAKING).toArray();
|
|
17
17
|
}
|
|
18
18
|
subscribeByAddresses(addresses) {
|
|
19
19
|
return (0, _dexie.liveQuery)(() => this.getByAddress(addresses));
|
|
@@ -22,7 +22,7 @@ class NominatorMetadataStore extends _BaseStoreWithAddressAndChain.default {
|
|
|
22
22
|
return (0, _dexie.liveQuery)(() => this.getAll());
|
|
23
23
|
}
|
|
24
24
|
getByAddress(addresses) {
|
|
25
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => item.status !==
|
|
25
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => item.status !== _KoniTypes.StakingStatus.NOT_STAKING).toArray();
|
|
26
26
|
}
|
|
27
27
|
async removeByAddress(address) {
|
|
28
28
|
return this.table.where('address').anyOfIgnoreCase(address).delete();
|
|
@@ -252,21 +252,5 @@ class SubscanService {
|
|
|
252
252
|
await _getTransferItems(0);
|
|
253
253
|
return resultMap;
|
|
254
254
|
}
|
|
255
|
-
getRewardHistoryList(chain, address) {
|
|
256
|
-
let page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
257
|
-
return this.addRequest(async () => {
|
|
258
|
-
const rs = await this.postRequest(this.getApiUrl(chain, 'api/scan/account/reward_slash'), {
|
|
259
|
-
page,
|
|
260
|
-
category: 'Reward',
|
|
261
|
-
row: 10,
|
|
262
|
-
address
|
|
263
|
-
});
|
|
264
|
-
if (rs.status !== 200) {
|
|
265
|
-
throw new _SWError.SWError('SubscanService.getRewardHistoryList', await rs.text());
|
|
266
|
-
}
|
|
267
|
-
const jsonData = await rs.json();
|
|
268
|
-
return jsonData.data;
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
255
|
}
|
|
272
256
|
exports.SubscanService = SubscanService;
|