@rango-dev/wallets-react 0.48.0 → 0.48.1-next.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/CHANGELOG.md +9 -0
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/hub/useHubAdapter.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
- package/src/hub/useHubAdapter.ts +12 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/wallets-react",
|
|
3
|
-
"version": "0.48.0",
|
|
3
|
+
"version": "0.48.1-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@hub3js/tvm": "^0.2.3",
|
|
45
45
|
"@rango-dev/logging-core": "^0.14.0",
|
|
46
46
|
"@rango-dev/wallets-core": "^0.61.0",
|
|
47
|
-
"@rango-dev/wallets-shared": "^0.62.0",
|
|
47
|
+
"@rango-dev/wallets-shared": "^0.62.1-next.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
|
@@ -50,6 +50,7 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
50
50
|
allVersionedProviders: params.allVersionedProviders,
|
|
51
51
|
allBlockChains: params.allBlockChains,
|
|
52
52
|
});
|
|
53
|
+
const hubInitiated = useRef(false);
|
|
53
54
|
|
|
54
55
|
/*
|
|
55
56
|
* Params of each connection attempt for each wallet type are stored here.
|
|
@@ -82,38 +83,7 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
82
83
|
};
|
|
83
84
|
}, [params]);
|
|
84
85
|
|
|
85
|
-
// Initialize instances
|
|
86
86
|
useEffect(() => {
|
|
87
|
-
const runOnInit = () => {
|
|
88
|
-
getHub().init(params.configs?.walletOptions);
|
|
89
|
-
|
|
90
|
-
rerender((currentRender) => currentRender + 1);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Then will call init whenever page is ready.
|
|
94
|
-
const initHubWhenPageIsReady = (event: Event) => {
|
|
95
|
-
// Then will call init whenever page is ready.
|
|
96
|
-
if (
|
|
97
|
-
event.target &&
|
|
98
|
-
(event.target as Document).readyState === 'complete'
|
|
99
|
-
) {
|
|
100
|
-
runOnInit();
|
|
101
|
-
document.removeEventListener(
|
|
102
|
-
'readystatechange',
|
|
103
|
-
initHubWhenPageIsReady
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Try to run, maybe it's ready.
|
|
109
|
-
runOnInit();
|
|
110
|
-
|
|
111
|
-
/*
|
|
112
|
-
* Try again when the page has been completely loaded.
|
|
113
|
-
* Some of wallets, take some time to be fully injected and loaded.
|
|
114
|
-
*/
|
|
115
|
-
document.addEventListener('readystatechange', initHubWhenPageIsReady);
|
|
116
|
-
|
|
117
87
|
getStore()
|
|
118
88
|
.subscribe((event) => {
|
|
119
89
|
if (dataRef.current.onUpdateState) {
|
|
@@ -136,6 +106,17 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
136
106
|
.flushEvents();
|
|
137
107
|
}, []);
|
|
138
108
|
|
|
109
|
+
// Initialize hub only after blockchain meta is available (e.g. WalletConnect needs it at init).
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (hubInitiated.current || !params.allBlockChains?.length) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getHub().init(params.configs?.walletOptions);
|
|
116
|
+
rerender((currentRender) => currentRender + 1);
|
|
117
|
+
hubInitiated.current = true;
|
|
118
|
+
}, [params.allBlockChains, params.configs?.walletOptions]);
|
|
119
|
+
|
|
139
120
|
useAutoConnect({
|
|
140
121
|
autoConnect: params.autoConnect,
|
|
141
122
|
allBlockChains: params.allBlockChains,
|