@subwallet/extension-base 1.3.65-0 → 1.3.67-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/cjs/core/substrate/xcm-parser.js +0 -176
- package/cjs/koni/background/handlers/Extension.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/smart-contract.js +54 -23
- package/cjs/services/balance-service/transfer/xcm/index.js +30 -44
- package/cjs/services/balance-service/transfer/xcm/utils.js +53 -18
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js +51 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251107.js +37 -0
- package/cjs/services/migration-service/scripts/index.js +13 -9
- package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/cjs/services/swap-service/handler/base-handler.js +18 -21
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/utils/eth.js +2 -1
- package/cjs/utils/fee/transfer.js +5 -2
- package/core/substrate/xcm-parser.d.ts +1 -49
- package/core/substrate/xcm-parser.js +1 -173
- package/koni/background/handlers/Extension.js +1 -1
- package/package.json +17 -22
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/smart-contract.d.ts +4 -0
- package/services/balance-service/transfer/smart-contract.js +52 -23
- package/services/balance-service/transfer/xcm/index.d.ts +2 -2
- package/services/balance-service/transfer/xcm/index.js +18 -32
- package/services/balance-service/transfer/xcm/utils.d.ts +1 -2
- package/services/balance-service/transfer/xcm/utils.js +51 -15
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js +42 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251107.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251107.js +29 -0
- package/services/migration-service/scripts/index.js +5 -1
- package/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/services/swap-service/handler/base-handler.d.ts +0 -1
- package/services/swap-service/handler/base-handler.js +19 -22
- package/services/transaction-service/index.js +1 -1
- package/types/transaction/data.d.ts +1 -1
- package/utils/eth.js +2 -1
- package/utils/fee/transfer.js +6 -3
- package/cjs/services/balance-service/transfer/xcm/polkadotXcm.js +0 -30
- package/cjs/services/balance-service/transfer/xcm/xTokens.js +0 -32
- package/cjs/services/balance-service/transfer/xcm/xcmPallet.js +0 -23
- package/services/balance-service/transfer/xcm/polkadotXcm.d.ts +0 -3
- package/services/balance-service/transfer/xcm/polkadotXcm.js +0 -24
- package/services/balance-service/transfer/xcm/xTokens.d.ts +0 -3
- package/services/balance-service/transfer/xcm/xTokens.js +0 -26
- package/services/balance-service/transfer/xcm/xcmPallet.d.ts +0 -3
- package/services/balance-service/transfer/xcm/xcmPallet.js +0 -17
|
@@ -9,6 +9,11 @@ import { EVM_REFORMAT_DECIMALS } from '@subwallet/extension-base/services/chain-
|
|
|
9
9
|
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
10
10
|
import BigN from 'bignumber.js';
|
|
11
11
|
import { t } from 'i18next';
|
|
12
|
+
// hot fix gas settings for Energy Web Chain
|
|
13
|
+
export const gasSettingsForEWC = {
|
|
14
|
+
gasLimit: 4900000,
|
|
15
|
+
maxFeePerGas: '10000000'
|
|
16
|
+
};
|
|
12
17
|
export async function getEVMTransactionObject(props) {
|
|
13
18
|
const {
|
|
14
19
|
chain,
|
|
@@ -23,10 +28,18 @@ export async function getEVMTransactionObject(props) {
|
|
|
23
28
|
transferAll,
|
|
24
29
|
value
|
|
25
30
|
} = props;
|
|
31
|
+
const isEnergyWebChain = chain === 'energy_web_chain'; // hot fix gas settings for Energy Web Chain
|
|
32
|
+
|
|
26
33
|
const feeCustom = _feeCustom;
|
|
27
34
|
const feeInfo = _feeInfo;
|
|
28
35
|
const feeCombine = combineEthFee(feeInfo, feeOption, feeCustom);
|
|
29
36
|
let errorOnEstimateFee = '';
|
|
37
|
+
if (isEnergyWebChain) {
|
|
38
|
+
feeCombine.maxFeePerGas = gasSettingsForEWC.maxFeePerGas;
|
|
39
|
+
if (!feeCombine.maxPriorityFeePerGas || new BigN(feeCombine.maxPriorityFeePerGas).gt(feeCombine.maxFeePerGas)) {
|
|
40
|
+
feeCombine.maxPriorityFeePerGas = gasSettingsForEWC.maxFeePerGas;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
30
43
|
const transactionObject = {
|
|
31
44
|
to,
|
|
32
45
|
value,
|
|
@@ -34,16 +47,21 @@ export async function getEVMTransactionObject(props) {
|
|
|
34
47
|
data,
|
|
35
48
|
...feeCombine
|
|
36
49
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
let gasLimit;
|
|
51
|
+
if (isEnergyWebChain) {
|
|
52
|
+
gasLimit = gasSettingsForEWC.gasLimit;
|
|
53
|
+
} else {
|
|
54
|
+
const gasEstimate = await evmApi.api.eth.estimateGas(transactionObject).catch(e => {
|
|
55
|
+
console.log('Cannot estimate fee with native transfer on', chain, e);
|
|
56
|
+
if (fallbackFee) {
|
|
57
|
+
errorOnEstimateFee = e.message;
|
|
58
|
+
return 21000;
|
|
59
|
+
} else {
|
|
60
|
+
throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
gasLimit = Math.floor(gasEstimate * 1.1); // 10% buffer for fluctuations
|
|
64
|
+
}
|
|
47
65
|
|
|
48
66
|
transactionObject.gas = gasLimit;
|
|
49
67
|
let estimateFee;
|
|
@@ -74,6 +92,8 @@ export async function getERC20TransactionObject(props) {
|
|
|
74
92
|
transferAll,
|
|
75
93
|
value
|
|
76
94
|
} = props;
|
|
95
|
+
const isEnergyWebChain = chain === 'energy_web_chain'; // hot fix gas settings for Energy Web Chain
|
|
96
|
+
|
|
77
97
|
const erc20Contract = getERC20Contract(assetAddress, evmApi);
|
|
78
98
|
const feeCustom = _feeCustom;
|
|
79
99
|
let freeAmount = new BigN(0);
|
|
@@ -89,21 +109,30 @@ export async function getERC20TransactionObject(props) {
|
|
|
89
109
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
90
110
|
return erc20Contract.methods.transfer(to, transferValue).encodeABI();
|
|
91
111
|
}
|
|
92
|
-
const transferData = generateTransferData(to, transferValue);
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
94
|
-
const gasLimit = await erc20Contract.methods.transfer(to, transferValue).estimateGas({
|
|
95
|
-
from
|
|
96
|
-
}).catch(e => {
|
|
97
|
-
console.log('Cannot estimate fee with token contract', assetAddress, chain, e);
|
|
98
|
-
if (fallbackFee) {
|
|
99
|
-
errorOnEstimateFee = e.message;
|
|
100
|
-
return 70000;
|
|
101
|
-
} else {
|
|
102
|
-
throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
112
|
const feeInfo = _feeInfo;
|
|
106
113
|
const feeCombine = combineEthFee(feeInfo, feeOption, feeCustom);
|
|
114
|
+
const transferData = generateTransferData(to, transferValue);
|
|
115
|
+
let gasLimit;
|
|
116
|
+
if (isEnergyWebChain) {
|
|
117
|
+
gasLimit = gasSettingsForEWC.gasLimit;
|
|
118
|
+
feeCombine.maxFeePerGas = gasSettingsForEWC.maxFeePerGas;
|
|
119
|
+
if (!feeCombine.maxPriorityFeePerGas || new BigN(feeCombine.maxPriorityFeePerGas).gt(feeCombine.maxFeePerGas)) {
|
|
120
|
+
feeCombine.maxPriorityFeePerGas = gasSettingsForEWC.maxFeePerGas;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
124
|
+
gasLimit = await erc20Contract.methods.transfer(to, transferValue).estimateGas({
|
|
125
|
+
from
|
|
126
|
+
}).catch(e => {
|
|
127
|
+
console.log('Cannot estimate fee with token contract', assetAddress, chain, e);
|
|
128
|
+
if (fallbackFee) {
|
|
129
|
+
errorOnEstimateFee = e.message;
|
|
130
|
+
return 70000;
|
|
131
|
+
} else {
|
|
132
|
+
throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
107
136
|
const transactionObject = {
|
|
108
137
|
gas: gasLimit,
|
|
109
138
|
from,
|
|
@@ -17,10 +17,10 @@ export declare type CreateXcmExtrinsicProps = {
|
|
|
17
17
|
} & TransactionFee;
|
|
18
18
|
export declare type FunctionCreateXcmExtrinsic = (props: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'> | TransactionConfig | undefined>;
|
|
19
19
|
export declare const createSnowBridgeExtrinsic: ({ destinationChain, evmApi, feeCustom, feeInfo, feeOption, originChain, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
20
|
-
export declare const createXcmExtrinsic: ({ destinationChain, originChain, originTokenInfo, recipient, sendingValue, substrateApi }: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'>>;
|
|
21
20
|
export declare const createAvailBridgeTxFromEth: ({ evmApi, feeCustom, feeInfo, feeOption, originChain, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
22
21
|
export declare const createAvailBridgeExtrinsicFromAvail: ({ recipient, sendingValue, substrateApi }: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'>>;
|
|
23
22
|
export declare const createPolygonBridgeExtrinsic: ({ destinationChain, evmApi, feeCustom, feeInfo, feeOption, originChain, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
24
23
|
export declare const createXcmExtrinsicV2: (request: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'> | undefined>;
|
|
25
|
-
export declare const dryRunXcmExtrinsicV2: (request: CreateXcmExtrinsicProps) => Promise<boolean>;
|
|
24
|
+
export declare const dryRunXcmExtrinsicV2: (request: CreateXcmExtrinsicProps, isPreview?: boolean) => Promise<boolean>;
|
|
25
|
+
export declare const getXcmOriginFee: (request: CreateXcmExtrinsicProps) => Promise<string | undefined>;
|
|
26
26
|
export declare const createAcrossBridgeExtrinsic: ({ destinationChain, destinationTokenInfo, evmApi, feeCustom, feeInfo, feeOption, originChain, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
@@ -3,14 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { _isAcrossBridgeXcm, _isPolygonBridgeXcm, _isPosBridgeXcm, _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
5
5
|
import { getAvailBridgeExtrinsicFromAvail, getAvailBridgeTxFromEth } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
6
|
-
import { getExtrinsicByPolkadotXcmPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polkadotXcm';
|
|
7
6
|
import { _createPolygonBridgeL1toL2Extrinsic, _createPolygonBridgeL2toL1Extrinsic } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
8
7
|
import { getSnowBridgeEvmTransfer } from '@subwallet/extension-base/services/balance-service/transfer/xcm/snowBridge';
|
|
9
|
-
import { buildXcm, dryRunXcm, isChainNotSupportDryRun, isChainNotSupportPolkadotApi } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
|
|
10
|
-
import { getExtrinsicByXcmPalletPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xcmPallet';
|
|
11
|
-
import { getExtrinsicByXtokensPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xTokens';
|
|
12
|
-
import { _XCM_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
13
|
-
import { _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
+
import { buildXcm, dryRunPreviewXcm, dryRunXcm, estimateXcmFee, isChainNotSupportDryRun, isChainNotSupportPolkadotApi } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
|
|
14
9
|
import { combineEthFee } from '@subwallet/extension-base/utils';
|
|
15
10
|
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
16
11
|
import { _createPosBridgeL1toL2Extrinsic, _createPosBridgeL2toL1Extrinsic } from "./posBridge.js";
|
|
@@ -38,30 +33,6 @@ export const createSnowBridgeExtrinsic = async ({
|
|
|
38
33
|
}
|
|
39
34
|
return getSnowBridgeEvmTransfer(originTokenInfo, originChain, destinationChain, sender, recipient, sendingValue, evmApi, feeInfo, feeCustom, feeOption);
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
// deprecated
|
|
43
|
-
export const createXcmExtrinsic = async ({
|
|
44
|
-
destinationChain,
|
|
45
|
-
originChain,
|
|
46
|
-
originTokenInfo,
|
|
47
|
-
recipient,
|
|
48
|
-
sendingValue,
|
|
49
|
-
substrateApi
|
|
50
|
-
}) => {
|
|
51
|
-
if (!substrateApi) {
|
|
52
|
-
throw Error('Substrate API is not available');
|
|
53
|
-
}
|
|
54
|
-
const chainApi = await substrateApi.isReady;
|
|
55
|
-
const api = chainApi.api;
|
|
56
|
-
const polkadotXcmSpecialCases = _XCM_CHAIN_GROUP.polkadotXcmSpecialCases.includes(originChain.slug) && _isNativeToken(originTokenInfo);
|
|
57
|
-
if (_XCM_CHAIN_GROUP.polkadotXcm.includes(originTokenInfo.originChain) || polkadotXcmSpecialCases) {
|
|
58
|
-
return getExtrinsicByPolkadotXcmPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
59
|
-
}
|
|
60
|
-
if (_XCM_CHAIN_GROUP.xcmPallet.includes(originTokenInfo.originChain)) {
|
|
61
|
-
return getExtrinsicByXcmPalletPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
62
|
-
}
|
|
63
|
-
return getExtrinsicByXtokensPallet(originTokenInfo, originChain, destinationChain, recipient, sendingValue, api);
|
|
64
|
-
};
|
|
65
36
|
export const createAvailBridgeTxFromEth = ({
|
|
66
37
|
evmApi,
|
|
67
38
|
feeCustom,
|
|
@@ -125,9 +96,9 @@ export const createXcmExtrinsicV2 = async request => {
|
|
|
125
96
|
return undefined;
|
|
126
97
|
}
|
|
127
98
|
};
|
|
128
|
-
export const dryRunXcmExtrinsicV2 = async request => {
|
|
99
|
+
export const dryRunXcmExtrinsicV2 = async (request, isPreview = false) => {
|
|
129
100
|
try {
|
|
130
|
-
const dryRunResult = await dryRunXcm(request);
|
|
101
|
+
const dryRunResult = isPreview ? await dryRunPreviewXcm(request) : await dryRunXcm(request);
|
|
131
102
|
const originDryRunRs = dryRunResult.origin;
|
|
132
103
|
if (originDryRunRs.success) {
|
|
133
104
|
const {
|
|
@@ -157,6 +128,21 @@ export const dryRunXcmExtrinsicV2 = async request => {
|
|
|
157
128
|
return false;
|
|
158
129
|
}
|
|
159
130
|
};
|
|
131
|
+
export const getXcmOriginFee = async request => {
|
|
132
|
+
try {
|
|
133
|
+
const xcmFeeInfo = await estimateXcmFee({
|
|
134
|
+
fromChainInfo: request.originChain,
|
|
135
|
+
fromTokenInfo: request.originTokenInfo,
|
|
136
|
+
toChainInfo: request.destinationChain,
|
|
137
|
+
recipient: request.recipient,
|
|
138
|
+
sender: request.sender,
|
|
139
|
+
value: request.sendingValue
|
|
140
|
+
});
|
|
141
|
+
return xcmFeeInfo === null || xcmFeeInfo === void 0 ? void 0 : xcmFeeInfo.origin.fee;
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
160
146
|
export const createAcrossBridgeExtrinsic = async ({
|
|
161
147
|
destinationChain,
|
|
162
148
|
destinationTokenInfo,
|
|
@@ -44,9 +44,8 @@ export declare type GetXcmFeeResult = {
|
|
|
44
44
|
};
|
|
45
45
|
export declare function buildXcm(request: CreateXcmExtrinsicProps): Promise<SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
46
46
|
export declare function dryRunXcm(request: CreateXcmExtrinsicProps): Promise<DryRunResult>;
|
|
47
|
+
export declare function dryRunPreviewXcm(request: CreateXcmExtrinsicProps): Promise<DryRunResult>;
|
|
47
48
|
export declare function estimateXcmFee(request: GetXcmFeeRequest): Promise<GetXcmFeeResult | undefined>;
|
|
48
49
|
export declare function isChainNotSupportPolkadotApi(str: string): boolean;
|
|
49
50
|
export declare function isChainNotSupportDryRun(str: string): boolean;
|
|
50
|
-
export declare const STABLE_XCM_VERSION = 3;
|
|
51
|
-
export declare function isUseTeleportProtocol(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, tokenSlug?: string): boolean;
|
|
52
51
|
export {};
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
import { fetchParaSpellChainMap } from '@subwallet/extension-base/constants/paraspell-chain-map';
|
|
5
5
|
import { ProxyServiceRoute } from '@subwallet/extension-base/types/environment';
|
|
6
6
|
import { fetchFromProxyService } from '@subwallet/extension-base/utils';
|
|
7
|
+
import BigNumber from 'bignumber.js';
|
|
7
8
|
import { assert, compactToU8a, isHex, u8aConcat, u8aEq } from '@polkadot/util';
|
|
8
9
|
const version = '/v4';
|
|
9
10
|
const paraSpellApi = {
|
|
10
11
|
buildXcm: `${version}/x-transfer`,
|
|
12
|
+
feeXcm: `${version}/xcm-fee`,
|
|
11
13
|
dryRunXcm: `${version}/dry-run`,
|
|
12
|
-
|
|
14
|
+
dryRunPreviewXcm: `${version}/dry-run-preview`
|
|
13
15
|
};
|
|
14
16
|
function txHexToSubmittableExtrinsic(api, hex) {
|
|
15
17
|
try {
|
|
@@ -151,6 +153,51 @@ export async function dryRunXcm(request) {
|
|
|
151
153
|
}
|
|
152
154
|
return await response.json();
|
|
153
155
|
}
|
|
156
|
+
export async function dryRunPreviewXcm(request) {
|
|
157
|
+
var _originTokenInfo$meta3;
|
|
158
|
+
const {
|
|
159
|
+
destinationChain,
|
|
160
|
+
originChain,
|
|
161
|
+
originTokenInfo,
|
|
162
|
+
recipient,
|
|
163
|
+
sender,
|
|
164
|
+
sendingValue
|
|
165
|
+
} = request;
|
|
166
|
+
const paraSpellChainMap = await fetchParaSpellChainMap();
|
|
167
|
+
const paraSpellIdentifyV4 = (_originTokenInfo$meta3 = originTokenInfo.metadata) === null || _originTokenInfo$meta3 === void 0 ? void 0 : _originTokenInfo$meta3.paraSpellIdentifyV4;
|
|
168
|
+
if (!paraSpellIdentifyV4) {
|
|
169
|
+
throw new Error('Token is not support XCM at this time');
|
|
170
|
+
}
|
|
171
|
+
const bodyData = {
|
|
172
|
+
senderAddress: sender,
|
|
173
|
+
address: recipient,
|
|
174
|
+
from: paraSpellChainMap[originChain.slug],
|
|
175
|
+
to: paraSpellChainMap[destinationChain.slug],
|
|
176
|
+
currency: createParaSpellCurrency(paraSpellIdentifyV4, sendingValue),
|
|
177
|
+
options: {
|
|
178
|
+
abstractDecimals: false,
|
|
179
|
+
mintFeeAssets: true
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const response = await fetchFromProxyService(ProxyServiceRoute.PARASPELL, paraSpellApi.dryRunPreviewXcm, {
|
|
183
|
+
method: 'POST',
|
|
184
|
+
body: JSON.stringify(bodyData),
|
|
185
|
+
headers: {
|
|
186
|
+
'Content-Type': 'application/json',
|
|
187
|
+
Accept: 'application/json'
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
if (!response.ok) {
|
|
191
|
+
const error = await response.json();
|
|
192
|
+
return {
|
|
193
|
+
origin: {
|
|
194
|
+
success: false,
|
|
195
|
+
failureReason: error.message
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return await response.json();
|
|
200
|
+
}
|
|
154
201
|
export async function estimateXcmFee(request) {
|
|
155
202
|
var _fromTokenInfo$metada;
|
|
156
203
|
const {
|
|
@@ -163,6 +210,8 @@ export async function estimateXcmFee(request) {
|
|
|
163
210
|
} = request;
|
|
164
211
|
const paraSpellChainMap = await fetchParaSpellChainMap();
|
|
165
212
|
const paraSpellIdentifyV4 = (_fromTokenInfo$metada = fromTokenInfo.metadata) === null || _fromTokenInfo$metada === void 0 ? void 0 : _fromTokenInfo$metada.paraSpellIdentifyV4;
|
|
213
|
+
const requestValue = BigNumber(value).gt(0) ? value : '1'; // avoid bug in-case estimate fee sendingValue <= 0;
|
|
214
|
+
|
|
166
215
|
if (!paraSpellIdentifyV4) {
|
|
167
216
|
console.error('Lack of paraspell metadata');
|
|
168
217
|
return undefined;
|
|
@@ -172,7 +221,7 @@ export async function estimateXcmFee(request) {
|
|
|
172
221
|
address: recipient,
|
|
173
222
|
from: paraSpellChainMap[fromChainInfo.slug],
|
|
174
223
|
to: paraSpellChainMap[toChainInfo.slug],
|
|
175
|
-
currency: createParaSpellCurrency(paraSpellIdentifyV4,
|
|
224
|
+
currency: createParaSpellCurrency(paraSpellIdentifyV4, requestValue),
|
|
176
225
|
options: {
|
|
177
226
|
abstractDecimals: false
|
|
178
227
|
}
|
|
@@ -192,8 +241,6 @@ export async function estimateXcmFee(request) {
|
|
|
192
241
|
return await response.json();
|
|
193
242
|
}
|
|
194
243
|
function createParaSpellCurrency(paraSpellIdentifyV4, amount) {
|
|
195
|
-
// todo: handle complex conditions for asset has same symbol in a chain: Id, Multi-location, ...
|
|
196
|
-
// todo: or update all asset to use multi-location
|
|
197
244
|
return {
|
|
198
245
|
...paraSpellIdentifyV4,
|
|
199
246
|
amount
|
|
@@ -208,15 +255,4 @@ export function isChainNotSupportDryRun(str) {
|
|
|
208
255
|
const regex = /(?=.*DryRunApi)(?=.*not available).*/i; // Example: DryRunApi is not available on node Acala
|
|
209
256
|
|
|
210
257
|
return regex.test(str);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// todo: remove
|
|
214
|
-
export const STABLE_XCM_VERSION = 3;
|
|
215
|
-
|
|
216
|
-
// todo: remove
|
|
217
|
-
export function isUseTeleportProtocol(originChainInfo, destChainInfo, tokenSlug) {
|
|
218
|
-
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);
|
|
219
|
-
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);
|
|
220
|
-
const isXcmMythos = originChainInfo.slug === 'mythos' && destChainInfo.slug === 'statemint' && tokenSlug === 'mythos-NATIVE-MYTH' || originChainInfo.slug === 'statemint' && destChainInfo.slug === 'mythos' && tokenSlug === 'statemint-LOCAL-MYTH';
|
|
221
|
-
return relayChainToSystemChain || systemChainToRelayChain || isXcmMythos;
|
|
222
258
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
export declare const ChainListVersion = "0.2.
|
|
2
|
+
export declare const ChainListVersion = "0.2.121";
|
|
3
3
|
export interface PatchInfo {
|
|
4
4
|
patchVersion: string;
|
|
5
5
|
appliedVersion: string;
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = process.env.PATCH_CHAIN_LIST_URL || (PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev');
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
export const ChainListVersion = '0.2.
|
|
8
|
+
export const ChainListVersion = '0.2.121'; // update this when build chain-list
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateTransactionHistoryBySymbol20251107 extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
try {
|
|
9
|
+
const changeSlugsMap = {
|
|
10
|
+
'bittensor-LOCAL-ف': 'bittensor-LOCAL-ㄴ'
|
|
11
|
+
};
|
|
12
|
+
const allTxs = [];
|
|
13
|
+
await Promise.all(Object.entries(changeSlugsMap).map(async ([oldSlug, newSlug], i) => {
|
|
14
|
+
const oldSlugSplit = oldSlug.split('-');
|
|
15
|
+
const oldChainSlug = oldSlugSplit[0];
|
|
16
|
+
const oldSymbolSlug = oldSlugSplit[2];
|
|
17
|
+
const newSlugSplit = newSlug.split('-');
|
|
18
|
+
const newSymbolSlug = newSlugSplit[2];
|
|
19
|
+
const filterTransactions = await state.dbService.stores.transaction.table.where({
|
|
20
|
+
chain: oldChainSlug
|
|
21
|
+
}).and(tx => {
|
|
22
|
+
var _tx$amount;
|
|
23
|
+
return ((_tx$amount = tx.amount) === null || _tx$amount === void 0 ? void 0 : _tx$amount.symbol) === oldSymbolSlug;
|
|
24
|
+
}).toArray();
|
|
25
|
+
if (filterTransactions.length > 0) {
|
|
26
|
+
for (const transaction of filterTransactions) {
|
|
27
|
+
if (transaction.amount && transaction.amount.symbol === oldSymbolSlug) {
|
|
28
|
+
transaction.amount.symbol = newSymbolSlug;
|
|
29
|
+
}
|
|
30
|
+
if (transaction.fee && transaction.fee.symbol === oldSymbolSlug) {
|
|
31
|
+
transaction.fee.symbol = newSymbolSlug;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
allTxs.push(...filterTransactions);
|
|
36
|
+
}));
|
|
37
|
+
await state.dbService.stores.transaction.table.bulkPut(allTxs);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
this.logger.error(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateAssetSetting20251107 extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
const changeSlugsMap = {
|
|
9
|
+
'bittensor-LOCAL-ف': 'bittensor-LOCAL-ㄴ'
|
|
10
|
+
};
|
|
11
|
+
const assetSetting = await this.state.chainService.getAssetSettings();
|
|
12
|
+
const migratedAssetSetting = {};
|
|
13
|
+
for (const [oldSlug, newSlug] of Object.entries(changeSlugsMap)) {
|
|
14
|
+
if (Object.keys(assetSetting).includes(oldSlug)) {
|
|
15
|
+
const isVisible = assetSetting[oldSlug].visible;
|
|
16
|
+
migratedAssetSetting[newSlug] = {
|
|
17
|
+
visible: isVisible
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
this.state.chainService.setAssetSettings({
|
|
22
|
+
...assetSetting,
|
|
23
|
+
...migratedAssetSetting
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import MigrateAssetSetting20251107 from '@subwallet/extension-base/services/migration-service/scripts/databases/MigrateAssetSetting20251107';
|
|
4
5
|
import MigrateChainPatrol from '@subwallet/extension-base/services/migration-service/scripts/MigrateChainPatrol';
|
|
6
|
+
import MigrateTransactionHistoryBySymbol20251107 from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107';
|
|
5
7
|
import ClearMetadataDatabase from "./databases/ClearMetadataDatabase.js";
|
|
6
8
|
import ClearMetadataForMythos from "./databases/ClearMetadataForMythos.js";
|
|
7
9
|
import MigrateAssetSetting from "./databases/MigrateAssetSetting.js";
|
|
@@ -77,5 +79,7 @@ export default {
|
|
|
77
79
|
'1.3.58-01': OptimizeEnableToken,
|
|
78
80
|
'1.3.64-01': MigrateAssetSetting20251027,
|
|
79
81
|
'1.3.64-02': MigrateTransactionHistoryBySymbol20251027,
|
|
80
|
-
'1.3.65-01': DeleteEarningData20251105
|
|
82
|
+
'1.3.65-01': DeleteEarningData20251105,
|
|
83
|
+
'1.3.66-01': MigrateAssetSetting20251107,
|
|
84
|
+
'1.3.66-02': MigrateTransactionHistoryBySymbol20251107
|
|
81
85
|
};
|
|
@@ -194,7 +194,7 @@ export default class EvmRequestHandler {
|
|
|
194
194
|
const params = {
|
|
195
195
|
...transaction,
|
|
196
196
|
gas: anyNumberToBN(gas).toNumber(),
|
|
197
|
-
value: anyNumberToBN(value).
|
|
197
|
+
value: anyNumberToBN(value).toFixed(),
|
|
198
198
|
gasPrice: anyNumberToBN(gasPrice).toNumber(),
|
|
199
199
|
gasLimit: anyNumberToBN(estimateGas).toNumber(),
|
|
200
200
|
maxFeePerGas: anyNumberToBN(maxFeePerGas).toNumber(),
|
|
@@ -34,7 +34,6 @@ export declare class SwapBaseHandler {
|
|
|
34
34
|
handleBridgeStep(params: SwapSubmitParams, type: string): Promise<SwapSubmitStepData>;
|
|
35
35
|
handleBridgeSubstrate(params: SwapSubmitParams): Promise<SwapSubmitStepData>;
|
|
36
36
|
handleBridgeAcross(params: SwapSubmitParams): Promise<SwapSubmitStepData>;
|
|
37
|
-
validateSetFeeTokenStep(params: ValidateSwapProcessParams, stepIndex: number): Promise<TransactionError[]>;
|
|
38
37
|
private validateBridgeStep;
|
|
39
38
|
private validateSwapStepV2;
|
|
40
39
|
validateSwapOnlyProcess(params: ValidateSwapProcessParams, swapIndex: number): Promise<TransactionError[]>;
|
|
@@ -7,7 +7,7 @@ import { validateSpendingAndFeePayment } from '@subwallet/extension-base/core/lo
|
|
|
7
7
|
import { _isAccountActive } from '@subwallet/extension-base/core/substrate/system-pallet';
|
|
8
8
|
import { _isAcrossBridgeXcm, _isSnowBridgeXcm, _isXcmWithinSameConsensus } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
9
9
|
import { _isSufficientToken } from '@subwallet/extension-base/core/utils';
|
|
10
|
-
import { createXcmExtrinsicV2, dryRunXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
10
|
+
import { createXcmExtrinsicV2, dryRunXcmExtrinsicV2, getXcmOriginFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
11
11
|
import { _isAcrossChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
12
12
|
import { estimateXcmFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
|
|
13
13
|
import { _getAssetDecimals, _getAssetOriginChain, _getAssetSymbol, _getChainNativeTokenSlug, _getTokenMinAmount, _isChainEvmCompatible, _isNativeToken, _isPureBitcoinChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -298,21 +298,6 @@ export class SwapBaseHandler {
|
|
|
298
298
|
txData: txData
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
-
async validateSetFeeTokenStep(params, stepIndex) {
|
|
302
|
-
if (!params.selectedQuote) {
|
|
303
|
-
return Promise.resolve([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
|
|
304
|
-
}
|
|
305
|
-
const feeInfo = params.process.totalFee[stepIndex];
|
|
306
|
-
const feeAmount = feeInfo.feeComponent[0];
|
|
307
|
-
const feeTokenInfo = this.chainService.getAssetBySlug(feeInfo.defaultFeeToken);
|
|
308
|
-
const feeTokenBalance = await this.balanceService.getTransferableBalance(params.address, feeTokenInfo.originChain, feeTokenInfo.slug);
|
|
309
|
-
const bnFeeTokenBalance = new BigN(feeTokenBalance.value);
|
|
310
|
-
const bnFeeAmount = new BigN(feeAmount.amount);
|
|
311
|
-
if (bnFeeAmount.gte(bnFeeTokenBalance)) {
|
|
312
|
-
return Promise.resolve([new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)]);
|
|
313
|
-
}
|
|
314
|
-
return [];
|
|
315
|
-
}
|
|
316
301
|
async validateBridgeStep(request) {
|
|
317
302
|
const {
|
|
318
303
|
bnBridgeAmount,
|
|
@@ -377,7 +362,7 @@ export class SwapBaseHandler {
|
|
|
377
362
|
const xcmRequest = {
|
|
378
363
|
originTokenInfo: fromToken,
|
|
379
364
|
destinationTokenInfo: toToken,
|
|
380
|
-
sendingValue: bnBridgeAmount.
|
|
365
|
+
sendingValue: bnBridgeAmount.toFixed(),
|
|
381
366
|
recipient: receiver,
|
|
382
367
|
substrateApi: substrateApi,
|
|
383
368
|
sender: sender,
|
|
@@ -385,11 +370,23 @@ export class SwapBaseHandler {
|
|
|
385
370
|
originChain: fromChain,
|
|
386
371
|
feeInfo
|
|
387
372
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
373
|
+
if (isFirstBridge) {
|
|
374
|
+
const isDryRunSuccess = await dryRunXcmExtrinsicV2(xcmRequest, false);
|
|
375
|
+
if (!isDryRunSuccess) {
|
|
376
|
+
return [new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
const isDryRunPreviewSuccess = await dryRunXcmExtrinsicV2(xcmRequest, true);
|
|
380
|
+
const originFee = await getXcmOriginFee(xcmRequest);
|
|
381
|
+
if (originFee) {
|
|
382
|
+
const isBridgeTokenNativeBalanceEnough = bnFeeTokenBalance.gte(originFee);
|
|
383
|
+
if (!isBridgeTokenNativeBalanceEnough) {
|
|
384
|
+
return [new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (!isDryRunPreviewSuccess) {
|
|
388
|
+
return [new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
389
|
+
}
|
|
393
390
|
}
|
|
394
391
|
}
|
|
395
392
|
return [];
|
|
@@ -1416,7 +1416,7 @@ export default class TransactionService {
|
|
|
1416
1416
|
maxPriorityFeePerGas: anyNumberToBN(payload.maxPriorityFeePerGas).toNumber(),
|
|
1417
1417
|
gasLimit: anyNumberToBN(payload.gas).toNumber(),
|
|
1418
1418
|
to: payload.to,
|
|
1419
|
-
value: anyNumberToBN(payload.value).
|
|
1419
|
+
value: anyNumberToBN(payload.value).toFixed(),
|
|
1420
1420
|
data: payload.data,
|
|
1421
1421
|
chainId: payload.chainId
|
|
1422
1422
|
};
|
package/utils/eth.js
CHANGED
|
@@ -25,12 +25,13 @@ export class Transaction {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export const anyNumberToBN = value => {
|
|
28
|
+
// TODO: Be careful when using .toNumber() outside this function. It may not round exactly for very large numbers.
|
|
28
29
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
29
30
|
return new BigN(value);
|
|
30
31
|
} else if (typeof value === 'undefined') {
|
|
31
32
|
return new BigN(0);
|
|
32
33
|
} else {
|
|
33
|
-
return new BigN(value.
|
|
34
|
+
return new BigN(value.toString());
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
export const createTransactionFromRLP = rlp => {
|
package/utils/fee/transfer.js
CHANGED
|
@@ -6,7 +6,7 @@ import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-p
|
|
|
6
6
|
import { DEFAULT_CARDANO_TTL_OFFSET } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/consts';
|
|
7
7
|
import { createBitcoinTransaction } from '@subwallet/extension-base/services/balance-service/transfer/bitcoin-transfer';
|
|
8
8
|
import { createCardanoTransaction } from '@subwallet/extension-base/services/balance-service/transfer/cardano-transfer';
|
|
9
|
-
import { getERC20TransactionObject, getEVMTransactionObject } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
9
|
+
import { gasSettingsForEWC, getERC20TransactionObject, getEVMTransactionObject } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
10
10
|
import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
11
11
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
12
12
|
import { createAcrossBridgeExtrinsic, createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
@@ -191,9 +191,13 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
191
191
|
var _tx$gas;
|
|
192
192
|
// Calculate fee for evm transaction
|
|
193
193
|
const tx = transaction;
|
|
194
|
-
|
|
194
|
+
let gasLimit = ((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.toString()) || (await evmApi.api.eth.estimateGas(tx)).toString();
|
|
195
195
|
const _feeCustom = feeCustom;
|
|
196
196
|
const combineFee = combineEthFee(fee, feeOption, _feeCustom);
|
|
197
|
+
if (srcChain.slug === 'energy_web_chain') {
|
|
198
|
+
gasLimit = gasSettingsForEWC.gasLimit.toString();
|
|
199
|
+
combineFee.maxFeePerGas = gasSettingsForEWC.maxFeePerGas;
|
|
200
|
+
}
|
|
197
201
|
if (combineFee.maxFeePerGas) {
|
|
198
202
|
estimatedFee = new BigN(combineFee.maxFeePerGas).multipliedBy(gasLimit).toFixed(0);
|
|
199
203
|
} else {
|
|
@@ -384,7 +388,6 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
384
388
|
funcCreateExtrinsic = createAvailBridgeExtrinsicFromAvail;
|
|
385
389
|
} else {
|
|
386
390
|
funcCreateExtrinsic = createXcmExtrinsicV2;
|
|
387
|
-
params.sendingValue = '1';
|
|
388
391
|
}
|
|
389
392
|
const extrinsic = await funcCreateExtrinsic(params);
|
|
390
393
|
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getExtrinsicByPolkadotXcmPallet = getExtrinsicByPolkadotXcmPallet;
|
|
7
|
-
var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
|
|
8
|
-
var _utils = require("@subwallet/extension-base/services/balance-service/transfer/xcm/utils");
|
|
9
|
-
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
14
|
-
let version = _utils.STABLE_XCM_VERSION;
|
|
15
|
-
let method = 'limitedReserveTransferAssets';
|
|
16
|
-
if ((0, _utils2._isBridgedToken)(tokenInfo) && !(0, _xcmParser._isXcmWithinSameConsensus)(originChainInfo, destinationChainInfo)) {
|
|
17
|
-
version = 4;
|
|
18
|
-
method = 'transferAssets';
|
|
19
|
-
}
|
|
20
|
-
if ((0, _utils.isUseTeleportProtocol)(originChainInfo, destinationChainInfo, tokenInfo.slug)) {
|
|
21
|
-
method = 'limitedTeleportAssets';
|
|
22
|
-
}
|
|
23
|
-
const weightParam = (0, _xcmParser._getXcmDestWeight)(originChainInfo);
|
|
24
|
-
const destination = (0, _xcmParser._getXcmMultiLocation)(originChainInfo, destinationChainInfo, version);
|
|
25
|
-
const beneficiary = (0, _xcmParser._getXcmBeneficiary)(destinationChainInfo, recipientAddress, version);
|
|
26
|
-
const tokenLocation = (0, _xcmParser._getXcmMultiAssets)(tokenInfo, value, version);
|
|
27
|
-
return api.tx.polkadotXcm[method](destination, beneficiary, tokenLocation, 0,
|
|
28
|
-
// FeeAssetItem
|
|
29
|
-
weightParam);
|
|
30
|
-
}
|