@subwallet/extension-base 1.1.31-beta.0 → 1.1.33-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 +71 -111
- package/background/KoniTypes.js +14 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +17 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +108 -76
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +3 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +29 -28
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +36 -11
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/cron.js +1 -11
- package/cjs/koni/background/handlers/Extension.js +69 -362
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/Tabs.js +19 -2
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +37 -95
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +25 -9
- package/cjs/services/chain-service/constants.js +21 -4
- package/cjs/services/chain-service/index.js +2 -3
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- package/cjs/services/history-service/index.js +12 -8
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -7
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -51
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/Campaign.js +9 -3
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +131 -242
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchEvmChainInfo.js +20 -0
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +17 -81
- package/cjs/utils/number.js +1 -3
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.d.ts +1 -1
- package/koni/api/staking/bonding/amplitude.js +105 -73
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +2 -1
- package/koni/api/staking/bonding/index.js +3 -5
- package/koni/api/staking/bonding/paraChain.js +16 -15
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +42 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +37 -12
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/cron.d.ts +0 -1
- package/koni/background/cron.js +2 -12
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -321
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/Tabs.js +20 -3
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +38 -97
- package/package.json +13 -321
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +25 -9
- package/services/chain-service/constants.d.ts +12 -0
- package/services/chain-service/constants.js +19 -3
- package/services/chain-service/index.js +2 -3
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +1 -8
- package/services/history-service/index.js +12 -8
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -7
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +2 -18
- package/services/storage-service/DatabaseService.js +3 -51
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/Campaign.js +9 -3
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +16 -4
- package/services/transaction-service/index.js +118 -230
- package/services/transaction-service/types.d.ts +1 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchEvmChainInfo.d.ts +17 -0
- package/utils/fetchEvmChainInfo.js +14 -0
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +2 -5
- package/utils/index.js +2 -52
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -259
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
- package/cjs/services/earning-service/handlers/special.js +0 -503
- package/cjs/services/earning-service/service.js +0 -387
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -112
- package/services/earning-service/handlers/base.js +0 -253
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -183
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
- package/services/earning-service/handlers/liquid-staking/base.js +0 -35
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -451
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -150
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -377
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -550
- package/services/earning-service/handlers/special.d.ts +0 -65
- package/services/earning-service/handlers/special.js +0 -495
- package/services/earning-service/service.d.ts +0 -45
- package/services/earning-service/service.js +0 -379
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -57
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -45
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -251
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -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 {
|
|
9
|
+
import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
10
|
+
import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
11
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
11
12
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
12
|
-
import {
|
|
13
|
+
import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
13
14
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
14
15
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
15
16
|
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,15 +26,20 @@ 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";
|
|
30
29
|
export default class TransactionService {
|
|
31
30
|
transactionSubject = new BehaviorSubject({});
|
|
32
31
|
watchTransactionSubscribes = {};
|
|
33
32
|
get transactions() {
|
|
34
33
|
return this.transactionSubject.getValue();
|
|
35
34
|
}
|
|
36
|
-
constructor(
|
|
37
|
-
this.
|
|
35
|
+
constructor(chainService, eventService, requestService, balanceService, historyService, notificationService, databaseService) {
|
|
36
|
+
this.chainService = chainService;
|
|
37
|
+
this.eventService = eventService;
|
|
38
|
+
this.requestService = requestService;
|
|
39
|
+
this.balanceService = balanceService;
|
|
40
|
+
this.historyService = historyService;
|
|
41
|
+
this.notificationService = notificationService;
|
|
42
|
+
this.databaseService = databaseService;
|
|
38
43
|
}
|
|
39
44
|
get allTransactions() {
|
|
40
45
|
return Object.values(this.transactions);
|
|
@@ -91,7 +96,7 @@ export default class TransactionService {
|
|
|
91
96
|
decimals: 0,
|
|
92
97
|
value: ''
|
|
93
98
|
};
|
|
94
|
-
const chainInfo = this.
|
|
99
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
95
100
|
if (!chainInfo) {
|
|
96
101
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
97
102
|
} else {
|
|
@@ -106,7 +111,7 @@ export default class TransactionService {
|
|
|
106
111
|
if (isSubstrateTransaction(transaction)) {
|
|
107
112
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
108
113
|
} else {
|
|
109
|
-
const web3 = this.
|
|
114
|
+
const web3 = this.chainService.getEvmApi(chain);
|
|
110
115
|
if (!web3) {
|
|
111
116
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
112
117
|
} else {
|
|
@@ -140,35 +145,32 @@ export default class TransactionService {
|
|
|
140
145
|
|
|
141
146
|
// Balance
|
|
142
147
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
143
|
-
const nativeTokenInfo = this.
|
|
144
|
-
const balance = await this.
|
|
148
|
+
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
+
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
145
150
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
146
151
|
const feeNum = parseInt(estimateFee.value);
|
|
147
152
|
const balanceNum = parseInt(balance.value);
|
|
148
153
|
const edNum = parseInt(existentialDeposit);
|
|
149
154
|
const transferNativeNum = parseInt(transferNative);
|
|
150
|
-
if (!
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
if (!new BigN(balance.value).gt(0)) {
|
|
156
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
157
|
+
}
|
|
158
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
159
|
+
if (!isTransferAll) {
|
|
153
160
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
} else {
|
|
162
|
+
if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
163
|
+
// Chain not have transfer all function
|
|
157
164
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
158
|
-
} else {
|
|
159
|
-
if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
160
|
-
// Chain not have transfer all function
|
|
161
|
-
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
162
|
-
}
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
}
|
|
168
|
+
if (!isTransferAll) {
|
|
169
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
170
|
+
if (edAsWarning) {
|
|
171
|
+
validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
172
|
+
} else {
|
|
173
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
}
|
|
@@ -235,21 +237,12 @@ export default class TransactionService {
|
|
|
235
237
|
}
|
|
236
238
|
validatedTransaction.warnings = [];
|
|
237
239
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
238
|
-
await new Promise(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
} else {
|
|
247
|
-
emitter.on('signed', data => {
|
|
248
|
-
validatedTransaction.id = data.id;
|
|
249
|
-
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
250
|
-
resolve();
|
|
251
|
-
});
|
|
252
|
-
}
|
|
240
|
+
await new Promise(resolve => {
|
|
241
|
+
emitter.on('signed', data => {
|
|
242
|
+
validatedTransaction.id = data.id;
|
|
243
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
244
|
+
resolve();
|
|
245
|
+
});
|
|
253
246
|
emitter.on('error', data => {
|
|
254
247
|
if (data.errors.length > 0) {
|
|
255
248
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -290,6 +283,12 @@ export default class TransactionService {
|
|
|
290
283
|
errors: [...data.errors, new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]
|
|
291
284
|
});
|
|
292
285
|
});
|
|
286
|
+
emitter.on('timeout', data => {
|
|
287
|
+
this.onTimeOut({
|
|
288
|
+
...data,
|
|
289
|
+
errors: [...data.errors, new TransactionError(BasicTxErrorType.TIMEOUT)]
|
|
290
|
+
});
|
|
291
|
+
});
|
|
293
292
|
|
|
294
293
|
// Todo: handle any event with transaction.eventsHandler
|
|
295
294
|
|
|
@@ -315,7 +314,7 @@ export default class TransactionService {
|
|
|
315
314
|
}
|
|
316
315
|
getTransactionLink(id) {
|
|
317
316
|
const transaction = this.getTransaction(id);
|
|
318
|
-
const chainInfo = this.
|
|
317
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
319
318
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
320
319
|
}
|
|
321
320
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -343,7 +342,7 @@ export default class TransactionService {
|
|
|
343
342
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
344
343
|
startBlock: startBlock || 0
|
|
345
344
|
};
|
|
346
|
-
const chainInfo = this.
|
|
345
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
347
346
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
348
347
|
const baseNativeAmount = {
|
|
349
348
|
value: '0',
|
|
@@ -357,7 +356,7 @@ export default class TransactionService {
|
|
|
357
356
|
{
|
|
358
357
|
const inputData = parseTransactionData(transaction.data);
|
|
359
358
|
historyItem.to = inputData.to;
|
|
360
|
-
const sendingTokenInfo = this.
|
|
359
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
361
360
|
historyItem.amount = {
|
|
362
361
|
value: inputData.value || '0',
|
|
363
362
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -370,7 +369,7 @@ export default class TransactionService {
|
|
|
370
369
|
{
|
|
371
370
|
const inputData = parseTransactionData(transaction.data);
|
|
372
371
|
historyItem.to = inputData.to;
|
|
373
|
-
const sendingTokenInfo = this.
|
|
372
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
374
373
|
historyItem.amount = {
|
|
375
374
|
value: inputData.value || '0',
|
|
376
375
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -383,7 +382,7 @@ export default class TransactionService {
|
|
|
383
382
|
{
|
|
384
383
|
const inputData = parseTransactionData(transaction.data);
|
|
385
384
|
historyItem.to = inputData.to;
|
|
386
|
-
const sendingTokenInfo = this.
|
|
385
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
387
386
|
historyItem.amount = {
|
|
388
387
|
value: inputData.value || '0',
|
|
389
388
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -432,29 +431,17 @@ export default class TransactionService {
|
|
|
432
431
|
case ExtrinsicType.STAKING_UNBOND:
|
|
433
432
|
{
|
|
434
433
|
const data = parseTransactionData(transaction.data);
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
};
|
|
441
|
-
historyItem.additionalInfo = {
|
|
442
|
-
inputTokenSlug: data.inputTokenInfo.slug,
|
|
443
|
-
exchangeRate: data.exchangeRate
|
|
444
|
-
};
|
|
445
|
-
} else {
|
|
446
|
-
historyItem.to = data.validatorAddress || '';
|
|
447
|
-
historyItem.amount = {
|
|
448
|
-
...baseNativeAmount,
|
|
449
|
-
value: data.amount || '0'
|
|
450
|
-
};
|
|
451
|
-
}
|
|
434
|
+
historyItem.to = data.validatorAddress || '';
|
|
435
|
+
historyItem.amount = {
|
|
436
|
+
...baseNativeAmount,
|
|
437
|
+
value: data.amount || '0'
|
|
438
|
+
};
|
|
452
439
|
}
|
|
453
440
|
break;
|
|
454
441
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
455
442
|
{
|
|
456
443
|
const data = parseTransactionData(transaction.data);
|
|
457
|
-
historyItem.to = data.address || '';
|
|
444
|
+
historyItem.to = data.nominatorMetadata.address || '';
|
|
458
445
|
historyItem.amount = {
|
|
459
446
|
...baseNativeAmount,
|
|
460
447
|
value: data.amount || '0'
|
|
@@ -473,21 +460,11 @@ export default class TransactionService {
|
|
|
473
460
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
474
461
|
{
|
|
475
462
|
const data = parseTransactionData(transaction.data);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
const amount = {
|
|
463
|
+
historyItem.to = data.validatorAddress || '';
|
|
464
|
+
historyItem.amount = {
|
|
479
465
|
...baseNativeAmount,
|
|
480
466
|
value: data.unstakingInfo.claimable || '0'
|
|
481
467
|
};
|
|
482
|
-
if (poolHandler) {
|
|
483
|
-
const asset = this.state.getAssetBySlug(poolHandler.metadataInfo.inputAsset);
|
|
484
|
-
if (asset) {
|
|
485
|
-
amount.decimals = asset.decimals || 0;
|
|
486
|
-
amount.symbol = asset.symbol;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
historyItem.to = data.unstakingInfo.validatorAddress || '';
|
|
490
|
-
historyItem.amount = amount;
|
|
491
468
|
break;
|
|
492
469
|
}
|
|
493
470
|
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -508,102 +485,6 @@ export default class TransactionService {
|
|
|
508
485
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
509
486
|
break;
|
|
510
487
|
}
|
|
511
|
-
case ExtrinsicType.MINT_STDOT:
|
|
512
|
-
case ExtrinsicType.MINT_QDOT:
|
|
513
|
-
case ExtrinsicType.MINT_LDOT:
|
|
514
|
-
case ExtrinsicType.MINT_SDOT:
|
|
515
|
-
|
|
516
|
-
// eslint-disable-next-line no-fallthrough
|
|
517
|
-
case ExtrinsicType.MINT_VDOT:
|
|
518
|
-
{
|
|
519
|
-
const params = parseTransactionData(transaction.data);
|
|
520
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
521
|
-
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
522
|
-
historyItem.amount = {
|
|
523
|
-
value: params.amount,
|
|
524
|
-
symbol: _getAssetSymbol(inputTokenInfo),
|
|
525
|
-
decimals: _getAssetDecimals(inputTokenInfo)
|
|
526
|
-
};
|
|
527
|
-
const additionalInfo = {
|
|
528
|
-
slug: params.slug,
|
|
529
|
-
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
530
|
-
exchangeRate: params.exchangeRate
|
|
531
|
-
};
|
|
532
|
-
historyItem.additionalInfo = additionalInfo;
|
|
533
|
-
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
case ExtrinsicType.REDEEM_QDOT:
|
|
537
|
-
{
|
|
538
|
-
const data = parseTransactionData(transaction.data);
|
|
539
|
-
const yieldPoolInfo = data.poolInfo;
|
|
540
|
-
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
541
|
-
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
542
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
543
|
-
historyItem.amount = {
|
|
544
|
-
value: data.amount,
|
|
545
|
-
symbol: _getAssetSymbol(inputTokenInfo),
|
|
546
|
-
decimals: _getAssetDecimals(inputTokenInfo)
|
|
547
|
-
};
|
|
548
|
-
eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
549
|
-
}
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
case ExtrinsicType.UNSTAKE_QDOT:
|
|
553
|
-
case ExtrinsicType.UNSTAKE_VDOT:
|
|
554
|
-
case ExtrinsicType.UNSTAKE_LDOT:
|
|
555
|
-
case ExtrinsicType.UNSTAKE_SDOT:
|
|
556
|
-
case ExtrinsicType.UNSTAKE_STDOT:
|
|
557
|
-
case ExtrinsicType.REDEEM_STDOT:
|
|
558
|
-
case ExtrinsicType.REDEEM_LDOT:
|
|
559
|
-
case ExtrinsicType.REDEEM_SDOT:
|
|
560
|
-
|
|
561
|
-
// eslint-disable-next-line no-fallthrough
|
|
562
|
-
case ExtrinsicType.REDEEM_VDOT:
|
|
563
|
-
{
|
|
564
|
-
const data = parseTransactionData(transaction.data);
|
|
565
|
-
const yieldPoolInfo = data.poolInfo;
|
|
566
|
-
const minAmountPercents = this.state.earningService.getMinAmountPercent();
|
|
567
|
-
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
568
|
-
var _yieldPoolInfo$statis;
|
|
569
|
-
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
570
|
-
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
571
|
-
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
572
|
-
historyItem.amount = {
|
|
573
|
-
value: data.amount,
|
|
574
|
-
symbol: _getAssetSymbol(derivativeTokenInfo),
|
|
575
|
-
decimals: _getAssetDecimals(derivativeTokenInfo)
|
|
576
|
-
};
|
|
577
|
-
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
578
|
-
const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
|
|
579
|
-
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
580
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
581
|
-
const additionalInfo = {
|
|
582
|
-
minAmountPercent,
|
|
583
|
-
symbol: inputTokenInfo.symbol,
|
|
584
|
-
decimals: inputTokenInfo.decimals || 0,
|
|
585
|
-
exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
|
|
586
|
-
slug: yieldPoolInfo.slug,
|
|
587
|
-
type: yieldPoolInfo.type,
|
|
588
|
-
chain: yieldPoolInfo.chain,
|
|
589
|
-
group: yieldPoolInfo.group,
|
|
590
|
-
isFast: data.fastLeave
|
|
591
|
-
};
|
|
592
|
-
historyItem.additionalInfo = additionalInfo;
|
|
593
|
-
}
|
|
594
|
-
break;
|
|
595
|
-
}
|
|
596
|
-
case ExtrinsicType.TOKEN_APPROVE:
|
|
597
|
-
{
|
|
598
|
-
const data = parseTransactionData(transaction.data);
|
|
599
|
-
const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
|
|
600
|
-
historyItem.amount = {
|
|
601
|
-
value: '0',
|
|
602
|
-
symbol: _getAssetSymbol(inputAsset),
|
|
603
|
-
decimals: _getAssetDecimals(inputAsset)
|
|
604
|
-
};
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
488
|
case ExtrinsicType.UNKNOWN:
|
|
608
489
|
break;
|
|
609
490
|
}
|
|
@@ -649,7 +530,7 @@ export default class TransactionService {
|
|
|
649
530
|
});
|
|
650
531
|
|
|
651
532
|
// Create Input History Transaction History
|
|
652
|
-
this.
|
|
533
|
+
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
653
534
|
console.debug(`Transaction "${id}" is sent`);
|
|
654
535
|
}
|
|
655
536
|
onHasTransactionHash({
|
|
@@ -666,12 +547,8 @@ export default class TransactionService {
|
|
|
666
547
|
this.updateTransaction(id, updateData);
|
|
667
548
|
|
|
668
549
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
669
|
-
this.
|
|
550
|
+
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
670
551
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
671
|
-
const transaction = this.getTransaction(id);
|
|
672
|
-
if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
673
|
-
this.handlePostEarningTransaction(id);
|
|
674
|
-
}
|
|
675
552
|
}
|
|
676
553
|
handlePostProcessing(id) {
|
|
677
554
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -680,15 +557,15 @@ export default class TransactionService {
|
|
|
680
557
|
const inputData = parseTransactionData(transaction.data);
|
|
681
558
|
try {
|
|
682
559
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
683
|
-
sender && this.
|
|
684
|
-
this.
|
|
560
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
561
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
685
562
|
}).catch(console.error);
|
|
686
563
|
} catch (e) {
|
|
687
564
|
console.error(e);
|
|
688
565
|
}
|
|
689
566
|
try {
|
|
690
567
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
691
|
-
recipient && this.
|
|
568
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
692
569
|
...inputData.nftItem,
|
|
693
570
|
owner: recipient.address
|
|
694
571
|
}).catch(console.error);
|
|
@@ -696,7 +573,7 @@ export default class TransactionService {
|
|
|
696
573
|
console.error(e);
|
|
697
574
|
}
|
|
698
575
|
} 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)) {
|
|
699
|
-
this.
|
|
576
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
700
577
|
}
|
|
701
578
|
}
|
|
702
579
|
onSuccess({
|
|
@@ -712,14 +589,14 @@ export default class TransactionService {
|
|
|
712
589
|
});
|
|
713
590
|
|
|
714
591
|
// Write success transaction history
|
|
715
|
-
this.
|
|
592
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
716
593
|
extrinsicHash,
|
|
717
594
|
status: ExtrinsicStatus.SUCCESS,
|
|
718
595
|
blockNumber: blockNumber || 0,
|
|
719
596
|
blockHash: blockHash || ''
|
|
720
597
|
}).catch(console.error);
|
|
721
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.
|
|
722
|
-
this.
|
|
598
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
599
|
+
this.notificationService.notify({
|
|
723
600
|
type: NotificationType.SUCCESS,
|
|
724
601
|
title: t('Transaction completed'),
|
|
725
602
|
message: t('Transaction {{info}} completed', {
|
|
@@ -732,7 +609,7 @@ export default class TransactionService {
|
|
|
732
609
|
},
|
|
733
610
|
notifyViaBrowser: true
|
|
734
611
|
});
|
|
735
|
-
this.
|
|
612
|
+
this.eventService.emit('transaction.done', transaction);
|
|
736
613
|
}
|
|
737
614
|
onFailed({
|
|
738
615
|
blockHash,
|
|
@@ -751,14 +628,14 @@ export default class TransactionService {
|
|
|
751
628
|
});
|
|
752
629
|
|
|
753
630
|
// Write failed transaction history
|
|
754
|
-
this.
|
|
631
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
755
632
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
756
633
|
status: nextStatus,
|
|
757
634
|
blockNumber: blockNumber || 0,
|
|
758
635
|
blockHash: blockHash || ''
|
|
759
636
|
}).catch(console.error);
|
|
760
|
-
const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.
|
|
761
|
-
this.
|
|
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({
|
|
762
639
|
type: NotificationType.ERROR,
|
|
763
640
|
title: t('Transaction failed'),
|
|
764
641
|
message: t('Transaction {{info}} failed', {
|
|
@@ -772,11 +649,49 @@ export default class TransactionService {
|
|
|
772
649
|
notifyViaBrowser: true
|
|
773
650
|
});
|
|
774
651
|
}
|
|
775
|
-
this.
|
|
652
|
+
this.eventService.emit('transaction.failed', transaction);
|
|
653
|
+
}
|
|
654
|
+
onTimeOut({
|
|
655
|
+
blockHash,
|
|
656
|
+
blockNumber,
|
|
657
|
+
errors,
|
|
658
|
+
extrinsicHash,
|
|
659
|
+
id
|
|
660
|
+
}) {
|
|
661
|
+
const transaction = this.getTransaction(id);
|
|
662
|
+
const nextStatus = ExtrinsicStatus.TIMEOUT;
|
|
663
|
+
if (transaction) {
|
|
664
|
+
this.updateTransaction(id, {
|
|
665
|
+
status: nextStatus,
|
|
666
|
+
errors,
|
|
667
|
+
extrinsicHash
|
|
668
|
+
});
|
|
669
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
670
|
+
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
671
|
+
status: nextStatus,
|
|
672
|
+
blockNumber: blockNumber || 0,
|
|
673
|
+
blockHash: blockHash || ''
|
|
674
|
+
}).catch(console.error);
|
|
675
|
+
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());
|
|
676
|
+
this.notificationService.notify({
|
|
677
|
+
type: NotificationType.ERROR,
|
|
678
|
+
title: t('Transaction timed out'),
|
|
679
|
+
message: t('Transaction {{info}} timed out', {
|
|
680
|
+
replace: {
|
|
681
|
+
info
|
|
682
|
+
}
|
|
683
|
+
}),
|
|
684
|
+
action: {
|
|
685
|
+
url: this.getTransactionLink(id)
|
|
686
|
+
},
|
|
687
|
+
notifyViaBrowser: true
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
this.eventService.emit('transaction.timeout', transaction);
|
|
776
691
|
}
|
|
777
692
|
generateHashPayload(chain, transaction) {
|
|
778
693
|
var _transaction$nonce;
|
|
779
|
-
const chainInfo = this.
|
|
694
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
780
695
|
const txObject = {
|
|
781
696
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
782
697
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -797,8 +712,8 @@ export default class TransactionService {
|
|
|
797
712
|
}) {
|
|
798
713
|
var _payload$nonce;
|
|
799
714
|
const payload = transaction;
|
|
800
|
-
const evmApi = this.
|
|
801
|
-
const chainInfo = this.
|
|
715
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
716
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
802
717
|
const accountPair = keyring.getPair(address);
|
|
803
718
|
const account = {
|
|
804
719
|
address,
|
|
@@ -828,7 +743,7 @@ export default class TransactionService {
|
|
|
828
743
|
|
|
829
744
|
// Set unique nonce to avoid transaction errors
|
|
830
745
|
if (!payload.nonce) {
|
|
831
|
-
const evmApi = this.
|
|
746
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
832
747
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
833
748
|
}
|
|
834
749
|
if (!payload.chainId) {
|
|
@@ -863,7 +778,7 @@ export default class TransactionService {
|
|
|
863
778
|
extrinsicHash: id
|
|
864
779
|
};
|
|
865
780
|
if (isInjected) {
|
|
866
|
-
this.
|
|
781
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
867
782
|
isApproved,
|
|
868
783
|
payload
|
|
869
784
|
}) => {
|
|
@@ -871,7 +786,7 @@ export default class TransactionService {
|
|
|
871
786
|
if (!payload) {
|
|
872
787
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
873
788
|
}
|
|
874
|
-
const web3Api = this.
|
|
789
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
875
790
|
|
|
876
791
|
// Emit signed event
|
|
877
792
|
emitter.emit('signed', eventData);
|
|
@@ -927,7 +842,7 @@ export default class TransactionService {
|
|
|
927
842
|
emitter.emit('error', eventData);
|
|
928
843
|
});
|
|
929
844
|
} else {
|
|
930
|
-
this.
|
|
845
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
931
846
|
isApproved,
|
|
932
847
|
payload
|
|
933
848
|
}) => {
|
|
@@ -936,7 +851,7 @@ export default class TransactionService {
|
|
|
936
851
|
if (!payload) {
|
|
937
852
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
938
853
|
}
|
|
939
|
-
const web3Api = this.
|
|
854
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
940
855
|
if (!isExternal) {
|
|
941
856
|
signedTransaction = payload;
|
|
942
857
|
} else {
|
|
@@ -1003,7 +918,7 @@ export default class TransactionService {
|
|
|
1003
918
|
transaction.signAsync(address, {
|
|
1004
919
|
signer: {
|
|
1005
920
|
signPayload: async payload => {
|
|
1006
|
-
const signing = await this.
|
|
921
|
+
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1007
922
|
return {
|
|
1008
923
|
id: new Date().getTime(),
|
|
1009
924
|
signature: signing.signature
|
|
@@ -1015,7 +930,7 @@ export default class TransactionService {
|
|
|
1015
930
|
emitter.emit('signed', eventData);
|
|
1016
931
|
|
|
1017
932
|
// Send transaction
|
|
1018
|
-
const api = this.
|
|
933
|
+
const api = this.chainService.getSubstrateApi(chain);
|
|
1019
934
|
eventData.nonce = rs.nonce.toNumber();
|
|
1020
935
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
1021
936
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -1072,7 +987,7 @@ export default class TransactionService {
|
|
|
1072
987
|
const transaction = this.getTransaction(eventData.id);
|
|
1073
988
|
if (transaction.status !== ExtrinsicStatus.SUCCESS && transaction.status !== ExtrinsicStatus.FAIL) {
|
|
1074
989
|
eventData.errors.push(new TransactionError(BasicTxErrorType.TIMEOUT, t('Transaction timeout')));
|
|
1075
|
-
emitter.emit('
|
|
990
|
+
emitter.emit('timeout', eventData);
|
|
1076
991
|
clearTimeout(timeout);
|
|
1077
992
|
}
|
|
1078
993
|
}, TRANSACTION_TIMEOUT);
|
|
@@ -1083,33 +998,6 @@ export default class TransactionService {
|
|
|
1083
998
|
clearTimeout(timeout);
|
|
1084
999
|
});
|
|
1085
1000
|
}
|
|
1086
|
-
handlePostEarningTransaction(id) {
|
|
1087
|
-
const transaction = this.getTransaction(id);
|
|
1088
|
-
let slug;
|
|
1089
|
-
|
|
1090
|
-
// TODO
|
|
1091
|
-
if ('data' in transaction.data) {
|
|
1092
|
-
slug = transaction.data.data.slug;
|
|
1093
|
-
} else {
|
|
1094
|
-
slug = transaction.data.slug;
|
|
1095
|
-
}
|
|
1096
|
-
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1097
|
-
if (poolHandler) {
|
|
1098
|
-
const type = poolHandler.type;
|
|
1099
|
-
if (type === YieldPoolType.NATIVE_STAKING) {
|
|
1100
|
-
return;
|
|
1101
|
-
}
|
|
1102
|
-
} else {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1106
|
-
transactionId: id,
|
|
1107
|
-
address: transaction.address,
|
|
1108
|
-
slug: slug,
|
|
1109
|
-
network: transaction.chain,
|
|
1110
|
-
extrinsicHash: transaction.extrinsicHash
|
|
1111
|
-
}).catch(console.error);
|
|
1112
|
-
}
|
|
1113
1001
|
resetWallet() {
|
|
1114
1002
|
this.transactionSubject.next({});
|
|
1115
1003
|
}
|
|
@@ -30,8 +30,6 @@ 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;
|
|
35
33
|
}
|
|
36
34
|
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
|
|
37
35
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
|
@@ -51,5 +49,6 @@ export interface TransactionEventMap {
|
|
|
51
49
|
extrinsicHash: (response: TransactionEventResponse) => void;
|
|
52
50
|
error: (response: TransactionEventResponse) => void;
|
|
53
51
|
success: (response: TransactionEventResponse) => void;
|
|
52
|
+
timeout: (response: TransactionEventResponse) => void;
|
|
54
53
|
}
|
|
55
54
|
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -5,12 +5,7 @@ export interface Message extends MessageEvent {
|
|
|
5
5
|
origin: string;
|
|
6
6
|
response?: string;
|
|
7
7
|
subscription?: string;
|
|
8
|
-
sender?: string;
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
10
|
export * from './balance';
|
|
12
11
|
export * from './buy';
|
|
13
|
-
export * from './campaigns';
|
|
14
|
-
export * from './ordinal';
|
|
15
|
-
export * from './transaction';
|
|
16
|
-
export * from './yield';
|
package/types/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export * from "./balance.js";
|
|
5
5
|
export * from "./buy.js";
|
|
6
|
-
export * from "./campaigns/index.js";
|
|
7
|
-
export * from "./ordinal.js";
|
|
8
|
-
export * from "./transaction.js";
|
|
9
|
-
export * from "./yield/index.js";
|
|
10
6
|
export {};
|