@subwallet/extension-base 1.1.33-0 → 1.1.33-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 +31 -28
- 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 +3 -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.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 +740 -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 +1 -1
- 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/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -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 +25 -22
- 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 +317 -4
- 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 +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 +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 +729 -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 +1 -1
- 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/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +52 -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
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { getAstarWithdrawable } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
|
|
6
|
-
import { _KNOWN_CHAIN_INFLATION_PARAMS,
|
|
6
|
+
import { _KNOWN_CHAIN_INFLATION_PARAMS, _SUBSTRATE_DEFAULT_INFLATION_PARAMS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
9
|
+
import { EarningStatus, UnstakingStatus, YieldPoolType } from '@subwallet/extension-base/types';
|
|
10
|
+
import { detectTranslate, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
9
11
|
import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils/number';
|
|
10
12
|
import { t } from 'i18next';
|
|
11
|
-
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a,
|
|
13
|
+
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
|
12
14
|
export let PalletParachainStakingRequestType;
|
|
13
15
|
(function (PalletParachainStakingRequestType) {
|
|
14
16
|
PalletParachainStakingRequestType["REVOKE"] = "revoke";
|
|
@@ -27,64 +29,6 @@ export function parsePoolStashAddress(api, index, poolId, poolsPalletId) {
|
|
|
27
29
|
export function transformPoolName(input) {
|
|
28
30
|
return input.replace(/[^\x20-\x7E]/g, '');
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @returns
|
|
33
|
-
* <p>
|
|
34
|
-
* [0] - identity
|
|
35
|
-
* </p>
|
|
36
|
-
* <p>
|
|
37
|
-
* [1] - isReasonable (isVerified)
|
|
38
|
-
* </p>
|
|
39
|
-
* */
|
|
40
|
-
export async function parseIdentity(substrateApi, address, children) {
|
|
41
|
-
const compactResult = rs => {
|
|
42
|
-
const result = [];
|
|
43
|
-
if (rs) {
|
|
44
|
-
result.push(rs);
|
|
45
|
-
}
|
|
46
|
-
if (children) {
|
|
47
|
-
result.push(children);
|
|
48
|
-
}
|
|
49
|
-
if (result.length > 0) {
|
|
50
|
-
return result.join('/');
|
|
51
|
-
} else {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
if (substrateApi.api.query.identity) {
|
|
56
|
-
let identity;
|
|
57
|
-
const _parent = await substrateApi.api.query.identity.superOf(address);
|
|
58
|
-
const parentInfo = _parent.toHuman();
|
|
59
|
-
if (parentInfo) {
|
|
60
|
-
const [parentAddress, {
|
|
61
|
-
Raw: data
|
|
62
|
-
}] = parentInfo;
|
|
63
|
-
const child = isHex(data) ? hexToString(data) : data;
|
|
64
|
-
if (!isSameAddress(address, parentAddress)) {
|
|
65
|
-
const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
|
|
66
|
-
return [compactResult(rs), isReasonable];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
70
|
-
const identityInfo = _identity.toHuman();
|
|
71
|
-
if (identityInfo) {
|
|
72
|
-
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
|
|
73
|
-
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;
|
|
74
|
-
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;
|
|
75
|
-
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;
|
|
76
|
-
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;
|
|
77
|
-
const isReasonable = identityInfo.judgements.length > 0;
|
|
78
|
-
if (displayName) {
|
|
79
|
-
identity = isHex(displayName) ? hexToString(displayName) : displayName;
|
|
80
|
-
} else {
|
|
81
|
-
identity = twitter || web || riot;
|
|
82
|
-
}
|
|
83
|
-
return [compactResult(identity), isReasonable];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return [undefined, false];
|
|
87
|
-
}
|
|
88
32
|
export function getInflationParams(networkKey) {
|
|
89
33
|
return _KNOWN_CHAIN_INFLATION_PARAMS[networkKey] || _SUBSTRATE_DEFAULT_INFLATION_PARAMS;
|
|
90
34
|
}
|
|
@@ -198,6 +142,78 @@ export function isUnstakeAll(selectedValidator, nominations, unstakeAmount) {
|
|
|
198
142
|
}
|
|
199
143
|
return isUnstakeAll;
|
|
200
144
|
}
|
|
145
|
+
export let YieldAction;
|
|
146
|
+
(function (YieldAction) {
|
|
147
|
+
YieldAction["STAKE"] = "STAKE";
|
|
148
|
+
YieldAction["UNSTAKE"] = "UNSTAKE";
|
|
149
|
+
YieldAction["WITHDRAW"] = "WITHDRAW";
|
|
150
|
+
YieldAction["CLAIM_REWARD"] = "CLAIM_REWARD";
|
|
151
|
+
YieldAction["CANCEL_UNSTAKE"] = "CANCEL_UNSTAKE";
|
|
152
|
+
YieldAction["START_EARNING"] = "EARN";
|
|
153
|
+
YieldAction["WITHDRAW_EARNING"] = "WITHDRAW_EARNING";
|
|
154
|
+
YieldAction["CUSTOM_ACTION"] = "CUSTOM_ACTION";
|
|
155
|
+
})(YieldAction || (YieldAction = {}));
|
|
156
|
+
export function getYieldAvailableActionsByType(yieldPoolInfo) {
|
|
157
|
+
if ([YieldPoolType.NATIVE_STAKING, YieldPoolType.NOMINATION_POOL].includes(yieldPoolInfo.type)) {
|
|
158
|
+
if (yieldPoolInfo.type === YieldPoolType.NOMINATION_POOL) {
|
|
159
|
+
return [YieldAction.STAKE, YieldAction.CLAIM_REWARD, YieldAction.UNSTAKE, YieldAction.WITHDRAW];
|
|
160
|
+
}
|
|
161
|
+
const chain = yieldPoolInfo.chain;
|
|
162
|
+
if (_STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
163
|
+
return [YieldAction.STAKE, YieldAction.UNSTAKE, YieldAction.WITHDRAW, YieldAction.CANCEL_UNSTAKE];
|
|
164
|
+
} else if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
165
|
+
return [YieldAction.STAKE, YieldAction.CLAIM_REWARD, YieldAction.UNSTAKE, YieldAction.WITHDRAW];
|
|
166
|
+
} else if (_STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
167
|
+
return [YieldAction.STAKE, YieldAction.UNSTAKE, YieldAction.WITHDRAW];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (yieldPoolInfo.type === YieldPoolType.LENDING) {
|
|
171
|
+
return [YieldAction.START_EARNING, YieldAction.WITHDRAW_EARNING];
|
|
172
|
+
} else if (yieldPoolInfo.type === YieldPoolType.LIQUID_STAKING) {
|
|
173
|
+
return [YieldAction.START_EARNING, YieldAction.UNSTAKE, YieldAction.WITHDRAW];
|
|
174
|
+
}
|
|
175
|
+
return [YieldAction.STAKE, YieldAction.UNSTAKE, YieldAction.WITHDRAW, YieldAction.CANCEL_UNSTAKE];
|
|
176
|
+
}
|
|
177
|
+
export function getYieldAvailableActionsByPosition(yieldPosition, yieldPoolInfo, unclaimedReward) {
|
|
178
|
+
const result = [];
|
|
179
|
+
if ([YieldPoolType.NATIVE_STAKING, YieldPoolType.NOMINATION_POOL].includes(yieldPoolInfo.type)) {
|
|
180
|
+
result.push(YieldAction.STAKE);
|
|
181
|
+
const bnActiveStake = new BN(yieldPosition.activeStake);
|
|
182
|
+
if (yieldPosition.activeStake && bnActiveStake.gt(BN_ZERO)) {
|
|
183
|
+
result.push(YieldAction.UNSTAKE);
|
|
184
|
+
const isAstarNetwork = _STAKING_CHAIN_GROUP.astar.includes(yieldPosition.chain);
|
|
185
|
+
const isAmplitudeNetwork = _STAKING_CHAIN_GROUP.amplitude.includes(yieldPosition.chain);
|
|
186
|
+
const bnUnclaimedReward = new BN(unclaimedReward || '0');
|
|
187
|
+
if ((yieldPosition.type === YieldPoolType.NOMINATION_POOL || isAmplitudeNetwork) && bnUnclaimedReward.gt(BN_ZERO) || isAstarNetwork) {
|
|
188
|
+
result.push(YieldAction.CLAIM_REWARD);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (yieldPosition.unstakings.length > 0) {
|
|
192
|
+
result.push(YieldAction.CANCEL_UNSTAKE);
|
|
193
|
+
const hasClaimable = yieldPosition.unstakings.some(unstaking => unstaking.status === UnstakingStatus.CLAIMABLE);
|
|
194
|
+
if (hasClaimable) {
|
|
195
|
+
result.push(YieldAction.WITHDRAW);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} else if (yieldPoolInfo.type === YieldPoolType.LIQUID_STAKING) {
|
|
199
|
+
result.push(YieldAction.START_EARNING);
|
|
200
|
+
const activeBalance = new BN(yieldPosition.activeStake || '0');
|
|
201
|
+
if (activeBalance.gt(BN_ZERO)) {
|
|
202
|
+
result.push(YieldAction.UNSTAKE);
|
|
203
|
+
}
|
|
204
|
+
const hasWithdrawal = yieldPosition.unstakings.some(unstakingInfo => unstakingInfo.status === UnstakingStatus.CLAIMABLE);
|
|
205
|
+
if (hasWithdrawal) {
|
|
206
|
+
result.push(YieldAction.WITHDRAW);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// TODO: check has unstakings to withdraw
|
|
210
|
+
} else {
|
|
211
|
+
result.push(YieldAction.START_EARNING);
|
|
212
|
+
result.push(YieldAction.WITHDRAW_EARNING); // TODO
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
201
217
|
export let StakingAction;
|
|
202
218
|
(function (StakingAction) {
|
|
203
219
|
StakingAction["STAKE"] = "STAKE";
|
|
@@ -241,7 +257,7 @@ export function getStakingAvailableActionsByNominator(nominatorMetadata, unclaim
|
|
|
241
257
|
return result;
|
|
242
258
|
}
|
|
243
259
|
export function isActionFromValidator(stakingType, chain) {
|
|
244
|
-
if (stakingType === StakingType.POOLED) {
|
|
260
|
+
if (stakingType === StakingType.POOLED || stakingType === StakingType.LIQUID_STAKING) {
|
|
245
261
|
return false;
|
|
246
262
|
}
|
|
247
263
|
if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
@@ -267,21 +283,21 @@ export function getWithdrawalInfo(nominatorMetadata) {
|
|
|
267
283
|
}
|
|
268
284
|
return result;
|
|
269
285
|
}
|
|
270
|
-
export function
|
|
271
|
-
let stakingStatus =
|
|
286
|
+
export function getEarningStatusByNominations(bnTotalActiveStake, nominationList) {
|
|
287
|
+
let stakingStatus = EarningStatus.EARNING_REWARD;
|
|
272
288
|
if (bnTotalActiveStake.isZero()) {
|
|
273
|
-
stakingStatus =
|
|
289
|
+
stakingStatus = EarningStatus.NOT_EARNING;
|
|
274
290
|
} else {
|
|
275
291
|
let invalidDelegationCount = 0;
|
|
276
292
|
for (const nomination of nominationList) {
|
|
277
|
-
if (nomination.status ===
|
|
293
|
+
if (nomination.status === EarningStatus.NOT_EARNING) {
|
|
278
294
|
invalidDelegationCount += 1;
|
|
279
295
|
}
|
|
280
296
|
}
|
|
281
297
|
if (invalidDelegationCount > 0 && invalidDelegationCount < nominationList.length) {
|
|
282
|
-
stakingStatus =
|
|
298
|
+
stakingStatus = EarningStatus.PARTIALLY_EARNING;
|
|
283
299
|
} else if (invalidDelegationCount === nominationList.length) {
|
|
284
|
-
stakingStatus =
|
|
300
|
+
stakingStatus = EarningStatus.NOT_EARNING;
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
303
|
return stakingStatus;
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { getAmplitudeStakingOnChain, getAstarStakingOnChain, getParaStakingOnChain } from '@subwallet/extension-base/koni/api/staking/paraChain';
|
|
5
5
|
import { getNominationPoolReward, getRelayPoolingOnChain, getRelayStakingOnChain } from '@subwallet/extension-base/koni/api/staking/relayChain';
|
|
6
6
|
import { getAllSubsquidStaking } from '@subwallet/extension-base/koni/api/staking/subsquidStaking';
|
|
7
|
-
import { _PURE_EVM_CHAINS
|
|
7
|
+
import { _PURE_EVM_CHAINS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _isChainEvmCompatible, _isChainSupportSubstrateStaking, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
9
10
|
import { categoryAddresses } from '@subwallet/extension-base/utils';
|
|
10
11
|
export function stakingOnChainApi(addresses, substrateApiMap, chainInfoMap, stakingCallback, nominatorStateCallback) {
|
|
11
12
|
const filteredApiMap = [];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState,
|
|
4
|
+
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { subscribeAmplitudeNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/amplitude';
|
|
6
6
|
import { subscribeAstarNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
|
|
7
7
|
import { subscribeParaChainNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
|
|
8
|
-
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
9
8
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
10
|
+
import { EarningStatus } from '@subwallet/extension-base/types';
|
|
10
11
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
12
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
13
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -43,7 +44,7 @@ function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, s
|
|
|
43
44
|
chain,
|
|
44
45
|
type: StakingType.NOMINATED,
|
|
45
46
|
address: owner,
|
|
46
|
-
status:
|
|
47
|
+
status: EarningStatus.NOT_STAKING,
|
|
47
48
|
activeStake: '0',
|
|
48
49
|
nominations: [],
|
|
49
50
|
unstakings: []
|
|
@@ -117,7 +118,7 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
117
118
|
chain,
|
|
118
119
|
type: StakingType.NOMINATED,
|
|
119
120
|
address: owner,
|
|
120
|
-
status:
|
|
121
|
+
status: EarningStatus.NOT_STAKING,
|
|
121
122
|
activeStake: '0',
|
|
122
123
|
nominations: [],
|
|
123
124
|
unstakings: []
|
|
@@ -240,7 +241,7 @@ export function getParaStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
240
241
|
chain,
|
|
241
242
|
type: StakingType.NOMINATED,
|
|
242
243
|
address: owner,
|
|
243
|
-
status:
|
|
244
|
+
status: EarningStatus.NOT_STAKING,
|
|
244
245
|
activeStake: '0',
|
|
245
246
|
nominations: [],
|
|
246
247
|
unstakings: []
|
|
@@ -300,7 +301,7 @@ export function getAstarStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
300
301
|
chain,
|
|
301
302
|
type: StakingType.NOMINATED,
|
|
302
303
|
address: owner,
|
|
303
|
-
status:
|
|
304
|
+
status: EarningStatus.NOT_STAKING,
|
|
304
305
|
activeStake: '0',
|
|
305
306
|
nominations: [],
|
|
306
307
|
unstakings: []
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState,
|
|
4
|
+
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { subscribeRelayChainNominatorMetadata, subscribeRelayChainPoolMemberMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
6
6
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
+
import { EarningStatus } from '@subwallet/extension-base/types';
|
|
7
8
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
8
9
|
import { BN } from '@polkadot/util';
|
|
9
10
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -51,7 +52,7 @@ export function getRelayStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
51
52
|
nominatorStateCallback({
|
|
52
53
|
chain,
|
|
53
54
|
type: StakingType.NOMINATED,
|
|
54
|
-
status:
|
|
55
|
+
status: EarningStatus.NOT_STAKING,
|
|
55
56
|
address: owner,
|
|
56
57
|
activeStake: '0',
|
|
57
58
|
nominations: [],
|
|
@@ -113,7 +114,7 @@ export function getRelayPoolingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
113
114
|
chain,
|
|
114
115
|
type: StakingType.POOLED,
|
|
115
116
|
address: owner,
|
|
116
|
-
status:
|
|
117
|
+
status: EarningStatus.NOT_STAKING,
|
|
117
118
|
activeStake: '0',
|
|
118
119
|
nominations: [],
|
|
119
120
|
// can only join 1 pool at a time
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { RuntimeDispatchInfo, SpecialYieldPoolInfo, YieldStepDetail } from '@subwallet/extension-base/types';
|
|
4
|
+
export declare const syntheticSelectedValidators: string[];
|
|
5
|
+
export declare function calculateAlternativeFee(feeInfo: RuntimeDispatchInfo): number;
|
|
6
|
+
export declare const DEFAULT_YIELD_FIRST_STEP: YieldStepDetail;
|
|
7
|
+
export declare const YIELD_EXTRINSIC_TYPES: ExtrinsicType[];
|
|
8
|
+
export declare const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
9
|
+
export declare const YIELD_POOL_MIN_AMOUNT_PERCENT: Record<string, number>;
|
|
10
|
+
export declare function convertDerivativeToOriginToken(amount: string, poolInfo: SpecialYieldPoolInfo, derivativeTokenInfo: _ChainAsset, originTokenInfo: _ChainAsset): number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { _getAssetDecimals } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
|
+
import { YieldStepType } from '@subwallet/extension-base/types';
|
|
7
|
+
export const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
|
|
8
|
+
export function calculateAlternativeFee(feeInfo) {
|
|
9
|
+
return feeInfo.partialFee;
|
|
10
|
+
}
|
|
11
|
+
export const DEFAULT_YIELD_FIRST_STEP = {
|
|
12
|
+
id: 0,
|
|
13
|
+
name: 'Fill information',
|
|
14
|
+
type: YieldStepType.DEFAULT
|
|
15
|
+
};
|
|
16
|
+
export const YIELD_EXTRINSIC_TYPES = [ExtrinsicType.MINT_VDOT, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_STDOT, ExtrinsicType.REDEEM_QDOT, ExtrinsicType.REDEEM_SDOT, ExtrinsicType.REDEEM_VDOT, ExtrinsicType.REDEEM_LDOT, ExtrinsicType.REDEEM_STDOT, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_LEAVE_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW];
|
|
17
|
+
export const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
18
|
+
export const YIELD_POOL_MIN_AMOUNT_PERCENT = {
|
|
19
|
+
DOT___acala_liquid_staking: 0.98,
|
|
20
|
+
DOT___bifrost_liquid_staking: 0.99,
|
|
21
|
+
DOT___parallel_liquid_staking: 0.97,
|
|
22
|
+
default: 0.98
|
|
23
|
+
};
|
|
24
|
+
export function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
|
|
25
|
+
var _poolInfo$statistic, _poolInfo$statistic$a;
|
|
26
|
+
const derivativeDecimals = _getAssetDecimals(derivativeTokenInfo);
|
|
27
|
+
const originDecimals = _getAssetDecimals(originTokenInfo);
|
|
28
|
+
const exchangeRate = ((_poolInfo$statistic = poolInfo.statistic) === null || _poolInfo$statistic === void 0 ? void 0 : (_poolInfo$statistic$a = _poolInfo$statistic.assetEarning) === null || _poolInfo$statistic$a === void 0 ? void 0 : _poolInfo$statistic$a[0].exchangeRate) || 1;
|
|
29
|
+
const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
|
|
30
|
+
const minAmount = formattedAmount * exchangeRate;
|
|
31
|
+
return Math.floor(minAmount * 10 ** originDecimals);
|
|
32
|
+
}
|
|
@@ -10,7 +10,6 @@ export declare class KoniCron {
|
|
|
10
10
|
private serviceSubscription;
|
|
11
11
|
dbService: DatabaseService;
|
|
12
12
|
private state;
|
|
13
|
-
private logger;
|
|
14
13
|
constructor(state: KoniState, subscriptions: KoniSubscription, dbService: DatabaseService);
|
|
15
14
|
private cronMap;
|
|
16
15
|
private subjectMap;
|
|
@@ -26,9 +25,6 @@ export declare class KoniCron {
|
|
|
26
25
|
syncMantaPay: () => void;
|
|
27
26
|
refreshNft: (address: string, apiMap: ApiMap, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>) => () => void;
|
|
28
27
|
resetNft: (newAddress: string) => void;
|
|
29
|
-
refreshStakingReward: (address: string) => () => void;
|
|
30
|
-
refreshStakingRewardFastInterval: (address: string) => () => void;
|
|
31
|
-
setStakingRewardReady: () => void;
|
|
32
28
|
checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
|
|
33
29
|
reloadNft(): Promise<boolean>;
|
|
34
30
|
reloadStaking(): Promise<boolean>;
|
package/koni/background/cron.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CRON_REFRESH_NFT_INTERVAL,
|
|
4
|
+
import { CRON_REFRESH_NFT_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
8
|
-
import { logger as createLogger } from '@polkadot/util';
|
|
9
8
|
export class KoniCron {
|
|
10
9
|
status = 'pending';
|
|
11
10
|
constructor(state, subscriptions, dbService) {
|
|
12
11
|
this.subscriptions = subscriptions;
|
|
13
12
|
this.dbService = dbService;
|
|
14
13
|
this.state = state;
|
|
15
|
-
this.logger = createLogger('Cron');
|
|
16
14
|
// this.init();
|
|
17
15
|
}
|
|
18
16
|
|
|
@@ -83,18 +81,18 @@ export class KoniCron {
|
|
|
83
81
|
|
|
84
82
|
// MantaPay
|
|
85
83
|
reloadMantaPay && this.removeCron('syncMantaPay');
|
|
84
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
86
85
|
|
|
87
86
|
// NFT
|
|
88
87
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
89
88
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
89
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
90
90
|
|
|
91
91
|
// Chains
|
|
92
92
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
93
|
-
// only add cron
|
|
93
|
+
// only add cron jobs if there's at least 1 active network
|
|
94
94
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
95
95
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
96
|
-
} else {
|
|
97
|
-
this.setStakingRewardReady();
|
|
98
96
|
}
|
|
99
97
|
};
|
|
100
98
|
this.state.eventService.onLazy(this.eventHandler);
|
|
@@ -105,10 +103,7 @@ export class KoniCron {
|
|
|
105
103
|
this.resetNft(currentAccountInfo.address);
|
|
106
104
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
107
105
|
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
108
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
109
106
|
this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
110
|
-
} else {
|
|
111
|
-
this.setStakingRewardReady();
|
|
112
107
|
}
|
|
113
108
|
this.status = 'running';
|
|
114
109
|
};
|
|
@@ -143,19 +138,6 @@ export class KoniCron {
|
|
|
143
138
|
resetNft = newAddress => {
|
|
144
139
|
this.state.resetNft(newAddress);
|
|
145
140
|
};
|
|
146
|
-
refreshStakingReward = address => {
|
|
147
|
-
return () => {
|
|
148
|
-
this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
refreshStakingRewardFastInterval = address => {
|
|
152
|
-
return () => {
|
|
153
|
-
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
setStakingRewardReady = () => {
|
|
157
|
-
this.state.updateStakingRewardReady(true);
|
|
158
|
-
};
|
|
159
141
|
checkNetworkAvailable = serviceInfo => {
|
|
160
142
|
return Object.keys(serviceInfo.chainApiMap.substrate).length > 0 || Object.keys(serviceInfo.chainApiMap.evm).length > 0;
|
|
161
143
|
};
|
|
@@ -92,6 +92,7 @@ export default class KoniExtension {
|
|
|
92
92
|
private getBalance;
|
|
93
93
|
private subscribeBalance;
|
|
94
94
|
private getCrowdloan;
|
|
95
|
+
private getCrowdloanContributions;
|
|
95
96
|
private subscribeCrowdloan;
|
|
96
97
|
private validatePassword;
|
|
97
98
|
private validatedAccountsPassword;
|
|
@@ -162,7 +163,6 @@ export default class KoniExtension {
|
|
|
162
163
|
private getNominationPoolOptions;
|
|
163
164
|
private submitBonding;
|
|
164
165
|
private submitUnbonding;
|
|
165
|
-
private submitStakeWithdrawal;
|
|
166
166
|
private submitStakeClaimReward;
|
|
167
167
|
private submitCancelStakeWithdrawal;
|
|
168
168
|
private submitPoolBonding;
|
|
@@ -214,6 +214,22 @@ export default class KoniExtension {
|
|
|
214
214
|
private resolveAddressByDomain;
|
|
215
215
|
private addInjects;
|
|
216
216
|
private removeInjects;
|
|
217
|
+
private subscribeYieldPoolInfo;
|
|
218
|
+
private earlyValidateJoin;
|
|
219
|
+
private getOptimalYieldPath;
|
|
220
|
+
private handleYieldStep;
|
|
221
|
+
private handleYieldLeave;
|
|
222
|
+
private getYieldPoolTargets;
|
|
223
|
+
private subscribeYieldPosition;
|
|
224
|
+
private subscribeYieldReward;
|
|
225
|
+
private subscribeYieldRewardHistory;
|
|
226
|
+
private subscribeEarningMinAmountPercent;
|
|
227
|
+
private handleValidateYieldProcess;
|
|
228
|
+
private yieldSubmitWithdrawal;
|
|
229
|
+
private yieldSubmitCancelWithdrawal;
|
|
230
|
+
private yieldSubmitClaimReward;
|
|
231
|
+
private unlockDotCheckCanMint;
|
|
232
|
+
private unlockDotSubscribeMintedData;
|
|
217
233
|
private subscribeProcessingBanner;
|
|
218
234
|
private completeCampaignBanner;
|
|
219
235
|
private subscribeBuyTokens;
|