@subwallet/extension-base 1.1.33-beta.0 → 1.1.34-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +69 -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 +16 -19
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +17 -10
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +21 -3
- package/cjs/koni/background/handlers/Extension.js +69 -368
- package/cjs/koni/background/handlers/State.js +12 -18
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +104 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +19 -2
- package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
- package/cjs/services/chain-service/index.js +101 -40
- package/cjs/services/chain-service/utils.js +69 -7
- package/cjs/services/event-service/index.js +0 -5
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -6
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -63
- 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 -249
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +2 -6
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +10 -13
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +18 -11
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +4 -0
- package/koni/background/cron.js +22 -4
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -327
- package/koni/background/handlers/State.d.ts +1 -6
- package/koni/background/handlers/State.js +12 -17
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +104 -8
- package/package.json +7 -320
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +13 -0
- package/services/chain-service/constants.js +15 -0
- package/services/chain-service/handler/SubstrateApi.js +10 -5
- package/services/chain-service/index.d.ts +9 -1
- package/services/chain-service/index.js +97 -37
- package/services/chain-service/utils.d.ts +10 -2
- package/services/chain-service/utils.js +67 -6
- package/services/event-service/index.d.ts +0 -2
- package/services/event-service/index.js +0 -5
- package/services/event-service/types.d.ts +0 -9
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -6
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -22
- package/services/storage-service/DatabaseService.js +0 -63
- 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 +13 -6
- package/services/transaction-service/index.js +73 -247
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +0 -52
- package/utils/number.d.ts +1 -2
- package/utils/number.js +1 -2
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -30
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -262
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -81
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
- package/cjs/services/earning-service/handlers/special.js +0 -493
- package/cjs/services/earning-service/service.js +0 -740
- 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 -71
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -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 -15
- package/services/earning-service/constants/chains.js +0 -22
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -113
- package/services/earning-service/handlers/base.js +0 -256
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -8
- package/services/earning-service/handlers/lending/base.js +0 -73
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -184
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
- package/services/earning-service/handlers/liquid-staking/base.js +0 -89
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
- 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 -219
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -456
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -152
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -556
- package/services/earning-service/handlers/special.d.ts +0 -64
- package/services/earning-service/handlers/special.js +0 -485
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -729
- 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 -11
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -58
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -47
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -252
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
3
|
-
import { ChainStakingMetadata, NominatorMetadata, UnstakingInfo, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { ChainStakingMetadata, NominationPoolInfo, NominatorMetadata, UnstakingInfo, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
+
import { PalletNominationPoolsPoolMember } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
4
5
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
5
|
-
import { NominationPoolInfo, PalletNominationPoolsPoolMember } from '@subwallet/extension-base/types';
|
|
6
6
|
import { Codec } from '@polkadot/types/types';
|
|
7
7
|
export interface PalletStakingNominations {
|
|
8
8
|
targets: string[];
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
|
-
import { StakingTxErrorType, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { StakingStatus, StakingTxErrorType, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { MAX_NOMINATIONS } from '@subwallet/extension-base/constants';
|
|
7
|
-
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturn, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getCommission, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, parsePoolStashAddress } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
8
|
-
import { _EXPECTED_BLOCK_TIME, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
+
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturn, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getCommission, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, parseIdentity, parsePoolStashAddress } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
8
|
+
import { _EXPECTED_BLOCK_TIME, _STAKING_CHAIN_GROUP, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
9
9
|
import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
|
-
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
11
|
-
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
12
|
-
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
13
10
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
14
11
|
import BigN from 'bignumber.js';
|
|
15
12
|
import { t } from 'i18next';
|
|
@@ -61,7 +58,7 @@ export function validateRelayBondingCondition(chainInfo, amount, selectedValidat
|
|
|
61
58
|
const bnMinStake = new BN(chainStakingMetadata.minStake);
|
|
62
59
|
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
63
60
|
const maxValidatorErrorMessage = getMaxValidatorErrorMessage(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
64
|
-
if (!nominatorMetadata || nominatorMetadata.status ===
|
|
61
|
+
if (!nominatorMetadata || nominatorMetadata.status === StakingStatus.NOT_STAKING) {
|
|
65
62
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
66
63
|
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
67
64
|
}
|
|
@@ -120,12 +117,12 @@ export function subscribeRelayChainStakingMetadata(chainInfo, substrateApi, call
|
|
|
120
117
|
});
|
|
121
118
|
}
|
|
122
119
|
export async function getRelayChainStakingMetadata(chainInfo, substrateApi) {
|
|
123
|
-
var _chainApi$api$
|
|
120
|
+
var _chainApi$api$query$a, _chainApi$api$query, _chainApi$api$query$s, _chainApi$api$query2, _chainApi$api$query2$, _chainApi$api$query3, _chainApi$api$query3$;
|
|
124
121
|
const chain = chainInfo.slug;
|
|
125
122
|
const chainApi = await substrateApi.isReady;
|
|
126
123
|
const _era = await chainApi.api.query.staking.currentEra();
|
|
127
124
|
const currentEra = _era.toString();
|
|
128
|
-
const maxNominations =
|
|
125
|
+
const maxNominations = chainApi.api.consts.staking.maxNominations.toString();
|
|
129
126
|
const maxUnlockingChunks = chainApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
130
127
|
const unlockingEras = chainApi.api.consts.staking.bondingDuration.toString();
|
|
131
128
|
const [_totalEraStake, _totalIssuance, _auctionCounter, _minimumActiveStake, _minNominatorBond, _minPoolJoin, _eraStakers] = await Promise.all([chainApi.api.query.staking.erasTotalStake(parseInt(currentEra)), chainApi.api.query.balances.totalIssuance(), (_chainApi$api$query$a = chainApi.api.query.auctions) === null || _chainApi$api$query$a === void 0 ? void 0 : _chainApi$api$query$a.auctionCounter(), ((_chainApi$api$query = chainApi.api.query) === null || _chainApi$api$query === void 0 ? void 0 : (_chainApi$api$query$s = _chainApi$api$query.staking) === null || _chainApi$api$query$s === void 0 ? void 0 : _chainApi$api$query$s.minimumActiveStake) && ((_chainApi$api$query2 = chainApi.api.query) === null || _chainApi$api$query2 === void 0 ? void 0 : (_chainApi$api$query2$ = _chainApi$api$query2.staking) === null || _chainApi$api$query2$ === void 0 ? void 0 : _chainApi$api$query2$.minimumActiveStake()), chainApi.api.query.staking.minNominatorBond(), (_chainApi$api$query3 = chainApi.api.query) === null || _chainApi$api$query3 === void 0 ? void 0 : (_chainApi$api$query3$ = _chainApi$api$query3.nominationPools) === null || _chainApi$api$query3$ === void 0 ? void 0 : _chainApi$api$query3$.minJoinBond(), chainApi.api.query.staking.erasStakers.entries(parseInt(currentEra))]);
|
|
@@ -196,7 +193,7 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
|
|
|
196
193
|
if (nominations) {
|
|
197
194
|
const validatorList = nominations.targets;
|
|
198
195
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
199
|
-
let nominationStatus =
|
|
196
|
+
let nominationStatus = StakingStatus.NOT_EARNING;
|
|
200
197
|
const [[identity], _eraStaker] = await Promise.all([parseIdentity(chainApi, validatorAddress), chainApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
201
198
|
const eraStaker = _eraStaker.toPrimitive();
|
|
202
199
|
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
@@ -207,10 +204,10 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
|
|
|
207
204
|
});
|
|
208
205
|
if (!topNominators.includes(reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
209
206
|
// if nominator has target but not in nominator list
|
|
210
|
-
nominationStatus =
|
|
207
|
+
nominationStatus = StakingStatus.WAITING;
|
|
211
208
|
} else if (topNominators.slice(0, unlimitedNominatorRewarded ? undefined : maxNominatorRewardedPerValidator).includes(reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
212
209
|
// if address in top nominators
|
|
213
|
-
nominationStatus =
|
|
210
|
+
nominationStatus = StakingStatus.EARNING_REWARD;
|
|
214
211
|
}
|
|
215
212
|
nominationList.push({
|
|
216
213
|
chain,
|
|
@@ -222,20 +219,20 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
|
|
|
222
219
|
}));
|
|
223
220
|
}
|
|
224
221
|
|
|
225
|
-
let stakingStatus =
|
|
222
|
+
let stakingStatus = StakingStatus.NOT_EARNING;
|
|
226
223
|
const bnActiveStake = new BN(activeStake);
|
|
227
224
|
let waitingNominationCount = 0;
|
|
228
225
|
if (bnActiveStake.gte(minStake)) {
|
|
229
226
|
for (const nomination of nominationList) {
|
|
230
|
-
if (nomination.status ===
|
|
227
|
+
if (nomination.status === StakingStatus.EARNING_REWARD) {
|
|
231
228
|
// only need 1 earning nomination to count
|
|
232
|
-
stakingStatus =
|
|
233
|
-
} else if (nomination.status ===
|
|
229
|
+
stakingStatus = StakingStatus.EARNING_REWARD;
|
|
230
|
+
} else if (nomination.status === StakingStatus.WAITING) {
|
|
234
231
|
waitingNominationCount += 1;
|
|
235
232
|
}
|
|
236
233
|
}
|
|
237
234
|
if (waitingNominationCount === nominationList.length) {
|
|
238
|
-
stakingStatus =
|
|
235
|
+
stakingStatus = StakingStatus.WAITING;
|
|
239
236
|
}
|
|
240
237
|
}
|
|
241
238
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
@@ -296,7 +293,7 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
|
|
|
296
293
|
return {
|
|
297
294
|
chain,
|
|
298
295
|
type: StakingType.NOMINATED,
|
|
299
|
-
status:
|
|
296
|
+
status: StakingStatus.NOT_STAKING,
|
|
300
297
|
address: address,
|
|
301
298
|
activeStake: '0',
|
|
302
299
|
nominations: [],
|
|
@@ -309,7 +306,7 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
|
|
|
309
306
|
if (nominations) {
|
|
310
307
|
const validatorList = nominations.targets;
|
|
311
308
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
312
|
-
let nominationStatus =
|
|
309
|
+
let nominationStatus = StakingStatus.NOT_EARNING;
|
|
313
310
|
const [[identity], _eraStaker] = await Promise.all([parseIdentity(chainApi, validatorAddress), chainApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
314
311
|
const eraStaker = _eraStaker.toPrimitive();
|
|
315
312
|
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
@@ -320,10 +317,10 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
|
|
|
320
317
|
});
|
|
321
318
|
if (!topNominators.includes(reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
322
319
|
// if nominator has target but not in nominator list
|
|
323
|
-
nominationStatus =
|
|
320
|
+
nominationStatus = StakingStatus.WAITING;
|
|
324
321
|
} else if (topNominators.slice(0, unlimitedNominatorRewarded ? undefined : maxNominatorRewardedPerValidator).includes(reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
325
322
|
// if address in top nominators
|
|
326
|
-
nominationStatus =
|
|
323
|
+
nominationStatus = StakingStatus.EARNING_REWARD;
|
|
327
324
|
}
|
|
328
325
|
nominationList.push({
|
|
329
326
|
chain,
|
|
@@ -335,20 +332,20 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
|
|
|
335
332
|
}));
|
|
336
333
|
}
|
|
337
334
|
|
|
338
|
-
let stakingStatus =
|
|
335
|
+
let stakingStatus = StakingStatus.NOT_EARNING;
|
|
339
336
|
const bnActiveStake = new BN(activeStake);
|
|
340
337
|
let waitingNominationCount = 0;
|
|
341
338
|
if (bnActiveStake.gte(minStake)) {
|
|
342
339
|
for (const nomination of nominationList) {
|
|
343
|
-
if (nomination.status ===
|
|
340
|
+
if (nomination.status === StakingStatus.EARNING_REWARD) {
|
|
344
341
|
// only need 1 earning nomination to count
|
|
345
|
-
stakingStatus =
|
|
346
|
-
} else if (nomination.status ===
|
|
342
|
+
stakingStatus = StakingStatus.EARNING_REWARD;
|
|
343
|
+
} else if (nomination.status === StakingStatus.WAITING) {
|
|
347
344
|
waitingNominationCount += 1;
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
347
|
if (waitingNominationCount === nominationList.length) {
|
|
351
|
-
stakingStatus =
|
|
348
|
+
stakingStatus = StakingStatus.WAITING;
|
|
352
349
|
}
|
|
353
350
|
}
|
|
354
351
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
@@ -384,7 +381,7 @@ export async function subscribeRelayChainPoolMemberMetadata(chainInfo, address,
|
|
|
384
381
|
const poolMetadata = _poolMetadata.toPrimitive();
|
|
385
382
|
const currentEra = _currentEra.toString();
|
|
386
383
|
const nominations = _nominations.toJSON();
|
|
387
|
-
let stakingStatus =
|
|
384
|
+
let stakingStatus = StakingStatus.NOT_EARNING;
|
|
388
385
|
const getPoolName = () => {
|
|
389
386
|
if (poolMetadata.isUtf8) {
|
|
390
387
|
return poolMetadata.toUtf8();
|
|
@@ -407,7 +404,7 @@ export async function subscribeRelayChainPoolMemberMetadata(chainInfo, address,
|
|
|
407
404
|
}).slice(0, unlimitedNominatorRewarded ? undefined : maxNominatorRewardedPerValidator);
|
|
408
405
|
if (topNominators.includes(reformatAddress(poolStashAccount, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
409
406
|
// if address in top nominators
|
|
410
|
-
stakingStatus =
|
|
407
|
+
stakingStatus = StakingStatus.EARNING_REWARD;
|
|
411
408
|
}
|
|
412
409
|
}));
|
|
413
410
|
}
|
|
@@ -442,7 +439,7 @@ export async function subscribeRelayChainPoolMemberMetadata(chainInfo, address,
|
|
|
442
439
|
});
|
|
443
440
|
const bnActiveStake = new BN(poolMemberInfo.points.toString());
|
|
444
441
|
if (!bnActiveStake.gt(BN_ZERO)) {
|
|
445
|
-
stakingStatus =
|
|
442
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
446
443
|
}
|
|
447
444
|
return {
|
|
448
445
|
chain: chainInfo.slug,
|
|
@@ -473,14 +470,14 @@ export async function getRelayChainPoolMemberMetadata(chainInfo, address, substr
|
|
|
473
470
|
chain: chainInfo.slug,
|
|
474
471
|
type: StakingType.POOLED,
|
|
475
472
|
address,
|
|
476
|
-
status:
|
|
473
|
+
status: StakingStatus.NOT_STAKING,
|
|
477
474
|
activeStake: '0',
|
|
478
475
|
nominations: [],
|
|
479
476
|
// can only join 1 pool at a time
|
|
480
477
|
unstakings: []
|
|
481
478
|
};
|
|
482
479
|
}
|
|
483
|
-
let stakingStatus =
|
|
480
|
+
let stakingStatus = StakingStatus.NOT_EARNING;
|
|
484
481
|
const _poolMetadata = await chainApi.api.query.nominationPools.metadata(poolMemberInfo.poolId);
|
|
485
482
|
const poolMetadata = _poolMetadata.toPrimitive();
|
|
486
483
|
const getPoolName = () => {
|
|
@@ -508,7 +505,7 @@ export async function getRelayChainPoolMemberMetadata(chainInfo, address, substr
|
|
|
508
505
|
}).slice(0, unlimitedNominatorRewarded ? undefined : maxNominatorRewardedPerValidator);
|
|
509
506
|
if (topNominators.includes(reformatAddress(poolStashAccount, _getChainSubstrateAddressPrefix(chainInfo)))) {
|
|
510
507
|
// if address in top nominators
|
|
511
|
-
stakingStatus =
|
|
508
|
+
stakingStatus = StakingStatus.EARNING_REWARD;
|
|
512
509
|
}
|
|
513
510
|
}));
|
|
514
511
|
}
|
|
@@ -535,7 +532,7 @@ export async function getRelayChainPoolMemberMetadata(chainInfo, address, substr
|
|
|
535
532
|
});
|
|
536
533
|
const bnActiveStake = new BN(poolMemberInfo.points.toString());
|
|
537
534
|
if (!bnActiveStake.gt(BN_ZERO)) {
|
|
538
|
-
stakingStatus =
|
|
535
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
539
536
|
}
|
|
540
537
|
return {
|
|
541
538
|
chain: chainInfo.slug,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
3
|
-
import { NominationInfo, NominatorMetadata, StakingType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { NominationInfo, NominatorMetadata, StakingStatus, StakingType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { _SubstrateInflationParams } from '@subwallet/extension-base/services/chain-service/constants';
|
|
5
|
-
import {
|
|
5
|
+
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
6
6
|
import { ApiPromise } from '@polkadot/api';
|
|
7
7
|
import { BN } from '@polkadot/util';
|
|
8
|
+
export interface PalletNominationPoolsPoolMember {
|
|
9
|
+
poolId: number;
|
|
10
|
+
points: number;
|
|
11
|
+
lasRecordedRewardCounter: number;
|
|
12
|
+
unbondingEras: Record<string, number>;
|
|
13
|
+
}
|
|
8
14
|
export interface PalletDappsStakingDappInfo {
|
|
9
15
|
address: string;
|
|
10
16
|
name: string;
|
|
@@ -65,6 +71,15 @@ export interface PalletParachainStakingDelegator {
|
|
|
65
71
|
lessTotal: number;
|
|
66
72
|
status: number;
|
|
67
73
|
}
|
|
74
|
+
export interface PalletStakingExposureItem {
|
|
75
|
+
who: string;
|
|
76
|
+
value: number;
|
|
77
|
+
}
|
|
78
|
+
export interface PalletStakingExposure {
|
|
79
|
+
total: number;
|
|
80
|
+
own: number;
|
|
81
|
+
others: PalletStakingExposureItem[];
|
|
82
|
+
}
|
|
68
83
|
export interface PalletIdentityRegistration {
|
|
69
84
|
judgements: any[];
|
|
70
85
|
deposit: number;
|
|
@@ -86,12 +101,32 @@ export interface PalletIdentityRegistration {
|
|
|
86
101
|
export declare type PalletIdentitySuper = [string, {
|
|
87
102
|
Raw: string;
|
|
88
103
|
}];
|
|
104
|
+
export interface ValidatorExtraInfo {
|
|
105
|
+
commission: string;
|
|
106
|
+
blocked: false;
|
|
107
|
+
identity?: string;
|
|
108
|
+
isVerified: boolean;
|
|
109
|
+
}
|
|
89
110
|
export interface Unlocking {
|
|
90
111
|
remainingEras: BN;
|
|
91
112
|
value: BN;
|
|
92
113
|
}
|
|
114
|
+
export interface TernoaStakingRewardsStakingRewardsData {
|
|
115
|
+
sessionEraPayout: string;
|
|
116
|
+
sessionExtraRewardPayout: string;
|
|
117
|
+
}
|
|
93
118
|
export declare function parsePoolStashAddress(api: ApiPromise, index: number, poolId: number, poolsPalletId: string): string;
|
|
94
119
|
export declare function transformPoolName(input: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* @returns
|
|
122
|
+
* <p>
|
|
123
|
+
* [0] - identity
|
|
124
|
+
* </p>
|
|
125
|
+
* <p>
|
|
126
|
+
* [1] - isReasonable (isVerified)
|
|
127
|
+
* </p>
|
|
128
|
+
* */
|
|
129
|
+
export declare function parseIdentity(substrateApi: _SubstrateApi, address: string, children?: string): Promise<[string | undefined, boolean]>;
|
|
95
130
|
export declare function getInflationParams(networkKey: string): _SubstrateInflationParams;
|
|
96
131
|
export declare function calcInflationUniformEraPayout(totalIssuance: BN, yearlyInflationInTokens: number): number;
|
|
97
132
|
export declare function calcInflationRewardCurve(minInflation: number, stakedFraction: number, idealStake: number, idealInterest: number, falloff: number): number;
|
|
@@ -129,18 +164,6 @@ export declare function getBondedValidators(nominations: NominationInfo[]): {
|
|
|
129
164
|
bondedValidators: string[];
|
|
130
165
|
};
|
|
131
166
|
export declare function isUnstakeAll(selectedValidator: string, nominations: NominationInfo[], unstakeAmount: string): boolean;
|
|
132
|
-
export declare enum YieldAction {
|
|
133
|
-
STAKE = "STAKE",
|
|
134
|
-
UNSTAKE = "UNSTAKE",
|
|
135
|
-
WITHDRAW = "WITHDRAW",
|
|
136
|
-
CLAIM_REWARD = "CLAIM_REWARD",
|
|
137
|
-
CANCEL_UNSTAKE = "CANCEL_UNSTAKE",
|
|
138
|
-
START_EARNING = "EARN",
|
|
139
|
-
WITHDRAW_EARNING = "WITHDRAW_EARNING",
|
|
140
|
-
CUSTOM_ACTION = "CUSTOM_ACTION"
|
|
141
|
-
}
|
|
142
|
-
export declare function getYieldAvailableActionsByType(yieldPoolInfo: YieldPoolInfo): YieldAction[];
|
|
143
|
-
export declare function getYieldAvailableActionsByPosition(yieldPosition: YieldPositionInfo, yieldPoolInfo: YieldPoolInfo, unclaimedReward?: string): YieldAction[];
|
|
144
167
|
export declare enum StakingAction {
|
|
145
168
|
STAKE = "STAKE",
|
|
146
169
|
UNSTAKE = "UNSTAKE",
|
|
@@ -152,7 +175,7 @@ export declare function getStakingAvailableActionsByChain(chain: string, type: S
|
|
|
152
175
|
export declare function getStakingAvailableActionsByNominator(nominatorMetadata: NominatorMetadata, unclaimedReward?: string): StakingAction[];
|
|
153
176
|
export declare function isActionFromValidator(stakingType: StakingType, chain: string): boolean;
|
|
154
177
|
export declare function getWithdrawalInfo(nominatorMetadata: NominatorMetadata): UnstakingInfo | undefined;
|
|
155
|
-
export declare function
|
|
178
|
+
export declare function getStakingStatusByNominations(bnTotalActiveStake: BN, nominationList: NominationInfo[]): StakingStatus;
|
|
156
179
|
export declare function getValidatorLabel(chain: string): "dApp" | "Validator" | "Collator";
|
|
157
180
|
export declare const getMinStakeErrorMessage: (chainInfo: _ChainInfo, bnMinStake: BN) => string;
|
|
158
181
|
export declare const getMaxValidatorErrorMessage: (chainInfo: _ChainInfo, max: number) => string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
+
import { StakingStatus, StakingType, UnstakingStatus } 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, _SUBSTRATE_DEFAULT_INFLATION_PARAMS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
|
+
import { _KNOWN_CHAIN_INFLATION_PARAMS, _STAKING_CHAIN_GROUP, _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 {
|
|
9
|
-
import { EarningStatus, UnstakingStatus, YieldPoolType } from '@subwallet/extension-base/types';
|
|
10
|
-
import { detectTranslate, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
8
|
+
import { detectTranslate, isSameAddress, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
9
|
import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils/number';
|
|
12
10
|
import { t } from 'i18next';
|
|
13
|
-
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
|
11
|
+
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, hexToString, isHex, stringToU8a, u8aConcat } from '@polkadot/util';
|
|
14
12
|
export let PalletParachainStakingRequestType;
|
|
15
13
|
(function (PalletParachainStakingRequestType) {
|
|
16
14
|
PalletParachainStakingRequestType["REVOKE"] = "revoke";
|
|
@@ -29,6 +27,64 @@ export function parsePoolStashAddress(api, index, poolId, poolsPalletId) {
|
|
|
29
27
|
export function transformPoolName(input) {
|
|
30
28
|
return input.replace(/[^\x20-\x7E]/g, '');
|
|
31
29
|
}
|
|
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
|
+
}
|
|
32
88
|
export function getInflationParams(networkKey) {
|
|
33
89
|
return _KNOWN_CHAIN_INFLATION_PARAMS[networkKey] || _SUBSTRATE_DEFAULT_INFLATION_PARAMS;
|
|
34
90
|
}
|
|
@@ -142,78 +198,6 @@ export function isUnstakeAll(selectedValidator, nominations, unstakeAmount) {
|
|
|
142
198
|
}
|
|
143
199
|
return isUnstakeAll;
|
|
144
200
|
}
|
|
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
|
-
}
|
|
217
201
|
export let StakingAction;
|
|
218
202
|
(function (StakingAction) {
|
|
219
203
|
StakingAction["STAKE"] = "STAKE";
|
|
@@ -257,7 +241,7 @@ export function getStakingAvailableActionsByNominator(nominatorMetadata, unclaim
|
|
|
257
241
|
return result;
|
|
258
242
|
}
|
|
259
243
|
export function isActionFromValidator(stakingType, chain) {
|
|
260
|
-
if (stakingType === StakingType.POOLED
|
|
244
|
+
if (stakingType === StakingType.POOLED) {
|
|
261
245
|
return false;
|
|
262
246
|
}
|
|
263
247
|
if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
@@ -283,21 +267,21 @@ export function getWithdrawalInfo(nominatorMetadata) {
|
|
|
283
267
|
}
|
|
284
268
|
return result;
|
|
285
269
|
}
|
|
286
|
-
export function
|
|
287
|
-
let stakingStatus =
|
|
270
|
+
export function getStakingStatusByNominations(bnTotalActiveStake, nominationList) {
|
|
271
|
+
let stakingStatus = StakingStatus.EARNING_REWARD;
|
|
288
272
|
if (bnTotalActiveStake.isZero()) {
|
|
289
|
-
stakingStatus =
|
|
273
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
290
274
|
} else {
|
|
291
275
|
let invalidDelegationCount = 0;
|
|
292
276
|
for (const nomination of nominationList) {
|
|
293
|
-
if (nomination.status ===
|
|
277
|
+
if (nomination.status === StakingStatus.NOT_EARNING) {
|
|
294
278
|
invalidDelegationCount += 1;
|
|
295
279
|
}
|
|
296
280
|
}
|
|
297
281
|
if (invalidDelegationCount > 0 && invalidDelegationCount < nominationList.length) {
|
|
298
|
-
stakingStatus =
|
|
282
|
+
stakingStatus = StakingStatus.PARTIALLY_EARNING;
|
|
299
283
|
} else if (invalidDelegationCount === nominationList.length) {
|
|
300
|
-
stakingStatus =
|
|
284
|
+
stakingStatus = StakingStatus.NOT_EARNING;
|
|
301
285
|
}
|
|
302
286
|
}
|
|
303
287
|
return stakingStatus;
|
|
@@ -4,9 +4,8 @@
|
|
|
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 } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
+
import { _PURE_EVM_CHAINS, _STAKING_CHAIN_GROUP } 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';
|
|
10
9
|
import { categoryAddresses } from '@subwallet/extension-base/utils';
|
|
11
10
|
export function stakingOnChainApi(addresses, substrateApiMap, chainInfoMap, stakingCallback, nominatorStateCallback) {
|
|
12
11
|
const filteredApiMap = [];
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
+
import { APIItemState, StakingStatus, 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';
|
|
8
9
|
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';
|
|
11
10
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
12
11
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
13
12
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -17,10 +16,14 @@ function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, s
|
|
|
17
16
|
if (_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
18
17
|
const krestDelegatorState = _delegatorState.toPrimitive();
|
|
19
18
|
const delegates = krestDelegatorState === null || krestDelegatorState === void 0 ? void 0 : krestDelegatorState.delegations;
|
|
20
|
-
|
|
19
|
+
if (delegates) {
|
|
20
|
+
delegatorState = delegatorState.concat(delegates);
|
|
21
|
+
}
|
|
21
22
|
} else {
|
|
22
23
|
const delegate = _delegatorState.toPrimitive();
|
|
23
|
-
|
|
24
|
+
if (delegate) {
|
|
25
|
+
delegatorState.push(delegate);
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
const unstakingInfo = _unstaking.toPrimitive();
|
|
26
29
|
const {
|
|
@@ -44,7 +47,7 @@ function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, s
|
|
|
44
47
|
chain,
|
|
45
48
|
type: StakingType.NOMINATED,
|
|
46
49
|
address: owner,
|
|
47
|
-
status:
|
|
50
|
+
status: StakingStatus.NOT_STAKING,
|
|
48
51
|
activeStake: '0',
|
|
49
52
|
nominations: [],
|
|
50
53
|
unstakings: []
|
|
@@ -95,10 +98,14 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
95
98
|
if (_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
96
99
|
const krestDelegatorState = _delegatorState.toPrimitive();
|
|
97
100
|
const delegates = krestDelegatorState === null || krestDelegatorState === void 0 ? void 0 : krestDelegatorState.delegations;
|
|
98
|
-
|
|
101
|
+
if (delegates) {
|
|
102
|
+
delegatorState = delegatorState.concat(delegates);
|
|
103
|
+
}
|
|
99
104
|
} else {
|
|
100
105
|
const delegate = _delegatorState.toPrimitive();
|
|
101
|
-
|
|
106
|
+
if (delegate) {
|
|
107
|
+
delegatorState.push(delegate);
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
const unstakingInfo = _unstakingStates[i].toPrimitive();
|
|
104
111
|
if (!delegatorState && !unstakingInfo) {
|
|
@@ -118,7 +125,7 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
118
125
|
chain,
|
|
119
126
|
type: StakingType.NOMINATED,
|
|
120
127
|
address: owner,
|
|
121
|
-
status:
|
|
128
|
+
status: StakingStatus.NOT_STAKING,
|
|
122
129
|
activeStake: '0',
|
|
123
130
|
nominations: [],
|
|
124
131
|
unstakings: []
|
|
@@ -241,7 +248,7 @@ export function getParaStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
241
248
|
chain,
|
|
242
249
|
type: StakingType.NOMINATED,
|
|
243
250
|
address: owner,
|
|
244
|
-
status:
|
|
251
|
+
status: StakingStatus.NOT_STAKING,
|
|
245
252
|
activeStake: '0',
|
|
246
253
|
nominations: [],
|
|
247
254
|
unstakings: []
|
|
@@ -301,7 +308,7 @@ export function getAstarStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
301
308
|
chain,
|
|
302
309
|
type: StakingType.NOMINATED,
|
|
303
310
|
address: owner,
|
|
304
|
-
status:
|
|
311
|
+
status: StakingStatus.NOT_STAKING,
|
|
305
312
|
activeStake: '0',
|
|
306
313
|
nominations: [],
|
|
307
314
|
unstakings: []
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
+
import { APIItemState, StakingStatus, 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';
|
|
8
7
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
9
8
|
import { BN } from '@polkadot/util';
|
|
10
9
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -52,7 +51,7 @@ export function getRelayStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
52
51
|
nominatorStateCallback({
|
|
53
52
|
chain,
|
|
54
53
|
type: StakingType.NOMINATED,
|
|
55
|
-
status:
|
|
54
|
+
status: StakingStatus.NOT_STAKING,
|
|
56
55
|
address: owner,
|
|
57
56
|
activeStake: '0',
|
|
58
57
|
nominations: [],
|
|
@@ -114,7 +113,7 @@ export function getRelayPoolingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
114
113
|
chain,
|
|
115
114
|
type: StakingType.POOLED,
|
|
116
115
|
address: owner,
|
|
117
|
-
status:
|
|
116
|
+
status: StakingStatus.NOT_STAKING,
|
|
118
117
|
activeStake: '0',
|
|
119
118
|
nominations: [],
|
|
120
119
|
// can only join 1 pool at a time
|