@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class MigrateTransactionHistoryBySymbol20251107 extends _Base.default {
|
|
13
|
+
async run() {
|
|
14
|
+
const state = this.state;
|
|
15
|
+
try {
|
|
16
|
+
const changeSlugsMap = {
|
|
17
|
+
'bittensor-LOCAL-ف': 'bittensor-LOCAL-ㄴ'
|
|
18
|
+
};
|
|
19
|
+
const allTxs = [];
|
|
20
|
+
await Promise.all(Object.entries(changeSlugsMap).map(async (_ref, i) => {
|
|
21
|
+
let [oldSlug, newSlug] = _ref;
|
|
22
|
+
const oldSlugSplit = oldSlug.split('-');
|
|
23
|
+
const oldChainSlug = oldSlugSplit[0];
|
|
24
|
+
const oldSymbolSlug = oldSlugSplit[2];
|
|
25
|
+
const newSlugSplit = newSlug.split('-');
|
|
26
|
+
const newSymbolSlug = newSlugSplit[2];
|
|
27
|
+
const filterTransactions = await state.dbService.stores.transaction.table.where({
|
|
28
|
+
chain: oldChainSlug
|
|
29
|
+
}).and(tx => {
|
|
30
|
+
var _tx$amount;
|
|
31
|
+
return ((_tx$amount = tx.amount) === null || _tx$amount === void 0 ? void 0 : _tx$amount.symbol) === oldSymbolSlug;
|
|
32
|
+
}).toArray();
|
|
33
|
+
if (filterTransactions.length > 0) {
|
|
34
|
+
for (const transaction of filterTransactions) {
|
|
35
|
+
if (transaction.amount && transaction.amount.symbol === oldSymbolSlug) {
|
|
36
|
+
transaction.amount.symbol = newSymbolSlug;
|
|
37
|
+
}
|
|
38
|
+
if (transaction.fee && transaction.fee.symbol === oldSymbolSlug) {
|
|
39
|
+
transaction.fee.symbol = newSymbolSlug;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
allTxs.push(...filterTransactions);
|
|
44
|
+
}));
|
|
45
|
+
await state.dbService.stores.transaction.table.bulkPut(allTxs);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
this.logger.error(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = MigrateTransactionHistoryBySymbol20251107;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class MigrateAssetSetting20251107 extends _Base.default {
|
|
13
|
+
async run() {
|
|
14
|
+
try {
|
|
15
|
+
const changeSlugsMap = {
|
|
16
|
+
'bittensor-LOCAL-ف': 'bittensor-LOCAL-ㄴ'
|
|
17
|
+
};
|
|
18
|
+
const assetSetting = await this.state.chainService.getAssetSettings();
|
|
19
|
+
const migratedAssetSetting = {};
|
|
20
|
+
for (const [oldSlug, newSlug] of Object.entries(changeSlugsMap)) {
|
|
21
|
+
if (Object.keys(assetSetting).includes(oldSlug)) {
|
|
22
|
+
const isVisible = assetSetting[oldSlug].visible;
|
|
23
|
+
migratedAssetSetting[newSlug] = {
|
|
24
|
+
visible: isVisible
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
this.state.chainService.setAssetSettings({
|
|
29
|
+
...assetSetting,
|
|
30
|
+
...migratedAssetSetting
|
|
31
|
+
});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.error(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = MigrateAssetSetting20251107;
|
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.MYTHOS_MIGRATION_KEY = exports.EVERYTIME = void 0;
|
|
8
|
+
var _MigrateAssetSetting = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/databases/MigrateAssetSetting20251107"));
|
|
8
9
|
var _MigrateChainPatrol = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/MigrateChainPatrol"));
|
|
10
|
+
var _MigrateTransactionHistoryBySymbol = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107"));
|
|
9
11
|
var _ClearMetadataDatabase = _interopRequireDefault(require("./databases/ClearMetadataDatabase"));
|
|
10
12
|
var _ClearMetadataForMythos = _interopRequireDefault(require("./databases/ClearMetadataForMythos"));
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
+
var _MigrateAssetSetting2 = _interopRequireDefault(require("./databases/MigrateAssetSetting"));
|
|
14
|
+
var _MigrateAssetSetting3 = _interopRequireDefault(require("./databases/MigrateAssetSetting20251027"));
|
|
13
15
|
var _MigrateEarningVersion = _interopRequireDefault(require("./databases/MigrateEarningVersion"));
|
|
14
16
|
var _ReloadMetadata = _interopRequireDefault(require("./databases/ReloadMetadata"));
|
|
15
17
|
var _MigrateLedgerAccount = _interopRequireDefault(require("./keyring/MigrateLedgerAccount"));
|
|
@@ -34,8 +36,8 @@ var _MigrateNewUnifiedAccount = _interopRequireDefault(require("./MigrateNewUnif
|
|
|
34
36
|
var _MigrateTokenDecimals = _interopRequireDefault(require("./MigrateTokenDecimals"));
|
|
35
37
|
var _MigrateTransactionHistory = _interopRequireDefault(require("./MigrateTransactionHistory"));
|
|
36
38
|
var _MigrateTransactionHistoryBridge = _interopRequireDefault(require("./MigrateTransactionHistoryBridge"));
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
+
var _MigrateTransactionHistoryBySymbol2 = _interopRequireDefault(require("./MigrateTransactionHistoryBySymbol"));
|
|
40
|
+
var _MigrateTransactionHistoryBySymbol3 = _interopRequireDefault(require("./MigrateTransactionHistoryBySymbol20251027"));
|
|
39
41
|
var _MigrateWalletReference = _interopRequireDefault(require("./MigrateWalletReference"));
|
|
40
42
|
var _OptimizeEnableToken = _interopRequireDefault(require("./OptimizeEnableToken"));
|
|
41
43
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -69,8 +71,8 @@ var _default = {
|
|
|
69
71
|
'1.1.33-01': _MigrateLedgerAccountV.default,
|
|
70
72
|
'1.1.41-01': _DeleteChainStaking.default,
|
|
71
73
|
// '1.1.46-01': AutoEnableSomeTokens,
|
|
72
|
-
'1.3.55-01':
|
|
73
|
-
'1.3.55-02':
|
|
74
|
+
'1.3.55-01': _MigrateAssetSetting2.default,
|
|
75
|
+
'1.3.55-02': _MigrateTransactionHistoryBySymbol2.default,
|
|
74
76
|
'1.2.69-01': _MigrateRemoveGenesisHash.default,
|
|
75
77
|
'1.2.13-01': _ReloadMetadata.default,
|
|
76
78
|
'1.2.32-01': _MigratePairData.default,
|
|
@@ -84,8 +86,10 @@ var _default = {
|
|
|
84
86
|
'1.3.54-01': _MigrateChainPatrol.default,
|
|
85
87
|
'1.3.62-01': _DeleteEarningData2.default,
|
|
86
88
|
'1.3.58-01': _OptimizeEnableToken.default,
|
|
87
|
-
'1.3.64-01':
|
|
88
|
-
'1.3.64-02':
|
|
89
|
-
'1.3.65-01': _DeleteEarningData3.default
|
|
89
|
+
'1.3.64-01': _MigrateAssetSetting3.default,
|
|
90
|
+
'1.3.64-02': _MigrateTransactionHistoryBySymbol3.default,
|
|
91
|
+
'1.3.65-01': _DeleteEarningData3.default,
|
|
92
|
+
'1.3.66-01': _MigrateAssetSetting.default,
|
|
93
|
+
'1.3.66-02': _MigrateTransactionHistoryBySymbol.default
|
|
90
94
|
};
|
|
91
95
|
exports.default = _default;
|
|
@@ -205,7 +205,7 @@ class EvmRequestHandler {
|
|
|
205
205
|
const params = {
|
|
206
206
|
...transaction,
|
|
207
207
|
gas: (0, _eth.anyNumberToBN)(gas).toNumber(),
|
|
208
|
-
value: (0, _eth.anyNumberToBN)(value).
|
|
208
|
+
value: (0, _eth.anyNumberToBN)(value).toFixed(),
|
|
209
209
|
gasPrice: (0, _eth.anyNumberToBN)(gasPrice).toNumber(),
|
|
210
210
|
gasLimit: (0, _eth.anyNumberToBN)(estimateGas).toNumber(),
|
|
211
211
|
maxFeePerGas: (0, _eth.anyNumberToBN)(maxFeePerGas).toNumber(),
|
|
@@ -306,21 +306,6 @@ class SwapBaseHandler {
|
|
|
306
306
|
txData: txData
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
|
-
async validateSetFeeTokenStep(params, stepIndex) {
|
|
310
|
-
if (!params.selectedQuote) {
|
|
311
|
-
return Promise.resolve([new _TransactionError.TransactionError(_types.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
312
|
-
}
|
|
313
|
-
const feeInfo = params.process.totalFee[stepIndex];
|
|
314
|
-
const feeAmount = feeInfo.feeComponent[0];
|
|
315
|
-
const feeTokenInfo = this.chainService.getAssetBySlug(feeInfo.defaultFeeToken);
|
|
316
|
-
const feeTokenBalance = await this.balanceService.getTransferableBalance(params.address, feeTokenInfo.originChain, feeTokenInfo.slug);
|
|
317
|
-
const bnFeeTokenBalance = new _bignumber.default(feeTokenBalance.value);
|
|
318
|
-
const bnFeeAmount = new _bignumber.default(feeAmount.amount);
|
|
319
|
-
if (bnFeeAmount.gte(bnFeeTokenBalance)) {
|
|
320
|
-
return Promise.resolve([new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_BALANCE)]);
|
|
321
|
-
}
|
|
322
|
-
return [];
|
|
323
|
-
}
|
|
324
309
|
async validateBridgeStep(request) {
|
|
325
310
|
const {
|
|
326
311
|
bnBridgeAmount,
|
|
@@ -385,7 +370,7 @@ class SwapBaseHandler {
|
|
|
385
370
|
const xcmRequest = {
|
|
386
371
|
originTokenInfo: fromToken,
|
|
387
372
|
destinationTokenInfo: toToken,
|
|
388
|
-
sendingValue: bnBridgeAmount.
|
|
373
|
+
sendingValue: bnBridgeAmount.toFixed(),
|
|
389
374
|
recipient: receiver,
|
|
390
375
|
substrateApi: substrateApi,
|
|
391
376
|
sender: sender,
|
|
@@ -393,11 +378,23 @@ class SwapBaseHandler {
|
|
|
393
378
|
originChain: fromChain,
|
|
394
379
|
feeInfo
|
|
395
380
|
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
381
|
+
if (isFirstBridge) {
|
|
382
|
+
const isDryRunSuccess = await (0, _xcm.dryRunXcmExtrinsicV2)(xcmRequest, false);
|
|
383
|
+
if (!isDryRunSuccess) {
|
|
384
|
+
return [new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
const isDryRunPreviewSuccess = await (0, _xcm.dryRunXcmExtrinsicV2)(xcmRequest, true);
|
|
388
|
+
const originFee = await (0, _xcm.getXcmOriginFee)(xcmRequest);
|
|
389
|
+
if (originFee) {
|
|
390
|
+
const isBridgeTokenNativeBalanceEnough = bnFeeTokenBalance.gte(originFee);
|
|
391
|
+
if (!isBridgeTokenNativeBalanceEnough) {
|
|
392
|
+
return [new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (!isDryRunPreviewSuccess) {
|
|
396
|
+
return [new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SEND, 'Swap amount too small. Increase amount and try again')];
|
|
397
|
+
}
|
|
401
398
|
}
|
|
402
399
|
}
|
|
403
400
|
return [];
|
|
@@ -1430,7 +1430,7 @@ class TransactionService {
|
|
|
1430
1430
|
maxPriorityFeePerGas: (0, _utils4.anyNumberToBN)(payload.maxPriorityFeePerGas).toNumber(),
|
|
1431
1431
|
gasLimit: (0, _utils4.anyNumberToBN)(payload.gas).toNumber(),
|
|
1432
1432
|
to: payload.to,
|
|
1433
|
-
value: (0, _utils4.anyNumberToBN)(payload.value).
|
|
1433
|
+
value: (0, _utils4.anyNumberToBN)(payload.value).toFixed(),
|
|
1434
1434
|
data: payload.data,
|
|
1435
1435
|
chainId: payload.chainId
|
|
1436
1436
|
};
|
package/cjs/utils/eth.js
CHANGED
|
@@ -33,12 +33,13 @@ class Transaction {
|
|
|
33
33
|
}
|
|
34
34
|
exports.Transaction = Transaction;
|
|
35
35
|
const anyNumberToBN = value => {
|
|
36
|
+
// TODO: Be careful when using .toNumber() outside this function. It may not round exactly for very large numbers.
|
|
36
37
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
37
38
|
return new _bignumber.default(value);
|
|
38
39
|
} else if (typeof value === 'undefined') {
|
|
39
40
|
return new _bignumber.default(0);
|
|
40
41
|
} else {
|
|
41
|
-
return new _bignumber.default(value.
|
|
42
|
+
return new _bignumber.default(value.toString());
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
exports.anyNumberToBN = anyNumberToBN;
|
|
@@ -202,9 +202,13 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
202
202
|
var _tx$gas;
|
|
203
203
|
// Calculate fee for evm transaction
|
|
204
204
|
const tx = transaction;
|
|
205
|
-
|
|
205
|
+
let gasLimit = ((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.toString()) || (await evmApi.api.eth.estimateGas(tx)).toString();
|
|
206
206
|
const _feeCustom = feeCustom;
|
|
207
207
|
const combineFee = (0, _combine.combineEthFee)(fee, feeOption, _feeCustom);
|
|
208
|
+
if (srcChain.slug === 'energy_web_chain') {
|
|
209
|
+
gasLimit = _smartContract.gasSettingsForEWC.gasLimit.toString();
|
|
210
|
+
combineFee.maxFeePerGas = _smartContract.gasSettingsForEWC.maxFeePerGas;
|
|
211
|
+
}
|
|
208
212
|
if (combineFee.maxFeePerGas) {
|
|
209
213
|
estimatedFee = new _bignumber.default(combineFee.maxFeePerGas).multipliedBy(gasLimit).toFixed(0);
|
|
210
214
|
} else {
|
|
@@ -396,7 +400,6 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
396
400
|
funcCreateExtrinsic = _xcm.createAvailBridgeExtrinsicFromAvail;
|
|
397
401
|
} else {
|
|
398
402
|
funcCreateExtrinsic = _xcm.createXcmExtrinsicV2;
|
|
399
|
-
params.sendingValue = '1';
|
|
400
403
|
}
|
|
401
404
|
const extrinsic = await funcCreateExtrinsic(params);
|
|
402
405
|
|
|
@@ -1,52 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _Address } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
-
export declare function _getXcmDestWeight(originChainInfo: _ChainInfo): "Unlimited" | 5000000000;
|
|
4
|
-
export declare function _getXcmBeneficiary(destChainInfo: _ChainInfo, recipient: _Address, version: number): {
|
|
5
|
-
[x: string]: {
|
|
6
|
-
parents: number;
|
|
7
|
-
interior: {
|
|
8
|
-
X1: {
|
|
9
|
-
AccountId32: {
|
|
10
|
-
network: string | undefined;
|
|
11
|
-
id: Uint8Array;
|
|
12
|
-
};
|
|
13
|
-
AccountKey20?: undefined;
|
|
14
|
-
} | {
|
|
15
|
-
AccountKey20: {
|
|
16
|
-
network: string | undefined;
|
|
17
|
-
key: string;
|
|
18
|
-
};
|
|
19
|
-
AccountId32?: undefined;
|
|
20
|
-
} | ({
|
|
21
|
-
AccountId32: {
|
|
22
|
-
network: string | undefined;
|
|
23
|
-
id: Uint8Array;
|
|
24
|
-
};
|
|
25
|
-
AccountKey20?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
AccountKey20: {
|
|
28
|
-
network: string | undefined;
|
|
29
|
-
key: string;
|
|
30
|
-
};
|
|
31
|
-
AccountId32?: undefined;
|
|
32
|
-
})[];
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare function _getXcmMultiAssets(tokenInfo: _ChainAsset, value: string, version: number): {
|
|
37
|
-
[x: string]: {
|
|
38
|
-
id: Record<string, any>;
|
|
39
|
-
fun: {
|
|
40
|
-
Fungible: string;
|
|
41
|
-
};
|
|
42
|
-
}[];
|
|
43
|
-
};
|
|
44
|
-
export declare function _getXcmMultiLocation(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, version: number, recipient?: _Address): {
|
|
45
|
-
[x: string]: {
|
|
46
|
-
parents: number;
|
|
47
|
-
interior: unknown;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
1
|
+
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
50
2
|
export declare function _isXcmTransferUnstable(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): boolean;
|
|
51
3
|
export declare function _getXcmUnstableWarning(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): string;
|
|
52
4
|
export declare function _isXcmWithinSameConsensus(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
@@ -6,50 +6,7 @@ import { _isAcrossChainBridge } from '@subwallet/extension-base/services/balance
|
|
|
6
6
|
import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
7
7
|
import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
8
8
|
import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
9
|
-
import {
|
|
10
|
-
import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
|
|
11
|
-
const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
|
|
12
|
-
const UNLIMITED_WEIGHT = 'Unlimited';
|
|
13
|
-
export function _getXcmDestWeight(originChainInfo) {
|
|
14
|
-
if (['pioneer'].includes(originChainInfo.slug)) {
|
|
15
|
-
return FOUR_INSTRUCTIONS_WEIGHT;
|
|
16
|
-
}
|
|
17
|
-
return UNLIMITED_WEIGHT;
|
|
18
|
-
}
|
|
19
|
-
export function _getXcmBeneficiary(destChainInfo, recipient, version) {
|
|
20
|
-
const receiverLocation = version < 4 // from V4, X1 is also an array
|
|
21
|
-
? _getRecipientLocation(destChainInfo, recipient, version) : [_getRecipientLocation(destChainInfo, recipient, version)];
|
|
22
|
-
return {
|
|
23
|
-
[`V${version}`]: {
|
|
24
|
-
parents: 0,
|
|
25
|
-
interior: {
|
|
26
|
-
X1: receiverLocation
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export function _getXcmMultiAssets(tokenInfo, value, version) {
|
|
32
|
-
const assetId = _getAssetIdentifier(tokenInfo, version);
|
|
33
|
-
return {
|
|
34
|
-
[`V${version}`]: [{
|
|
35
|
-
id: assetId,
|
|
36
|
-
fun: {
|
|
37
|
-
Fungible: value
|
|
38
|
-
}
|
|
39
|
-
}]
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function _getXcmMultiLocation(originChainInfo, destChainInfo, version, recipient) {
|
|
43
|
-
const isWithinSameConsensus = _isXcmWithinSameConsensus(originChainInfo, destChainInfo);
|
|
44
|
-
const parents = _getMultiLocationParent(originChainInfo, isWithinSameConsensus);
|
|
45
|
-
const interior = _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient);
|
|
46
|
-
return {
|
|
47
|
-
[`V${version}`]: {
|
|
48
|
-
parents,
|
|
49
|
-
interior
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
9
|
+
import { _getSubstrateRelayParent, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
53
10
|
export function _isXcmTransferUnstable(originChainInfo, destChainInfo, assetSlug) {
|
|
54
11
|
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo) || _isPosBridgeXcm(originChainInfo, destChainInfo);
|
|
55
12
|
}
|
|
@@ -133,123 +90,6 @@ export function _isAcrossBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
133
90
|
}
|
|
134
91
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
135
92
|
|
|
136
|
-
function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
|
|
137
|
-
let parent = 0; // how many hops up the hierarchy
|
|
138
|
-
|
|
139
|
-
if (_isSubstrateParaChain(originChainInfo)) {
|
|
140
|
-
parent += 1;
|
|
141
|
-
}
|
|
142
|
-
if (!isWithinSameConsensus) {
|
|
143
|
-
parent += 1;
|
|
144
|
-
}
|
|
145
|
-
return parent;
|
|
146
|
-
}
|
|
147
|
-
function _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient) {
|
|
148
|
-
const junctions = [];
|
|
149
|
-
if (isWithinSameConsensus) {
|
|
150
|
-
if (_isSubstrateParaChain(destChainInfo)) {
|
|
151
|
-
junctions.push({
|
|
152
|
-
Parachain: _getSubstrateParaId(destChainInfo)
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
junctions.push({
|
|
157
|
-
GlobalConsensus: _getGlobalConsensusJunction(destChainInfo, version)
|
|
158
|
-
});
|
|
159
|
-
if (_isSubstrateParaChain(destChainInfo)) {
|
|
160
|
-
junctions.push({
|
|
161
|
-
Parachain: _getSubstrateParaId(destChainInfo)
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (recipient) {
|
|
166
|
-
junctions.push(_getRecipientLocation(destChainInfo, recipient, version));
|
|
167
|
-
}
|
|
168
|
-
if (junctions.length === 0 && !recipient) {
|
|
169
|
-
return 'Here';
|
|
170
|
-
}
|
|
171
|
-
if (version < 4 && junctions.length === 1) {
|
|
172
|
-
return {
|
|
173
|
-
X1: junctions[0]
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
[`X${junctions.length}`]: junctions
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function _getGlobalConsensusJunction(destChainInfo, version) {
|
|
181
|
-
let chainSlug = destChainInfo.slug;
|
|
182
|
-
let evmChainId;
|
|
183
|
-
if (_isSubstrateParaChain(destChainInfo)) {
|
|
184
|
-
const relaySlug = _getSubstrateRelayParent(destChainInfo);
|
|
185
|
-
if (!relaySlug) {
|
|
186
|
-
throw Error('Parachain must have a parent chainSlug');
|
|
187
|
-
}
|
|
188
|
-
chainSlug = relaySlug;
|
|
189
|
-
} else {
|
|
190
|
-
evmChainId = _getEvmChainId(destChainInfo);
|
|
191
|
-
}
|
|
192
|
-
if (evmChainId) {
|
|
193
|
-
return {
|
|
194
|
-
Ethereum: {
|
|
195
|
-
chainId: evmChainId
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
switch (chainSlug) {
|
|
200
|
-
case COMMON_CHAIN_SLUGS.POLKADOT:
|
|
201
|
-
return version < 4 ? {
|
|
202
|
-
Polkadot: null
|
|
203
|
-
} : 'Polkadot';
|
|
204
|
-
case COMMON_CHAIN_SLUGS.KUSAMA:
|
|
205
|
-
return version < 4 ? {
|
|
206
|
-
Kusama: null
|
|
207
|
-
} : 'Kusama';
|
|
208
|
-
default:
|
|
209
|
-
return version < 4 ? {
|
|
210
|
-
Rococo: null
|
|
211
|
-
} : 'Rococo';
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function _getRecipientLocation(destChainInfo, recipient, version) {
|
|
215
|
-
const network = _getNetworkByVersion(version);
|
|
216
|
-
if (destChainInfo.slug === COMMON_CHAIN_SLUGS.ASTAR_EVM) {
|
|
217
|
-
const ss58Address = evmToAddress(recipient, _getChainSubstrateAddressPrefix(destChainInfo)); // TODO: shouldn't pass addressPrefix directly
|
|
218
|
-
|
|
219
|
-
return {
|
|
220
|
-
AccountId32: {
|
|
221
|
-
network,
|
|
222
|
-
id: decodeAddress(ss58Address)
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
if (_isChainEvmCompatible(destChainInfo)) {
|
|
227
|
-
return {
|
|
228
|
-
AccountKey20: {
|
|
229
|
-
network,
|
|
230
|
-
key: recipient
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
AccountId32: {
|
|
236
|
-
network,
|
|
237
|
-
id: decodeAddress(recipient)
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function _getAssetIdentifier(tokenInfo, version) {
|
|
242
|
-
const _assetIdentifier = _getXcmAssetMultilocation(tokenInfo);
|
|
243
|
-
if (!_assetIdentifier) {
|
|
244
|
-
throw new Error('Asset must have multilocation');
|
|
245
|
-
}
|
|
246
|
-
const assetIdentifier = ['statemint-LOCAL-KSM', 'statemine-LOCAL-DOT'].includes(tokenInfo.slug) // todo: hotfix for ksm statemint recheck all chain
|
|
247
|
-
? _assetIdentifier : _adaptX1Interior(_assetIdentifier, version);
|
|
248
|
-
return version >= 4 // from V4, Concrete is removed
|
|
249
|
-
? assetIdentifier : {
|
|
250
|
-
Concrete: assetIdentifier
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
93
|
export function _adaptX1Interior(_assetIdentifier, version) {
|
|
254
94
|
const assetIdentifier = structuredClone(_assetIdentifier);
|
|
255
95
|
const interior = assetIdentifier.interior;
|
|
@@ -262,16 +102,4 @@ export function _adaptX1Interior(_assetIdentifier, version) {
|
|
|
262
102
|
interior.X1 = interior.X1[0];
|
|
263
103
|
}
|
|
264
104
|
return assetIdentifier;
|
|
265
|
-
}
|
|
266
|
-
function _getNetworkByVersion(version) {
|
|
267
|
-
switch (version) {
|
|
268
|
-
case 1:
|
|
269
|
-
case 2:
|
|
270
|
-
return 'Any';
|
|
271
|
-
case 3:
|
|
272
|
-
case 4:
|
|
273
|
-
return undefined;
|
|
274
|
-
default:
|
|
275
|
-
return undefined;
|
|
276
|
-
}
|
|
277
105
|
}
|
|
@@ -1644,7 +1644,7 @@ export default class KoniExtension {
|
|
|
1644
1644
|
error.length && inputTransaction.errors.push(...error);
|
|
1645
1645
|
}
|
|
1646
1646
|
if (isSubstrateXcm) {
|
|
1647
|
-
const isDryRunSuccess = await dryRunXcmExtrinsicV2(params);
|
|
1647
|
+
const isDryRunSuccess = await dryRunXcmExtrinsicV2(params, false);
|
|
1648
1648
|
if (!isDryRunSuccess) {
|
|
1649
1649
|
inputTransaction.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Unable to perform transaction. Select another token or destination chain and try again'));
|
|
1650
1650
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.67-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -799,11 +799,6 @@
|
|
|
799
799
|
"require": "./cjs/services/balance-service/transfer/xcm/availBridge.js",
|
|
800
800
|
"default": "./services/balance-service/transfer/xcm/availBridge.js"
|
|
801
801
|
},
|
|
802
|
-
"./services/balance-service/transfer/xcm/polkadotXcm": {
|
|
803
|
-
"types": "./services/balance-service/transfer/xcm/polkadotXcm.d.ts",
|
|
804
|
-
"require": "./cjs/services/balance-service/transfer/xcm/polkadotXcm.js",
|
|
805
|
-
"default": "./services/balance-service/transfer/xcm/polkadotXcm.js"
|
|
806
|
-
},
|
|
807
802
|
"./services/balance-service/transfer/xcm/polygonBridge": {
|
|
808
803
|
"types": "./services/balance-service/transfer/xcm/polygonBridge.d.ts",
|
|
809
804
|
"require": "./cjs/services/balance-service/transfer/xcm/polygonBridge.js",
|
|
@@ -824,16 +819,6 @@
|
|
|
824
819
|
"require": "./cjs/services/balance-service/transfer/xcm/utils.js",
|
|
825
820
|
"default": "./services/balance-service/transfer/xcm/utils.js"
|
|
826
821
|
},
|
|
827
|
-
"./services/balance-service/transfer/xcm/xcmPallet": {
|
|
828
|
-
"types": "./services/balance-service/transfer/xcm/xcmPallet.d.ts",
|
|
829
|
-
"require": "./cjs/services/balance-service/transfer/xcm/xcmPallet.js",
|
|
830
|
-
"default": "./services/balance-service/transfer/xcm/xcmPallet.js"
|
|
831
|
-
},
|
|
832
|
-
"./services/balance-service/transfer/xcm/xTokens": {
|
|
833
|
-
"types": "./services/balance-service/transfer/xcm/xTokens.d.ts",
|
|
834
|
-
"require": "./cjs/services/balance-service/transfer/xcm/xTokens.js",
|
|
835
|
-
"default": "./services/balance-service/transfer/xcm/xTokens.js"
|
|
836
|
-
},
|
|
837
822
|
"./services/base/types": {
|
|
838
823
|
"types": "./services/base/types.d.ts",
|
|
839
824
|
"require": "./cjs/services/base/types.js",
|
|
@@ -1491,6 +1476,11 @@
|
|
|
1491
1476
|
"require": "./cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251027.js",
|
|
1492
1477
|
"default": "./services/migration-service/scripts/databases/MigrateAssetSetting20251027.js"
|
|
1493
1478
|
},
|
|
1479
|
+
"./services/migration-service/scripts/databases/MigrateAssetSetting20251107": {
|
|
1480
|
+
"types": "./services/migration-service/scripts/databases/MigrateAssetSetting20251107.d.ts",
|
|
1481
|
+
"require": "./cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251107.js",
|
|
1482
|
+
"default": "./services/migration-service/scripts/databases/MigrateAssetSetting20251107.js"
|
|
1483
|
+
},
|
|
1494
1484
|
"./services/migration-service/scripts/databases/MigrateEarningHistory": {
|
|
1495
1485
|
"types": "./services/migration-service/scripts/databases/MigrateEarningHistory.d.ts",
|
|
1496
1486
|
"require": "./cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js",
|
|
@@ -1631,6 +1621,11 @@
|
|
|
1631
1621
|
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251027.js",
|
|
1632
1622
|
"default": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251027.js"
|
|
1633
1623
|
},
|
|
1624
|
+
"./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107": {
|
|
1625
|
+
"types": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.d.ts",
|
|
1626
|
+
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js",
|
|
1627
|
+
"default": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js"
|
|
1628
|
+
},
|
|
1634
1629
|
"./services/migration-service/scripts/MigrateWalletReference": {
|
|
1635
1630
|
"types": "./services/migration-service/scripts/MigrateWalletReference.d.ts",
|
|
1636
1631
|
"require": "./cjs/services/migration-service/scripts/MigrateWalletReference.js",
|
|
@@ -2908,16 +2903,16 @@
|
|
|
2908
2903
|
"@polkadot/util-crypto": "^13.5.3",
|
|
2909
2904
|
"@polkadot/x-global": "^13.5.3",
|
|
2910
2905
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2911
|
-
"@snowbridge/api": "^0.2.
|
|
2906
|
+
"@snowbridge/api": "^0.2.13",
|
|
2912
2907
|
"@snowbridge/registry": "^0.2.0",
|
|
2913
2908
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2914
2909
|
"@substrate/connect": "^0.8.9",
|
|
2915
2910
|
"@subwallet-monorepos/subwallet-services-sdk": "0.1.13",
|
|
2916
|
-
"@subwallet/chain-list": "0.2.
|
|
2917
|
-
"@subwallet/extension-base": "^1.3.
|
|
2918
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2919
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2920
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2911
|
+
"@subwallet/chain-list": "0.2.121",
|
|
2912
|
+
"@subwallet/extension-base": "^1.3.67-0",
|
|
2913
|
+
"@subwallet/extension-chains": "^1.3.67-0",
|
|
2914
|
+
"@subwallet/extension-dapp": "^1.3.67-0",
|
|
2915
|
+
"@subwallet/extension-inject": "^1.3.67-0",
|
|
2921
2916
|
"@subwallet/keyring": "^0.1.13",
|
|
2922
2917
|
"@subwallet/ui-keyring": "^0.1.13",
|
|
2923
2918
|
"@ton/core": "^0.56.3",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.67-0'
|
|
11
11
|
};
|
|
@@ -12,6 +12,10 @@ interface TransferEvmProps extends TransactionFee {
|
|
|
12
12
|
fallbackFee?: boolean;
|
|
13
13
|
data?: string;
|
|
14
14
|
}
|
|
15
|
+
export declare const gasSettingsForEWC: {
|
|
16
|
+
gasLimit: number;
|
|
17
|
+
maxFeePerGas: string;
|
|
18
|
+
};
|
|
15
19
|
export declare function getEVMTransactionObject(props: TransferEvmProps): Promise<[TransactionConfig, string, string]>;
|
|
16
20
|
export declare function getERC20TransactionObject(props: TransferERC20Props): Promise<[TransactionConfig, string, string]>;
|
|
17
21
|
interface TransferERC20Props extends TransactionFee {
|