@subwallet/extension-base 1.1.34-0 → 1.1.35-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/constants/staking.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +19 -16
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -17
- package/cjs/services/chain-service/index.js +50 -3
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +30 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +262 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +81 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
- package/cjs/services/earning-service/handlers/special.js +493 -0
- package/cjs/services/earning-service/service.js +733 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +3 -2
- package/cjs/services/request-service/handler/PopupHandler.js +2 -3
- package/cjs/services/storage-service/DatabaseService.js +97 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/AssetRef.js +24 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +249 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/environment.js +23 -28
- package/cjs/utils/fetchStaticCache.js +22 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +94 -10
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/mv3.js +14 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/constants/staking.js +1 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +13 -10
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +0 -4
- package/koni/background/cron.js +4 -22
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +327 -30
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +17 -12
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +8 -104
- package/package.json +335 -7
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +1 -13
- package/services/chain-service/constants.js +1 -15
- package/services/chain-service/index.d.ts +3 -0
- package/services/chain-service/index.js +50 -3
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +15 -0
- package/services/earning-service/constants/chains.js +22 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +113 -0
- package/services/earning-service/handlers/base.js +256 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +8 -0
- package/services/earning-service/handlers/lending/base.js +73 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +184 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
- package/services/earning-service/handlers/liquid-staking/base.js +89 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +456 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +152 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +556 -0
- package/services/earning-service/handlers/special.d.ts +64 -0
- package/services/earning-service/handlers/special.js +485 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +722 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +6 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +3 -2
- package/services/request-service/handler/PopupHandler.js +3 -4
- package/services/storage-service/DatabaseService.d.ts +22 -1
- package/services/storage-service/DatabaseService.js +97 -0
- package/services/storage-service/databases/index.d.ts +7 -2
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
- package/services/storage-service/db-stores/AssetRef.js +16 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +6 -13
- package/services/transaction-service/index.js +247 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +58 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +252 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/environment.d.ts +9 -2
- package/utils/environment.js +14 -26
- package/utils/fetchStaticCache.d.ts +1 -0
- package/utils/fetchStaticCache.js +14 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -1
- package/utils/index.js +53 -3
- package/utils/mv3.d.ts +2 -0
- package/utils/mv3.js +6 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -6,14 +6,14 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
6
6
|
import { BasicTxErrorType, BasicTxWarningCode, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
7
|
import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
|
|
8
8
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
9
|
-
import {
|
|
10
|
-
import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
10
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
12
11
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
13
|
-
import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
12
|
+
import { parseLiquidStakingEvents, parseLiquidStakingFastUnstakeEvents, parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
14
13
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
15
14
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
16
15
|
import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
16
|
+
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
17
17
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
18
18
|
import { anyNumberToBN, recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
|
|
19
19
|
import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
|
|
@@ -26,20 +26,19 @@ import EventEmitter from 'eventemitter3';
|
|
|
26
26
|
import { t } from 'i18next';
|
|
27
27
|
import { BehaviorSubject } from 'rxjs';
|
|
28
28
|
import { isHex } from '@polkadot/util';
|
|
29
|
+
import { _TRANSFER_CHAIN_GROUP } from "../chain-service/constants.js";
|
|
29
30
|
export default class TransactionService {
|
|
30
31
|
transactionSubject = new BehaviorSubject({});
|
|
31
32
|
watchTransactionSubscribes = {};
|
|
32
33
|
get transactions() {
|
|
33
34
|
return this.transactionSubject.getValue();
|
|
34
35
|
}
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
37
|
-
this.eventService = eventService;
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.notificationService = notificationService;
|
|
42
|
-
this.databaseService = databaseService;
|
|
36
|
+
constructor(state) {
|
|
37
|
+
this.state = state;
|
|
38
|
+
this.eventService = state.eventService;
|
|
39
|
+
this.historyService = state.historyService;
|
|
40
|
+
this.notificationService = state.notificationService;
|
|
41
|
+
this.chainService = state.chainService;
|
|
43
42
|
}
|
|
44
43
|
get allTransactions() {
|
|
45
44
|
return Object.values(this.transactions);
|
|
@@ -96,7 +95,7 @@ export default class TransactionService {
|
|
|
96
95
|
decimals: 0,
|
|
97
96
|
value: ''
|
|
98
97
|
};
|
|
99
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
98
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
100
99
|
if (!chainInfo) {
|
|
101
100
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
102
101
|
} else {
|
|
@@ -111,7 +110,7 @@ export default class TransactionService {
|
|
|
111
110
|
if (isSubstrateTransaction(transaction)) {
|
|
112
111
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
113
112
|
} else {
|
|
114
|
-
const web3 = this.chainService.getEvmApi(chain);
|
|
113
|
+
const web3 = this.state.chainService.getEvmApi(chain);
|
|
115
114
|
if (!web3) {
|
|
116
115
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
117
116
|
} else {
|
|
@@ -145,32 +144,35 @@ export default class TransactionService {
|
|
|
145
144
|
|
|
146
145
|
// Balance
|
|
147
146
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
148
|
-
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
-
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
147
|
+
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
|
|
148
|
+
const balance = await this.state.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
150
149
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
151
150
|
const feeNum = parseInt(estimateFee.value);
|
|
152
151
|
const balanceNum = parseInt(balance.value);
|
|
153
152
|
const edNum = parseInt(existentialDeposit);
|
|
154
153
|
const transferNativeNum = parseInt(transferNative);
|
|
155
|
-
if (!
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (transferNativeNum + feeNum > balanceNum) {
|
|
159
|
-
if (!isTransferAll) {
|
|
154
|
+
if (!validationInput.skipFeeValidation) {
|
|
155
|
+
// TODO
|
|
156
|
+
if (!new BigN(balance.value).gt(0)) {
|
|
160
157
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
}
|
|
159
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
160
|
+
if (!isTransferAll) {
|
|
164
161
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
162
|
+
} else {
|
|
163
|
+
if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
164
|
+
// Chain not have transfer all function
|
|
165
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
if (!isTransferAll) {
|
|
170
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
171
|
+
if (edAsWarning) {
|
|
172
|
+
validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
173
|
+
} else {
|
|
174
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
175
|
+
}
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
@@ -237,12 +239,21 @@ export default class TransactionService {
|
|
|
237
239
|
}
|
|
238
240
|
validatedTransaction.warnings = [];
|
|
239
241
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
240
|
-
await new Promise(resolve => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
await new Promise((resolve, reject) => {
|
|
243
|
+
// TODO
|
|
244
|
+
if (transaction.resolveOnDone) {
|
|
245
|
+
emitter.on('success', data => {
|
|
246
|
+
validatedTransaction.id = data.id;
|
|
247
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
248
|
+
resolve();
|
|
249
|
+
});
|
|
250
|
+
} else {
|
|
251
|
+
emitter.on('signed', data => {
|
|
252
|
+
validatedTransaction.id = data.id;
|
|
253
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
254
|
+
resolve();
|
|
255
|
+
});
|
|
256
|
+
}
|
|
246
257
|
emitter.on('error', data => {
|
|
247
258
|
if (data.errors.length > 0) {
|
|
248
259
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -314,7 +325,7 @@ export default class TransactionService {
|
|
|
314
325
|
}
|
|
315
326
|
getTransactionLink(id) {
|
|
316
327
|
const transaction = this.getTransaction(id);
|
|
317
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
328
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
318
329
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
319
330
|
}
|
|
320
331
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -342,7 +353,7 @@ export default class TransactionService {
|
|
|
342
353
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
343
354
|
startBlock: startBlock || 0
|
|
344
355
|
};
|
|
345
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
356
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
346
357
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
347
358
|
const baseNativeAmount = {
|
|
348
359
|
value: '0',
|
|
@@ -356,7 +367,7 @@ export default class TransactionService {
|
|
|
356
367
|
{
|
|
357
368
|
const inputData = parseTransactionData(transaction.data);
|
|
358
369
|
historyItem.to = inputData.to;
|
|
359
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
370
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
360
371
|
historyItem.amount = {
|
|
361
372
|
value: inputData.value || '0',
|
|
362
373
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -369,7 +380,7 @@ export default class TransactionService {
|
|
|
369
380
|
{
|
|
370
381
|
const inputData = parseTransactionData(transaction.data);
|
|
371
382
|
historyItem.to = inputData.to;
|
|
372
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
383
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
373
384
|
historyItem.amount = {
|
|
374
385
|
value: inputData.value || '0',
|
|
375
386
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -382,7 +393,7 @@ export default class TransactionService {
|
|
|
382
393
|
{
|
|
383
394
|
const inputData = parseTransactionData(transaction.data);
|
|
384
395
|
historyItem.to = inputData.to;
|
|
385
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
396
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
386
397
|
historyItem.amount = {
|
|
387
398
|
value: inputData.value || '0',
|
|
388
399
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -431,17 +442,29 @@ export default class TransactionService {
|
|
|
431
442
|
case ExtrinsicType.STAKING_UNBOND:
|
|
432
443
|
{
|
|
433
444
|
const data = parseTransactionData(transaction.data);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
445
|
+
if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
|
|
446
|
+
historyItem.amount = {
|
|
447
|
+
decimals: _getAssetDecimals(data.derivativeTokenInfo),
|
|
448
|
+
symbol: _getAssetSymbol(data.derivativeTokenInfo),
|
|
449
|
+
value: data.amount
|
|
450
|
+
};
|
|
451
|
+
historyItem.additionalInfo = {
|
|
452
|
+
inputTokenSlug: data.inputTokenInfo.slug,
|
|
453
|
+
exchangeRate: data.exchangeRate
|
|
454
|
+
};
|
|
455
|
+
} else {
|
|
456
|
+
historyItem.to = data.validatorAddress || '';
|
|
457
|
+
historyItem.amount = {
|
|
458
|
+
...baseNativeAmount,
|
|
459
|
+
value: data.amount || '0'
|
|
460
|
+
};
|
|
461
|
+
}
|
|
439
462
|
}
|
|
440
463
|
break;
|
|
441
464
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
442
465
|
{
|
|
443
466
|
const data = parseTransactionData(transaction.data);
|
|
444
|
-
historyItem.to = data.
|
|
467
|
+
historyItem.to = data.address || '';
|
|
445
468
|
historyItem.amount = {
|
|
446
469
|
...baseNativeAmount,
|
|
447
470
|
value: data.amount || '0'
|
|
@@ -460,11 +483,21 @@ export default class TransactionService {
|
|
|
460
483
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
461
484
|
{
|
|
462
485
|
const data = parseTransactionData(transaction.data);
|
|
463
|
-
|
|
464
|
-
|
|
486
|
+
const slug = data.slug;
|
|
487
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
488
|
+
const amount = {
|
|
465
489
|
...baseNativeAmount,
|
|
466
490
|
value: data.unstakingInfo.claimable || '0'
|
|
467
491
|
};
|
|
492
|
+
if (poolHandler) {
|
|
493
|
+
const asset = this.state.getAssetBySlug(poolHandler.metadataInfo.inputAsset);
|
|
494
|
+
if (asset) {
|
|
495
|
+
amount.decimals = asset.decimals || 0;
|
|
496
|
+
amount.symbol = asset.symbol;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
historyItem.to = data.unstakingInfo.validatorAddress || '';
|
|
500
|
+
historyItem.amount = amount;
|
|
468
501
|
break;
|
|
469
502
|
}
|
|
470
503
|
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -485,6 +518,116 @@ export default class TransactionService {
|
|
|
485
518
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
486
519
|
break;
|
|
487
520
|
}
|
|
521
|
+
case ExtrinsicType.MINT_STDOT:
|
|
522
|
+
case ExtrinsicType.MINT_QDOT:
|
|
523
|
+
case ExtrinsicType.MINT_LDOT:
|
|
524
|
+
case ExtrinsicType.MINT_SDOT:
|
|
525
|
+
|
|
526
|
+
// eslint-disable-next-line no-fallthrough
|
|
527
|
+
case ExtrinsicType.MINT_VDOT:
|
|
528
|
+
{
|
|
529
|
+
const params = parseTransactionData(transaction.data);
|
|
530
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
531
|
+
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
532
|
+
historyItem.amount = {
|
|
533
|
+
value: params.amount,
|
|
534
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
535
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
536
|
+
};
|
|
537
|
+
const additionalInfo = {
|
|
538
|
+
slug: params.slug,
|
|
539
|
+
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
540
|
+
exchangeRate: params.exchangeRate
|
|
541
|
+
};
|
|
542
|
+
historyItem.additionalInfo = additionalInfo;
|
|
543
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
case ExtrinsicType.UNSTAKE_QDOT:
|
|
547
|
+
|
|
548
|
+
// eslint-disable-next-line no-fallthrough
|
|
549
|
+
case ExtrinsicType.REDEEM_QDOT:
|
|
550
|
+
{
|
|
551
|
+
const data = parseTransactionData(transaction.data);
|
|
552
|
+
const yieldPoolInfo = data.poolInfo;
|
|
553
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
554
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
555
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
556
|
+
historyItem.amount = {
|
|
557
|
+
value: data.amount,
|
|
558
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
559
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
560
|
+
};
|
|
561
|
+
eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
562
|
+
const additionalInfo = {
|
|
563
|
+
minAmountPercent: 1,
|
|
564
|
+
symbol: inputTokenInfo.symbol,
|
|
565
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
566
|
+
exchangeRate: 1,
|
|
567
|
+
slug: yieldPoolInfo.slug,
|
|
568
|
+
type: yieldPoolInfo.type,
|
|
569
|
+
chain: yieldPoolInfo.chain,
|
|
570
|
+
group: yieldPoolInfo.group,
|
|
571
|
+
isFast: data.fastLeave
|
|
572
|
+
};
|
|
573
|
+
historyItem.additionalInfo = additionalInfo;
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
case ExtrinsicType.UNSTAKE_VDOT:
|
|
578
|
+
case ExtrinsicType.UNSTAKE_LDOT:
|
|
579
|
+
case ExtrinsicType.UNSTAKE_SDOT:
|
|
580
|
+
case ExtrinsicType.UNSTAKE_STDOT:
|
|
581
|
+
case ExtrinsicType.REDEEM_STDOT:
|
|
582
|
+
case ExtrinsicType.REDEEM_LDOT:
|
|
583
|
+
case ExtrinsicType.REDEEM_SDOT:
|
|
584
|
+
|
|
585
|
+
// eslint-disable-next-line no-fallthrough
|
|
586
|
+
case ExtrinsicType.REDEEM_VDOT:
|
|
587
|
+
{
|
|
588
|
+
const data = parseTransactionData(transaction.data);
|
|
589
|
+
const yieldPoolInfo = data.poolInfo;
|
|
590
|
+
const minAmountPercents = this.state.earningService.getMinAmountPercent();
|
|
591
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
592
|
+
var _yieldPoolInfo$statis;
|
|
593
|
+
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
594
|
+
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
595
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
596
|
+
historyItem.amount = {
|
|
597
|
+
value: data.amount,
|
|
598
|
+
symbol: _getAssetSymbol(derivativeTokenInfo),
|
|
599
|
+
decimals: _getAssetDecimals(derivativeTokenInfo)
|
|
600
|
+
};
|
|
601
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
602
|
+
const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
|
|
603
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
604
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
605
|
+
const additionalInfo = {
|
|
606
|
+
minAmountPercent,
|
|
607
|
+
symbol: inputTokenInfo.symbol,
|
|
608
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
609
|
+
exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
|
|
610
|
+
slug: yieldPoolInfo.slug,
|
|
611
|
+
type: yieldPoolInfo.type,
|
|
612
|
+
chain: yieldPoolInfo.chain,
|
|
613
|
+
group: yieldPoolInfo.group,
|
|
614
|
+
isFast: data.fastLeave
|
|
615
|
+
};
|
|
616
|
+
historyItem.additionalInfo = additionalInfo;
|
|
617
|
+
}
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
case ExtrinsicType.TOKEN_APPROVE:
|
|
621
|
+
{
|
|
622
|
+
const data = parseTransactionData(transaction.data);
|
|
623
|
+
const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
|
|
624
|
+
historyItem.amount = {
|
|
625
|
+
value: '0',
|
|
626
|
+
symbol: _getAssetSymbol(inputAsset),
|
|
627
|
+
decimals: _getAssetDecimals(inputAsset)
|
|
628
|
+
};
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
488
631
|
case ExtrinsicType.UNKNOWN:
|
|
489
632
|
break;
|
|
490
633
|
}
|
|
@@ -530,7 +673,7 @@ export default class TransactionService {
|
|
|
530
673
|
});
|
|
531
674
|
|
|
532
675
|
// Create Input History Transaction History
|
|
533
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
676
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
534
677
|
console.debug(`Transaction "${id}" is sent`);
|
|
535
678
|
}
|
|
536
679
|
onHasTransactionHash({
|
|
@@ -547,8 +690,12 @@ export default class TransactionService {
|
|
|
547
690
|
this.updateTransaction(id, updateData);
|
|
548
691
|
|
|
549
692
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
550
|
-
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
693
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
551
694
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
695
|
+
const transaction = this.getTransaction(id);
|
|
696
|
+
if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
697
|
+
this.handlePostEarningTransaction(id);
|
|
698
|
+
}
|
|
552
699
|
}
|
|
553
700
|
handlePostProcessing(id) {
|
|
554
701
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -557,15 +704,15 @@ export default class TransactionService {
|
|
|
557
704
|
const inputData = parseTransactionData(transaction.data);
|
|
558
705
|
try {
|
|
559
706
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
560
|
-
sender && this.
|
|
561
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
707
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
708
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
562
709
|
}).catch(console.error);
|
|
563
710
|
} catch (e) {
|
|
564
711
|
console.error(e);
|
|
565
712
|
}
|
|
566
713
|
try {
|
|
567
714
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
568
|
-
recipient && this.
|
|
715
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
569
716
|
...inputData.nftItem,
|
|
570
717
|
owner: recipient.address
|
|
571
718
|
}).catch(console.error);
|
|
@@ -573,7 +720,7 @@ export default class TransactionService {
|
|
|
573
720
|
console.error(e);
|
|
574
721
|
}
|
|
575
722
|
} else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
576
|
-
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
723
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
577
724
|
}
|
|
578
725
|
}
|
|
579
726
|
onSuccess({
|
|
@@ -589,14 +736,14 @@ export default class TransactionService {
|
|
|
589
736
|
});
|
|
590
737
|
|
|
591
738
|
// Write success transaction history
|
|
592
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
739
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
593
740
|
extrinsicHash,
|
|
594
741
|
status: ExtrinsicStatus.SUCCESS,
|
|
595
742
|
blockNumber: blockNumber || 0,
|
|
596
743
|
blockHash: blockHash || ''
|
|
597
744
|
}).catch(console.error);
|
|
598
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
599
|
-
this.notificationService.notify({
|
|
745
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
746
|
+
this.state.notificationService.notify({
|
|
600
747
|
type: NotificationType.SUCCESS,
|
|
601
748
|
title: t('Transaction completed'),
|
|
602
749
|
message: t('Transaction {{info}} completed', {
|
|
@@ -609,7 +756,7 @@ export default class TransactionService {
|
|
|
609
756
|
},
|
|
610
757
|
notifyViaBrowser: true
|
|
611
758
|
});
|
|
612
|
-
this.eventService.emit('transaction.done', transaction);
|
|
759
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
613
760
|
}
|
|
614
761
|
onFailed({
|
|
615
762
|
blockHash,
|
|
@@ -628,14 +775,14 @@ export default class TransactionService {
|
|
|
628
775
|
});
|
|
629
776
|
|
|
630
777
|
// Write failed transaction history
|
|
631
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
778
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
632
779
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
633
780
|
status: nextStatus,
|
|
634
781
|
blockNumber: blockNumber || 0,
|
|
635
782
|
blockHash: blockHash || ''
|
|
636
783
|
}).catch(console.error);
|
|
637
|
-
const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
638
|
-
this.notificationService.notify({
|
|
784
|
+
const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
785
|
+
this.state.notificationService.notify({
|
|
639
786
|
type: NotificationType.ERROR,
|
|
640
787
|
title: t('Transaction failed'),
|
|
641
788
|
message: t('Transaction {{info}} failed', {
|
|
@@ -649,7 +796,7 @@ export default class TransactionService {
|
|
|
649
796
|
notifyViaBrowser: true
|
|
650
797
|
});
|
|
651
798
|
}
|
|
652
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
799
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
653
800
|
}
|
|
654
801
|
onTimeOut({
|
|
655
802
|
blockHash,
|
|
@@ -691,7 +838,7 @@ export default class TransactionService {
|
|
|
691
838
|
}
|
|
692
839
|
generateHashPayload(chain, transaction) {
|
|
693
840
|
var _transaction$nonce;
|
|
694
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
841
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
695
842
|
const txObject = {
|
|
696
843
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
697
844
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -712,8 +859,8 @@ export default class TransactionService {
|
|
|
712
859
|
}) {
|
|
713
860
|
var _payload$nonce;
|
|
714
861
|
const payload = transaction;
|
|
715
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
716
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
862
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
863
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
717
864
|
const accountPair = keyring.getPair(address);
|
|
718
865
|
const account = {
|
|
719
866
|
address,
|
|
@@ -743,7 +890,7 @@ export default class TransactionService {
|
|
|
743
890
|
|
|
744
891
|
// Set unique nonce to avoid transaction errors
|
|
745
892
|
if (!payload.nonce) {
|
|
746
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
893
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
747
894
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
748
895
|
}
|
|
749
896
|
if (!payload.chainId) {
|
|
@@ -778,7 +925,7 @@ export default class TransactionService {
|
|
|
778
925
|
extrinsicHash: id
|
|
779
926
|
};
|
|
780
927
|
if (isInjected) {
|
|
781
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
928
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
782
929
|
isApproved,
|
|
783
930
|
payload
|
|
784
931
|
}) => {
|
|
@@ -786,7 +933,7 @@ export default class TransactionService {
|
|
|
786
933
|
if (!payload) {
|
|
787
934
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
788
935
|
}
|
|
789
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
936
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
790
937
|
|
|
791
938
|
// Emit signed event
|
|
792
939
|
emitter.emit('signed', eventData);
|
|
@@ -842,7 +989,7 @@ export default class TransactionService {
|
|
|
842
989
|
emitter.emit('error', eventData);
|
|
843
990
|
});
|
|
844
991
|
} else {
|
|
845
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
992
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
846
993
|
isApproved,
|
|
847
994
|
payload
|
|
848
995
|
}) => {
|
|
@@ -851,7 +998,7 @@ export default class TransactionService {
|
|
|
851
998
|
if (!payload) {
|
|
852
999
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
853
1000
|
}
|
|
854
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
1001
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
855
1002
|
if (!isExternal) {
|
|
856
1003
|
signedTransaction = payload;
|
|
857
1004
|
} else {
|
|
@@ -918,7 +1065,7 @@ export default class TransactionService {
|
|
|
918
1065
|
transaction.signAsync(address, {
|
|
919
1066
|
signer: {
|
|
920
1067
|
signPayload: async payload => {
|
|
921
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1068
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
922
1069
|
return {
|
|
923
1070
|
id: new Date().getTime(),
|
|
924
1071
|
signature: signing.signature
|
|
@@ -930,7 +1077,7 @@ export default class TransactionService {
|
|
|
930
1077
|
emitter.emit('signed', eventData);
|
|
931
1078
|
|
|
932
1079
|
// Send transaction
|
|
933
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
1080
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
934
1081
|
eventData.nonce = rs.nonce.toNumber();
|
|
935
1082
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
936
1083
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -998,6 +1145,33 @@ export default class TransactionService {
|
|
|
998
1145
|
clearTimeout(timeout);
|
|
999
1146
|
});
|
|
1000
1147
|
}
|
|
1148
|
+
handlePostEarningTransaction(id) {
|
|
1149
|
+
const transaction = this.getTransaction(id);
|
|
1150
|
+
let slug;
|
|
1151
|
+
|
|
1152
|
+
// TODO
|
|
1153
|
+
if ('data' in transaction.data) {
|
|
1154
|
+
slug = transaction.data.data.slug;
|
|
1155
|
+
} else {
|
|
1156
|
+
slug = transaction.data.slug;
|
|
1157
|
+
}
|
|
1158
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1159
|
+
if (poolHandler) {
|
|
1160
|
+
const type = poolHandler.type;
|
|
1161
|
+
if (type === YieldPoolType.NATIVE_STAKING) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
} else {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1168
|
+
transactionId: id,
|
|
1169
|
+
address: transaction.address,
|
|
1170
|
+
slug: slug,
|
|
1171
|
+
network: transaction.chain,
|
|
1172
|
+
extrinsicHash: transaction.extrinsicHash
|
|
1173
|
+
}).catch(console.error);
|
|
1174
|
+
}
|
|
1001
1175
|
resetWallet() {
|
|
1002
1176
|
this.transactionSubject.next({});
|
|
1003
1177
|
}
|
|
@@ -30,6 +30,8 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
|
|
|
30
30
|
errors?: SWTransaction['errors'];
|
|
31
31
|
edAsWarning?: boolean;
|
|
32
32
|
isTransferAll?: boolean;
|
|
33
|
+
resolveOnDone?: boolean;
|
|
34
|
+
skipFeeValidation?: boolean;
|
|
33
35
|
}
|
|
34
36
|
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
|
|
35
37
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unlock-dot';
|