@subwallet/extension-base 1.1.33-0 → 1.1.33-beta.1
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 +120 -69
- package/background/KoniTypes.js +22 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +23 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +31 -28
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +49 -0
- package/cjs/koni/background/cron.js +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +4 -17
- package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
- package/cjs/services/chain-service/index.js +123 -39
- package/cjs/services/chain-service/utils.js +75 -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 +98 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +299 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +41 -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 +497 -0
- package/cjs/services/earning-service/service.js +741 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +92 -1
- package/cjs/services/storage-service/databases/index.js +7 -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 +252 -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 +48 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +25 -22
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +34 -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 +327 -4
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +1 -12
- package/services/chain-service/constants.js +1 -14
- package/services/chain-service/handler/SubstrateApi.js +10 -5
- package/services/chain-service/index.d.ts +11 -1
- package/services/chain-service/index.js +119 -36
- package/services/chain-service/utils.d.ts +11 -1
- package/services/chain-service/utils.js +71 -2
- 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 +90 -0
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +37 -0
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +132 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +288 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +5 -0
- package/services/earning-service/handlers/liquid-staking/index.js +8 -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 +489 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +730 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +6 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +30 -3
- package/services/storage-service/DatabaseService.js +91 -1
- package/services/storage-service/databases/index.d.ts +8 -2
- package/services/storage-service/databases/index.js +7 -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 +250 -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 +96 -0
- package/types/yield/actions/join/step.js +47 -0
- package/types/yield/actions/join/submit.d.ts +58 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +252 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +52 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -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,119 @@ 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
|
+
case ExtrinsicType.MINT_VMANTA:
|
|
526
|
+
|
|
527
|
+
// eslint-disable-next-line no-fallthrough
|
|
528
|
+
case ExtrinsicType.MINT_VDOT:
|
|
529
|
+
{
|
|
530
|
+
const params = parseTransactionData(transaction.data);
|
|
531
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
532
|
+
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
533
|
+
historyItem.amount = {
|
|
534
|
+
value: params.amount,
|
|
535
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
536
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
537
|
+
};
|
|
538
|
+
const additionalInfo = {
|
|
539
|
+
slug: params.slug,
|
|
540
|
+
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
541
|
+
exchangeRate: params.exchangeRate
|
|
542
|
+
};
|
|
543
|
+
historyItem.additionalInfo = additionalInfo;
|
|
544
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
case ExtrinsicType.UNSTAKE_QDOT:
|
|
548
|
+
|
|
549
|
+
// eslint-disable-next-line no-fallthrough
|
|
550
|
+
case ExtrinsicType.REDEEM_QDOT:
|
|
551
|
+
{
|
|
552
|
+
const data = parseTransactionData(transaction.data);
|
|
553
|
+
const yieldPoolInfo = data.poolInfo;
|
|
554
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
555
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
556
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
557
|
+
historyItem.amount = {
|
|
558
|
+
value: data.amount,
|
|
559
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
560
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
561
|
+
};
|
|
562
|
+
eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
563
|
+
const additionalInfo = {
|
|
564
|
+
minAmountPercent: 1,
|
|
565
|
+
symbol: inputTokenInfo.symbol,
|
|
566
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
567
|
+
exchangeRate: 1,
|
|
568
|
+
slug: yieldPoolInfo.slug,
|
|
569
|
+
type: yieldPoolInfo.type,
|
|
570
|
+
chain: yieldPoolInfo.chain,
|
|
571
|
+
group: yieldPoolInfo.group,
|
|
572
|
+
isFast: data.fastLeave
|
|
573
|
+
};
|
|
574
|
+
historyItem.additionalInfo = additionalInfo;
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
case ExtrinsicType.UNSTAKE_VDOT:
|
|
579
|
+
case ExtrinsicType.UNSTAKE_VMANTA:
|
|
580
|
+
case ExtrinsicType.UNSTAKE_LDOT:
|
|
581
|
+
case ExtrinsicType.UNSTAKE_SDOT:
|
|
582
|
+
case ExtrinsicType.UNSTAKE_STDOT:
|
|
583
|
+
case ExtrinsicType.REDEEM_STDOT:
|
|
584
|
+
case ExtrinsicType.REDEEM_LDOT:
|
|
585
|
+
case ExtrinsicType.REDEEM_SDOT:
|
|
586
|
+
case ExtrinsicType.REDEEM_VMANTA:
|
|
587
|
+
|
|
588
|
+
// eslint-disable-next-line no-fallthrough
|
|
589
|
+
case ExtrinsicType.REDEEM_VDOT:
|
|
590
|
+
{
|
|
591
|
+
const data = parseTransactionData(transaction.data);
|
|
592
|
+
const yieldPoolInfo = data.poolInfo;
|
|
593
|
+
const minAmountPercents = this.state.earningService.getMinAmountPercent();
|
|
594
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
595
|
+
var _yieldPoolInfo$statis;
|
|
596
|
+
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
597
|
+
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
598
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
599
|
+
historyItem.amount = {
|
|
600
|
+
value: data.amount,
|
|
601
|
+
symbol: _getAssetSymbol(derivativeTokenInfo),
|
|
602
|
+
decimals: _getAssetDecimals(derivativeTokenInfo)
|
|
603
|
+
};
|
|
604
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
605
|
+
const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
|
|
606
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
607
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
608
|
+
const additionalInfo = {
|
|
609
|
+
minAmountPercent,
|
|
610
|
+
symbol: inputTokenInfo.symbol,
|
|
611
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
612
|
+
exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
|
|
613
|
+
slug: yieldPoolInfo.slug,
|
|
614
|
+
type: yieldPoolInfo.type,
|
|
615
|
+
chain: yieldPoolInfo.chain,
|
|
616
|
+
group: yieldPoolInfo.group,
|
|
617
|
+
isFast: data.fastLeave
|
|
618
|
+
};
|
|
619
|
+
historyItem.additionalInfo = additionalInfo;
|
|
620
|
+
}
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
case ExtrinsicType.TOKEN_APPROVE:
|
|
624
|
+
{
|
|
625
|
+
const data = parseTransactionData(transaction.data);
|
|
626
|
+
const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
|
|
627
|
+
historyItem.amount = {
|
|
628
|
+
value: '0',
|
|
629
|
+
symbol: _getAssetSymbol(inputAsset),
|
|
630
|
+
decimals: _getAssetDecimals(inputAsset)
|
|
631
|
+
};
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
488
634
|
case ExtrinsicType.UNKNOWN:
|
|
489
635
|
break;
|
|
490
636
|
}
|
|
@@ -530,7 +676,7 @@ export default class TransactionService {
|
|
|
530
676
|
});
|
|
531
677
|
|
|
532
678
|
// Create Input History Transaction History
|
|
533
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
679
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
534
680
|
console.debug(`Transaction "${id}" is sent`);
|
|
535
681
|
}
|
|
536
682
|
onHasTransactionHash({
|
|
@@ -547,8 +693,12 @@ export default class TransactionService {
|
|
|
547
693
|
this.updateTransaction(id, updateData);
|
|
548
694
|
|
|
549
695
|
// 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);
|
|
696
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
551
697
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
698
|
+
const transaction = this.getTransaction(id);
|
|
699
|
+
if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
700
|
+
this.handlePostEarningTransaction(id);
|
|
701
|
+
}
|
|
552
702
|
}
|
|
553
703
|
handlePostProcessing(id) {
|
|
554
704
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -557,15 +707,15 @@ export default class TransactionService {
|
|
|
557
707
|
const inputData = parseTransactionData(transaction.data);
|
|
558
708
|
try {
|
|
559
709
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
560
|
-
sender && this.
|
|
561
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
710
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
711
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
562
712
|
}).catch(console.error);
|
|
563
713
|
} catch (e) {
|
|
564
714
|
console.error(e);
|
|
565
715
|
}
|
|
566
716
|
try {
|
|
567
717
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
568
|
-
recipient && this.
|
|
718
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
569
719
|
...inputData.nftItem,
|
|
570
720
|
owner: recipient.address
|
|
571
721
|
}).catch(console.error);
|
|
@@ -573,7 +723,7 @@ export default class TransactionService {
|
|
|
573
723
|
console.error(e);
|
|
574
724
|
}
|
|
575
725
|
} 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);
|
|
726
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
577
727
|
}
|
|
578
728
|
}
|
|
579
729
|
onSuccess({
|
|
@@ -589,14 +739,14 @@ export default class TransactionService {
|
|
|
589
739
|
});
|
|
590
740
|
|
|
591
741
|
// Write success transaction history
|
|
592
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
742
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
593
743
|
extrinsicHash,
|
|
594
744
|
status: ExtrinsicStatus.SUCCESS,
|
|
595
745
|
blockNumber: blockNumber || 0,
|
|
596
746
|
blockHash: blockHash || ''
|
|
597
747
|
}).catch(console.error);
|
|
598
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
599
|
-
this.notificationService.notify({
|
|
748
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
749
|
+
this.state.notificationService.notify({
|
|
600
750
|
type: NotificationType.SUCCESS,
|
|
601
751
|
title: t('Transaction completed'),
|
|
602
752
|
message: t('Transaction {{info}} completed', {
|
|
@@ -609,7 +759,7 @@ export default class TransactionService {
|
|
|
609
759
|
},
|
|
610
760
|
notifyViaBrowser: true
|
|
611
761
|
});
|
|
612
|
-
this.eventService.emit('transaction.done', transaction);
|
|
762
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
613
763
|
}
|
|
614
764
|
onFailed({
|
|
615
765
|
blockHash,
|
|
@@ -628,14 +778,14 @@ export default class TransactionService {
|
|
|
628
778
|
});
|
|
629
779
|
|
|
630
780
|
// Write failed transaction history
|
|
631
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
781
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
632
782
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
633
783
|
status: nextStatus,
|
|
634
784
|
blockNumber: blockNumber || 0,
|
|
635
785
|
blockHash: blockHash || ''
|
|
636
786
|
}).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({
|
|
787
|
+
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());
|
|
788
|
+
this.state.notificationService.notify({
|
|
639
789
|
type: NotificationType.ERROR,
|
|
640
790
|
title: t('Transaction failed'),
|
|
641
791
|
message: t('Transaction {{info}} failed', {
|
|
@@ -649,7 +799,7 @@ export default class TransactionService {
|
|
|
649
799
|
notifyViaBrowser: true
|
|
650
800
|
});
|
|
651
801
|
}
|
|
652
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
802
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
653
803
|
}
|
|
654
804
|
onTimeOut({
|
|
655
805
|
blockHash,
|
|
@@ -691,7 +841,7 @@ export default class TransactionService {
|
|
|
691
841
|
}
|
|
692
842
|
generateHashPayload(chain, transaction) {
|
|
693
843
|
var _transaction$nonce;
|
|
694
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
844
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
695
845
|
const txObject = {
|
|
696
846
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
697
847
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -712,8 +862,8 @@ export default class TransactionService {
|
|
|
712
862
|
}) {
|
|
713
863
|
var _payload$nonce;
|
|
714
864
|
const payload = transaction;
|
|
715
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
716
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
865
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
866
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
717
867
|
const accountPair = keyring.getPair(address);
|
|
718
868
|
const account = {
|
|
719
869
|
address,
|
|
@@ -743,7 +893,7 @@ export default class TransactionService {
|
|
|
743
893
|
|
|
744
894
|
// Set unique nonce to avoid transaction errors
|
|
745
895
|
if (!payload.nonce) {
|
|
746
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
896
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
747
897
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
748
898
|
}
|
|
749
899
|
if (!payload.chainId) {
|
|
@@ -778,7 +928,7 @@ export default class TransactionService {
|
|
|
778
928
|
extrinsicHash: id
|
|
779
929
|
};
|
|
780
930
|
if (isInjected) {
|
|
781
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
931
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
782
932
|
isApproved,
|
|
783
933
|
payload
|
|
784
934
|
}) => {
|
|
@@ -786,7 +936,7 @@ export default class TransactionService {
|
|
|
786
936
|
if (!payload) {
|
|
787
937
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
788
938
|
}
|
|
789
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
939
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
790
940
|
|
|
791
941
|
// Emit signed event
|
|
792
942
|
emitter.emit('signed', eventData);
|
|
@@ -842,7 +992,7 @@ export default class TransactionService {
|
|
|
842
992
|
emitter.emit('error', eventData);
|
|
843
993
|
});
|
|
844
994
|
} else {
|
|
845
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
995
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
846
996
|
isApproved,
|
|
847
997
|
payload
|
|
848
998
|
}) => {
|
|
@@ -851,7 +1001,7 @@ export default class TransactionService {
|
|
|
851
1001
|
if (!payload) {
|
|
852
1002
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
853
1003
|
}
|
|
854
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
1004
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
855
1005
|
if (!isExternal) {
|
|
856
1006
|
signedTransaction = payload;
|
|
857
1007
|
} else {
|
|
@@ -918,7 +1068,7 @@ export default class TransactionService {
|
|
|
918
1068
|
transaction.signAsync(address, {
|
|
919
1069
|
signer: {
|
|
920
1070
|
signPayload: async payload => {
|
|
921
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1071
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
922
1072
|
return {
|
|
923
1073
|
id: new Date().getTime(),
|
|
924
1074
|
signature: signing.signature
|
|
@@ -930,7 +1080,7 @@ export default class TransactionService {
|
|
|
930
1080
|
emitter.emit('signed', eventData);
|
|
931
1081
|
|
|
932
1082
|
// Send transaction
|
|
933
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
1083
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
934
1084
|
eventData.nonce = rs.nonce.toNumber();
|
|
935
1085
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
936
1086
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -998,6 +1148,33 @@ export default class TransactionService {
|
|
|
998
1148
|
clearTimeout(timeout);
|
|
999
1149
|
});
|
|
1000
1150
|
}
|
|
1151
|
+
handlePostEarningTransaction(id) {
|
|
1152
|
+
const transaction = this.getTransaction(id);
|
|
1153
|
+
let slug;
|
|
1154
|
+
|
|
1155
|
+
// TODO
|
|
1156
|
+
if ('data' in transaction.data) {
|
|
1157
|
+
slug = transaction.data.data.slug;
|
|
1158
|
+
} else {
|
|
1159
|
+
slug = transaction.data.slug;
|
|
1160
|
+
}
|
|
1161
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1162
|
+
if (poolHandler) {
|
|
1163
|
+
const type = poolHandler.type;
|
|
1164
|
+
if (type === YieldPoolType.NATIVE_STAKING) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
} else {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1171
|
+
transactionId: id,
|
|
1172
|
+
address: transaction.address,
|
|
1173
|
+
slug: slug,
|
|
1174
|
+
network: transaction.chain,
|
|
1175
|
+
extrinsicHash: transaction.extrinsicHash
|
|
1176
|
+
}).catch(console.error);
|
|
1177
|
+
}
|
|
1001
1178
|
resetWallet() {
|
|
1002
1179
|
this.transactionSubject.next({});
|
|
1003
1180
|
}
|
|
@@ -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';
|