@subwallet/extension-base 1.3.70-2 → 1.3.71-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 (182) hide show
  1. package/background/KoniTypes.js +65 -8
  2. package/cjs/background/KoniTypes.js +65 -8
  3. package/cjs/constants/blocked-actions.js +3 -0
  4. package/cjs/core/logic-validation/swap.js +0 -3
  5. package/cjs/core/substrate/system-pallet.js +0 -2
  6. package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
  7. package/cjs/koni/api/staking/bonding/astar.js +0 -2
  8. package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
  9. package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
  10. package/cjs/koni/api/staking/bonding/utils.js +0 -4
  11. package/cjs/koni/background/cron.js +0 -1
  12. package/cjs/koni/background/handlers/Extension.js +154 -158
  13. package/cjs/koni/background/handlers/State.js +54 -52
  14. package/cjs/koni/background/handlers/Tabs.js +39 -34
  15. package/cjs/packageInfo.js +1 -1
  16. package/cjs/page/index.js +7 -0
  17. package/cjs/page/substrate/PostMessageProvider.js +3 -0
  18. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  19. package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  20. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -3
  21. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  22. package/cjs/services/balance-service/index.js +103 -7
  23. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  24. package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
  25. package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
  26. package/cjs/services/balance-service/transfer/token.js +0 -2
  27. package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
  28. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  29. package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
  30. package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
  31. package/cjs/services/chain-service/handler/light-client/index.js +1 -2
  32. package/cjs/services/chain-service/health-check/index.js +0 -1
  33. package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  34. package/cjs/services/chain-service/index.js +18 -26
  35. package/cjs/services/chain-service/utils/index.js +21 -25
  36. package/cjs/services/earning-service/handlers/base.js +32 -0
  37. package/cjs/services/earning-service/handlers/lending/base.js +0 -2
  38. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  39. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
  40. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  41. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  42. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
  43. package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
  44. package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
  45. package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
  46. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  47. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  48. package/cjs/services/earning-service/handlers/special.js +7 -0
  49. package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
  50. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  51. package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
  52. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
  53. package/cjs/services/keyring-service/context/state.js +21 -3
  54. package/cjs/services/keyring-service/utils.js +12 -2
  55. package/cjs/services/migration-service/index.js +1 -2
  56. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  57. package/cjs/services/nft-service/index.js +5 -0
  58. package/cjs/services/open-gov/handler.js +0 -2
  59. package/cjs/services/open-gov/interface.js +4 -1
  60. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
  61. package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
  62. package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
  63. package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
  64. package/cjs/services/request-service/helper/index.js +1 -2
  65. package/cjs/services/storage-service/DatabaseService.js +0 -2
  66. package/cjs/services/storage-service/databases/index.js +2 -0
  67. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
  68. package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
  69. package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
  70. package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
  71. package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
  72. package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
  73. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
  74. package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
  75. package/cjs/services/transaction-service/event-parser/index.js +6 -6
  76. package/cjs/services/transaction-service/index.js +28 -28
  77. package/cjs/services/wallet-connect-service/index.js +21 -18
  78. package/cjs/services/wallet-connect-service/types.js +1 -1
  79. package/cjs/types/account/info/keyring.js +9 -1
  80. package/cjs/types/balance/index.js +5 -1
  81. package/cjs/types/swap/index.js +2 -1
  82. package/cjs/types/transaction/process.js +2 -0
  83. package/cjs/types/yield/actions/join/step.js +17 -1
  84. package/cjs/utils/account/common.js +0 -26
  85. package/cjs/utils/account/derive/info/solo.js +7 -4
  86. package/cjs/utils/account/derive/validate.js +1 -1
  87. package/cjs/utils/account/transform.js +5 -1
  88. package/cjs/utils/auth.js +1 -1
  89. package/cjs/utils/bitcoin/utxo-management.js +0 -1
  90. package/cjs/utils/environment.js +2 -1
  91. package/cjs/utils/fee/transfer.js +1 -2
  92. package/cjs/utils/index.js +1 -2
  93. package/constants/blocked-actions.js +3 -0
  94. package/core/logic-validation/swap.js +0 -3
  95. package/core/substrate/system-pallet.js +0 -2
  96. package/koni/api/nft/wasm_nft/index.js +0 -1
  97. package/koni/api/staking/bonding/astar.js +0 -2
  98. package/koni/api/staking/bonding/paraChain.js +0 -3
  99. package/koni/api/staking/bonding/relayChain.js +2 -4
  100. package/koni/api/staking/bonding/utils.js +0 -4
  101. package/koni/background/cron.js +0 -1
  102. package/koni/background/handlers/Extension.js +8 -11
  103. package/koni/background/handlers/State.js +41 -38
  104. package/koni/background/handlers/Tabs.js +9 -3
  105. package/package.json +19 -20
  106. package/packageInfo.js +1 -1
  107. package/page/substrate/PostMessageProvider.js +3 -0
  108. package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  109. package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  110. package/services/balance-service/helpers/subscribe/substrate/index.js +0 -1
  111. package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  112. package/services/balance-service/index.d.ts +8 -0
  113. package/services/balance-service/index.js +105 -9
  114. package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  115. package/services/balance-service/transfer/smart-contract.js +0 -1
  116. package/services/balance-service/transfer/token.js +0 -2
  117. package/services/balance-service/transfer/ton-transfer.js +0 -1
  118. package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  119. package/services/chain-service/handler/CardanoApi.js +3 -1
  120. package/services/chain-service/handler/SubstrateApi.js +0 -2
  121. package/services/chain-service/health-check/index.js +0 -1
  122. package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  123. package/services/chain-service/index.d.ts +0 -1
  124. package/services/chain-service/index.js +15 -23
  125. package/services/chain-service/utils/index.js +22 -26
  126. package/services/earning-service/handlers/base.js +32 -0
  127. package/services/earning-service/handlers/lending/base.js +0 -2
  128. package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  129. package/services/earning-service/handlers/liquid-staking/base.js +0 -2
  130. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  131. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  132. package/services/earning-service/handlers/native-staking/astar.js +0 -2
  133. package/services/earning-service/handlers/native-staking/dtao.js +43 -0
  134. package/services/earning-service/handlers/native-staking/energy.js +0 -1
  135. package/services/earning-service/handlers/native-staking/mythos.js +0 -2
  136. package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  137. package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  138. package/services/earning-service/handlers/special.js +7 -0
  139. package/services/history-service/subsquid-multi-chain-history.js +0 -1
  140. package/services/keyring-service/context/handlers/Derive.js +2 -2
  141. package/services/keyring-service/context/handlers/Migration.js +3 -1
  142. package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
  143. package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
  144. package/services/keyring-service/context/state.d.ts +3 -0
  145. package/services/keyring-service/context/state.js +21 -3
  146. package/services/keyring-service/utils.d.ts +1 -0
  147. package/services/keyring-service/utils.js +9 -0
  148. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  149. package/services/nft-service/index.js +6 -0
  150. package/services/open-gov/handler.js +0 -2
  151. package/services/open-gov/interface.js +4 -1
  152. package/services/request-service/handler/CardanoRequestHandler.js +0 -1
  153. package/services/request-service/handler/EvmRequestHandler.js +0 -1
  154. package/services/request-service/handler/TonRequestHandler.js +0 -1
  155. package/services/setting-service/constants.js +0 -1
  156. package/services/storage-service/DatabaseService.js +0 -2
  157. package/services/storage-service/databases/index.js +3 -0
  158. package/services/swap-service/handler/asset-hub/handler.js +0 -1
  159. package/services/swap-service/handler/asset-hub/router.js +0 -1
  160. package/services/swap-service/handler/chainflip-handler.js +0 -2
  161. package/services/swap-service/handler/hydradx-handler.js +0 -1
  162. package/services/swap-service/handler/kyber-handler.js +0 -1
  163. package/services/swap-service/handler/simpleswap-handler.js +0 -1
  164. package/services/swap-service/handler/uniswap-handler.js +0 -3
  165. package/services/transaction-service/event-parser/index.js +6 -6
  166. package/services/wallet-connect-service/index.js +21 -18
  167. package/services/wallet-connect-service/types.js +1 -1
  168. package/types/account/action/add/mnemonic.d.ts +3 -2
  169. package/types/account/info/keyring.js +9 -1
  170. package/types/balance/index.js +5 -1
  171. package/types/swap/index.js +2 -1
  172. package/types/transaction/process.js +3 -1
  173. package/types/yield/actions/join/step.js +17 -1
  174. package/utils/account/common.d.ts +0 -3
  175. package/utils/account/common.js +0 -24
  176. package/utils/account/derive/info/solo.js +8 -5
  177. package/utils/account/derive/validate.d.ts +2 -2
  178. package/utils/account/derive/validate.js +1 -1
  179. package/utils/account/transform.js +5 -1
  180. package/utils/auth.js +2 -2
  181. package/utils/bitcoin/utxo-management.js +0 -1
  182. package/utils/index.js +2 -5
@@ -4,6 +4,9 @@
4
4
  import EventEmitter from 'eventemitter3';
5
5
  import { isUndefined, logger } from '@polkadot/util';
6
6
  const l = logger('PostMessageProvider');
7
+
8
+ // Same as https://github.com/polkadot-js/api/blob/57ca9a9c3204339e1e1f693fcacc33039868dc27/packages/rpc-provider/src/ws/Provider.ts#L17
9
+
7
10
  // External to class, this.# is not private enough (yet)
8
11
  let sendRequest;
9
12
 
@@ -37,7 +37,6 @@ export async function retryCardanoTxStatus(fn, options) {
37
37
  await new Promise(resolve => setTimeout(resolve, options.delay)); // wait for delay period, then recall the fn()
38
38
  }
39
39
  }
40
-
41
40
  console.error('Cardano transaction timeout', lastError); // throw only last error, in case no successful result from fn()
42
41
 
43
42
  return false;
@@ -59,7 +59,6 @@ export const subscribeGRC20Balance = ({
59
59
  }
60
60
  });
61
61
  };
62
-
63
62
  getTokenBalances();
64
63
  const interval = setInterval(getTokenBalances, SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
65
64
  return () => {
@@ -116,7 +115,6 @@ export const subscribeVftBalance = ({
116
115
  }
117
116
  });
118
117
  };
119
-
120
118
  getTokenBalances();
121
119
  const interval = setInterval(getTokenBalances, SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
122
120
  return () => {
@@ -343,7 +343,6 @@ const subscribePSP22Balance = ({
343
343
  }
344
344
  });
345
345
  };
346
-
347
346
  getTokenBalances();
348
347
  const interval = setInterval(getTokenBalances, SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
349
348
  return () => {
@@ -35,10 +35,8 @@ export async function retryTonTxStatus(fn, options) {
35
35
  await new Promise(resolve => setTimeout(resolve, options.delay)); // wait for delay period, then recall the fn()
36
36
  }
37
37
  }
38
-
39
38
  throw lastError; // throw only last error, in case no successful result from fn()
40
39
  }
41
-
42
40
  export function getMessageTxStatus(txByMsgInfo) {
43
41
  var _txDetailInfo$descrip, _txDetailInfo$descrip2, _txDetailInfo$descrip3, _txDetailInfo$descrip4, _txDetailInfo$descrip5, _txDetailInfo$descrip6, _txDetailInfo$out_msg, _txDetailInfo$out_msg2;
44
42
  const txDetailInfo = txByMsgInfo.transactions[0];
@@ -64,7 +62,6 @@ export async function getJettonTxStatus(tonApi, jettonTransferMsgHash) {
64
62
  const jettonInternalTransferTxInfoRaw = await tonApi.getTxByInMsg(jettonInternalTransferHash);
65
63
  return getMessageTxStatus(jettonInternalTransferTxInfoRaw); // Jetton Internal Transfer success -> Receiver successfully receiver fund!
66
64
  }
67
-
68
65
  return false;
69
66
  }
70
67
  export async function estimateTonTxFee(tonApi, messages, walletContract, _seqno) {
@@ -1,3 +1,4 @@
1
+ import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
1
2
  import { AmountData, DetectBalanceCache, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
3
  import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
4
  import { RequestOptimalTransferProcess } from '@subwallet/extension-base/services/balance-service/helpers/process';
@@ -111,4 +112,11 @@ export declare class BalanceService implements StoppableServiceInterface {
111
112
  /** optimize token area **/
112
113
  enableOptimizeTokenPromise(): void;
113
114
  optimizeEnableTokens(): Promise<void>;
115
+ /** Return token slugs with balance in evm chain - only work with evm addresses & pure evm chains **/
116
+ getEvmTokensBalanceByChain(address: string, chainSlug: string): Promise<string[]>;
117
+ /** Return token slugs with balance in substrate chain - only work with substrate chains that have subscanSlug **/
118
+ getSubstrateTokensBalanceByChain(address: string, chainSlug: string, assetsByChain: Record<string, _ChainAsset>): Promise<string[]>;
119
+ getCurrentAccountAddressByChain(chainInfo: _ChainInfo): string | undefined;
120
+ /** re-detect balance & enable custom, priority tokens when enabling chain again **/
121
+ updatePriorityAssetsByChain(chainSlug: string, visible: boolean): Promise<void>;
114
122
  }
@@ -7,12 +7,12 @@ import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
7
7
  import { _isXcmWithinSameConsensus } from '@subwallet/extension-base/core/substrate/xcm-parser';
8
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, _isCustomAsset, _isNativeToken, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
10
+ import { _getChainNativeTokenSlug, _isChainSubstrateCompatible, _isCustomAsset, _isCustomChain, _isNativeToken, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
11
11
  import DetectAccountBalanceStore from '@subwallet/extension-base/stores/DetectAccountBalance';
12
12
  import { BalanceType } from '@subwallet/extension-base/types';
13
13
  import { addLazy, createPromiseHandler, isAccountAll, waitTimeout } from '@subwallet/extension-base/utils';
14
14
  import { getKeypairTypeByAddress } from '@subwallet/keyring';
15
- import { EthereumKeypairTypes, SubstrateKeypairTypes } from '@subwallet/keyring/types';
15
+ import { AllSubstrateKeypairTypes, EthereumKeypairTypes } from '@subwallet/keyring/types';
16
16
  import keyring from '@subwallet/ui-keyring';
17
17
  import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
18
18
  import BigN from 'bignumber.js';
@@ -458,7 +458,7 @@ export class BalanceService {
458
458
  const assetMap = this.state.chainService.getAssetRegistry();
459
459
  const promiseList = addresses.map(address => {
460
460
  const type = getKeypairTypeByAddress(address);
461
- const typeValid = [...SubstrateKeypairTypes, ...EthereumKeypairTypes].includes(type);
461
+ const typeValid = [...AllSubstrateKeypairTypes, ...EthereumKeypairTypes].includes(type);
462
462
  if (typeValid) {
463
463
  return this.state.subscanService.getMultiChainBalance(address).catch(e => {
464
464
  console.error(e);
@@ -539,12 +539,10 @@ export class BalanceService {
539
539
  var _currentAssetSettings2;
540
540
  const chainSlug = tokenSlug.split('-')[0];
541
541
  const chainState = this.state.chainService.getChainStateByKey(chainSlug);
542
- const existedKey = Object.keys(assetMap).find(v => v.toLowerCase() === tokenSlug.toLowerCase());
543
-
544
- // Cancel if chain is turned off by user
545
- if (chainState && chainState.manualTurnOff) {
542
+ if (chainState !== null && chainState !== void 0 && chainState.manualTurnOff) {
546
543
  continue;
547
544
  }
545
+ const existedKey = Object.keys(assetMap).find(v => v.toLowerCase() === tokenSlug.toLowerCase());
548
546
  if (existedKey && !((_currentAssetSettings2 = currentAssetSettings[existedKey]) !== null && _currentAssetSettings2 !== void 0 && _currentAssetSettings2.visible)) {
549
547
  needEnableChains.push(chainSlug);
550
548
  needActiveTokens.push(existedKey);
@@ -760,7 +758,7 @@ export class BalanceService {
760
758
  const assetMap = this.state.chainService.getAssetRegistry();
761
759
  const addresses = keyring.getPairs().map(account => account.address);
762
760
  const evmAddresses = addresses.filter(address => [...EthereumKeypairTypes].includes(getKeypairTypeByAddress(address)));
763
- const substrateAddresses = addresses.filter(address => [...SubstrateKeypairTypes].includes(getKeypairTypeByAddress(address)));
761
+ const substrateAddresses = addresses.filter(address => [...AllSubstrateKeypairTypes].includes(getKeypairTypeByAddress(address)));
764
762
  const [nonZeroBalanceEvmToken, nonZeroBalanceSubstrateToken] = await Promise.all([this.evmDetectBalanceToken(evmAddresses), this.substrateDetectBalanceToken(substrateAddresses)]);
765
763
  const substrateDetectChain = this.substrateDetectBalanceChain();
766
764
  const evmDetectChain = await this.evmDetectBalanceChain();
@@ -788,5 +786,103 @@ export class BalanceService {
788
786
  }
789
787
  }
790
788
 
791
- /** optimize token area **/
789
+ /** Return token slugs with balance in evm chain - only work with evm addresses & pure evm chains **/
790
+ async getEvmTokensBalanceByChain(address, chainSlug) {
791
+ const tokenBalanceSlugs = await subwalletApiSdk.balanceDetectionApi.getSwEvmTokenBalanceByChain(address, chainSlug);
792
+ return tokenBalanceSlugs;
793
+ }
794
+
795
+ /** Return token slugs with balance in substrate chain - only work with substrate chains that have subscanSlug **/
796
+ async getSubstrateTokensBalanceByChain(address, chainSlug, assetsByChain) {
797
+ const tokenBalanceSlugs = [];
798
+ const balanceData = await this.state.subscanService.getMultiChainBalance(address);
799
+ if (!balanceData) {
800
+ return [];
801
+ }
802
+ for (const datum of balanceData) {
803
+ const {
804
+ balance,
805
+ bonded,
806
+ category,
807
+ locked,
808
+ network,
809
+ symbol
810
+ } = datum;
811
+ const chain = this.state.chainService.detectBalanceChainSlugMap[network];
812
+ if (chain !== chainSlug) {
813
+ continue;
814
+ }
815
+ const isBalanceEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
816
+ if (isBalanceEmpty) {
817
+ continue;
818
+ }
819
+ const tokenKey = `${chain}-${category === 'native' ? 'NATIVE' : 'LOCAL'}-${symbol.toUpperCase()}`;
820
+ const existedKey = Object.keys(assetsByChain).find(v => v.toLowerCase() === tokenKey.toLowerCase());
821
+ if (existedKey) {
822
+ tokenBalanceSlugs.push(existedKey);
823
+ }
824
+ }
825
+ return tokenBalanceSlugs;
826
+ }
827
+ getCurrentAccountAddressByChain(chainInfo) {
828
+ const proxyId = this.state.keyringService.context.currentAccount.proxyId;
829
+ const addresses = this.state.keyringService.context.addressesByProxyId(proxyId);
830
+ if (_isPureEvmChain(chainInfo)) {
831
+ const evmAddress = addresses.find(address => {
832
+ const type = getKeypairTypeByAddress(address);
833
+ return [...EthereumKeypairTypes].includes(type);
834
+ });
835
+ if (evmAddress) {
836
+ return evmAddress;
837
+ }
838
+ }
839
+ if (_isChainSubstrateCompatible(chainInfo)) {
840
+ const substrateAddress = addresses.find(address => {
841
+ const type = getKeypairTypeByAddress(address);
842
+ return [...AllSubstrateKeypairTypes, ...EthereumKeypairTypes].includes(type);
843
+ });
844
+ if (substrateAddress) {
845
+ return substrateAddress;
846
+ }
847
+ }
848
+ return undefined;
849
+ }
850
+
851
+ /** re-detect balance & enable custom, priority tokens when enabling chain again **/
852
+ async updatePriorityAssetsByChain(chainSlug, visible) {
853
+ const currentAssetSettings = await this.state.chainService.getAssetSettings();
854
+ const assetsByChain = this.state.chainService.getFungibleTokensByChain(chainSlug);
855
+ const priorityTokensMap = this.state.chainService.value.priorityTokens || {};
856
+ const chainInfo = this.state.chainService.getChainInfoByKey(chainSlug);
857
+ const address = this.getCurrentAccountAddressByChain(chainInfo);
858
+ const tokenSlugsWithBalance = [];
859
+ if (address && !_isCustomChain(chainInfo.slug)) {
860
+ if (_isPureEvmChain(chainInfo)) {
861
+ tokenSlugsWithBalance.push(...(await this.getEvmTokensBalanceByChain(address, chainSlug)));
862
+ } else if (_isChainSubstrateCompatible(chainInfo)) {
863
+ tokenSlugsWithBalance.push(...(await this.getSubstrateTokensBalanceByChain(address, chainSlug, assetsByChain)));
864
+ }
865
+ }
866
+ tokenSlugsWithBalance.forEach(tokenSlug => {
867
+ currentAssetSettings[tokenSlug] = {
868
+ visible: true
869
+ };
870
+ });
871
+ const priorityTokensList = priorityTokensMap.token && typeof priorityTokensMap.token === 'object' ? Object.keys(priorityTokensMap.token) : [];
872
+ for (const asset of Object.values(assetsByChain)) {
873
+ if (visible) {
874
+ const isPriorityToken = priorityTokensList.includes(asset.slug) || _isCustomAsset(asset.slug);
875
+ if (isPriorityToken || _isNativeToken(asset)) {
876
+ currentAssetSettings[asset.slug] = {
877
+ visible: true
878
+ };
879
+ }
880
+ } else {
881
+ currentAssetSettings[asset.slug] = {
882
+ visible: false
883
+ };
884
+ }
885
+ }
886
+ this.state.chainService.setAssetSettings(currentAssetSettings);
887
+ }
792
888
  }
@@ -76,7 +76,6 @@ export async function createBitcoinTransaction(params) {
76
76
  script: pair.bitcoin.output,
77
77
  value: input.value // UTXO value in satoshis
78
78
  },
79
-
80
79
  tapInternalKey: pair.bitcoin.internalPubkey // X-only public key (32 bytes)
81
80
  });
82
81
  } else {
@@ -62,7 +62,6 @@ export async function getEVMTransactionObject(props) {
62
62
  });
63
63
  gasLimit = Math.floor(gasEstimate * 1.1); // 10% buffer for fluctuations
64
64
  }
65
-
66
65
  transactionObject.gas = gasLimit;
67
66
  let estimateFee;
68
67
  if (feeCombine.maxFeePerGas) {
@@ -158,7 +158,6 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
158
158
  // estimate value
159
159
  bounce: false // anyMode
160
160
  });
161
-
162
161
  estimatedFee = new BigN((await estimateTonTxFee(tonApi, [mockMessage], mockWalletContract)).toString());
163
162
  } else {
164
163
  var _paymentInfo$partialF;
@@ -176,7 +175,6 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
176
175
  const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
177
176
  estimatedFee = new BigN((paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0'); // todo: should handle error case instead of setting fee to 0
178
177
  }
179
-
180
178
  return estimatedFee;
181
179
  } catch (e) {
182
180
  console.error('error mocking tx fee', e);
@@ -56,7 +56,6 @@ async function createTonNativeTransaction({
56
56
  value: fromNano(value),
57
57
  bounce: false // todo: check and update the send bounced logic
58
58
  });
59
-
60
59
  const messagePayload = cellToBase64Str(messageRelaxedToCell(messages));
61
60
  const estimateExternalFee = await estimateTonTxFee(tonApi, [messages], walletContract);
62
61
  const transactionObject = {
@@ -57,7 +57,6 @@ export async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, desti
57
57
  } catch (e) {
58
58
  gasLimit = 200000; // todo: handle this better
59
59
  }
60
-
61
60
  transactionConfig.gas = gasLimit;
62
61
  return transactionConfig;
63
62
  }
@@ -21,6 +21,9 @@ export class CardanoApi {
21
21
  connectionStatusSubject = new BehaviorSubject(_ChainConnectionStatus.DISCONNECTED);
22
22
  isApiReady = false;
23
23
  isApiReadyOnce = false;
24
+
25
+ // todo: add api with interface BlockFrostAPI to remove isTestnet check
26
+
24
27
  constructor(chainSlug, apiUrl, {
25
28
  isTestnet,
26
29
  providerName
@@ -62,7 +65,6 @@ export class CardanoApi {
62
65
  this.apiUrl = apiUrl;
63
66
  // this.api = this.createProvider();
64
67
  }
65
-
66
68
  async recoverConnect() {
67
69
  await this.disconnect();
68
70
  this.connect();
@@ -281,7 +281,6 @@ export class SubstrateApi {
281
281
  // this.apiDefaultTx = api.tx[defaultSection][defaultMethod];
282
282
  // this.apiDefaultTxSudo = (api.tx.system && api.tx.system.setCode) || this.apiDefaultTx;
283
283
  }
284
-
285
284
  async makeRpcQuery({
286
285
  args,
287
286
  method,
@@ -322,7 +321,6 @@ export class SubstrateApi {
322
321
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
323
322
  return (await this.api[section][module][method]()).toPrimitive(); // todo: improve this
324
323
  }
325
-
326
324
  if (isStateQuery) {
327
325
  if (!this.api[section][module]) {
328
326
  return undefined;
@@ -21,7 +21,6 @@ export async function checkSubstrateEndpoint(endpoint, timeout) {
21
21
  await wsProvider.disconnect(); // disconnect from the endpoint after the health check is complete
22
22
  }
23
23
  }
24
-
25
24
  export async function checkEvmEndpoint(endpoint, timeout) {
26
25
  try {
27
26
  const web3 = new Web3(endpoint);
@@ -11,7 +11,6 @@ export function validateTokenHasValueByChain(chainAsset) {
11
11
  }
12
12
  return isTestnet !== chainAsset.hasValue; // todo: also check multichainAsset hasValue if has.
13
13
  }
14
-
15
14
  export function validateNativeInfoByChain(chainAsset) {
16
15
  var _chainInfo$evmInfo, _chainInfo$substrateI, _chainInfo$bitcoinInf, _chainInfo$evmInfo2, _chainInfo$substrateI2, _chainInfo$bitcoinInf2, _chainInfo$evmInfo3, _chainInfo$substrateI3, _chainInfo$bitcoinInf3;
17
16
  const chainInfo = ChainInfoMap[chainAsset.originChain];
@@ -170,7 +170,6 @@ export declare class ChainService {
170
170
  getAssetSettings(): Promise<Record<string, AssetSetting>>;
171
171
  updateAssetSetting(assetSlug: string, assetSetting: AssetSetting, autoEnableNativeToken?: boolean): Promise<boolean | undefined>;
172
172
  updateAssetSettingByChain(chainSlug: string, visible: boolean): Promise<void>;
173
- updatePriorityAssetsByChain(chainSlug: string, visible: boolean): Promise<void>;
174
173
  subscribeAssetSettings(): BehaviorSubject<Record<string, AssetSetting>>;
175
174
  getAssetLogoMap(): Record<string, string>;
176
175
  subscribeAssetLogoMap(): BehaviorSubject<Record<string, string>>;
@@ -12,7 +12,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
12
12
  import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
13
13
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
14
14
  import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
15
- import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
15
+ import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
16
16
  import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
17
17
  import { convertUtxoRawToUtxo } from '@subwallet/extension-base/services/request-service/helper';
18
18
  import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
@@ -43,6 +43,9 @@ export class ChainService {
43
43
  assetRegistry: {},
44
44
  assetRefMap: {}
45
45
  };
46
+
47
+ // to save chain, token settings from user
48
+
46
49
  lockChainInfoMap = false; // prevent unwanted changes (edit, enable, disable) to chainInfoMap
47
50
 
48
51
  get mantaPay() {
@@ -708,7 +711,6 @@ export class ChainService {
708
711
  .catch(e => console.error('Error enabling popular tokens:', e)); // Log error if enabling fails
709
712
  }
710
713
  }
711
-
712
714
  handleLatestSufficientChains(latestSufficientChains) {
713
715
  this.sufficientChainsSubject.next(latestSufficientChains);
714
716
  this.logger.log('Finished updating latest supported sufficient chains');
@@ -1352,7 +1354,18 @@ export class ChainService {
1352
1354
 
1353
1355
  // Enable chain if not before
1354
1356
  if (!targetChainState.active) {
1357
+ var _currentAssetSettings;
1355
1358
  targetChainState.active = true;
1359
+
1360
+ // enable native token
1361
+ const nativeAsset = this.getNativeTokenInfo(chainSlug);
1362
+ const currentAssetSettings = await this.getAssetSettings();
1363
+ if (!((_currentAssetSettings = currentAssetSettings[nativeAsset.slug]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
1364
+ currentAssetSettings[nativeAsset.slug] = {
1365
+ visible: true
1366
+ };
1367
+ this.setAssetSettings(currentAssetSettings);
1368
+ }
1356
1369
  }
1357
1370
 
1358
1371
  // It auto detects the change of api url to create new instance or reuse existed one
@@ -1855,27 +1868,6 @@ export class ChainService {
1855
1868
  });
1856
1869
  this.setAssetSettings(assetSettings);
1857
1870
  }
1858
- async updatePriorityAssetsByChain(chainSlug, visible) {
1859
- const currentAssetSettings = await this.getAssetSettings();
1860
- const assetsByChain = this.getFungibleTokensByChain(chainSlug);
1861
- const priorityTokensMap = this.priorityTokensSubject.value || {};
1862
- const priorityTokensList = priorityTokensMap.token && typeof priorityTokensMap.token === 'object' ? Object.keys(priorityTokensMap.token) : [];
1863
- for (const asset of Object.values(assetsByChain)) {
1864
- if (visible) {
1865
- const isPriorityToken = priorityTokensList.includes(asset.slug);
1866
- if (isPriorityToken || _isNativeToken(asset)) {
1867
- currentAssetSettings[asset.slug] = {
1868
- visible: true
1869
- };
1870
- }
1871
- } else {
1872
- currentAssetSettings[asset.slug] = {
1873
- visible: false
1874
- };
1875
- }
1876
- }
1877
- this.setAssetSettings(currentAssetSettings);
1878
- }
1879
1871
  subscribeAssetSettings() {
1880
1872
  return this.assetSettingSubject;
1881
1873
  }
@@ -6,7 +6,7 @@ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
7
7
  import { _CUSTOM_PREFIX, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
8
8
  import { AccountChainType, AccountSignMode } from '@subwallet/extension-base/types';
9
- import { BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
9
+ import { AllSubstrateKeypairTypes, BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
10
10
  import { isEthereumAddress } from '@polkadot/util-crypto';
11
11
  export function _isCustomChain(slug) {
12
12
  if (slug.length === 0) {
@@ -34,7 +34,6 @@ export function _isEqualContractAddress(address1, address2) {
34
34
  if (isEthereumAddress(address1) && isEthereumAddress(address2)) {
35
35
  return address1.toLowerCase() === address2.toLowerCase(); // EVM address is case-insensitive
36
36
  }
37
-
38
37
  return address2 === address1;
39
38
  }
40
39
  export function _isEqualSmartContractAsset(asset1, asset2) {
@@ -174,12 +173,10 @@ export function _isSmartContractToken(tokenInfo) {
174
173
  export function _isChainSubstrateCompatible(chainInfo) {
175
174
  return !!chainInfo.substrateInfo; // fallback to Ethereum
176
175
  }
177
-
178
176
  export function _getEvmChainId(chainInfo) {
179
177
  var _chainInfo$evmInfo;
180
178
  return (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.evmChainId; // fallback to Ethereum
181
179
  }
182
-
183
180
  export function _getSubstrateParaId(chainInfo) {
184
181
  var _chainInfo$substrateI;
185
182
  return ((_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.paraId) || -1;
@@ -220,8 +217,8 @@ export function _isChainSupportEvmERC20(chainInfo) {
220
217
  return ((_chainInfo$evmInfo3 = chainInfo.evmInfo) === null || _chainInfo$evmInfo3 === void 0 ? void 0 : (_chainInfo$evmInfo3$s = _chainInfo$evmInfo3.supportSmartContract) === null || _chainInfo$evmInfo3$s === void 0 ? void 0 : _chainInfo$evmInfo3$s.includes(_AssetType.ERC20)) || false;
221
218
  }
222
219
  export function _isChainSupportWasmPSP22(chainInfo) {
223
- var _chainInfo$substrateI10, _chainInfo$substrateI11;
224
- return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_AssetType.PSP22)) || false;
220
+ var _chainInfo$substrateI0, _chainInfo$substrateI1;
221
+ return ((_chainInfo$substrateI0 = chainInfo.substrateInfo) === null || _chainInfo$substrateI0 === void 0 ? void 0 : (_chainInfo$substrateI1 = _chainInfo$substrateI0.supportSmartContract) === null || _chainInfo$substrateI1 === void 0 ? void 0 : _chainInfo$substrateI1.includes(_AssetType.PSP22)) || false;
225
222
  }
226
223
  export function _isAssetHubChain(chainInfo) {
227
224
  return ['statemint', 'statemine'].includes(chainInfo.slug);
@@ -230,12 +227,12 @@ export function _isAssetHubToken(token) {
230
227
  return ['statemint', 'statemine'].includes(token.originChain);
231
228
  }
232
229
  export function _isChainSupportGRC20(chainInfo) {
233
- var _chainInfo$substrateI12, _chainInfo$substrateI13;
234
- return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_AssetType.GRC20)) || false;
230
+ var _chainInfo$substrateI10, _chainInfo$substrateI11;
231
+ return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_AssetType.GRC20)) || false;
235
232
  }
236
233
  export function _isChainSupportVFT(chainInfo) {
237
- var _chainInfo$substrateI14, _chainInfo$substrateI15;
238
- return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : (_chainInfo$substrateI15 = _chainInfo$substrateI14.supportSmartContract) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.includes(_AssetType.VFT)) || false;
234
+ var _chainInfo$substrateI12, _chainInfo$substrateI13;
235
+ return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_AssetType.VFT)) || false;
239
236
  }
240
237
  export const _isSupportOrdinal = chain => {
241
238
  const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
@@ -347,7 +344,6 @@ export function _isTokenEvmSmartContract(tokenInfo) {
347
344
  export function _isTokenTonSmartContract(tokenInfo) {
348
345
  return [_AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
349
346
  }
350
-
351
347
  export function _isCIP26Token(tokenInfo) {
352
348
  return [_AssetType.CIP26].includes(tokenInfo.assetType);
353
349
  }
@@ -375,12 +371,12 @@ export function _getXcmAssetType(tokenInfo) {
375
371
  return ((_tokenInfo$metadata9 = tokenInfo.metadata) === null || _tokenInfo$metadata9 === void 0 ? void 0 : _tokenInfo$metadata9.assetType) || '';
376
372
  }
377
373
  export function _getXcmAssetId(tokenInfo) {
378
- var _tokenInfo$metadata10;
379
- return ((_tokenInfo$metadata10 = tokenInfo.metadata) === null || _tokenInfo$metadata10 === void 0 ? void 0 : _tokenInfo$metadata10.assetId) || '-1';
374
+ var _tokenInfo$metadata0;
375
+ return ((_tokenInfo$metadata0 = tokenInfo.metadata) === null || _tokenInfo$metadata0 === void 0 ? void 0 : _tokenInfo$metadata0.assetId) || '-1';
380
376
  }
381
377
  export function _getXcmAssetMultilocation(tokenInfo) {
382
- var _tokenInfo$metadata11;
383
- return (_tokenInfo$metadata11 = tokenInfo.metadata) === null || _tokenInfo$metadata11 === void 0 ? void 0 : _tokenInfo$metadata11.multilocation;
378
+ var _tokenInfo$metadata1;
379
+ return (_tokenInfo$metadata1 = tokenInfo.metadata) === null || _tokenInfo$metadata1 === void 0 ? void 0 : _tokenInfo$metadata1.multilocation;
384
380
  }
385
381
  export function _getXcmTransferType(originChainInfo, destinationChainInfo) {
386
382
  var _originChainInfo$subs, _destinationChainInfo;
@@ -390,12 +386,12 @@ export function _isRelayChain(chainInfo) {
390
386
  return _isSubstrateRelayChain(chainInfo) || _isPureEvmChain(chainInfo);
391
387
  }
392
388
  export function _isSubstrateRelayChain(chainInfo) {
393
- var _chainInfo$substrateI16;
394
- return ((_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.chainType) === _SubstrateChainType.RELAYCHAIN;
389
+ var _chainInfo$substrateI14;
390
+ return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : _chainInfo$substrateI14.chainType) === _SubstrateChainType.RELAYCHAIN;
395
391
  }
396
392
  export function _isSubstrateParaChain(chainInfo) {
397
- var _chainInfo$substrateI17;
398
- return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.chainType) === _SubstrateChainType.PARACHAIN;
393
+ var _chainInfo$substrateI15;
394
+ return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI15 = chainInfo.substrateInfo) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.chainType) === _SubstrateChainType.PARACHAIN;
399
395
  }
400
396
  export function _getEvmAbiExplorer(chainInfo) {
401
397
  var _chainInfo$evmInfo4;
@@ -449,8 +445,8 @@ export function _getBlockExplorerFromChain(chainInfo) {
449
445
  var _chainInfo$tonInfo;
450
446
  blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$tonInfo = chainInfo.tonInfo) === null || _chainInfo$tonInfo === void 0 ? void 0 : _chainInfo$tonInfo.blockExplorer;
451
447
  } else {
452
- var _chainInfo$substrateI18;
453
- blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
448
+ var _chainInfo$substrateI16;
449
+ blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.blockExplorer;
454
450
  }
455
451
  if (!blockExplorer) {
456
452
  return undefined;
@@ -481,8 +477,8 @@ export const _isAssetAutoEnable = chainAsset => {
481
477
  return chainAsset.metadata ? !!chainAsset.metadata.autoEnable : false;
482
478
  };
483
479
  export function _getCrowdloanUrlFromChain(chainInfo) {
484
- var _chainInfo$substrateI19;
485
- return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI19 = chainInfo.substrateInfo) === null || _chainInfo$substrateI19 === void 0 ? void 0 : _chainInfo$substrateI19.crowdloanUrl) || '';
480
+ var _chainInfo$substrateI17;
481
+ return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.crowdloanUrl) || '';
486
482
  }
487
483
  export function _isCustomProvider(providerKey) {
488
484
  return providerKey.startsWith(_CUSTOM_PREFIX);
@@ -518,8 +514,8 @@ export function _isMantaZkAsset(chainAsset) {
518
514
  return _MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_ZK_ASSET_PREFIX);
519
515
  }
520
516
  export function _getChainExistentialDeposit(chainInfo) {
521
- var _chainInfo$substrateI20;
522
- return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI20 = chainInfo.substrateInfo) === null || _chainInfo$substrateI20 === void 0 ? void 0 : _chainInfo$substrateI20.existentialDeposit) || '0';
517
+ var _chainInfo$substrateI18;
518
+ return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.existentialDeposit) || '0';
523
519
  }
524
520
  export function _getAssetExistentialDeposit(chainAsset) {
525
521
  return (chainAsset === null || chainAsset === void 0 ? void 0 : chainAsset.minAmount) || '0';
@@ -648,7 +644,7 @@ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) =>
648
644
  type: accountType
649
645
  } = accountInfo;
650
646
  if (accountChainType === AccountChainType.SUBSTRATE) {
651
- return _isPureSubstrateChain(chainInfo) && SubstrateKeypairTypes.includes(accountType);
647
+ return _isPureSubstrateChain(chainInfo) && AllSubstrateKeypairTypes.includes(accountType);
652
648
  }
653
649
  if (accountChainType === AccountChainType.ETHEREUM) {
654
650
  if (accountSignMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
@@ -133,6 +133,14 @@ export default class BasePoolHandler {
133
133
 
134
134
  /** Subscribe pool info */
135
135
 
136
+ /** Subscribe pool position */
137
+
138
+ /** Get pool reward */
139
+
140
+ /** Get pool reward history */
141
+
142
+ /** Get pool target */
143
+
136
144
  /* Subscribe data */
137
145
 
138
146
  /* Join action */
@@ -268,6 +276,24 @@ export default class BasePoolHandler {
268
276
 
269
277
  /** Validate param to join the pool */
270
278
 
279
+ /* Validate */
280
+
281
+ /* Submit */
282
+
283
+ /** Create `transaction` to join the pool step-by-step */
284
+
285
+ /* Submit */
286
+
287
+ /* Join action */
288
+
289
+ /* Leave action */
290
+
291
+ /** Validate param to leave the pool */
292
+
293
+ /** Create `transaction` to leave the pool normal (default unstake) */
294
+
295
+ /** Create `transaction` to leave the pool fast (swap token) */
296
+
271
297
  /** Create `transaction` to leave the pool */
272
298
  async handleYieldLeave(fastLeave, amount, address, selectedTarget, netuid, slippage) {
273
299
  if (fastLeave) {
@@ -283,6 +309,12 @@ export default class BasePoolHandler {
283
309
 
284
310
  /** Create `transaction` to withdraw unstaked amount */
285
311
 
312
+ /** Create `transaction` to cancel unstake */
313
+
314
+ /** Create `transaction` to claim reward */
315
+
316
+ /** Change earning validator */
317
+
286
318
  /** Check handler can handle slug */
287
319
  canHandleSlug(slug) {
288
320
  return this.slug === slug;
@@ -52,7 +52,6 @@ export default class BaseLendingPoolHandler extends BaseSpecialStakingPoolHandle
52
52
  if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
53
53
  errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
54
54
  }
55
-
56
55
  if (poolPosition.unstakings.length > maxUnstakeRequest) {
57
56
  errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_UNSTAKING, t('bg.EARNING.services.service.earning.lending.maxUnstakeTimes', {
58
57
  replace: {
@@ -64,7 +63,6 @@ export default class BaseLendingPoolHandler extends BaseSpecialStakingPoolHandle
64
63
  if (bnRemainingStake.lt(0)) {
65
64
  errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
66
65
  }
67
-
68
66
  return Promise.resolve(errors);
69
67
  }
70
68
 
@@ -249,7 +249,6 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
249
249
  // Min target amount
250
250
  weightedMinAmount // should always set a min target to prevent unexpected result
251
251
  );
252
-
253
252
  return [ExtrinsicType.REDEEM_LDOT, extrinsic];
254
253
  }
255
254
  async handleYieldUnstake(amount, address, selectedTarget) {