@subwallet/extension-base 1.1.35-0 → 1.1.35-beta.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 +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +19 -16
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +1 -16
- package/cjs/services/chain-service/index.js +6 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +30 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +262 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +81 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
- package/cjs/services/earning-service/handlers/special.js +493 -0
- package/cjs/services/earning-service/service.js +733 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +3 -2
- package/cjs/services/request-service/handler/PopupHandler.js +2 -3
- package/cjs/services/storage-service/DatabaseService.js +63 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +249 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/environment.js +23 -28
- package/cjs/utils/fetchStaticCache.js +22 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +94 -10
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/mv3.js +14 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +13 -10
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +0 -4
- package/koni/background/cron.js +4 -22
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +327 -30
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +17 -12
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +8 -104
- package/package.json +326 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -12
- package/services/chain-service/constants.js +0 -14
- package/services/chain-service/index.js +6 -2
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +15 -0
- package/services/earning-service/constants/chains.js +22 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +113 -0
- package/services/earning-service/handlers/base.js +256 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +8 -0
- package/services/earning-service/handlers/lending/base.js +73 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +184 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
- package/services/earning-service/handlers/liquid-staking/base.js +89 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +456 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +152 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +556 -0
- package/services/earning-service/handlers/special.d.ts +64 -0
- package/services/earning-service/handlers/special.js +485 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +722 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +6 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +3 -2
- package/services/request-service/handler/PopupHandler.js +3 -4
- package/services/storage-service/DatabaseService.d.ts +22 -1
- package/services/storage-service/DatabaseService.js +63 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +6 -13
- package/services/transaction-service/index.js +247 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +58 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +252 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/environment.d.ts +9 -2
- package/utils/environment.js +14 -26
- package/utils/fetchStaticCache.d.ts +1 -0
- package/utils/fetchStaticCache.js +14 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -1
- package/utils/index.js +53 -3
- package/utils/mv3.d.ts +2 -0
- package/utils/mv3.js +6 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -12,6 +12,8 @@ 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"));
|
|
15
17
|
var _utils = require("@subwallet/extension-base/utils");
|
|
16
18
|
var _dexieExportImport = require("dexie-export-import");
|
|
17
19
|
var _util = require("@polkadot/util");
|
|
@@ -42,6 +44,9 @@ class DatabaseService {
|
|
|
42
44
|
metadata: new _dbStores.MetadataStore(this._db.metadata),
|
|
43
45
|
chain: new _dbStores.ChainStore(this._db.chain),
|
|
44
46
|
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),
|
|
45
50
|
// staking
|
|
46
51
|
chainStakingMetadata: new _ChainStakingMetadata.default(this._db.chainStakingMetadata),
|
|
47
52
|
nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata),
|
|
@@ -283,6 +288,64 @@ class DatabaseService {
|
|
|
283
288
|
return this.stores.mantaPay.getFirstConfig(chain);
|
|
284
289
|
}
|
|
285
290
|
|
|
291
|
+
/* Earning */
|
|
292
|
+
|
|
293
|
+
async removeOldEarningData() {
|
|
294
|
+
await this.stores.yieldPoolInfo.clear();
|
|
295
|
+
await this.stores.yieldPosition.clear();
|
|
296
|
+
}
|
|
297
|
+
async updateYieldPoolStore(data) {
|
|
298
|
+
await this.stores.yieldPoolInfo.upsert(data);
|
|
299
|
+
}
|
|
300
|
+
async updateYieldPoolsStore(data) {
|
|
301
|
+
await this.stores.yieldPoolInfo.bulkUpsert(data);
|
|
302
|
+
}
|
|
303
|
+
async deleteYieldPoolInfo(slugs) {
|
|
304
|
+
await this.stores.yieldPoolInfo.bulkDelete(slugs);
|
|
305
|
+
}
|
|
306
|
+
async getYieldPools() {
|
|
307
|
+
return this.stores.yieldPoolInfo.getAll();
|
|
308
|
+
}
|
|
309
|
+
async getYieldPoolStakingInfo(chain, poolType) {
|
|
310
|
+
return this.stores.yieldPoolInfo.getByChainAndType(chain, poolType);
|
|
311
|
+
}
|
|
312
|
+
async getYieldPool(slug) {
|
|
313
|
+
return this.stores.yieldPoolInfo.getBySlug(slug);
|
|
314
|
+
}
|
|
315
|
+
async getYieldPositionByAddressAndSlug(address, slug) {
|
|
316
|
+
return this.stores.yieldPosition.getByAddressAndSlug(address, slug);
|
|
317
|
+
}
|
|
318
|
+
subscribeYieldPoolInfo(chains, callback) {
|
|
319
|
+
this.yieldInfoSubscription && this.yieldInfoSubscription.unsubscribe();
|
|
320
|
+
this.yieldInfoSubscription = this.stores.yieldPoolInfo.subscribeYieldPoolInfo(chains).subscribe({
|
|
321
|
+
next: data => callback && callback(data)
|
|
322
|
+
});
|
|
323
|
+
return this.yieldInfoSubscription;
|
|
324
|
+
}
|
|
325
|
+
removeYieldPositionByAddresses(addresses) {
|
|
326
|
+
return this.stores.yieldPosition.removeByAddresses(addresses);
|
|
327
|
+
}
|
|
328
|
+
removeYieldPositionByChains(chains) {
|
|
329
|
+
return this.stores.yieldPosition.removeByChains(chains);
|
|
330
|
+
}
|
|
331
|
+
async updateYieldPosition(data) {
|
|
332
|
+
await this.stores.yieldPosition.upsert(data);
|
|
333
|
+
}
|
|
334
|
+
async updateYieldPositions(data) {
|
|
335
|
+
await this.stores.yieldPosition.bulkUpsert(data);
|
|
336
|
+
}
|
|
337
|
+
async getYieldPositionByAddress(addresses) {
|
|
338
|
+
return this.stores.yieldPosition.getByAddress(addresses);
|
|
339
|
+
}
|
|
340
|
+
subscribeYieldPosition(addresses, callback) {
|
|
341
|
+
return this.stores.yieldPosition.subscribeYieldPositions(addresses).subscribe({
|
|
342
|
+
next: data => callback && callback(data)
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async getYieldNominationPoolPosition(addresses, chains) {
|
|
346
|
+
return this.stores.yieldPosition.getByAddressAndChains(addresses, chains);
|
|
347
|
+
}
|
|
348
|
+
|
|
286
349
|
/* Campaign */
|
|
287
350
|
|
|
288
351
|
getAllCampaign() {
|
|
@@ -40,6 +40,10 @@ 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, {
|
|
43
47
|
campaign: 'slug'
|
|
44
48
|
});
|
|
45
49
|
}
|
|
@@ -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");
|
|
9
8
|
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 !== _types.EarningStatus.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 !== _types.EarningStatus.NOT_STAKING).toArray();
|
|
26
26
|
}
|
|
27
27
|
async removeByAddress(address) {
|
|
28
28
|
return this.table.where('address').anyOfIgnoreCase(address).delete();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
|
|
9
|
+
var _dexie = require("dexie");
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
class YieldPoolStore extends _BaseStore.default {
|
|
14
|
+
async getAll() {
|
|
15
|
+
return this.table.toArray();
|
|
16
|
+
}
|
|
17
|
+
async getByChains(chains) {
|
|
18
|
+
if (chains.length === 0) {
|
|
19
|
+
return this.getAll();
|
|
20
|
+
}
|
|
21
|
+
return this.table.where('chain').anyOfIgnoreCase(chains).toArray();
|
|
22
|
+
}
|
|
23
|
+
async getByChainAndType(chain, poolType) {
|
|
24
|
+
return this.table.where('chain').equals(chain).and(item => item.type === poolType).first();
|
|
25
|
+
}
|
|
26
|
+
async bulkDelete(slugs) {
|
|
27
|
+
return this.table.bulkDelete(slugs);
|
|
28
|
+
}
|
|
29
|
+
async getBySlug(slug) {
|
|
30
|
+
return this.table.get(slug);
|
|
31
|
+
}
|
|
32
|
+
subscribeYieldPoolInfo(chains) {
|
|
33
|
+
return (0, _dexie.liveQuery)(() => this.getByChains(chains));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = YieldPoolStore;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
|
|
9
|
+
var _dexie = require("dexie");
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
class YieldPositionStore extends _BaseStore.default {
|
|
14
|
+
async getAll() {
|
|
15
|
+
return this.table
|
|
16
|
+
// .filter((item) => {
|
|
17
|
+
// let isValidLiquidStaking = false;
|
|
18
|
+
//
|
|
19
|
+
// if (item.type === YieldPoolType.LIQUID_STAKING) {
|
|
20
|
+
// const nominatorMetadata = item.metadata as NominatorMetadata;
|
|
21
|
+
//
|
|
22
|
+
// if (nominatorMetadata.unstakings.length > 0) {
|
|
23
|
+
// console.log('true', item);
|
|
24
|
+
// isValidLiquidStaking = true;
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
//
|
|
28
|
+
// return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
|
|
29
|
+
// })
|
|
30
|
+
.toArray();
|
|
31
|
+
}
|
|
32
|
+
async getByAddress(addresses) {
|
|
33
|
+
if (addresses.length === 0) {
|
|
34
|
+
return this.getAll();
|
|
35
|
+
}
|
|
36
|
+
return this.table.where('address').anyOfIgnoreCase(addresses)
|
|
37
|
+
// .filter((item) => {
|
|
38
|
+
// let isValidLiquidStaking = false;
|
|
39
|
+
//
|
|
40
|
+
// if (item.type === YieldPoolType.LIQUID_STAKING) {
|
|
41
|
+
// const nominatorMetadata = item.metadata as NominatorMetadata;
|
|
42
|
+
//
|
|
43
|
+
// if (nominatorMetadata && nominatorMetadata?.unstakings?.length > 0) {
|
|
44
|
+
// isValidLiquidStaking = true;
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
//
|
|
48
|
+
// return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
|
|
49
|
+
// })
|
|
50
|
+
.toArray();
|
|
51
|
+
}
|
|
52
|
+
removeByAddresses(addresses) {
|
|
53
|
+
return this.table.where('address').anyOf(addresses).delete();
|
|
54
|
+
}
|
|
55
|
+
removeByChains(chains) {
|
|
56
|
+
return this.table.where('chain').anyOf(chains).delete();
|
|
57
|
+
}
|
|
58
|
+
async getByAddressAndChains(addresses, chains) {
|
|
59
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).filter(item => chains.includes(item.chain)).toArray();
|
|
60
|
+
}
|
|
61
|
+
getByAddressAndSlug(address, slug) {
|
|
62
|
+
return this.table.get({
|
|
63
|
+
address,
|
|
64
|
+
slug
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
subscribeYieldPositions(addresses) {
|
|
68
|
+
return (0, _dexie.liveQuery)(() => this.getByAddress(addresses));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.default = YieldPositionStore;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DatabaseService = void 0;
|
|
8
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
|
+
var _databases = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/databases"));
|
|
10
|
+
var _dbStores = require("@subwallet/extension-base/services/storage-service/db-stores");
|
|
11
|
+
var _ChainStakingMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata"));
|
|
12
|
+
var _NominatorMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata"));
|
|
13
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
14
|
+
var _util = require("@polkadot/util");
|
|
15
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
class DatabaseService {
|
|
19
|
+
// TODO: might remove this
|
|
20
|
+
|
|
21
|
+
constructor(eventService) {
|
|
22
|
+
this.eventService = eventService;
|
|
23
|
+
this.logger = (0, _util.logger)('DB-Service');
|
|
24
|
+
this._db = new _databases.default();
|
|
25
|
+
this._db.on('ready', () => {
|
|
26
|
+
this.eventService.emit('database.ready', true);
|
|
27
|
+
});
|
|
28
|
+
this.stores = {
|
|
29
|
+
price: new _dbStores.PriceStore(this._db.price),
|
|
30
|
+
balance: new _dbStores.BalanceStore(this._db.balances),
|
|
31
|
+
nft: new _dbStores.NftStore(this._db.nfts),
|
|
32
|
+
nftCollection: new _dbStores.NftCollectionStore(this._db.nftCollections),
|
|
33
|
+
crowdloan: new _dbStores.CrowdloanStore(this._db.crowdloans),
|
|
34
|
+
staking: new _dbStores.StakingStore(this._db.stakings),
|
|
35
|
+
transaction: new _dbStores.TransactionStore(this._db.transactions),
|
|
36
|
+
migration: new _dbStores.MigrationStore(this._db.migrations),
|
|
37
|
+
metadata: new _dbStores.MetadataStore(this._db.metadata),
|
|
38
|
+
chain: new _dbStores.ChainStore(this._db.chain),
|
|
39
|
+
asset: new _dbStores.AssetStore(this._db.asset),
|
|
40
|
+
// staking
|
|
41
|
+
chainStakingMetadata: new _ChainStakingMetadata.default(this._db.chainStakingMetadata),
|
|
42
|
+
nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async updatePriceStore(priceData) {
|
|
46
|
+
await this.stores.price.table.put(priceData);
|
|
47
|
+
}
|
|
48
|
+
async getPriceStore() {
|
|
49
|
+
try {
|
|
50
|
+
const rs = await this.stores.price.table.get('usd');
|
|
51
|
+
return rs;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
this.logger.error(e);
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Balance
|
|
59
|
+
async getStoredBalance() {
|
|
60
|
+
return this.stores.balance.table.toArray();
|
|
61
|
+
}
|
|
62
|
+
async updateBalanceStore(address, item) {
|
|
63
|
+
if (item.state === _KoniTypes.APIItemState.READY) {
|
|
64
|
+
return this.stores.balance.upsert({
|
|
65
|
+
address,
|
|
66
|
+
...item
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async removeFromBalanceStore(assets) {
|
|
71
|
+
return this.stores.balance.removeBySlugs(assets);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Crowdloan
|
|
75
|
+
async updateCrowdloanStore(chain, address, item) {
|
|
76
|
+
if (item.state === _KoniTypes.APIItemState.READY && item.contribute !== '0') {
|
|
77
|
+
return this.stores.crowdloan.upsert({
|
|
78
|
+
chain,
|
|
79
|
+
address,
|
|
80
|
+
...item
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
return this.stores.crowdloan.deleteByChainAndAddress(chain, address);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Staking
|
|
88
|
+
async updateStaking(chain, address, item) {
|
|
89
|
+
if (item.state === _KoniTypes.APIItemState.READY) {
|
|
90
|
+
return this.stores.staking.upsert(item);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async getStakings(addresses, chains) {
|
|
94
|
+
return this.stores.staking.getStakings(addresses, chains);
|
|
95
|
+
}
|
|
96
|
+
async getStakingsByChains(chains) {
|
|
97
|
+
return this.stores.staking.getStakingsByChains(chains);
|
|
98
|
+
}
|
|
99
|
+
async getPooledStakings(addresses, chainHashes) {
|
|
100
|
+
return this.stores.staking.getPooledStakings(addresses, chainHashes);
|
|
101
|
+
}
|
|
102
|
+
subscribeStaking(addresses, chainList, callback) {
|
|
103
|
+
this.stakingSubscription && this.stakingSubscription.unsubscribe();
|
|
104
|
+
this.stakingSubscription = this.stores.staking.subscribeStaking(addresses, chainList).subscribe({
|
|
105
|
+
next: stakings => callback && callback(stakings)
|
|
106
|
+
});
|
|
107
|
+
return this.stakingSubscription;
|
|
108
|
+
}
|
|
109
|
+
subscribeChainStakingMetadata(chains, callback) {
|
|
110
|
+
this.stores.chainStakingMetadata.subscribeByChain(chains).subscribe({
|
|
111
|
+
next: data => callback && callback(data)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
subscribeNominatorMetadata(addresses, callback) {
|
|
115
|
+
return this.stores.nominatorMetadata.subscribeByAddresses(addresses).subscribe({
|
|
116
|
+
next: data => callback && callback(data)
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Transaction histories
|
|
121
|
+
async getHistories(query) {
|
|
122
|
+
return this.stores.transaction.queryHistory(query);
|
|
123
|
+
}
|
|
124
|
+
async upsertHistory(histories) {
|
|
125
|
+
const cleanedHistory = histories.filter(x => x && x.address && x.chain && x.extrinsicHash);
|
|
126
|
+
return this.stores.transaction.bulkUpsert(cleanedHistory);
|
|
127
|
+
}
|
|
128
|
+
async updateHistoryByExtrinsicHash(extrinsicHash, updateData) {
|
|
129
|
+
const canUpdate = updateData && extrinsicHash;
|
|
130
|
+
if (!canUpdate) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
return this.stores.transaction.updateWithQuery({
|
|
134
|
+
extrinsicHash
|
|
135
|
+
}, updateData);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// NFT Collection
|
|
139
|
+
async addNftCollection(collection) {
|
|
140
|
+
return this.stores.nftCollection.upsert(collection);
|
|
141
|
+
}
|
|
142
|
+
async deleteNftCollection(chain, collectionId) {
|
|
143
|
+
await this.stores.nftCollection.removeCollection(chain, collectionId);
|
|
144
|
+
await this.stores.nft.deleteNftsByCollection(chain, collectionId);
|
|
145
|
+
}
|
|
146
|
+
getAllNftCollection(chainHashes) {
|
|
147
|
+
return this.stores.nftCollection.getNftCollection(chainHashes);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// NFT
|
|
151
|
+
subscribeNft(addresses, chainHashes, callback) {
|
|
152
|
+
this.nftSubscription && this.nftSubscription.unsubscribe();
|
|
153
|
+
this.nftSubscription = this.stores.nft.subscribeNft(addresses, chainHashes).subscribe({
|
|
154
|
+
next: nfts => callback && callback(nfts)
|
|
155
|
+
});
|
|
156
|
+
return this.nftSubscription;
|
|
157
|
+
}
|
|
158
|
+
async cleanUpNft(chain, owner, collectionIds, nftIds, ownNothing) {
|
|
159
|
+
if (ownNothing) {
|
|
160
|
+
return this.stores.nft.deleteNftsByChainAndOwner(chain, (0, _utils.reformatAddress)(owner, 42), collectionIds);
|
|
161
|
+
}
|
|
162
|
+
return this.stores.nft.cleanUpNfts(chain, (0, _utils.reformatAddress)(owner, 42), collectionIds, nftIds);
|
|
163
|
+
}
|
|
164
|
+
async getNft(addresses, chainHashes) {
|
|
165
|
+
return this.stores.nft.getNft(addresses, chainHashes);
|
|
166
|
+
}
|
|
167
|
+
async addNft(address, nft) {
|
|
168
|
+
return this.stores.nft.upsert({
|
|
169
|
+
...nft,
|
|
170
|
+
address
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
handleNftTransfer(chain, addresses, nftItem) {
|
|
174
|
+
return this.stores.nft.deleteNftItem(chain, addresses, nftItem);
|
|
175
|
+
}
|
|
176
|
+
removeNfts(chain, address, collectionId, nftIds) {
|
|
177
|
+
return this.stores.nft.removeNfts(chain, address, collectionId, nftIds);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Chain
|
|
181
|
+
async updateChainStore(item) {
|
|
182
|
+
return this.stores.chain.upsert(item);
|
|
183
|
+
}
|
|
184
|
+
async bulkUpdateChainStore(data) {
|
|
185
|
+
return this.stores.chain.bulkUpsert(data);
|
|
186
|
+
}
|
|
187
|
+
async removeFromChainStore(chains) {
|
|
188
|
+
return this.stores.chain.removeChains(chains);
|
|
189
|
+
}
|
|
190
|
+
async getAllChainStore() {
|
|
191
|
+
return this.stores.chain.getAll();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Asset
|
|
195
|
+
async updateAssetStore(item) {
|
|
196
|
+
return this.stores.asset.upsert(item);
|
|
197
|
+
}
|
|
198
|
+
async getAllAssetStore() {
|
|
199
|
+
return this.stores.asset.getAll();
|
|
200
|
+
}
|
|
201
|
+
async removeFromAssetStore(items) {
|
|
202
|
+
return this.stores.asset.removeAssets(items);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Staking
|
|
206
|
+
async updateChainStakingMetadata(item, changes) {
|
|
207
|
+
const existingRecord = await this.stores.chainStakingMetadata.getByChainAndType(item.chain, item.type);
|
|
208
|
+
if (existingRecord && changes) {
|
|
209
|
+
return this.stores.chainStakingMetadata.updateByChainAndType(item.chain, item.type, changes);
|
|
210
|
+
}
|
|
211
|
+
return this.stores.chainStakingMetadata.upsert(item);
|
|
212
|
+
}
|
|
213
|
+
async getChainStakingMetadata() {
|
|
214
|
+
return this.stores.chainStakingMetadata.getAll();
|
|
215
|
+
}
|
|
216
|
+
async getStakingMetadataByChain(chain) {
|
|
217
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _KoniTypes.StakingType.NOMINATED;
|
|
218
|
+
return this.stores.chainStakingMetadata.getByChainAndType(chain, type);
|
|
219
|
+
}
|
|
220
|
+
async updateNominatorMetadata(item) {
|
|
221
|
+
return this.stores.nominatorMetadata.upsert(item);
|
|
222
|
+
}
|
|
223
|
+
async getNominatorMetadata() {
|
|
224
|
+
return this.stores.nominatorMetadata.getAll();
|
|
225
|
+
}
|
|
226
|
+
async resetWallet(resetAll) {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata];
|
|
229
|
+
if (resetAll) {
|
|
230
|
+
stores.push(this.stores.chain, this.stores.asset);
|
|
231
|
+
}
|
|
232
|
+
const promises = stores.map(store => store.clear());
|
|
233
|
+
Promise.all(promises).then(() => {
|
|
234
|
+
resolve();
|
|
235
|
+
}).catch(e => {
|
|
236
|
+
reject(e);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.DatabaseService = DatabaseService;
|
|
@@ -252,5 +252,21 @@ 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
|
+
}
|
|
255
271
|
}
|
|
256
272
|
exports.SubscanService = SubscanService;
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.parseLiquidStakingEvents = parseLiquidStakingEvents;
|
|
7
|
+
exports.parseLiquidStakingFastUnstakeEvents = parseLiquidStakingFastUnstakeEvents;
|
|
6
8
|
exports.parseTransferEventLogs = parseTransferEventLogs;
|
|
7
9
|
exports.parseXcmEventLogs = parseXcmEventLogs;
|
|
10
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
11
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
9
12
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
13
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -72,4 +75,59 @@ function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTokenInfo,
|
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
78
|
+
}
|
|
79
|
+
function parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, feePaidWithInputAsset, extrinsicType) {
|
|
80
|
+
if (feePaidWithInputAsset) {
|
|
81
|
+
historyItem.fee = {
|
|
82
|
+
value: '0',
|
|
83
|
+
// TODO
|
|
84
|
+
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
85
|
+
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
86
|
+
};
|
|
87
|
+
} else {
|
|
88
|
+
for (let index = 0; index < eventLogs.length; index++) {
|
|
89
|
+
const record = eventLogs[index];
|
|
90
|
+
const {
|
|
91
|
+
decimals: nativeDecimals,
|
|
92
|
+
symbol: nativeSymbol
|
|
93
|
+
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
94
|
+
const section = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
95
|
+
const eventMethod = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
96
|
+
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
97
|
+
var _record$event$data$9;
|
|
98
|
+
if ((_record$event$data$9 = record.event.data[2]) !== null && _record$event$data$9 !== void 0 && _record$event$data$9.toString()) {
|
|
99
|
+
var _record$event$data$10;
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
101
|
+
historyItem.fee = {
|
|
102
|
+
value: ((_record$event$data$10 = record.event.data[2]) === null || _record$event$data$10 === void 0 ? void 0 : _record$event$data$10.toString()) || '0',
|
|
103
|
+
symbol: nativeSymbol,
|
|
104
|
+
decimals: nativeDecimals
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType) {
|
|
112
|
+
for (let index = 0; index < eventLogs.length; index++) {
|
|
113
|
+
const record = eventLogs[index];
|
|
114
|
+
const {
|
|
115
|
+
decimals: nativeDecimals,
|
|
116
|
+
symbol: nativeSymbol
|
|
117
|
+
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
118
|
+
const section = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
119
|
+
const eventMethod = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
120
|
+
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
121
|
+
var _record$event$data$11;
|
|
122
|
+
if ((_record$event$data$11 = record.event.data[2]) !== null && _record$event$data$11 !== void 0 && _record$event$data$11.toString()) {
|
|
123
|
+
var _record$event$data$12;
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
125
|
+
historyItem.fee = {
|
|
126
|
+
value: ((_record$event$data$12 = record.event.data[2]) === null || _record$event$data$12 === void 0 ? void 0 : _record$event$data$12.toString()) || '0',
|
|
127
|
+
symbol: nativeSymbol,
|
|
128
|
+
decimals: nativeDecimals
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
75
133
|
}
|
|
@@ -40,7 +40,7 @@ const typeName = type => {
|
|
|
40
40
|
case _KoniTypes.ExtrinsicType.STAKING_BOND:
|
|
41
41
|
return 'Bond';
|
|
42
42
|
case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
|
|
43
|
-
return '
|
|
43
|
+
return 'Unstake';
|
|
44
44
|
case _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD:
|
|
45
45
|
return 'Claim reward';
|
|
46
46
|
case _KoniTypes.ExtrinsicType.STAKING_WITHDRAW:
|
|
@@ -55,6 +55,8 @@ const typeName = type => {
|
|
|
55
55
|
return 'Cancel compounding';
|
|
56
56
|
case _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW:
|
|
57
57
|
return 'Withdraw pool';
|
|
58
|
+
case _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL:
|
|
59
|
+
return 'Start earning';
|
|
58
60
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
59
61
|
default:
|
|
60
62
|
return 'unknown';
|