@subwallet/extension-base 1.1.33-beta.1 → 1.1.34-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +69 -120
- package/background/KoniTypes.js +13 -22
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -23
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +16 -19
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +17 -10
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +21 -3
- package/cjs/koni/background/handlers/Extension.js +69 -368
- package/cjs/koni/background/handlers/State.js +12 -18
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +104 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +17 -2
- package/cjs/services/chain-service/index.js +3 -25
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -5
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -6
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +1 -92
- package/cjs/services/storage-service/databases/index.js +0 -7
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -252
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +2 -6
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +10 -13
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +18 -11
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +4 -0
- package/koni/background/cron.js +22 -4
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -327
- package/koni/background/handlers/State.d.ts +1 -6
- package/koni/background/handlers/State.js +12 -17
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +104 -8
- package/package.json +8 -331
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +13 -1
- package/services/chain-service/constants.js +15 -1
- package/services/chain-service/index.d.ts +0 -2
- package/services/chain-service/index.js +3 -25
- 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 -2
- package/services/event-service/index.js +0 -5
- package/services/event-service/types.d.ts +0 -9
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -6
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +3 -30
- package/services/storage-service/DatabaseService.js +1 -91
- package/services/storage-service/databases/index.d.ts +2 -8
- package/services/storage-service/databases/index.js +0 -7
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +13 -6
- package/services/transaction-service/index.js +73 -250
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +0 -52
- package/utils/number.d.ts +1 -2
- package/utils/number.js +1 -2
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -49
- package/cjs/services/earning-service/constants/chains.js +0 -30
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -262
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -81
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -98
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -299
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -41
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
- package/cjs/services/earning-service/handlers/special.js +0 -497
- package/cjs/services/earning-service/service.js +0 -741
- 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/AssetRef.js +0 -24
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -48
- 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 -34
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -15
- package/services/earning-service/constants/chains.js +0 -22
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -113
- package/services/earning-service/handlers/base.js +0 -256
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -8
- package/services/earning-service/handlers/lending/base.js +0 -73
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -184
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
- package/services/earning-service/handlers/liquid-staking/base.js +0 -90
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +0 -37
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -132
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -288
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -5
- package/services/earning-service/handlers/liquid-staking/index.js +0 -8
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -456
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -152
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -556
- package/services/earning-service/handlers/special.d.ts +0 -64
- package/services/earning-service/handlers/special.js +0 -489
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -730
- 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/AssetRef.d.ts +0 -7
- package/services/storage-service/db-stores/AssetRef.js +0 -16
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -96
- package/types/yield/actions/join/step.js +0 -47
- package/types/yield/actions/join/submit.d.ts +0 -58
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -47
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -252
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -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,19 +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.
|
|
38
|
-
this.eventService =
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
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;
|
|
42
43
|
}
|
|
43
44
|
get allTransactions() {
|
|
44
45
|
return Object.values(this.transactions);
|
|
@@ -95,7 +96,7 @@ export default class TransactionService {
|
|
|
95
96
|
decimals: 0,
|
|
96
97
|
value: ''
|
|
97
98
|
};
|
|
98
|
-
const chainInfo = this.
|
|
99
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
99
100
|
if (!chainInfo) {
|
|
100
101
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
101
102
|
} else {
|
|
@@ -110,7 +111,7 @@ export default class TransactionService {
|
|
|
110
111
|
if (isSubstrateTransaction(transaction)) {
|
|
111
112
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
112
113
|
} else {
|
|
113
|
-
const web3 = this.
|
|
114
|
+
const web3 = this.chainService.getEvmApi(chain);
|
|
114
115
|
if (!web3) {
|
|
115
116
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
116
117
|
} else {
|
|
@@ -144,35 +145,32 @@ export default class TransactionService {
|
|
|
144
145
|
|
|
145
146
|
// Balance
|
|
146
147
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
147
|
-
const nativeTokenInfo = this.
|
|
148
|
-
const balance = await this.
|
|
148
|
+
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
+
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
149
150
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
150
151
|
const feeNum = parseInt(estimateFee.value);
|
|
151
152
|
const balanceNum = parseInt(balance.value);
|
|
152
153
|
const edNum = parseInt(existentialDeposit);
|
|
153
154
|
const transferNativeNum = parseInt(transferNative);
|
|
154
|
-
if (!
|
|
155
|
-
|
|
156
|
-
|
|
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) {
|
|
157
160
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
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
|
|
161
164
|
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
|
-
}
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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));
|
|
176
174
|
}
|
|
177
175
|
}
|
|
178
176
|
}
|
|
@@ -239,21 +237,12 @@ export default class TransactionService {
|
|
|
239
237
|
}
|
|
240
238
|
validatedTransaction.warnings = [];
|
|
241
239
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
242
|
-
await new Promise(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
resolve();
|
|
249
|
-
});
|
|
250
|
-
} else {
|
|
251
|
-
emitter.on('signed', data => {
|
|
252
|
-
validatedTransaction.id = data.id;
|
|
253
|
-
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
254
|
-
resolve();
|
|
255
|
-
});
|
|
256
|
-
}
|
|
240
|
+
await new Promise(resolve => {
|
|
241
|
+
emitter.on('signed', data => {
|
|
242
|
+
validatedTransaction.id = data.id;
|
|
243
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
244
|
+
resolve();
|
|
245
|
+
});
|
|
257
246
|
emitter.on('error', data => {
|
|
258
247
|
if (data.errors.length > 0) {
|
|
259
248
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -325,7 +314,7 @@ export default class TransactionService {
|
|
|
325
314
|
}
|
|
326
315
|
getTransactionLink(id) {
|
|
327
316
|
const transaction = this.getTransaction(id);
|
|
328
|
-
const chainInfo = this.
|
|
317
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
329
318
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
330
319
|
}
|
|
331
320
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -353,7 +342,7 @@ export default class TransactionService {
|
|
|
353
342
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
354
343
|
startBlock: startBlock || 0
|
|
355
344
|
};
|
|
356
|
-
const chainInfo = this.
|
|
345
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
357
346
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
358
347
|
const baseNativeAmount = {
|
|
359
348
|
value: '0',
|
|
@@ -367,7 +356,7 @@ export default class TransactionService {
|
|
|
367
356
|
{
|
|
368
357
|
const inputData = parseTransactionData(transaction.data);
|
|
369
358
|
historyItem.to = inputData.to;
|
|
370
|
-
const sendingTokenInfo = this.
|
|
359
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
371
360
|
historyItem.amount = {
|
|
372
361
|
value: inputData.value || '0',
|
|
373
362
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -380,7 +369,7 @@ export default class TransactionService {
|
|
|
380
369
|
{
|
|
381
370
|
const inputData = parseTransactionData(transaction.data);
|
|
382
371
|
historyItem.to = inputData.to;
|
|
383
|
-
const sendingTokenInfo = this.
|
|
372
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
384
373
|
historyItem.amount = {
|
|
385
374
|
value: inputData.value || '0',
|
|
386
375
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -393,7 +382,7 @@ export default class TransactionService {
|
|
|
393
382
|
{
|
|
394
383
|
const inputData = parseTransactionData(transaction.data);
|
|
395
384
|
historyItem.to = inputData.to;
|
|
396
|
-
const sendingTokenInfo = this.
|
|
385
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
397
386
|
historyItem.amount = {
|
|
398
387
|
value: inputData.value || '0',
|
|
399
388
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -442,29 +431,17 @@ export default class TransactionService {
|
|
|
442
431
|
case ExtrinsicType.STAKING_UNBOND:
|
|
443
432
|
{
|
|
444
433
|
const data = parseTransactionData(transaction.data);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
-
}
|
|
434
|
+
historyItem.to = data.validatorAddress || '';
|
|
435
|
+
historyItem.amount = {
|
|
436
|
+
...baseNativeAmount,
|
|
437
|
+
value: data.amount || '0'
|
|
438
|
+
};
|
|
462
439
|
}
|
|
463
440
|
break;
|
|
464
441
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
465
442
|
{
|
|
466
443
|
const data = parseTransactionData(transaction.data);
|
|
467
|
-
historyItem.to = data.address || '';
|
|
444
|
+
historyItem.to = data.nominatorMetadata.address || '';
|
|
468
445
|
historyItem.amount = {
|
|
469
446
|
...baseNativeAmount,
|
|
470
447
|
value: data.amount || '0'
|
|
@@ -483,21 +460,11 @@ export default class TransactionService {
|
|
|
483
460
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
484
461
|
{
|
|
485
462
|
const data = parseTransactionData(transaction.data);
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const amount = {
|
|
463
|
+
historyItem.to = data.validatorAddress || '';
|
|
464
|
+
historyItem.amount = {
|
|
489
465
|
...baseNativeAmount,
|
|
490
466
|
value: data.unstakingInfo.claimable || '0'
|
|
491
467
|
};
|
|
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;
|
|
501
468
|
break;
|
|
502
469
|
}
|
|
503
470
|
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -518,119 +485,6 @@ export default class TransactionService {
|
|
|
518
485
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
519
486
|
break;
|
|
520
487
|
}
|
|
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
|
-
}
|
|
634
488
|
case ExtrinsicType.UNKNOWN:
|
|
635
489
|
break;
|
|
636
490
|
}
|
|
@@ -676,7 +530,7 @@ export default class TransactionService {
|
|
|
676
530
|
});
|
|
677
531
|
|
|
678
532
|
// Create Input History Transaction History
|
|
679
|
-
this.
|
|
533
|
+
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
680
534
|
console.debug(`Transaction "${id}" is sent`);
|
|
681
535
|
}
|
|
682
536
|
onHasTransactionHash({
|
|
@@ -693,12 +547,8 @@ export default class TransactionService {
|
|
|
693
547
|
this.updateTransaction(id, updateData);
|
|
694
548
|
|
|
695
549
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
696
|
-
this.
|
|
550
|
+
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
697
551
|
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
|
-
}
|
|
702
552
|
}
|
|
703
553
|
handlePostProcessing(id) {
|
|
704
554
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -707,15 +557,15 @@ export default class TransactionService {
|
|
|
707
557
|
const inputData = parseTransactionData(transaction.data);
|
|
708
558
|
try {
|
|
709
559
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
710
|
-
sender && this.
|
|
711
|
-
this.
|
|
560
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
561
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
712
562
|
}).catch(console.error);
|
|
713
563
|
} catch (e) {
|
|
714
564
|
console.error(e);
|
|
715
565
|
}
|
|
716
566
|
try {
|
|
717
567
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
718
|
-
recipient && this.
|
|
568
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
719
569
|
...inputData.nftItem,
|
|
720
570
|
owner: recipient.address
|
|
721
571
|
}).catch(console.error);
|
|
@@ -723,7 +573,7 @@ export default class TransactionService {
|
|
|
723
573
|
console.error(e);
|
|
724
574
|
}
|
|
725
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)) {
|
|
726
|
-
this.
|
|
576
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
727
577
|
}
|
|
728
578
|
}
|
|
729
579
|
onSuccess({
|
|
@@ -739,14 +589,14 @@ export default class TransactionService {
|
|
|
739
589
|
});
|
|
740
590
|
|
|
741
591
|
// Write success transaction history
|
|
742
|
-
this.
|
|
592
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
743
593
|
extrinsicHash,
|
|
744
594
|
status: ExtrinsicStatus.SUCCESS,
|
|
745
595
|
blockNumber: blockNumber || 0,
|
|
746
596
|
blockHash: blockHash || ''
|
|
747
597
|
}).catch(console.error);
|
|
748
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.
|
|
749
|
-
this.
|
|
598
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
599
|
+
this.notificationService.notify({
|
|
750
600
|
type: NotificationType.SUCCESS,
|
|
751
601
|
title: t('Transaction completed'),
|
|
752
602
|
message: t('Transaction {{info}} completed', {
|
|
@@ -759,7 +609,7 @@ export default class TransactionService {
|
|
|
759
609
|
},
|
|
760
610
|
notifyViaBrowser: true
|
|
761
611
|
});
|
|
762
|
-
this.
|
|
612
|
+
this.eventService.emit('transaction.done', transaction);
|
|
763
613
|
}
|
|
764
614
|
onFailed({
|
|
765
615
|
blockHash,
|
|
@@ -778,14 +628,14 @@ export default class TransactionService {
|
|
|
778
628
|
});
|
|
779
629
|
|
|
780
630
|
// Write failed transaction history
|
|
781
|
-
this.
|
|
631
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
782
632
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
783
633
|
status: nextStatus,
|
|
784
634
|
blockNumber: blockNumber || 0,
|
|
785
635
|
blockHash: blockHash || ''
|
|
786
636
|
}).catch(console.error);
|
|
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.
|
|
788
|
-
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({
|
|
789
639
|
type: NotificationType.ERROR,
|
|
790
640
|
title: t('Transaction failed'),
|
|
791
641
|
message: t('Transaction {{info}} failed', {
|
|
@@ -799,7 +649,7 @@ export default class TransactionService {
|
|
|
799
649
|
notifyViaBrowser: true
|
|
800
650
|
});
|
|
801
651
|
}
|
|
802
|
-
this.
|
|
652
|
+
this.eventService.emit('transaction.failed', transaction);
|
|
803
653
|
}
|
|
804
654
|
onTimeOut({
|
|
805
655
|
blockHash,
|
|
@@ -841,7 +691,7 @@ export default class TransactionService {
|
|
|
841
691
|
}
|
|
842
692
|
generateHashPayload(chain, transaction) {
|
|
843
693
|
var _transaction$nonce;
|
|
844
|
-
const chainInfo = this.
|
|
694
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
845
695
|
const txObject = {
|
|
846
696
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
847
697
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -862,8 +712,8 @@ export default class TransactionService {
|
|
|
862
712
|
}) {
|
|
863
713
|
var _payload$nonce;
|
|
864
714
|
const payload = transaction;
|
|
865
|
-
const evmApi = this.
|
|
866
|
-
const chainInfo = this.
|
|
715
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
716
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
867
717
|
const accountPair = keyring.getPair(address);
|
|
868
718
|
const account = {
|
|
869
719
|
address,
|
|
@@ -893,7 +743,7 @@ export default class TransactionService {
|
|
|
893
743
|
|
|
894
744
|
// Set unique nonce to avoid transaction errors
|
|
895
745
|
if (!payload.nonce) {
|
|
896
|
-
const evmApi = this.
|
|
746
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
897
747
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
898
748
|
}
|
|
899
749
|
if (!payload.chainId) {
|
|
@@ -928,7 +778,7 @@ export default class TransactionService {
|
|
|
928
778
|
extrinsicHash: id
|
|
929
779
|
};
|
|
930
780
|
if (isInjected) {
|
|
931
|
-
this.
|
|
781
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
932
782
|
isApproved,
|
|
933
783
|
payload
|
|
934
784
|
}) => {
|
|
@@ -936,7 +786,7 @@ export default class TransactionService {
|
|
|
936
786
|
if (!payload) {
|
|
937
787
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
938
788
|
}
|
|
939
|
-
const web3Api = this.
|
|
789
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
940
790
|
|
|
941
791
|
// Emit signed event
|
|
942
792
|
emitter.emit('signed', eventData);
|
|
@@ -992,7 +842,7 @@ export default class TransactionService {
|
|
|
992
842
|
emitter.emit('error', eventData);
|
|
993
843
|
});
|
|
994
844
|
} else {
|
|
995
|
-
this.
|
|
845
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
996
846
|
isApproved,
|
|
997
847
|
payload
|
|
998
848
|
}) => {
|
|
@@ -1001,7 +851,7 @@ export default class TransactionService {
|
|
|
1001
851
|
if (!payload) {
|
|
1002
852
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
1003
853
|
}
|
|
1004
|
-
const web3Api = this.
|
|
854
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
1005
855
|
if (!isExternal) {
|
|
1006
856
|
signedTransaction = payload;
|
|
1007
857
|
} else {
|
|
@@ -1068,7 +918,7 @@ export default class TransactionService {
|
|
|
1068
918
|
transaction.signAsync(address, {
|
|
1069
919
|
signer: {
|
|
1070
920
|
signPayload: async payload => {
|
|
1071
|
-
const signing = await this.
|
|
921
|
+
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1072
922
|
return {
|
|
1073
923
|
id: new Date().getTime(),
|
|
1074
924
|
signature: signing.signature
|
|
@@ -1080,7 +930,7 @@ export default class TransactionService {
|
|
|
1080
930
|
emitter.emit('signed', eventData);
|
|
1081
931
|
|
|
1082
932
|
// Send transaction
|
|
1083
|
-
const api = this.
|
|
933
|
+
const api = this.chainService.getSubstrateApi(chain);
|
|
1084
934
|
eventData.nonce = rs.nonce.toNumber();
|
|
1085
935
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
1086
936
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -1148,33 +998,6 @@ export default class TransactionService {
|
|
|
1148
998
|
clearTimeout(timeout);
|
|
1149
999
|
});
|
|
1150
1000
|
}
|
|
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
|
-
}
|
|
1178
1001
|
resetWallet() {
|
|
1179
1002
|
this.transactionSubject.next({});
|
|
1180
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;
|
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 {};
|
package/utils/fetchStaticData.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { staticData } from '@subwallet/extension-base/utils/staticData';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
-
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
7
6
|
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
8
|
-
const fetchTarget =
|
|
7
|
+
const fetchTarget = branchName === 'master' || branchName === 'webapp' ? 'list.json' : 'preview.json';
|
|
9
8
|
export async function fetchStaticData(slug, targetFile) {
|
|
10
9
|
const fetchFile = targetFile || fetchTarget;
|
|
11
10
|
try {
|
package/utils/index.d.ts
CHANGED
|
@@ -39,17 +39,12 @@ export declare function isSameAddress(address1: string, address2: string): boole
|
|
|
39
39
|
export declare function getDomainFromUrl(url: string): string;
|
|
40
40
|
export declare function waitTimeout(ms: number): Promise<void>;
|
|
41
41
|
export declare const stripUrl: (url: string) => string;
|
|
42
|
-
export declare const baseParseIPFSUrl: (input: string) => string | undefined;
|
|
43
|
-
export declare const swParseIPFSUrl: (input: string) => string | undefined;
|
|
44
42
|
export declare function wait(milliseconds: number): Promise<void>;
|
|
45
43
|
export * from './account';
|
|
46
44
|
export * from './array';
|
|
47
45
|
export * from './environment';
|
|
48
|
-
export * from './number';
|
|
49
46
|
export * from './lazy';
|
|
50
|
-
export * from './promise';
|
|
51
47
|
export * from './registry';
|
|
52
48
|
export * from './translate';
|
|
53
|
-
export * from './object';
|
|
54
49
|
export * from './fetchStaticData';
|
|
55
50
|
export * from './fetchEvmChainInfo';
|