@subwallet/extension-base 1.3.17-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.
- package/background/KoniTypes.d.ts +7 -2
- package/cjs/constants/index.js +6 -3
- package/cjs/core/logic-validation/request.js +26 -19
- package/cjs/core/logic-validation/transfer.js +18 -17
- package/cjs/koni/api/contract-handler/evm/web3.js +3 -3
- package/cjs/koni/background/handlers/Extension.js +269 -123
- package/cjs/koni/background/handlers/State.js +1 -8
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -1
- package/cjs/services/balance-service/index.js +13 -0
- package/cjs/services/balance-service/transfer/smart-contract.js +47 -33
- package/cjs/services/balance-service/transfer/token.js +5 -4
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +14 -18
- package/cjs/services/balance-service/transfer/xcm/index.js +30 -61
- package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
- package/cjs/services/balance-service/transfer/xcm/posBridge.js +20 -21
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +7 -7
- package/cjs/services/balance-service/transfer/xcm/utils.js +2 -2
- package/cjs/services/chain-service/constants.js +3 -3
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
- package/cjs/services/earning-service/handlers/special.js +15 -4
- package/cjs/services/fee-service/interfaces.js +1 -0
- package/cjs/services/fee-service/service.js +111 -0
- package/cjs/services/fee-service/utils/index.js +99 -113
- package/cjs/services/storage-service/db-stores/Balance.js +3 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +21 -6
- package/cjs/services/swap-service/handler/asset-hub/router.js +1 -1
- package/cjs/services/swap-service/handler/asset-hub/utils.js +4 -4
- package/cjs/services/swap-service/handler/base-handler.js +2 -0
- package/cjs/services/swap-service/handler/chainflip-handler.js +25 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +20 -6
- package/cjs/services/swap-service/handler/simpleswap-handler.js +23 -3
- package/cjs/services/swap-service/index.js +8 -8
- package/cjs/services/transaction-service/index.js +23 -3
- package/cjs/types/balance/transfer.js +1 -0
- package/cjs/types/fee/base.js +1 -0
- package/cjs/types/fee/evm.js +16 -1
- package/cjs/types/fee/index.js +37 -4
- package/cjs/types/fee/option.js +1 -0
- package/cjs/types/fee/subscription.js +1 -0
- package/cjs/types/fee/substrate.js +1 -0
- package/cjs/types/fee/ton.js +1 -0
- package/cjs/utils/fee/combine.js +50 -0
- package/cjs/utils/fee/index.js +27 -0
- package/cjs/utils/fee/transfer.js +374 -0
- package/cjs/utils/index.js +12 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +1 -0
- package/core/logic-validation/request.js +17 -10
- package/core/logic-validation/transfer.d.ts +5 -5
- package/core/logic-validation/transfer.js +20 -19
- package/core/substrate/xcm-parser.d.ts +1 -1
- package/koni/api/contract-handler/evm/web3.js +3 -3
- package/koni/background/handlers/Extension.d.ts +3 -3
- package/koni/background/handlers/Extension.js +253 -107
- package/koni/background/handlers/State.js +1 -8
- package/package.json +55 -5
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +1 -1
- package/services/balance-service/index.d.ts +1 -0
- package/services/balance-service/index.js +13 -0
- package/services/balance-service/transfer/smart-contract.d.ts +24 -4
- package/services/balance-service/transfer/smart-contract.js +45 -33
- package/services/balance-service/transfer/token.js +6 -5
- package/services/balance-service/transfer/xcm/availBridge.d.ts +3 -2
- package/services/balance-service/transfer/xcm/availBridge.js +11 -15
- package/services/balance-service/transfer/xcm/index.d.ts +12 -11
- package/services/balance-service/transfer/xcm/index.js +29 -58
- package/services/balance-service/transfer/xcm/polygonBridge.d.ts +4 -3
- package/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
- package/services/balance-service/transfer/xcm/posBridge.d.ts +4 -3
- package/services/balance-service/transfer/xcm/posBridge.js +18 -19
- package/services/balance-service/transfer/xcm/snowBridge.d.ts +2 -1
- package/services/balance-service/transfer/xcm/snowBridge.js +7 -7
- package/services/balance-service/transfer/xcm/utils.js +2 -2
- package/services/chain-service/constants.js +3 -3
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
- package/services/earning-service/handlers/special.js +15 -4
- package/services/fee-service/interfaces.d.ts +5 -0
- package/services/fee-service/interfaces.js +1 -0
- package/services/fee-service/service.d.ts +4 -1
- package/services/fee-service/service.js +111 -0
- package/services/fee-service/utils/index.d.ts +8 -2
- package/services/fee-service/utils/index.js +92 -108
- package/services/storage-service/db-stores/Balance.d.ts +1 -0
- package/services/storage-service/db-stores/Balance.js +3 -0
- package/services/swap-service/handler/asset-hub/handler.d.ts +2 -1
- package/services/swap-service/handler/asset-hub/handler.js +21 -6
- package/services/swap-service/handler/asset-hub/router.js +2 -2
- package/services/swap-service/handler/asset-hub/utils.d.ts +1 -1
- package/services/swap-service/handler/asset-hub/utils.js +2 -2
- package/services/swap-service/handler/base-handler.d.ts +4 -1
- package/services/swap-service/handler/base-handler.js +2 -0
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
- package/services/swap-service/handler/chainflip-handler.js +24 -3
- package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
- package/services/swap-service/handler/hydradx-handler.js +19 -5
- package/services/swap-service/handler/simpleswap-handler.d.ts +2 -1
- package/services/swap-service/handler/simpleswap-handler.js +23 -3
- package/services/swap-service/index.js +8 -8
- package/services/transaction-service/index.js +23 -3
- package/services/transaction-service/types.d.ts +5 -4
- package/types/balance/transfer.d.ts +25 -0
- package/types/balance/transfer.js +1 -0
- package/types/fee/base.d.ts +8 -0
- package/types/fee/base.js +1 -0
- package/types/fee/evm.d.ts +46 -16
- package/types/fee/evm.js +10 -1
- package/types/fee/index.d.ts +4 -1
- package/types/fee/index.js +4 -1
- package/types/fee/option.d.ts +8 -0
- package/types/fee/option.js +1 -0
- package/types/fee/subscription.d.ts +12 -0
- package/types/fee/subscription.js +1 -0
- package/types/fee/substrate.d.ts +15 -0
- package/types/fee/substrate.js +1 -0
- package/types/fee/ton.d.ts +18 -0
- package/types/fee/ton.js +1 -0
- package/types/transaction/request.d.ts +13 -3
- package/utils/fee/combine.d.ts +12 -0
- package/utils/fee/combine.js +42 -0
- package/utils/fee/index.d.ts +2 -0
- package/utils/fee/index.js +5 -0
- package/utils/fee/transfer.d.ts +22 -0
- package/utils/fee/transfer.js +363 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
package/cjs/utils/index.js
CHANGED
|
@@ -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;
|
package/constants/index.d.ts
CHANGED
|
@@ -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';
|
package/constants/index.js
CHANGED
|
@@ -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
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
estimateGas =
|
|
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
|
-
|
|
343
|
-
|
|
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
|
-
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
355
|
+
estimateFee.value = new BigN(transaction.gasPrice.toString()).multipliedBy(gasLimit).toFixed(0);
|
|
362
356
|
} else {
|
|
363
|
-
if (
|
|
364
|
-
const maxFee =
|
|
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(
|
|
361
|
+
} else if (feeCombine.gasPrice) {
|
|
362
|
+
estimateFee.value = new BigN(feeCombine.gasPrice || 0).multipliedBy(gasLimit).toFixed(0);
|
|
369
363
|
}
|
|
370
364
|
}
|
|
371
|
-
estimateFee.tooHigh =
|
|
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"
|
|
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
|
-
|
|
43
|
-
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
43
|
+
...feeCombine
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -118,6 +118,8 @@ export default class KoniExtension {
|
|
|
118
118
|
private approveSpending;
|
|
119
119
|
private makeTransfer;
|
|
120
120
|
private makeCrossChainTransfer;
|
|
121
|
+
private getTokensCanPayFee;
|
|
122
|
+
private getAmountForPair;
|
|
121
123
|
private evmNftSubmitTransaction;
|
|
122
124
|
private upsertChain;
|
|
123
125
|
private removeCustomChain;
|
|
@@ -134,9 +136,7 @@ export default class KoniExtension {
|
|
|
134
136
|
private validateCustomAsset;
|
|
135
137
|
private getAddressTransferableBalance;
|
|
136
138
|
private getAddressTotalBalance;
|
|
137
|
-
private
|
|
138
|
-
private getXcmMaxTransferable;
|
|
139
|
-
private getNativeTokenMaxTransferable;
|
|
139
|
+
private subscribeMaxTransferable;
|
|
140
140
|
private subscribeAddressTransferableBalance;
|
|
141
141
|
private substrateNftSubmitTransaction;
|
|
142
142
|
private enableChains;
|