@subwallet/extension-base 1.1.31-1 → 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/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 +316 -3
- 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
|
@@ -10,14 +10,14 @@ var _TransactionError = require("@subwallet/extension-base/background/errors/Tra
|
|
|
10
10
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
11
|
var _TransactionWarning = require("@subwallet/extension-base/background/warnings/TransactionWarning");
|
|
12
12
|
var _constants = require("@subwallet/extension-base/constants");
|
|
13
|
-
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
14
13
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
14
|
+
var _constants2 = require("@subwallet/extension-base/services/request-service/constants");
|
|
15
|
+
var _constants3 = require("@subwallet/extension-base/services/transaction-service/constants");
|
|
17
16
|
var _eventParser = require("@subwallet/extension-base/services/transaction-service/event-parser");
|
|
18
17
|
var _helpers = require("@subwallet/extension-base/services/transaction-service/helpers");
|
|
19
18
|
var _utils2 = require("@subwallet/extension-base/services/transaction-service/utils");
|
|
20
19
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
20
|
+
var _types = require("@subwallet/extension-base/types");
|
|
21
21
|
var _utils3 = require("@subwallet/extension-base/utils");
|
|
22
22
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
23
23
|
var _mergeTransactionAndSignature = require("@subwallet/extension-base/utils/eth/mergeTransactionAndSignature");
|
|
@@ -30,6 +30,7 @@ var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
|
30
30
|
var _i18next = require("i18next");
|
|
31
31
|
var _rxjs = require("rxjs");
|
|
32
32
|
var _util = require("@polkadot/util");
|
|
33
|
+
var _constants4 = require("../chain-service/constants");
|
|
33
34
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
34
35
|
// SPDX-License-Identifier: Apache-2.0
|
|
35
36
|
|
|
@@ -39,14 +40,8 @@ class TransactionService {
|
|
|
39
40
|
get transactions() {
|
|
40
41
|
return this.transactionSubject.getValue();
|
|
41
42
|
}
|
|
42
|
-
constructor(
|
|
43
|
-
this.
|
|
44
|
-
this.eventService = eventService;
|
|
45
|
-
this.requestService = requestService;
|
|
46
|
-
this.balanceService = balanceService;
|
|
47
|
-
this.historyService = historyService;
|
|
48
|
-
this.notificationService = notificationService;
|
|
49
|
-
this.databaseService = databaseService;
|
|
43
|
+
constructor(state) {
|
|
44
|
+
this.state = state;
|
|
50
45
|
}
|
|
51
46
|
get allTransactions() {
|
|
52
47
|
return Object.values(this.transactions);
|
|
@@ -103,7 +98,7 @@ class TransactionService {
|
|
|
103
98
|
decimals: 0,
|
|
104
99
|
value: ''
|
|
105
100
|
};
|
|
106
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
101
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
107
102
|
if (!chainInfo) {
|
|
108
103
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Cannot find network')));
|
|
109
104
|
} else {
|
|
@@ -118,7 +113,7 @@ class TransactionService {
|
|
|
118
113
|
if ((0, _helpers.isSubstrateTransaction)(transaction)) {
|
|
119
114
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
120
115
|
} else {
|
|
121
|
-
const web3 = this.chainService.getEvmApi(chain);
|
|
116
|
+
const web3 = this.state.chainService.getEvmApi(chain);
|
|
122
117
|
if (!web3) {
|
|
123
118
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
124
119
|
} else {
|
|
@@ -152,32 +147,35 @@ class TransactionService {
|
|
|
152
147
|
|
|
153
148
|
// Balance
|
|
154
149
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
155
|
-
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
156
|
-
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
150
|
+
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
|
|
151
|
+
const balance = await this.state.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
157
152
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
158
153
|
const feeNum = parseInt(estimateFee.value);
|
|
159
154
|
const balanceNum = parseInt(balance.value);
|
|
160
155
|
const edNum = parseInt(existentialDeposit);
|
|
161
156
|
const transferNativeNum = parseInt(transferNative);
|
|
162
|
-
if (!
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (transferNativeNum + feeNum > balanceNum) {
|
|
166
|
-
if (!isTransferAll) {
|
|
157
|
+
if (!validationInput.skipFeeValidation) {
|
|
158
|
+
// TODO
|
|
159
|
+
if (!new _bignumber.default(balance.value).gt(0)) {
|
|
167
160
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
}
|
|
162
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
163
|
+
if (!isTransferAll) {
|
|
171
164
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
165
|
+
} else {
|
|
166
|
+
if ([..._constants4._TRANSFER_CHAIN_GROUP.acala, ..._constants4._TRANSFER_CHAIN_GROUP.genshiro, ..._constants4._TRANSFER_CHAIN_GROUP.bitcountry, ..._constants4._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
167
|
+
// Chain not have transfer all function
|
|
168
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
169
|
+
}
|
|
172
170
|
}
|
|
173
171
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
if (!isTransferAll) {
|
|
173
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
174
|
+
if (edAsWarning) {
|
|
175
|
+
validationResponse.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
176
|
+
} else {
|
|
177
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
178
|
+
}
|
|
181
179
|
}
|
|
182
180
|
}
|
|
183
181
|
}
|
|
@@ -198,7 +196,7 @@ class TransactionService {
|
|
|
198
196
|
updatedAt: new Date().getTime(),
|
|
199
197
|
errors: transaction.errors || [],
|
|
200
198
|
warnings: transaction.warnings || [],
|
|
201
|
-
url: transaction.url ||
|
|
199
|
+
url: transaction.url || _constants2.EXTENSION_REQUEST_URL,
|
|
202
200
|
status: _KoniTypes.ExtrinsicStatus.QUEUED,
|
|
203
201
|
isInternal,
|
|
204
202
|
id: transactionId,
|
|
@@ -244,12 +242,21 @@ class TransactionService {
|
|
|
244
242
|
}
|
|
245
243
|
validatedTransaction.warnings = [];
|
|
246
244
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
247
|
-
await new Promise(resolve => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
await new Promise((resolve, reject) => {
|
|
246
|
+
// TODO
|
|
247
|
+
if (transaction.resolveOnDone) {
|
|
248
|
+
emitter.on('success', data => {
|
|
249
|
+
validatedTransaction.id = data.id;
|
|
250
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
251
|
+
resolve();
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
emitter.on('signed', data => {
|
|
255
|
+
validatedTransaction.id = data.id;
|
|
256
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
257
|
+
resolve();
|
|
258
|
+
});
|
|
259
|
+
}
|
|
253
260
|
emitter.on('error', data => {
|
|
254
261
|
if (data.errors.length > 0) {
|
|
255
262
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -315,7 +322,7 @@ class TransactionService {
|
|
|
315
322
|
}
|
|
316
323
|
getTransactionLink(id) {
|
|
317
324
|
const transaction = this.getTransaction(id);
|
|
318
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
325
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
319
326
|
return (0, _utils2.getExplorerLink)(chainInfo, transaction.extrinsicHash, 'tx');
|
|
320
327
|
}
|
|
321
328
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -343,7 +350,7 @@ class TransactionService {
|
|
|
343
350
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
344
351
|
startBlock: startBlock || 0
|
|
345
352
|
};
|
|
346
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
353
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
347
354
|
const nativeAsset = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
348
355
|
const baseNativeAmount = {
|
|
349
356
|
value: '0',
|
|
@@ -357,7 +364,7 @@ class TransactionService {
|
|
|
357
364
|
{
|
|
358
365
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
359
366
|
historyItem.to = inputData.to;
|
|
360
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
367
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
361
368
|
historyItem.amount = {
|
|
362
369
|
value: inputData.value || '0',
|
|
363
370
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -370,7 +377,7 @@ class TransactionService {
|
|
|
370
377
|
{
|
|
371
378
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
372
379
|
historyItem.to = inputData.to;
|
|
373
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
380
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
374
381
|
historyItem.amount = {
|
|
375
382
|
value: inputData.value || '0',
|
|
376
383
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -383,7 +390,7 @@ class TransactionService {
|
|
|
383
390
|
{
|
|
384
391
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
385
392
|
historyItem.to = inputData.to;
|
|
386
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
393
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
387
394
|
historyItem.amount = {
|
|
388
395
|
value: inputData.value || '0',
|
|
389
396
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -432,17 +439,29 @@ class TransactionService {
|
|
|
432
439
|
case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
|
|
433
440
|
{
|
|
434
441
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
442
|
+
if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
|
|
443
|
+
historyItem.amount = {
|
|
444
|
+
decimals: (0, _utils._getAssetDecimals)(data.derivativeTokenInfo),
|
|
445
|
+
symbol: (0, _utils._getAssetSymbol)(data.derivativeTokenInfo),
|
|
446
|
+
value: data.amount
|
|
447
|
+
};
|
|
448
|
+
historyItem.additionalInfo = {
|
|
449
|
+
inputTokenSlug: data.inputTokenInfo.slug,
|
|
450
|
+
exchangeRate: data.exchangeRate
|
|
451
|
+
};
|
|
452
|
+
} else {
|
|
453
|
+
historyItem.to = data.validatorAddress || '';
|
|
454
|
+
historyItem.amount = {
|
|
455
|
+
...baseNativeAmount,
|
|
456
|
+
value: data.amount || '0'
|
|
457
|
+
};
|
|
458
|
+
}
|
|
440
459
|
}
|
|
441
460
|
break;
|
|
442
461
|
case _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL:
|
|
443
462
|
{
|
|
444
463
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
445
|
-
historyItem.to = data.
|
|
464
|
+
historyItem.to = data.address || '';
|
|
446
465
|
historyItem.amount = {
|
|
447
466
|
...baseNativeAmount,
|
|
448
467
|
value: data.amount || '0'
|
|
@@ -461,11 +480,21 @@ class TransactionService {
|
|
|
461
480
|
case _KoniTypes.ExtrinsicType.STAKING_WITHDRAW:
|
|
462
481
|
{
|
|
463
482
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
464
|
-
|
|
465
|
-
|
|
483
|
+
const slug = data.slug;
|
|
484
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
485
|
+
const amount = {
|
|
466
486
|
...baseNativeAmount,
|
|
467
487
|
value: data.unstakingInfo.claimable || '0'
|
|
468
488
|
};
|
|
489
|
+
if (poolHandler) {
|
|
490
|
+
const asset = this.state.getAssetBySlug(poolHandler.metadataInfo.inputAsset);
|
|
491
|
+
if (asset) {
|
|
492
|
+
amount.decimals = asset.decimals || 0;
|
|
493
|
+
amount.symbol = asset.symbol;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
historyItem.to = data.unstakingInfo.validatorAddress || '';
|
|
497
|
+
historyItem.amount = amount;
|
|
469
498
|
break;
|
|
470
499
|
}
|
|
471
500
|
case _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -486,6 +515,102 @@ class TransactionService {
|
|
|
486
515
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
487
516
|
break;
|
|
488
517
|
}
|
|
518
|
+
case _KoniTypes.ExtrinsicType.MINT_STDOT:
|
|
519
|
+
case _KoniTypes.ExtrinsicType.MINT_QDOT:
|
|
520
|
+
case _KoniTypes.ExtrinsicType.MINT_LDOT:
|
|
521
|
+
case _KoniTypes.ExtrinsicType.MINT_SDOT:
|
|
522
|
+
|
|
523
|
+
// eslint-disable-next-line no-fallthrough
|
|
524
|
+
case _KoniTypes.ExtrinsicType.MINT_VDOT:
|
|
525
|
+
{
|
|
526
|
+
const params = (0, _utils2.parseTransactionData)(transaction.data);
|
|
527
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
528
|
+
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
529
|
+
historyItem.amount = {
|
|
530
|
+
value: params.amount,
|
|
531
|
+
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
532
|
+
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
533
|
+
};
|
|
534
|
+
const additionalInfo = {
|
|
535
|
+
slug: params.slug,
|
|
536
|
+
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
537
|
+
exchangeRate: params.exchangeRate
|
|
538
|
+
};
|
|
539
|
+
historyItem.additionalInfo = additionalInfo;
|
|
540
|
+
eventLogs && !(0, _utils._isChainEvmCompatible)(chainInfo) && (0, _eventParser.parseLiquidStakingEvents)(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
case _KoniTypes.ExtrinsicType.REDEEM_QDOT:
|
|
544
|
+
{
|
|
545
|
+
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
546
|
+
const yieldPoolInfo = data.poolInfo;
|
|
547
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
548
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
549
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
550
|
+
historyItem.amount = {
|
|
551
|
+
value: data.amount,
|
|
552
|
+
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
553
|
+
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
554
|
+
};
|
|
555
|
+
eventLogs && (0, _eventParser.parseLiquidStakingFastUnstakeEvents)(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
556
|
+
}
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_QDOT:
|
|
560
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_VDOT:
|
|
561
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_LDOT:
|
|
562
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_SDOT:
|
|
563
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_STDOT:
|
|
564
|
+
case _KoniTypes.ExtrinsicType.REDEEM_STDOT:
|
|
565
|
+
case _KoniTypes.ExtrinsicType.REDEEM_LDOT:
|
|
566
|
+
case _KoniTypes.ExtrinsicType.REDEEM_SDOT:
|
|
567
|
+
|
|
568
|
+
// eslint-disable-next-line no-fallthrough
|
|
569
|
+
case _KoniTypes.ExtrinsicType.REDEEM_VDOT:
|
|
570
|
+
{
|
|
571
|
+
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
572
|
+
const yieldPoolInfo = data.poolInfo;
|
|
573
|
+
const minAmountPercents = this.state.earningService.getMinAmountPercent();
|
|
574
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
575
|
+
var _yieldPoolInfo$statis;
|
|
576
|
+
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
577
|
+
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
578
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
579
|
+
historyItem.amount = {
|
|
580
|
+
value: data.amount,
|
|
581
|
+
symbol: (0, _utils._getAssetSymbol)(derivativeTokenInfo),
|
|
582
|
+
decimals: (0, _utils._getAssetDecimals)(derivativeTokenInfo)
|
|
583
|
+
};
|
|
584
|
+
eventLogs && !(0, _utils._isChainEvmCompatible)(chainInfo) && (0, _eventParser.parseLiquidStakingFastUnstakeEvents)(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
585
|
+
const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
|
|
586
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
587
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
588
|
+
const additionalInfo = {
|
|
589
|
+
minAmountPercent,
|
|
590
|
+
symbol: inputTokenInfo.symbol,
|
|
591
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
592
|
+
exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
|
|
593
|
+
slug: yieldPoolInfo.slug,
|
|
594
|
+
type: yieldPoolInfo.type,
|
|
595
|
+
chain: yieldPoolInfo.chain,
|
|
596
|
+
group: yieldPoolInfo.group,
|
|
597
|
+
isFast: data.fastLeave
|
|
598
|
+
};
|
|
599
|
+
historyItem.additionalInfo = additionalInfo;
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
case _KoniTypes.ExtrinsicType.TOKEN_APPROVE:
|
|
604
|
+
{
|
|
605
|
+
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
606
|
+
const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
|
|
607
|
+
historyItem.amount = {
|
|
608
|
+
value: '0',
|
|
609
|
+
symbol: (0, _utils._getAssetSymbol)(inputAsset),
|
|
610
|
+
decimals: (0, _utils._getAssetDecimals)(inputAsset)
|
|
611
|
+
};
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
489
614
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
490
615
|
break;
|
|
491
616
|
}
|
|
@@ -533,7 +658,7 @@ class TransactionService {
|
|
|
533
658
|
});
|
|
534
659
|
|
|
535
660
|
// Create Input History Transaction History
|
|
536
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
661
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
537
662
|
console.debug(`Transaction "${id}" is sent`);
|
|
538
663
|
}
|
|
539
664
|
onHasTransactionHash(_ref3) {
|
|
@@ -551,8 +676,12 @@ class TransactionService {
|
|
|
551
676
|
this.updateTransaction(id, updateData);
|
|
552
677
|
|
|
553
678
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
554
|
-
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
679
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
555
680
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
681
|
+
const transaction = this.getTransaction(id);
|
|
682
|
+
if ([_KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
683
|
+
this.handlePostEarningTransaction(id);
|
|
684
|
+
}
|
|
556
685
|
}
|
|
557
686
|
handlePostProcessing(id) {
|
|
558
687
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -561,15 +690,15 @@ class TransactionService {
|
|
|
561
690
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
562
691
|
try {
|
|
563
692
|
const sender = _uiKeyring.default.getPair(inputData.senderAddress);
|
|
564
|
-
sender && this.
|
|
565
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
693
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, _constants.ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
694
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
566
695
|
}).catch(console.error);
|
|
567
696
|
} catch (e) {
|
|
568
697
|
console.error(e);
|
|
569
698
|
}
|
|
570
699
|
try {
|
|
571
700
|
const recipient = _uiKeyring.default.getPair(inputData.recipientAddress);
|
|
572
|
-
recipient && this.
|
|
701
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
573
702
|
...inputData.nftItem,
|
|
574
703
|
owner: recipient.address
|
|
575
704
|
}).catch(console.error);
|
|
@@ -577,7 +706,7 @@ class TransactionService {
|
|
|
577
706
|
console.error(e);
|
|
578
707
|
}
|
|
579
708
|
} else if ([_KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.STAKING_UNBOND, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
580
|
-
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
709
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
581
710
|
}
|
|
582
711
|
}
|
|
583
712
|
onSuccess(_ref4) {
|
|
@@ -594,14 +723,14 @@ class TransactionService {
|
|
|
594
723
|
});
|
|
595
724
|
|
|
596
725
|
// Write success transaction history
|
|
597
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
726
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
598
727
|
extrinsicHash,
|
|
599
728
|
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
600
729
|
blockNumber: blockNumber || 0,
|
|
601
730
|
blockHash: blockHash || ''
|
|
602
731
|
}).catch(console.error);
|
|
603
|
-
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
604
|
-
this.notificationService.notify({
|
|
732
|
+
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.state.chainService.getChainInfoMap());
|
|
733
|
+
this.state.notificationService.notify({
|
|
605
734
|
type: _KoniTypes.NotificationType.SUCCESS,
|
|
606
735
|
title: (0, _i18next.t)('Transaction completed'),
|
|
607
736
|
message: (0, _i18next.t)('Transaction {{info}} completed', {
|
|
@@ -614,7 +743,7 @@ class TransactionService {
|
|
|
614
743
|
},
|
|
615
744
|
notifyViaBrowser: true
|
|
616
745
|
});
|
|
617
|
-
this.eventService.emit('transaction.done', transaction);
|
|
746
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
618
747
|
}
|
|
619
748
|
onFailed(_ref5) {
|
|
620
749
|
let {
|
|
@@ -634,14 +763,14 @@ class TransactionService {
|
|
|
634
763
|
});
|
|
635
764
|
|
|
636
765
|
// Write failed transaction history
|
|
637
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
766
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
638
767
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
639
768
|
status: nextStatus,
|
|
640
769
|
blockNumber: blockNumber || 0,
|
|
641
770
|
blockHash: blockHash || ''
|
|
642
771
|
}).catch(console.error);
|
|
643
|
-
const info = (0, _util.isHex)(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
644
|
-
this.notificationService.notify({
|
|
772
|
+
const info = (0, _util.isHex)(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.state.chainService.getChainInfoMap());
|
|
773
|
+
this.state.notificationService.notify({
|
|
645
774
|
type: _KoniTypes.NotificationType.ERROR,
|
|
646
775
|
title: (0, _i18next.t)('Transaction failed'),
|
|
647
776
|
message: (0, _i18next.t)('Transaction {{info}} failed', {
|
|
@@ -655,11 +784,11 @@ class TransactionService {
|
|
|
655
784
|
notifyViaBrowser: true
|
|
656
785
|
});
|
|
657
786
|
}
|
|
658
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
787
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
659
788
|
}
|
|
660
789
|
generateHashPayload(chain, transaction) {
|
|
661
790
|
var _transaction$nonce;
|
|
662
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
791
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
663
792
|
const txObject = {
|
|
664
793
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
665
794
|
gasPrice: (0, _ethereumjsUtil.addHexPrefix)((0, _eth.anyNumberToBN)(transaction.gasPrice).toString(16)),
|
|
@@ -681,8 +810,8 @@ class TransactionService {
|
|
|
681
810
|
url
|
|
682
811
|
} = _ref6;
|
|
683
812
|
const payload = transaction;
|
|
684
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
685
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
813
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
814
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
686
815
|
const accountPair = _uiKeyring.default.getPair(address);
|
|
687
816
|
const account = {
|
|
688
817
|
address,
|
|
@@ -712,7 +841,7 @@ class TransactionService {
|
|
|
712
841
|
|
|
713
842
|
// Set unique nonce to avoid transaction errors
|
|
714
843
|
if (!payload.nonce) {
|
|
715
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
844
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
716
845
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
717
846
|
}
|
|
718
847
|
if (!payload.chainId) {
|
|
@@ -747,7 +876,7 @@ class TransactionService {
|
|
|
747
876
|
extrinsicHash: id
|
|
748
877
|
};
|
|
749
878
|
if (isInjected) {
|
|
750
|
-
this.requestService.addConfirmation(id, url ||
|
|
879
|
+
this.state.requestService.addConfirmation(id, url || _constants2.EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async _ref7 => {
|
|
751
880
|
let {
|
|
752
881
|
isApproved,
|
|
753
882
|
payload
|
|
@@ -756,7 +885,7 @@ class TransactionService {
|
|
|
756
885
|
if (!payload) {
|
|
757
886
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
758
887
|
}
|
|
759
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
888
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
760
889
|
|
|
761
890
|
// Emit signed event
|
|
762
891
|
emitter.emit('signed', eventData);
|
|
@@ -812,7 +941,7 @@ class TransactionService {
|
|
|
812
941
|
emitter.emit('error', eventData);
|
|
813
942
|
});
|
|
814
943
|
} else {
|
|
815
|
-
this.requestService.addConfirmation(id, url ||
|
|
944
|
+
this.state.requestService.addConfirmation(id, url || _constants2.EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async _ref8 => {
|
|
816
945
|
let {
|
|
817
946
|
isApproved,
|
|
818
947
|
payload
|
|
@@ -822,7 +951,7 @@ class TransactionService {
|
|
|
822
951
|
if (!payload) {
|
|
823
952
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, (0, _i18next.t)('Failed to sign'));
|
|
824
953
|
}
|
|
825
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
954
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
826
955
|
if (!isExternal) {
|
|
827
956
|
signedTransaction = payload;
|
|
828
957
|
} else {
|
|
@@ -890,7 +1019,7 @@ class TransactionService {
|
|
|
890
1019
|
transaction.signAsync(address, {
|
|
891
1020
|
signer: {
|
|
892
1021
|
signPayload: async payload => {
|
|
893
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url ||
|
|
1022
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || _constants2.EXTENSION_REQUEST_URL, payload);
|
|
894
1023
|
return {
|
|
895
1024
|
id: new Date().getTime(),
|
|
896
1025
|
signature: signing.signature
|
|
@@ -902,7 +1031,7 @@ class TransactionService {
|
|
|
902
1031
|
emitter.emit('signed', eventData);
|
|
903
1032
|
|
|
904
1033
|
// Send transaction
|
|
905
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
1034
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
906
1035
|
eventData.nonce = rs.nonce.toNumber();
|
|
907
1036
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
908
1037
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -966,7 +1095,7 @@ class TransactionService {
|
|
|
966
1095
|
emitter.emit('error', eventData);
|
|
967
1096
|
clearTimeout(timeout);
|
|
968
1097
|
}
|
|
969
|
-
},
|
|
1098
|
+
}, _constants3.TRANSACTION_TIMEOUT);
|
|
970
1099
|
emitter.once('success', () => {
|
|
971
1100
|
clearTimeout(timeout);
|
|
972
1101
|
});
|
|
@@ -974,6 +1103,33 @@ class TransactionService {
|
|
|
974
1103
|
clearTimeout(timeout);
|
|
975
1104
|
});
|
|
976
1105
|
}
|
|
1106
|
+
handlePostEarningTransaction(id) {
|
|
1107
|
+
const transaction = this.getTransaction(id);
|
|
1108
|
+
let slug;
|
|
1109
|
+
|
|
1110
|
+
// TODO
|
|
1111
|
+
if ('data' in transaction.data) {
|
|
1112
|
+
slug = transaction.data.data.slug;
|
|
1113
|
+
} else {
|
|
1114
|
+
slug = transaction.data.slug;
|
|
1115
|
+
}
|
|
1116
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1117
|
+
if (poolHandler) {
|
|
1118
|
+
const type = poolHandler.type;
|
|
1119
|
+
if (type === _types.YieldPoolType.NATIVE_STAKING) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1126
|
+
transactionId: id,
|
|
1127
|
+
address: transaction.address,
|
|
1128
|
+
slug: slug,
|
|
1129
|
+
network: transaction.chain,
|
|
1130
|
+
extrinsicHash: transaction.extrinsicHash
|
|
1131
|
+
}).catch(console.error);
|
|
1132
|
+
}
|
|
977
1133
|
resetWallet() {
|
|
978
1134
|
this.transactionSubject.next({});
|
|
979
1135
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _unlockDot = require("./unlock-dot");
|
|
7
|
+
Object.keys(_unlockDot).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _unlockDot[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _unlockDot[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/cjs/types/index.js
CHANGED
|
@@ -24,4 +24,48 @@ Object.keys(_buy).forEach(function (key) {
|
|
|
24
24
|
return _buy[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
});
|
|
28
|
+
var _campaigns = require("./campaigns");
|
|
29
|
+
Object.keys(_campaigns).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _campaigns[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _campaigns[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _ordinal = require("./ordinal");
|
|
40
|
+
Object.keys(_ordinal).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _ordinal[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _ordinal[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _transaction = require("./transaction");
|
|
51
|
+
Object.keys(_transaction).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _transaction[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _transaction[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _yield = require("./yield");
|
|
62
|
+
Object.keys(_yield).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _yield[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _yield[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
27
71
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|