@subwallet/extension-base 1.1.31-beta.0 → 1.1.32-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +3 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +29 -28
- 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 +5 -6
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +1 -11
- package/cjs/koni/background/handlers/Extension.js +69 -362
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +37 -95
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +18 -3
- package/cjs/services/chain-service/index.js +2 -3
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- 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 -7
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -51
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -231
- 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 +1 -3
- 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 +9 -11
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +2 -1
- package/koni/api/staking/bonding/index.js +3 -5
- package/koni/api/staking/bonding/paraChain.js +16 -15
- 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 +6 -7
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +0 -1
- package/koni/background/cron.js +2 -12
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -321
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +38 -97
- package/package.json +8 -321
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +11 -0
- package/services/chain-service/constants.js +16 -2
- package/services/chain-service/index.js +2 -3
- 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 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +0 -8
- 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 -7
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -18
- package/services/storage-service/DatabaseService.js +0 -51
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +15 -4
- package/services/transaction-service/index.js +73 -229
- 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 +1 -53
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- 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 -259
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
- package/cjs/services/earning-service/handlers/special.js +0 -503
- package/cjs/services/earning-service/service.js +0 -387
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- 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 -112
- package/services/earning-service/handlers/base.js +0 -253
- 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 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- 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 -183
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
- package/services/earning-service/handlers/liquid-staking/base.js +0 -35
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -451
- 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 -150
- 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 -377
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -550
- package/services/earning-service/handlers/special.d.ts +0 -65
- package/services/earning-service/handlers/special.js +0 -495
- package/services/earning-service/service.d.ts +0 -45
- package/services/earning-service/service.js +0 -379
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -57
- 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 -45
- 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 -251
- 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
|
@@ -1,387 +0,0 @@
|
|
|
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 _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
9
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
10
|
-
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
11
|
-
var _constants = require("@subwallet/extension-base/services/earning-service/constants");
|
|
12
|
-
var _base = _interopRequireDefault(require("@subwallet/extension-base/services/earning-service/handlers/liquid-staking/base"));
|
|
13
|
-
var _types = require("@subwallet/extension-base/types");
|
|
14
|
-
var _utils2 = require("@subwallet/extension-base/utils");
|
|
15
|
-
var _rxjs = require("rxjs");
|
|
16
|
-
var _handlers = require("./handlers");
|
|
17
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
18
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
19
|
-
|
|
20
|
-
class EarningService {
|
|
21
|
-
handlers = {};
|
|
22
|
-
earningRewardSubject = new _rxjs.BehaviorSubject({
|
|
23
|
-
ready: false,
|
|
24
|
-
data: {}
|
|
25
|
-
});
|
|
26
|
-
earningRewardHistorySubject = new _rxjs.BehaviorSubject({});
|
|
27
|
-
minAmountPercentSubject = new _rxjs.BehaviorSubject({});
|
|
28
|
-
constructor(state) {
|
|
29
|
-
this.state = state;
|
|
30
|
-
this.initHandlers().catch(console.error);
|
|
31
|
-
}
|
|
32
|
-
async initHandlers() {
|
|
33
|
-
await this.state.eventService.waitChainReady;
|
|
34
|
-
const chains = Object.keys(this.state.getChainInfoMap());
|
|
35
|
-
const minAmountPercent = {};
|
|
36
|
-
for (const chain of chains) {
|
|
37
|
-
const handlers = [];
|
|
38
|
-
if (_constants._STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
39
|
-
handlers.push(new _handlers.RelayNativeStakingPoolHandler(this.state, chain));
|
|
40
|
-
}
|
|
41
|
-
if (_constants._STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
42
|
-
handlers.push(new _handlers.ParaNativeStakingPoolHandler(this.state, chain));
|
|
43
|
-
}
|
|
44
|
-
if (_constants._STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
45
|
-
handlers.push(new _handlers.AstarNativeStakingPoolHandler(this.state, chain));
|
|
46
|
-
}
|
|
47
|
-
if (_constants._STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
48
|
-
handlers.push(new _handlers.AmplitudeNativeStakingPoolHandler(this.state, chain));
|
|
49
|
-
}
|
|
50
|
-
if (_constants._STAKING_CHAIN_GROUP.nominationPool.includes(chain)) {
|
|
51
|
-
handlers.push(new _handlers.NominationPoolHandler(this.state, chain));
|
|
52
|
-
}
|
|
53
|
-
if (_constants._STAKING_CHAIN_GROUP.liquidStaking.includes(chain)) {
|
|
54
|
-
if (chain === 'bifrost_dot') {
|
|
55
|
-
handlers.push(new _handlers.BifrostLiquidStakingPoolHandler(this.state, chain));
|
|
56
|
-
}
|
|
57
|
-
if (chain === 'acala') {
|
|
58
|
-
handlers.push(new _handlers.AcalaLiquidStakingPoolHandler(this.state, chain));
|
|
59
|
-
}
|
|
60
|
-
if (chain === 'parallel') {
|
|
61
|
-
handlers.push(new _handlers.ParallelLiquidStakingPoolHandler(this.state, chain));
|
|
62
|
-
}
|
|
63
|
-
if (chain === 'moonbeam') {
|
|
64
|
-
handlers.push(new _handlers.StellaSwapLiquidStakingPoolHandler(this.state, chain));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (_constants._STAKING_CHAIN_GROUP.lending.includes(chain)) {
|
|
68
|
-
if (chain === 'interlay') {
|
|
69
|
-
handlers.push(new _handlers.InterlayLendingPoolHandler(this.state, chain));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
for (const handler of handlers) {
|
|
73
|
-
this.handlers[handler.slug] = handler;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
for (const handler of Object.values(this.handlers)) {
|
|
77
|
-
if (handler.type === _types.YieldPoolType.LIQUID_STAKING) {
|
|
78
|
-
minAmountPercent[handler.slug] = handler.minAmountPercent;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
minAmountPercent.default = _base.default.defaultMinAmountPercent;
|
|
82
|
-
this.minAmountPercentSubject.next(minAmountPercent);
|
|
83
|
-
}
|
|
84
|
-
getPoolHandler(slug) {
|
|
85
|
-
return this.handlers[slug];
|
|
86
|
-
}
|
|
87
|
-
isPoolSupportAlternativeFee(slug) {
|
|
88
|
-
const handler = this.getPoolHandler(slug);
|
|
89
|
-
if (handler) {
|
|
90
|
-
return handler.isPoolSupportAlternativeFee;
|
|
91
|
-
} else {
|
|
92
|
-
throw new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
subscribeMinAmountPercent() {
|
|
96
|
-
return this.minAmountPercentSubject;
|
|
97
|
-
}
|
|
98
|
-
getMinAmountPercent() {
|
|
99
|
-
return this.minAmountPercentSubject.getValue();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* Subscribe pools' info */
|
|
103
|
-
|
|
104
|
-
async subscribePoolsInfo(callback) {
|
|
105
|
-
let cancel = false;
|
|
106
|
-
await this.state.eventService.waitChainReady;
|
|
107
|
-
const unsubList = [];
|
|
108
|
-
for (const handler of Object.values(this.handlers)) {
|
|
109
|
-
handler.subscribePoolInfo(callback).then(unsub => {
|
|
110
|
-
if (cancel) {
|
|
111
|
-
unsub();
|
|
112
|
-
} else {
|
|
113
|
-
unsubList.push(unsub);
|
|
114
|
-
}
|
|
115
|
-
}).catch(console.error);
|
|
116
|
-
}
|
|
117
|
-
return () => {
|
|
118
|
-
cancel = true;
|
|
119
|
-
unsubList.forEach(unsub => {
|
|
120
|
-
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/* Subscribe pools' info */
|
|
126
|
-
|
|
127
|
-
/* Subscribe pools' position */
|
|
128
|
-
|
|
129
|
-
async subscribePoolPositions(addresses, callback) {
|
|
130
|
-
let cancel = false;
|
|
131
|
-
await this.state.eventService.waitChainReady;
|
|
132
|
-
const [substrateAddresses, evmAddresses] = (0, _utils2.categoryAddresses)(addresses);
|
|
133
|
-
const activeChains = this.state.activeChainSlugs;
|
|
134
|
-
const unsubList = [];
|
|
135
|
-
for (const handler of Object.values(this.handlers)) {
|
|
136
|
-
if (activeChains.includes(handler.chain)) {
|
|
137
|
-
const chainInfo = handler.chainInfo;
|
|
138
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
139
|
-
handler.subscribePoolPosition(useAddresses, callback).then(unsub => {
|
|
140
|
-
if (cancel) {
|
|
141
|
-
unsub();
|
|
142
|
-
} else {
|
|
143
|
-
unsubList.push(unsub);
|
|
144
|
-
}
|
|
145
|
-
}).catch(console.error);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return () => {
|
|
149
|
-
cancel = true;
|
|
150
|
-
unsubList.forEach(unsub => {
|
|
151
|
-
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/* Subscribe pools' position */
|
|
157
|
-
|
|
158
|
-
/* Get pools' reward */
|
|
159
|
-
|
|
160
|
-
updateEarningReward(stakingRewardData) {
|
|
161
|
-
const stakingRewardState = this.earningRewardSubject.getValue();
|
|
162
|
-
stakingRewardState.ready = true;
|
|
163
|
-
const key = `${stakingRewardData.slug}---${stakingRewardData.address}`;
|
|
164
|
-
stakingRewardState.data[key] = stakingRewardData;
|
|
165
|
-
this.earningRewardSubject.next(stakingRewardState);
|
|
166
|
-
}
|
|
167
|
-
async getPoolReward(addresses, callback) {
|
|
168
|
-
let cancel = false;
|
|
169
|
-
await this.state.eventService.waitChainReady;
|
|
170
|
-
const [substrateAddresses, evmAddresses] = (0, _utils2.categoryAddresses)(addresses);
|
|
171
|
-
const activeChains = this.state.activeChainSlugs;
|
|
172
|
-
const unsubList = [];
|
|
173
|
-
for (const handler of Object.values(this.handlers)) {
|
|
174
|
-
if (activeChains.includes(handler.chain)) {
|
|
175
|
-
const chainInfo = handler.chainInfo;
|
|
176
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
177
|
-
handler.getPoolReward(useAddresses, callback).then(unsub => {
|
|
178
|
-
if (cancel) {
|
|
179
|
-
unsub();
|
|
180
|
-
} else {
|
|
181
|
-
unsubList.push(unsub);
|
|
182
|
-
}
|
|
183
|
-
}).catch(console.error);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return () => {
|
|
187
|
-
cancel = true;
|
|
188
|
-
unsubList.forEach(unsub => {
|
|
189
|
-
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
subscribeEarningReward() {
|
|
194
|
-
return this.earningRewardSubject;
|
|
195
|
-
}
|
|
196
|
-
getEarningRewards() {
|
|
197
|
-
return this.earningRewardSubject.getValue();
|
|
198
|
-
}
|
|
199
|
-
async fetchPoolRewardHistory(addresses, callback) {
|
|
200
|
-
let cancel = false;
|
|
201
|
-
await this.state.eventService.waitChainReady;
|
|
202
|
-
const [substrateAddresses, evmAddresses] = (0, _utils2.categoryAddresses)(addresses);
|
|
203
|
-
const activeChains = this.state.activeChainSlugs;
|
|
204
|
-
const unsubList = [];
|
|
205
|
-
for (const handler of Object.values(this.handlers)) {
|
|
206
|
-
if (activeChains.includes(handler.chain)) {
|
|
207
|
-
const chainInfo = handler.chainInfo;
|
|
208
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
209
|
-
handler.getPoolRewardHistory(useAddresses, callback).then(unsub => {
|
|
210
|
-
if (cancel) {
|
|
211
|
-
unsub();
|
|
212
|
-
} else {
|
|
213
|
-
unsubList.push(unsub);
|
|
214
|
-
}
|
|
215
|
-
}).catch(console.error);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return () => {
|
|
219
|
-
cancel = true;
|
|
220
|
-
unsubList.forEach(unsub => {
|
|
221
|
-
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
updateEarningRewardHistory(earningRewardHistory) {
|
|
226
|
-
const earningRewardHistoryState = this.earningRewardHistorySubject.getValue();
|
|
227
|
-
const key = `${earningRewardHistory.slug}---${earningRewardHistory.address}---${earningRewardHistory.blockTimestamp}`;
|
|
228
|
-
earningRewardHistoryState[key] = earningRewardHistory;
|
|
229
|
-
this.earningRewardHistorySubject.next(earningRewardHistoryState);
|
|
230
|
-
}
|
|
231
|
-
subscribeEarningRewardHistory() {
|
|
232
|
-
return this.earningRewardHistorySubject;
|
|
233
|
-
}
|
|
234
|
-
getEarningRewardHistory() {
|
|
235
|
-
return this.earningRewardHistorySubject.getValue();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/* Get pools' reward */
|
|
239
|
-
|
|
240
|
-
/* Get pool's targets */
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* @async
|
|
244
|
-
* @function getPoolTargets
|
|
245
|
-
* @param {string} slug - Pool's slug
|
|
246
|
-
* @return {Promise<YieldPoolTarget[]>} List of pool's target
|
|
247
|
-
* */
|
|
248
|
-
async getPoolTargets(slug) {
|
|
249
|
-
await this.state.eventService.waitChainReady;
|
|
250
|
-
const handler = this.getPoolHandler(slug);
|
|
251
|
-
if (handler) {
|
|
252
|
-
return await handler.getPoolTargets();
|
|
253
|
-
} else {
|
|
254
|
-
return [];
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/* Get pool's targets */
|
|
259
|
-
|
|
260
|
-
/* Handle actions */
|
|
261
|
-
|
|
262
|
-
/* Join */
|
|
263
|
-
|
|
264
|
-
async earlyValidateJoin(request) {
|
|
265
|
-
await this.state.eventService.waitChainReady;
|
|
266
|
-
const {
|
|
267
|
-
slug
|
|
268
|
-
} = request;
|
|
269
|
-
const handler = this.getPoolHandler(slug);
|
|
270
|
-
if (handler) {
|
|
271
|
-
return handler.earlyValidate(request);
|
|
272
|
-
} else {
|
|
273
|
-
throw new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
async generateOptimalSteps(params) {
|
|
277
|
-
await this.state.eventService.waitChainReady;
|
|
278
|
-
const {
|
|
279
|
-
slug
|
|
280
|
-
} = params;
|
|
281
|
-
const handler = this.getPoolHandler(slug);
|
|
282
|
-
if (handler) {
|
|
283
|
-
return handler.generateOptimalPath(params);
|
|
284
|
-
} else {
|
|
285
|
-
throw new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
async validateYieldJoin(params) {
|
|
289
|
-
await this.state.eventService.waitChainReady;
|
|
290
|
-
const {
|
|
291
|
-
slug
|
|
292
|
-
} = params.data;
|
|
293
|
-
const handler = this.getPoolHandler(slug);
|
|
294
|
-
if (handler) {
|
|
295
|
-
return handler.validateYieldJoin(params.data, params.path);
|
|
296
|
-
} else {
|
|
297
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
async handleYieldJoin(params) {
|
|
301
|
-
await this.state.eventService.waitChainReady;
|
|
302
|
-
const {
|
|
303
|
-
slug
|
|
304
|
-
} = params.data;
|
|
305
|
-
const handler = this.getPoolHandler(slug);
|
|
306
|
-
if (handler) {
|
|
307
|
-
return handler.handleYieldJoin(params.data, params.path, params.currentStep);
|
|
308
|
-
} else {
|
|
309
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/* Join */
|
|
314
|
-
|
|
315
|
-
/* Leave */
|
|
316
|
-
|
|
317
|
-
async validateYieldLeave(params) {
|
|
318
|
-
await this.state.eventService.waitChainReady;
|
|
319
|
-
const {
|
|
320
|
-
slug
|
|
321
|
-
} = params;
|
|
322
|
-
const handler = this.getPoolHandler(slug);
|
|
323
|
-
if (handler) {
|
|
324
|
-
return handler.validateYieldLeave(params.amount, params.address, params.fastLeave, params.selectedTarget);
|
|
325
|
-
} else {
|
|
326
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
async handleYieldLeave(params) {
|
|
330
|
-
await this.state.eventService.waitChainReady;
|
|
331
|
-
const {
|
|
332
|
-
slug
|
|
333
|
-
} = params;
|
|
334
|
-
const handler = this.getPoolHandler(slug);
|
|
335
|
-
if (handler) {
|
|
336
|
-
return handler.handleYieldLeave(params.fastLeave, params.amount, params.address, params.selectedTarget);
|
|
337
|
-
} else {
|
|
338
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/* Leave */
|
|
343
|
-
|
|
344
|
-
/* Other */
|
|
345
|
-
|
|
346
|
-
async handleYieldWithdraw(params) {
|
|
347
|
-
await this.state.eventService.waitChainReady;
|
|
348
|
-
const {
|
|
349
|
-
slug
|
|
350
|
-
} = params;
|
|
351
|
-
const handler = this.getPoolHandler(slug);
|
|
352
|
-
if (handler) {
|
|
353
|
-
return handler.handleYieldWithdraw(params.address, params.unstakingInfo);
|
|
354
|
-
} else {
|
|
355
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
async handleYieldCancelUnstake(params) {
|
|
359
|
-
await this.state.eventService.waitChainReady;
|
|
360
|
-
const {
|
|
361
|
-
slug
|
|
362
|
-
} = params;
|
|
363
|
-
const handler = this.getPoolHandler(slug);
|
|
364
|
-
if (handler) {
|
|
365
|
-
return handler.handleYieldCancelUnstake(params);
|
|
366
|
-
} else {
|
|
367
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
async handleYieldClaimReward(params) {
|
|
371
|
-
await this.state.eventService.waitChainReady;
|
|
372
|
-
const {
|
|
373
|
-
slug
|
|
374
|
-
} = params;
|
|
375
|
-
const handler = this.getPoolHandler(slug);
|
|
376
|
-
if (handler) {
|
|
377
|
-
return handler.handleYieldClaimReward(params.address, params.bondReward);
|
|
378
|
-
} else {
|
|
379
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/* Other */
|
|
384
|
-
|
|
385
|
-
/* Handle actions */
|
|
386
|
-
}
|
|
387
|
-
exports.default = EarningService;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calculateReward = calculateReward;
|
|
7
|
-
exports.isActionFromValidator = isActionFromValidator;
|
|
8
|
-
exports.isNominationPool = exports.isNativeStakingPool = exports.isLiquidPool = exports.isLendingPool = void 0;
|
|
9
|
-
exports.parseIdentity = parseIdentity;
|
|
10
|
-
var _constants = require("@subwallet/extension-base/services/earning-service/constants");
|
|
11
|
-
var _types = require("@subwallet/extension-base/types");
|
|
12
|
-
var _util = require("@polkadot/util");
|
|
13
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
-
|
|
16
|
-
function calculateReward(apr) {
|
|
17
|
-
let amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
18
|
-
let compoundingPeriod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _types.YieldCompoundingPeriod.YEARLY;
|
|
19
|
-
let isApy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
20
|
-
if (!apr) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
if (!isApy) {
|
|
24
|
-
const periodApr = apr / 365 * compoundingPeriod; // APR is always annually
|
|
25
|
-
const earningRatio = periodApr / 100 / compoundingPeriod;
|
|
26
|
-
const periodApy = (1 + earningRatio) ** compoundingPeriod - 1;
|
|
27
|
-
const reward = periodApy * amount;
|
|
28
|
-
return {
|
|
29
|
-
apy: periodApy * 100,
|
|
30
|
-
rewardInToken: reward
|
|
31
|
-
};
|
|
32
|
-
} else {
|
|
33
|
-
const reward = apr / 100 * amount;
|
|
34
|
-
return {
|
|
35
|
-
apy: apr,
|
|
36
|
-
rewardInToken: reward * (compoundingPeriod / _types.YieldCompoundingPeriod.YEARLY)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @returns
|
|
43
|
-
* <p>
|
|
44
|
-
* [0] - identity
|
|
45
|
-
* </p>
|
|
46
|
-
* <p>
|
|
47
|
-
* [1] - isReasonable (isVerified)
|
|
48
|
-
* </p>
|
|
49
|
-
* */
|
|
50
|
-
async function parseIdentity(substrateApi, address, children) {
|
|
51
|
-
const compactResult = rs => {
|
|
52
|
-
const result = [];
|
|
53
|
-
if (rs) {
|
|
54
|
-
result.push(rs);
|
|
55
|
-
}
|
|
56
|
-
if (children) {
|
|
57
|
-
result.push(children);
|
|
58
|
-
}
|
|
59
|
-
if (result.length > 0) {
|
|
60
|
-
return result.join('/');
|
|
61
|
-
} else {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
if (substrateApi.api.query.identity) {
|
|
66
|
-
let identity;
|
|
67
|
-
const _parent = await substrateApi.api.query.identity.superOf(address);
|
|
68
|
-
const parentInfo = _parent.toHuman();
|
|
69
|
-
if (parentInfo) {
|
|
70
|
-
const [parentAddress, {
|
|
71
|
-
Raw: data
|
|
72
|
-
}] = parentInfo;
|
|
73
|
-
const child = (0, _util.isHex)(data) ? (0, _util.hexToString)(data) : data;
|
|
74
|
-
|
|
75
|
-
// TODO: Re-check
|
|
76
|
-
if (address !== parentAddress) {
|
|
77
|
-
const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
|
|
78
|
-
return [compactResult(rs), isReasonable];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
82
|
-
const identityInfo = _identity.toHuman();
|
|
83
|
-
if (identityInfo) {
|
|
84
|
-
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
|
|
85
|
-
const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
|
|
86
|
-
const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
|
|
87
|
-
const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
|
|
88
|
-
const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
|
|
89
|
-
const isReasonable = identityInfo.judgements.length > 0;
|
|
90
|
-
if (displayName) {
|
|
91
|
-
identity = (0, _util.isHex)(displayName) ? (0, _util.hexToString)(displayName) : displayName;
|
|
92
|
-
} else {
|
|
93
|
-
identity = twitter || web || riot;
|
|
94
|
-
}
|
|
95
|
-
return [compactResult(identity), isReasonable];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return [undefined, false];
|
|
99
|
-
}
|
|
100
|
-
function isActionFromValidator(stakingType, chain) {
|
|
101
|
-
if (stakingType === _types.YieldPoolType.NOMINATION_POOL || stakingType === _types.YieldPoolType.LIQUID_STAKING || stakingType === _types.YieldPoolType.LENDING) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
if (_constants._STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
105
|
-
return true;
|
|
106
|
-
} else if (_constants._STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
107
|
-
return true;
|
|
108
|
-
} else if (_constants._STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const isNominationPool = pool => {
|
|
114
|
-
return pool.type === _types.YieldPoolType.NOMINATION_POOL;
|
|
115
|
-
};
|
|
116
|
-
exports.isNominationPool = isNominationPool;
|
|
117
|
-
const isNativeStakingPool = pool => {
|
|
118
|
-
return pool.type === _types.YieldPoolType.NATIVE_STAKING;
|
|
119
|
-
};
|
|
120
|
-
exports.isNativeStakingPool = isNativeStakingPool;
|
|
121
|
-
const isLiquidPool = pool => {
|
|
122
|
-
return pool.type === _types.YieldPoolType.LIQUID_STAKING;
|
|
123
|
-
};
|
|
124
|
-
exports.isLiquidPool = isLiquidPool;
|
|
125
|
-
const isLendingPool = pool => {
|
|
126
|
-
return pool.type === _types.YieldPoolType.LENDING;
|
|
127
|
-
};
|
|
128
|
-
exports.isLendingPool = isLendingPool;
|
|
@@ -1,21 +0,0 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class DeleteEarningData extends _Base.default {
|
|
13
|
-
async run() {
|
|
14
|
-
try {
|
|
15
|
-
await this.state.dbService.deleteYieldPoolInfo(['LcDOT___acala_euphrates_liquid_staking', 'xcDOT___moonwell_lending']);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = DeleteEarningData;
|
|
@@ -1,21 +0,0 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class EnableEarningChains extends _Base.default {
|
|
13
|
-
async run() {
|
|
14
|
-
try {
|
|
15
|
-
await this.state.chainService.enableChains(['moonbeam', 'acala', 'bifrost_dot', 'interlay', 'parallel']);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = EnableEarningChains;
|
|
@@ -1,17 +0,0 @@
|
|
|
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 _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class MigrateEthProvider extends _MigrateProvider.default {
|
|
13
|
-
newProvider = 'ethereum';
|
|
14
|
-
oldProvider = 'Cloudflare';
|
|
15
|
-
slug = 'Llamarpc';
|
|
16
|
-
}
|
|
17
|
-
exports.default = MigrateEthProvider;
|
|
@@ -1,17 +0,0 @@
|
|
|
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 _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class MigratePioneerProvider extends _MigrateProvider.default {
|
|
13
|
-
slug = 'pioneer';
|
|
14
|
-
oldProvider = 'OnFinality';
|
|
15
|
-
newProvider = 'Pioneer';
|
|
16
|
-
}
|
|
17
|
-
exports.default = MigratePioneerProvider;
|
|
@@ -1,29 +0,0 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class MigrateProvider extends _Base.default {
|
|
13
|
-
async run() {
|
|
14
|
-
const state = this.state;
|
|
15
|
-
const chainState = state.getChainStateByKey(this.slug);
|
|
16
|
-
const chainInfo = state.getChainInfo(this.slug);
|
|
17
|
-
if (chainState && chainState.active && chainState.currentProvider === this.oldProvider) {
|
|
18
|
-
await state.upsertChainInfo({
|
|
19
|
-
mode: 'update',
|
|
20
|
-
chainEditInfo: {
|
|
21
|
-
currentProvider: this.newProvider,
|
|
22
|
-
slug: this.slug,
|
|
23
|
-
providers: chainInfo.providers
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.default = MigrateProvider;
|
|
@@ -1,21 +0,0 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class MigrateEarningHistory extends _Base.default {
|
|
13
|
-
async run() {
|
|
14
|
-
try {
|
|
15
|
-
await this.state.dbService.removeOldEarningData();
|
|
16
|
-
} catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = MigrateEarningHistory;
|
|
@@ -1,21 +0,0 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class MigrateEarningVersion extends _Base.default {
|
|
13
|
-
async run() {
|
|
14
|
-
try {
|
|
15
|
-
await this.state.dbService.removeOldEarningData();
|
|
16
|
-
} catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = MigrateEarningVersion;
|