@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.
- package/background/KoniTypes.d.ts +12 -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/api/staking/bonding/utils.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +289 -124
- 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 +14 -2
- 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/chain-service/index.js +22 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
- package/cjs/services/earning-service/handlers/native-staking/tao.js +121 -30
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +1 -1
- package/cjs/services/earning-service/handlers/special.js +34 -14
- 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/api/staking/bonding/utils.js +1 -1
- package/koni/background/handlers/Extension.d.ts +4 -3
- package/koni/background/handlers/Extension.js +273 -108
- 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 +14 -2
- 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/chain-service/index.d.ts +6 -1
- package/services/chain-service/index.js +22 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
- package/services/earning-service/handlers/native-staking/tao.d.ts +7 -2
- package/services/earning-service/handlers/native-staking/tao.js +119 -29
- package/services/earning-service/handlers/nomination-pool/index.js +1 -1
- package/services/earning-service/handlers/special.js +36 -16
- 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
|
@@ -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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
|
-
import { AssetSetting, MetadataItem, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { AssetSetting, MetadataItem, TokenPriorityDetails, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
5
5
|
import { _ChainApiStatus, _ChainConnectionStatus, _ChainState, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
|
|
6
6
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
@@ -30,15 +30,18 @@ export declare class ChainService {
|
|
|
30
30
|
private assetLogoMapSubject;
|
|
31
31
|
private chainLogoMapSubject;
|
|
32
32
|
private ledgerGenericAllowChainsSubject;
|
|
33
|
+
private priorityTokensSubject;
|
|
33
34
|
private store;
|
|
34
35
|
private assetSettingSubject;
|
|
35
36
|
private logger;
|
|
36
37
|
constructor(dbService: DatabaseService, eventService: EventService);
|
|
37
38
|
get value(): {
|
|
38
39
|
readonly ledgerGenericAllowChains: string[];
|
|
40
|
+
readonly priorityTokens: TokenPriorityDetails;
|
|
39
41
|
};
|
|
40
42
|
get observable(): {
|
|
41
43
|
readonly ledgerGenericAllowChains: import("rxjs").Observable<string[]>;
|
|
44
|
+
readonly priorityTokens: import("rxjs").Observable<TokenPriorityDetails>;
|
|
42
45
|
};
|
|
43
46
|
subscribeSwapRefMap(): Subject<Record<string, _AssetRef>>;
|
|
44
47
|
get xcmRefMap(): Record<string, _AssetRef>;
|
|
@@ -105,6 +108,7 @@ export declare class ChainService {
|
|
|
105
108
|
handleLatestChainData(latestChainInfo: _ChainInfo[]): void;
|
|
106
109
|
autoEnableTokens(): Promise<void>;
|
|
107
110
|
handleLatestLedgerGenericAllowChains(latestledgerGenericAllowChains: string[]): void;
|
|
111
|
+
handleLatestPriorityTokens(latestPriorityTokens: TokenPriorityDetails): void;
|
|
108
112
|
handleLatestData(): void;
|
|
109
113
|
private initApis;
|
|
110
114
|
initSingleApi(slug: string): Promise<boolean>;
|
|
@@ -118,6 +122,7 @@ export declare class ChainService {
|
|
|
118
122
|
private fetchLatestChainData;
|
|
119
123
|
private fetchLatestPriceIdsData;
|
|
120
124
|
private fetchLatestLedgerGenericAllowChains;
|
|
125
|
+
private fetchLatestPriorityTokens;
|
|
121
126
|
private initChains;
|
|
122
127
|
private initAssetRegistry;
|
|
123
128
|
private updateChainStateMapSubscription;
|
|
@@ -47,6 +47,7 @@ export class ChainService {
|
|
|
47
47
|
assetLogoMapSubject = new BehaviorSubject(AssetLogoMap);
|
|
48
48
|
chainLogoMapSubject = new BehaviorSubject(ChainLogoMap);
|
|
49
49
|
ledgerGenericAllowChainsSubject = new BehaviorSubject([]);
|
|
50
|
+
priorityTokensSubject = new BehaviorSubject({});
|
|
50
51
|
|
|
51
52
|
// Todo: Update to new store indexed DB
|
|
52
53
|
store = new AssetSettingStore();
|
|
@@ -70,17 +71,25 @@ export class ChainService {
|
|
|
70
71
|
}
|
|
71
72
|
get value() {
|
|
72
73
|
const ledgerGenericAllowChains = this.ledgerGenericAllowChainsSubject;
|
|
74
|
+
const priorityTokens = this.priorityTokensSubject;
|
|
73
75
|
return {
|
|
74
76
|
get ledgerGenericAllowChains() {
|
|
75
77
|
return ledgerGenericAllowChains.value;
|
|
78
|
+
},
|
|
79
|
+
get priorityTokens() {
|
|
80
|
+
return priorityTokens.value;
|
|
76
81
|
}
|
|
77
82
|
};
|
|
78
83
|
}
|
|
79
84
|
get observable() {
|
|
80
85
|
const ledgerGenericAllowChains = this.ledgerGenericAllowChainsSubject;
|
|
86
|
+
const priorityTokens = this.priorityTokensSubject;
|
|
81
87
|
return {
|
|
82
88
|
get ledgerGenericAllowChains() {
|
|
83
89
|
return ledgerGenericAllowChains.asObservable();
|
|
90
|
+
},
|
|
91
|
+
get priorityTokens() {
|
|
92
|
+
return priorityTokens.asObservable();
|
|
84
93
|
}
|
|
85
94
|
};
|
|
86
95
|
}
|
|
@@ -581,6 +590,10 @@ export class ChainService {
|
|
|
581
590
|
this.eventService.emit('ledger.ready', true);
|
|
582
591
|
this.logger.log('Finished updating latest ledger generic allow chains');
|
|
583
592
|
}
|
|
593
|
+
handleLatestPriorityTokens(latestPriorityTokens) {
|
|
594
|
+
this.priorityTokensSubject.next(latestPriorityTokens);
|
|
595
|
+
this.logger.log('Finished updating latest popular tokens');
|
|
596
|
+
}
|
|
584
597
|
handleLatestData() {
|
|
585
598
|
this.fetchLatestChainData().then(latestChainInfo => {
|
|
586
599
|
this.lockChainInfoMap = true; // do not need to check current lockChainInfoMap because all remains action is fast enough and don't affect this feature.
|
|
@@ -598,6 +611,9 @@ export class ChainService {
|
|
|
598
611
|
this.fetchLatestLedgerGenericAllowChains().then(latestledgerGenericAllowChains => {
|
|
599
612
|
this.handleLatestLedgerGenericAllowChains(latestledgerGenericAllowChains);
|
|
600
613
|
}).catch(console.error);
|
|
614
|
+
this.fetchLatestPriorityTokens().then(latestPriorityTokens => {
|
|
615
|
+
this.handleLatestPriorityTokens(latestPriorityTokens);
|
|
616
|
+
}).catch(console.error);
|
|
601
617
|
}
|
|
602
618
|
async initApis() {
|
|
603
619
|
const chainInfoMap = this.getChainInfoMap();
|
|
@@ -859,6 +875,12 @@ export class ChainService {
|
|
|
859
875
|
async fetchLatestLedgerGenericAllowChains() {
|
|
860
876
|
return (await fetchStaticData('chains/ledger-generic-allow-chains')) || [];
|
|
861
877
|
}
|
|
878
|
+
async fetchLatestPriorityTokens() {
|
|
879
|
+
return (await fetchStaticData('chain-assets/priority-tokens')) || {
|
|
880
|
+
tokenGroup: {},
|
|
881
|
+
token: {}
|
|
882
|
+
};
|
|
883
|
+
}
|
|
862
884
|
async initChains() {
|
|
863
885
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
864
886
|
const defaultChainInfoMap = filterChainInfoMap(ChainInfoMap, ignoredList);
|