@subwallet/extension-base 1.3.17-0 → 1.3.18-1
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 +23 -7
- 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 +3 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +26 -5
- package/cjs/services/swap-service/handler/hydradx-handler.js +23 -8
- package/cjs/services/swap-service/handler/simpleswap-handler.js +24 -4
- 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 +23 -7
- 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 +3 -1
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
- package/services/swap-service/handler/chainflip-handler.js +25 -4
- package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
- package/services/swap-service/handler/hydradx-handler.js +22 -7
- package/services/swap-service/handler/simpleswap-handler.d.ts +2 -1
- package/services/swap-service/handler/simpleswap-handler.js +24 -4
- 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
|
@@ -9,23 +9,22 @@ import { getSnowBridgeEvmTransfer } from '@subwallet/extension-base/services/bal
|
|
|
9
9
|
import { getExtrinsicByXcmPalletPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xcmPallet';
|
|
10
10
|
import { getExtrinsicByXtokensPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xTokens';
|
|
11
11
|
import { _XCM_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
12
|
-
import {
|
|
13
|
-
import BigN from 'bignumber.js';
|
|
14
|
-
import { u8aToHex } from '@polkadot/util';
|
|
15
|
-
import { addressToEvm } from '@polkadot/util-crypto';
|
|
12
|
+
import { _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
16
13
|
import { _createPosBridgeL1toL2Extrinsic, _createPosBridgeL2toL1Extrinsic } from "./posBridge.js";
|
|
14
|
+
// SnowBridge
|
|
17
15
|
export const createSnowBridgeExtrinsic = async ({
|
|
18
|
-
|
|
19
|
-
destinationTokenInfo,
|
|
16
|
+
destinationChain,
|
|
20
17
|
evmApi,
|
|
18
|
+
feeCustom,
|
|
19
|
+
feeInfo,
|
|
20
|
+
feeOption,
|
|
21
|
+
originChain,
|
|
21
22
|
originTokenInfo,
|
|
22
23
|
recipient,
|
|
23
24
|
sender,
|
|
24
25
|
sendingValue
|
|
25
26
|
}) => {
|
|
26
|
-
|
|
27
|
-
const destinationChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
28
|
-
if (!_isSnowBridgeXcm(originChainInfo, destinationChainInfo)) {
|
|
27
|
+
if (!_isSnowBridgeXcm(originChain, destinationChain)) {
|
|
29
28
|
throw new Error('This is not a valid SnowBridge transfer');
|
|
30
29
|
}
|
|
31
30
|
if (!evmApi) {
|
|
@@ -34,48 +33,47 @@ export const createSnowBridgeExtrinsic = async ({
|
|
|
34
33
|
if (!sender) {
|
|
35
34
|
throw Error('Sender is required');
|
|
36
35
|
}
|
|
37
|
-
return getSnowBridgeEvmTransfer(originTokenInfo,
|
|
36
|
+
return getSnowBridgeEvmTransfer(originTokenInfo, originChain, destinationChain, sender, recipient, sendingValue, evmApi, feeInfo, feeCustom, feeOption);
|
|
38
37
|
};
|
|
39
38
|
export const createXcmExtrinsic = async ({
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
destinationChain,
|
|
40
|
+
originChain,
|
|
42
41
|
originTokenInfo,
|
|
43
42
|
recipient,
|
|
44
43
|
sendingValue,
|
|
45
44
|
substrateApi
|
|
46
45
|
}) => {
|
|
47
|
-
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
48
|
-
const destinationChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
49
46
|
if (!substrateApi) {
|
|
50
47
|
throw Error('Substrate API is not available');
|
|
51
48
|
}
|
|
52
49
|
const chainApi = await substrateApi.isReady;
|
|
53
50
|
const api = chainApi.api;
|
|
54
|
-
const polkadotXcmSpecialCases = _XCM_CHAIN_GROUP.polkadotXcmSpecialCases.includes(
|
|
51
|
+
const polkadotXcmSpecialCases = _XCM_CHAIN_GROUP.polkadotXcmSpecialCases.includes(originChain.slug) && _isNativeToken(originTokenInfo);
|
|
55
52
|
if (_XCM_CHAIN_GROUP.polkadotXcm.includes(originTokenInfo.originChain) || polkadotXcmSpecialCases) {
|
|
56
|
-
return getExtrinsicByPolkadotXcmPallet(originTokenInfo,
|
|
53
|
+
return getExtrinsicByPolkadotXcmPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
57
54
|
}
|
|
58
55
|
if (_XCM_CHAIN_GROUP.xcmPallet.includes(originTokenInfo.originChain)) {
|
|
59
|
-
return getExtrinsicByXcmPalletPallet(originTokenInfo,
|
|
56
|
+
return getExtrinsicByXcmPalletPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
60
57
|
}
|
|
61
|
-
return getExtrinsicByXtokensPallet(originTokenInfo,
|
|
58
|
+
return getExtrinsicByXtokensPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
62
59
|
};
|
|
63
60
|
export const createAvailBridgeTxFromEth = ({
|
|
64
|
-
chainInfoMap,
|
|
65
61
|
evmApi,
|
|
66
|
-
|
|
62
|
+
feeCustom,
|
|
63
|
+
feeInfo,
|
|
64
|
+
feeOption,
|
|
65
|
+
originChain,
|
|
67
66
|
recipient,
|
|
68
67
|
sender,
|
|
69
68
|
sendingValue
|
|
70
69
|
}) => {
|
|
71
|
-
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
72
70
|
if (!evmApi) {
|
|
73
71
|
throw Error('Evm API is not available');
|
|
74
72
|
}
|
|
75
73
|
if (!sender) {
|
|
76
74
|
throw Error('Sender is required');
|
|
77
75
|
}
|
|
78
|
-
return getAvailBridgeTxFromEth(
|
|
76
|
+
return getAvailBridgeTxFromEth(originChain, sender, recipient, sendingValue, evmApi, feeInfo, feeCustom, feeOption);
|
|
79
77
|
};
|
|
80
78
|
export const createAvailBridgeExtrinsicFromAvail = async ({
|
|
81
79
|
recipient,
|
|
@@ -88,18 +86,19 @@ export const createAvailBridgeExtrinsicFromAvail = async ({
|
|
|
88
86
|
return await getAvailBridgeExtrinsicFromAvail(recipient, sendingValue, substrateApi);
|
|
89
87
|
};
|
|
90
88
|
export const createPolygonBridgeExtrinsic = async ({
|
|
91
|
-
|
|
92
|
-
destinationTokenInfo,
|
|
89
|
+
destinationChain,
|
|
93
90
|
evmApi,
|
|
91
|
+
feeCustom,
|
|
92
|
+
feeInfo,
|
|
93
|
+
feeOption,
|
|
94
|
+
originChain,
|
|
94
95
|
originTokenInfo,
|
|
95
96
|
recipient,
|
|
96
97
|
sender,
|
|
97
98
|
sendingValue
|
|
98
99
|
}) => {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const isPolygonBridgeXcm = _isPolygonBridgeXcm(originChainInfo, destinationChainInfo);
|
|
102
|
-
const isValidBridge = isPolygonBridgeXcm || _isPosBridgeXcm(originChainInfo, destinationChainInfo);
|
|
100
|
+
const isPolygonBridgeXcm = _isPolygonBridgeXcm(originChain, destinationChain);
|
|
101
|
+
const isValidBridge = isPolygonBridgeXcm || _isPosBridgeXcm(originChain, destinationChain);
|
|
103
102
|
if (!isValidBridge) {
|
|
104
103
|
throw new Error('This is not a valid PolygonBridge transfer');
|
|
105
104
|
}
|
|
@@ -109,35 +108,7 @@ export const createPolygonBridgeExtrinsic = async ({
|
|
|
109
108
|
if (!sender) {
|
|
110
109
|
throw Error('Sender is required');
|
|
111
110
|
}
|
|
112
|
-
const sourceChain =
|
|
111
|
+
const sourceChain = originChain.slug;
|
|
113
112
|
const createExtrinsic = isPolygonBridgeXcm ? sourceChain === 'polygonzkEvm_cardona' || sourceChain === 'polygonZkEvm' ? _createPolygonBridgeL2toL1Extrinsic : _createPolygonBridgeL1toL2Extrinsic : sourceChain === 'polygon_amoy' || sourceChain === 'polygon' ? _createPosBridgeL2toL1Extrinsic : _createPosBridgeL1toL2Extrinsic;
|
|
114
|
-
return createExtrinsic(originTokenInfo,
|
|
115
|
-
};
|
|
116
|
-
export const getXcmMockTxFee = async (substrateApi, chainInfoMap, originTokenInfo, destinationTokenInfo) => {
|
|
117
|
-
try {
|
|
118
|
-
var _paymentInfo$partialF;
|
|
119
|
-
const destChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
120
|
-
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
121
|
-
const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
|
|
122
|
-
const substrateAddress = fakeAddress; // todo: move this
|
|
123
|
-
const evmAddress = u8aToHex(addressToEvm(fakeAddress)); // todo: move this
|
|
124
|
-
|
|
125
|
-
// mock receiving account from sender
|
|
126
|
-
const sender = _isChainEvmCompatible(originChainInfo) ? evmAddress : substrateAddress;
|
|
127
|
-
const recipient = _isChainEvmCompatible(destChainInfo) ? evmAddress : substrateAddress;
|
|
128
|
-
const mockTx = await createXcmExtrinsic({
|
|
129
|
-
chainInfoMap,
|
|
130
|
-
destinationTokenInfo,
|
|
131
|
-
originTokenInfo,
|
|
132
|
-
sender,
|
|
133
|
-
recipient,
|
|
134
|
-
sendingValue: '1000000000000000000',
|
|
135
|
-
substrateApi
|
|
136
|
-
});
|
|
137
|
-
const paymentInfo = await mockTx.paymentInfo(fakeAddress);
|
|
138
|
-
return new BigN((paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0');
|
|
139
|
-
} catch (e) {
|
|
140
|
-
console.error('error mocking xcm tx fee', e);
|
|
141
|
-
return new BigN(0);
|
|
142
|
-
}
|
|
113
|
+
return createExtrinsic(originTokenInfo, originChain, sender, recipient, sendingValue, evmApi, feeInfo, feeCustom, feeOption);
|
|
143
114
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
3
|
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
4
|
+
import { EvmFeeInfo, FeeCustom, FeeInfo, FeeOption } from '@subwallet/extension-base/types';
|
|
4
5
|
import { TransactionConfig } from 'web3-core';
|
|
5
6
|
export interface gasStation {
|
|
6
7
|
safeLow: number;
|
|
@@ -15,8 +16,8 @@ export declare const POLYGON_GAS_INDEXER: {
|
|
|
15
16
|
MAINNET: string;
|
|
16
17
|
TESTNET: string;
|
|
17
18
|
};
|
|
18
|
-
export declare function _createPolygonBridgeL1toL2Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
19
|
-
export declare function _createPolygonBridgeL2toL1Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
20
|
-
export declare function getClaimPolygonBridge(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
19
|
+
export declare function _createPolygonBridgeL1toL2Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi, feeInfo: FeeInfo, feeCustom?: FeeCustom, feeOption?: FeeOption): Promise<TransactionConfig>;
|
|
20
|
+
export declare function _createPolygonBridgeL2toL1Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi, feeInfo: FeeInfo, feeCustom?: FeeCustom, feeOption?: FeeOption): Promise<TransactionConfig>;
|
|
21
|
+
export declare function getClaimPolygonBridge(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi, feeInfo: EvmFeeInfo): Promise<TransactionConfig>;
|
|
21
22
|
export declare function isClaimedPolygonBridge(chainSlug: string, counter: number, sourceNetwork: number, evmApi: _EvmApi): Promise<any>;
|
|
22
23
|
export declare function _isPolygonChainBridge(srcChain: string, destChain: string): boolean;
|
|
@@ -5,7 +5,7 @@ import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
|
5
5
|
import { getWeb3Contract } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
6
6
|
import { _POLYGON_BRIDGE_ABI, getPolygonBridgeContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
7
7
|
import { _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
9
9
|
export const POLYGON_PROOF_INDEXER = {
|
|
10
10
|
MAINNET: 'https://api-gateway.polygon.technology/api/v3/proof/mainnet/merkle-proof',
|
|
11
11
|
TESTNET: 'https://api-gateway.polygon.technology/api/v3/proof/testnet/merkle-proof'
|
|
@@ -14,8 +14,7 @@ export const POLYGON_GAS_INDEXER = {
|
|
|
14
14
|
MAINNET: 'https://gasstation.polygon.technology/zkevm',
|
|
15
15
|
TESTNET: 'https://gasstation.polygon.technology/zkevm/cardona'
|
|
16
16
|
};
|
|
17
|
-
async function createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, destinationNetwork, evmApi) {
|
|
18
|
-
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
17
|
+
async function createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, destinationNetwork, evmApi, _feeInfo, feeCustom, feeOption) {
|
|
19
18
|
const polygonBridgeContractAddress = getPolygonBridgeContract(originChainInfo.slug);
|
|
20
19
|
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
|
|
21
20
|
const tokenContract = _getContractAddressOfToken(tokenInfo) || '0x0000000000000000000000000000000000000000'; // FOR Ethereum: use null address
|
|
@@ -27,28 +26,27 @@ async function createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender
|
|
|
27
26
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
28
27
|
const transferCall = polygonBridgeContract.methods.bridgeAsset(destinationNetwork, recipientAddress, value, tokenContract, true, '0x');
|
|
29
28
|
const transferEncodedCall = transferCall.encodeABI();
|
|
30
|
-
const
|
|
29
|
+
const feeInfo = _feeInfo;
|
|
30
|
+
const feeCombine = combineEthFee(feeInfo, feeOption, feeCustom);
|
|
31
31
|
const transactionConfig = {
|
|
32
32
|
from: sender,
|
|
33
33
|
to: polygonBridgeContractAddress,
|
|
34
34
|
value: value,
|
|
35
35
|
data: transferEncodedCall,
|
|
36
|
-
|
|
37
|
-
maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
38
|
-
maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
36
|
+
...feeCombine
|
|
39
37
|
};
|
|
40
38
|
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
41
39
|
transactionConfig.gas = gasLimit.toString();
|
|
42
40
|
return transactionConfig;
|
|
43
41
|
}
|
|
44
|
-
export async function _createPolygonBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
45
|
-
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 1, evmApi);
|
|
42
|
+
export async function _createPolygonBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, feeInfo, feeCustom, feeOption) {
|
|
43
|
+
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 1, evmApi, feeInfo, feeCustom, feeOption);
|
|
46
44
|
}
|
|
47
|
-
export async function _createPolygonBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
48
|
-
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 0, evmApi);
|
|
45
|
+
export async function _createPolygonBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, feeInfo, feeCustom, feeOption) {
|
|
46
|
+
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 0, evmApi, feeInfo, feeCustom, feeOption);
|
|
49
47
|
}
|
|
50
|
-
export async function getClaimPolygonBridge(chainSlug, notification, evmApi) {
|
|
51
|
-
var _metadata$sourceNetwo, _metadata$counter
|
|
48
|
+
export async function getClaimPolygonBridge(chainSlug, notification, evmApi, feeInfo) {
|
|
49
|
+
var _metadata$sourceNetwo, _metadata$counter;
|
|
52
50
|
const polygonBridgeContractAddress = getPolygonBridgeContract(chainSlug);
|
|
53
51
|
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
|
|
54
52
|
const metadata = notification.metadata;
|
|
@@ -60,15 +58,13 @@ export async function getClaimPolygonBridge(chainSlug, notification, evmApi) {
|
|
|
60
58
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
61
59
|
const transferCall = polygonBridgeContract.methods.claimAsset(proof.merkle_proof, proof.rollup_merkle_proof, metadata.counter, proof.main_exit_root, proof.rollup_exit_root, metadata.originTokenNetwork, metadata.originTokenAddress, metadata.destinationNetwork, metadata.receiver, metadata.amounts[0], '0x');
|
|
62
60
|
const transferEncodedCall = transferCall.encodeABI();
|
|
63
|
-
const
|
|
61
|
+
const feeCombine = combineEthFee(feeInfo);
|
|
64
62
|
const transactionConfig = {
|
|
65
63
|
from: metadata.userAddress,
|
|
66
64
|
to: polygonBridgeContractAddress,
|
|
67
65
|
value: '0',
|
|
68
66
|
data: transferEncodedCall,
|
|
69
|
-
|
|
70
|
-
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
71
|
-
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
67
|
+
...feeCombine
|
|
72
68
|
};
|
|
73
69
|
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
74
70
|
transactionConfig.gas = gasLimit.toString();
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
3
|
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
4
|
+
import { EvmFeeInfo, FeeCustom, FeeInfo, FeeOption } from '@subwallet/extension-base/types';
|
|
4
5
|
import { TransactionConfig } from 'web3-core';
|
|
5
6
|
export declare const POS_EXIT_PAYLOAD_INDEXER: {
|
|
6
7
|
MAINNET: string;
|
|
7
8
|
TESTNET: string;
|
|
8
9
|
};
|
|
9
|
-
export declare function _createPosBridgeL1toL2Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
10
|
-
export declare function _createPosBridgeL2toL1Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
11
|
-
export declare function getClaimPosBridge(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
10
|
+
export declare function _createPosBridgeL1toL2Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi, _feeInfo: FeeInfo, feeCustom?: FeeCustom, feeOption?: FeeOption): Promise<TransactionConfig>;
|
|
11
|
+
export declare function _createPosBridgeL2toL1Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi, _feeInfo: FeeInfo, feeCustom?: FeeCustom, feeOption?: FeeOption): Promise<TransactionConfig>;
|
|
12
|
+
export declare function getClaimPosBridge(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi, feeInfo: EvmFeeInfo): Promise<TransactionConfig>;
|
|
12
13
|
export declare function isClaimedPosBridge(id: string, address: string, isTestnet: boolean): Promise<boolean>;
|
|
13
14
|
export declare function _isPosChainBridge(srcChain: string, destChain: string): boolean;
|
|
14
15
|
export declare function _isPosChainL2Bridge(srcChain: string, destChain: string): boolean;
|
|
@@ -4,59 +4,60 @@
|
|
|
4
4
|
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
5
|
import { getWeb3Contract } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
6
6
|
import { _POS_BRIDGE_ABI, _POS_BRIDGE_L2_ABI, getPosL1BridgeContract, getPosL2BridgeContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
7
|
-
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
8
7
|
import { fetchPolygonBridgeTransactions } from '@subwallet/extension-base/services/inapp-notification-service/utils';
|
|
9
8
|
import { BasicTxErrorType } from '@subwallet/extension-base/types';
|
|
9
|
+
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
10
10
|
export const POS_EXIT_PAYLOAD_INDEXER = {
|
|
11
11
|
MAINNET: 'https://proof-generator.polygon.technology/api/v1/matic/exit-payload',
|
|
12
12
|
TESTNET: 'https://proof-generator.polygon.technology/api/v1/amoy/exit-payload'
|
|
13
13
|
};
|
|
14
|
-
export async function _createPosBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
15
|
-
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
14
|
+
export async function _createPosBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
|
|
16
15
|
const posBridgeContractAddress = getPosL1BridgeContract(originChainInfo.slug);
|
|
17
16
|
const posBridgeContract = getWeb3Contract(posBridgeContractAddress, evmApi, _POS_BRIDGE_ABI);
|
|
17
|
+
const _feeCustom = feeCustom;
|
|
18
|
+
const feeInfo = _feeInfo;
|
|
19
|
+
const feeCombine = combineEthFee(feeInfo, feeOption, _feeCustom);
|
|
18
20
|
|
|
19
21
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
20
22
|
const transferCall = posBridgeContract.methods.depositEtherFor(recipientAddress);
|
|
21
23
|
const transferEncodedCall = transferCall.encodeABI();
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
// const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
|
|
26
|
+
|
|
23
27
|
const transactionConfig = {
|
|
24
28
|
from: sender,
|
|
25
29
|
to: posBridgeContractAddress,
|
|
26
30
|
value: value,
|
|
27
31
|
data: transferEncodedCall,
|
|
28
|
-
|
|
29
|
-
maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
30
|
-
maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
32
|
+
...feeCombine
|
|
31
33
|
};
|
|
32
34
|
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
33
35
|
transactionConfig.gas = gasLimit.toString();
|
|
34
36
|
return transactionConfig;
|
|
35
37
|
}
|
|
36
|
-
export async function _createPosBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
37
|
-
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
38
|
+
export async function _createPosBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
|
|
38
39
|
const posBridgeContractAddress = getPosL2BridgeContract(originChainInfo.slug);
|
|
39
40
|
const posBridgeContract = getWeb3Contract(posBridgeContractAddress, evmApi, _POS_BRIDGE_L2_ABI);
|
|
40
41
|
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
42
43
|
const transferCall = posBridgeContract.methods.withdraw(value);
|
|
43
44
|
const transferEncodedCall = transferCall.encodeABI();
|
|
44
|
-
const
|
|
45
|
+
const _feeCustom = feeCustom;
|
|
46
|
+
const feeInfo = _feeInfo;
|
|
47
|
+
const feeCombine = combineEthFee(feeInfo, feeOption, _feeCustom);
|
|
45
48
|
const transactionConfig = {
|
|
46
49
|
from: sender,
|
|
47
50
|
to: posBridgeContractAddress,
|
|
48
51
|
value: undefined,
|
|
49
52
|
data: transferEncodedCall,
|
|
50
|
-
|
|
51
|
-
maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
52
|
-
maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
53
|
+
...feeCombine
|
|
53
54
|
};
|
|
54
55
|
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
55
56
|
transactionConfig.gas = gasLimit.toString();
|
|
56
57
|
return transactionConfig;
|
|
57
58
|
}
|
|
58
|
-
export async function getClaimPosBridge(chainSlug, notification, evmApi) {
|
|
59
|
-
var _event$arguments, _event$arguments$, _event$arguments$$top
|
|
59
|
+
export async function getClaimPosBridge(chainSlug, notification, evmApi, feeInfo) {
|
|
60
|
+
var _event$arguments, _event$arguments$, _event$arguments$$top;
|
|
60
61
|
const posBridgeContractAddress = getPosL2BridgeContract(chainSlug);
|
|
61
62
|
const posBridgeContract = getWeb3Contract(posBridgeContractAddress, evmApi, _POS_BRIDGE_L2_ABI);
|
|
62
63
|
const metadata = notification.metadata;
|
|
@@ -83,15 +84,13 @@ export async function getClaimPosBridge(chainSlug, notification, evmApi) {
|
|
|
83
84
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
84
85
|
const transferCall = posClaimContract.methods.exit(inputData.result);
|
|
85
86
|
const transferEncodedCall = transferCall.encodeABI();
|
|
86
|
-
const
|
|
87
|
+
const feeCombine = combineEthFee(feeInfo);
|
|
87
88
|
const transactionConfig = {
|
|
88
89
|
from: metadata.userAddress,
|
|
89
90
|
to: posClaimContractAddress,
|
|
90
91
|
value: '0',
|
|
91
92
|
data: transferEncodedCall,
|
|
92
|
-
|
|
93
|
-
maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
|
|
94
|
-
maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString()
|
|
93
|
+
...feeCombine
|
|
95
94
|
};
|
|
96
95
|
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
97
96
|
transactionConfig.gas = gasLimit.toString();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
|
+
import { FeeCustom, FeeInfo, FeeOption } from '@subwallet/extension-base/types';
|
|
3
4
|
import { TransactionConfig } from 'web3-core';
|
|
4
|
-
export declare function getSnowBridgeEvmTransfer(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, destinationChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
5
|
+
export declare function getSnowBridgeEvmTransfer(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, destinationChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi, _feeInfo: FeeInfo, feeCustom?: FeeCustom, feeOption?: FeeOption): Promise<TransactionConfig>;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { getWeb3Contract } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
5
5
|
import { _SNOWBRIDGE_GATEWAY_ABI, getSnowBridgeGatewayContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
6
6
|
import { _getContractAddressOfToken, _getSubstrateParaId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
8
8
|
import { u8aToHex } from '@polkadot/util';
|
|
9
9
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
10
10
|
async function getSendFeeToken(contract, tokenContract, destChainParaId, destinationFee) {
|
|
@@ -14,8 +14,7 @@ async function getSendFeeToken(contract, tokenContract, destChainParaId, destina
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
15
15
|
return await quoteSendTokenFee.call();
|
|
16
16
|
}
|
|
17
|
-
export async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, destinationChainInfo, sender, recipientAddress, value, evmApi) {
|
|
18
|
-
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
17
|
+
export async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, destinationChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
|
|
19
18
|
const snowBridgeContractAddress = getSnowBridgeGatewayContract(originChainInfo.slug);
|
|
20
19
|
const snowBridgeContract = getWeb3Contract(snowBridgeContractAddress, evmApi, _SNOWBRIDGE_GATEWAY_ABI);
|
|
21
20
|
const tokenContract = _getContractAddressOfToken(tokenInfo);
|
|
@@ -30,15 +29,16 @@ export async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, desti
|
|
|
30
29
|
const transferCall = snowBridgeContract.methods.sendToken(tokenContract, destinationChainParaId, recipient, destinationFee, value);
|
|
31
30
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
32
31
|
const transferEncodedCall = transferCall.encodeABI();
|
|
33
|
-
const
|
|
32
|
+
const feeInfo = _feeInfo;
|
|
33
|
+
const _feeCustom = feeCustom;
|
|
34
|
+
const feeCombine = combineEthFee(feeInfo, feeOption, _feeCustom);
|
|
35
|
+
const sendTokenFee = await getSendFeeToken(snowBridgeContract, tokenContract, destinationChainParaId, destinationFee);
|
|
34
36
|
const transactionConfig = {
|
|
35
37
|
from: sender,
|
|
36
38
|
to: snowBridgeContractAddress,
|
|
37
39
|
value: sendTokenFee,
|
|
38
40
|
data: transferEncodedCall,
|
|
39
|
-
|
|
40
|
-
maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
41
|
-
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
41
|
+
...feeCombine
|
|
42
42
|
};
|
|
43
43
|
let gasLimit;
|
|
44
44
|
try {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
export const STABLE_XCM_VERSION = 3;
|
|
5
5
|
export function isUseTeleportProtocol(originChainInfo, destChainInfo, tokenSlug) {
|
|
6
|
-
const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug) || ['rococo'].includes(originChainInfo.slug) && ['rococo_assethub'].includes(destChainInfo.slug);
|
|
7
|
-
const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug) || ['rococo'].includes(destChainInfo.slug) && ['rococo_assethub'].includes(originChainInfo.slug);
|
|
6
|
+
const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug) || ['rococo'].includes(originChainInfo.slug) && ['rococo_assethub'].includes(destChainInfo.slug) || ['westend'].includes(originChainInfo.slug) && ['westend_assethub'].includes(destChainInfo.slug);
|
|
7
|
+
const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug) || ['rococo'].includes(destChainInfo.slug) && ['rococo_assethub'].includes(originChainInfo.slug) || ['westend'].includes(destChainInfo.slug) && ['westend_assethub'].includes(originChainInfo.slug);
|
|
8
8
|
const isXcmMythos = originChainInfo.slug === 'mythos' && destChainInfo.slug === 'statemint' && tokenSlug === 'mythos-NATIVE-MYTH' || originChainInfo.slug === 'statemint' && destChainInfo.slug === 'mythos' && tokenSlug === 'statemint-LOCAL-MYTH';
|
|
9
9
|
return relayChainToSystemChain || systemChainToRelayChain || isXcmMythos;
|
|
10
10
|
}
|
|
@@ -30,7 +30,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
30
30
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
31
31
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
32
32
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
|
|
33
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain'],
|
|
33
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub'],
|
|
34
34
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
35
35
|
// perhaps there are some runtime updates
|
|
36
36
|
centrifuge: ['centrifuge'],
|
|
@@ -266,9 +266,9 @@ export const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
|
266
266
|
// XCM------------------------------------------------------------------------------------------------------------------
|
|
267
267
|
|
|
268
268
|
export const _XCM_CHAIN_GROUP = {
|
|
269
|
-
polkadotXcm: ['statemine', 'statemint', 'equilibrium_parachain', 'rococo_assethub', 'mythos'],
|
|
269
|
+
polkadotXcm: ['statemine', 'statemint', 'equilibrium_parachain', 'rococo_assethub', 'mythos', 'westend_assethub'],
|
|
270
270
|
polkadotXcmSpecialCases: ['astar', 'shiden'],
|
|
271
|
-
xcmPallet: ['polkadot', 'kusama', 'rococo']
|
|
271
|
+
xcmPallet: ['polkadot', 'kusama', 'rococo', 'westend']
|
|
272
272
|
// default is xTokens pallet
|
|
273
273
|
};
|
|
274
274
|
|
|
@@ -7,6 +7,7 @@ import { getERC20Contract, getERC20SpendingApprovalTx } from '@subwallet/extensi
|
|
|
7
7
|
import { _getAssetDecimals, _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
8
|
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
9
9
|
import { BasicTxErrorType, EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
10
|
+
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
10
11
|
import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
|
|
11
12
|
import { ST_LIQUID_TOKEN_ABI } from "../../constants/index.js";
|
|
12
13
|
import BaseLiquidStakingPoolHandler from "./base.js";
|
|
@@ -271,7 +272,6 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
271
272
|
});
|
|
272
273
|
}
|
|
273
274
|
async handleSubmitStep(data, path) {
|
|
274
|
-
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
275
275
|
const {
|
|
276
276
|
address,
|
|
277
277
|
amount
|
|
@@ -291,14 +291,13 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
291
291
|
from: address
|
|
292
292
|
});
|
|
293
293
|
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
294
|
+
const feeCombine = combineEthFee(priority);
|
|
294
295
|
const transactionObject = {
|
|
295
296
|
from: address,
|
|
296
297
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
297
298
|
data: depositEncodedCall,
|
|
298
299
|
gas: gasLimit,
|
|
299
|
-
|
|
300
|
-
maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
301
|
-
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
300
|
+
...feeCombine
|
|
302
301
|
};
|
|
303
302
|
return {
|
|
304
303
|
txChain: this.chain,
|
|
@@ -318,7 +317,6 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
318
317
|
return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
319
318
|
}
|
|
320
319
|
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
321
|
-
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
322
320
|
const evmApi = this.evmApi;
|
|
323
321
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
324
322
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
@@ -334,14 +332,13 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
334
332
|
from: address
|
|
335
333
|
});
|
|
336
334
|
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
335
|
+
const feeCombine = combineEthFee(priority);
|
|
337
336
|
const transaction = {
|
|
338
337
|
from: address,
|
|
339
338
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
340
339
|
data: redeemEncodedCall,
|
|
341
340
|
gas: gasLimit,
|
|
342
|
-
|
|
343
|
-
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
344
|
-
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
341
|
+
...feeCombine
|
|
345
342
|
};
|
|
346
343
|
return [ExtrinsicType.UNSTAKE_STDOT, transaction];
|
|
347
344
|
}
|
|
@@ -351,7 +348,6 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
351
348
|
/* Other actions */
|
|
352
349
|
|
|
353
350
|
async handleYieldWithdraw(address, unstakingInfo) {
|
|
354
|
-
var _priority$maxFeePerGa3, _priority$maxPriority3;
|
|
355
351
|
const evmApi = this.evmApi;
|
|
356
352
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
357
353
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
@@ -367,14 +363,13 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
367
363
|
from: address
|
|
368
364
|
});
|
|
369
365
|
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
366
|
+
const feeCombine = combineEthFee(priority);
|
|
370
367
|
return {
|
|
371
368
|
from: address,
|
|
372
369
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
373
370
|
data: withdrawEncodedCall,
|
|
374
371
|
gas: gasLimit,
|
|
375
|
-
|
|
376
|
-
maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
|
|
377
|
-
maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString()
|
|
372
|
+
...feeCombine
|
|
378
373
|
}; // TODO: check tx history parsing
|
|
379
374
|
}
|
|
380
375
|
|
|
@@ -9,6 +9,7 @@ import { createXcmExtrinsic } from '@subwallet/extension-base/services/balance-s
|
|
|
9
9
|
import { _getAssetDecimals, _getAssetExistentialDeposit, _getAssetName, _getAssetSymbol, _getChainNativeTokenSlug } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
10
|
import { BasicTxErrorType, YieldStepType, YieldValidationStatus } from '@subwallet/extension-base/types';
|
|
11
11
|
import { createPromiseHandler, formatNumber } from '@subwallet/extension-base/utils';
|
|
12
|
+
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
12
13
|
import { t } from 'i18next';
|
|
13
14
|
import { BN, BN_TEN, BN_ZERO, noop } from '@polkadot/util';
|
|
14
15
|
import BasePoolHandler from "./base.js";
|
|
@@ -225,13 +226,18 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
225
226
|
type: YieldStepType.XCM
|
|
226
227
|
};
|
|
227
228
|
const xcmOriginSubstrateApi = await this.state.getSubstrateApi(altInputTokenInfo.originChain).isReady;
|
|
229
|
+
const id = getId();
|
|
230
|
+
const feeInfo = await this.state.feeService.subscribeChainFee(id, altChainInfo.slug, 'substrate');
|
|
228
231
|
const xcmTransfer = await createXcmExtrinsic({
|
|
232
|
+
sender: address,
|
|
229
233
|
originTokenInfo: altInputTokenInfo,
|
|
230
234
|
destinationTokenInfo: inputTokenInfo,
|
|
231
235
|
sendingValue: bnAmount.toString(),
|
|
232
236
|
recipient: address,
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
destinationChain: this.chainInfo,
|
|
238
|
+
originChain: altChainInfo,
|
|
239
|
+
substrateApi: xcmOriginSubstrateApi,
|
|
240
|
+
feeInfo
|
|
235
241
|
});
|
|
236
242
|
const _xcmFeeInfo = await xcmTransfer.paymentInfo(address);
|
|
237
243
|
const xcmFeeInfo = _xcmFeeInfo.toPrimitive();
|
|
@@ -428,13 +434,18 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
428
434
|
const bnXcmFee = new BN(xcmFee);
|
|
429
435
|
const bnAmount = new BN(amount);
|
|
430
436
|
const bnTotalAmount = bnAmount.sub(bnInputTokenBalance).add(bnXcmFee);
|
|
437
|
+
const id = getId();
|
|
438
|
+
const feeInfo = await this.state.feeService.subscribeChainFee(id, originChainInfo.slug, 'substrate');
|
|
431
439
|
const extrinsic = await createXcmExtrinsic({
|
|
432
|
-
chainInfoMap: this.state.getChainInfoMap(),
|
|
433
440
|
destinationTokenInfo,
|
|
434
441
|
originTokenInfo,
|
|
435
442
|
recipient: address,
|
|
436
443
|
sendingValue: bnTotalAmount.toString(),
|
|
437
|
-
substrateApi
|
|
444
|
+
substrateApi,
|
|
445
|
+
sender: address,
|
|
446
|
+
originChain: originChainInfo,
|
|
447
|
+
destinationChain: this.chainInfo,
|
|
448
|
+
feeInfo
|
|
438
449
|
});
|
|
439
450
|
const xcmData = {
|
|
440
451
|
originNetworkKey: originChainInfo.slug,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
|
-
import { EvmFeeInfo } from '@subwallet/extension-base/types';
|
|
2
|
+
import { EvmFeeInfo, FeeChainType, FeeInfo } from '@subwallet/extension-base/types';
|
|
3
3
|
export default class FeeService {
|
|
4
4
|
protected readonly state: KoniState;
|
|
5
5
|
private evmFeeSubject;
|
|
6
6
|
private useInfura;
|
|
7
|
+
private chainFeeSubscriptionMap;
|
|
7
8
|
constructor(state: KoniState);
|
|
8
9
|
changeMode(useInfura: boolean): void;
|
|
9
10
|
private updateFees;
|
|
10
11
|
private updateChainFee;
|
|
11
12
|
subscribeFees(callback: (data: Record<string, EvmFeeInfo>) => void): () => void;
|
|
13
|
+
subscribeChainFee(id: string, chain: string, type: FeeChainType, callback?: (data: FeeInfo) => void): Promise<FeeInfo>;
|
|
14
|
+
unsubscribeChainFee(id: string, chain: string, type: FeeChainType): void;
|
|
12
15
|
}
|