@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
|
@@ -9,12 +9,12 @@ import { withErrorLog } from '@subwallet/extension-base/background/handlers/help
|
|
|
9
9
|
import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions';
|
|
10
10
|
import { CampaignDataType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, MantaPayEnableMessage, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
11
11
|
import { _SUPPORT_TOKEN_PAY_FEE_GROUP, ALL_ACCOUNT_KEY, LATEST_SESSION } from '@subwallet/extension-base/constants';
|
|
12
|
-
import { additionalValidateTransferForRecipient, validateTransferRequest, validateXcmTransferRequest } from '@subwallet/extension-base/core/logic-validation/transfer';
|
|
12
|
+
import { additionalValidateTransferForRecipient, validateTransferRequest, validateXcmMinAmountToMythos, validateXcmTransferRequest } from '@subwallet/extension-base/core/logic-validation/transfer';
|
|
13
13
|
import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
14
14
|
import { _isSufficientToken } from '@subwallet/extension-base/core/utils';
|
|
15
15
|
import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
|
|
16
16
|
import { getERC20SpendingApprovalTx } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
17
|
-
import { _ERC721_ABI
|
|
17
|
+
import { _ERC721_ABI } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
18
18
|
import { resolveAzeroAddressToDomain, resolveAzeroDomainToAddress } from '@subwallet/extension-base/koni/api/dotsama/domain';
|
|
19
19
|
import { parseSubstrateTransaction } from '@subwallet/extension-base/koni/api/dotsama/parseTransaction';
|
|
20
20
|
import { UNSUPPORTED_TRANSFER_EVM_CHAIN_NAME } from '@subwallet/extension-base/koni/api/nft/config';
|
|
@@ -29,7 +29,8 @@ import { createCardanoTransaction } from '@subwallet/extension-base/services/bal
|
|
|
29
29
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
30
30
|
import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
31
31
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
32
|
-
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic,
|
|
32
|
+
import { createAcrossBridgeExtrinsic, createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsicV2, dryRunXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
33
|
+
import { _isAcrossChainBridge, getAcrossQuote } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
33
34
|
import { getClaimTxOnAvail, getClaimTxOnEthereum, isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
34
35
|
import { _isPolygonChainBridge, getClaimPolygonBridge, isClaimedPolygonBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
35
36
|
import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
@@ -1104,9 +1105,10 @@ export default class KoniExtension {
|
|
|
1104
1105
|
owner,
|
|
1105
1106
|
spenderAddress
|
|
1106
1107
|
} = params;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1108
|
+
|
|
1109
|
+
// if (!isSnowBridgeGatewayContract(spenderAddress) && !isAvailBridgeGatewayContract(spenderAddress)) {
|
|
1110
|
+
// throw new Error('Only SnowBridge and AvailBridge is supported'); // todo: support all ERC20 spending approval
|
|
1111
|
+
// }
|
|
1110
1112
|
|
|
1111
1113
|
const evmApi = this.#koniState.getEvmApi(chain);
|
|
1112
1114
|
const transactionConfig = await getERC20SpendingApprovalTx(spenderAddress, owner, contractAddress, evmApi, amount);
|
|
@@ -1298,7 +1300,8 @@ export default class KoniExtension {
|
|
|
1298
1300
|
const receiverSendingTokenKeepAliveBalance = BigInt(_receiverSendingTokenKeepAliveBalance);
|
|
1299
1301
|
const amount = BigInt(transferAmount.value);
|
|
1300
1302
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1301
|
-
const
|
|
1303
|
+
const sufficientChain = this.#koniState.chainService.value.sufficientChains;
|
|
1304
|
+
const isSendingTokenSufficient = await _isSufficientToken(transferTokenInfo, substrateApi, sufficientChain);
|
|
1302
1305
|
const [warnings, errors] = additionalValidateTransferForRecipient(transferTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, amount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient);
|
|
1303
1306
|
warnings.length && inputTransaction.warnings.push(...warnings);
|
|
1304
1307
|
errors.length && inputTransaction.errors.push(...errors);
|
|
@@ -1350,7 +1353,7 @@ export default class KoniExtension {
|
|
|
1350
1353
|
const destinationNativeTokenInfo = this.#koniState.getNativeTokenInfo(destinationNetworkKey);
|
|
1351
1354
|
const destinationNativeTokenSlug = destinationNativeTokenInfo.slug;
|
|
1352
1355
|
const [errors, fromKeyPair] = validateXcmTransferRequest(destinationTokenInfo, from, value);
|
|
1353
|
-
let extrinsic
|
|
1356
|
+
let extrinsic;
|
|
1354
1357
|
if (errors.length > 0) {
|
|
1355
1358
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
|
|
1356
1359
|
}
|
|
@@ -1360,9 +1363,12 @@ export default class KoniExtension {
|
|
|
1360
1363
|
const isSnowBridgeEvmTransfer = _isPureEvmChain(chainInfoMap[originNetworkKey]) && _isSnowBridgeXcm(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]) && !isAvailBridgeFromEvm;
|
|
1361
1364
|
const isPolygonBridgeTransfer = _isPolygonChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1362
1365
|
const isPosBridgeTransfer = _isPosChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1366
|
+
const isAcrossBridgeTransfer = _isAcrossChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1363
1367
|
const extrinsicType = ExtrinsicType.TRANSFER_XCM;
|
|
1368
|
+
const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer);
|
|
1364
1369
|
const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
|
|
1365
1370
|
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
|
|
1371
|
+
let xcmFeeDryRun;
|
|
1366
1372
|
let additionalValidator;
|
|
1367
1373
|
let eventsHandler;
|
|
1368
1374
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1373,6 +1379,9 @@ export default class KoniExtension {
|
|
|
1373
1379
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
1374
1380
|
funcCreateExtrinsic = createPolygonBridgeExtrinsic;
|
|
1375
1381
|
type = 'evm';
|
|
1382
|
+
} else if (isAcrossBridgeTransfer) {
|
|
1383
|
+
funcCreateExtrinsic = createAcrossBridgeExtrinsic;
|
|
1384
|
+
type = 'evm';
|
|
1376
1385
|
} else if (isSnowBridgeEvmTransfer) {
|
|
1377
1386
|
funcCreateExtrinsic = createSnowBridgeExtrinsic;
|
|
1378
1387
|
type = 'evm';
|
|
@@ -1383,7 +1392,7 @@ export default class KoniExtension {
|
|
|
1383
1392
|
funcCreateExtrinsic = createAvailBridgeExtrinsicFromAvail;
|
|
1384
1393
|
type = 'substrate';
|
|
1385
1394
|
} else {
|
|
1386
|
-
funcCreateExtrinsic =
|
|
1395
|
+
funcCreateExtrinsic = createXcmExtrinsicV2;
|
|
1387
1396
|
type = 'substrate';
|
|
1388
1397
|
}
|
|
1389
1398
|
const feeInfo = await this.#koniState.feeService.subscribeChainFee(getId(), originNetworkKey, type);
|
|
@@ -1402,6 +1411,19 @@ export default class KoniExtension {
|
|
|
1402
1411
|
feeInfo
|
|
1403
1412
|
};
|
|
1404
1413
|
extrinsic = await funcCreateExtrinsic(params);
|
|
1414
|
+
let dryRunInfo;
|
|
1415
|
+
if (isSubstrateXcm) {
|
|
1416
|
+
dryRunInfo = await dryRunXcmExtrinsicV2(params);
|
|
1417
|
+
xcmFeeDryRun = dryRunInfo.fee;
|
|
1418
|
+
}
|
|
1419
|
+
if (isAcrossBridgeTransfer) {
|
|
1420
|
+
const metadata = await getAcrossQuote(params);
|
|
1421
|
+
inputData.metadata = {
|
|
1422
|
+
amountOut: metadata.outputAmount,
|
|
1423
|
+
rate: metadata.rate,
|
|
1424
|
+
destChainSlug: destinationTokenInfo.slug
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1405
1427
|
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(originNetworkKey)) {
|
|
1406
1428
|
var _this$koniState$chain2, _substrateApi$api$que2;
|
|
1407
1429
|
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain2 = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.assetId);
|
|
@@ -1411,11 +1433,20 @@ export default class KoniExtension {
|
|
|
1411
1433
|
extrinsic = batchExtrinsicSetFeeHydration(substrateApi, _extrinsic, feeSetting, hydrationFeeAssetId);
|
|
1412
1434
|
}
|
|
1413
1435
|
additionalValidator = async inputTransaction => {
|
|
1436
|
+
// hotfix xcm mythos to mythos chain
|
|
1437
|
+
const mythosError = validateXcmMinAmountToMythos(destinationNetworkKey, destinationTokenInfo.slug, value);
|
|
1438
|
+
if (mythosError) {
|
|
1439
|
+
inputTransaction.errors.push(mythosError);
|
|
1440
|
+
}
|
|
1414
1441
|
let isSendingTokenSufficient = false;
|
|
1415
1442
|
let receiverSystemAccountInfo;
|
|
1416
1443
|
if (!_isChainSubstrateCompatible(chainInfoMap[destinationNetworkKey])) {
|
|
1417
1444
|
return undefined;
|
|
1418
1445
|
}
|
|
1446
|
+
const setting = {
|
|
1447
|
+
visible: true
|
|
1448
|
+
};
|
|
1449
|
+
await this.#koniState.chainService.updateAssetSetting(destinationTokenInfo.slug, setting, true);
|
|
1419
1450
|
const {
|
|
1420
1451
|
value: _senderTransferable
|
|
1421
1452
|
} = await this.getAddressTransferableBalance({
|
|
@@ -1443,15 +1474,17 @@ export default class KoniExtension {
|
|
|
1443
1474
|
});
|
|
1444
1475
|
receiverSystemAccountInfo = _receiverNativeTotal.metadata;
|
|
1445
1476
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
}
|
|
1477
|
+
const substrateApi = this.#koniState.getSubstrateApi(destinationNetworkKey);
|
|
1478
|
+
const sufficientChain = this.#koniState.chainService.value.sufficientChains;
|
|
1479
|
+
isSendingTokenSufficient = await _isSufficientToken(destinationTokenInfo, substrateApi, sufficientChain);
|
|
1450
1480
|
const [warning, error] = additionalValidateTransferForRecipient(destinationTokenInfo, destinationNativeTokenInfo, extrinsicType, receiverDestinationTokenKeepAliveBalance, sendingAmount, senderTransferable,
|
|
1451
1481
|
// different from sendingTokenInfo being passed in
|
|
1452
1482
|
receiverSystemAccountInfo, isSendingTokenSufficient);
|
|
1453
1483
|
warning.length && inputTransaction.warnings.push(...warning);
|
|
1454
1484
|
error.length && inputTransaction.errors.push(...error);
|
|
1485
|
+
if (isSubstrateXcm && !dryRunInfo.success) {
|
|
1486
|
+
inputTransaction.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Unable to perform transaction. Select another token or destination chain and try again'));
|
|
1487
|
+
}
|
|
1455
1488
|
};
|
|
1456
1489
|
eventsHandler = eventEmitter => {
|
|
1457
1490
|
eventEmitter.on('send', () => {
|
|
@@ -1484,13 +1517,14 @@ export default class KoniExtension {
|
|
|
1484
1517
|
transaction: extrinsic,
|
|
1485
1518
|
data: inputData,
|
|
1486
1519
|
extrinsicType,
|
|
1487
|
-
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1520
|
+
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer && !isAcrossBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1488
1521
|
transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
|
|
1489
1522
|
ignoreWarnings,
|
|
1490
1523
|
tokenPayFeeSlug,
|
|
1491
1524
|
isTransferAll: transferAll,
|
|
1492
1525
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1493
1526
|
isPassConfirmation,
|
|
1527
|
+
xcmFeeDryRun,
|
|
1494
1528
|
errors,
|
|
1495
1529
|
additionalValidator: additionalValidator,
|
|
1496
1530
|
eventsHandler: eventsHandler
|
|
@@ -1621,6 +1655,12 @@ export default class KoniExtension {
|
|
|
1621
1655
|
}) {
|
|
1622
1656
|
return await this.#koniState.enableChain(chainSlug, enableTokens);
|
|
1623
1657
|
}
|
|
1658
|
+
async enableChainWithPriorityAssets({
|
|
1659
|
+
chainSlug,
|
|
1660
|
+
enableTokens
|
|
1661
|
+
}) {
|
|
1662
|
+
return await this.#koniState.enableChainWithPriorityAssets(chainSlug, enableTokens);
|
|
1663
|
+
}
|
|
1624
1664
|
async reconnectChain(chainSlug) {
|
|
1625
1665
|
return this.#koniState.chainService.reconnectChain(chainSlug);
|
|
1626
1666
|
}
|
|
@@ -1729,7 +1769,8 @@ export default class KoniExtension {
|
|
|
1729
1769
|
feeCustom,
|
|
1730
1770
|
feeOption,
|
|
1731
1771
|
token,
|
|
1732
|
-
tokenPayFeeSlug
|
|
1772
|
+
tokenPayFeeSlug,
|
|
1773
|
+
value
|
|
1733
1774
|
} = request;
|
|
1734
1775
|
const cb = createSubscription(id, port);
|
|
1735
1776
|
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
@@ -1749,6 +1790,8 @@ export default class KoniExtension {
|
|
|
1749
1790
|
}
|
|
1750
1791
|
const _request = {
|
|
1751
1792
|
address: address,
|
|
1793
|
+
value,
|
|
1794
|
+
// todo: lazy subscribe to improve performance
|
|
1752
1795
|
cardanoApi: this.#koniState.chainService.getCardanoApi(chain),
|
|
1753
1796
|
destChain,
|
|
1754
1797
|
destToken,
|
|
@@ -4389,6 +4432,8 @@ export default class KoniExtension {
|
|
|
4389
4432
|
return this.getSupportedSmartContractTypes();
|
|
4390
4433
|
case 'pri(chainService.enableChain)':
|
|
4391
4434
|
return await this.enableChain(request);
|
|
4435
|
+
case 'pri(chainService.enableChainWithPriorityAssets)':
|
|
4436
|
+
return await this.enableChainWithPriorityAssets(request);
|
|
4392
4437
|
case 'pri(chainService.reconnectChain)':
|
|
4393
4438
|
return await this.reconnectChain(request);
|
|
4394
4439
|
case 'pri(chainService.disableChain)':
|
|
@@ -185,6 +185,7 @@ export default class KoniState {
|
|
|
185
185
|
private getDefaultNetworkKeys;
|
|
186
186
|
disableChain(chainSlug: string): Promise<boolean>;
|
|
187
187
|
enableChain(chainSlug: string, enableTokens?: boolean): Promise<boolean>;
|
|
188
|
+
enableChainWithPriorityAssets(chainSlug: string, enableTokens?: boolean): Promise<boolean>;
|
|
188
189
|
resetDefaultChains(): boolean;
|
|
189
190
|
getSubstrateApiMap(): Record<string, import("@subwallet/extension-base/services/chain-service/types")._SubstrateApi>;
|
|
190
191
|
getSubstrateApi(networkKey: string): import("@subwallet/extension-base/services/chain-service/types")._SubstrateApi;
|
|
@@ -428,7 +428,7 @@ export default class KoniState {
|
|
|
428
428
|
const chainState = this.chainService.getChainStateByKey(networkKey);
|
|
429
429
|
if (authUrls[shortenUrl]) {
|
|
430
430
|
if (chainInfo && !_isChainEnabled(chainState)) {
|
|
431
|
-
await this.
|
|
431
|
+
await this.enableChainWithPriorityAssets(networkKey);
|
|
432
432
|
}
|
|
433
433
|
authUrls[shortenUrl].currentEvmNetworkKey = networkKey;
|
|
434
434
|
this.setAuthorize(authUrls);
|
|
@@ -699,6 +699,12 @@ export default class KoniState {
|
|
|
699
699
|
}
|
|
700
700
|
return this.chainService.enableChain(chainSlug);
|
|
701
701
|
}
|
|
702
|
+
async enableChainWithPriorityAssets(chainSlug, enableTokens = true) {
|
|
703
|
+
if (enableTokens) {
|
|
704
|
+
await this.chainService.updatePriorityAssetsByChain(chainSlug, true);
|
|
705
|
+
}
|
|
706
|
+
return this.chainService.enableChain(chainSlug);
|
|
707
|
+
}
|
|
702
708
|
resetDefaultChains() {
|
|
703
709
|
const defaultChains = this.getDefaultNetworkKeys();
|
|
704
710
|
return this.chainService.resetChainInfoMap(defaultChains);
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.31-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -129,6 +129,11 @@
|
|
|
129
129
|
"require": "./cjs/constants/i18n.js",
|
|
130
130
|
"default": "./constants/i18n.js"
|
|
131
131
|
},
|
|
132
|
+
"./constants/paraspell-chain-map": {
|
|
133
|
+
"types": "./constants/paraspell-chain-map.d.ts",
|
|
134
|
+
"require": "./cjs/constants/paraspell-chain-map.js",
|
|
135
|
+
"default": "./constants/paraspell-chain-map.js"
|
|
136
|
+
},
|
|
132
137
|
"./constants/remind-notification-time": {
|
|
133
138
|
"types": "./constants/remind-notification-time.d.ts",
|
|
134
139
|
"require": "./cjs/constants/remind-notification-time.js",
|
|
@@ -739,6 +744,11 @@
|
|
|
739
744
|
"require": "./cjs/services/balance-service/transfer/xcm/index.js",
|
|
740
745
|
"default": "./services/balance-service/transfer/xcm/index.js"
|
|
741
746
|
},
|
|
747
|
+
"./services/balance-service/transfer/xcm/acrossBridge": {
|
|
748
|
+
"types": "./services/balance-service/transfer/xcm/acrossBridge/index.d.ts",
|
|
749
|
+
"require": "./cjs/services/balance-service/transfer/xcm/acrossBridge/index.js",
|
|
750
|
+
"default": "./services/balance-service/transfer/xcm/acrossBridge/index.js"
|
|
751
|
+
},
|
|
742
752
|
"./services/balance-service/transfer/xcm/availBridge": {
|
|
743
753
|
"types": "./services/balance-service/transfer/xcm/availBridge.d.ts",
|
|
744
754
|
"require": "./cjs/services/balance-service/transfer/xcm/availBridge.js",
|
|
@@ -1401,6 +1411,11 @@
|
|
|
1401
1411
|
"require": "./cjs/services/migration-service/scripts/DeleteEarningData.js",
|
|
1402
1412
|
"default": "./services/migration-service/scripts/DeleteEarningData.js"
|
|
1403
1413
|
},
|
|
1414
|
+
"./services/migration-service/scripts/DisableZeroBalanceTokens": {
|
|
1415
|
+
"types": "./services/migration-service/scripts/DisableZeroBalanceTokens.d.ts",
|
|
1416
|
+
"require": "./cjs/services/migration-service/scripts/DisableZeroBalanceTokens.js",
|
|
1417
|
+
"default": "./services/migration-service/scripts/DisableZeroBalanceTokens.js"
|
|
1418
|
+
},
|
|
1404
1419
|
"./services/migration-service/scripts/EnableChain": {
|
|
1405
1420
|
"types": "./services/migration-service/scripts/EnableChain.d.ts",
|
|
1406
1421
|
"require": "./cjs/services/migration-service/scripts/EnableChain.js",
|
|
@@ -2615,6 +2630,7 @@
|
|
|
2615
2630
|
"./utils/staticData/currencySymbol.json": "./utils/staticData/currencySymbol.json",
|
|
2616
2631
|
"./utils/staticData/marketingCampaigns.json": "./utils/staticData/marketingCampaigns.json",
|
|
2617
2632
|
"./utils/staticData/oldChainPrefix.json": "./utils/staticData/oldChainPrefix.json",
|
|
2633
|
+
"./utils/staticData/paraSpellChainMap.json": "./utils/staticData/paraSpellChainMap.json",
|
|
2618
2634
|
"./utils/staticData/remindNotificationTime.json": "./utils/staticData/remindNotificationTime.json",
|
|
2619
2635
|
"./utils/staticData/termAndCondition.json": "./utils/staticData/termAndCondition.json",
|
|
2620
2636
|
"./utils/swap": {
|
|
@@ -2663,13 +2679,13 @@
|
|
|
2663
2679
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2664
2680
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2665
2681
|
"@substrate/connect": "^0.8.9",
|
|
2666
|
-
"@subwallet/chain-list": "0.2.
|
|
2667
|
-
"@subwallet/extension-base": "^1.3.
|
|
2668
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2669
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2670
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2682
|
+
"@subwallet/chain-list": "0.2.103",
|
|
2683
|
+
"@subwallet/extension-base": "^1.3.31-1",
|
|
2684
|
+
"@subwallet/extension-chains": "^1.3.31-1",
|
|
2685
|
+
"@subwallet/extension-dapp": "^1.3.31-1",
|
|
2686
|
+
"@subwallet/extension-inject": "^1.3.31-1",
|
|
2671
2687
|
"@subwallet/keyring": "^0.1.9",
|
|
2672
|
-
"@subwallet/subwallet-api-sdk": "^1.3.
|
|
2688
|
+
"@subwallet/subwallet-api-sdk": "^1.3.31-1",
|
|
2673
2689
|
"@subwallet/ui-keyring": "^0.1.9",
|
|
2674
2690
|
"@ton/core": "^0.56.3",
|
|
2675
2691
|
"@ton/crypto": "^3.2.0",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.31-1'
|
|
11
11
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
1
|
+
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _Address } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
4
|
import { CommonOptimalTransferPath } from '@subwallet/extension-base/types/service-base';
|
|
@@ -11,3 +11,4 @@ export interface RequestOptimalTransferProcess {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function getDefaultTransferProcess(): CommonOptimalTransferPath;
|
|
13
13
|
export declare function getSnowbridgeTransferProcessFromEvm(address: string, evmApi: _EvmApi, tokenInfo: _ChainAsset, amount: string): Promise<CommonOptimalTransferPath>;
|
|
14
|
+
export declare function getAcrossbridgeTransferProcessFromEvm(originChainInfo: _ChainInfo): Promise<CommonOptimalTransferPath>;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
5
|
import { CommonStepType, DEFAULT_FIRST_STEP, MOCK_STEP_FEE } from '@subwallet/extension-base/types/service-base';
|
|
6
|
+
import { _getEvmChainId } from "../../chain-service/utils/index.js";
|
|
7
|
+
import { SpokePoolMapping } from "../transfer/xcm/acrossBridge/index.js";
|
|
6
8
|
export function getDefaultTransferProcess() {
|
|
7
9
|
return {
|
|
8
10
|
totalFee: [MOCK_STEP_FEE, MOCK_STEP_FEE],
|
|
@@ -34,6 +36,30 @@ export async function getSnowbridgeTransferProcessFromEvm(address, evmApi, token
|
|
|
34
36
|
// if (!allowance || BigInt(allowance) < BigInt(amount)) {
|
|
35
37
|
// }
|
|
36
38
|
|
|
39
|
+
result.steps.push({
|
|
40
|
+
id: result.steps.length,
|
|
41
|
+
type: CommonStepType.TRANSFER,
|
|
42
|
+
name: 'Transfer'
|
|
43
|
+
});
|
|
44
|
+
result.totalFee.push(MOCK_STEP_FEE);
|
|
45
|
+
return Promise.resolve(result);
|
|
46
|
+
}
|
|
47
|
+
export async function getAcrossbridgeTransferProcessFromEvm(originChainInfo) {
|
|
48
|
+
const chainId = _getEvmChainId(originChainInfo);
|
|
49
|
+
const SpokePoolAddress = SpokePoolMapping[chainId].SpokePool.address;
|
|
50
|
+
const result = {
|
|
51
|
+
totalFee: [MOCK_STEP_FEE],
|
|
52
|
+
steps: [DEFAULT_FIRST_STEP]
|
|
53
|
+
};
|
|
54
|
+
result.steps.push({
|
|
55
|
+
id: result.steps.length,
|
|
56
|
+
type: CommonStepType.TOKEN_APPROVAL,
|
|
57
|
+
name: 'Approve spending',
|
|
58
|
+
metadata: {
|
|
59
|
+
SpokePoolAddress
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
result.totalFee.push(MOCK_STEP_FEE);
|
|
37
63
|
result.steps.push({
|
|
38
64
|
id: result.steps.length,
|
|
39
65
|
type: CommonStepType.TRANSFER,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
5
|
import { APIItemState } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
-
import { SUB_TOKEN_REFRESH_BALANCE_INTERVAL } from '@subwallet/extension-base/constants';
|
|
6
|
+
import { CRON_REFRESH_PRICE_INTERVAL, SUB_TOKEN_REFRESH_BALANCE_INTERVAL } from '@subwallet/extension-base/constants';
|
|
7
7
|
import { _getAssetsPalletLocked, _getAssetsPalletTransferable } from '@subwallet/extension-base/core/substrate/assets-pallet';
|
|
8
8
|
import { _getForeignAssetPalletLockedBalance, _getForeignAssetPalletTransferable } from '@subwallet/extension-base/core/substrate/foreign-asset-pallet';
|
|
9
9
|
import { _getTotalStakeInNominationPool } from '@subwallet/extension-base/core/substrate/nominationpools-pallet';
|
|
@@ -17,6 +17,7 @@ import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@
|
|
|
17
17
|
import { _checkSmartContractSupportByChain, _getAssetExistentialDeposit, _getAssetNetuid, _getChainExistentialDeposit, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
18
18
|
import { filterAlphaAssetsByChain, filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
|
|
19
19
|
import BigN from 'bignumber.js';
|
|
20
|
+
import { timer } from 'rxjs';
|
|
20
21
|
import { subscribeERC20Interval } from "../evm.js";
|
|
21
22
|
import { subscribeEquilibriumTokenBalance } from "./equilibrium.js";
|
|
22
23
|
import { subscribeGRC20Balance, subscribeVftBalance } from "./gear.js";
|
|
@@ -323,7 +324,19 @@ const subscribeTokensAccountsPallet = async ({
|
|
|
323
324
|
const tokensAccountsKey = 'query_tokens_accounts';
|
|
324
325
|
const tokenTypes = includeNativeToken ? [_AssetType.NATIVE, _AssetType.LOCAL] : [_AssetType.LOCAL];
|
|
325
326
|
const tokenMap = filterAssetsByChainAndType(assetMap, chainInfo.slug, tokenTypes);
|
|
327
|
+
|
|
328
|
+
// Hotfix balance for gdot
|
|
329
|
+
const getGdotBalance = async () => {
|
|
330
|
+
const gdotBalances = await queryGdotBalance(substrateApi, addresses, assetMap[gdotSlug], extrinsicType);
|
|
331
|
+
callback(gdotBalances);
|
|
332
|
+
};
|
|
326
333
|
const unsubList = await Promise.all(Object.values(tokenMap).map(tokenInfo => {
|
|
334
|
+
// Hotfix balance for gdot
|
|
335
|
+
if (tokenInfo.slug === gdotSlug) {
|
|
336
|
+
return timer(0, CRON_REFRESH_PRICE_INTERVAL).subscribe(() => {
|
|
337
|
+
getGdotBalance().catch(console.error);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
327
340
|
try {
|
|
328
341
|
const params = [{
|
|
329
342
|
section: 'query',
|
|
@@ -529,4 +542,23 @@ const subscribeSubnetAlphaPallet = async ({
|
|
|
529
542
|
cancel = true;
|
|
530
543
|
clearInterval(interval);
|
|
531
544
|
};
|
|
532
|
-
};
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// Hot fix for gdot balance
|
|
548
|
+
|
|
549
|
+
const gdotSlug = 'hydradx_main-LOCAL-GDOT';
|
|
550
|
+
async function queryGdotBalance(substrateApi, addresses, tokenInfo, extrinsicType) {
|
|
551
|
+
return await Promise.all(addresses.map(async address => {
|
|
552
|
+
const _balanceInfo = await substrateApi.api.call.currenciesApi.account(_getTokenOnChainAssetId(tokenInfo), address);
|
|
553
|
+
const balanceInfo = _balanceInfo.toPrimitive();
|
|
554
|
+
const transferableBalance = _getTokensPalletTransferable(balanceInfo, _getAssetExistentialDeposit(tokenInfo), extrinsicType);
|
|
555
|
+
const totalLockedFromTransfer = _getTokensPalletLocked(balanceInfo);
|
|
556
|
+
return {
|
|
557
|
+
address,
|
|
558
|
+
tokenSlug: tokenInfo.slug,
|
|
559
|
+
state: APIItemState.READY,
|
|
560
|
+
free: transferableBalance.toString(),
|
|
561
|
+
locked: totalLockedFromTransfer.toString()
|
|
562
|
+
};
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
@@ -5,9 +5,9 @@ import { BalanceError } from '@subwallet/extension-base/background/errors/Balanc
|
|
|
5
5
|
import { APIItemState, BalanceErrorType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
7
7
|
import { _isXcmWithinSameConsensus } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
8
|
-
import { getDefaultTransferProcess, getSnowbridgeTransferProcessFromEvm } from '@subwallet/extension-base/services/balance-service/helpers/process';
|
|
8
|
+
import { getAcrossbridgeTransferProcessFromEvm, getDefaultTransferProcess, getSnowbridgeTransferProcessFromEvm } from '@subwallet/extension-base/services/balance-service/helpers/process';
|
|
9
9
|
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
10
|
-
import { _getChainNativeTokenSlug, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
|
+
import { _getChainNativeTokenSlug, _isNativeToken, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
11
|
import DetectAccountBalanceStore from '@subwallet/extension-base/stores/DetectAccountBalance';
|
|
12
12
|
import { addLazy, createPromiseHandler, isAccountAll, waitTimeout } from '@subwallet/extension-base/utils';
|
|
13
13
|
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
@@ -18,6 +18,7 @@ import BigN from 'bignumber.js';
|
|
|
18
18
|
import { t } from 'i18next';
|
|
19
19
|
import { BehaviorSubject } from 'rxjs';
|
|
20
20
|
import { noop } from '@polkadot/util';
|
|
21
|
+
import { _isAcrossChainBridge } from "./transfer/xcm/acrossBridge/index.js";
|
|
21
22
|
import { BalanceMapImpl } from "./BalanceMapImpl.js";
|
|
22
23
|
import { subscribeBalance } from "./helpers/index.js";
|
|
23
24
|
|
|
@@ -571,6 +572,14 @@ export class BalanceService {
|
|
|
571
572
|
const tokenInfo = this.state.chainService.getAssetBySlug(params.tokenSlug);
|
|
572
573
|
return getSnowbridgeTransferProcessFromEvm(params.address, evmApi, tokenInfo, params.amount);
|
|
573
574
|
}
|
|
575
|
+
|
|
576
|
+
// Across Bridge
|
|
577
|
+
if (_isAcrossChainBridge(originChainInfo.slug, destChainInfo.slug)) {
|
|
578
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(params.tokenSlug);
|
|
579
|
+
if (!_isNativeToken(tokenInfo)) {
|
|
580
|
+
return getAcrossbridgeTransferProcessFromEvm(originChainInfo);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
574
583
|
return getDefaultTransferProcess();
|
|
575
584
|
}
|
|
576
585
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CreateXcmExtrinsicProps } from '..';
|
|
2
|
+
export declare function _isAcrossChainBridge(srcChain: string, destChain: string): boolean;
|
|
3
|
+
export declare function _isAcrossTestnetBridge(srcChain: string): boolean;
|
|
4
|
+
export declare const SpokePoolMapping: Record<number, {
|
|
5
|
+
SpokePool: {
|
|
6
|
+
address: string;
|
|
7
|
+
blockNumber: number;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
interface AcrossQuote {
|
|
11
|
+
outputAmount: string;
|
|
12
|
+
rate: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const getAcrossQuote: ({ destinationChain, destinationTokenInfo, originChain, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<AcrossQuote>;
|
|
15
|
+
export {};
|