@rango-dev/wallets-react 0.47.1-next.4 → 0.48.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.
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/index.js.map +3 -3
- package/dist/hub/useHubAdapter.d.ts.map +1 -1
- package/dist/hub/utils.d.ts +0 -1
- package/dist/hub/utils.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +11 -11
- package/src/hub/useHubAdapter.ts +17 -9
- package/src/hub/utils.ts +1 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/wallets-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
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.
|
|
39
|
-
"@hub3js/evm": "^0.3.
|
|
40
|
-
"@hub3js/namespaces": "^0.2.
|
|
41
|
-
"@hub3js/solana": "^0.3.
|
|
42
|
-
"@hub3js/std": "^0.2.
|
|
43
|
-
"@hub3js/sui": "^0.2.
|
|
44
|
-
"@hub3js/tvm": "^0.2.
|
|
45
|
-
"@rango-dev/logging-core": "^0.
|
|
46
|
-
"@rango-dev/wallets-core": "^0.
|
|
47
|
-
"@rango-dev/wallets-shared": "^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
|
+
"@rango-dev/logging-core": "^0.14.0",
|
|
46
|
+
"@rango-dev/wallets-core": "^0.61.0",
|
|
47
|
+
"@rango-dev/wallets-shared": "^0.62.0",
|
|
48
48
|
"caip": "^1.1.1",
|
|
49
49
|
"rango-types": "^0.5.0",
|
|
50
50
|
"ts-results": "^3.3.0"
|
package/src/hub/useHubAdapter.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
|
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,
|