@subwallet/extension-base 1.1.28-beta.1 → 1.1.30-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 +70 -93
- package/background/KoniTypes.js +14 -16
- package/background/errors/TransactionError.js +4 -9
- package/cjs/background/KoniTypes.js +17 -17
- package/cjs/background/errors/TransactionError.js +4 -9
- package/cjs/constants/index.js +3 -9
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +5 -6
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +0 -2
- package/cjs/koni/background/handlers/Extension.js +88 -326
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +18 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +16 -2
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +0 -4
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -47
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +74 -180
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -2
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +9 -11
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +6 -7
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.js +0 -2
- package/koni/background/handlers/Extension.d.ts +1 -14
- package/koni/background/handlers/Extension.js +50 -286
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -5
- package/koni/background/subscription.js +20 -90
- package/package.json +8 -311
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +11 -0
- package/services/chain-service/constants.js +14 -1
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +0 -8
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +0 -4
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -17
- package/services/storage-service/DatabaseService.js +0 -47
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +15 -4
- package/services/transaction-service/index.js +72 -178
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +1 -53
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -202
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -168
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -196
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -39
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -257
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -180
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -373
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -359
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -426
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -137
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -109
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -361
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -512
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -501
- package/cjs/services/earning-service/handlers/special.js +0 -387
- package/cjs/services/earning-service/service.js +0 -327
- package/cjs/services/earning-service/utils/index.js +0 -111
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -37
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -34
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -105
- package/services/earning-service/handlers/base.js +0 -195
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -22
- package/services/earning-service/handlers/lending/interlay.js +0 -160
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -188
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -8
- package/services/earning-service/handlers/liquid-staking/base.js +0 -31
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -44
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -246
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -172
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -36
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -363
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -350
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -18
- package/services/earning-service/handlers/native-staking/astar.js +0 -416
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -129
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/base.js +0 -101
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -353
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -503
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -33
- package/services/earning-service/handlers/nomination-pool/index.js +0 -492
- package/services/earning-service/handlers/special.d.ts +0 -56
- package/services/earning-service/handlers/special.js +0 -379
- package/services/earning-service/service.d.ts +0 -36
- package/services/earning-service/service.js +0 -320
- package/services/earning-service/utils/index.d.ts +0 -14
- package/services/earning-service/utils/index.js +0 -100
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -75
- package/types/yield/actions/join/step.js +0 -34
- package/types/yield/actions/join/submit.d.ts +0 -53
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -60
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -112
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -41
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -28
- package/types/yield/info/base.js +0 -28
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -190
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -33
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.parseLiquidStakingEvents = parseLiquidStakingEvents;
|
|
7
|
-
exports.parseLiquidStakingFastUnstakeEvents = parseLiquidStakingFastUnstakeEvents;
|
|
8
6
|
exports.parseTransferEventLogs = parseTransferEventLogs;
|
|
9
7
|
exports.parseXcmEventLogs = parseXcmEventLogs;
|
|
10
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
8
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
12
9
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
13
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -75,59 +72,4 @@ function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTokenInfo,
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
}
|
|
79
|
-
function parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, feePaidWithInputAsset, extrinsicType) {
|
|
80
|
-
if (feePaidWithInputAsset) {
|
|
81
|
-
historyItem.fee = {
|
|
82
|
-
value: '0',
|
|
83
|
-
// TODO
|
|
84
|
-
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
85
|
-
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
86
|
-
};
|
|
87
|
-
} else {
|
|
88
|
-
for (let index = 0; index < eventLogs.length; index++) {
|
|
89
|
-
const record = eventLogs[index];
|
|
90
|
-
const {
|
|
91
|
-
decimals: nativeDecimals,
|
|
92
|
-
symbol: nativeSymbol
|
|
93
|
-
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
94
|
-
const section = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
95
|
-
const eventMethod = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
96
|
-
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
97
|
-
var _record$event$data$9;
|
|
98
|
-
if ((_record$event$data$9 = record.event.data[2]) !== null && _record$event$data$9 !== void 0 && _record$event$data$9.toString()) {
|
|
99
|
-
var _record$event$data$10;
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
101
|
-
historyItem.fee = {
|
|
102
|
-
value: ((_record$event$data$10 = record.event.data[2]) === null || _record$event$data$10 === void 0 ? void 0 : _record$event$data$10.toString()) || '0',
|
|
103
|
-
symbol: nativeSymbol,
|
|
104
|
-
decimals: nativeDecimals
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType) {
|
|
112
|
-
for (let index = 0; index < eventLogs.length; index++) {
|
|
113
|
-
const record = eventLogs[index];
|
|
114
|
-
const {
|
|
115
|
-
decimals: nativeDecimals,
|
|
116
|
-
symbol: nativeSymbol
|
|
117
|
-
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
118
|
-
const section = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
119
|
-
const eventMethod = extrinsicType === _KoniTypes.ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
120
|
-
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
121
|
-
var _record$event$data$11;
|
|
122
|
-
if ((_record$event$data$11 = record.event.data[2]) !== null && _record$event$data$11 !== void 0 && _record$event$data$11.toString()) {
|
|
123
|
-
var _record$event$data$12;
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
125
|
-
historyItem.fee = {
|
|
126
|
-
value: ((_record$event$data$12 = record.event.data[2]) === null || _record$event$data$12 === void 0 ? void 0 : _record$event$data$12.toString()) || '0',
|
|
127
|
-
symbol: nativeSymbol,
|
|
128
|
-
decimals: nativeDecimals
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
75
|
}
|
|
@@ -40,7 +40,7 @@ const typeName = type => {
|
|
|
40
40
|
case _KoniTypes.ExtrinsicType.STAKING_BOND:
|
|
41
41
|
return 'Bond';
|
|
42
42
|
case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
|
|
43
|
-
return '
|
|
43
|
+
return 'Unbond';
|
|
44
44
|
case _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD:
|
|
45
45
|
return 'Claim reward';
|
|
46
46
|
case _KoniTypes.ExtrinsicType.STAKING_WITHDRAW:
|
|
@@ -55,8 +55,6 @@ const typeName = type => {
|
|
|
55
55
|
return 'Cancel compounding';
|
|
56
56
|
case _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW:
|
|
57
57
|
return 'Withdraw pool';
|
|
58
|
-
case _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL:
|
|
59
|
-
return 'Start earning';
|
|
60
58
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
61
59
|
default:
|
|
62
60
|
return 'unknown';
|
|
@@ -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");
|
|
13
14
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
15
|
+
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
16
|
+
var _constants4 = require("@subwallet/extension-base/services/transaction-service/constants");
|
|
16
17
|
var _eventParser = require("@subwallet/extension-base/services/transaction-service/event-parser");
|
|
17
18
|
var _helpers = require("@subwallet/extension-base/services/transaction-service/helpers");
|
|
18
19
|
var _utils2 = require("@subwallet/extension-base/services/transaction-service/utils");
|
|
19
20
|
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,7 +30,6 @@ 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");
|
|
34
33
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
35
34
|
// SPDX-License-Identifier: Apache-2.0
|
|
36
35
|
|
|
@@ -40,8 +39,14 @@ class TransactionService {
|
|
|
40
39
|
get transactions() {
|
|
41
40
|
return this.transactionSubject.getValue();
|
|
42
41
|
}
|
|
43
|
-
constructor(
|
|
44
|
-
this.
|
|
42
|
+
constructor(chainService, eventService, requestService, balanceService, historyService, notificationService, databaseService) {
|
|
43
|
+
this.chainService = chainService;
|
|
44
|
+
this.eventService = eventService;
|
|
45
|
+
this.requestService = requestService;
|
|
46
|
+
this.balanceService = balanceService;
|
|
47
|
+
this.historyService = historyService;
|
|
48
|
+
this.notificationService = notificationService;
|
|
49
|
+
this.databaseService = databaseService;
|
|
45
50
|
}
|
|
46
51
|
get allTransactions() {
|
|
47
52
|
return Object.values(this.transactions);
|
|
@@ -98,7 +103,7 @@ class TransactionService {
|
|
|
98
103
|
decimals: 0,
|
|
99
104
|
value: ''
|
|
100
105
|
};
|
|
101
|
-
const chainInfo = this.
|
|
106
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
102
107
|
if (!chainInfo) {
|
|
103
108
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Cannot find network')));
|
|
104
109
|
} else {
|
|
@@ -113,7 +118,7 @@ class TransactionService {
|
|
|
113
118
|
if ((0, _helpers.isSubstrateTransaction)(transaction)) {
|
|
114
119
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
115
120
|
} else {
|
|
116
|
-
const web3 = this.
|
|
121
|
+
const web3 = this.chainService.getEvmApi(chain);
|
|
117
122
|
if (!web3) {
|
|
118
123
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
119
124
|
} else {
|
|
@@ -147,35 +152,32 @@ class TransactionService {
|
|
|
147
152
|
|
|
148
153
|
// Balance
|
|
149
154
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
150
|
-
const nativeTokenInfo = this.
|
|
151
|
-
const balance = await this.
|
|
155
|
+
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
156
|
+
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
152
157
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
153
158
|
const feeNum = parseInt(estimateFee.value);
|
|
154
159
|
const balanceNum = parseInt(balance.value);
|
|
155
160
|
const edNum = parseInt(existentialDeposit);
|
|
156
161
|
const transferNativeNum = parseInt(transferNative);
|
|
157
|
-
if (!
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
if (!new _bignumber.default(balance.value).gt(0)) {
|
|
163
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
164
|
+
}
|
|
165
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
166
|
+
if (!isTransferAll) {
|
|
160
167
|
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
} else {
|
|
169
|
+
if ([..._constants2._TRANSFER_CHAIN_GROUP.acala, ..._constants2._TRANSFER_CHAIN_GROUP.genshiro, ..._constants2._TRANSFER_CHAIN_GROUP.bitcountry, ..._constants2._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
170
|
+
// Chain not have transfer all function
|
|
164
171
|
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
|
-
}
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
}
|
|
175
|
+
if (!isTransferAll) {
|
|
176
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
177
|
+
if (edAsWarning) {
|
|
178
|
+
validationResponse.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
179
|
+
} else {
|
|
180
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
}
|
|
@@ -196,7 +198,7 @@ class TransactionService {
|
|
|
196
198
|
updatedAt: new Date().getTime(),
|
|
197
199
|
errors: transaction.errors || [],
|
|
198
200
|
warnings: transaction.warnings || [],
|
|
199
|
-
url: transaction.url ||
|
|
201
|
+
url: transaction.url || _constants3.EXTENSION_REQUEST_URL,
|
|
200
202
|
status: _KoniTypes.ExtrinsicStatus.QUEUED,
|
|
201
203
|
isInternal,
|
|
202
204
|
id: transactionId,
|
|
@@ -242,21 +244,12 @@ class TransactionService {
|
|
|
242
244
|
}
|
|
243
245
|
validatedTransaction.warnings = [];
|
|
244
246
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
245
|
-
await new Promise(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
resolve();
|
|
252
|
-
});
|
|
253
|
-
} else {
|
|
254
|
-
emitter.on('signed', data => {
|
|
255
|
-
validatedTransaction.id = data.id;
|
|
256
|
-
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
257
|
-
resolve();
|
|
258
|
-
});
|
|
259
|
-
}
|
|
247
|
+
await new Promise(resolve => {
|
|
248
|
+
emitter.on('signed', data => {
|
|
249
|
+
validatedTransaction.id = data.id;
|
|
250
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
251
|
+
resolve();
|
|
252
|
+
});
|
|
260
253
|
emitter.on('error', data => {
|
|
261
254
|
if (data.errors.length > 0) {
|
|
262
255
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -322,7 +315,7 @@ class TransactionService {
|
|
|
322
315
|
}
|
|
323
316
|
getTransactionLink(id) {
|
|
324
317
|
const transaction = this.getTransaction(id);
|
|
325
|
-
const chainInfo = this.
|
|
318
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
326
319
|
return (0, _utils2.getExplorerLink)(chainInfo, transaction.extrinsicHash, 'tx');
|
|
327
320
|
}
|
|
328
321
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -350,7 +343,7 @@ class TransactionService {
|
|
|
350
343
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
351
344
|
startBlock: startBlock || 0
|
|
352
345
|
};
|
|
353
|
-
const chainInfo = this.
|
|
346
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
354
347
|
const nativeAsset = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
355
348
|
const baseNativeAmount = {
|
|
356
349
|
value: '0',
|
|
@@ -364,7 +357,7 @@ class TransactionService {
|
|
|
364
357
|
{
|
|
365
358
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
366
359
|
historyItem.to = inputData.to;
|
|
367
|
-
const sendingTokenInfo = this.
|
|
360
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
368
361
|
historyItem.amount = {
|
|
369
362
|
value: inputData.value || '0',
|
|
370
363
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -377,7 +370,7 @@ class TransactionService {
|
|
|
377
370
|
{
|
|
378
371
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
379
372
|
historyItem.to = inputData.to;
|
|
380
|
-
const sendingTokenInfo = this.
|
|
373
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
381
374
|
historyItem.amount = {
|
|
382
375
|
value: inputData.value || '0',
|
|
383
376
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -390,7 +383,7 @@ class TransactionService {
|
|
|
390
383
|
{
|
|
391
384
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
392
385
|
historyItem.to = inputData.to;
|
|
393
|
-
const sendingTokenInfo = this.
|
|
386
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
394
387
|
historyItem.amount = {
|
|
395
388
|
value: inputData.value || '0',
|
|
396
389
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -439,29 +432,17 @@ class TransactionService {
|
|
|
439
432
|
case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
|
|
440
433
|
{
|
|
441
434
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
}
|
|
435
|
+
historyItem.to = data.validatorAddress || '';
|
|
436
|
+
historyItem.amount = {
|
|
437
|
+
...baseNativeAmount,
|
|
438
|
+
value: data.amount || '0'
|
|
439
|
+
};
|
|
459
440
|
}
|
|
460
441
|
break;
|
|
461
442
|
case _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL:
|
|
462
443
|
{
|
|
463
444
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
464
|
-
historyItem.to = data.address || '';
|
|
445
|
+
historyItem.to = data.nominatorMetadata.address || '';
|
|
465
446
|
historyItem.amount = {
|
|
466
447
|
...baseNativeAmount,
|
|
467
448
|
value: data.amount || '0'
|
|
@@ -480,7 +461,7 @@ class TransactionService {
|
|
|
480
461
|
case _KoniTypes.ExtrinsicType.STAKING_WITHDRAW:
|
|
481
462
|
{
|
|
482
463
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
483
|
-
historyItem.to = data.
|
|
464
|
+
historyItem.to = data.validatorAddress || '';
|
|
484
465
|
historyItem.amount = {
|
|
485
466
|
...baseNativeAmount,
|
|
486
467
|
value: data.unstakingInfo.claimable || '0'
|
|
@@ -505,68 +486,6 @@ class TransactionService {
|
|
|
505
486
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
506
487
|
break;
|
|
507
488
|
}
|
|
508
|
-
case _KoniTypes.ExtrinsicType.MINT_STDOT:
|
|
509
|
-
case _KoniTypes.ExtrinsicType.MINT_QDOT:
|
|
510
|
-
case _KoniTypes.ExtrinsicType.MINT_LDOT:
|
|
511
|
-
case _KoniTypes.ExtrinsicType.MINT_SDOT:
|
|
512
|
-
|
|
513
|
-
// eslint-disable-next-line no-fallthrough
|
|
514
|
-
case _KoniTypes.ExtrinsicType.MINT_VDOT:
|
|
515
|
-
{
|
|
516
|
-
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
517
|
-
const params = data.data;
|
|
518
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
519
|
-
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
520
|
-
historyItem.amount = {
|
|
521
|
-
value: params.amount,
|
|
522
|
-
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
523
|
-
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
524
|
-
};
|
|
525
|
-
historyItem.additionalInfo = {
|
|
526
|
-
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
527
|
-
exchangeRate: params.exchangeRate
|
|
528
|
-
};
|
|
529
|
-
eventLogs && !(0, _utils._isChainEvmCompatible)(chainInfo) && (0, _eventParser.parseLiquidStakingEvents)(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
case _KoniTypes.ExtrinsicType.REDEEM_QDOT:
|
|
533
|
-
{
|
|
534
|
-
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
535
|
-
const yieldPoolInfo = data.yieldPoolInfo;
|
|
536
|
-
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
537
|
-
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
538
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
539
|
-
historyItem.amount = {
|
|
540
|
-
value: data.amount,
|
|
541
|
-
symbol: (0, _utils._getAssetSymbol)(inputTokenInfo),
|
|
542
|
-
decimals: (0, _utils._getAssetDecimals)(inputTokenInfo)
|
|
543
|
-
};
|
|
544
|
-
eventLogs && (0, _eventParser.parseLiquidStakingFastUnstakeEvents)(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
545
|
-
}
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
case _KoniTypes.ExtrinsicType.REDEEM_STDOT:
|
|
549
|
-
case _KoniTypes.ExtrinsicType.REDEEM_LDOT:
|
|
550
|
-
case _KoniTypes.ExtrinsicType.REDEEM_SDOT:
|
|
551
|
-
|
|
552
|
-
// eslint-disable-next-line no-fallthrough
|
|
553
|
-
case _KoniTypes.ExtrinsicType.REDEEM_VDOT:
|
|
554
|
-
{
|
|
555
|
-
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
556
|
-
const yieldPoolInfo = data.yieldPoolInfo;
|
|
557
|
-
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
558
|
-
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
559
|
-
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
560
|
-
const chainInfo = this.state.chainService.getChainInfoByKey(data.yieldPoolInfo.chain);
|
|
561
|
-
historyItem.amount = {
|
|
562
|
-
value: data.amount,
|
|
563
|
-
symbol: (0, _utils._getAssetSymbol)(derivativeTokenInfo),
|
|
564
|
-
decimals: (0, _utils._getAssetDecimals)(derivativeTokenInfo)
|
|
565
|
-
};
|
|
566
|
-
eventLogs && !(0, _utils._isChainEvmCompatible)(chainInfo) && (0, _eventParser.parseLiquidStakingFastUnstakeEvents)(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
567
|
-
}
|
|
568
|
-
break;
|
|
569
|
-
}
|
|
570
489
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
571
490
|
break;
|
|
572
491
|
}
|
|
@@ -614,7 +533,7 @@ class TransactionService {
|
|
|
614
533
|
});
|
|
615
534
|
|
|
616
535
|
// Create Input History Transaction History
|
|
617
|
-
this.
|
|
536
|
+
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
618
537
|
console.debug(`Transaction "${id}" is sent`);
|
|
619
538
|
}
|
|
620
539
|
onHasTransactionHash(_ref3) {
|
|
@@ -632,12 +551,8 @@ class TransactionService {
|
|
|
632
551
|
this.updateTransaction(id, updateData);
|
|
633
552
|
|
|
634
553
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
635
|
-
this.
|
|
554
|
+
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
636
555
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
637
|
-
const transaction = this.getTransaction(id);
|
|
638
|
-
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)) {
|
|
639
|
-
this.handlePostEarningTransaction(id);
|
|
640
|
-
}
|
|
641
556
|
}
|
|
642
557
|
handlePostProcessing(id) {
|
|
643
558
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -646,15 +561,15 @@ class TransactionService {
|
|
|
646
561
|
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
647
562
|
try {
|
|
648
563
|
const sender = _uiKeyring.default.getPair(inputData.senderAddress);
|
|
649
|
-
sender && this.
|
|
650
|
-
this.
|
|
564
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, _constants.ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
565
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
651
566
|
}).catch(console.error);
|
|
652
567
|
} catch (e) {
|
|
653
568
|
console.error(e);
|
|
654
569
|
}
|
|
655
570
|
try {
|
|
656
571
|
const recipient = _uiKeyring.default.getPair(inputData.recipientAddress);
|
|
657
|
-
recipient && this.
|
|
572
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
658
573
|
...inputData.nftItem,
|
|
659
574
|
owner: recipient.address
|
|
660
575
|
}).catch(console.error);
|
|
@@ -662,7 +577,7 @@ class TransactionService {
|
|
|
662
577
|
console.error(e);
|
|
663
578
|
}
|
|
664
579
|
} 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)) {
|
|
665
|
-
this.
|
|
580
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
666
581
|
}
|
|
667
582
|
}
|
|
668
583
|
onSuccess(_ref4) {
|
|
@@ -679,14 +594,14 @@ class TransactionService {
|
|
|
679
594
|
});
|
|
680
595
|
|
|
681
596
|
// Write success transaction history
|
|
682
|
-
this.
|
|
597
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
683
598
|
extrinsicHash,
|
|
684
599
|
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
685
600
|
blockNumber: blockNumber || 0,
|
|
686
601
|
blockHash: blockHash || ''
|
|
687
602
|
}).catch(console.error);
|
|
688
|
-
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.
|
|
689
|
-
this.
|
|
603
|
+
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
604
|
+
this.notificationService.notify({
|
|
690
605
|
type: _KoniTypes.NotificationType.SUCCESS,
|
|
691
606
|
title: (0, _i18next.t)('Transaction completed'),
|
|
692
607
|
message: (0, _i18next.t)('Transaction {{info}} completed', {
|
|
@@ -699,7 +614,7 @@ class TransactionService {
|
|
|
699
614
|
},
|
|
700
615
|
notifyViaBrowser: true
|
|
701
616
|
});
|
|
702
|
-
this.
|
|
617
|
+
this.eventService.emit('transaction.done', transaction);
|
|
703
618
|
}
|
|
704
619
|
onFailed(_ref5) {
|
|
705
620
|
let {
|
|
@@ -719,14 +634,14 @@ class TransactionService {
|
|
|
719
634
|
});
|
|
720
635
|
|
|
721
636
|
// Write failed transaction history
|
|
722
|
-
this.
|
|
637
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
723
638
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
724
639
|
status: nextStatus,
|
|
725
640
|
blockNumber: blockNumber || 0,
|
|
726
641
|
blockHash: blockHash || ''
|
|
727
642
|
}).catch(console.error);
|
|
728
|
-
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.
|
|
729
|
-
this.
|
|
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({
|
|
730
645
|
type: _KoniTypes.NotificationType.ERROR,
|
|
731
646
|
title: (0, _i18next.t)('Transaction failed'),
|
|
732
647
|
message: (0, _i18next.t)('Transaction {{info}} failed', {
|
|
@@ -740,11 +655,11 @@ class TransactionService {
|
|
|
740
655
|
notifyViaBrowser: true
|
|
741
656
|
});
|
|
742
657
|
}
|
|
743
|
-
this.
|
|
658
|
+
this.eventService.emit('transaction.failed', transaction);
|
|
744
659
|
}
|
|
745
660
|
generateHashPayload(chain, transaction) {
|
|
746
661
|
var _transaction$nonce;
|
|
747
|
-
const chainInfo = this.
|
|
662
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
748
663
|
const txObject = {
|
|
749
664
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
750
665
|
gasPrice: (0, _ethereumjsUtil.addHexPrefix)((0, _eth.anyNumberToBN)(transaction.gasPrice).toString(16)),
|
|
@@ -766,8 +681,8 @@ class TransactionService {
|
|
|
766
681
|
url
|
|
767
682
|
} = _ref6;
|
|
768
683
|
const payload = transaction;
|
|
769
|
-
const evmApi = this.
|
|
770
|
-
const chainInfo = this.
|
|
684
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
685
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
771
686
|
const accountPair = _uiKeyring.default.getPair(address);
|
|
772
687
|
const account = {
|
|
773
688
|
address,
|
|
@@ -797,7 +712,7 @@ class TransactionService {
|
|
|
797
712
|
|
|
798
713
|
// Set unique nonce to avoid transaction errors
|
|
799
714
|
if (!payload.nonce) {
|
|
800
|
-
const evmApi = this.
|
|
715
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
801
716
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
802
717
|
}
|
|
803
718
|
if (!payload.chainId) {
|
|
@@ -832,7 +747,7 @@ class TransactionService {
|
|
|
832
747
|
extrinsicHash: id
|
|
833
748
|
};
|
|
834
749
|
if (isInjected) {
|
|
835
|
-
this.
|
|
750
|
+
this.requestService.addConfirmation(id, url || _constants3.EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async _ref7 => {
|
|
836
751
|
let {
|
|
837
752
|
isApproved,
|
|
838
753
|
payload
|
|
@@ -841,7 +756,7 @@ class TransactionService {
|
|
|
841
756
|
if (!payload) {
|
|
842
757
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
843
758
|
}
|
|
844
|
-
const web3Api = this.
|
|
759
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
845
760
|
|
|
846
761
|
// Emit signed event
|
|
847
762
|
emitter.emit('signed', eventData);
|
|
@@ -897,7 +812,7 @@ class TransactionService {
|
|
|
897
812
|
emitter.emit('error', eventData);
|
|
898
813
|
});
|
|
899
814
|
} else {
|
|
900
|
-
this.
|
|
815
|
+
this.requestService.addConfirmation(id, url || _constants3.EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async _ref8 => {
|
|
901
816
|
let {
|
|
902
817
|
isApproved,
|
|
903
818
|
payload
|
|
@@ -907,7 +822,7 @@ class TransactionService {
|
|
|
907
822
|
if (!payload) {
|
|
908
823
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, (0, _i18next.t)('Failed to sign'));
|
|
909
824
|
}
|
|
910
|
-
const web3Api = this.
|
|
825
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
911
826
|
if (!isExternal) {
|
|
912
827
|
signedTransaction = payload;
|
|
913
828
|
} else {
|
|
@@ -975,7 +890,7 @@ class TransactionService {
|
|
|
975
890
|
transaction.signAsync(address, {
|
|
976
891
|
signer: {
|
|
977
892
|
signPayload: async payload => {
|
|
978
|
-
const signing = await this.
|
|
893
|
+
const signing = await this.requestService.signInternalTransaction(id, address, url || _constants3.EXTENSION_REQUEST_URL, payload);
|
|
979
894
|
return {
|
|
980
895
|
id: new Date().getTime(),
|
|
981
896
|
signature: signing.signature
|
|
@@ -987,7 +902,7 @@ class TransactionService {
|
|
|
987
902
|
emitter.emit('signed', eventData);
|
|
988
903
|
|
|
989
904
|
// Send transaction
|
|
990
|
-
const api = this.
|
|
905
|
+
const api = this.chainService.getSubstrateApi(chain);
|
|
991
906
|
eventData.nonce = rs.nonce.toNumber();
|
|
992
907
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
993
908
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -1051,7 +966,7 @@ class TransactionService {
|
|
|
1051
966
|
emitter.emit('error', eventData);
|
|
1052
967
|
clearTimeout(timeout);
|
|
1053
968
|
}
|
|
1054
|
-
},
|
|
969
|
+
}, _constants4.TRANSACTION_TIMEOUT);
|
|
1055
970
|
emitter.once('success', () => {
|
|
1056
971
|
clearTimeout(timeout);
|
|
1057
972
|
});
|
|
@@ -1059,27 +974,6 @@ class TransactionService {
|
|
|
1059
974
|
clearTimeout(timeout);
|
|
1060
975
|
});
|
|
1061
976
|
}
|
|
1062
|
-
handlePostEarningTransaction(id) {
|
|
1063
|
-
const transaction = this.getTransaction(id);
|
|
1064
|
-
const data = transaction.data;
|
|
1065
|
-
const slug = data.data.slug;
|
|
1066
|
-
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1067
|
-
if (poolHandler) {
|
|
1068
|
-
const type = poolHandler.type;
|
|
1069
|
-
if (type === _types.YieldPoolType.NATIVE_STAKING) {
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
} else {
|
|
1073
|
-
return;
|
|
1074
|
-
}
|
|
1075
|
-
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1076
|
-
transactionId: id,
|
|
1077
|
-
address: transaction.address,
|
|
1078
|
-
slug: slug,
|
|
1079
|
-
network: transaction.chain,
|
|
1080
|
-
extrinsicHash: transaction.extrinsicHash
|
|
1081
|
-
}).catch(console.error);
|
|
1082
|
-
}
|
|
1083
977
|
resetWallet() {
|
|
1084
978
|
this.transactionSubject.next({});
|
|
1085
979
|
}
|
package/cjs/types/index.js
CHANGED
|
@@ -24,48 +24,4 @@ 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
|
-
});
|
|
71
27
|
});
|