@subwallet/extension-base 1.3.16-0 → 1.3.18-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.
Files changed (137) hide show
  1. package/background/KoniTypes.d.ts +12 -2
  2. package/cjs/constants/index.js +6 -3
  3. package/cjs/core/logic-validation/request.js +26 -19
  4. package/cjs/core/logic-validation/transfer.js +18 -17
  5. package/cjs/koni/api/contract-handler/evm/web3.js +3 -3
  6. package/cjs/koni/api/staking/bonding/utils.js +1 -1
  7. package/cjs/koni/background/handlers/Extension.js +289 -124
  8. package/cjs/koni/background/handlers/State.js +1 -8
  9. package/cjs/packageInfo.js +1 -1
  10. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +14 -2
  11. package/cjs/services/balance-service/index.js +13 -0
  12. package/cjs/services/balance-service/transfer/smart-contract.js +47 -33
  13. package/cjs/services/balance-service/transfer/token.js +5 -4
  14. package/cjs/services/balance-service/transfer/xcm/availBridge.js +14 -18
  15. package/cjs/services/balance-service/transfer/xcm/index.js +30 -61
  16. package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
  17. package/cjs/services/balance-service/transfer/xcm/posBridge.js +20 -21
  18. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +7 -7
  19. package/cjs/services/balance-service/transfer/xcm/utils.js +2 -2
  20. package/cjs/services/chain-service/constants.js +3 -3
  21. package/cjs/services/chain-service/index.js +22 -0
  22. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
  23. package/cjs/services/earning-service/handlers/native-staking/tao.js +121 -30
  24. package/cjs/services/earning-service/handlers/nomination-pool/index.js +1 -1
  25. package/cjs/services/earning-service/handlers/special.js +34 -14
  26. package/cjs/services/fee-service/interfaces.js +1 -0
  27. package/cjs/services/fee-service/service.js +111 -0
  28. package/cjs/services/fee-service/utils/index.js +99 -113
  29. package/cjs/services/storage-service/db-stores/Balance.js +3 -0
  30. package/cjs/services/swap-service/handler/asset-hub/handler.js +21 -6
  31. package/cjs/services/swap-service/handler/asset-hub/router.js +1 -1
  32. package/cjs/services/swap-service/handler/asset-hub/utils.js +4 -4
  33. package/cjs/services/swap-service/handler/base-handler.js +2 -0
  34. package/cjs/services/swap-service/handler/chainflip-handler.js +25 -4
  35. package/cjs/services/swap-service/handler/hydradx-handler.js +20 -6
  36. package/cjs/services/swap-service/handler/simpleswap-handler.js +23 -3
  37. package/cjs/services/swap-service/index.js +8 -8
  38. package/cjs/services/transaction-service/index.js +23 -3
  39. package/cjs/types/balance/transfer.js +1 -0
  40. package/cjs/types/fee/base.js +1 -0
  41. package/cjs/types/fee/evm.js +16 -1
  42. package/cjs/types/fee/index.js +37 -4
  43. package/cjs/types/fee/option.js +1 -0
  44. package/cjs/types/fee/subscription.js +1 -0
  45. package/cjs/types/fee/substrate.js +1 -0
  46. package/cjs/types/fee/ton.js +1 -0
  47. package/cjs/utils/fee/combine.js +50 -0
  48. package/cjs/utils/fee/index.js +27 -0
  49. package/cjs/utils/fee/transfer.js +374 -0
  50. package/cjs/utils/index.js +12 -0
  51. package/constants/index.d.ts +1 -0
  52. package/constants/index.js +1 -0
  53. package/core/logic-validation/request.js +17 -10
  54. package/core/logic-validation/transfer.d.ts +5 -5
  55. package/core/logic-validation/transfer.js +20 -19
  56. package/core/substrate/xcm-parser.d.ts +1 -1
  57. package/koni/api/contract-handler/evm/web3.js +3 -3
  58. package/koni/api/staking/bonding/utils.js +1 -1
  59. package/koni/background/handlers/Extension.d.ts +4 -3
  60. package/koni/background/handlers/Extension.js +273 -108
  61. package/koni/background/handlers/State.js +1 -8
  62. package/package.json +55 -5
  63. package/packageInfo.js +1 -1
  64. package/services/balance-service/helpers/subscribe/substrate/index.js +14 -2
  65. package/services/balance-service/index.d.ts +1 -0
  66. package/services/balance-service/index.js +13 -0
  67. package/services/balance-service/transfer/smart-contract.d.ts +24 -4
  68. package/services/balance-service/transfer/smart-contract.js +45 -33
  69. package/services/balance-service/transfer/token.js +6 -5
  70. package/services/balance-service/transfer/xcm/availBridge.d.ts +3 -2
  71. package/services/balance-service/transfer/xcm/availBridge.js +11 -15
  72. package/services/balance-service/transfer/xcm/index.d.ts +12 -11
  73. package/services/balance-service/transfer/xcm/index.js +29 -58
  74. package/services/balance-service/transfer/xcm/polygonBridge.d.ts +4 -3
  75. package/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
  76. package/services/balance-service/transfer/xcm/posBridge.d.ts +4 -3
  77. package/services/balance-service/transfer/xcm/posBridge.js +18 -19
  78. package/services/balance-service/transfer/xcm/snowBridge.d.ts +2 -1
  79. package/services/balance-service/transfer/xcm/snowBridge.js +7 -7
  80. package/services/balance-service/transfer/xcm/utils.js +2 -2
  81. package/services/chain-service/constants.js +3 -3
  82. package/services/chain-service/index.d.ts +6 -1
  83. package/services/chain-service/index.js +22 -0
  84. package/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
  85. package/services/earning-service/handlers/native-staking/tao.d.ts +7 -2
  86. package/services/earning-service/handlers/native-staking/tao.js +119 -29
  87. package/services/earning-service/handlers/nomination-pool/index.js +1 -1
  88. package/services/earning-service/handlers/special.js +36 -16
  89. package/services/fee-service/interfaces.d.ts +5 -0
  90. package/services/fee-service/interfaces.js +1 -0
  91. package/services/fee-service/service.d.ts +4 -1
  92. package/services/fee-service/service.js +111 -0
  93. package/services/fee-service/utils/index.d.ts +8 -2
  94. package/services/fee-service/utils/index.js +92 -108
  95. package/services/storage-service/db-stores/Balance.d.ts +1 -0
  96. package/services/storage-service/db-stores/Balance.js +3 -0
  97. package/services/swap-service/handler/asset-hub/handler.d.ts +2 -1
  98. package/services/swap-service/handler/asset-hub/handler.js +21 -6
  99. package/services/swap-service/handler/asset-hub/router.js +2 -2
  100. package/services/swap-service/handler/asset-hub/utils.d.ts +1 -1
  101. package/services/swap-service/handler/asset-hub/utils.js +2 -2
  102. package/services/swap-service/handler/base-handler.d.ts +4 -1
  103. package/services/swap-service/handler/base-handler.js +2 -0
  104. package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
  105. package/services/swap-service/handler/chainflip-handler.js +24 -3
  106. package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
  107. package/services/swap-service/handler/hydradx-handler.js +19 -5
  108. package/services/swap-service/handler/simpleswap-handler.d.ts +2 -1
  109. package/services/swap-service/handler/simpleswap-handler.js +23 -3
  110. package/services/swap-service/index.js +8 -8
  111. package/services/transaction-service/index.js +23 -3
  112. package/services/transaction-service/types.d.ts +5 -4
  113. package/types/balance/transfer.d.ts +25 -0
  114. package/types/balance/transfer.js +1 -0
  115. package/types/fee/base.d.ts +8 -0
  116. package/types/fee/base.js +1 -0
  117. package/types/fee/evm.d.ts +46 -16
  118. package/types/fee/evm.js +10 -1
  119. package/types/fee/index.d.ts +4 -1
  120. package/types/fee/index.js +4 -1
  121. package/types/fee/option.d.ts +8 -0
  122. package/types/fee/option.js +1 -0
  123. package/types/fee/subscription.d.ts +12 -0
  124. package/types/fee/subscription.js +1 -0
  125. package/types/fee/substrate.d.ts +15 -0
  126. package/types/fee/substrate.js +1 -0
  127. package/types/fee/ton.d.ts +18 -0
  128. package/types/fee/ton.js +1 -0
  129. package/types/transaction/request.d.ts +13 -3
  130. package/utils/fee/combine.d.ts +12 -0
  131. package/utils/fee/combine.js +42 -0
  132. package/utils/fee/index.d.ts +2 -0
  133. package/utils/fee/index.js +5 -0
  134. package/utils/fee/transfer.d.ts +22 -0
  135. package/utils/fee/transfer.js +363 -0
  136. package/utils/index.d.ts +1 -0
  137. package/utils/index.js +1 -0
@@ -0,0 +1,374 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.detectTransferTxType = exports.calculateXCMMaxTransferable = exports.calculateTransferMaxTransferable = exports.calculateMaxTransferable = void 0;
8
+ var _constants = require("@subwallet/extension-base/constants");
9
+ var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
10
+ var _smartContract = require("@subwallet/extension-base/services/balance-service/transfer/smart-contract");
11
+ var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
12
+ var _tonTransfer = require("@subwallet/extension-base/services/balance-service/transfer/ton-transfer");
13
+ var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
14
+ var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
15
+ var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
16
+ var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
17
+ var _utils = require("@subwallet/extension-base/services/chain-service/utils");
18
+ var _utils2 = require("@subwallet/extension-base/services/fee-service/utils");
19
+ var _helpers = require("@subwallet/extension-base/services/transaction-service/helpers");
20
+ var _utils3 = require("@subwallet/extension-base/utils");
21
+ var _keyring = require("@subwallet/keyring");
22
+ var _bignumber = _interopRequireDefault(require("bignumber.js"));
23
+ var _util = require("@polkadot/util");
24
+ var _utilCrypto = require("@polkadot/util-crypto");
25
+ var _combine = require("./combine");
26
+ // Copyright 2019-2022 @subwallet/extension-base
27
+ // SPDX-License-Identifier: Apache-2.0
28
+
29
+ const detectTransferTxType = (srcToken, srcChain, destChain) => {
30
+ const isXcmTransfer = srcChain.slug !== destChain.slug;
31
+ if (isXcmTransfer) {
32
+ const isAvailBridgeFromEvm = (0, _utils._isPureEvmChain)(srcChain) && (0, _availBridge.isAvailChainBridge)(destChain.slug);
33
+ const isSnowBridgeEvmTransfer = (0, _utils._isPureEvmChain)(srcChain) && (0, _xcmParser._isSnowBridgeXcm)(srcChain, destChain) && !isAvailBridgeFromEvm;
34
+ const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(srcChain.slug, destChain.slug);
35
+ const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(srcChain.slug, destChain.slug);
36
+ return isAvailBridgeFromEvm || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer ? 'evm' : 'substrate';
37
+ } else {
38
+ if ((0, _utils._isChainEvmCompatible)(srcChain) && (0, _utils._isTokenTransferredByEvm)(srcToken)) {
39
+ return 'evm';
40
+ } else if ((0, _utils._isChainTonCompatible)(srcChain) && (0, _utils._isTokenTransferredByTon)(srcToken)) {
41
+ return 'ton';
42
+ } else {
43
+ return 'substrate';
44
+ }
45
+ }
46
+ };
47
+ exports.detectTransferTxType = detectTransferTxType;
48
+ const calculateMaxTransferable = async (id, request, freeBalance, fee) => {
49
+ const {
50
+ destChain,
51
+ srcChain
52
+ } = request;
53
+ const isXcmTransfer = srcChain.slug !== destChain.slug;
54
+ let maxTransferableAmount;
55
+ if (isXcmTransfer) {
56
+ maxTransferableAmount = await calculateXCMMaxTransferable(id, request, freeBalance, fee);
57
+ } else {
58
+ maxTransferableAmount = await calculateTransferMaxTransferable(id, request, freeBalance, fee);
59
+ }
60
+ maxTransferableAmount.feePercentageSpecialCase = _utils2.FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE;
61
+ return maxTransferableAmount;
62
+ };
63
+ exports.calculateMaxTransferable = calculateMaxTransferable;
64
+ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) => {
65
+ const {
66
+ address,
67
+ destChain,
68
+ evmApi,
69
+ feeCustom,
70
+ feeOption,
71
+ isTransferLocalTokenAndPayThatTokenAsFee,
72
+ isTransferNativeTokenAndPayLocalTokenAsFee,
73
+ nativeToken,
74
+ srcChain,
75
+ srcToken,
76
+ substrateApi,
77
+ tonApi
78
+ } = request;
79
+ const feeChainType = fee.type;
80
+ let estimatedFee;
81
+ let feeOptions;
82
+ let maxTransferable;
83
+ let error;
84
+ const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
85
+ const substrateAddress = fakeAddress; // todo: move this
86
+ const evmAddress = (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(fakeAddress)); // todo: move this
87
+
88
+ const recipient = (0, _utils._isChainEvmCompatible)(destChain) ? evmAddress : substrateAddress;
89
+ try {
90
+ let transaction;
91
+ if ((0, _utilCrypto.isEthereumAddress)(address) && (0, _utilCrypto.isEthereumAddress)(recipient) && (0, _utils._isTokenTransferredByEvm)(srcToken)) {
92
+ // todo: refactor: merge getERC20TransactionObject & getEVMTransactionObject
93
+ // Estimate with EVM API
94
+ if ((0, _utils._isTokenEvmSmartContract)(srcToken) || (0, _utils._isLocalToken)(srcToken)) {
95
+ [transaction] = await (0, _smartContract.getERC20TransactionObject)({
96
+ assetAddress: (0, _utils._getContractAddressOfToken)(srcToken),
97
+ chain: srcChain.slug,
98
+ evmApi,
99
+ feeCustom,
100
+ feeInfo: fee,
101
+ feeOption,
102
+ from: address,
103
+ to: recipient,
104
+ transferAll: false,
105
+ value: '0'
106
+ });
107
+ } else {
108
+ [transaction] = await (0, _smartContract.getEVMTransactionObject)({
109
+ chain: srcChain.slug,
110
+ evmApi,
111
+ feeCustom,
112
+ feeInfo: fee,
113
+ feeOption,
114
+ from: address,
115
+ to: recipient,
116
+ transferAll: false,
117
+ value: '0'
118
+ });
119
+ }
120
+ } else if ((0, _keyring.isTonAddress)(address) && (0, _utils._isTokenTransferredByTon)(srcToken)) {
121
+ [transaction] = await (0, _tonTransfer.createTonTransaction)({
122
+ tokenInfo: srcToken,
123
+ from: address,
124
+ to: address,
125
+ networkKey: srcChain.slug,
126
+ value: '0',
127
+ transferAll: false,
128
+ // currently not used
129
+ tonApi
130
+ });
131
+ } else {
132
+ [transaction] = await (0, _token.createTransferExtrinsic)({
133
+ transferAll: false,
134
+ value: '0',
135
+ from: address,
136
+ networkKey: srcChain.slug,
137
+ tokenInfo: srcToken,
138
+ to: recipient,
139
+ substrateApi
140
+ });
141
+ }
142
+ if (feeChainType === 'evm') {
143
+ var _tx$gas;
144
+ // Calculate fee for evm transaction
145
+ const tx = transaction;
146
+ const gasLimit = ((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.toString()) || (await evmApi.api.eth.estimateGas(tx)).toString();
147
+ const _feeCustom = feeCustom;
148
+ const combineFee = (0, _combine.combineEthFee)(fee, feeOption, _feeCustom);
149
+ if (combineFee.maxFeePerGas) {
150
+ estimatedFee = new _bignumber.default(combineFee.maxFeePerGas).multipliedBy(gasLimit).toFixed(0);
151
+ } else {
152
+ estimatedFee = new _bignumber.default(combineFee.gasPrice || '0').multipliedBy(gasLimit).toFixed(0);
153
+ }
154
+ feeOptions = {
155
+ ...fee,
156
+ estimatedFee,
157
+ gasLimit: gasLimit.toString()
158
+ };
159
+ } else if (feeChainType === 'substrate') {
160
+ // Calculate fee for substrate transaction
161
+ try {
162
+ var _paymentInfo$partialF;
163
+ const mockTx = transaction;
164
+ const paymentInfo = await mockTx.paymentInfo(address);
165
+ estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
166
+ } catch (e) {
167
+ estimatedFee = '0';
168
+ }
169
+ const _feeCustom = feeCustom;
170
+ const tip = (0, _combine.combineSubstrateFee)(fee, feeOption, _feeCustom).tip;
171
+ estimatedFee = new _bignumber.default(estimatedFee).plus(tip).toFixed(0);
172
+ feeOptions = {
173
+ ...fee,
174
+ estimatedFee
175
+ };
176
+ } else {
177
+ if (transaction && (0, _helpers.isTonTransaction)(transaction)) {
178
+ estimatedFee = transaction.estimateFee;
179
+ feeOptions = {
180
+ ...fee,
181
+ estimatedFee: estimatedFee
182
+ };
183
+ } else {
184
+ // Not implemented yet
185
+ estimatedFee = '0';
186
+ feeOptions = {
187
+ ...fee,
188
+ estimatedFee: '0'
189
+ };
190
+ }
191
+ }
192
+ } catch (e) {
193
+ estimatedFee = '0';
194
+ if (fee.type === 'evm') {
195
+ feeOptions = {
196
+ ...fee,
197
+ estimatedFee,
198
+ gasLimit: '0'
199
+ };
200
+ } else {
201
+ feeOptions = {
202
+ ...fee,
203
+ estimatedFee
204
+ };
205
+ }
206
+ error = e.message || 'Unable to estimate fee';
207
+ console.warn('Unable to estimate fee', e);
208
+ }
209
+ if (isTransferLocalTokenAndPayThatTokenAsFee && feeChainType === 'substrate') {
210
+ const estimatedFeeNative = (BigInt(estimatedFee) * BigInt(_utils2.FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString();
211
+ const estimatedFeeLocal = await (0, _utils2.calculateToAmountByReservePool)(substrateApi.api, nativeToken, srcToken, estimatedFeeNative);
212
+ maxTransferable = (0, _bignumber.default)(freeBalance.value).minus(estimatedFeeLocal);
213
+ } else if (isTransferNativeTokenAndPayLocalTokenAsFee) {
214
+ maxTransferable = (0, _bignumber.default)(freeBalance.value);
215
+ } else {
216
+ if (!(0, _utils._isNativeToken)(srcToken)) {
217
+ maxTransferable = (0, _bignumber.default)(freeBalance.value);
218
+ } else {
219
+ maxTransferable = (0, _bignumber.default)(freeBalance.value).minus(new _bignumber.default(estimatedFee));
220
+ }
221
+ }
222
+ return {
223
+ maxTransferable: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0) || '0' : '0',
224
+ feeOptions: feeOptions,
225
+ feeType: feeChainType,
226
+ id: id,
227
+ error
228
+ };
229
+ };
230
+ exports.calculateTransferMaxTransferable = calculateTransferMaxTransferable;
231
+ const calculateXCMMaxTransferable = async (id, request, freeBalance, fee) => {
232
+ const {
233
+ address,
234
+ destChain,
235
+ destToken,
236
+ evmApi,
237
+ feeCustom,
238
+ feeOption,
239
+ isTransferLocalTokenAndPayThatTokenAsFee,
240
+ isTransferNativeTokenAndPayLocalTokenAsFee,
241
+ nativeToken,
242
+ srcChain,
243
+ srcToken,
244
+ substrateApi
245
+ } = request;
246
+ const feeChainType = fee.type;
247
+ let estimatedFee;
248
+ let feeOptions;
249
+ let maxTransferable;
250
+ let error;
251
+ const isAvailBridgeFromEvm = (0, _utils._isPureEvmChain)(srcChain) && (0, _availBridge.isAvailChainBridge)(destChain.slug);
252
+ const isAvailBridgeFromAvail = (0, _availBridge.isAvailChainBridge)(srcChain.slug) && (0, _utils._isPureEvmChain)(destChain);
253
+ const isSnowBridgeEvmTransfer = (0, _utils._isPureEvmChain)(srcChain) && (0, _xcmParser._isSnowBridgeXcm)(srcChain, destChain) && !isAvailBridgeFromEvm;
254
+ const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(srcChain.slug, destChain.slug);
255
+ const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(srcChain.slug, destChain.slug);
256
+ const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
257
+ const substrateAddress = fakeAddress; // todo: move this
258
+ const evmAddress = (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(fakeAddress)); // todo: move this
259
+
260
+ const recipient = (0, _utils._isChainEvmCompatible)(destChain) ? evmAddress : substrateAddress;
261
+ try {
262
+ if (!destToken) {
263
+ throw Error('Destination token is not available');
264
+ }
265
+ const params = {
266
+ destinationTokenInfo: destToken,
267
+ originTokenInfo: srcToken,
268
+ // If value is 0, substrate will throw error when estimating fee
269
+ sendingValue: feeChainType === 'substrate' ? '1000000000000000000' : '0',
270
+ sender: address,
271
+ recipient,
272
+ destinationChain: destChain,
273
+ originChain: srcChain,
274
+ substrateApi,
275
+ evmApi,
276
+ feeCustom,
277
+ feeOption,
278
+ feeInfo: fee
279
+ };
280
+ let funcCreateExtrinsic;
281
+ if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
282
+ funcCreateExtrinsic = _xcm.createPolygonBridgeExtrinsic;
283
+ } else if (isSnowBridgeEvmTransfer) {
284
+ funcCreateExtrinsic = _xcm.createSnowBridgeExtrinsic;
285
+ } else if (isAvailBridgeFromEvm) {
286
+ funcCreateExtrinsic = _xcm.createAvailBridgeTxFromEth;
287
+ } else if (isAvailBridgeFromAvail) {
288
+ funcCreateExtrinsic = _xcm.createAvailBridgeExtrinsicFromAvail;
289
+ } else {
290
+ funcCreateExtrinsic = _xcm.createXcmExtrinsic;
291
+ }
292
+ const extrinsic = await funcCreateExtrinsic(params);
293
+ if (feeChainType === 'evm') {
294
+ var _tx$gas2;
295
+ // Calculate fee for evm transaction
296
+ const tx = extrinsic;
297
+ const gasLimit = ((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.toString()) || (await evmApi.api.eth.estimateGas(tx)).toString();
298
+ const _feeCustom = feeCustom;
299
+ const combineFee = (0, _combine.combineEthFee)(fee, feeOption, _feeCustom);
300
+ if (combineFee.maxFeePerGas) {
301
+ estimatedFee = new _bignumber.default(combineFee.maxFeePerGas).multipliedBy(gasLimit).toFixed(0);
302
+ } else {
303
+ estimatedFee = new _bignumber.default(combineFee.gasPrice || '0').multipliedBy(gasLimit).toFixed(0);
304
+ }
305
+ feeOptions = {
306
+ ...fee,
307
+ estimatedFee,
308
+ gasLimit: gasLimit.toString()
309
+ };
310
+ } else if (feeChainType === 'substrate') {
311
+ // Calculate fee for substrate transaction
312
+ try {
313
+ var _paymentInfo$partialF2;
314
+ const paymentInfo = await extrinsic.paymentInfo(address);
315
+ estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
316
+ } catch (e) {
317
+ estimatedFee = '0';
318
+ }
319
+ const _feeCustom = feeCustom;
320
+ const tip = (0, _combine.combineSubstrateFee)(fee, feeOption, _feeCustom).tip;
321
+ estimatedFee = new _bignumber.default(estimatedFee).plus(tip).toFixed(0);
322
+ feeOptions = {
323
+ ...fee,
324
+ estimatedFee
325
+ };
326
+ } else {
327
+ // Not implemented yet
328
+ estimatedFee = '0';
329
+ feeOptions = {
330
+ ...fee,
331
+ estimatedFee: '0'
332
+ };
333
+ }
334
+ } catch (e) {
335
+ estimatedFee = '0';
336
+ if (fee.type === 'evm') {
337
+ feeOptions = {
338
+ ...fee,
339
+ estimatedFee,
340
+ gasLimit: '0'
341
+ };
342
+ } else {
343
+ feeOptions = {
344
+ ...fee,
345
+ estimatedFee
346
+ };
347
+ }
348
+ error = e.message || 'Unable to estimate fee';
349
+ console.warn('Unable to estimate fee', e);
350
+ }
351
+ if (!destToken) {
352
+ maxTransferable = _utils3.BN_ZERO;
353
+ } else if (isTransferLocalTokenAndPayThatTokenAsFee && feeChainType === 'substrate') {
354
+ const estimatedFeeNative = (BigInt(estimatedFee) * BigInt(_utils2.FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString();
355
+ const estimatedFeeLocal = await (0, _utils2.calculateToAmountByReservePool)(substrateApi.api, nativeToken, srcToken, estimatedFeeNative);
356
+ maxTransferable = (0, _bignumber.default)(freeBalance.value).minus(estimatedFeeLocal);
357
+ } else if (isTransferNativeTokenAndPayLocalTokenAsFee) {
358
+ maxTransferable = (0, _bignumber.default)(freeBalance.value);
359
+ } else {
360
+ if (!(0, _utils._isNativeToken)(srcToken)) {
361
+ maxTransferable = (0, _bignumber.default)(freeBalance.value);
362
+ } else {
363
+ maxTransferable = (0, _bignumber.default)(freeBalance.value).minus(new _bignumber.default(estimatedFee).multipliedBy(_constants.XCM_FEE_RATIO));
364
+ }
365
+ }
366
+ return {
367
+ maxTransferable: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0) || '0' : '0',
368
+ feeOptions: feeOptions,
369
+ feeType: feeChainType,
370
+ id: id,
371
+ error
372
+ };
373
+ };
374
+ exports.calculateXCMMaxTransferable = calculateXCMMaxTransferable;
@@ -174,6 +174,18 @@ Object.keys(_eth).forEach(function (key) {
174
174
  }
175
175
  });
176
176
  });
177
+ var _fee = require("./fee");
178
+ Object.keys(_fee).forEach(function (key) {
179
+ if (key === "default" || key === "__esModule") return;
180
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
181
+ if (key in exports && exports[key] === _fee[key]) return;
182
+ Object.defineProperty(exports, key, {
183
+ enumerable: true,
184
+ get: function () {
185
+ return _fee[key];
186
+ }
187
+ });
188
+ });
177
189
  var _fetchEvmChainInfo = require("./fetchEvmChainInfo");
178
190
  Object.keys(_fetchEvmChainInfo).forEach(function (key) {
179
191
  if (key === "default" || key === "__esModule") return;
@@ -35,6 +35,7 @@ export declare const NETWORK_MULTI_GAS_FEE: string[];
35
35
  export declare const ORDINAL_COLLECTION = "__Ordinal__";
36
36
  export declare const ORDINAL_METHODS: string[];
37
37
  export declare const PERMISSIONS_TO_REVOKE: string[];
38
+ export declare const ASSET_HUB_CHAIN_SLUGS: string[];
38
39
  export * from './blocked-actions';
39
40
  export * from './environment';
40
41
  export * from './signing';
@@ -37,6 +37,7 @@ export const NETWORK_MULTI_GAS_FEE = ['*'];
37
37
  export const ORDINAL_COLLECTION = '__Ordinal__';
38
38
  export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
39
39
  export const PERMISSIONS_TO_REVOKE = ['eth_accounts'];
40
+ export const ASSET_HUB_CHAIN_SLUGS = ['paseo_assethub', 'westend_assethub', 'rococo_assethub', 'statemine', 'statemint'];
40
41
  export * from "./blocked-actions.js";
41
42
  export * from "./environment.js";
42
43
  export * from "./signing.js";
@@ -5,10 +5,10 @@ import { typedSignatureHash } from '@metamask/eth-sig-util';
5
5
  import { EvmProviderError } from '@subwallet/extension-base/background/errors/EvmProviderError';
6
6
  import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
7
7
  import { EvmProviderErrorType } from '@subwallet/extension-base/background/KoniTypes';
8
- import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
9
8
  import { BasicTxErrorType } from '@subwallet/extension-base/types';
10
- import { BN_ZERO, createPromiseHandler, isSameAddress, stripUrl, wait } from '@subwallet/extension-base/utils';
9
+ import { BN_ZERO, combineEthFee, createPromiseHandler, isSameAddress, stripUrl, wait } from '@subwallet/extension-base/utils';
11
10
  import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
11
+ import { getId } from '@subwallet/extension-base/utils/getId';
12
12
  import { isSubstrateAddress } from '@subwallet/keyring';
13
13
  import { keyring } from '@subwallet/ui-keyring';
14
14
  import { getSdkError } from '@walletconnect/utils';
@@ -332,15 +332,22 @@ export async function validationEvmDataTransactionMiddleware(koni, url, payload)
332
332
  estimateGas = new BigN(transactionParams.gasPrice).multipliedBy(transaction.gas).toFixed(0);
333
333
  } else {
334
334
  try {
335
- const priority = await calculateGasFeeParams(evmApi, networkKey || '');
336
- if (priority.baseGasFee) {
337
- transaction.maxPriorityFeePerGas = priority.maxPriorityFeePerGas.toString();
338
- transaction.maxFeePerGas = priority.maxFeePerGas.toString();
339
- const maxFee = priority.maxFeePerGas;
340
- estimateGas = maxFee.multipliedBy(transaction.gas).toFixed(0);
335
+ const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
336
+ const id = getId();
337
+ const feeInfo = await koni.feeService.subscribeChainFee(id, transaction.chain || '', 'evm');
338
+ const feeCombine = combineEthFee(feeInfo);
339
+ if (transaction.maxFeePerGas) {
340
+ estimateGas = new BigN(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
341
+ } else if (transaction.gasPrice) {
342
+ estimateGas = new BigN(transaction.gasPrice.toString()).multipliedBy(gasLimit).toFixed(0);
341
343
  } else {
342
- transaction.gasPrice = priority.gasPrice;
343
- estimateGas = new BigN(priority.gasPrice).multipliedBy(transaction.gas).toFixed(0);
344
+ if (feeCombine.maxFeePerGas) {
345
+ const maxFee = new BigN(feeCombine.maxFeePerGas); // TODO: Need review
346
+
347
+ estimateGas = maxFee.multipliedBy(gasLimit).toFixed(0);
348
+ } else if (feeCombine.gasPrice) {
349
+ estimateGas = new BigN(feeCombine.gasPrice || 0).multipliedBy(gasLimit).toFixed(0);
350
+ }
344
351
  }
345
352
  } catch (e) {
346
353
  handleError(e.message);
@@ -3,18 +3,18 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
3
3
  import { _Address, AmountData, ExtrinsicType, FeeData } from '@subwallet/extension-base/background/KoniTypes';
4
4
  import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
5
5
  import { FrameSystemAccountInfo } from '@subwallet/extension-base/core/substrate/types';
6
- import { _EvmApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
6
+ import { _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
7
7
  import { OptionalSWTransaction, SWTransactionInput, SWTransactionResponse } from '@subwallet/extension-base/services/transaction-service/types';
8
+ import { EvmFeeInfo } from '@subwallet/extension-base/types';
8
9
  import { KeyringPair } from '@subwallet/keyring/types';
9
- import BigN from 'bignumber.js';
10
- export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _Address, to: _Address, value: string | undefined, transferAll: boolean | undefined): [TransactionError[], KeyringPair | undefined, BigN | undefined];
10
+ export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _Address, to: _Address, value: string | undefined, transferAll: boolean | undefined): TransactionError[];
11
11
  export declare function additionalValidateTransferForRecipient(sendingTokenInfo: _ChainAsset, nativeTokenInfo: _ChainAsset, extrinsicType: ExtrinsicType, receiverSendingTokenKeepAliveBalance: bigint, transferAmount: bigint, senderSendingTokenTransferable?: bigint, receiverSystemAccountInfo?: FrameSystemAccountInfo, isSendingTokenSufficient?: boolean): [TransactionWarning[], TransactionError[]];
12
- export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset | undefined, sender: _Address, sendingValue: string): [TransactionError[], KeyringPair | undefined, BigN | undefined];
12
+ export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset | undefined, sender: _Address, sendingValue: string): [TransactionError[], KeyringPair | undefined];
13
13
  export declare function additionalValidateXcmTransfer(originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset, sendingAmount: string, senderTransferable: string, receiverNativeBalance: string, destChainInfo: _ChainInfo, isSnowBridge?: boolean): [TransactionWarning | undefined, TransactionError | undefined];
14
14
  export declare function checkSupportForFeature(validationResponse: SWTransactionResponse, blockedFeaturesList: string[], chainInfo: _ChainInfo): void;
15
15
  export declare function checkSupportForAction(validationResponse: SWTransactionResponse, blockedActionsMap: Record<ExtrinsicType, string[]>): void;
16
16
  export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
17
- export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi): Promise<FeeData>;
17
+ export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi, substrateApi: _SubstrateApi, feeInfo: EvmFeeInfo, nativeTokenInfo: _ChainAsset, tokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined): Promise<FeeData>;
18
18
  export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>): void;
19
19
  export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData): void;
20
20
  export declare function checkTonAddressBounceableAndAccountNotActive(tonApi: _TonApi, validationResponse: SWTransactionResponse): Promise<void>;
@@ -9,10 +9,10 @@ import { _canAccountBeReaped, _isAccountActive } from '@subwallet/extension-base
9
9
  import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
10
10
  import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
11
11
  import { _getAssetDecimals, _getChainExistentialDeposit, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isNativeToken, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
12
- import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
12
+ import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
13
13
  import { isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
14
14
  import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types';
15
- import { balanceFormatter, formatNumber, pairToAccount } from '@subwallet/extension-base/utils';
15
+ import { balanceFormatter, combineEthFee, formatNumber, pairToAccount } from '@subwallet/extension-base/utils';
16
16
  import { isTonAddress } from '@subwallet/keyring';
17
17
  import { keyring } from '@subwallet/ui-keyring';
18
18
  import BigN from 'bignumber.js';
@@ -22,15 +22,10 @@ import { isEthereumAddress } from '@polkadot/util-crypto';
22
22
  // normal transfer
23
23
  export function validateTransferRequest(tokenInfo, from, to, value, transferAll) {
24
24
  const errors = [];
25
- const keypair = keyring.getPair(from);
26
- let transferValue;
27
25
  if (!transferAll) {
28
26
  if (value === undefined) {
29
27
  errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Transfer amount is required')));
30
28
  }
31
- if (value) {
32
- transferValue = new BigN(value);
33
- }
34
29
  }
35
30
  if (!tokenInfo) {
36
31
  errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found token from registry')));
@@ -41,7 +36,7 @@ export function validateTransferRequest(tokenInfo, from, to, value, transferAll)
41
36
  if (isTonAddress(from) && isTonAddress(to) && _isTokenTonSmartContract(tokenInfo) && _getContractAddressOfToken(tokenInfo).length === 0) {
42
37
  errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found TEP74 address for this token')));
43
38
  }
44
- return [errors, keypair, transferValue];
39
+ return errors;
45
40
  }
46
41
  export function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, transferAmount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient) {
47
42
  const sendingTokenMinAmount = BigInt(_getTokenMinAmount(sendingTokenInfo));
@@ -103,11 +98,10 @@ export function additionalValidateTransferForRecipient(sendingTokenInfo, nativeT
103
98
  export function validateXcmTransferRequest(destTokenInfo, sender, sendingValue) {
104
99
  const errors = [];
105
100
  const keypair = keyring.getPair(sender);
106
- const transferValue = new BigN(sendingValue);
107
101
  if (!destTokenInfo) {
108
102
  errors.push(new TransactionError(TransferTxErrorType.INVALID_TOKEN, t('Not found token from registry')));
109
103
  }
110
- return [errors, keypair, transferValue];
104
+ return [errors, keypair];
111
105
  }
112
106
  export function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, sendingAmount, senderTransferable, receiverNativeBalance, destChainInfo, isSnowBridge = false) {
113
107
  const destMinAmount = _getTokenMinAmount(destinationTokenInfo);
@@ -333,7 +327,7 @@ export function checkSupportForTransaction(validationResponse, transaction) {
333
327
  }
334
328
  }
335
329
  }
336
- export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi) {
330
+ export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, feeInfo, nativeTokenInfo, tokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee) {
337
331
  const estimateFee = {
338
332
  symbol: '',
339
333
  decimals: 0,
@@ -354,21 +348,21 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
354
348
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
355
349
  } else {
356
350
  const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
357
- const priority = await calculateGasFeeParams(evmApi, chainInfo.slug);
351
+ const feeCombine = combineEthFee(feeInfo, validationResponse.feeOption, validationResponse.feeCustom);
358
352
  if (transaction.maxFeePerGas) {
359
353
  estimateFee.value = new BigN(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
360
354
  } else if (transaction.gasPrice) {
361
- estimateFee.value = new BigN((transaction.gasPrice || 0).toString()).multipliedBy(gasLimit).toFixed(0);
355
+ estimateFee.value = new BigN(transaction.gasPrice.toString()).multipliedBy(gasLimit).toFixed(0);
362
356
  } else {
363
- if (priority.baseGasFee) {
364
- const maxFee = priority.maxFeePerGas; // TODO: Need review
357
+ if (feeCombine.maxFeePerGas) {
358
+ const maxFee = new BigN(feeCombine.maxFeePerGas); // TODO: Need review
365
359
 
366
360
  estimateFee.value = maxFee.multipliedBy(gasLimit).toFixed(0);
367
- } else {
368
- estimateFee.value = new BigN(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
361
+ } else if (feeCombine.gasPrice) {
362
+ estimateFee.value = new BigN(feeCombine.gasPrice || 0).multipliedBy(gasLimit).toFixed(0);
369
363
  }
370
364
  }
371
- estimateFee.tooHigh = priority.busyNetwork;
365
+ estimateFee.tooHigh = feeInfo.busyNetwork;
372
366
  }
373
367
  } catch (e) {
374
368
  const error = e;
@@ -377,6 +371,12 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
377
371
  }
378
372
  }
379
373
  }
374
+ if (tokenPayFeeInfo) {
375
+ const estimatedFeeAmount = isTransferLocalTokenAndPayThatTokenAsFee ? (BigInt(estimateFee.value) * BigInt(FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString() : estimateFee.value;
376
+ estimateFee.decimals = tokenPayFeeInfo.decimals || 0;
377
+ estimateFee.symbol = tokenPayFeeInfo.symbol;
378
+ estimateFee.value = await calculateToAmountByReservePool(substrateApi.api, nativeTokenInfo, tokenPayFeeInfo, estimatedFeeAmount);
379
+ }
380
380
  return estimateFee;
381
381
  }
382
382
  export function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
@@ -415,9 +415,10 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
415
415
  edAsWarning,
416
416
  extrinsicType,
417
417
  isTransferAll,
418
+ nonNativeTokenPayFeeSlug,
418
419
  skipFeeValidation
419
420
  } = transactionInput;
420
- if (skipFeeValidation) {
421
+ if (skipFeeValidation || nonNativeTokenPayFeeSlug) {
421
422
  return;
422
423
  }
423
424
  const bnFee = new BigN(validationResponse.estimateFee.value);
@@ -1,6 +1,6 @@
1
1
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { _Address } from '@subwallet/extension-base/background/KoniTypes';
3
- export declare function _getXcmDestWeight(originChainInfo: _ChainInfo): "Unlimited" | 5000000000;
3
+ export declare function _getXcmDestWeight(originChainInfo: _ChainInfo): 5000000000 | "Unlimited";
4
4
  export declare function _getXcmBeneficiary(destChainInfo: _ChainInfo, recipient: _Address, version: number): {
5
5
  [x: string]: {
6
6
  parents: number;
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { _ERC20_ABI } from '@subwallet/extension-base/koni/api/contract-handler/utils';
5
5
  import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
6
+ import { combineEthFee } from '@subwallet/extension-base/utils';
6
7
  export const getERC20Contract = (assetAddress, evmApi, options = {}) => {
7
8
  // @ts-ignore
8
9
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
@@ -22,7 +23,6 @@ export async function getERC20Allowance(spender, owner, contractAddress, evmApi)
22
23
  return await allowanceCall.call();
23
24
  }
24
25
  export async function getERC20SpendingApprovalTx(spender, owner, contractAddress, evmApi, amount = '115792089237316195423570985008687907853269984665640564039457584007913129639935') {
25
- var _priority$maxFeePerGa, _priority$maxPriority;
26
26
  const tokenContract = getERC20Contract(contractAddress, evmApi);
27
27
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
28
28
  const approveCall = tokenContract.methods.approve(spender, amount); // TODO: need test
@@ -33,13 +33,13 @@ export async function getERC20SpendingApprovalTx(spender, owner, contractAddress
33
33
  from: owner
34
34
  });
35
35
  const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
36
+ const feeCombine = combineEthFee(priority);
36
37
  return {
37
38
  from: owner,
38
39
  to: contractAddress,
39
40
  data: approveEncodedCall,
40
41
  gas: gasLimit,
41
42
  gasPrice: priority.gasPrice,
42
- maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
43
- maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
43
+ ...feeCombine
44
44
  };
45
45
  }
@@ -352,7 +352,7 @@ export function getAvgValidatorEraReward(supportedDays, eraRewardHistory) {
352
352
  export function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras, liveDay) {
353
353
  const maxSupportDay = Math.floor(maxSupportedEras / erasPerDay);
354
354
  if (liveDay && liveDay <= 30) {
355
- return Math.min(liveDay - 1, maxSupportDay);
355
+ return Math.min(Math.floor(liveDay - 1), maxSupportDay);
356
356
  }
357
357
  if (maxSupportDay > 30) {
358
358
  return 30;