@subwallet/extension-base 1.3.52-0 → 1.3.54-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 (59) hide show
  1. package/background/KoniTypes.d.ts +10 -3
  2. package/cjs/koni/background/handlers/Extension.js +4 -4
  3. package/cjs/koni/background/handlers/State.js +1 -0
  4. package/cjs/packageInfo.js +1 -1
  5. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +21 -10
  6. package/cjs/services/chain-online-service/index.js +168 -15
  7. package/cjs/services/chain-service/index.js +39 -10
  8. package/cjs/services/chain-service/utils/patch.js +2 -2
  9. package/cjs/services/earning-service/constants/chains.js +2 -4
  10. package/cjs/services/earning-service/handlers/base.js +1 -1
  11. package/cjs/services/earning-service/handlers/native-staking/base.js +4 -2
  12. package/cjs/services/earning-service/handlers/native-staking/dtao.js +9 -3
  13. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +1 -10
  14. package/cjs/services/earning-service/handlers/native-staking/tao.js +24 -14
  15. package/cjs/services/earning-service/service.js +2 -2
  16. package/cjs/services/keyring-service/context/handlers/Json.js +28 -3
  17. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +6 -2
  18. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +6 -2
  19. package/cjs/services/migration-service/scripts/index.js +2 -2
  20. package/cjs/services/swap-service/index.js +24 -18
  21. package/cjs/services/transaction-service/utils.js +25 -16
  22. package/cjs/services/wallet-connect-service/constants.js +6 -2
  23. package/cjs/services/wallet-connect-service/index.js +62 -45
  24. package/koni/background/handlers/Extension.d.ts +1 -1
  25. package/koni/background/handlers/Extension.js +4 -4
  26. package/koni/background/handlers/State.js +1 -0
  27. package/package.json +30 -29
  28. package/packageInfo.js +1 -1
  29. package/services/balance-service/transfer/xcm/snowBridge.js +21 -10
  30. package/services/chain-online-service/index.d.ts +4 -1
  31. package/services/chain-online-service/index.js +168 -15
  32. package/services/chain-service/index.js +39 -10
  33. package/services/chain-service/utils/patch.d.ts +1 -1
  34. package/services/chain-service/utils/patch.js +2 -2
  35. package/services/earning-service/constants/chains.d.ts +0 -1
  36. package/services/earning-service/constants/chains.js +1 -2
  37. package/services/earning-service/handlers/base.d.ts +3 -3
  38. package/services/earning-service/handlers/base.js +1 -1
  39. package/services/earning-service/handlers/native-staking/base.js +4 -2
  40. package/services/earning-service/handlers/native-staking/dtao.d.ts +4 -3
  41. package/services/earning-service/handlers/native-staking/dtao.js +9 -3
  42. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -2
  43. package/services/earning-service/handlers/native-staking/relay-chain.js +2 -11
  44. package/services/earning-service/handlers/native-staking/tao.d.ts +1 -0
  45. package/services/earning-service/handlers/native-staking/tao.js +24 -14
  46. package/services/earning-service/service.d.ts +3 -3
  47. package/services/earning-service/service.js +2 -2
  48. package/services/keyring-service/context/handlers/Json.js +28 -3
  49. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +6 -2
  50. package/services/migration-service/scripts/databases/MigrateAssetSetting.js +6 -2
  51. package/services/migration-service/scripts/index.js +2 -2
  52. package/services/swap-service/index.js +24 -18
  53. package/services/transaction-service/utils.js +25 -16
  54. package/services/wallet-connect-service/constants.d.ts +2 -0
  55. package/services/wallet-connect-service/constants.js +3 -1
  56. package/services/wallet-connect-service/index.js +50 -33
  57. package/types/yield/actions/join/submit.d.ts +5 -0
  58. package/types/yield/actions/others.d.ts +7 -2
  59. package/types/yield/info/account/info.d.ts +1 -0
@@ -14,6 +14,7 @@ var _basePara = _interopRequireDefault(require("@subwallet/extension-base/servic
14
14
  var _types = require("@subwallet/extension-base/types");
15
15
  var _environment = require("@subwallet/extension-base/types/environment");
16
16
  var _utils3 = require("@subwallet/extension-base/utils");
17
+ var _fetchStaticCache = require("@subwallet/extension-base/utils/fetchStaticCache");
17
18
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
18
19
  var _i18next = require("i18next");
19
20
  var _rxjs = require("rxjs");
@@ -52,21 +53,12 @@ class BittensorCache {
52
53
  }
53
54
  async fetchData() {
54
55
  try {
55
- const resp = await (0, _utils3.fetchFromProxyService)(_environment.ProxyServiceRoute.BITTENSOR, '/dtao/validator/latest/v1?limit=100', {
56
- method: 'GET',
57
- headers: {
58
- 'Content-Type': 'application/json'
59
- }
56
+ const fetchData = await (0, _fetchStaticCache.fetchStaticCache)('earning/dtao/validator.json', {
57
+ data: {}
60
58
  });
61
- if (!resp.ok) {
62
- console.error('Fetch bittensor delegates fail:', resp.status);
63
- return this.cache || {
64
- data: []
65
- };
66
- }
67
- const rawData = await resp.json();
59
+ const validators = Object.values(fetchData.data);
68
60
  const data = {
69
- data: rawData.data.filter(validator => parseFloat(validator.root_stake) > 0)
61
+ data: validators.filter(validator => parseFloat(validator.root_stake) > 0)
70
62
  };
71
63
  this.cache = data;
72
64
  this.promise = null;
@@ -79,7 +71,8 @@ class BittensorCache {
79
71
  this.cache = newData;
80
72
  }
81
73
  }).catch(console.error);
82
- }, 60 * 2000);
74
+ }, 60 * 1000); // Cache 1 minute
75
+
83
76
  return data;
84
77
  } catch (error) {
85
78
  console.error(error);
@@ -110,6 +103,23 @@ class BittensorCache {
110
103
  };
111
104
  }
112
105
  }
106
+ async fetchSubnetFeeRate(netuid) {
107
+ try {
108
+ var _subnet$fee_rate;
109
+ const resp = await (0, _utils3.fetchFromProxyService)(_environment.ProxyServiceRoute.BITTENSOR, '/subnet/latest/v1', {
110
+ method: 'GET',
111
+ headers: {
112
+ 'Content-Type': 'application/json'
113
+ }
114
+ });
115
+ const rawData = await resp.json();
116
+ const subnet = rawData.data.find(item => item.netuid === netuid);
117
+ return (_subnet$fee_rate = subnet === null || subnet === void 0 ? void 0 : subnet.fee_rate) !== null && _subnet$fee_rate !== void 0 ? _subnet$fee_rate : '0.0005';
118
+ } catch (error) {
119
+ console.error(error);
120
+ return '0.0005'; // Default fee rate if fetch fails
121
+ }
122
+ }
113
123
  }
114
124
 
115
125
  // export async function fetchTaoDelegateState (address: string): Promise<RawDelegateState> {
@@ -959,14 +959,14 @@ class EarningService {
959
959
  return Promise.reject(new _TransactionError.TransactionError(_types2.BasicTxErrorType.INTERNAL_ERROR));
960
960
  }
961
961
  }
962
- async yieldGetEarningSlippage(params) {
962
+ async yieldGetEarningImpact(params) {
963
963
  await this.eventService.waitChainReady;
964
964
  const {
965
965
  slug
966
966
  } = params;
967
967
  const handler = this.getPoolHandler(slug);
968
968
  if (handler) {
969
- return handler.getEarningSlippage(params);
969
+ return handler.getEarningImpact(params);
970
970
  } else {
971
971
  return Promise.reject(new _TransactionError.TransactionError(_types2.BasicTxErrorType.INTERNAL_ERROR));
972
972
  }
@@ -162,7 +162,17 @@ class AccountJsonHandler extends _Base.AccountBaseHandler {
162
162
  accountProxies,
163
163
  modifyPairs
164
164
  } = json;
165
- const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
165
+ const pairs = jsons.reduce((rs, pair) => {
166
+ try {
167
+ rs.push(_uiKeyring.keyring.createFromJson(pair));
168
+ } catch (e) {
169
+ console.error(e);
170
+ }
171
+ return rs;
172
+ }, []);
173
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
174
+ throw new Error((0, _i18next.t)('No valid accounts found to import'));
175
+ }
166
176
  const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
167
177
  const result = Object.values(accountProxyMap).map(proxy => {
168
178
  const rs = {
@@ -205,9 +215,24 @@ class AccountJsonHandler extends _Base.AccountBaseHandler {
205
215
  try {
206
216
  const {
207
217
  accountProxies,
208
- modifyPairs
218
+ modifyPairs: modifyPairsRestored
209
219
  } = file;
210
- const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
220
+ const modifyPairs = {};
221
+ const pairs = jsons.reduce((rs, pairJson) => {
222
+ try {
223
+ const pair = _uiKeyring.keyring.createFromJson(pairJson);
224
+ if (modifyPairsRestored !== null && modifyPairsRestored !== void 0 && modifyPairsRestored[pair.address]) {
225
+ modifyPairs[pair.address] = modifyPairsRestored[pair.address];
226
+ }
227
+ rs.push(pair);
228
+ } catch (e) {
229
+ console.error(e);
230
+ }
231
+ return rs;
232
+ }, []);
233
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
234
+ throw new Error((0, _i18next.t)('No valid accounts found to import'));
235
+ }
211
236
  const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
212
237
  const rawProxyIds = _proxyIds && _proxyIds.length ? _proxyIds : Object.keys(accountProxyMap);
213
238
  let _exists;
@@ -14,8 +14,12 @@ class MigrateTransactionHistoryBySymbol extends _Base.default {
14
14
  const state = this.state;
15
15
  try {
16
16
  const changeSlugsMap = {
17
- 'polygon-NATIVE-MATIC': 'polygon-NATIVE-POL',
18
- '5irechain_mainnet-NATIVE-5IRE': '5irechain_mainnet-NATIVE-5ire'
17
+ 'bifrost_testnet-NATIVE-BNC': 'bifrost_testnet-NATIVE-BFC',
18
+ 'energy_web_x_rococo-NATIVE-VT': 'energy_web_x_rococo-NATIVE-EWT',
19
+ 'chainflip_dot-NATIVE-DOT': 'chainflip_dot-NATIVE-Unit',
20
+ 'autonomys_taurus-NATIVE-AI3': 'autonomys_taurus-NATIVE-tAI3',
21
+ 'fraxtal-NATIVE-frxETH': 'fraxtal-ERC20-frxETH-0xFC00000000000000000000000000000000000006',
22
+ 'arbitrum_one-ERC20-USDT-0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9': 'arbitrum_one-ERC20-USD₮0-0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9'
19
23
  };
20
24
  const allTxs = [];
21
25
  await Promise.all(Object.entries(changeSlugsMap).map(async (_ref, i) => {
@@ -13,8 +13,12 @@ class MigrateAssetSetting extends _Base.default {
13
13
  async run() {
14
14
  try {
15
15
  const changeSlugsMap = {
16
- 'polygon-NATIVE-MATIC': 'polygon-NATIVE-POL',
17
- '5irechain_mainnet-NATIVE-5IRE': '5irechain_mainnet-NATIVE-5ire'
16
+ 'bifrost_testnet-NATIVE-BNC': 'bifrost_testnet-NATIVE-BFC',
17
+ 'energy_web_x_rococo-NATIVE-VT': 'energy_web_x_rococo-NATIVE-EWT',
18
+ 'chainflip_dot-NATIVE-DOT': 'chainflip_dot-NATIVE-Unit',
19
+ 'autonomys_taurus-NATIVE-AI3': 'autonomys_taurus-NATIVE-tAI3',
20
+ 'fraxtal-NATIVE-frxETH': 'fraxtal-ERC20-frxETH-0xFC00000000000000000000000000000000000006',
21
+ 'arbitrum_one-ERC20-USDT-0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9': 'arbitrum_one-ERC20-USD₮0-0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9'
18
22
  };
19
23
  const assetSetting = await this.state.chainService.getAssetSettings();
20
24
  const migratedAssetSetting = {};
@@ -63,8 +63,8 @@ var _default = {
63
63
  '1.1.33-01': _MigrateLedgerAccountV.default,
64
64
  '1.1.41-01': _DeleteChainStaking.default,
65
65
  // '1.1.46-01': AutoEnableSomeTokens,
66
- '1.2.28-01': _MigrateAssetSetting.default,
67
- '1.2.28-02': _MigrateTransactionHistoryBySymbol.default,
66
+ '1.3.53-01': _MigrateAssetSetting.default,
67
+ '1.3.53-02': _MigrateTransactionHistoryBySymbol.default,
68
68
  '1.2.69-01': _MigrateRemoveGenesisHash.default,
69
69
  '1.2.13-01': _ReloadMetadata.default,
70
70
  '1.2.32-01': _MigratePairData.default,
@@ -50,24 +50,30 @@ class SwapService {
50
50
  ..._request,
51
51
  isSupportKyberVersion: true
52
52
  };
53
- const quotes = await _subwalletServicesSdk.default.swapApi.fetchSwapQuoteData(request);
54
- if (Array.isArray(quotes)) {
55
- quotes.forEach(quoteData => {
56
- if (!_swap._SUPPORTED_SWAP_PROVIDERS.includes(quoteData.provider)) {
57
- return;
58
- }
59
- if (!quoteData.quote || Object.keys(quoteData.quote).length === 0) {
60
- return;
61
- }
62
- if (!('errorClass' in quoteData.quote)) {
63
- availableQuotes.push({
64
- quote: quoteData.quote
65
- });
66
- } else {
67
- availableQuotes.push({
68
- error: new _SwapError.SwapError(quoteData.quote.errorType, quoteData.quote.message)
69
- });
70
- }
53
+ try {
54
+ const quotes = await _subwalletServicesSdk.default.swapApi.fetchSwapQuoteData(request);
55
+ if (Array.isArray(quotes)) {
56
+ quotes.forEach(quoteData => {
57
+ if (!_swap._SUPPORTED_SWAP_PROVIDERS.includes(quoteData.provider)) {
58
+ return;
59
+ }
60
+ if (!quoteData.quote || Object.keys(quoteData.quote).length === 0) {
61
+ return;
62
+ }
63
+ if (!('errorClass' in quoteData.quote)) {
64
+ availableQuotes.push({
65
+ quote: quoteData.quote
66
+ });
67
+ } else {
68
+ availableQuotes.push({
69
+ error: new _SwapError.SwapError(quoteData.quote.errorType, quoteData.quote.message)
70
+ });
71
+ }
72
+ });
73
+ }
74
+ } catch (err) {
75
+ availableQuotes.push({
76
+ error: new _SwapError.SwapError(_swap.SwapErrorType.ASSET_NOT_SUPPORTED)
71
77
  });
72
78
  }
73
79
  return availableQuotes;
@@ -24,6 +24,21 @@ function getBlockExplorerAccountRoute(explorerLink) {
24
24
  if (explorerLink.includes('explorer.subspace.network')) {
25
25
  return 'accounts';
26
26
  }
27
+ if (explorerLink.includes('edgscan.ink')) {
28
+ return 'accounts';
29
+ }
30
+ if (explorerLink.includes('devnet-explorer.mosaicchain.io')) {
31
+ return 'accounts';
32
+ }
33
+ if (explorerLink.includes('statescan.io')) {
34
+ return '#/accounts';
35
+ }
36
+ if (explorerLink.includes('explorer.joystream.org')) {
37
+ return '#/accounts';
38
+ }
39
+ if (explorerLink.includes('explorer.gen6.app')) {
40
+ return '#/accounts';
41
+ }
27
42
  if (explorerLink.includes('deeperscan.io')) {
28
43
  return 'account';
29
44
  }
@@ -33,24 +48,18 @@ function getBlockExplorerAccountRoute(explorerLink) {
33
48
  if (explorerLink.includes('3dpscan.io')) {
34
49
  return 'account';
35
50
  }
36
- if (explorerLink.includes('statescan.io')) {
37
- return '#/accounts';
38
- }
39
- if (explorerLink.includes('explorer.gen6.app')) {
40
- return '#/accounts';
41
- }
42
- if (explorerLink.includes('astral.autonomys')) {
43
- return 'accounts';
51
+ if (explorerLink.includes('main.dentnet.io')) {
52
+ return 'account';
44
53
  }
45
54
  if (explorerLink.includes('taostats.io')) {
46
55
  return 'account';
47
56
  }
57
+ if (explorerLink.includes('uniquescan.io')) {
58
+ return 'account';
59
+ }
48
60
  if (explorerLink.includes('tonviewer.com')) {
49
61
  return '';
50
62
  }
51
- if (explorerLink.includes('devnet-explorer.mosaicchain.io')) {
52
- return 'accounts';
53
- }
54
63
  if (explorerLink.includes('pdexmon.com')) {
55
64
  return 'holders';
56
65
  }
@@ -60,7 +69,7 @@ function getBlockExplorerTxRoute(chainInfo) {
60
69
  if ((0, _utils._isPureEvmChain)(chainInfo) || (0, _utils._isPureBitcoinChain)(chainInfo)) {
61
70
  return 'tx';
62
71
  }
63
- if (['moonbeam'].includes(chainInfo.slug)) {
72
+ if (['moonbeam', 'crabParachain'].includes(chainInfo.slug)) {
64
73
  return 'tx';
65
74
  }
66
75
  if ((0, _utils._isPureCardanoChain)(chainInfo) || (0, _utils._isPureTonChain)(chainInfo)) {
@@ -69,15 +78,15 @@ function getBlockExplorerTxRoute(chainInfo) {
69
78
  if (['aventus', 'deeper_network'].includes(chainInfo.slug)) {
70
79
  return 'transaction';
71
80
  }
72
- if (['gen6_public'].includes(chainInfo.slug)) {
81
+ if (['gen6_public', 'joystream'].includes(chainInfo.slug)) {
73
82
  return '#/extrinsics';
74
83
  }
84
+ if (['edgeware'].includes(chainInfo.slug)) {
85
+ return 'extrinsics';
86
+ }
75
87
  if (['mosaicTest', 'polkadex'].includes(chainInfo.slug)) {
76
88
  return 'transactions';
77
89
  }
78
- if (['autonomys'].includes(chainInfo.slug)) {
79
- return 'extrinsics';
80
- }
81
90
  const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
82
91
  if (explorerLink && explorerLink.includes('statescan.io')) {
83
92
  return '#/extrinsics';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.PROJECT_ID_MOBILE = exports.PROJECT_ID_EXTENSION = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
6
+ exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_SESSION_TIMEOUT = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.RELAY_FALLBACK_URL = exports.PROJECT_ID_MOBILE = exports.PROJECT_ID_EXTENSION = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
7
7
  var _types = require("@subwallet/extension-base/services/wallet-connect-service/types");
8
8
  var _utils = require("@subwallet/extension-base/utils");
9
9
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
@@ -15,6 +15,8 @@ const PROJECT_ID_MOBILE = '6da34c0b48164d27681924dd9a46d6be';
15
15
  exports.PROJECT_ID_MOBILE = PROJECT_ID_MOBILE;
16
16
  const RELAY_URL = 'wss://relay.walletconnect.com';
17
17
  exports.RELAY_URL = RELAY_URL;
18
+ const RELAY_FALLBACK_URL = 'wss://relay.walletconnect.org';
19
+ exports.RELAY_FALLBACK_URL = RELAY_FALLBACK_URL;
18
20
  const DEFAULT_WALLET_CONNECT_OPTIONS = {
19
21
  logger: 'error',
20
22
  projectId: _utils.targetIsMobile ? PROJECT_ID_MOBILE : PROJECT_ID_EXTENSION,
@@ -38,4 +40,6 @@ exports.WALLET_CONNECT_EIP155_NAMESPACE = WALLET_CONNECT_EIP155_NAMESPACE;
38
40
  const WALLET_CONNECT_POLKADOT_NAMESPACE = 'polkadot';
39
41
  exports.WALLET_CONNECT_POLKADOT_NAMESPACE = WALLET_CONNECT_POLKADOT_NAMESPACE;
40
42
  const WALLET_CONNECT_SUPPORT_NAMESPACES = [WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_POLKADOT_NAMESPACE];
41
- exports.WALLET_CONNECT_SUPPORT_NAMESPACES = WALLET_CONNECT_SUPPORT_NAMESPACES;
43
+ exports.WALLET_CONNECT_SUPPORT_NAMESPACES = WALLET_CONNECT_SUPPORT_NAMESPACES;
44
+ const WALLET_CONNECT_SESSION_TIMEOUT = 20000; // 20 seconds
45
+ exports.WALLET_CONNECT_SESSION_TIMEOUT = WALLET_CONNECT_SESSION_TIMEOUT;
@@ -10,8 +10,9 @@ var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime
10
10
  var _utils = require("@json-rpc-tools/utils");
11
11
  var _Eip155RequestHandler = _interopRequireDefault(require("@subwallet/extension-base/services/wallet-connect-service/handler/Eip155RequestHandler"));
12
12
  var _storage = require("@subwallet/extension-base/storage");
13
+ var _utils2 = require("@subwallet/extension-base/utils");
13
14
  var _signClient = _interopRequireDefault(require("@walletconnect/sign-client"));
14
- var _utils2 = require("@walletconnect/utils");
15
+ var _utils3 = require("@walletconnect/utils");
15
16
  var _rxjs = require("rxjs");
16
17
  var _PolkadotRequestHandler = _interopRequireDefault(require("./handler/PolkadotRequestHandler"));
17
18
  var _constants = require("./constants");
@@ -130,7 +131,19 @@ class WalletConnectService {
130
131
  async initClient(force) {
131
132
  (0, _classPrivateFieldLooseBase2.default)(this, _removeListener)[_removeListener]();
132
133
  if (force || (await this.haveData())) {
133
- (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
134
+ try {
135
+ (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
136
+ } catch (e) {
137
+ if ((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option].relayUrl === _constants.RELAY_URL) {
138
+ (0, _classPrivateFieldLooseBase2.default)(this, _option)[_option] = {
139
+ ...(0, _classPrivateFieldLooseBase2.default)(this, _option)[_option],
140
+ relayUrl: _constants.RELAY_FALLBACK_URL
141
+ };
142
+ (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
143
+ } else {
144
+ throw e;
145
+ }
146
+ }
134
147
  }
135
148
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
136
149
  (0, _classPrivateFieldLooseBase2.default)(this, _createListener)[_createListener]();
@@ -143,7 +156,7 @@ class WalletConnectService {
143
156
  var _classPrivateFieldLoo2;
144
157
  const session = (_classPrivateFieldLoo2 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo2 === void 0 ? void 0 : _classPrivateFieldLoo2.session.get(topic);
145
158
  if (!session) {
146
- throw new Error((0, _utils2.getInternalError)('MISMATCHED_TOPIC').message);
159
+ throw new Error((0, _utils3.getInternalError)('MISMATCHED_TOPIC').message);
147
160
  } else {
148
161
  return session;
149
162
  }
@@ -153,17 +166,21 @@ class WalletConnectService {
153
166
  await this.initClient();
154
167
  }
155
168
  async connect(uri) {
156
- var _classPrivateFieldLoo3;
157
- if (!(await this.haveData())) {
169
+ var _classPrivateFieldLoo3, _classPrivateFieldLoo4;
170
+ if (!(await this.haveData()) || !((_classPrivateFieldLoo3 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) !== null && _classPrivateFieldLoo3 !== void 0 && _classPrivateFieldLoo3.core.relayer.connected)) {
158
171
  await this.initClient(true);
159
172
  }
160
173
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
161
- await ((_classPrivateFieldLoo3 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo3 === void 0 ? void 0 : _classPrivateFieldLoo3.pair({
174
+
175
+ // The purpose of designing a timeout for pairing is to prevent the promise from not being resolved if there are issues during the pairing process.
176
+ await Promise.race([(_classPrivateFieldLoo4 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.pair({
162
177
  uri
163
- }));
178
+ }), (0, _utils2.wait)(_constants.WALLET_CONNECT_SESSION_TIMEOUT).then(() => {
179
+ throw new Error((0, _utils3.getInternalError)('EXPIRED').message);
180
+ })]);
164
181
  }
165
182
  async approveSession(result) {
166
- var _classPrivateFieldLoo4;
183
+ var _classPrivateFieldLoo5;
167
184
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
168
185
  Object.entries(result.namespaces).forEach(_ref3 => {
169
186
  let [namespace, {
@@ -172,34 +189,34 @@ class WalletConnectService {
172
189
  methods = [...methods, ...this.findMethodsMissing(_constants.WALLET_CONNECT_EIP155_NAMESPACE === namespace ? methodEVMRequire : methodDOTRequire, methods)];
173
190
  result.namespaces[namespace].methods = methods;
174
191
  });
175
- await ((_classPrivateFieldLoo4 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.approve(result));
192
+ await ((_classPrivateFieldLoo5 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.approve(result));
176
193
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
177
194
  }
178
195
  async rejectSession(id) {
179
- var _classPrivateFieldLoo5;
196
+ var _classPrivateFieldLoo6;
180
197
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
181
- await ((_classPrivateFieldLoo5 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.reject({
198
+ await ((_classPrivateFieldLoo6 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.reject({
182
199
  id: id,
183
- reason: (0, _utils2.getSdkError)('USER_REJECTED')
200
+ reason: (0, _utils3.getSdkError)('USER_REJECTED')
184
201
  }));
185
202
  }
186
203
  async responseRequest(response) {
187
- var _classPrivateFieldLoo6;
204
+ var _classPrivateFieldLoo7;
188
205
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
189
- await ((_classPrivateFieldLoo6 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.respond(response));
206
+ await ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.respond(response));
190
207
  }
191
208
  async resetWallet(resetAll) {
192
- var _classPrivateFieldLoo7, _classPrivateFieldLoo9, _classPrivateFieldLoo11;
209
+ var _classPrivateFieldLoo8, _classPrivateFieldLoo10, _classPrivateFieldLoo12;
193
210
  (0, _classPrivateFieldLooseBase2.default)(this, _removeListener)[_removeListener]();
194
211
 
195
212
  // Disconnect session
196
- const sessions = ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.session.values) || [];
213
+ const sessions = ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.session.values) || [];
197
214
  for (const session of sessions) {
198
215
  try {
199
- var _classPrivateFieldLoo8;
200
- await ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.disconnect({
216
+ var _classPrivateFieldLoo9;
217
+ await ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.disconnect({
201
218
  topic: session.topic,
202
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
219
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
203
220
  }));
204
221
  } catch (e) {
205
222
  console.error(e);
@@ -207,24 +224,24 @@ class WalletConnectService {
207
224
  }
208
225
 
209
226
  // Disconnect pair
210
- const pairs = ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.pairing.values) || [];
227
+ const pairs = ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.pairing.values) || [];
211
228
  for (const pair of pairs) {
212
229
  try {
213
- var _classPrivateFieldLoo10;
214
- await ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.disconnect({
230
+ var _classPrivateFieldLoo11;
231
+ await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.disconnect({
215
232
  topic: pair.topic,
216
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
233
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
217
234
  }));
218
235
  } catch (e) {
219
236
  console.error(e);
220
237
  }
221
238
  }
222
- const keys = (await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.getKeys())) || [];
239
+ const keys = (await ((_classPrivateFieldLoo12 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.getKeys())) || [];
223
240
  const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
224
241
  for (const key of deleteKeys) {
225
242
  try {
226
- var _classPrivateFieldLoo12;
227
- await ((_classPrivateFieldLoo12 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.removeItem(key));
243
+ var _classPrivateFieldLoo13;
244
+ await ((_classPrivateFieldLoo13 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.core.storage.removeItem(key));
228
245
  } catch (e) {
229
246
  console.error(e);
230
247
  }
@@ -233,10 +250,10 @@ class WalletConnectService {
233
250
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
234
251
  }
235
252
  async disconnect(topic) {
236
- var _classPrivateFieldLoo13;
237
- await ((_classPrivateFieldLoo13 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.disconnect({
253
+ var _classPrivateFieldLoo14;
254
+ await ((_classPrivateFieldLoo14 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.disconnect({
238
255
  topic: topic,
239
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
256
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
240
257
  }));
241
258
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
242
259
  }
@@ -279,19 +296,19 @@ function _onSessionRequest2(requestEvent) {
279
296
  const chainInfoMap = (0, _classPrivateFieldLooseBase2.default)(this, _koniState)[_koniState].getChainInfoMap();
280
297
  const [requestNamespace] = chainId.split(':');
281
298
  if (!namespaces.includes(requestNamespace)) {
282
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message);
299
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message);
283
300
  }
284
301
  if (!chains.includes(chainId)) {
285
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
302
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
286
303
  }
287
304
  if (!(0, _helpers.isSupportWalletConnectChain)(chainId, chainInfoMap)) {
288
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
305
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
289
306
  }
290
307
  if (!methods.includes(method)) {
291
- throw Error((0, _utils2.getSdkError)('UNAUTHORIZED_METHOD').message + ' ' + method);
308
+ throw Error((0, _utils3.getSdkError)('UNAUTHORIZED_METHOD').message + ' ' + method);
292
309
  }
293
310
  if (!_constants.WALLET_CONNECT_SUPPORTED_METHODS.includes(method)) {
294
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_METHODS').message + ' ' + method);
311
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_METHODS').message + ' ' + method);
295
312
  }
296
313
  switch (method) {
297
314
  case _types.POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_MESSAGE:
@@ -307,7 +324,7 @@ function _onSessionRequest2(requestEvent) {
307
324
  (0, _classPrivateFieldLooseBase2.default)(this, _eip155RequestHandler)[_eip155RequestHandler].handleRequest(requestEvent);
308
325
  break;
309
326
  default:
310
- throw Error((0, _utils2.getSdkError)('INVALID_METHOD').message + ' ' + method);
327
+ throw Error((0, _utils3.getSdkError)('INVALID_METHOD').message + ' ' + method);
311
328
  }
312
329
  } catch (e) {
313
330
  console.log(e);
@@ -343,22 +360,22 @@ async function _onPingReply2(_ref4) {
343
360
  }
344
361
  }
345
362
  function _createListener2() {
346
- var _classPrivateFieldLoo14, _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19;
347
- (_classPrivateFieldLoo14 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.on('session_proposal', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionProposal)[_onSessionProposal].bind(this));
348
- (_classPrivateFieldLoo15 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_request', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionRequest)[_onSessionRequest].bind(this));
349
- (_classPrivateFieldLoo16 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_ping', (0, _classPrivateFieldLooseBase2.default)(this, _onPingReply)[_onPingReply].bind(this));
350
- (_classPrivateFieldLoo17 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_event', data => console.log('event', data));
351
- (_classPrivateFieldLoo18 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_update', data => console.log('update', data));
352
- (_classPrivateFieldLoo19 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_delete', (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions].bind(this));
363
+ var _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19, _classPrivateFieldLoo20;
364
+ (_classPrivateFieldLoo15 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_proposal', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionProposal)[_onSessionProposal].bind(this));
365
+ (_classPrivateFieldLoo16 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_request', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionRequest)[_onSessionRequest].bind(this));
366
+ (_classPrivateFieldLoo17 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_ping', (0, _classPrivateFieldLooseBase2.default)(this, _onPingReply)[_onPingReply].bind(this));
367
+ (_classPrivateFieldLoo18 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_event', data => console.log('event', data));
368
+ (_classPrivateFieldLoo19 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_update', data => console.log('update', data));
369
+ (_classPrivateFieldLoo20 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.on('session_delete', (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions].bind(this));
353
370
  }
354
371
  function _removeListener2() {
355
372
  _constants.ALL_WALLET_CONNECT_EVENT.forEach(event => {
356
- var _classPrivateFieldLoo20;
357
- (_classPrivateFieldLoo20 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.removeAllListeners(event);
373
+ var _classPrivateFieldLoo21;
374
+ (_classPrivateFieldLoo21 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo21 === void 0 ? void 0 : _classPrivateFieldLoo21.removeAllListeners(event);
358
375
  });
359
376
  }
360
377
  function _checkClient2() {
361
378
  if (!(0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) {
362
- throw new Error((0, _utils2.getInternalError)('NOT_INITIALIZED').message);
379
+ throw new Error((0, _utils3.getInternalError)('NOT_INITIALIZED').message);
363
380
  }
364
381
  }
@@ -252,7 +252,7 @@ export default class KoniExtension {
252
252
  private yieldSubmitWithdrawal;
253
253
  private yieldSubmitCancelWithdrawal;
254
254
  private yieldSubmitClaimReward;
255
- private yieldGetEarningSlippage;
255
+ private yieldGetEarningImpact;
256
256
  private handleYieldChangeValidator;
257
257
  private unlockDotCheckCanMint;
258
258
  private unlockDotSubscribeMintedData;
@@ -3960,7 +3960,7 @@ export default class KoniExtension {
3960
3960
  chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || ChainType.SUBSTRATE
3961
3961
  });
3962
3962
  }
3963
- async yieldGetEarningSlippage(params) {
3963
+ async yieldGetEarningImpact(params) {
3964
3964
  const {
3965
3965
  slug
3966
3966
  } = params;
@@ -3968,7 +3968,7 @@ export default class KoniExtension {
3968
3968
  if (!poolHandler) {
3969
3969
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INVALID_PARAMS)]);
3970
3970
  }
3971
- const slippage = await this.#koniState.earningService.yieldGetEarningSlippage(params);
3971
+ const slippage = await this.#koniState.earningService.yieldGetEarningImpact(params);
3972
3972
  return slippage;
3973
3973
  }
3974
3974
  async handleYieldChangeValidator(params) {
@@ -4857,8 +4857,8 @@ export default class KoniExtension {
4857
4857
  return await this.yieldSubmitCancelWithdrawal(request);
4858
4858
  case 'pri(yield.claimReward.submit)':
4859
4859
  return await this.yieldSubmitClaimReward(request);
4860
- case 'pri(yield.getEarningSlippage)':
4861
- return await this.yieldGetEarningSlippage(request);
4860
+ case 'pri(yield.getEarningImpact)':
4861
+ return await this.yieldGetEarningImpact(request);
4862
4862
  case 'pri(yield.changeValidator.submit)':
4863
4863
  return await this.handleYieldChangeValidator(request);
4864
4864
  /* Others */
@@ -1803,6 +1803,7 @@ export default class KoniState {
1803
1803
  this.chainService.resetWallet(resetAll);
1804
1804
  await this.walletConnectService.resetWallet(resetAll);
1805
1805
  await this.chainService.init();
1806
+ this.chainOnlineService.resetFirstApplied();
1806
1807
  this.chainOnlineService.checkLatestData();
1807
1808
  this.chainService.checkLatestData();
1808
1809
  this.chainService.subscribeChainInfoMap().subscribe(() => {