@subwallet/extension-base 1.1.33-beta.1 → 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 -120
- package/background/KoniTypes.js +13 -22
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -23
- 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 +17 -2
- package/cjs/services/chain-service/index.js +3 -25
- package/cjs/services/chain-service/utils.js +1 -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 +1 -92
- package/cjs/services/storage-service/databases/index.js +0 -7
- 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 -252
- 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 +8 -331
- 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 -1
- package/services/chain-service/constants.js +15 -1
- package/services/chain-service/index.d.ts +0 -2
- package/services/chain-service/index.js +3 -25
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- 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 +3 -30
- package/services/storage-service/DatabaseService.js +1 -91
- package/services/storage-service/databases/index.d.ts +2 -8
- package/services/storage-service/databases/index.js +0 -7
- 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 -250
- 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 -49
- 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 -98
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -299
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -41
- 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 -497
- package/cjs/services/earning-service/service.js +0 -741
- 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/AssetRef.js +0 -24
- 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 -48
- 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 -34
- 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 -90
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +0 -37
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -132
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -288
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -5
- package/services/earning-service/handlers/liquid-staking/index.js +0 -8
- 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 -489
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -730
- 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/AssetRef.d.ts +0 -7
- package/services/storage-service/db-stores/AssetRef.js +0 -16
- 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 -96
- package/types/yield/actions/join/step.js +0 -47
- 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
|
@@ -14,12 +14,10 @@ import CampaignService from '@subwallet/extension-base/services/campaign-service
|
|
|
14
14
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
15
15
|
import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _PREDEFINED_SINGLE_MODES } from '@subwallet/extension-base/services/chain-service/constants';
|
|
16
16
|
import { _getEvmChainId, _getSubstrateGenesisHash, _getTokenOnChainAssetId, _isAssetFungibleToken, _isChainEnabled, _isChainTestNet, _parseMetadataForSmartContractAsset } from '@subwallet/extension-base/services/chain-service/utils';
|
|
17
|
-
import EarningService from '@subwallet/extension-base/services/earning-service/service';
|
|
18
17
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
19
18
|
import { HistoryService } from '@subwallet/extension-base/services/history-service';
|
|
20
19
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
21
20
|
import MigrationService from '@subwallet/extension-base/services/migration-service';
|
|
22
|
-
import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
|
|
23
21
|
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
24
22
|
import { PriceService } from '@subwallet/extension-base/services/price-service';
|
|
25
23
|
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
@@ -95,13 +93,11 @@ export default class KoniState {
|
|
|
95
93
|
this.priceService = new PriceService(this.dbService, this.eventService, this.chainService);
|
|
96
94
|
this.balanceService = new BalanceService(this);
|
|
97
95
|
this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService, this.subscanService);
|
|
98
|
-
this.
|
|
96
|
+
this.transactionService = new TransactionService(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
99
97
|
this.walletConnectService = new WalletConnectService(this, this.requestService);
|
|
100
98
|
this.migrationService = new MigrationService(this, this.eventService);
|
|
101
99
|
this.campaignService = new CampaignService(this);
|
|
102
100
|
this.buyService = new BuyService(this);
|
|
103
|
-
this.transactionService = new TransactionService(this);
|
|
104
|
-
this.earningService = new EarningService(this);
|
|
105
101
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
106
102
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
107
103
|
this.logger = createLogger('State');
|
|
@@ -222,7 +218,6 @@ export default class KoniState {
|
|
|
222
218
|
await this.migrationService.run();
|
|
223
219
|
this.campaignService.init();
|
|
224
220
|
this.eventService.emit('chain.ready', true);
|
|
225
|
-
await this.earningService.init();
|
|
226
221
|
this.onReady();
|
|
227
222
|
this.onAccountAdd();
|
|
228
223
|
this.onAccountRemove();
|
|
@@ -245,13 +240,20 @@ export default class KoniState {
|
|
|
245
240
|
}
|
|
246
241
|
async startSubscription() {
|
|
247
242
|
await this.eventService.waitKeyringReady;
|
|
248
|
-
await this.eventService.waitAssetReady;
|
|
249
243
|
this.dbService.subscribeChainStakingMetadata([], data => {
|
|
250
244
|
this.chainStakingMetadataSubject.next(data);
|
|
251
245
|
});
|
|
252
246
|
this.dbService.subscribeMantaPayConfig(_DEFAULT_MANTA_ZK_CHAIN, data => {
|
|
253
247
|
this.mantaPayConfigSubject.next(data);
|
|
254
248
|
});
|
|
249
|
+
let unsub;
|
|
250
|
+
this.keyringService.accountSubject.subscribe(accounts => {
|
|
251
|
+
// TODO: improve this
|
|
252
|
+
unsub && unsub.unsubscribe();
|
|
253
|
+
unsub = this.dbService.subscribeNominatorMetadata(Object.keys(accounts), data => {
|
|
254
|
+
this.stakingNominatorMetadataSubject.next(data);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
255
257
|
}
|
|
256
258
|
onReady() {
|
|
257
259
|
// Todo: Need optimize in the future to, only run important services onetime to save resources
|
|
@@ -1407,7 +1409,7 @@ export default class KoniState {
|
|
|
1407
1409
|
// Stopping services
|
|
1408
1410
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1409
1411
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1410
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop()
|
|
1412
|
+
await Promise.all([this.historyService.stop(), this.priceService.stop()]);
|
|
1411
1413
|
|
|
1412
1414
|
// Complete sleeping
|
|
1413
1415
|
sleeping.resolve();
|
|
@@ -1439,7 +1441,7 @@ export default class KoniState {
|
|
|
1439
1441
|
}
|
|
1440
1442
|
|
|
1441
1443
|
// Start services
|
|
1442
|
-
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start()
|
|
1444
|
+
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start()]);
|
|
1443
1445
|
|
|
1444
1446
|
// Complete starting
|
|
1445
1447
|
starting.resolve();
|
|
@@ -1540,7 +1542,7 @@ export default class KoniState {
|
|
|
1540
1542
|
return await this.cron.reloadNft();
|
|
1541
1543
|
}
|
|
1542
1544
|
async reloadStaking() {
|
|
1543
|
-
await this.
|
|
1545
|
+
await this.subscription.reloadStaking();
|
|
1544
1546
|
return true;
|
|
1545
1547
|
}
|
|
1546
1548
|
async reloadBalance() {
|
|
@@ -1739,11 +1741,4 @@ export default class KoniState {
|
|
|
1739
1741
|
specVersion: parseInt((metadata === null || metadata === void 0 ? void 0 : metadata.specVersion) || '0')
|
|
1740
1742
|
};
|
|
1741
1743
|
}
|
|
1742
|
-
getCrowdloanContributions({
|
|
1743
|
-
address,
|
|
1744
|
-
page,
|
|
1745
|
-
relayChain
|
|
1746
|
-
}) {
|
|
1747
|
-
return this.subscanService.getCrowdloanContributions(relayChain, address, page);
|
|
1748
|
-
}
|
|
1749
1744
|
}
|
|
@@ -58,8 +58,7 @@ export default function handlers({
|
|
|
58
58
|
assert(port, 'Port has been disconnected');
|
|
59
59
|
port.postMessage({
|
|
60
60
|
id,
|
|
61
|
-
response
|
|
62
|
-
sender: 'BACKGROUND'
|
|
61
|
+
response
|
|
63
62
|
});
|
|
64
63
|
}).catch(error => {
|
|
65
64
|
console.error(error);
|
|
@@ -71,8 +70,7 @@ export default function handlers({
|
|
|
71
70
|
error: error.message,
|
|
72
71
|
errorCode: error.code,
|
|
73
72
|
errorData: error.data,
|
|
74
|
-
id
|
|
75
|
-
sender: 'BACKGROUND'
|
|
73
|
+
id
|
|
76
74
|
});
|
|
77
75
|
}
|
|
78
76
|
});
|
|
@@ -2,7 +2,7 @@ import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
|
2
2
|
import { _ChainState, _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
3
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
4
4
|
import KoniState from './handlers/State';
|
|
5
|
-
declare type SubscriptionName = 'balance' | 'crowdloan' | '
|
|
5
|
+
declare type SubscriptionName = 'balance' | 'crowdloan' | 'stakingOnChain' | 'essentialChainStakingMetadata';
|
|
6
6
|
export declare class KoniSubscription {
|
|
7
7
|
private eventHandler?;
|
|
8
8
|
private subscriptionMap;
|
|
@@ -18,11 +18,16 @@ export declare class KoniSubscription {
|
|
|
18
18
|
stop(): Promise<void>;
|
|
19
19
|
subscribeBalances(address: string, chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>, web3ApiMap: Record<string, _EvmApi>, onlyRunOnFirstTime?: boolean): void;
|
|
20
20
|
subscribeCrowdloans(address: string, substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): void;
|
|
21
|
+
subscribeStakingOnChain(address: string, substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): void;
|
|
22
|
+
initStakingOnChainSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
23
|
+
initEssentialChainStakingMetadataSubscription(substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
21
24
|
initBalanceSubscription(addresses: string[], chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
22
25
|
initCrowdloanSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
23
26
|
subscribeNft(address: string, substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>): void;
|
|
24
27
|
initNftSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>): void;
|
|
25
28
|
subscribeStakingReward(address: string): Promise<void>;
|
|
29
|
+
subscribeStakingRewardFastInterval(address: string): Promise<void>;
|
|
30
|
+
reloadStaking(): Promise<void>;
|
|
26
31
|
reloadBalance(): Promise<void>;
|
|
27
32
|
reloadCrowdloan(): Promise<void>;
|
|
28
33
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { subscribeCrowdloan } from '@subwallet/extension-base/koni/api/dotsama/crowdloan';
|
|
5
|
-
import { getNominationStakingRewardData } from '@subwallet/extension-base/koni/api/staking';
|
|
5
|
+
import { getNominationStakingRewardData, getPoolingStakingRewardData, stakingOnChainApi } from '@subwallet/extension-base/koni/api/staking';
|
|
6
|
+
import { subscribeEssentialChainStakingMetadata } from '@subwallet/extension-base/koni/api/staking/bonding';
|
|
7
|
+
import { getAmplitudeUnclaimedStakingReward } from '@subwallet/extension-base/koni/api/staking/paraChain';
|
|
6
8
|
import { nftHandler } from '@subwallet/extension-base/koni/background/handlers';
|
|
7
9
|
import { subscribeBalance } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/balance';
|
|
8
10
|
import { _isChainEnabled, _isChainSupportSubstrateStaking } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -13,8 +15,8 @@ export class KoniSubscription {
|
|
|
13
15
|
subscriptionMap = {
|
|
14
16
|
crowdloan: undefined,
|
|
15
17
|
balance: undefined,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
stakingOnChain: undefined,
|
|
19
|
+
essentialChainStakingMetadata: undefined
|
|
18
20
|
};
|
|
19
21
|
constructor(state, dbService) {
|
|
20
22
|
this.dbService = dbService;
|
|
@@ -41,6 +43,10 @@ export class KoniSubscription {
|
|
|
41
43
|
this.subscriptionMap.crowdloan();
|
|
42
44
|
delete this.subscriptionMap.crowdloan;
|
|
43
45
|
}
|
|
46
|
+
if (this.subscriptionMap.stakingOnChain) {
|
|
47
|
+
this.subscriptionMap.stakingOnChain();
|
|
48
|
+
delete this.subscriptionMap.stakingOnChain;
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
async start() {
|
|
46
52
|
var _this$state$keyringSe;
|
|
@@ -49,6 +55,7 @@ export class KoniSubscription {
|
|
|
49
55
|
if (currentAddress) {
|
|
50
56
|
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
51
57
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
58
|
+
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
52
59
|
}
|
|
53
60
|
this.eventHandler = (events, eventTypes) => {
|
|
54
61
|
var _serviceInfo$currentA;
|
|
@@ -63,6 +70,7 @@ export class KoniSubscription {
|
|
|
63
70
|
}
|
|
64
71
|
this.subscribeBalances(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
|
|
65
72
|
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
73
|
+
this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
|
|
66
74
|
};
|
|
67
75
|
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
68
76
|
}
|
|
@@ -92,6 +100,55 @@ export class KoniSubscription {
|
|
|
92
100
|
this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
93
101
|
}).catch(console.error);
|
|
94
102
|
}
|
|
103
|
+
subscribeStakingOnChain(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
104
|
+
this.state.resetStaking(address);
|
|
105
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
106
|
+
if (!addresses.length) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.updateSubscription('stakingOnChain', this.initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
110
|
+
this.updateSubscription('essentialChainStakingMetadata', this.initEssentialChainStakingMetadataSubscription(substrateApiMap, onlyRunOnFirstTime)); // TODO: might not need to re-subscribe on changing account
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
|
|
114
|
+
const stakingCallback = (networkKey, rs) => {
|
|
115
|
+
this.state.setStakingItem(networkKey, rs);
|
|
116
|
+
};
|
|
117
|
+
const nominatorStateCallback = nominatorMetadata => {
|
|
118
|
+
this.state.updateStakingNominatorMetadata(nominatorMetadata);
|
|
119
|
+
};
|
|
120
|
+
const unsub = stakingOnChainApi(addresses, substrateApiMap, this.state.getActiveChainInfoMap(), stakingCallback, nominatorStateCallback);
|
|
121
|
+
if (onlyRunOnFirstTime) {
|
|
122
|
+
unsub && unsub();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
return () => {
|
|
126
|
+
unsub && unsub();
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
initEssentialChainStakingMetadataSubscription(substrateApiMap, onlyRunOnFirstTime) {
|
|
130
|
+
const unsub = subscribeEssentialChainStakingMetadata(substrateApiMap, this.state.getActiveChainInfoMap(), (networkKey, rs) => {
|
|
131
|
+
this.state.updateChainStakingMetadata(rs, {
|
|
132
|
+
era: rs.era,
|
|
133
|
+
minStake: rs.minStake,
|
|
134
|
+
maxValidatorPerNominator: rs.maxValidatorPerNominator,
|
|
135
|
+
// temporary fix for Astar, there's no limit for now
|
|
136
|
+
maxWithdrawalRequestPerValidator: rs.maxWithdrawalRequestPerValidator,
|
|
137
|
+
// by default
|
|
138
|
+
allowCancelUnstaking: rs.allowCancelUnstaking,
|
|
139
|
+
unstakingPeriod: rs.unstakingPeriod,
|
|
140
|
+
expectedReturn: rs.expectedReturn,
|
|
141
|
+
inflation: rs.inflation
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
if (onlyRunOnFirstTime) {
|
|
145
|
+
unsub && unsub();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
return () => {
|
|
149
|
+
unsub && unsub();
|
|
150
|
+
};
|
|
151
|
+
}
|
|
95
152
|
initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, evmApiMap, onlyRunOnFirstTime) {
|
|
96
153
|
const filteredChainInfoMap = {};
|
|
97
154
|
Object.values(chainStateMap).forEach(chainState => {
|
|
@@ -118,11 +175,15 @@ export class KoniSubscription {
|
|
|
118
175
|
this.state.setCrowdloanItem(networkKey, rs);
|
|
119
176
|
});
|
|
120
177
|
if (onlyRunOnFirstTime) {
|
|
121
|
-
subscriptionPromise.then(unsub =>
|
|
178
|
+
subscriptionPromise.then(unsub => {
|
|
179
|
+
unsub && unsub();
|
|
180
|
+
}).catch(this.logger.warn);
|
|
122
181
|
return;
|
|
123
182
|
}
|
|
124
183
|
return () => {
|
|
125
|
-
subscriptionPromise.then(unsub =>
|
|
184
|
+
subscriptionPromise.then(unsub => {
|
|
185
|
+
unsub && unsub();
|
|
186
|
+
}).catch(this.logger.warn);
|
|
126
187
|
};
|
|
127
188
|
}
|
|
128
189
|
subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
|
|
@@ -156,16 +217,51 @@ export class KoniSubscription {
|
|
|
156
217
|
this.state.updateStakingReward(rewardItem);
|
|
157
218
|
});
|
|
158
219
|
}
|
|
159
|
-
async
|
|
220
|
+
async subscribeStakingRewardFastInterval(address) {
|
|
221
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
222
|
+
if (!addresses.length) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const pooledStakingItems = await this.state.getPooledStakingRecordsByAddress(addresses);
|
|
226
|
+
const pooledAddresses = [];
|
|
227
|
+
pooledStakingItems.forEach(pooledItem => {
|
|
228
|
+
if (!pooledAddresses.includes(pooledItem.address)) {
|
|
229
|
+
pooledAddresses.push(pooledItem.address);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const chainInfoMap = this.state.getChainInfoMap();
|
|
233
|
+
const targetChainMap = {};
|
|
234
|
+
Object.entries(chainInfoMap).forEach(([key, network]) => {
|
|
235
|
+
const chainState = this.state.getChainStateByKey(key);
|
|
236
|
+
if (_isChainEnabled(chainState) && _isChainSupportSubstrateStaking(network)) {
|
|
237
|
+
targetChainMap[key] = network;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const activeNetworks = [];
|
|
241
|
+
Object.keys(targetChainMap).forEach(key => {
|
|
242
|
+
activeNetworks.push(key);
|
|
243
|
+
});
|
|
244
|
+
const updateState = result => {
|
|
245
|
+
this.state.updateStakingReward(result);
|
|
246
|
+
};
|
|
247
|
+
await Promise.all([getPoolingStakingRewardData(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap(), updateState), getAmplitudeUnclaimedStakingReward(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks, updateState)]);
|
|
248
|
+
}
|
|
249
|
+
async reloadStaking() {
|
|
160
250
|
var _this$state$keyringSe2;
|
|
161
251
|
const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.address;
|
|
252
|
+
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
253
|
+
await waitTimeout(1800);
|
|
254
|
+
}
|
|
255
|
+
async reloadBalance() {
|
|
256
|
+
var _this$state$keyringSe3;
|
|
257
|
+
const currentAddress = (_this$state$keyringSe3 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe3 === void 0 ? void 0 : _this$state$keyringSe3.address;
|
|
162
258
|
await this.state.handleResetBalance(currentAddress, true);
|
|
163
259
|
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
164
260
|
await waitTimeout(1800);
|
|
165
261
|
}
|
|
166
262
|
async reloadCrowdloan() {
|
|
167
|
-
var _this$state$
|
|
168
|
-
const currentAddress = (_this$state$
|
|
263
|
+
var _this$state$keyringSe4;
|
|
264
|
+
const currentAddress = (_this$state$keyringSe4 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe4 === void 0 ? void 0 : _this$state$keyringSe4.address;
|
|
169
265
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
170
266
|
await waitTimeout(1800);
|
|
171
267
|
}
|