@subwallet/extension-base 1.1.31-0 → 1.1.31-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +17 -15
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +11 -1
- package/cjs/koni/background/handlers/Extension.js +362 -69
- package/cjs/koni/background/handlers/State.js +51 -3
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +95 -37
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -16
- package/cjs/services/chain-service/index.js +3 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +29 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +259 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +20 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +191 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +239 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +297 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +226 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +395 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +384 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +461 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +159 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +385 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +560 -0
- package/cjs/services/earning-service/handlers/special.js +503 -0
- package/cjs/services/earning-service/service.js +387 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +4 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +7 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +51 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +65 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +231 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/number.js +3 -1
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +11 -9
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +12 -2
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +321 -30
- package/koni/background/handlers/State.d.ts +18 -2
- package/koni/background/handlers/State.js +50 -3
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +97 -38
- package/package.json +321 -8
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +1 -14
- package/services/chain-service/index.js +3 -2
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +14 -0
- package/services/earning-service/constants/chains.js +21 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +112 -0
- package/services/earning-service/handlers/base.js +253 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +6 -0
- package/services/earning-service/handlers/lending/base.js +12 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +183 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +231 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +9 -0
- package/services/earning-service/handlers/liquid-staking/base.js +35 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +286 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +218 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +385 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +375 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +451 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +150 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +377 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +549 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +550 -0
- package/services/earning-service/handlers/special.d.ts +65 -0
- package/services/earning-service/handlers/special.js +495 -0
- package/services/earning-service/service.d.ts +45 -0
- package/services/earning-service/service.js +379 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +8 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +7 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +18 -1
- package/services/storage-service/DatabaseService.js +51 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +9 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +57 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +4 -15
- package/services/transaction-service/index.js +229 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +57 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +45 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +251 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +53 -1
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -6,14 +6,14 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
6
6
|
import { BasicTxErrorType, BasicTxWarningCode, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
7
|
import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
|
|
8
8
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
9
|
-
import {
|
|
10
|
-
import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
10
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
12
11
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
13
|
-
import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
12
|
+
import { parseLiquidStakingEvents, parseLiquidStakingFastUnstakeEvents, parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
14
13
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
15
14
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
16
15
|
import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
16
|
+
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
17
17
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
18
18
|
import { anyNumberToBN, recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
|
|
19
19
|
import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
|
|
@@ -26,20 +26,15 @@ import EventEmitter from 'eventemitter3';
|
|
|
26
26
|
import { t } from 'i18next';
|
|
27
27
|
import { BehaviorSubject } from 'rxjs';
|
|
28
28
|
import { isHex } from '@polkadot/util';
|
|
29
|
+
import { _TRANSFER_CHAIN_GROUP } from "../chain-service/constants.js";
|
|
29
30
|
export default class TransactionService {
|
|
30
31
|
transactionSubject = new BehaviorSubject({});
|
|
31
32
|
watchTransactionSubscribes = {};
|
|
32
33
|
get transactions() {
|
|
33
34
|
return this.transactionSubject.getValue();
|
|
34
35
|
}
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
37
|
-
this.eventService = eventService;
|
|
38
|
-
this.requestService = requestService;
|
|
39
|
-
this.balanceService = balanceService;
|
|
40
|
-
this.historyService = historyService;
|
|
41
|
-
this.notificationService = notificationService;
|
|
42
|
-
this.databaseService = databaseService;
|
|
36
|
+
constructor(state) {
|
|
37
|
+
this.state = state;
|
|
43
38
|
}
|
|
44
39
|
get allTransactions() {
|
|
45
40
|
return Object.values(this.transactions);
|
|
@@ -96,7 +91,7 @@ export default class TransactionService {
|
|
|
96
91
|
decimals: 0,
|
|
97
92
|
value: ''
|
|
98
93
|
};
|
|
99
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
94
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
100
95
|
if (!chainInfo) {
|
|
101
96
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
102
97
|
} else {
|
|
@@ -111,7 +106,7 @@ export default class TransactionService {
|
|
|
111
106
|
if (isSubstrateTransaction(transaction)) {
|
|
112
107
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
113
108
|
} else {
|
|
114
|
-
const web3 = this.chainService.getEvmApi(chain);
|
|
109
|
+
const web3 = this.state.chainService.getEvmApi(chain);
|
|
115
110
|
if (!web3) {
|
|
116
111
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
117
112
|
} else {
|
|
@@ -145,32 +140,35 @@ export default class TransactionService {
|
|
|
145
140
|
|
|
146
141
|
// Balance
|
|
147
142
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
148
|
-
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
-
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
143
|
+
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
|
|
144
|
+
const balance = await this.state.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
150
145
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
151
146
|
const feeNum = parseInt(estimateFee.value);
|
|
152
147
|
const balanceNum = parseInt(balance.value);
|
|
153
148
|
const edNum = parseInt(existentialDeposit);
|
|
154
149
|
const transferNativeNum = parseInt(transferNative);
|
|
155
|
-
if (!
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (transferNativeNum + feeNum > balanceNum) {
|
|
159
|
-
if (!isTransferAll) {
|
|
150
|
+
if (!validationInput.skipFeeValidation) {
|
|
151
|
+
// TODO
|
|
152
|
+
if (!new BigN(balance.value).gt(0)) {
|
|
160
153
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
}
|
|
155
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
156
|
+
if (!isTransferAll) {
|
|
164
157
|
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
|
+
}
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
if (!isTransferAll) {
|
|
166
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
167
|
+
if (edAsWarning) {
|
|
168
|
+
validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
169
|
+
} else {
|
|
170
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
}
|
|
@@ -237,12 +235,21 @@ export default class TransactionService {
|
|
|
237
235
|
}
|
|
238
236
|
validatedTransaction.warnings = [];
|
|
239
237
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
240
|
-
await new Promise(resolve => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
238
|
+
await new Promise((resolve, reject) => {
|
|
239
|
+
// TODO
|
|
240
|
+
if (transaction.resolveOnDone) {
|
|
241
|
+
emitter.on('success', data => {
|
|
242
|
+
validatedTransaction.id = data.id;
|
|
243
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
244
|
+
resolve();
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
emitter.on('signed', data => {
|
|
248
|
+
validatedTransaction.id = data.id;
|
|
249
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
250
|
+
resolve();
|
|
251
|
+
});
|
|
252
|
+
}
|
|
246
253
|
emitter.on('error', data => {
|
|
247
254
|
if (data.errors.length > 0) {
|
|
248
255
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -308,7 +315,7 @@ export default class TransactionService {
|
|
|
308
315
|
}
|
|
309
316
|
getTransactionLink(id) {
|
|
310
317
|
const transaction = this.getTransaction(id);
|
|
311
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
318
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
312
319
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
313
320
|
}
|
|
314
321
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -336,7 +343,7 @@ export default class TransactionService {
|
|
|
336
343
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
337
344
|
startBlock: startBlock || 0
|
|
338
345
|
};
|
|
339
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
346
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
340
347
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
341
348
|
const baseNativeAmount = {
|
|
342
349
|
value: '0',
|
|
@@ -350,7 +357,7 @@ export default class TransactionService {
|
|
|
350
357
|
{
|
|
351
358
|
const inputData = parseTransactionData(transaction.data);
|
|
352
359
|
historyItem.to = inputData.to;
|
|
353
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
360
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
354
361
|
historyItem.amount = {
|
|
355
362
|
value: inputData.value || '0',
|
|
356
363
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -363,7 +370,7 @@ export default class TransactionService {
|
|
|
363
370
|
{
|
|
364
371
|
const inputData = parseTransactionData(transaction.data);
|
|
365
372
|
historyItem.to = inputData.to;
|
|
366
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
373
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
367
374
|
historyItem.amount = {
|
|
368
375
|
value: inputData.value || '0',
|
|
369
376
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -376,7 +383,7 @@ export default class TransactionService {
|
|
|
376
383
|
{
|
|
377
384
|
const inputData = parseTransactionData(transaction.data);
|
|
378
385
|
historyItem.to = inputData.to;
|
|
379
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
386
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
380
387
|
historyItem.amount = {
|
|
381
388
|
value: inputData.value || '0',
|
|
382
389
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -425,17 +432,29 @@ export default class TransactionService {
|
|
|
425
432
|
case ExtrinsicType.STAKING_UNBOND:
|
|
426
433
|
{
|
|
427
434
|
const data = parseTransactionData(transaction.data);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
435
|
+
if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
|
|
436
|
+
historyItem.amount = {
|
|
437
|
+
decimals: _getAssetDecimals(data.derivativeTokenInfo),
|
|
438
|
+
symbol: _getAssetSymbol(data.derivativeTokenInfo),
|
|
439
|
+
value: data.amount
|
|
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
|
+
}
|
|
433
452
|
}
|
|
434
453
|
break;
|
|
435
454
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
436
455
|
{
|
|
437
456
|
const data = parseTransactionData(transaction.data);
|
|
438
|
-
historyItem.to = data.
|
|
457
|
+
historyItem.to = data.address || '';
|
|
439
458
|
historyItem.amount = {
|
|
440
459
|
...baseNativeAmount,
|
|
441
460
|
value: data.amount || '0'
|
|
@@ -454,11 +473,21 @@ export default class TransactionService {
|
|
|
454
473
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
455
474
|
{
|
|
456
475
|
const data = parseTransactionData(transaction.data);
|
|
457
|
-
|
|
458
|
-
|
|
476
|
+
const slug = data.slug;
|
|
477
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
478
|
+
const amount = {
|
|
459
479
|
...baseNativeAmount,
|
|
460
480
|
value: data.unstakingInfo.claimable || '0'
|
|
461
481
|
};
|
|
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;
|
|
462
491
|
break;
|
|
463
492
|
}
|
|
464
493
|
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -479,6 +508,102 @@ export default class TransactionService {
|
|
|
479
508
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
480
509
|
break;
|
|
481
510
|
}
|
|
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
|
+
}
|
|
482
607
|
case ExtrinsicType.UNKNOWN:
|
|
483
608
|
break;
|
|
484
609
|
}
|
|
@@ -524,7 +649,7 @@ export default class TransactionService {
|
|
|
524
649
|
});
|
|
525
650
|
|
|
526
651
|
// Create Input History Transaction History
|
|
527
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
652
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
528
653
|
console.debug(`Transaction "${id}" is sent`);
|
|
529
654
|
}
|
|
530
655
|
onHasTransactionHash({
|
|
@@ -541,8 +666,12 @@ export default class TransactionService {
|
|
|
541
666
|
this.updateTransaction(id, updateData);
|
|
542
667
|
|
|
543
668
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
544
|
-
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
669
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
545
670
|
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
|
+
}
|
|
546
675
|
}
|
|
547
676
|
handlePostProcessing(id) {
|
|
548
677
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -551,15 +680,15 @@ export default class TransactionService {
|
|
|
551
680
|
const inputData = parseTransactionData(transaction.data);
|
|
552
681
|
try {
|
|
553
682
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
554
|
-
sender && this.
|
|
555
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
683
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
684
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
556
685
|
}).catch(console.error);
|
|
557
686
|
} catch (e) {
|
|
558
687
|
console.error(e);
|
|
559
688
|
}
|
|
560
689
|
try {
|
|
561
690
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
562
|
-
recipient && this.
|
|
691
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
563
692
|
...inputData.nftItem,
|
|
564
693
|
owner: recipient.address
|
|
565
694
|
}).catch(console.error);
|
|
@@ -567,7 +696,7 @@ export default class TransactionService {
|
|
|
567
696
|
console.error(e);
|
|
568
697
|
}
|
|
569
698
|
} 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)) {
|
|
570
|
-
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
699
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
571
700
|
}
|
|
572
701
|
}
|
|
573
702
|
onSuccess({
|
|
@@ -583,14 +712,14 @@ export default class TransactionService {
|
|
|
583
712
|
});
|
|
584
713
|
|
|
585
714
|
// Write success transaction history
|
|
586
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
715
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
587
716
|
extrinsicHash,
|
|
588
717
|
status: ExtrinsicStatus.SUCCESS,
|
|
589
718
|
blockNumber: blockNumber || 0,
|
|
590
719
|
blockHash: blockHash || ''
|
|
591
720
|
}).catch(console.error);
|
|
592
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
593
|
-
this.notificationService.notify({
|
|
721
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
722
|
+
this.state.notificationService.notify({
|
|
594
723
|
type: NotificationType.SUCCESS,
|
|
595
724
|
title: t('Transaction completed'),
|
|
596
725
|
message: t('Transaction {{info}} completed', {
|
|
@@ -603,7 +732,7 @@ export default class TransactionService {
|
|
|
603
732
|
},
|
|
604
733
|
notifyViaBrowser: true
|
|
605
734
|
});
|
|
606
|
-
this.eventService.emit('transaction.done', transaction);
|
|
735
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
607
736
|
}
|
|
608
737
|
onFailed({
|
|
609
738
|
blockHash,
|
|
@@ -622,14 +751,14 @@ export default class TransactionService {
|
|
|
622
751
|
});
|
|
623
752
|
|
|
624
753
|
// Write failed transaction history
|
|
625
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
754
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
626
755
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
627
756
|
status: nextStatus,
|
|
628
757
|
blockNumber: blockNumber || 0,
|
|
629
758
|
blockHash: blockHash || ''
|
|
630
759
|
}).catch(console.error);
|
|
631
|
-
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());
|
|
632
|
-
this.notificationService.notify({
|
|
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.state.chainService.getChainInfoMap());
|
|
761
|
+
this.state.notificationService.notify({
|
|
633
762
|
type: NotificationType.ERROR,
|
|
634
763
|
title: t('Transaction failed'),
|
|
635
764
|
message: t('Transaction {{info}} failed', {
|
|
@@ -643,11 +772,11 @@ export default class TransactionService {
|
|
|
643
772
|
notifyViaBrowser: true
|
|
644
773
|
});
|
|
645
774
|
}
|
|
646
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
775
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
647
776
|
}
|
|
648
777
|
generateHashPayload(chain, transaction) {
|
|
649
778
|
var _transaction$nonce;
|
|
650
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
779
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
651
780
|
const txObject = {
|
|
652
781
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
653
782
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -668,8 +797,8 @@ export default class TransactionService {
|
|
|
668
797
|
}) {
|
|
669
798
|
var _payload$nonce;
|
|
670
799
|
const payload = transaction;
|
|
671
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
672
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
800
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
801
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
673
802
|
const accountPair = keyring.getPair(address);
|
|
674
803
|
const account = {
|
|
675
804
|
address,
|
|
@@ -699,7 +828,7 @@ export default class TransactionService {
|
|
|
699
828
|
|
|
700
829
|
// Set unique nonce to avoid transaction errors
|
|
701
830
|
if (!payload.nonce) {
|
|
702
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
831
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
703
832
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
704
833
|
}
|
|
705
834
|
if (!payload.chainId) {
|
|
@@ -734,7 +863,7 @@ export default class TransactionService {
|
|
|
734
863
|
extrinsicHash: id
|
|
735
864
|
};
|
|
736
865
|
if (isInjected) {
|
|
737
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
866
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
738
867
|
isApproved,
|
|
739
868
|
payload
|
|
740
869
|
}) => {
|
|
@@ -742,7 +871,7 @@ export default class TransactionService {
|
|
|
742
871
|
if (!payload) {
|
|
743
872
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
744
873
|
}
|
|
745
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
874
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
746
875
|
|
|
747
876
|
// Emit signed event
|
|
748
877
|
emitter.emit('signed', eventData);
|
|
@@ -798,7 +927,7 @@ export default class TransactionService {
|
|
|
798
927
|
emitter.emit('error', eventData);
|
|
799
928
|
});
|
|
800
929
|
} else {
|
|
801
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
930
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
802
931
|
isApproved,
|
|
803
932
|
payload
|
|
804
933
|
}) => {
|
|
@@ -807,7 +936,7 @@ export default class TransactionService {
|
|
|
807
936
|
if (!payload) {
|
|
808
937
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
809
938
|
}
|
|
810
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
939
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
811
940
|
if (!isExternal) {
|
|
812
941
|
signedTransaction = payload;
|
|
813
942
|
} else {
|
|
@@ -874,7 +1003,7 @@ export default class TransactionService {
|
|
|
874
1003
|
transaction.signAsync(address, {
|
|
875
1004
|
signer: {
|
|
876
1005
|
signPayload: async payload => {
|
|
877
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1006
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
878
1007
|
return {
|
|
879
1008
|
id: new Date().getTime(),
|
|
880
1009
|
signature: signing.signature
|
|
@@ -886,7 +1015,7 @@ export default class TransactionService {
|
|
|
886
1015
|
emitter.emit('signed', eventData);
|
|
887
1016
|
|
|
888
1017
|
// Send transaction
|
|
889
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
1018
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
890
1019
|
eventData.nonce = rs.nonce.toNumber();
|
|
891
1020
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
892
1021
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -954,6 +1083,33 @@ export default class TransactionService {
|
|
|
954
1083
|
clearTimeout(timeout);
|
|
955
1084
|
});
|
|
956
1085
|
}
|
|
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
|
+
}
|
|
957
1113
|
resetWallet() {
|
|
958
1114
|
this.transactionSubject.next({});
|
|
959
1115
|
}
|
|
@@ -30,6 +30,8 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
|
|
|
30
30
|
errors?: SWTransaction['errors'];
|
|
31
31
|
edAsWarning?: boolean;
|
|
32
32
|
isTransferAll?: boolean;
|
|
33
|
+
resolveOnDone?: boolean;
|
|
34
|
+
skipFeeValidation?: boolean;
|
|
33
35
|
}
|
|
34
36
|
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
|
|
35
37
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unlock-dot';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface UnlockDotAdditionalData {
|
|
2
|
+
slug: string;
|
|
3
|
+
network: string;
|
|
4
|
+
extrinsicHash?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UnlockDotCheckMintRequest {
|
|
7
|
+
address: string;
|
|
8
|
+
additionalData: UnlockDotAdditionalData;
|
|
9
|
+
category: string;
|
|
10
|
+
campaignId: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UnlockDotCheckMintResponse {
|
|
13
|
+
requestId: number | null;
|
|
14
|
+
userId: number;
|
|
15
|
+
validUser: boolean;
|
|
16
|
+
validCampaign: boolean;
|
|
17
|
+
validCategory: boolean;
|
|
18
|
+
isWhiteList: boolean;
|
|
19
|
+
isOwner: boolean;
|
|
20
|
+
hasBalance: boolean;
|
|
21
|
+
notDuplicated: boolean;
|
|
22
|
+
inMintingTime: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface UnlockDotMintedData {
|
|
25
|
+
id: number;
|
|
26
|
+
campaignId: number;
|
|
27
|
+
collectionId: number;
|
|
28
|
+
userId: number;
|
|
29
|
+
address: string;
|
|
30
|
+
status: string;
|
|
31
|
+
extrinsicHash: string;
|
|
32
|
+
mintCategory: string;
|
|
33
|
+
mintDate: null;
|
|
34
|
+
rmrkNftId: string;
|
|
35
|
+
nftName: string;
|
|
36
|
+
nftImage: string;
|
|
37
|
+
recipient: string;
|
|
38
|
+
blockNumber: number;
|
|
39
|
+
additionalData: string;
|
|
40
|
+
}
|
|
41
|
+
export declare type UnlockDotTransactionNft = UnlockDotMintedData | undefined | Pick<UnlockDotMintedData, 'nftImage'>;
|
|
42
|
+
export interface UnlockDotFetchMintedRequest {
|
|
43
|
+
address: string;
|
|
44
|
+
}
|
|
45
|
+
export declare type UnlockDotFetchMintedResponse = UnlockDotMintedData[];
|
|
46
|
+
export interface UnlockDotMintSubmitRequest {
|
|
47
|
+
recipient: string;
|
|
48
|
+
requestId: number;
|
|
49
|
+
}
|
|
50
|
+
export declare type UnlockDotMintSubmitResponse = UnlockDotMintedData;
|
|
51
|
+
export interface UnlockDotCheckMintData {
|
|
52
|
+
address: string;
|
|
53
|
+
slug: string;
|
|
54
|
+
network: string;
|
|
55
|
+
extrinsicHash?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface UnlockDotSubmitMintData {
|
|
58
|
+
transactionId: string;
|
|
59
|
+
address: string;
|
|
60
|
+
slug: string;
|
|
61
|
+
network: string;
|
|
62
|
+
extrinsicHash: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RequestUnlockDotCheckCanMint {
|
|
65
|
+
address: string;
|
|
66
|
+
slug: string;
|
|
67
|
+
network: string;
|
|
68
|
+
}
|
|
69
|
+
export interface RequestUnlockDotSubscribeMintedData {
|
|
70
|
+
transactionId: string;
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|