@subwallet/extension-base 1.3.23-0 → 1.3.25-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.
Files changed (91) hide show
  1. package/background/KoniTypes.d.ts +11 -3
  2. package/background/KoniTypes.js +1 -0
  3. package/background/errors/EvmProviderError.js +4 -0
  4. package/background/errors/ProviderError.d.ts +1 -1
  5. package/background/errors/ProviderError.js +2 -2
  6. package/cjs/background/KoniTypes.js +1 -0
  7. package/cjs/background/errors/EvmProviderError.js +4 -0
  8. package/cjs/background/errors/ProviderError.js +2 -2
  9. package/cjs/constants/environment.js +1 -1
  10. package/cjs/constants/index.js +21 -4
  11. package/cjs/core/logic-validation/transfer.js +23 -8
  12. package/cjs/koni/background/handlers/Extension.js +109 -89
  13. package/cjs/koni/background/handlers/State.js +2 -2
  14. package/cjs/koni/background/handlers/Tabs.js +4 -3
  15. package/cjs/packageInfo.js +1 -1
  16. package/cjs/page/index.js +1 -1
  17. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +3 -3
  18. package/cjs/services/balance-service/transfer/smart-contract.js +24 -3
  19. package/cjs/services/buy-service/constants/token.js +3 -0
  20. package/cjs/services/chain-service/index.js +11 -0
  21. package/cjs/services/earning-service/constants/chains.js +1 -1
  22. package/cjs/services/earning-service/handlers/base.js +11 -5
  23. package/cjs/services/earning-service/handlers/native-staking/base-para.js +7 -6
  24. package/cjs/services/earning-service/handlers/native-staking/base.js +6 -3
  25. package/cjs/services/earning-service/handlers/native-staking/dtao.js +444 -0
  26. package/cjs/services/earning-service/handlers/native-staking/index.js +8 -1
  27. package/cjs/services/earning-service/handlers/native-staking/tao.js +138 -125
  28. package/cjs/services/earning-service/service.js +14 -4
  29. package/cjs/services/fee-service/utils/tokenPayFee.js +151 -0
  30. package/cjs/services/inapp-notification-service/index.js +3 -0
  31. package/cjs/services/request-service/handler/MetadataRequestHandler.js +5 -13
  32. package/cjs/services/request-service/index.js +2 -2
  33. package/cjs/services/transaction-service/index.js +14 -5
  34. package/cjs/types/yield/info/base.js +1 -0
  35. package/cjs/utils/fee/transfer.js +47 -14
  36. package/cjs/utils/fetchEvmChainInfo.js +10 -5
  37. package/constants/environment.js +1 -1
  38. package/constants/index.d.ts +6 -1
  39. package/constants/index.js +14 -1
  40. package/core/logic-validation/transfer.d.ts +1 -1
  41. package/core/logic-validation/transfer.js +25 -10
  42. package/koni/background/handlers/Extension.js +82 -62
  43. package/koni/background/handlers/State.d.ts +1 -1
  44. package/koni/background/handlers/State.js +2 -2
  45. package/koni/background/handlers/Tabs.js +4 -3
  46. package/package.json +16 -6
  47. package/packageInfo.js +1 -1
  48. package/page/index.js +1 -1
  49. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -2
  50. package/services/balance-service/transfer/smart-contract.d.ts +4 -2
  51. package/services/balance-service/transfer/smart-contract.js +24 -3
  52. package/services/buy-service/constants/token.js +3 -0
  53. package/services/chain-service/index.d.ts +1 -0
  54. package/services/chain-service/index.js +12 -1
  55. package/services/earning-service/constants/chains.js +1 -1
  56. package/services/earning-service/handlers/base.d.ts +7 -5
  57. package/services/earning-service/handlers/base.js +11 -7
  58. package/services/earning-service/handlers/native-staking/base-para.d.ts +1 -1
  59. package/services/earning-service/handlers/native-staking/base-para.js +7 -6
  60. package/services/earning-service/handlers/native-staking/base.d.ts +1 -1
  61. package/services/earning-service/handlers/native-staking/base.js +6 -3
  62. package/services/earning-service/handlers/native-staking/dtao.d.ts +64 -0
  63. package/services/earning-service/handlers/native-staking/dtao.js +434 -0
  64. package/services/earning-service/handlers/native-staking/index.d.ts +1 -0
  65. package/services/earning-service/handlers/native-staking/index.js +2 -1
  66. package/services/earning-service/handlers/native-staking/tao.d.ts +16 -4
  67. package/services/earning-service/handlers/native-staking/tao.js +136 -121
  68. package/services/earning-service/service.d.ts +1 -0
  69. package/services/earning-service/service.js +15 -5
  70. package/services/fee-service/interfaces.d.ts +25 -0
  71. package/services/fee-service/utils/tokenPayFee.d.ts +8 -0
  72. package/services/fee-service/utils/tokenPayFee.js +141 -0
  73. package/services/inapp-notification-service/index.js +3 -0
  74. package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -1
  75. package/services/request-service/handler/MetadataRequestHandler.js +5 -13
  76. package/services/request-service/index.d.ts +1 -1
  77. package/services/request-service/index.js +2 -2
  78. package/services/transaction-service/index.js +16 -7
  79. package/types/bridge/index.d.ts +1 -0
  80. package/types/buy.d.ts +1 -1
  81. package/types/fee/option.d.ts +1 -1
  82. package/types/yield/actions/join/step.d.ts +1 -0
  83. package/types/yield/actions/join/submit.d.ts +1 -0
  84. package/types/yield/info/account/info.d.ts +14 -1
  85. package/types/yield/info/base.d.ts +3 -1
  86. package/types/yield/info/base.js +1 -0
  87. package/types/yield/info/chain/info.d.ts +5 -1
  88. package/utils/fee/transfer.d.ts +1 -1
  89. package/utils/fee/transfer.js +46 -13
  90. package/utils/fetchEvmChainInfo.d.ts +1 -1
  91. package/utils/fetchEvmChainInfo.js +10 -5
@@ -8,7 +8,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
8
8
  import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
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
- import { ALL_ACCOUNT_KEY, ASSET_HUB_CHAIN_SLUGS, LATEST_SESSION } from '@subwallet/extension-base/constants';
11
+ import { _SUPPORT_TOKEN_PAY_FEE_GROUP, ALL_ACCOUNT_KEY, LATEST_SESSION } from '@subwallet/extension-base/constants';
12
12
  import { additionalValidateTransferForRecipient, additionalValidateXcmTransfer, validateTransferRequest, validateXcmTransferRequest } from '@subwallet/extension-base/core/logic-validation/transfer';
13
13
  import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
14
14
  import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
@@ -34,11 +34,11 @@ import { _isPolygonChainBridge, getClaimPolygonBridge, isClaimedPolygonBridge }
34
34
  import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
35
35
  import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX, SUFFICIENT_CHAIN } from '@subwallet/extension-base/services/chain-service/constants';
36
36
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
37
- import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isAssetSmartContractNft, _isBridgedToken, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
37
+ import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isAssetSmartContractNft, _isBridgedToken, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
38
38
  import { calculateToAmountByReservePool } from '@subwallet/extension-base/services/fee-service/utils';
39
+ import { batchExtrinsicSetFeeHydration, getAssetHubTokensCanPayFee, getHydrationTokensCanPayFee } from '@subwallet/extension-base/services/fee-service/utils/tokenPayFee';
39
40
  import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
40
41
  import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
41
- import { checkLiquidityForPool, estimateTokensForPool, getReserveForPool } from '@subwallet/extension-base/services/swap-service/handler/asset-hub/utils';
42
42
  import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
43
43
  import { SWStorage } from '@subwallet/extension-base/storage';
44
44
  import { AccountsStore } from '@subwallet/extension-base/stores';
@@ -1131,8 +1131,8 @@ export default class KoniExtension {
1131
1131
  feeCustom,
1132
1132
  feeOption,
1133
1133
  from,
1134
- nonNativeTokenPayFeeSlug,
1135
1134
  to,
1135
+ tokenPayFeeSlug,
1136
1136
  tokenSlug,
1137
1137
  transferAll,
1138
1138
  transferBounceable,
@@ -1145,7 +1145,9 @@ export default class KoniExtension {
1145
1145
  const nativeTokenInfo = this.#koniState.getNativeTokenInfo(chain);
1146
1146
  const nativeTokenSlug = nativeTokenInfo.slug;
1147
1147
  const isTransferNativeToken = nativeTokenSlug === tokenSlug;
1148
- const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken && nonNativeTokenPayFeeSlug === tokenSlug;
1148
+ const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken && tokenPayFeeSlug === tokenSlug;
1149
+ const isCustomTokenPayFeeAssetHub = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug) && _SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain);
1150
+ const isCustomTokenPayFeeHydration = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug) && _SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain);
1149
1151
  const extrinsicType = isTransferNativeToken ? ExtrinsicType.TRANSFER_BALANCE : ExtrinsicType.TRANSFER_TOKEN;
1150
1152
  let chainType = ChainType.SUBSTRATE;
1151
1153
  const transferAmount = {
@@ -1236,6 +1238,13 @@ export default class KoniExtension {
1236
1238
  to: to,
1237
1239
  substrateApi
1238
1240
  });
1241
+ if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
1242
+ var _this$koniState$chain, _substrateApi$api$que;
1243
+ const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain === void 0 ? void 0 : _this$koniState$chain.assetId);
1244
+ const _feeSetting = await ((_substrateApi$api$que = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.accountCurrencyMap(from));
1245
+ const feeSetting = _feeSetting.toPrimitive();
1246
+ transaction = batchExtrinsicSetFeeHydration(substrateApi, transaction, feeSetting, hydrationFeeAssetId);
1247
+ }
1239
1248
  }
1240
1249
  } catch (e) {
1241
1250
  const error = e;
@@ -1253,11 +1262,11 @@ export default class KoniExtension {
1253
1262
  }
1254
1263
 
1255
1264
  // Check enough free local to pay fee local
1256
- if (nonNativeTokenPayFeeSlug) {
1257
- var _inputTransaction$est;
1265
+ if (isCustomTokenPayFeeAssetHub || isCustomTokenPayFeeHydration) {
1266
+ var _inputTransaction$est, _nonNativeTokenPayFee;
1258
1267
  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
1259
- const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance(reformatAddress(from), chain, nonNativeTokenPayFeeSlug);
1260
- const nonNativeTokenPayFeeBalance = BigInt(nonNativeTokenPayFeeInfo[nonNativeTokenPayFeeSlug].free);
1268
+ const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance(reformatAddress(from), chain, tokenPayFeeSlug);
1269
+ const nonNativeTokenPayFeeBalance = BigInt(((_nonNativeTokenPayFee = nonNativeTokenPayFeeInfo[tokenPayFeeSlug]) === null || _nonNativeTokenPayFee === void 0 ? void 0 : _nonNativeTokenPayFee.free) || '0');
1261
1270
  if (nonNativeFee > nonNativeTokenPayFeeBalance) {
1262
1271
  inputTransaction.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
1263
1272
  }
@@ -1309,7 +1318,7 @@ export default class KoniExtension {
1309
1318
  chain,
1310
1319
  feeCustom,
1311
1320
  feeOption,
1312
- nonNativeTokenPayFeeSlug,
1321
+ tokenPayFeeSlug,
1313
1322
  chainType,
1314
1323
  transferNativeAmount,
1315
1324
  transaction,
@@ -1329,9 +1338,9 @@ export default class KoniExtension {
1329
1338
  feeOption,
1330
1339
  from,
1331
1340
  isPassConfirmation,
1332
- nonNativeTokenPayFeeSlug,
1333
1341
  originNetworkKey,
1334
1342
  to,
1343
+ tokenPayFeeSlug,
1335
1344
  tokenSlug,
1336
1345
  transferAll,
1337
1346
  transferBounceable,
@@ -1351,7 +1360,7 @@ export default class KoniExtension {
1351
1360
  const isPolygonBridgeTransfer = _isPolygonChainBridge(originNetworkKey, destinationNetworkKey);
1352
1361
  const isPosBridgeTransfer = _isPosChainBridge(originNetworkKey, destinationNetworkKey);
1353
1362
  const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
1354
- const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === nonNativeTokenPayFeeSlug;
1363
+ const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
1355
1364
  let additionalValidator;
1356
1365
  let eventsHandler;
1357
1366
  if (fromKeyPair && destinationTokenInfo) {
@@ -1391,6 +1400,14 @@ export default class KoniExtension {
1391
1400
  feeInfo
1392
1401
  };
1393
1402
  extrinsic = await funcCreateExtrinsic(params);
1403
+ if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(originNetworkKey)) {
1404
+ var _this$koniState$chain2, _substrateApi$api$que2;
1405
+ const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain2 = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.assetId);
1406
+ const _feeSetting = await ((_substrateApi$api$que2 = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.accountCurrencyMap(from));
1407
+ const feeSetting = _feeSetting.toPrimitive();
1408
+ const _extrinsic = extrinsic;
1409
+ extrinsic = batchExtrinsicSetFeeHydration(substrateApi, _extrinsic, feeSetting, hydrationFeeAssetId);
1410
+ }
1394
1411
  additionalValidator = async inputTransaction => {
1395
1412
  const {
1396
1413
  value: senderTransferable
@@ -1449,7 +1466,7 @@ export default class KoniExtension {
1449
1466
  chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
1450
1467
  transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
1451
1468
  ignoreWarnings,
1452
- nonNativeTokenPayFeeSlug,
1469
+ tokenPayFeeSlug,
1453
1470
  isTransferAll: transferAll,
1454
1471
  isTransferLocalTokenAndPayThatTokenAsFee,
1455
1472
  isPassConfirmation,
@@ -1468,48 +1485,51 @@ export default class KoniExtension {
1468
1485
  const chainService = this.#koniState.chainService;
1469
1486
  const substrateApi = this.#koniState.getSubstrateApi(chain);
1470
1487
  const address = reformatAddress(_address);
1471
-
1472
- // ensure nativeTokenInfo and localTokenInfo have multi-location metadata beforehand to improve performance.
1473
1488
  const tokensHasBalanceInfoMap = await this.#koniState.balanceService.getTokensHasBalance(address, chain);
1474
- const tokensHasBalanceSlug = Object.keys(tokensHasBalanceInfoMap);
1475
- const tokenInfos = tokensHasBalanceSlug.map(tokenSlug => chainService.getAssetBySlug(tokenSlug)).filter(token => token.originChain === chain && token.assetType !== _AssetType.NATIVE && token.metadata && token.metadata.multilocation);
1476
1489
  const nativeTokenInfo = chainService.getNativeTokenInfo(chain);
1477
- const nativeTokenBalanceInfo = {
1490
+ const nativeBalanceInfo = {
1478
1491
  slug: nativeTokenInfo.slug,
1479
1492
  free: ((_tokensHasBalanceInfo = tokensHasBalanceInfoMap[nativeTokenInfo.slug]) === null || _tokensHasBalanceInfo === void 0 ? void 0 : _tokensHasBalanceInfo.free) || '0',
1480
1493
  rate: '1'
1481
1494
  };
1482
- const tokensCanPayFee = [nativeTokenBalanceInfo];
1483
- if (!ASSET_HUB_CHAIN_SLUGS.includes(chain) || !nativeTokenInfo.metadata || !nativeTokenInfo.metadata.multilocation) {
1484
- return tokensCanPayFee;
1485
- }
1486
- await Promise.all(tokenInfos.map(async tokenInfo => {
1487
- try {
1488
- const tokenSlug = tokenInfo.slug;
1489
- const reserve = await getReserveForPool(substrateApi.api, nativeTokenInfo, tokenInfo);
1490
- if (!reserve || !reserve[0] || !reserve[1] || reserve[0] === '0' || reserve[1] === '0') {
1491
- return;
1492
- }
1493
- const rate = new BigN(reserve[1]).div(reserve[0]).toFixed();
1494
- const tokenCanPayFee = {
1495
- slug: tokenSlug,
1496
- free: tokensHasBalanceInfoMap[tokenSlug].free,
1497
- rate
1498
- };
1499
- if (feeAmount === undefined) {
1500
- tokensCanPayFee.push(tokenCanPayFee);
1501
- } else {
1502
- const amount = estimateTokensForPool(feeAmount, reserve);
1503
- const liquidityError = checkLiquidityForPool(amount, reserve[0], reserve[1]);
1504
- if (!liquidityError) {
1505
- tokensCanPayFee.push(tokenCanPayFee);
1506
- }
1495
+ let tokensCanPayFee = [nativeBalanceInfo];
1496
+ let defaultTokenSlug = nativeBalanceInfo.slug;
1497
+ if (_SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain)) {
1498
+ tokensCanPayFee = await getAssetHubTokensCanPayFee({
1499
+ substrateApi,
1500
+ chainService,
1501
+ nativeTokenInfo,
1502
+ nativeBalanceInfo,
1503
+ tokensHasBalanceInfoMap,
1504
+ feeAmount
1505
+ });
1506
+ } else if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
1507
+ const _assetId = await substrateApi.api.query.multiTransactionPayment.accountCurrencyMap(address);
1508
+ const assetId = _assetId.toPrimitive();
1509
+ const hydrationAssets = this.#koniState.chainService.getHydrationAssetIdMap(chain);
1510
+ for (const [key, value] of Object.entries(hydrationAssets)) {
1511
+ if (assetId && assetId.toString() === value) {
1512
+ defaultTokenSlug = key;
1513
+ break;
1507
1514
  }
1508
- } catch (e) {
1509
- console.error('error when fetching pool with token', tokenInfo.slug, e);
1510
1515
  }
1511
- }));
1512
- return tokensCanPayFee;
1516
+ tokensCanPayFee = await getHydrationTokensCanPayFee({
1517
+ substrateApi,
1518
+ chainService,
1519
+ nativeTokenInfo,
1520
+ nativeBalanceInfo,
1521
+ tokensHasBalanceInfoMap,
1522
+ address,
1523
+ feeAmount
1524
+ });
1525
+ if (!tokensCanPayFee.map(token => token.slug).includes(defaultTokenSlug)) {
1526
+ defaultTokenSlug = nativeBalanceInfo.slug;
1527
+ }
1528
+ }
1529
+ return {
1530
+ tokensCanPayFee,
1531
+ defaultTokenSlug
1532
+ };
1513
1533
  }
1514
1534
  async getAmountForPair(request) {
1515
1535
  const {
@@ -1706,13 +1726,13 @@ export default class KoniExtension {
1706
1726
  destChain: _destChain,
1707
1727
  feeCustom,
1708
1728
  feeOption,
1709
- nonNativeTokenPayFeeSlug,
1710
- token
1729
+ token,
1730
+ tokenPayFeeSlug
1711
1731
  } = request;
1712
1732
  const cb = createSubscription(id, port);
1713
1733
  const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(token);
1714
- const isTransferLocalTokenAndPayThatTokenAsFee = !_isNativeToken(transferTokenInfo) && !!nonNativeTokenPayFeeSlug && nonNativeTokenPayFeeSlug === token;
1715
- const isTransferNativeTokenAndPayLocalTokenAsFee = _isNativeToken(transferTokenInfo) && !!nonNativeTokenPayFeeSlug;
1734
+ const isTransferLocalTokenAndPayThatTokenAsFee = !_isNativeToken(transferTokenInfo) && !!tokenPayFeeSlug && tokenPayFeeSlug === token;
1735
+ const isTransferNativeTokenAndPayLocalTokenAsFee = _isNativeToken(transferTokenInfo) && !!tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug);
1716
1736
  const srcToken = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(chain);
1717
1737
  const destToken = _destChain !== chain ? this.#koniState.getXcmEqualAssetByChain(_destChain, srcToken.slug) : srcToken;
1718
1738
  const srcChain = this.#koniState.chainService.getChainInfoByKey(chain);
@@ -2905,7 +2925,7 @@ export default class KoniExtension {
2905
2925
  return new Promise(resolve => setTimeout(resolve, 1500));
2906
2926
  }
2907
2927
  try {
2908
- var _this$koniState$chain, _this$koniState$chain2;
2928
+ var _this$koniState$chain3, _this$koniState$chain4;
2909
2929
  await this.#koniState.chainService.enableChain(_DEFAULT_MANTA_ZK_CHAIN);
2910
2930
  this.#koniState.chainService.setMantaZkAssetSettings(true);
2911
2931
  const mnemonic = this.keyringExportMnemonic({
@@ -2924,7 +2944,7 @@ export default class KoniExtension {
2924
2944
  await this.saveCurrentAccountProxy({
2925
2945
  address
2926
2946
  });
2927
- const unsubSyncProgress = await ((_this$koniState$chain = this.#koniState.chainService) === null || _this$koniState$chain === void 0 ? void 0 : (_this$koniState$chain2 = _this$koniState$chain.mantaPay) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.subscribeSyncProgress());
2947
+ 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());
2928
2948
  console.debug('Start initial sync for MantaPay');
2929
2949
  this.#koniState.initialSyncMantaPay(address).then(() => {
2930
2950
  console.debug('Finished initial sync for MantaPay');
@@ -2955,32 +2975,32 @@ export default class KoniExtension {
2955
2975
  }
2956
2976
  }
2957
2977
  async initSyncMantaPay(address) {
2958
- var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
2959
- if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing || !MODULE_SUPPORT.MANTA_ZK) {
2978
+ var _this$koniState$chain5, _this$koniState$chain6, _this$koniState$chain7, _this$koniState$chain8;
2979
+ 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 || !MODULE_SUPPORT.MANTA_ZK) {
2960
2980
  return;
2961
2981
  }
2962
2982
  this.#skipAutoLock = true;
2963
2983
  await this.saveCurrentAccountProxy({
2964
2984
  address
2965
2985
  });
2966
- const unsubSyncProgress = await ((_this$koniState$chain5 = this.#koniState.chainService) === null || _this$koniState$chain5 === void 0 ? void 0 : (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) === null || _this$koniState$chain6 === void 0 ? void 0 : _this$koniState$chain6.subscribeSyncProgress());
2986
+ 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());
2967
2987
  console.debug('Start initial sync for MantaPay');
2968
2988
  this.#koniState.initialSyncMantaPay(address).then(() => {
2969
- var _this$koniState$chain7, _this$koniState$chain8;
2989
+ var _this$koniState$chain9, _this$koniState$chain10;
2970
2990
  console.debug('Finished initial sync for MantaPay');
2971
2991
  this.#skipAutoLock = false;
2972
2992
  unsubSyncProgress && unsubSyncProgress();
2973
2993
  // make sure the sync state is set, just in case it gets unsubscribed
2974
- (_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.setSyncState({
2994
+ (_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({
2975
2995
  progress: 100,
2976
2996
  isSyncing: false
2977
2997
  });
2978
2998
  }).catch(e => {
2979
- var _this$koniState$chain9, _this$koniState$chain10;
2999
+ var _this$koniState$chain11, _this$koniState$chain12;
2980
3000
  console.error('Error syncing MantaPay', e);
2981
3001
  this.#skipAutoLock = false;
2982
3002
  unsubSyncProgress && unsubSyncProgress();
2983
- (_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({
3003
+ (_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({
2984
3004
  progress: 0,
2985
3005
  isSyncing: false
2986
3006
  });
@@ -3018,7 +3038,7 @@ export default class KoniExtension {
3018
3038
  return this.#koniState.getMantaPayConfig('calamari');
3019
3039
  }
3020
3040
  subscribeMantaPaySyncState(id, port) {
3021
- var _this$koniState$subsc, _this$koniState$chain11, _this$koniState$chain12;
3041
+ var _this$koniState$subsc, _this$koniState$chain13, _this$koniState$chain14;
3022
3042
  const cb = createSubscription(id, port);
3023
3043
  const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
3024
3044
  next: rs => {
@@ -3029,7 +3049,7 @@ export default class KoniExtension {
3029
3049
  port.onDisconnect.addListener(() => {
3030
3050
  this.cancelSubscription(id);
3031
3051
  });
3032
- return ((_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.getSyncState()) || {
3052
+ 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()) || {
3033
3053
  isSyncing: false,
3034
3054
  progress: 0,
3035
3055
  needManualSync: false
@@ -83,7 +83,7 @@ export default class KoniState {
83
83
  private waitStarting;
84
84
  constructor(providers?: Providers);
85
85
  get knownMetadata(): MetadataDef[];
86
- injectMetadata(url: string, request: MetadataDef): Promise<boolean>;
86
+ injectMetadata(request: MetadataDef): boolean;
87
87
  getMetaRequest(id: string): MetaRequest;
88
88
  getSignRequest(id: string): SignRequest | undefined;
89
89
  rpcListProviders(): Promise<ResponseRpcListProviders>;
@@ -124,8 +124,8 @@ export default class KoniState {
124
124
  get knownMetadata() {
125
125
  return this.requestService.knownMetadata;
126
126
  }
127
- injectMetadata(url, request) {
128
- return this.requestService.injectMetadata(url, request);
127
+ injectMetadata(request) {
128
+ return this.requestService.injectMetadata(request);
129
129
  }
130
130
  getMetaRequest(id) {
131
131
  return this.requestService.getMetaRequest(id);
@@ -147,7 +147,7 @@ export default class KoniTabs {
147
147
  }
148
148
  }
149
149
  metadataProvide(url, request) {
150
- return this.#koniState.injectMetadata(url, request);
150
+ return this.#koniState.injectMetadata(request);
151
151
  }
152
152
 
153
153
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -505,11 +505,12 @@ export default class KoniTabs {
505
505
  } else {
506
506
  const onlineData = await getEVMChainInfo(chainIdDec);
507
507
  if (onlineData) {
508
+ var _onlineData$explorers;
508
509
  const chainData = {
509
510
  chainId: chainId,
510
511
  rpcUrls: onlineData.rpc.filter(url => url.startsWith('https://')),
511
512
  chainName: onlineData.name,
512
- blockExplorerUrls: onlineData.explorers.map(explorer => explorer.url),
513
+ blockExplorerUrls: (_onlineData$explorers = onlineData.explorers) === null || _onlineData$explorers === void 0 ? void 0 : _onlineData$explorers.map(explorer => explorer.url),
513
514
  nativeCurrency: onlineData.nativeCurrency,
514
515
  requestId: id
515
516
  };
@@ -518,7 +519,7 @@ export default class KoniTabs {
518
519
  params: [chainData]
519
520
  });
520
521
  } else {
521
- throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'This network is currently not supported');
522
+ throw new EvmProviderError(EvmProviderErrorType.NETWORK_NOT_SUPPORTED, 'This network is currently not supported');
522
523
  }
523
524
  }
524
525
  return null;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.23-0",
20
+ "version": "1.3.25-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1076,6 +1076,11 @@
1076
1076
  "require": "./cjs/services/earning-service/handlers/native-staking/base-para.js",
1077
1077
  "default": "./services/earning-service/handlers/native-staking/base-para.js"
1078
1078
  },
1079
+ "./services/earning-service/handlers/native-staking/dtao": {
1080
+ "types": "./services/earning-service/handlers/native-staking/dtao.d.ts",
1081
+ "require": "./cjs/services/earning-service/handlers/native-staking/dtao.js",
1082
+ "default": "./services/earning-service/handlers/native-staking/dtao.js"
1083
+ },
1079
1084
  "./services/earning-service/handlers/native-staking/mythos": {
1080
1085
  "types": "./services/earning-service/handlers/native-staking/mythos.d.ts",
1081
1086
  "require": "./cjs/services/earning-service/handlers/native-staking/mythos.js",
@@ -1146,6 +1151,11 @@
1146
1151
  "require": "./cjs/services/fee-service/utils/index.js",
1147
1152
  "default": "./services/fee-service/utils/index.js"
1148
1153
  },
1154
+ "./services/fee-service/utils/tokenPayFee": {
1155
+ "types": "./services/fee-service/utils/tokenPayFee.d.ts",
1156
+ "require": "./cjs/services/fee-service/utils/tokenPayFee.js",
1157
+ "default": "./services/fee-service/utils/tokenPayFee.js"
1158
+ },
1149
1159
  "./services/history-service": {
1150
1160
  "types": "./services/history-service/index.d.ts",
1151
1161
  "require": "./cjs/services/history-service/index.js",
@@ -2655,12 +2665,12 @@
2655
2665
  "@sora-substrate/type-definitions": "^1.17.7",
2656
2666
  "@substrate/connect": "^0.8.9",
2657
2667
  "@subwallet/chain-list": "0.2.101",
2658
- "@subwallet/extension-base": "^1.3.23-0",
2659
- "@subwallet/extension-chains": "^1.3.23-0",
2660
- "@subwallet/extension-dapp": "^1.3.23-0",
2661
- "@subwallet/extension-inject": "^1.3.23-0",
2668
+ "@subwallet/extension-base": "^1.3.25-0",
2669
+ "@subwallet/extension-chains": "^1.3.25-0",
2670
+ "@subwallet/extension-dapp": "^1.3.25-0",
2671
+ "@subwallet/extension-inject": "^1.3.25-0",
2662
2672
  "@subwallet/keyring": "^0.1.9",
2663
- "@subwallet/subwallet-api-sdk": "^1.3.23-0",
2673
+ "@subwallet/subwallet-api-sdk": "^1.3.25-0",
2664
2674
  "@subwallet/ui-keyring": "^0.1.9",
2665
2675
  "@ton/core": "^0.56.3",
2666
2676
  "@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.23-0'
10
+ version: '1.3.25-0'
11
11
  };
package/page/index.js CHANGED
@@ -61,7 +61,7 @@ export function handleResponse(data) {
61
61
  // eslint-disable-next-line @typescript-eslint/ban-types
62
62
  handler.subscriber(data.subscription);
63
63
  } else if (data.error) {
64
- handler.reject(new ProviderError(ProviderErrorType.INTERNAL_ERROR, data.error, data.errorCode));
64
+ handler.reject(new ProviderError(ProviderErrorType.INTERNAL_ERROR, data.error, data.errorCode, data.errorCode));
65
65
  } else {
66
66
  handler.resolve(data.response);
67
67
  }
@@ -15,7 +15,7 @@ import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/cont
15
15
  import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/contract-handler/wasm/utils';
16
16
  import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
17
17
  import { _checkSmartContractSupportByChain, _getAssetExistentialDeposit, _getChainExistentialDeposit, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
18
- import { getTaoToAlphaMapping } from '@subwallet/extension-base/services/earning-service/handlers/native-staking/tao';
18
+ import { getTaoToAlphaMapping } from '@subwallet/extension-base/services/earning-service/handlers/native-staking/dtao';
19
19
  import { filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
20
20
  import BigN from 'bignumber.js';
21
21
  import { subscribeERC20Interval } from "../evm.js";
@@ -131,7 +131,7 @@ const subscribeWithSystemAccountPallet = async ({
131
131
  });
132
132
  }
133
133
  let bittensorStakingBalances = new Array(addresses.length).fill(new BigN(0));
134
- if (['bittensor'].includes(chainInfo.slug)) {
134
+ if (['bittensor', 'bittensor_testnet'].includes(chainInfo.slug)) {
135
135
  bittensorStakingBalances = await Promise.all(addresses.map(async address => {
136
136
  const stakeInfo = (await substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)).toJSON();
137
137
  const price = await getTaoToAlphaMapping(substrateApi);
@@ -9,9 +9,10 @@ interface TransferEvmProps extends TransactionFee {
9
9
  transferAll: boolean;
10
10
  value: string;
11
11
  evmApi: _EvmApi;
12
+ fallbackFee?: boolean;
12
13
  }
13
- export declare function getEVMTransactionObject({ chain, evmApi, feeCustom: _feeCustom, feeInfo: _feeInfo, feeOption, from, to, transferAll, value }: TransferEvmProps): Promise<[TransactionConfig, string]>;
14
- export declare function getERC20TransactionObject({ assetAddress, evmApi, feeCustom: _feeCustom, feeInfo: _feeInfo, feeOption, from, to, transferAll, value }: TransferERC20Props): Promise<[TransactionConfig, string]>;
14
+ export declare function getEVMTransactionObject({ chain, evmApi, fallbackFee, feeCustom: _feeCustom, feeInfo: _feeInfo, feeOption, from, to, transferAll, value }: TransferEvmProps): Promise<[TransactionConfig, string, string]>;
15
+ export declare function getERC20TransactionObject({ assetAddress, chain, evmApi, fallbackFee, feeCustom: _feeCustom, feeInfo: _feeInfo, feeOption, from, to, transferAll, value }: TransferERC20Props): Promise<[TransactionConfig, string, string]>;
15
16
  interface TransferERC20Props extends TransactionFee {
16
17
  assetAddress: string;
17
18
  chain: string;
@@ -21,6 +22,7 @@ interface TransferERC20Props extends TransactionFee {
21
22
  to: string;
22
23
  transferAll: boolean;
23
24
  value: string;
25
+ fallbackFee?: boolean;
24
26
  }
25
27
  export declare function getERC721Transaction(web3Api: _EvmApi, chain: string, contractAddress: string, senderAddress: string, recipientAddress: string, tokenId: string, _feeInfo: FeeInfo): Promise<TransactionConfig>;
26
28
  export declare function getPSP34TransferExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null>;
@@ -12,6 +12,7 @@ import { t } from 'i18next';
12
12
  export async function getEVMTransactionObject({
13
13
  chain,
14
14
  evmApi,
15
+ fallbackFee,
15
16
  feeCustom: _feeCustom,
16
17
  feeInfo: _feeInfo,
17
18
  feeOption,
@@ -23,13 +24,22 @@ export async function getEVMTransactionObject({
23
24
  const feeCustom = _feeCustom;
24
25
  const feeInfo = _feeInfo;
25
26
  const feeCombine = combineEthFee(feeInfo, feeOption, feeCustom);
27
+ let errorOnEstimateFee = '';
26
28
  const transactionObject = {
27
29
  to: to,
28
30
  value: value,
29
31
  from: from,
30
32
  ...feeCombine
31
33
  };
32
- const gasLimit = await evmApi.api.eth.estimateGas(transactionObject);
34
+ const gasLimit = await evmApi.api.eth.estimateGas(transactionObject).catch(e => {
35
+ console.log('Cannot estimate fee with native transfer on', chain, e);
36
+ if (fallbackFee) {
37
+ errorOnEstimateFee = e.message;
38
+ return 21000;
39
+ } else {
40
+ throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
41
+ }
42
+ });
33
43
  transactionObject.gas = gasLimit;
34
44
  let estimateFee;
35
45
  if (feeCombine.maxFeePerGas) {
@@ -43,11 +53,13 @@ export async function getEVMTransactionObject({
43
53
  const numberReplace = 18 - 12;
44
54
  transactionObject.value = transactionObject.value.substring(0, transactionObject.value.length - 6) + new Array(numberReplace).fill('0').join('');
45
55
  }
46
- return [transactionObject, transactionObject.value.toString()];
56
+ return [transactionObject, transactionObject.value.toString(), errorOnEstimateFee];
47
57
  }
48
58
  export async function getERC20TransactionObject({
49
59
  assetAddress,
60
+ chain,
50
61
  evmApi,
62
+ fallbackFee,
51
63
  feeCustom: _feeCustom,
52
64
  feeInfo: _feeInfo,
53
65
  feeOption,
@@ -60,6 +72,7 @@ export async function getERC20TransactionObject({
60
72
  const feeCustom = _feeCustom;
61
73
  let freeAmount = new BigN(0);
62
74
  let transferValue = value;
75
+ let errorOnEstimateFee = '';
63
76
  if (transferAll) {
64
77
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
65
78
  const bal = await erc20Contract.methods.balanceOf(from).call();
@@ -74,6 +87,14 @@ export async function getERC20TransactionObject({
74
87
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
75
88
  const gasLimit = await erc20Contract.methods.transfer(to, transferValue).estimateGas({
76
89
  from
90
+ }).catch(e => {
91
+ console.log('Cannot estimate fee with token contract', assetAddress, chain, e);
92
+ if (fallbackFee) {
93
+ errorOnEstimateFee = e.message;
94
+ return 70000;
95
+ } else {
96
+ throw Error('Unable to estimate fee for this transaction. Edit fee and try again.');
97
+ }
77
98
  });
78
99
  const feeInfo = _feeInfo;
79
100
  const feeCombine = combineEthFee(feeInfo, feeOption, feeCustom);
@@ -89,7 +110,7 @@ export async function getERC20TransactionObject({
89
110
  transferValue = freeAmount.toFixed(0);
90
111
  transactionObject.data = generateTransferData(to, transferValue);
91
112
  }
92
- return [transactionObject, transferValue];
113
+ return [transactionObject, transferValue, errorOnEstimateFee];
93
114
  }
94
115
  export async function getERC721Transaction(web3Api, chain, contractAddress, senderAddress, recipientAddress, tokenId, _feeInfo) {
95
116
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -20,5 +20,8 @@ export const DEFAULT_SERVICE_INFO = {
20
20
  },
21
21
  moonpay: {
22
22
  ...DEFAULT_BUY_SERVICE
23
+ },
24
+ meld: {
25
+ ...DEFAULT_BUY_SERVICE
23
26
  }
24
27
  };
@@ -72,6 +72,7 @@ export declare class ChainService {
72
72
  getMultiChainAssetMap(): Record<string, _MultiChainAsset>;
73
73
  getSmartContractTokens(): Record<string, _ChainAsset>;
74
74
  getAssetHubToken(): Record<string, _ChainAsset>;
75
+ getHydrationAssetIdMap(chain: string): Record<string, string>;
75
76
  getChainInfoMap(): Record<string, _ChainInfo>;
76
77
  setChainInfoMap(chainInfoMap: Record<string, _ChainInfo>): void;
77
78
  getEvmChainInfoMap(): Record<string, _ChainInfo>;
@@ -11,7 +11,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
11
11
  import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
12
12
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
13
13
  import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
14
- import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
14
+ import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
15
15
  import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
16
16
  import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
17
17
  import { addLazy, calculateMetadataHash, fetchStaticData, filterAssetsByChainAndType, getShortMetadata, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
@@ -203,6 +203,17 @@ export class ChainService {
203
203
  });
204
204
  return assetHubToken;
205
205
  }
206
+ getHydrationAssetIdMap(chain) {
207
+ const hydrationAssetIdMap = {};
208
+ Object.values(this.getAssetRegistry()).forEach(asset => {
209
+ const originChain = _getAssetOriginChain(asset);
210
+ const assetId = _getTokenOnChainAssetId(asset);
211
+ if (originChain === chain && assetId !== '-1') {
212
+ hydrationAssetIdMap[asset.slug] = assetId;
213
+ }
214
+ });
215
+ return hydrationAssetIdMap;
216
+ }
206
217
  getChainInfoMap() {
207
218
  return this.dataMap.chainInfoMap;
208
219
  }
@@ -17,7 +17,7 @@ export const _STAKING_CHAIN_GROUP = {
17
17
  lending: ['interlay'],
18
18
  krest_network: ['krest_network'],
19
19
  manta: ['manta_network'],
20
- bittensor: ['bittensor', 'bittensor_devnet'],
20
+ bittensor: ['bittensor', 'bittensor_testnet'],
21
21
  mythos: ['mythos', 'muse_testnet']
22
22
  };
23
23
  export const TON_CHAINS = ['ton', 'ton_testnet'];