@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
|
@@ -1355,6 +1355,12 @@ export interface TokenPriorityDetails {
|
|
|
1355
1355
|
tokenGroup: Record<string, number>;
|
|
1356
1356
|
token: Record<string, number>;
|
|
1357
1357
|
}
|
|
1358
|
+
export interface SufficientChainsDetails {
|
|
1359
|
+
assetHubPallet: string[];
|
|
1360
|
+
assetsPallet: string[];
|
|
1361
|
+
foreignAssetsPallet: string[];
|
|
1362
|
+
assetRegistryPallet: string[];
|
|
1363
|
+
}
|
|
1358
1364
|
export interface RequestConnectWalletConnect {
|
|
1359
1365
|
uri: string;
|
|
1360
1366
|
}
|
|
@@ -1529,6 +1535,11 @@ export interface ResponseMigrateSoloAccount {
|
|
|
1529
1535
|
export interface RequestPingSession {
|
|
1530
1536
|
sessionId: string;
|
|
1531
1537
|
}
|
|
1538
|
+
export interface ExtrinsicsDataResponse {
|
|
1539
|
+
extrinsics: {
|
|
1540
|
+
id: string;
|
|
1541
|
+
}[];
|
|
1542
|
+
}
|
|
1532
1543
|
export declare type _Address = string;
|
|
1533
1544
|
export declare type _BalanceMetadata = unknown;
|
|
1534
1545
|
export interface KoniRequestSignatures {
|
|
@@ -1553,6 +1564,7 @@ export interface KoniRequestSignatures {
|
|
|
1553
1564
|
'pri(chainService.upsertChain)': [_NetworkUpsertParams, boolean];
|
|
1554
1565
|
'pri(chainService.enableChains)': [EnableMultiChainParams, boolean];
|
|
1555
1566
|
'pri(chainService.enableChain)': [EnableChainParams, boolean];
|
|
1567
|
+
'pri(chainService.enableChainWithPriorityAssets)': [EnableChainParams, boolean];
|
|
1556
1568
|
'pri(chainService.reconnectChain)': [string, boolean];
|
|
1557
1569
|
'pri(chainService.disableChains)': [string[], boolean];
|
|
1558
1570
|
'pri(chainService.disableChain)': [string, boolean];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fetchParaSpellChainMap = fetchParaSpellChainMap;
|
|
7
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
8
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
11
|
+
async function fetchParaSpellChainMap() {
|
|
12
|
+
return await (0, _utils.fetchStaticData)('paraspell-chain-map');
|
|
13
|
+
}
|
|
@@ -13,6 +13,7 @@ exports.checkSupportForTransaction = checkSupportForTransaction;
|
|
|
13
13
|
exports.checkTonAddressBounceableAndAccountNotActive = checkTonAddressBounceableAndAccountNotActive;
|
|
14
14
|
exports.estimateFeeForTransaction = estimateFeeForTransaction;
|
|
15
15
|
exports.validateTransferRequest = validateTransferRequest;
|
|
16
|
+
exports.validateXcmMinAmountToMythos = validateXcmMinAmountToMythos;
|
|
16
17
|
exports.validateXcmTransferRequest = validateXcmTransferRequest;
|
|
17
18
|
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
18
19
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
@@ -330,7 +331,8 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
330
331
|
if (transaction) {
|
|
331
332
|
try {
|
|
332
333
|
if ((0, _helpers.isSubstrateTransaction)(transaction)) {
|
|
333
|
-
|
|
334
|
+
var _validationResponse$x;
|
|
335
|
+
estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
334
336
|
} else if ((0, _helpers.isTonTransaction)(transaction)) {
|
|
335
337
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
336
338
|
} else if ((0, _helpers.isCardanoTransaction)(transaction)) {
|
|
@@ -458,4 +460,14 @@ function isTonAddressBounceable(address) {
|
|
|
458
460
|
async function isAccountActive(tonApi, address) {
|
|
459
461
|
const state = await tonApi.getAccountState(address);
|
|
460
462
|
return state === 'active';
|
|
463
|
+
}
|
|
464
|
+
function validateXcmMinAmountToMythos(destChain, destToken, amount) {
|
|
465
|
+
const MYTHOS_DESTINATION_FEE = '2500000000000000000';
|
|
466
|
+
const errorMsg = 'Enter an amount higher than 2.5 MYTH to pay cross-chain fee and avoid your MYTH being lost after the transaction';
|
|
467
|
+
if (destChain === 'mythos' && destToken === 'mythos-NATIVE-MYTH') {
|
|
468
|
+
if ((0, _bignumber.default)(amount).lte(MYTHOS_DESTINATION_FEE)) {
|
|
469
|
+
return new _TransactionError.TransactionError(_types.TransferTxErrorType.NOT_ENOUGH_VALUE, (0, _i18next.t)(errorMsg));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return undefined;
|
|
461
473
|
}
|
|
@@ -9,6 +9,7 @@ exports._getXcmDestWeight = _getXcmDestWeight;
|
|
|
9
9
|
exports._getXcmMultiAssets = _getXcmMultiAssets;
|
|
10
10
|
exports._getXcmMultiLocation = _getXcmMultiLocation;
|
|
11
11
|
exports._getXcmUnstableWarning = _getXcmUnstableWarning;
|
|
12
|
+
exports._isAcrossBridgeXcm = _isAcrossBridgeXcm;
|
|
12
13
|
exports._isAvailBridgeXcm = _isAvailBridgeXcm;
|
|
13
14
|
exports._isMythosFromHydrationToMythos = _isMythosFromHydrationToMythos;
|
|
14
15
|
exports._isPolygonBridgeXcm = _isPolygonBridgeXcm;
|
|
@@ -17,6 +18,7 @@ exports._isSnowBridgeXcm = _isSnowBridgeXcm;
|
|
|
17
18
|
exports._isXcmTransferUnstable = _isXcmTransferUnstable;
|
|
18
19
|
exports._isXcmWithinSameConsensus = _isXcmWithinSameConsensus;
|
|
19
20
|
var _chainList = require("@subwallet/chain-list");
|
|
21
|
+
var _acrossBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge");
|
|
20
22
|
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
21
23
|
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
22
24
|
var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
|
|
@@ -145,7 +147,9 @@ function _isPolygonBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
145
147
|
function _isPosBridgeXcm(originChainInfo, destChainInfo) {
|
|
146
148
|
return (0, _posBridge._isPosChainBridge)(originChainInfo.slug, destChainInfo.slug);
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
function _isAcrossBridgeXcm(originChainInfo, destChainInfo) {
|
|
151
|
+
return (0, _acrossBridge._isAcrossChainBridge)(originChainInfo.slug, destChainInfo.slug);
|
|
152
|
+
}
|
|
149
153
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
150
154
|
|
|
151
155
|
function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
|
package/cjs/core/utils.js
CHANGED
|
@@ -20,7 +20,6 @@ var _types = require("@subwallet/chain-list/types");
|
|
|
20
20
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
21
21
|
var _types2 = require("@subwallet/extension-base/core/substrate/types");
|
|
22
22
|
var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils");
|
|
23
|
-
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
24
23
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
25
24
|
var _utils3 = require("@subwallet/extension-base/utils");
|
|
26
25
|
var _keyring = require("@subwallet/keyring");
|
|
@@ -150,28 +149,50 @@ function _isSupportLedgerAccount(validateRecipientParams) {
|
|
|
150
149
|
}
|
|
151
150
|
return '';
|
|
152
151
|
}
|
|
153
|
-
const _isSufficientToken = async (tokenInfo, substrateApi) => {
|
|
154
|
-
|
|
155
|
-
if (
|
|
152
|
+
const _isSufficientToken = async (tokenInfo, substrateApi, sufficientChain) => {
|
|
153
|
+
var _tokenInfo$metadata;
|
|
154
|
+
if (tokenInfo.assetType !== _types._AssetType.NATIVE) {
|
|
156
155
|
const assetId = (0, _utils2._isBridgedToken)(tokenInfo) ? (0, _utils2._getXcmAssetMultilocation)(tokenInfo) : (0, _utils2._getTokenOnChainAssetId)(tokenInfo);
|
|
156
|
+
const chainSlug = tokenInfo.originChain;
|
|
157
157
|
const queryParams = {
|
|
158
158
|
section: 'query',
|
|
159
|
-
module: 'foreignAssets',
|
|
160
|
-
method: 'asset',
|
|
161
159
|
args: [assetId]
|
|
162
160
|
};
|
|
163
|
-
if (
|
|
161
|
+
if (sufficientChain.assetHubPallet.includes(chainSlug)) {
|
|
162
|
+
if (!(0, _utils2._isBridgedToken)(tokenInfo)) {
|
|
163
|
+
queryParams.module = 'assets';
|
|
164
|
+
} else {
|
|
165
|
+
queryParams.module = 'foreignAssets';
|
|
166
|
+
}
|
|
167
|
+
queryParams.method = 'asset';
|
|
168
|
+
}
|
|
169
|
+
if (sufficientChain.assetRegistryPallet.includes(chainSlug)) {
|
|
170
|
+
queryParams.module = 'assetRegistry';
|
|
171
|
+
queryParams.method = 'assets';
|
|
172
|
+
}
|
|
173
|
+
if (sufficientChain.assetsPallet.includes(chainSlug)) {
|
|
164
174
|
queryParams.module = 'assets';
|
|
175
|
+
queryParams.method = 'asset';
|
|
176
|
+
}
|
|
177
|
+
if (sufficientChain.foreignAssetsPallet.includes(chainSlug)) {
|
|
178
|
+
queryParams.module = 'foreignAsset';
|
|
179
|
+
queryParams.method = 'asset';
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
if (queryParams.method && queryParams.module) {
|
|
183
|
+
const metadata = await substrateApi.makeRpcQuery(queryParams);
|
|
184
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient) !== undefined) {
|
|
185
|
+
return metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch (e) {
|
|
189
|
+
console.error(e);
|
|
165
190
|
}
|
|
166
|
-
const metadata = await substrateApi.makeRpcQuery(queryParams);
|
|
167
|
-
return (metadata === null || metadata === void 0 ? void 0 : metadata.isSufficient) || false;
|
|
168
191
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// }
|
|
174
|
-
|
|
192
|
+
if ((_tokenInfo$metadata = tokenInfo.metadata) !== null && _tokenInfo$metadata !== void 0 && _tokenInfo$metadata.isSufficient) {
|
|
193
|
+
var _tokenInfo$metadata2;
|
|
194
|
+
return (_tokenInfo$metadata2 = tokenInfo.metadata) === null || _tokenInfo$metadata2 === void 0 ? void 0 : _tokenInfo$metadata2.isSufficient;
|
|
195
|
+
}
|
|
175
196
|
return false;
|
|
176
197
|
};
|
|
177
198
|
exports._isSufficientToken = _isSufficientToken;
|