@rango-dev/wallets-react 0.47.1-next.4 → 0.47.1-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/wallets-react",
3
- "version": "0.47.1-next.4",
3
+ "version": "0.47.1-next.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -35,16 +35,16 @@
35
35
  "react-dom": "^17.0.0 || ^18.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@hub3js/core": "^0.61.0",
39
- "@hub3js/evm": "^0.3.0",
40
- "@hub3js/namespaces": "^0.2.2",
41
- "@hub3js/solana": "^0.3.0",
42
- "@hub3js/std": "^0.2.0",
43
- "@hub3js/sui": "^0.2.0",
44
- "@hub3js/tvm": "^0.2.0",
38
+ "@hub3js/core": "^0.61.1",
39
+ "@hub3js/evm": "^0.3.3",
40
+ "@hub3js/namespaces": "^0.2.5",
41
+ "@hub3js/solana": "^0.3.3",
42
+ "@hub3js/std": "^0.2.3",
43
+ "@hub3js/sui": "^0.2.3",
44
+ "@hub3js/tvm": "^0.2.3",
45
45
  "@rango-dev/logging-core": "^0.13.1-next.0",
46
- "@rango-dev/wallets-core": "^0.60.1-next.3",
47
- "@rango-dev/wallets-shared": "^0.61.1-next.4",
46
+ "@rango-dev/wallets-core": "^0.60.1-next.4",
47
+ "@rango-dev/wallets-shared": "^0.61.1-next.5",
48
48
  "caip": "^1.1.1",
49
49
  "rango-types": "^0.5.0",
50
50
  "ts-results": "^3.3.0"
@@ -6,7 +6,12 @@ import type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';
6
6
  import type { LegacyNamespaceInputForConnect } from '@rango-dev/wallets-core/legacy';
7
7
 
8
8
  import { utils } from '@hub3js/evm';
9
- import { type WalletInfo, type WalletType } from '@rango-dev/wallets-shared';
9
+ import {
10
+ getSupportedChainsFromNamespace,
11
+ getSupportedChainsFromProvider,
12
+ type WalletInfo,
13
+ type WalletType,
14
+ } from '@rango-dev/wallets-shared';
10
15
  import { useEffect, useRef, useState } from 'react';
11
16
  import { Ok, Result } from 'ts-results';
12
17
 
@@ -22,7 +27,6 @@ import { createQueue, fromAccountIdToLegacyAddressFormat } from './helpers.js';
22
27
  import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
23
28
  import { useHubRefs } from './useHubRefs.js';
24
29
  import {
25
- getSupportedChainsFromProvider,
26
30
  isEvmNamespace,
27
31
  isSolanaNamespace,
28
32
  isUtxoNamespace,
@@ -182,21 +186,25 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
182
186
  if (!dataRef.current.allBlockChains) {
183
187
  throw new Error(`Blockchains are not available`);
184
188
  }
185
- const providerSupportedChainsOfNamespace = namespacesProperty?.value.data
186
- .find(
187
- (providerNamespace) => providerNamespace.value === namespace.namespace
188
- )
189
- ?.getSupportedChains(dataRef.current.allBlockChains);
190
189
 
191
- if (!providerSupportedChainsOfNamespace) {
190
+ const namespaceMeta = namespacesProperty?.value.data.find(
191
+ (providerNamespace) => providerNamespace.value === namespace.namespace
192
+ );
193
+
194
+ if (!namespaceMeta) {
192
195
  throw new Error(
193
196
  `NamespaceMeta is not defined for requested namespace: ${namespace.namespace}`
194
197
  );
195
198
  }
196
199
 
200
+ const supportedChains = getSupportedChainsFromNamespace(
201
+ namespaceMeta,
202
+ dataRef.current.allBlockChains
203
+ );
204
+
197
205
  return proxiedNamespace.canSwitchNetwork({
198
206
  network,
199
- supportedChains: providerSupportedChainsOfNamespace,
207
+ supportedChains,
200
208
  });
201
209
  },
202
210
  async connect(type, namespaces) {
package/src/hub/utils.ts CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  type AddEthereumChainParameter,
21
21
  convertEvmBlockchainMetaToEvmChainInfo,
22
22
  getBlockChainNameFromId,
23
+ getSupportedChainsFromProvider,
23
24
  type WalletType,
24
25
  } from '@rango-dev/wallets-shared';
25
26
  import { AccountId } from 'caip';
@@ -77,22 +78,6 @@ const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
77
78
  HUB_LAST_CONNECTED_WALLETS
78
79
  );
79
80
 
80
- export function getSupportedChainsFromProvider(
81
- provider: Provider,
82
- allBlockChains: ProviderProps['allBlockChains']
83
- ) {
84
- const namespacesProperty = provider
85
- .info()
86
- ?.metadata.properties?.find((property) => property.name === 'namespaces');
87
-
88
- const supportedChains =
89
- namespacesProperty?.value.data.flatMap((namespace) =>
90
- namespace.getSupportedChains(allBlockChains || [])
91
- ) || [];
92
-
93
- return supportedChains;
94
- }
95
-
96
81
  export function mapHubEventsToLegacy(
97
82
  hub: Hub,
98
83
  event: Event,