@subwallet/extension-base 1.3.30-0 → 1.3.31-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +12 -0
- package/cjs/constants/paraspell-chain-map.js +13 -0
- package/cjs/core/logic-validation/transfer.js +13 -1
- package/cjs/core/substrate/xcm-parser.js +5 -1
- package/cjs/core/utils.js +36 -15
- package/cjs/koni/background/handlers/Extension.js +136 -90
- package/cjs/koni/background/handlers/State.js +8 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +27 -0
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +33 -1
- package/cjs/services/balance-service/index.js +9 -0
- package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +229 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +96 -7
- package/cjs/services/balance-service/transfer/xcm/utils.js +213 -0
- package/cjs/services/chain-service/constants.js +2 -4
- package/cjs/services/chain-service/index.js +71 -17
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/special.js +18 -9
- package/cjs/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/cjs/services/keyring-service/context/state.js +3 -0
- package/cjs/services/migration-service/scripts/DisableZeroBalanceTokens.js +60 -0
- package/cjs/services/migration-service/scripts/EnableChain.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +3 -2
- package/cjs/services/swap-service/handler/base-handler.js +24 -11
- package/cjs/services/transaction-service/utils.js +38 -14
- package/cjs/utils/fee/transfer.js +52 -28
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/paraspell-chain-map.d.ts +1 -0
- package/constants/paraspell-chain-map.js +7 -0
- package/core/logic-validation/transfer.d.ts +1 -0
- package/core/logic-validation/transfer.js +12 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +4 -1
- package/core/utils.d.ts +2 -2
- package/core/utils.js +36 -15
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +60 -15
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +7 -1
- package/package.json +23 -7
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.d.ts +2 -1
- package/services/balance-service/helpers/process.js +26 -0
- package/services/balance-service/helpers/subscribe/substrate/index.js +34 -2
- package/services/balance-service/index.js +11 -2
- package/services/balance-service/transfer/xcm/acrossBridge/index.d.ts +15 -0
- package/services/balance-service/transfer/xcm/acrossBridge/index.js +216 -0
- package/services/balance-service/transfer/xcm/index.d.ts +5 -1
- package/services/balance-service/transfer/xcm/index.js +85 -1
- package/services/balance-service/transfer/xcm/utils.d.ts +11 -0
- package/services/balance-service/transfer/xcm/utils.js +208 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +1 -2
- package/services/chain-service/index.d.ts +9 -2
- package/services/chain-service/index.js +72 -18
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/special.js +19 -10
- package/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +3 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.d.ts +4 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.js +51 -0
- package/services/migration-service/scripts/EnableChain.js +1 -1
- package/services/migration-service/scripts/index.js +3 -2
- package/services/swap-service/handler/base-handler.js +25 -12
- package/services/transaction-service/types.d.ts +3 -2
- package/services/transaction-service/utils.d.ts +1 -0
- package/services/transaction-service/utils.js +38 -15
- package/types/balance/transfer.d.ts +1 -0
- package/types/transaction/request.d.ts +7 -0
- package/utils/fee/transfer.d.ts +1 -0
- package/utils/fee/transfer.js +54 -30
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
- package/utils/staticData/paraSpellChainMap.json +1 -0
|
@@ -11,6 +11,7 @@ var _logicValidation = require("@subwallet/extension-base/core/logic-validation"
|
|
|
11
11
|
var _systemPallet = require("@subwallet/extension-base/core/substrate/system-pallet");
|
|
12
12
|
var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
|
|
13
13
|
var _utils = require("@subwallet/extension-base/core/utils");
|
|
14
|
+
var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
|
|
14
15
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
15
16
|
var _utils3 = require("@subwallet/extension-base/services/swap-service/utils");
|
|
16
17
|
var _types = require("@subwallet/extension-base/types");
|
|
@@ -21,7 +22,6 @@ var _getId = require("@subwallet/extension-base/utils/getId");
|
|
|
21
22
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
22
23
|
var _i18next = require("i18next");
|
|
23
24
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
24
|
-
var _xcm = require("../../balance-service/transfer/xcm");
|
|
25
25
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
26
26
|
// SPDX-License-Identifier: Apache-2.0
|
|
27
27
|
|
|
@@ -98,6 +98,9 @@ class SwapBaseHandler {
|
|
|
98
98
|
// bridge after swap
|
|
99
99
|
recipientAddress = (0, _utils4._reformatAddressWithChain)(recipient || address, toChainInfo);
|
|
100
100
|
}
|
|
101
|
+
if (!(0, _xcmParser._isXcmWithinSameConsensus)(fromChainInfo, toChainInfo) || (0, _xcmParser._isSnowBridgeXcm)(fromChainInfo, toChainInfo) || (0, _xcmParser._isAcrossBridgeXcm)(fromChainInfo, toChainInfo)) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
101
104
|
try {
|
|
102
105
|
if (!this.chainService.getChainStateByKey(toTokenInfo.originChain).active) {
|
|
103
106
|
await this.chainService.enableChain(toTokenInfo.originChain);
|
|
@@ -105,7 +108,8 @@ class SwapBaseHandler {
|
|
|
105
108
|
const substrateApi = await this.chainService.getSubstrateApi(fromTokenInfo.originChain).isReady;
|
|
106
109
|
const id = (0, _getId.getId)();
|
|
107
110
|
const [feeInfo, toTokenBalance] = await Promise.all([this.feeService.subscribeChainFee(id, fromTokenInfo.originChain, 'substrate'), this.balanceService.getTotalBalance(senderAddress, toTokenInfo.originChain, toTokenInfo.slug, _KoniTypes.ExtrinsicType.TRANSFER_BALANCE)]);
|
|
108
|
-
const
|
|
111
|
+
const mockSendingValue = stepIndex === 0 ? fromAmount : (selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.toAmount) || '0';
|
|
112
|
+
const xcmRequest = {
|
|
109
113
|
originTokenInfo: fromTokenInfo,
|
|
110
114
|
destinationTokenInfo: toTokenInfo,
|
|
111
115
|
originChain: fromChainInfo,
|
|
@@ -113,13 +117,17 @@ class SwapBaseHandler {
|
|
|
113
117
|
substrateApi: substrateApi,
|
|
114
118
|
feeInfo,
|
|
115
119
|
// Mock sending value to get payment info
|
|
116
|
-
sendingValue:
|
|
120
|
+
sendingValue: mockSendingValue,
|
|
117
121
|
sender: senderAddress,
|
|
118
122
|
recipient: recipientAddress
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// TODO: calculate fee for destination chain
|
|
126
|
+
const bridgeFeeByDryRun = await (0, _xcm.dryRunXcmExtrinsicV2)(xcmRequest);
|
|
127
|
+
if (!bridgeFeeByDryRun.fee) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const estimatedBridgeFee = (0, _bignumber.default)(bridgeFeeByDryRun.fee).multipliedBy(_utils3.FEE_RATE_MULTIPLIER.medium).toFixed(0, 1);
|
|
123
131
|
const fee = {
|
|
124
132
|
feeComponent: [{
|
|
125
133
|
feeType: _swap.SwapFeeType.NETWORK_FEE,
|
|
@@ -196,7 +204,7 @@ class SwapBaseHandler {
|
|
|
196
204
|
const substrateApi = this.chainService.getSubstrateApi(originAsset.originChain);
|
|
197
205
|
const chainApi = await substrateApi.isReady;
|
|
198
206
|
const feeInfo = await this.feeService.subscribeChainFee((0, _getId.getId)(), originAsset.originChain, 'substrate');
|
|
199
|
-
const
|
|
207
|
+
const xcmRequest = {
|
|
200
208
|
originTokenInfo: originAsset,
|
|
201
209
|
destinationTokenInfo: destinationAsset,
|
|
202
210
|
sendingValue: briefXcmStep.sendingValue,
|
|
@@ -206,7 +214,11 @@ class SwapBaseHandler {
|
|
|
206
214
|
destinationChain,
|
|
207
215
|
originChain,
|
|
208
216
|
feeInfo
|
|
209
|
-
}
|
|
217
|
+
};
|
|
218
|
+
const extrinsic = await (0, _xcm.createXcmExtrinsicV2)(xcmRequest);
|
|
219
|
+
if (!extrinsic) {
|
|
220
|
+
throw new Error('XCM extrinsic error');
|
|
221
|
+
}
|
|
210
222
|
const xcmData = {
|
|
211
223
|
originNetworkKey: originAsset.originChain,
|
|
212
224
|
destinationNetworkKey: destinationAsset.originChain,
|
|
@@ -218,7 +230,7 @@ class SwapBaseHandler {
|
|
|
218
230
|
};
|
|
219
231
|
return {
|
|
220
232
|
txChain: originAsset.originChain,
|
|
221
|
-
extrinsic
|
|
233
|
+
extrinsic,
|
|
222
234
|
transferNativeAmount: (0, _utils2._isNativeToken)(originAsset) ? briefXcmStep.sendingValue : '0',
|
|
223
235
|
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
224
236
|
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
@@ -260,12 +272,13 @@ class SwapBaseHandler {
|
|
|
260
272
|
|
|
261
273
|
// By here, we know that the user is receiving a valid amount of toToken
|
|
262
274
|
const toChainApi = this.chainService.getSubstrateApi(toToken.originChain);
|
|
275
|
+
const sufficientChain = this.chainService.value.sufficientChains;
|
|
263
276
|
if (!toChainApi) {
|
|
264
277
|
return [new _TransactionError.TransactionError(_types.BasicTxErrorType.INTERNAL_ERROR)];
|
|
265
278
|
}
|
|
266
279
|
|
|
267
280
|
// Only need to check if account is alive with the receiving toToken
|
|
268
|
-
const isToTokenSufficient = await (0, _utils._isSufficientToken)(toToken, toChainApi);
|
|
281
|
+
const isToTokenSufficient = await (0, _utils._isSufficientToken)(toToken, toChainApi, sufficientChain);
|
|
269
282
|
if (!isToTokenSufficient && !(0, _utils2._isNativeToken)(toToken)) {
|
|
270
283
|
// sending token cannot keep account alive, must check with native token
|
|
271
284
|
const toChainNativeTokenBalance = await this.balanceService.getTotalBalance(receiver, toToken.originChain, toChainNativeToken.slug, _KoniTypes.ExtrinsicType.TRANSFER_BALANCE);
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getChainflipExplorerLink = getChainflipExplorerLink;
|
|
7
7
|
exports.getExplorerLink = getExplorerLink;
|
|
8
8
|
exports.getSimpleSwapExplorerLink = getSimpleSwapExplorerLink;
|
|
9
|
+
exports.getTransactionId = getTransactionId;
|
|
9
10
|
exports.parseTransactionData = parseTransactionData;
|
|
10
11
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
11
12
|
var _utils2 = require("@subwallet/extension-base/services/swap-service/utils");
|
|
12
13
|
var _util = require("@polkadot/util");
|
|
14
|
+
var _utilCrypto = require("@polkadot/util-crypto");
|
|
13
15
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
14
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
15
17
|
|
|
@@ -32,19 +34,7 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
32
34
|
if (explorerLink.includes('3dpscan.io')) {
|
|
33
35
|
return 'account';
|
|
34
36
|
}
|
|
35
|
-
if (explorerLink.includes('
|
|
36
|
-
return 'account';
|
|
37
|
-
}
|
|
38
|
-
if (explorerLink.includes('invarch.statescan.io')) {
|
|
39
|
-
return '#/accounts';
|
|
40
|
-
}
|
|
41
|
-
if (explorerLink.includes('tangle.statescan.io')) {
|
|
42
|
-
return '#/accounts';
|
|
43
|
-
}
|
|
44
|
-
if (explorerLink.includes('laos.statescan.io')) {
|
|
45
|
-
return '#/accounts';
|
|
46
|
-
}
|
|
47
|
-
if (explorerLink.includes('polimec.statescan.io')) {
|
|
37
|
+
if (explorerLink.includes('statescan.io')) {
|
|
48
38
|
return '#/accounts';
|
|
49
39
|
}
|
|
50
40
|
if (explorerLink.includes('explorer.zkverify.io')) {
|
|
@@ -68,15 +58,38 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
68
58
|
if (['aventus', 'deeper_network'].includes(chainInfo.slug)) {
|
|
69
59
|
return 'transaction';
|
|
70
60
|
}
|
|
71
|
-
|
|
61
|
+
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
62
|
+
if (explorerLink && explorerLink.includes('statescan.io')) {
|
|
72
63
|
return '#/extrinsics';
|
|
73
64
|
}
|
|
74
65
|
return 'extrinsic';
|
|
75
66
|
}
|
|
67
|
+
function getTransactionId(value) {
|
|
68
|
+
const query = `
|
|
69
|
+
query ExtrinsicQuery {
|
|
70
|
+
extrinsics(where: {hash_eq: ${value}}, limit: 1) {
|
|
71
|
+
id
|
|
72
|
+
}
|
|
73
|
+
}`;
|
|
74
|
+
const apiUrl = 'https://archive-explorer.truth-network.io/graphql';
|
|
75
|
+
return fetch(apiUrl, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json'
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
query
|
|
82
|
+
})
|
|
83
|
+
}).then(response => response.json()).then(result => result.data.extrinsics[0].id);
|
|
84
|
+
}
|
|
76
85
|
function getExplorerLink(chainInfo, value, type) {
|
|
77
86
|
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
78
87
|
if (explorerLink && type === 'account') {
|
|
79
88
|
const route = getBlockExplorerAccountRoute(explorerLink);
|
|
89
|
+
if (chainInfo.slug === 'truth_network') {
|
|
90
|
+
const address = (0, _util.u8aToHex)((0, _utilCrypto.decodeAddress)(value));
|
|
91
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${address}`;
|
|
92
|
+
}
|
|
80
93
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
|
|
81
94
|
}
|
|
82
95
|
if (explorerLink && (0, _util.isHex)((0, _util.hexAddPrefix)(value))) {
|
|
@@ -84,6 +97,17 @@ function getExplorerLink(chainInfo, value, type) {
|
|
|
84
97
|
if (chainInfo.slug === 'tangle') {
|
|
85
98
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${value}${route}/${value}`;
|
|
86
99
|
}
|
|
100
|
+
if (chainInfo.slug === 'truth_network') {
|
|
101
|
+
// getTransactionId(value)
|
|
102
|
+
// .then((transactionId) => {
|
|
103
|
+
// return (`${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${transactionId}`);
|
|
104
|
+
// })
|
|
105
|
+
// .catch((err) => {
|
|
106
|
+
// console.error(err);
|
|
107
|
+
// });
|
|
108
|
+
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
87
111
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
|
|
88
112
|
}
|
|
89
113
|
return undefined;
|
|
@@ -13,6 +13,7 @@ var _smartContract = require("@subwallet/extension-base/services/balance-service
|
|
|
13
13
|
var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
|
|
14
14
|
var _tonTransfer = require("@subwallet/extension-base/services/balance-service/transfer/ton-transfer");
|
|
15
15
|
var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
|
|
16
|
+
var _acrossBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge");
|
|
16
17
|
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
17
18
|
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
18
19
|
var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
|
|
@@ -36,7 +37,8 @@ const detectTransferTxType = (srcToken, srcChain, destChain) => {
|
|
|
36
37
|
const isSnowBridgeEvmTransfer = (0, _utils._isPureEvmChain)(srcChain) && (0, _xcmParser._isSnowBridgeXcm)(srcChain, destChain) && !isAvailBridgeFromEvm;
|
|
37
38
|
const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(srcChain.slug, destChain.slug);
|
|
38
39
|
const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(srcChain.slug, destChain.slug);
|
|
39
|
-
|
|
40
|
+
const isAcrossBridgeTransfer = (0, _acrossBridge._isAcrossChainBridge)(srcChain.slug, destChain.slug);
|
|
41
|
+
return isAvailBridgeFromEvm || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer ? 'evm' : 'substrate';
|
|
40
42
|
} else {
|
|
41
43
|
if ((0, _utils._isChainEvmCompatible)(srcChain) && (0, _utils._isTokenTransferredByEvm)(srcToken)) {
|
|
42
44
|
return 'evm';
|
|
@@ -86,7 +88,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
86
88
|
srcChain,
|
|
87
89
|
srcToken,
|
|
88
90
|
substrateApi,
|
|
89
|
-
tonApi
|
|
91
|
+
tonApi,
|
|
92
|
+
value
|
|
90
93
|
} = request;
|
|
91
94
|
const feeChainType = fee.type;
|
|
92
95
|
let estimatedFee;
|
|
@@ -114,7 +117,7 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
114
117
|
from: address,
|
|
115
118
|
to: recipient,
|
|
116
119
|
transferAll: false,
|
|
117
|
-
value
|
|
120
|
+
value,
|
|
118
121
|
fallbackFee: true
|
|
119
122
|
});
|
|
120
123
|
} else {
|
|
@@ -127,7 +130,7 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
127
130
|
from: address,
|
|
128
131
|
to: recipient,
|
|
129
132
|
transferAll: false,
|
|
130
|
-
value
|
|
133
|
+
value,
|
|
131
134
|
fallbackFee: true
|
|
132
135
|
});
|
|
133
136
|
}
|
|
@@ -137,19 +140,18 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
137
140
|
from: address,
|
|
138
141
|
to: address,
|
|
139
142
|
networkKey: srcChain.slug,
|
|
140
|
-
value
|
|
143
|
+
value,
|
|
141
144
|
transferAll: false,
|
|
142
145
|
// currently not used
|
|
143
146
|
tonApi
|
|
144
147
|
});
|
|
145
148
|
} else if ((0, _keyring.isCardanoAddress)(address) && (0, _utils._isTokenTransferredByCardano)(srcToken)) {
|
|
146
|
-
const isTransferNativeToken = (0, _utils._isNativeToken)(srcToken);
|
|
147
149
|
[transaction] = await (0, _cardanoTransfer.createCardanoTransaction)({
|
|
148
150
|
tokenInfo: srcToken,
|
|
149
151
|
from: address,
|
|
150
152
|
to: address,
|
|
151
153
|
networkKey: srcChain.slug,
|
|
152
|
-
value
|
|
154
|
+
value,
|
|
153
155
|
cardanoTtlOffset: _consts.DEFAULT_CARDANO_TTL_OFFSET,
|
|
154
156
|
transferAll: false,
|
|
155
157
|
cardanoApi,
|
|
@@ -158,7 +160,7 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
158
160
|
} else {
|
|
159
161
|
[transaction] = await (0, _token.createSubstrateExtrinsic)({
|
|
160
162
|
transferAll: false,
|
|
161
|
-
value
|
|
163
|
+
value,
|
|
162
164
|
from: address,
|
|
163
165
|
networkKey: srcChain.slug,
|
|
164
166
|
tokenInfo: srcToken,
|
|
@@ -295,10 +297,11 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
295
297
|
nativeToken,
|
|
296
298
|
srcChain,
|
|
297
299
|
srcToken,
|
|
298
|
-
substrateApi
|
|
300
|
+
substrateApi,
|
|
301
|
+
value
|
|
299
302
|
} = request;
|
|
300
303
|
const feeChainType = fee.type;
|
|
301
|
-
let estimatedFee;
|
|
304
|
+
let estimatedFee = '0';
|
|
302
305
|
let feeOptions;
|
|
303
306
|
let maxTransferable;
|
|
304
307
|
let error;
|
|
@@ -307,20 +310,22 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
307
310
|
const isSnowBridgeEvmTransfer = (0, _utils._isPureEvmChain)(srcChain) && (0, _xcmParser._isSnowBridgeXcm)(srcChain, destChain) && !isAvailBridgeFromEvm;
|
|
308
311
|
const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(srcChain.slug, destChain.slug);
|
|
309
312
|
const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(srcChain.slug, destChain.slug);
|
|
313
|
+
const isAcrossBridgeTransfer = (0, _acrossBridge._isAcrossChainBridge)(srcChain.slug, destChain.slug);
|
|
314
|
+
const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer);
|
|
310
315
|
const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
|
|
311
316
|
const substrateAddress = fakeAddress; // todo: move this
|
|
312
317
|
const evmAddress = (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(fakeAddress)); // todo: move this
|
|
313
|
-
|
|
318
|
+
const bnFreeBalance = new _bignumber.default(freeBalance.value);
|
|
314
319
|
const recipient = (0, _utils._isChainEvmCompatible)(destChain) ? evmAddress : substrateAddress;
|
|
320
|
+
if (!destToken) {
|
|
321
|
+
throw Error('Destination token is not available');
|
|
322
|
+
}
|
|
315
323
|
try {
|
|
316
|
-
if (!destToken) {
|
|
317
|
-
throw Error('Destination token is not available');
|
|
318
|
-
}
|
|
319
324
|
const params = {
|
|
320
325
|
destinationTokenInfo: destToken,
|
|
321
326
|
originTokenInfo: srcToken,
|
|
322
327
|
// If value is 0, substrate will throw error when estimating fee
|
|
323
|
-
sendingValue:
|
|
328
|
+
sendingValue: value,
|
|
324
329
|
sender: address,
|
|
325
330
|
recipient,
|
|
326
331
|
destinationChain: destChain,
|
|
@@ -334,6 +339,13 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
334
339
|
let funcCreateExtrinsic;
|
|
335
340
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
336
341
|
funcCreateExtrinsic = _xcm.createPolygonBridgeExtrinsic;
|
|
342
|
+
} else if (isAcrossBridgeTransfer) {
|
|
343
|
+
funcCreateExtrinsic = _xcm.createAcrossBridgeExtrinsic;
|
|
344
|
+
if ((0, _acrossBridge._isAcrossTestnetBridge)(srcChain.slug)) {
|
|
345
|
+
params.sendingValue = (0, _bignumber.default)(0.0037).shiftedBy((0, _utils._getAssetDecimals)(srcToken)).toFixed(0, 1);
|
|
346
|
+
} else {
|
|
347
|
+
params.sendingValue = (0, _bignumber.default)(1).shiftedBy((0, _utils._getAssetDecimals)(srcToken)).toFixed(0, 1);
|
|
348
|
+
}
|
|
337
349
|
} else if (isSnowBridgeEvmTransfer) {
|
|
338
350
|
funcCreateExtrinsic = _xcm.createSnowBridgeExtrinsic;
|
|
339
351
|
} else if (isAvailBridgeFromEvm) {
|
|
@@ -341,9 +353,12 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
341
353
|
} else if (isAvailBridgeFromAvail) {
|
|
342
354
|
funcCreateExtrinsic = _xcm.createAvailBridgeExtrinsicFromAvail;
|
|
343
355
|
} else {
|
|
344
|
-
funcCreateExtrinsic = _xcm.
|
|
356
|
+
funcCreateExtrinsic = _xcm.createXcmExtrinsicV2;
|
|
357
|
+
params.sendingValue = '1';
|
|
345
358
|
}
|
|
346
359
|
const extrinsic = await funcCreateExtrinsic(params);
|
|
360
|
+
|
|
361
|
+
// todo: refactor condition
|
|
347
362
|
if (feeChainType === 'evm') {
|
|
348
363
|
var _tx$gas2;
|
|
349
364
|
// Calculate fee for evm transaction
|
|
@@ -363,12 +378,17 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
363
378
|
};
|
|
364
379
|
} else if (feeChainType === 'substrate') {
|
|
365
380
|
// Calculate fee for substrate transaction
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
381
|
+
if (isSubstrateXcm) {
|
|
382
|
+
const estimatedFeeByDryRun = await (0, _xcm.dryRunXcmExtrinsicV2)(params);
|
|
383
|
+
estimatedFee = estimatedFeeByDryRun.fee || '0';
|
|
384
|
+
} else {
|
|
385
|
+
try {
|
|
386
|
+
var _paymentInfo$partialF2;
|
|
387
|
+
const paymentInfo = await extrinsic.paymentInfo(address);
|
|
388
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
389
|
+
} catch (e) {
|
|
390
|
+
estimatedFee = '0';
|
|
391
|
+
}
|
|
372
392
|
}
|
|
373
393
|
const _feeCustom = feeCustom;
|
|
374
394
|
const tip = (0, _combine.combineSubstrateFee)(fee, feeOption, _feeCustom).tip;
|
|
@@ -408,12 +428,12 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
408
428
|
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(srcChain.slug)) {
|
|
409
429
|
const estimatedFeeNative = (BigInt(estimatedFee) * BigInt(_utils2.FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString();
|
|
410
430
|
const estimatedFeeLocal = await (0, _utils2.calculateToAmountByReservePool)(substrateApi.api, nativeToken, srcToken, estimatedFeeNative);
|
|
411
|
-
maxTransferable =
|
|
431
|
+
maxTransferable = bnFreeBalance.minus(estimatedFeeLocal);
|
|
412
432
|
} else if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(srcChain.slug)) {
|
|
413
433
|
const rate = await (0, _tokenPayFee.getHydrationRate)(address, nativeToken, srcToken);
|
|
414
434
|
if (rate) {
|
|
415
435
|
const estimatedFeeLocal = new _bignumber.default(estimatedFee).multipliedBy(rate).integerValue(_bignumber.default.ROUND_UP).toString();
|
|
416
|
-
maxTransferable =
|
|
436
|
+
maxTransferable = bnFreeBalance.minus(estimatedFeeLocal);
|
|
417
437
|
} else {
|
|
418
438
|
throw new Error(`Unable to estimate fee for ${srcChain.slug}.`);
|
|
419
439
|
}
|
|
@@ -421,16 +441,20 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
421
441
|
throw new Error(`Unable to estimate fee for ${srcChain.slug}.`);
|
|
422
442
|
}
|
|
423
443
|
} else if (isTransferNativeTokenAndPayLocalTokenAsFee) {
|
|
424
|
-
maxTransferable =
|
|
444
|
+
maxTransferable = bnFreeBalance;
|
|
425
445
|
} else {
|
|
426
446
|
if (!(0, _utils._isNativeToken)(srcToken)) {
|
|
427
|
-
maxTransferable =
|
|
447
|
+
maxTransferable = bnFreeBalance;
|
|
428
448
|
} else {
|
|
429
|
-
maxTransferable = (0, _bignumber.default)(
|
|
449
|
+
maxTransferable = bnFreeBalance.minus((0, _bignumber.default)(estimatedFee).multipliedBy(_constants.XCM_FEE_RATIO));
|
|
430
450
|
}
|
|
431
451
|
}
|
|
452
|
+
if (isAvailBridgeFromAvail) {
|
|
453
|
+
const addedAmount = (0, _bignumber.default)(1).shiftedBy((0, _utils._getAssetDecimals)(srcToken));
|
|
454
|
+
maxTransferable = maxTransferable.minus(addedAmount);
|
|
455
|
+
}
|
|
432
456
|
return {
|
|
433
|
-
maxTransferable: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0)
|
|
457
|
+
maxTransferable: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0) : '0',
|
|
434
458
|
feeOptions: feeOptions,
|
|
435
459
|
feeType: feeChainType,
|
|
436
460
|
id: id,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.oldChainPrefix = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.blockedActions = exports.StaticKey = void 0;
|
|
6
|
+
exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.paraSpellChainMap = exports.oldChainPrefix = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.blockedActions = exports.StaticKey = void 0;
|
|
7
7
|
var _chainList = require("@subwallet/chain-list");
|
|
8
8
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -39,7 +39,10 @@ const blockedActions = require('./blockedActions.json');
|
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
40
40
|
exports.blockedActions = blockedActions;
|
|
41
41
|
const oldChainPrefix = require('./oldChainPrefix.json');
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
42
43
|
exports.oldChainPrefix = oldChainPrefix;
|
|
44
|
+
const paraSpellChainMap = require('./paraSpellChainMap.json');
|
|
45
|
+
exports.paraSpellChainMap = paraSpellChainMap;
|
|
43
46
|
let StaticKey;
|
|
44
47
|
exports.StaticKey = StaticKey;
|
|
45
48
|
(function (StaticKey) {
|
|
@@ -54,6 +57,7 @@ exports.StaticKey = StaticKey;
|
|
|
54
57
|
StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
|
|
55
58
|
StaticKey["BLOCKED_ACTIONS"] = "blocked-actions";
|
|
56
59
|
StaticKey["OLD_CHAIN_PREFIX"] = "old-chain-prefix";
|
|
60
|
+
StaticKey["PARASPELL_CHAIN_MAP"] = "paraspell-chain-map";
|
|
57
61
|
})(StaticKey || (exports.StaticKey = StaticKey = {}));
|
|
58
62
|
const staticData = {
|
|
59
63
|
[StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
|
|
@@ -66,6 +70,7 @@ const staticData = {
|
|
|
66
70
|
[StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
|
|
67
71
|
[StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime,
|
|
68
72
|
[StaticKey.BLOCKED_ACTIONS]: blockedActions,
|
|
69
|
-
[StaticKey.OLD_CHAIN_PREFIX]: oldChainPrefix
|
|
73
|
+
[StaticKey.OLD_CHAIN_PREFIX]: oldChainPrefix,
|
|
74
|
+
[StaticKey.PARASPELL_CHAIN_MAP]: paraSpellChainMap
|
|
70
75
|
};
|
|
71
76
|
exports.staticData = staticData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fetchParaSpellChainMap(): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { fetchStaticData } from '@subwallet/extension-base/utils';
|
|
5
|
+
export async function fetchParaSpellChainMap() {
|
|
6
|
+
return await fetchStaticData('paraspell-chain-map');
|
|
7
|
+
}
|
|
@@ -17,3 +17,4 @@ export declare function estimateFeeForTransaction(validationResponse: SWTransact
|
|
|
17
17
|
export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>): void;
|
|
18
18
|
export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData): void;
|
|
19
19
|
export declare function checkTonAddressBounceableAndAccountNotActive(tonApi: _TonApi, validationResponse: SWTransactionResponse): Promise<void>;
|
|
20
|
+
export declare function validateXcmMinAmountToMythos(destChain: string, destToken: string, amount: string): TransactionError | undefined;
|
|
@@ -315,7 +315,8 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
|
|
|
315
315
|
if (transaction) {
|
|
316
316
|
try {
|
|
317
317
|
if (isSubstrateTransaction(transaction)) {
|
|
318
|
-
|
|
318
|
+
var _validationResponse$x;
|
|
319
|
+
estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
319
320
|
} else if (isTonTransaction(transaction)) {
|
|
320
321
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
321
322
|
} else if (isCardanoTransaction(transaction)) {
|
|
@@ -443,4 +444,14 @@ function isTonAddressBounceable(address) {
|
|
|
443
444
|
async function isAccountActive(tonApi, address) {
|
|
444
445
|
const state = await tonApi.getAccountState(address);
|
|
445
446
|
return state === 'active';
|
|
447
|
+
}
|
|
448
|
+
export function validateXcmMinAmountToMythos(destChain, destToken, amount) {
|
|
449
|
+
const MYTHOS_DESTINATION_FEE = '2500000000000000000';
|
|
450
|
+
const errorMsg = 'Enter an amount higher than 2.5 MYTH to pay cross-chain fee and avoid your MYTH being lost after the transaction';
|
|
451
|
+
if (destChain === 'mythos' && destToken === 'mythos-NATIVE-MYTH') {
|
|
452
|
+
if (BigN(amount).lte(MYTHOS_DESTINATION_FEE)) {
|
|
453
|
+
return new TransactionError(TransferTxErrorType.NOT_ENOUGH_VALUE, t(errorMsg));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return undefined;
|
|
446
457
|
}
|
|
@@ -55,4 +55,5 @@ export declare function _isAvailBridgeXcm(originChainInfo: _ChainInfo, destChain
|
|
|
55
55
|
export declare function _isMythosFromHydrationToMythos(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): boolean;
|
|
56
56
|
export declare function _isPolygonBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
57
57
|
export declare function _isPosBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
58
|
+
export declare function _isAcrossBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
58
59
|
export declare function _adaptX1Interior(_assetIdentifier: Record<string, any>, version: number): Record<string, any>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
|
+
import { _isAcrossChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
5
6
|
import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
6
7
|
import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
7
8
|
import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
@@ -127,7 +128,9 @@ export function _isPolygonBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
127
128
|
export function _isPosBridgeXcm(originChainInfo, destChainInfo) {
|
|
128
129
|
return _isPosChainBridge(originChainInfo.slug, destChainInfo.slug);
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
+
export function _isAcrossBridgeXcm(originChainInfo, destChainInfo) {
|
|
132
|
+
return _isAcrossChainBridge(originChainInfo.slug, destChainInfo.slug);
|
|
133
|
+
}
|
|
131
134
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
132
135
|
|
|
133
136
|
function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
|
package/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { ExtrinsicType, SufficientChainsDetails } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { LedgerMustCheckType, ValidateRecipientParams } from '@subwallet/extension-base/core/types';
|
|
4
4
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
5
5
|
import { AccountJson } from '@subwallet/extension-base/types';
|
|
@@ -15,4 +15,4 @@ export declare function _isValidTonAddressFormat(validateRecipientParams: Valida
|
|
|
15
15
|
export declare function _isValidCardanoAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
|
|
16
16
|
export declare function _isNotDuplicateAddress(validateRecipientParams: ValidateRecipientParams): string;
|
|
17
17
|
export declare function _isSupportLedgerAccount(validateRecipientParams: ValidateRecipientParams): string;
|
|
18
|
-
export declare const _isSufficientToken: (tokenInfo: _ChainAsset, substrateApi: _SubstrateApi) => Promise<boolean>;
|
|
18
|
+
export declare const _isSufficientToken: (tokenInfo: _ChainAsset, substrateApi: _SubstrateApi, sufficientChain: SufficientChainsDetails) => Promise<boolean>;
|
package/core/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ import { _AssetType } from '@subwallet/chain-list/types';
|
|
|
5
5
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
7
7
|
import { tonAddressInfo } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
|
|
8
|
-
import { SUFFICIENT_CHAIN } from '@subwallet/extension-base/services/chain-service/constants';
|
|
9
8
|
import { _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isBridgedToken, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
9
|
import { isAddressAndChainCompatible, isSameAddress, reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
10
|
import { isAddress, isCardanoTestnetAddress, isTonAddress } from '@subwallet/keyring';
|
|
@@ -132,27 +131,49 @@ export function _isSupportLedgerAccount(validateRecipientParams) {
|
|
|
132
131
|
}
|
|
133
132
|
return '';
|
|
134
133
|
}
|
|
135
|
-
export const _isSufficientToken = async (tokenInfo, substrateApi) => {
|
|
136
|
-
|
|
137
|
-
if (
|
|
134
|
+
export const _isSufficientToken = async (tokenInfo, substrateApi, sufficientChain) => {
|
|
135
|
+
var _tokenInfo$metadata;
|
|
136
|
+
if (tokenInfo.assetType !== _AssetType.NATIVE) {
|
|
138
137
|
const assetId = _isBridgedToken(tokenInfo) ? _getXcmAssetMultilocation(tokenInfo) : _getTokenOnChainAssetId(tokenInfo);
|
|
138
|
+
const chainSlug = tokenInfo.originChain;
|
|
139
139
|
const queryParams = {
|
|
140
140
|
section: 'query',
|
|
141
|
-
module: 'foreignAssets',
|
|
142
|
-
method: 'asset',
|
|
143
141
|
args: [assetId]
|
|
144
142
|
};
|
|
145
|
-
if (
|
|
143
|
+
if (sufficientChain.assetHubPallet.includes(chainSlug)) {
|
|
144
|
+
if (!_isBridgedToken(tokenInfo)) {
|
|
145
|
+
queryParams.module = 'assets';
|
|
146
|
+
} else {
|
|
147
|
+
queryParams.module = 'foreignAssets';
|
|
148
|
+
}
|
|
149
|
+
queryParams.method = 'asset';
|
|
150
|
+
}
|
|
151
|
+
if (sufficientChain.assetRegistryPallet.includes(chainSlug)) {
|
|
152
|
+
queryParams.module = 'assetRegistry';
|
|
153
|
+
queryParams.method = 'assets';
|
|
154
|
+
}
|
|
155
|
+
if (sufficientChain.assetsPallet.includes(chainSlug)) {
|
|
146
156
|
queryParams.module = 'assets';
|
|
157
|
+
queryParams.method = 'asset';
|
|
158
|
+
}
|
|
159
|
+
if (sufficientChain.foreignAssetsPallet.includes(chainSlug)) {
|
|
160
|
+
queryParams.module = 'foreignAsset';
|
|
161
|
+
queryParams.method = 'asset';
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
if (queryParams.method && queryParams.module) {
|
|
165
|
+
const metadata = await substrateApi.makeRpcQuery(queryParams);
|
|
166
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient) !== undefined) {
|
|
167
|
+
return metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} catch (e) {
|
|
171
|
+
console.error(e);
|
|
147
172
|
}
|
|
148
|
-
const metadata = await substrateApi.makeRpcQuery(queryParams);
|
|
149
|
-
return (metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient) || false;
|
|
150
173
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// }
|
|
156
|
-
|
|
174
|
+
if ((_tokenInfo$metadata = tokenInfo.metadata) !== null && _tokenInfo$metadata !== void 0 && _tokenInfo$metadata.isSufficient) {
|
|
175
|
+
var _tokenInfo$metadata2;
|
|
176
|
+
return (_tokenInfo$metadata2 = tokenInfo.metadata) === null || _tokenInfo$metadata2 === void 0 ? void 0 : _tokenInfo$metadata2.isSufficient;
|
|
177
|
+
}
|
|
157
178
|
return false;
|
|
158
179
|
};
|