@subwallet/extension-base 1.3.23-0 → 1.3.24-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 +2 -2
- package/cjs/constants/environment.js +1 -1
- package/cjs/constants/index.js +21 -4
- package/cjs/core/logic-validation/transfer.js +23 -8
- package/cjs/koni/background/handlers/Extension.js +109 -89
- package/cjs/koni/background/handlers/State.js +2 -2
- package/cjs/koni/background/handlers/Tabs.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/smart-contract.js +24 -3
- package/cjs/services/chain-service/index.js +11 -0
- package/cjs/services/fee-service/utils/tokenPayFee.js +151 -0
- package/cjs/services/request-service/handler/MetadataRequestHandler.js +5 -13
- package/cjs/services/request-service/index.js +2 -2
- package/cjs/services/transaction-service/index.js +8 -5
- package/cjs/utils/fee/transfer.js +47 -14
- package/constants/environment.js +1 -1
- package/constants/index.d.ts +6 -1
- package/constants/index.js +14 -1
- package/core/logic-validation/transfer.d.ts +1 -1
- package/core/logic-validation/transfer.js +25 -10
- package/koni/background/handlers/Extension.js +82 -62
- package/koni/background/handlers/State.d.ts +1 -1
- package/koni/background/handlers/State.js +2 -2
- package/koni/background/handlers/Tabs.js +1 -1
- package/package.json +11 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/smart-contract.d.ts +4 -2
- package/services/balance-service/transfer/smart-contract.js +24 -3
- package/services/chain-service/index.d.ts +1 -0
- package/services/chain-service/index.js +12 -1
- package/services/fee-service/interfaces.d.ts +25 -0
- package/services/fee-service/utils/tokenPayFee.d.ts +8 -0
- package/services/fee-service/utils/tokenPayFee.js +141 -0
- package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -1
- package/services/request-service/handler/MetadataRequestHandler.js +5 -13
- package/services/request-service/index.d.ts +1 -1
- package/services/request-service/index.js +2 -2
- package/services/transaction-service/index.js +10 -7
- package/types/fee/option.d.ts +1 -1
- package/utils/fee/transfer.d.ts +1 -1
- package/utils/fee/transfer.js +46 -13
|
@@ -41,27 +41,27 @@ var _constants2 = require("@subwallet/extension-base/services/chain-service/cons
|
|
|
41
41
|
var _types2 = require("@subwallet/extension-base/services/chain-service/types");
|
|
42
42
|
var _utils4 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
43
43
|
var _utils5 = require("@subwallet/extension-base/services/fee-service/utils");
|
|
44
|
+
var _tokenPayFee = require("@subwallet/extension-base/services/fee-service/utils/tokenPayFee");
|
|
44
45
|
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
45
46
|
var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
46
|
-
var _utils6 = require("@subwallet/extension-base/services/swap-service/handler/asset-hub/utils");
|
|
47
47
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
48
48
|
var _storage = require("@subwallet/extension-base/storage");
|
|
49
49
|
var _stores = require("@subwallet/extension-base/stores");
|
|
50
50
|
var _types3 = require("@subwallet/extension-base/types");
|
|
51
|
-
var
|
|
51
|
+
var _utils6 = require("@subwallet/extension-base/utils");
|
|
52
52
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
53
53
|
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
54
54
|
var _keyring = require("@subwallet/keyring");
|
|
55
55
|
var _types4 = require("@subwallet/keyring/types");
|
|
56
56
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
57
|
-
var
|
|
57
|
+
var _utils7 = require("@walletconnect/utils");
|
|
58
58
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
59
59
|
var _i18next = require("i18next");
|
|
60
60
|
var _rxjs = require("rxjs");
|
|
61
61
|
var _types5 = require("@polkadot/types");
|
|
62
62
|
var _util = require("@polkadot/util");
|
|
63
63
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
64
|
-
var
|
|
64
|
+
var _utils8 = require("../utils");
|
|
65
65
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
66
66
|
// SPDX-License-Identifier: Apache-2.0
|
|
67
67
|
|
|
@@ -276,7 +276,7 @@ class KoniExtension {
|
|
|
276
276
|
const accounts = keyringService.context.accounts;
|
|
277
277
|
const transformedAccounts = Object.values(accounts);
|
|
278
278
|
const responseData = {
|
|
279
|
-
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0,
|
|
279
|
+
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0, _utils6.combineAllAccountProxy)(transformedAccounts), ...transformedAccounts] : [],
|
|
280
280
|
currentAccountProxy: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.proxyId
|
|
281
281
|
};
|
|
282
282
|
const accountProxyMapObservable = keyringService.context.observable.accounts;
|
|
@@ -290,7 +290,7 @@ class KoniExtension {
|
|
|
290
290
|
currentAccount
|
|
291
291
|
} = _ref7;
|
|
292
292
|
const transformedAccounts = Object.values(accountProxies);
|
|
293
|
-
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0,
|
|
293
|
+
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0, _utils6.combineAllAccountProxy)(transformedAccounts), ...transformedAccounts] : [];
|
|
294
294
|
responseData.currentAccountProxy = currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.proxyId;
|
|
295
295
|
console.debug('subscriptionAccountGroups', responseData);
|
|
296
296
|
cb(responseData);
|
|
@@ -311,10 +311,10 @@ class KoniExtension {
|
|
|
311
311
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
312
312
|
const combineFunction = async (chainInfoMap, accountProxyMap, _contacts) => {
|
|
313
313
|
const accountProxies = Object.values(accountProxyMap);
|
|
314
|
-
const contacts = (0,
|
|
314
|
+
const contacts = (0, _utils6.transformAddresses)(_contacts);
|
|
315
315
|
const chainInfo = chainInfoMap[chain];
|
|
316
316
|
const substrateApi = this.#koniState.chainService.getSubstrateApi(chain);
|
|
317
|
-
const rs = await (0,
|
|
317
|
+
const rs = await (0, _utils6._analyzeAddress)(data, accountProxies, contacts, chainInfo, substrateApi);
|
|
318
318
|
return {
|
|
319
319
|
id,
|
|
320
320
|
...rs
|
|
@@ -354,7 +354,7 @@ class KoniExtension {
|
|
|
354
354
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
355
355
|
let old = '';
|
|
356
356
|
const subscription = this.#koniState.keyringService.context.observable.contacts.subscribe(subjectInfo => {
|
|
357
|
-
const addresses = (0,
|
|
357
|
+
const addresses = (0, _utils6.transformAddresses)(subjectInfo);
|
|
358
358
|
const _new = JSON.stringify(addresses);
|
|
359
359
|
if (old !== _new) {
|
|
360
360
|
_cb({
|
|
@@ -371,7 +371,7 @@ class KoniExtension {
|
|
|
371
371
|
});
|
|
372
372
|
const subjectInfo = this.#koniState.keyringService.context.contacts;
|
|
373
373
|
return {
|
|
374
|
-
addresses: (0,
|
|
374
|
+
addresses: (0, _utils6.transformAccounts)(subjectInfo)
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
|
|
@@ -384,7 +384,7 @@ class KoniExtension {
|
|
|
384
384
|
chain
|
|
385
385
|
} = _ref9;
|
|
386
386
|
if ((0, _keyring.isAddress)(accountId)) {
|
|
387
|
-
const address = (0,
|
|
387
|
+
const address = (0, _utils6.reformatAddress)(accountId);
|
|
388
388
|
const account = _uiKeyring.keyring.getAccount(address);
|
|
389
389
|
const contact = _uiKeyring.keyring.getAddress(address, 'address');
|
|
390
390
|
if (account) {
|
|
@@ -430,7 +430,7 @@ class KoniExtension {
|
|
|
430
430
|
meta
|
|
431
431
|
} = _ref10;
|
|
432
432
|
if ((0, _keyring.isAddress)(address)) {
|
|
433
|
-
const _address = (0,
|
|
433
|
+
const _address = (0, _utils6.reformatAddress)(address);
|
|
434
434
|
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
435
435
|
return true;
|
|
436
436
|
} else {
|
|
@@ -446,7 +446,7 @@ class KoniExtension {
|
|
|
446
446
|
address
|
|
447
447
|
} = _ref11;
|
|
448
448
|
if ((0, _keyring.isAddress)(address)) {
|
|
449
|
-
const _address = (0,
|
|
449
|
+
const _address = (0, _utils6.reformatAddress)(address);
|
|
450
450
|
_uiKeyring.keyring.forgetAddress(_address);
|
|
451
451
|
return true;
|
|
452
452
|
} else {
|
|
@@ -575,7 +575,7 @@ class KoniExtension {
|
|
|
575
575
|
}
|
|
576
576
|
getPairs() {
|
|
577
577
|
const storedAccounts = this.#koniState.keyringService.context.pairs;
|
|
578
|
-
return (0,
|
|
578
|
+
return (0, _utils6.transformAccounts)(storedAccounts);
|
|
579
579
|
}
|
|
580
580
|
isAddressValidWithAuthType(address, accountAuthTypes) {
|
|
581
581
|
const type = (0, _keyring.getKeypairTypeByAddress)(address);
|
|
@@ -1109,7 +1109,7 @@ class KoniExtension {
|
|
|
1109
1109
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1110
1110
|
|
|
1111
1111
|
// Re-filter
|
|
1112
|
-
cb(histories.filter(item => addresses.some(address => (0,
|
|
1112
|
+
cb(histories.filter(item => addresses.some(address => (0, _utils6.isSameAddress)(item.address, address))));
|
|
1113
1113
|
});
|
|
1114
1114
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1115
1115
|
port.onDisconnect.addListener(() => {
|
|
@@ -1118,7 +1118,7 @@ class KoniExtension {
|
|
|
1118
1118
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1119
1119
|
|
|
1120
1120
|
// Re-filter
|
|
1121
|
-
return historySubject.getValue().filter(item => addresses.some(address => (0,
|
|
1121
|
+
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils6.isSameAddress)(item.address, address)));
|
|
1122
1122
|
}
|
|
1123
1123
|
subscribeHistoryByChainAndAddress(_ref29, id, port) {
|
|
1124
1124
|
let {
|
|
@@ -1174,8 +1174,8 @@ class KoniExtension {
|
|
|
1174
1174
|
feeCustom,
|
|
1175
1175
|
feeOption,
|
|
1176
1176
|
from,
|
|
1177
|
-
nonNativeTokenPayFeeSlug,
|
|
1178
1177
|
to,
|
|
1178
|
+
tokenPayFeeSlug,
|
|
1179
1179
|
tokenSlug,
|
|
1180
1180
|
transferAll,
|
|
1181
1181
|
transferBounceable,
|
|
@@ -1188,7 +1188,9 @@ class KoniExtension {
|
|
|
1188
1188
|
const nativeTokenInfo = this.#koniState.getNativeTokenInfo(chain);
|
|
1189
1189
|
const nativeTokenSlug = nativeTokenInfo.slug;
|
|
1190
1190
|
const isTransferNativeToken = nativeTokenSlug === tokenSlug;
|
|
1191
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken &&
|
|
1191
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken && tokenPayFeeSlug === tokenSlug;
|
|
1192
|
+
const isCustomTokenPayFeeAssetHub = tokenPayFeeSlug && !(0, _utils4._isNativeTokenBySlug)(tokenPayFeeSlug) && _constants._SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain);
|
|
1193
|
+
const isCustomTokenPayFeeHydration = tokenPayFeeSlug && !(0, _utils4._isNativeTokenBySlug)(tokenPayFeeSlug) && _constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain);
|
|
1192
1194
|
const extrinsicType = isTransferNativeToken ? _KoniTypes.ExtrinsicType.TRANSFER_BALANCE : _KoniTypes.ExtrinsicType.TRANSFER_TOKEN;
|
|
1193
1195
|
let chainType = _KoniTypes.ChainType.SUBSTRATE;
|
|
1194
1196
|
const transferAmount = {
|
|
@@ -1279,6 +1281,13 @@ class KoniExtension {
|
|
|
1279
1281
|
to: to,
|
|
1280
1282
|
substrateApi
|
|
1281
1283
|
});
|
|
1284
|
+
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
1285
|
+
var _this$koniState$chain, _substrateApi$api$que;
|
|
1286
|
+
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain === void 0 ? void 0 : _this$koniState$chain.assetId);
|
|
1287
|
+
const _feeSetting = await ((_substrateApi$api$que = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.accountCurrencyMap(from));
|
|
1288
|
+
const feeSetting = _feeSetting.toPrimitive();
|
|
1289
|
+
transaction = (0, _tokenPayFee.batchExtrinsicSetFeeHydration)(substrateApi, transaction, feeSetting, hydrationFeeAssetId);
|
|
1290
|
+
}
|
|
1282
1291
|
}
|
|
1283
1292
|
} catch (e) {
|
|
1284
1293
|
const error = e;
|
|
@@ -1296,11 +1305,11 @@ class KoniExtension {
|
|
|
1296
1305
|
}
|
|
1297
1306
|
|
|
1298
1307
|
// Check enough free local to pay fee local
|
|
1299
|
-
if (
|
|
1300
|
-
var _inputTransaction$est;
|
|
1308
|
+
if (isCustomTokenPayFeeAssetHub || isCustomTokenPayFeeHydration) {
|
|
1309
|
+
var _inputTransaction$est, _nonNativeTokenPayFee;
|
|
1301
1310
|
const nonNativeFee = BigInt(((_inputTransaction$est = inputTransaction.estimateFee) === null || _inputTransaction$est === void 0 ? void 0 : _inputTransaction$est.value) || '0'); // todo: estimateFee should be must-have, need to refactor interface
|
|
1302
|
-
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance((0,
|
|
1303
|
-
const nonNativeTokenPayFeeBalance = BigInt(nonNativeTokenPayFeeInfo[
|
|
1311
|
+
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance((0, _utils6.reformatAddress)(from), chain, tokenPayFeeSlug);
|
|
1312
|
+
const nonNativeTokenPayFeeBalance = BigInt(((_nonNativeTokenPayFee = nonNativeTokenPayFeeInfo[tokenPayFeeSlug]) === null || _nonNativeTokenPayFee === void 0 ? void 0 : _nonNativeTokenPayFee.free) || '0');
|
|
1304
1313
|
if (nonNativeFee > nonNativeTokenPayFeeBalance) {
|
|
1305
1314
|
inputTransaction.errors.push(new _TransactionError.TransactionError(_types3.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
1306
1315
|
}
|
|
@@ -1352,7 +1361,7 @@ class KoniExtension {
|
|
|
1352
1361
|
chain,
|
|
1353
1362
|
feeCustom,
|
|
1354
1363
|
feeOption,
|
|
1355
|
-
|
|
1364
|
+
tokenPayFeeSlug,
|
|
1356
1365
|
chainType,
|
|
1357
1366
|
transferNativeAmount,
|
|
1358
1367
|
transaction,
|
|
@@ -1372,9 +1381,9 @@ class KoniExtension {
|
|
|
1372
1381
|
feeOption,
|
|
1373
1382
|
from,
|
|
1374
1383
|
isPassConfirmation,
|
|
1375
|
-
nonNativeTokenPayFeeSlug,
|
|
1376
1384
|
originNetworkKey,
|
|
1377
1385
|
to,
|
|
1386
|
+
tokenPayFeeSlug,
|
|
1378
1387
|
tokenSlug,
|
|
1379
1388
|
transferAll,
|
|
1380
1389
|
transferBounceable,
|
|
@@ -1394,7 +1403,7 @@ class KoniExtension {
|
|
|
1394
1403
|
const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(originNetworkKey, destinationNetworkKey);
|
|
1395
1404
|
const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(originNetworkKey, destinationNetworkKey);
|
|
1396
1405
|
const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
|
|
1397
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug ===
|
|
1406
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
|
|
1398
1407
|
let additionalValidator;
|
|
1399
1408
|
let eventsHandler;
|
|
1400
1409
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1434,6 +1443,14 @@ class KoniExtension {
|
|
|
1434
1443
|
feeInfo
|
|
1435
1444
|
};
|
|
1436
1445
|
extrinsic = await funcCreateExtrinsic(params);
|
|
1446
|
+
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(originNetworkKey)) {
|
|
1447
|
+
var _this$koniState$chain2, _substrateApi$api$que2;
|
|
1448
|
+
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain2 = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.assetId);
|
|
1449
|
+
const _feeSetting = await ((_substrateApi$api$que2 = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.accountCurrencyMap(from));
|
|
1450
|
+
const feeSetting = _feeSetting.toPrimitive();
|
|
1451
|
+
const _extrinsic = extrinsic;
|
|
1452
|
+
extrinsic = (0, _tokenPayFee.batchExtrinsicSetFeeHydration)(substrateApi, _extrinsic, feeSetting, hydrationFeeAssetId);
|
|
1453
|
+
}
|
|
1437
1454
|
additionalValidator = async inputTransaction => {
|
|
1438
1455
|
const {
|
|
1439
1456
|
value: senderTransferable
|
|
@@ -1492,7 +1509,7 @@ class KoniExtension {
|
|
|
1492
1509
|
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM,
|
|
1493
1510
|
transferNativeAmount: (0, _utils4._isNativeToken)(originTokenInfo) ? value : '0',
|
|
1494
1511
|
ignoreWarnings,
|
|
1495
|
-
|
|
1512
|
+
tokenPayFeeSlug,
|
|
1496
1513
|
isTransferAll: transferAll,
|
|
1497
1514
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1498
1515
|
isPassConfirmation,
|
|
@@ -1510,49 +1527,52 @@ class KoniExtension {
|
|
|
1510
1527
|
} = request;
|
|
1511
1528
|
const chainService = this.#koniState.chainService;
|
|
1512
1529
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1513
|
-
const address = (0,
|
|
1514
|
-
|
|
1515
|
-
// ensure nativeTokenInfo and localTokenInfo have multi-location metadata beforehand to improve performance.
|
|
1530
|
+
const address = (0, _utils6.reformatAddress)(_address);
|
|
1516
1531
|
const tokensHasBalanceInfoMap = await this.#koniState.balanceService.getTokensHasBalance(address, chain);
|
|
1517
|
-
const tokensHasBalanceSlug = Object.keys(tokensHasBalanceInfoMap);
|
|
1518
|
-
const tokenInfos = tokensHasBalanceSlug.map(tokenSlug => chainService.getAssetBySlug(tokenSlug)).filter(token => token.originChain === chain && token.assetType !== _types._AssetType.NATIVE && token.metadata && token.metadata.multilocation);
|
|
1519
1532
|
const nativeTokenInfo = chainService.getNativeTokenInfo(chain);
|
|
1520
|
-
const
|
|
1533
|
+
const nativeBalanceInfo = {
|
|
1521
1534
|
slug: nativeTokenInfo.slug,
|
|
1522
1535
|
free: ((_tokensHasBalanceInfo = tokensHasBalanceInfoMap[nativeTokenInfo.slug]) === null || _tokensHasBalanceInfo === void 0 ? void 0 : _tokensHasBalanceInfo.free) || '0',
|
|
1523
1536
|
rate: '1'
|
|
1524
1537
|
};
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
} else {
|
|
1545
|
-
const amount = (0, _utils6.estimateTokensForPool)(feeAmount, reserve);
|
|
1546
|
-
const liquidityError = (0, _utils6.checkLiquidityForPool)(amount, reserve[0], reserve[1]);
|
|
1547
|
-
if (!liquidityError) {
|
|
1548
|
-
tokensCanPayFee.push(tokenCanPayFee);
|
|
1549
|
-
}
|
|
1538
|
+
let tokensCanPayFee = [nativeBalanceInfo];
|
|
1539
|
+
let defaultTokenSlug = nativeBalanceInfo.slug;
|
|
1540
|
+
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain)) {
|
|
1541
|
+
tokensCanPayFee = await (0, _tokenPayFee.getAssetHubTokensCanPayFee)({
|
|
1542
|
+
substrateApi,
|
|
1543
|
+
chainService,
|
|
1544
|
+
nativeTokenInfo,
|
|
1545
|
+
nativeBalanceInfo,
|
|
1546
|
+
tokensHasBalanceInfoMap,
|
|
1547
|
+
feeAmount
|
|
1548
|
+
});
|
|
1549
|
+
} else if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
1550
|
+
const _assetId = await substrateApi.api.query.multiTransactionPayment.accountCurrencyMap(address);
|
|
1551
|
+
const assetId = _assetId.toPrimitive();
|
|
1552
|
+
const hydrationAssets = this.#koniState.chainService.getHydrationAssetIdMap(chain);
|
|
1553
|
+
for (const [key, value] of Object.entries(hydrationAssets)) {
|
|
1554
|
+
if (assetId && assetId.toString() === value) {
|
|
1555
|
+
defaultTokenSlug = key;
|
|
1556
|
+
break;
|
|
1550
1557
|
}
|
|
1551
|
-
} catch (e) {
|
|
1552
|
-
console.error('error when fetching pool with token', tokenInfo.slug, e);
|
|
1553
1558
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1559
|
+
tokensCanPayFee = await (0, _tokenPayFee.getHydrationTokensCanPayFee)({
|
|
1560
|
+
substrateApi,
|
|
1561
|
+
chainService,
|
|
1562
|
+
nativeTokenInfo,
|
|
1563
|
+
nativeBalanceInfo,
|
|
1564
|
+
tokensHasBalanceInfoMap,
|
|
1565
|
+
address,
|
|
1566
|
+
feeAmount
|
|
1567
|
+
});
|
|
1568
|
+
if (!tokensCanPayFee.map(token => token.slug).includes(defaultTokenSlug)) {
|
|
1569
|
+
defaultTokenSlug = nativeBalanceInfo.slug;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return {
|
|
1573
|
+
tokensCanPayFee,
|
|
1574
|
+
defaultTokenSlug
|
|
1575
|
+
};
|
|
1556
1576
|
}
|
|
1557
1577
|
async getAmountForPair(request) {
|
|
1558
1578
|
const {
|
|
@@ -1753,13 +1773,13 @@ class KoniExtension {
|
|
|
1753
1773
|
destChain: _destChain,
|
|
1754
1774
|
feeCustom,
|
|
1755
1775
|
feeOption,
|
|
1756
|
-
|
|
1757
|
-
|
|
1776
|
+
token,
|
|
1777
|
+
tokenPayFeeSlug
|
|
1758
1778
|
} = request;
|
|
1759
1779
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1760
1780
|
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
1761
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !(0, _utils4._isNativeToken)(transferTokenInfo) && !!
|
|
1762
|
-
const isTransferNativeTokenAndPayLocalTokenAsFee = (0, _utils4._isNativeToken)(transferTokenInfo) && !!
|
|
1781
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !(0, _utils4._isNativeToken)(transferTokenInfo) && !!tokenPayFeeSlug && tokenPayFeeSlug === token;
|
|
1782
|
+
const isTransferNativeTokenAndPayLocalTokenAsFee = (0, _utils4._isNativeToken)(transferTokenInfo) && !!tokenPayFeeSlug && !(0, _utils4._isNativeTokenBySlug)(tokenPayFeeSlug);
|
|
1763
1783
|
const srcToken = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(chain);
|
|
1764
1784
|
const destToken = _destChain !== chain ? this.#koniState.getXcmEqualAssetByChain(_destChain, srcToken.slug) : srcToken;
|
|
1765
1785
|
const srcChain = this.#koniState.chainService.getChainInfoByKey(chain);
|
|
@@ -1768,7 +1788,7 @@ class KoniExtension {
|
|
|
1768
1788
|
const extrinsicType = srcChain.slug !== destChain.slug ? _KoniTypes.ExtrinsicType.TRANSFER_XCM : _KoniTypes.ExtrinsicType.TRANSFER_BALANCE;
|
|
1769
1789
|
const freeBalanceSubject = new _rxjs.Subject();
|
|
1770
1790
|
const feeSubject = new _rxjs.Subject();
|
|
1771
|
-
const feeChainType = (0,
|
|
1791
|
+
const feeChainType = (0, _utils6.detectTransferTxType)(srcToken, srcChain, destChain);
|
|
1772
1792
|
if (!destToken) {
|
|
1773
1793
|
throw new Error('Destination token not found');
|
|
1774
1794
|
}
|
|
@@ -1797,7 +1817,7 @@ class KoniExtension {
|
|
|
1797
1817
|
fee,
|
|
1798
1818
|
freeBalance
|
|
1799
1819
|
} = _ref34;
|
|
1800
|
-
(0,
|
|
1820
|
+
(0, _utils6.calculateMaxTransferable)(id, _request, freeBalance, fee).then(cb).catch(console.error);
|
|
1801
1821
|
}
|
|
1802
1822
|
});
|
|
1803
1823
|
const [unsubBalance, freeBalance] = await (async () => {
|
|
@@ -1828,7 +1848,7 @@ class KoniExtension {
|
|
|
1828
1848
|
port.onDisconnect.addListener(() => {
|
|
1829
1849
|
this.cancelSubscription(id);
|
|
1830
1850
|
});
|
|
1831
|
-
return (0,
|
|
1851
|
+
return (0, _utils6.calculateMaxTransferable)(id, _request, freeBalance, fee);
|
|
1832
1852
|
}
|
|
1833
1853
|
async subscribeAddressTransferableBalance(_ref35, id, port) {
|
|
1834
1854
|
let {
|
|
@@ -2093,7 +2113,7 @@ class KoniExtension {
|
|
|
2093
2113
|
signed = await pair.evm.signMessage(data, 'personal_sign');
|
|
2094
2114
|
} else {
|
|
2095
2115
|
var _signedTranaction$r, _signedTranaction$s, _signedTranaction$v;
|
|
2096
|
-
const tx = (0,
|
|
2116
|
+
const tx = (0, _utils6.createTransactionFromRLP)(message);
|
|
2097
2117
|
if (!tx) {
|
|
2098
2118
|
throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
|
|
2099
2119
|
}
|
|
@@ -2118,7 +2138,7 @@ class KoniExtension {
|
|
|
2118
2138
|
common
|
|
2119
2139
|
});
|
|
2120
2140
|
const signedTranaction = _tx.LegacyTransaction.fromSerializedTx((0, _util.hexToU8a)(pair.evm.signTransaction(transaction)));
|
|
2121
|
-
signed = (0,
|
|
2141
|
+
signed = (0, _utils6.signatureToHex)({
|
|
2122
2142
|
r: ((_signedTranaction$r = signedTranaction.r) === null || _signedTranaction$r === void 0 ? void 0 : _signedTranaction$r.toString(16)) || '',
|
|
2123
2143
|
s: ((_signedTranaction$s = signedTranaction.s) === null || _signedTranaction$s === void 0 ? void 0 : _signedTranaction$s.toString(16)) || '',
|
|
2124
2144
|
v: ((_signedTranaction$v = signedTranaction.v) === null || _signedTranaction$v === void 0 ? void 0 : _signedTranaction$v.toString(16)) || ''
|
|
@@ -2552,11 +2572,11 @@ class KoniExtension {
|
|
|
2552
2572
|
let registry = new _types5.TypeRegistry();
|
|
2553
2573
|
if (isJsonPayload(payload)) {
|
|
2554
2574
|
const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
2555
|
-
const allRegistry = [(0,
|
|
2575
|
+
const allRegistry = [(0, _utils8.setupApiRegistry)(chainInfo, this.#koniState), (0, _utils8.setupDatabaseRegistry)(await this.#koniState.chainService.getMetadataByHash(payload.genesisHash), chainInfo, payload), (0, _utils8.setupDappRegistry)(this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash), payload)].filter(item => item !== null && item.registry !== undefined);
|
|
2556
2576
|
if (allRegistry.length === 0) {
|
|
2557
2577
|
registry.setSignedExtensions(payload.signedExtensions);
|
|
2558
2578
|
} else {
|
|
2559
|
-
registry = (0,
|
|
2579
|
+
registry = (0, _utils8.getSuitableRegistry)(allRegistry, payload);
|
|
2560
2580
|
}
|
|
2561
2581
|
}
|
|
2562
2582
|
const result = request.sign(registry, pair);
|
|
@@ -2852,12 +2872,12 @@ class KoniExtension {
|
|
|
2852
2872
|
if (namespace.chains) {
|
|
2853
2873
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
2854
2874
|
if (unSupportChains.length) {
|
|
2855
|
-
throw new Error((0,
|
|
2875
|
+
throw new Error((0, _utils7.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
2856
2876
|
}
|
|
2857
2877
|
availableNamespaces[key] = namespace;
|
|
2858
2878
|
}
|
|
2859
2879
|
} else {
|
|
2860
|
-
throw new Error((0,
|
|
2880
|
+
throw new Error((0, _utils7.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
2861
2881
|
}
|
|
2862
2882
|
});
|
|
2863
2883
|
Object.entries(optionalNamespaces).forEach(_ref55 => {
|
|
@@ -2892,7 +2912,7 @@ class KoniExtension {
|
|
|
2892
2912
|
const [_namespace] = address.split(':');
|
|
2893
2913
|
return _namespace === key;
|
|
2894
2914
|
});
|
|
2895
|
-
const chains = (0,
|
|
2915
|
+
const chains = (0, _utils6.uniqueStringArray)(namespace.chains);
|
|
2896
2916
|
namespaces[key] = {
|
|
2897
2917
|
accounts,
|
|
2898
2918
|
methods: namespace.methods,
|
|
@@ -2980,7 +3000,7 @@ class KoniExtension {
|
|
|
2980
3000
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
2981
3001
|
}
|
|
2982
3002
|
try {
|
|
2983
|
-
var _this$koniState$
|
|
3003
|
+
var _this$koniState$chain3, _this$koniState$chain4;
|
|
2984
3004
|
await this.#koniState.chainService.enableChain(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
2985
3005
|
this.#koniState.chainService.setMantaZkAssetSettings(true);
|
|
2986
3006
|
const mnemonic = this.keyringExportMnemonic({
|
|
@@ -2999,7 +3019,7 @@ class KoniExtension {
|
|
|
2999
3019
|
await this.saveCurrentAccountProxy({
|
|
3000
3020
|
address
|
|
3001
3021
|
});
|
|
3002
|
-
const unsubSyncProgress = await ((_this$koniState$
|
|
3022
|
+
const unsubSyncProgress = await ((_this$koniState$chain3 = this.#koniState.chainService) === null || _this$koniState$chain3 === void 0 ? void 0 : (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) === null || _this$koniState$chain4 === void 0 ? void 0 : _this$koniState$chain4.subscribeSyncProgress());
|
|
3003
3023
|
console.debug('Start initial sync for MantaPay');
|
|
3004
3024
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3005
3025
|
console.debug('Finished initial sync for MantaPay');
|
|
@@ -3030,32 +3050,32 @@ class KoniExtension {
|
|
|
3030
3050
|
}
|
|
3031
3051
|
}
|
|
3032
3052
|
async initSyncMantaPay(address) {
|
|
3033
|
-
var _this$koniState$
|
|
3034
|
-
if ((_this$koniState$
|
|
3053
|
+
var _this$koniState$chain5, _this$koniState$chain6, _this$koniState$chain7, _this$koniState$chain8;
|
|
3054
|
+
if ((_this$koniState$chain5 = this.#koniState.chainService) !== null && _this$koniState$chain5 !== void 0 && (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) !== null && _this$koniState$chain6 !== void 0 && _this$koniState$chain6.getSyncState().isSyncing || !_utils6.MODULE_SUPPORT.MANTA_ZK) {
|
|
3035
3055
|
return;
|
|
3036
3056
|
}
|
|
3037
3057
|
this.#skipAutoLock = true;
|
|
3038
3058
|
await this.saveCurrentAccountProxy({
|
|
3039
3059
|
address
|
|
3040
3060
|
});
|
|
3041
|
-
const unsubSyncProgress = await ((_this$koniState$
|
|
3061
|
+
const unsubSyncProgress = await ((_this$koniState$chain7 = this.#koniState.chainService) === null || _this$koniState$chain7 === void 0 ? void 0 : (_this$koniState$chain8 = _this$koniState$chain7.mantaPay) === null || _this$koniState$chain8 === void 0 ? void 0 : _this$koniState$chain8.subscribeSyncProgress());
|
|
3042
3062
|
console.debug('Start initial sync for MantaPay');
|
|
3043
3063
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3044
|
-
var _this$koniState$
|
|
3064
|
+
var _this$koniState$chain9, _this$koniState$chain10;
|
|
3045
3065
|
console.debug('Finished initial sync for MantaPay');
|
|
3046
3066
|
this.#skipAutoLock = false;
|
|
3047
3067
|
unsubSyncProgress && unsubSyncProgress();
|
|
3048
3068
|
// make sure the sync state is set, just in case it gets unsubscribed
|
|
3049
|
-
(_this$koniState$
|
|
3069
|
+
(_this$koniState$chain9 = this.#koniState.chainService) === null || _this$koniState$chain9 === void 0 ? void 0 : (_this$koniState$chain10 = _this$koniState$chain9.mantaPay) === null || _this$koniState$chain10 === void 0 ? void 0 : _this$koniState$chain10.setSyncState({
|
|
3050
3070
|
progress: 100,
|
|
3051
3071
|
isSyncing: false
|
|
3052
3072
|
});
|
|
3053
3073
|
}).catch(e => {
|
|
3054
|
-
var _this$koniState$
|
|
3074
|
+
var _this$koniState$chain11, _this$koniState$chain12;
|
|
3055
3075
|
console.error('Error syncing MantaPay', e);
|
|
3056
3076
|
this.#skipAutoLock = false;
|
|
3057
3077
|
unsubSyncProgress && unsubSyncProgress();
|
|
3058
|
-
(_this$koniState$
|
|
3078
|
+
(_this$koniState$chain11 = this.#koniState.chainService) === null || _this$koniState$chain11 === void 0 ? void 0 : (_this$koniState$chain12 = _this$koniState$chain11.mantaPay) === null || _this$koniState$chain12 === void 0 ? void 0 : _this$koniState$chain12.setSyncState({
|
|
3059
3079
|
progress: 0,
|
|
3060
3080
|
isSyncing: false
|
|
3061
3081
|
});
|
|
@@ -3094,7 +3114,7 @@ class KoniExtension {
|
|
|
3094
3114
|
return this.#koniState.getMantaPayConfig('calamari');
|
|
3095
3115
|
}
|
|
3096
3116
|
subscribeMantaPaySyncState(id, port) {
|
|
3097
|
-
var _this$koniState$subsc, _this$koniState$
|
|
3117
|
+
var _this$koniState$subsc, _this$koniState$chain13, _this$koniState$chain14;
|
|
3098
3118
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3099
3119
|
const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
|
|
3100
3120
|
next: rs => {
|
|
@@ -3105,7 +3125,7 @@ class KoniExtension {
|
|
|
3105
3125
|
port.onDisconnect.addListener(() => {
|
|
3106
3126
|
this.cancelSubscription(id);
|
|
3107
3127
|
});
|
|
3108
|
-
return ((_this$koniState$
|
|
3128
|
+
return ((_this$koniState$chain13 = this.#koniState.chainService) === null || _this$koniState$chain13 === void 0 ? void 0 : (_this$koniState$chain14 = _this$koniState$chain13.mantaPay) === null || _this$koniState$chain14 === void 0 ? void 0 : _this$koniState$chain14.getSyncState()) || {
|
|
3109
3129
|
isSyncing: false,
|
|
3110
3130
|
progress: 0,
|
|
3111
3131
|
needManualSync: false
|
|
@@ -3290,7 +3310,7 @@ class KoniExtension {
|
|
|
3290
3310
|
};
|
|
3291
3311
|
await this.#koniState.transactionService.createProcessIfNeed({
|
|
3292
3312
|
id: processId,
|
|
3293
|
-
address: (0,
|
|
3313
|
+
address: (0, _utils6.reformatAddress)(address),
|
|
3294
3314
|
type: _types3.ProcessType.EARNING,
|
|
3295
3315
|
combineInfo,
|
|
3296
3316
|
currentStepId: step.stepId,
|
|
@@ -3763,7 +3783,7 @@ class KoniExtension {
|
|
|
3763
3783
|
};
|
|
3764
3784
|
await this.#koniState.transactionService.createProcessIfNeed({
|
|
3765
3785
|
id: processId,
|
|
3766
|
-
address: (0,
|
|
3786
|
+
address: (0, _utils6.reformatAddress)(address),
|
|
3767
3787
|
type: _types3.ProcessType.SWAP,
|
|
3768
3788
|
currentStepId: step.stepId,
|
|
3769
3789
|
combineInfo,
|
|
@@ -3998,7 +4018,7 @@ class KoniExtension {
|
|
|
3998
4018
|
if (!pair) {
|
|
3999
4019
|
throw new Error('Pair not found');
|
|
4000
4020
|
}
|
|
4001
|
-
const signMode = (0,
|
|
4021
|
+
const signMode = (0, _utils6.getAccountSignMode)(address, pair.meta);
|
|
4002
4022
|
if (signMode !== _types3.AccountSignMode.PASSWORD) {
|
|
4003
4023
|
throw new Error('Account can not use this feature');
|
|
4004
4024
|
}
|
|
@@ -131,8 +131,8 @@ class KoniState {
|
|
|
131
131
|
get knownMetadata() {
|
|
132
132
|
return this.requestService.knownMetadata;
|
|
133
133
|
}
|
|
134
|
-
injectMetadata(
|
|
135
|
-
return this.requestService.injectMetadata(
|
|
134
|
+
injectMetadata(request) {
|
|
135
|
+
return this.requestService.injectMetadata(request);
|
|
136
136
|
}
|
|
137
137
|
getMetaRequest(id) {
|
|
138
138
|
return this.requestService.getMetaRequest(id);
|
package/cjs/packageInfo.js
CHANGED
|
@@ -23,6 +23,7 @@ async function getEVMTransactionObject(_ref) {
|
|
|
23
23
|
let {
|
|
24
24
|
chain,
|
|
25
25
|
evmApi,
|
|
26
|
+
fallbackFee,
|
|
26
27
|
feeCustom: _feeCustom,
|
|
27
28
|
feeInfo: _feeInfo,
|
|
28
29
|
feeOption,
|
|
@@ -34,13 +35,22 @@ async function getEVMTransactionObject(_ref) {
|
|
|
34
35
|
const feeCustom = _feeCustom;
|
|
35
36
|
const feeInfo = _feeInfo;
|
|
36
37
|
const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, feeCustom);
|
|
38
|
+
let errorOnEstimateFee = '';
|
|
37
39
|
const transactionObject = {
|
|
38
40
|
to: to,
|
|
39
41
|
value: value,
|
|
40
42
|
from: from,
|
|
41
43
|
...feeCombine
|
|
42
44
|
};
|
|
43
|
-
const gasLimit = await evmApi.api.eth.estimateGas(transactionObject)
|
|
45
|
+
const gasLimit = await evmApi.api.eth.estimateGas(transactionObject).catch(e => {
|
|
46
|
+
console.log('Cannot estimate fee with native transfer on', chain, e);
|
|
47
|
+
if (fallbackFee) {
|
|
48
|
+
errorOnEstimateFee = e.message;
|
|
49
|
+
return 21000;
|
|
50
|
+
} else {
|
|
51
|
+
throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
44
54
|
transactionObject.gas = gasLimit;
|
|
45
55
|
let estimateFee;
|
|
46
56
|
if (feeCombine.maxFeePerGas) {
|
|
@@ -54,12 +64,14 @@ async function getEVMTransactionObject(_ref) {
|
|
|
54
64
|
const numberReplace = 18 - 12;
|
|
55
65
|
transactionObject.value = transactionObject.value.substring(0, transactionObject.value.length - 6) + new Array(numberReplace).fill('0').join('');
|
|
56
66
|
}
|
|
57
|
-
return [transactionObject, transactionObject.value.toString()];
|
|
67
|
+
return [transactionObject, transactionObject.value.toString(), errorOnEstimateFee];
|
|
58
68
|
}
|
|
59
69
|
async function getERC20TransactionObject(_ref2) {
|
|
60
70
|
let {
|
|
61
71
|
assetAddress,
|
|
72
|
+
chain,
|
|
62
73
|
evmApi,
|
|
74
|
+
fallbackFee,
|
|
63
75
|
feeCustom: _feeCustom,
|
|
64
76
|
feeInfo: _feeInfo,
|
|
65
77
|
feeOption,
|
|
@@ -72,6 +84,7 @@ async function getERC20TransactionObject(_ref2) {
|
|
|
72
84
|
const feeCustom = _feeCustom;
|
|
73
85
|
let freeAmount = new _bignumber.default(0);
|
|
74
86
|
let transferValue = value;
|
|
87
|
+
let errorOnEstimateFee = '';
|
|
75
88
|
if (transferAll) {
|
|
76
89
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
77
90
|
const bal = await erc20Contract.methods.balanceOf(from).call();
|
|
@@ -86,6 +99,14 @@ async function getERC20TransactionObject(_ref2) {
|
|
|
86
99
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
87
100
|
const gasLimit = await erc20Contract.methods.transfer(to, transferValue).estimateGas({
|
|
88
101
|
from
|
|
102
|
+
}).catch(e => {
|
|
103
|
+
console.log('Cannot estimate fee with token contract', assetAddress, chain, e);
|
|
104
|
+
if (fallbackFee) {
|
|
105
|
+
errorOnEstimateFee = e.message;
|
|
106
|
+
return 70000;
|
|
107
|
+
} else {
|
|
108
|
+
throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
|
|
109
|
+
}
|
|
89
110
|
});
|
|
90
111
|
const feeInfo = _feeInfo;
|
|
91
112
|
const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, feeCustom);
|
|
@@ -101,7 +122,7 @@ async function getERC20TransactionObject(_ref2) {
|
|
|
101
122
|
transferValue = freeAmount.toFixed(0);
|
|
102
123
|
transactionObject.data = generateTransferData(to, transferValue);
|
|
103
124
|
}
|
|
104
|
-
return [transactionObject, transferValue];
|
|
125
|
+
return [transactionObject, transferValue, errorOnEstimateFee];
|
|
105
126
|
}
|
|
106
127
|
async function getERC721Transaction(web3Api, chain, contractAddress, senderAddress, recipientAddress, tokenId, _feeInfo) {
|
|
107
128
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -219,6 +219,17 @@ class ChainService {
|
|
|
219
219
|
});
|
|
220
220
|
return assetHubToken;
|
|
221
221
|
}
|
|
222
|
+
getHydrationAssetIdMap(chain) {
|
|
223
|
+
const hydrationAssetIdMap = {};
|
|
224
|
+
Object.values(this.getAssetRegistry()).forEach(asset => {
|
|
225
|
+
const originChain = (0, _utils._getAssetOriginChain)(asset);
|
|
226
|
+
const assetId = (0, _utils._getTokenOnChainAssetId)(asset);
|
|
227
|
+
if (originChain === chain && assetId !== '-1') {
|
|
228
|
+
hydrationAssetIdMap[asset.slug] = assetId;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return hydrationAssetIdMap;
|
|
232
|
+
}
|
|
222
233
|
getChainInfoMap() {
|
|
223
234
|
return this.dataMap.chainInfoMap;
|
|
224
235
|
}
|