@subwallet/extension-base 1.1.31-1 → 1.1.31-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 +17 -15
- 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 +11 -1
- package/cjs/koni/background/handlers/Extension.js +362 -69
- package/cjs/koni/background/handlers/State.js +51 -3
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +95 -37
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -16
- package/cjs/services/chain-service/index.js +3 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +29 -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 +259 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +20 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +191 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +239 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +297 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +226 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +395 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +384 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +461 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +159 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +385 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +560 -0
- package/cjs/services/earning-service/handlers/special.js +503 -0
- package/cjs/services/earning-service/service.js +387 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +4 -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 +7 -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 +1 -1
- package/cjs/services/storage-service/DatabaseService.js +51 -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 +65 -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 +231 -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/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/number.js +3 -1
- 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 +11 -9
- 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 +1 -0
- package/koni/background/cron.js +12 -2
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +321 -30
- package/koni/background/handlers/State.d.ts +18 -2
- package/koni/background/handlers/State.js +50 -3
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +97 -38
- package/package.json +316 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +1 -14
- package/services/chain-service/index.js +3 -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 +14 -0
- package/services/earning-service/constants/chains.js +21 -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 +112 -0
- package/services/earning-service/handlers/base.js +253 -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 +6 -0
- package/services/earning-service/handlers/lending/base.js +12 -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 +183 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +231 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +9 -0
- package/services/earning-service/handlers/liquid-staking/base.js +35 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +286 -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 +218 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +385 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +375 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +451 -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 +150 -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 +377 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +549 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +550 -0
- package/services/earning-service/handlers/special.d.ts +65 -0
- package/services/earning-service/handlers/special.js +495 -0
- package/services/earning-service/service.d.ts +45 -0
- package/services/earning-service/service.js +379 -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 +1 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +8 -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 +7 -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 +1 -1
- package/services/storage-service/DatabaseService.d.ts +18 -1
- package/services/storage-service/DatabaseService.js +51 -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 +9 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +57 -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 +4 -15
- package/services/transaction-service/index.js +229 -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 +57 -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 +45 -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 +251 -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/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +53 -1
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -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';
|