@cookill/wallet-adapter 0.1.0 → 2.4.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/README.md +93 -69
- package/dist/index.cjs +65 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -48
- package/dist/index.d.ts +51 -48
- package/dist/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +302 -120
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +32 -56
- package/dist/react.d.ts +32 -56
- package/dist/react.js +299 -122
- package/dist/react.js.map +1 -1
- package/dist/standard.cjs +80 -14
- package/dist/standard.cjs.map +1 -1
- package/dist/standard.d.cts +12 -4
- package/dist/standard.d.ts +12 -4
- package/dist/standard.js +80 -15
- package/dist/standard.js.map +1 -1
- package/package.json +5 -4
package/dist/react.cjs
CHANGED
|
@@ -12,28 +12,36 @@ var NETWORKS = {
|
|
|
12
12
|
name: "Rialo Mainnet",
|
|
13
13
|
rpcUrl: "https://mainnet.rialo.io:4101",
|
|
14
14
|
wsUrl: "wss://mainnet.rialo.io:4102",
|
|
15
|
-
explorerUrl: "https://explorer.rialo.io"
|
|
15
|
+
explorerUrl: "https://explorer.rialo.io",
|
|
16
|
+
symbol: "RLO",
|
|
17
|
+
decimals: 9
|
|
16
18
|
},
|
|
17
19
|
testnet: {
|
|
18
20
|
chainId: "rialo:testnet",
|
|
19
21
|
name: "Rialo Testnet",
|
|
20
22
|
rpcUrl: "https://testnet.rialo.io:4101",
|
|
21
23
|
wsUrl: "wss://testnet.rialo.io:4102",
|
|
22
|
-
explorerUrl: "https://testnet.explorer.rialo.io"
|
|
24
|
+
explorerUrl: "https://testnet.explorer.rialo.io",
|
|
25
|
+
symbol: "tRLO",
|
|
26
|
+
decimals: 9
|
|
23
27
|
},
|
|
24
28
|
devnet: {
|
|
25
29
|
chainId: "rialo:devnet",
|
|
26
30
|
name: "Rialo Devnet",
|
|
27
31
|
rpcUrl: "https://devnet.rialo.io:4101",
|
|
28
32
|
wsUrl: "wss://devnet.rialo.io:4102",
|
|
29
|
-
explorerUrl: "https://devnet.explorer.rialo.io"
|
|
33
|
+
explorerUrl: "https://devnet.explorer.rialo.io",
|
|
34
|
+
symbol: "dRLO",
|
|
35
|
+
decimals: 9
|
|
30
36
|
},
|
|
31
37
|
localnet: {
|
|
32
38
|
chainId: "rialo:localnet",
|
|
33
39
|
name: "Rialo Localnet",
|
|
34
40
|
rpcUrl: "http://localhost:4101",
|
|
35
41
|
wsUrl: "ws://localhost:4102",
|
|
36
|
-
explorerUrl: "http://localhost:3000"
|
|
42
|
+
explorerUrl: "http://localhost:3000",
|
|
43
|
+
symbol: "lRLO",
|
|
44
|
+
decimals: 9
|
|
37
45
|
}
|
|
38
46
|
};
|
|
39
47
|
function isRialoInstalled() {
|
|
@@ -45,21 +53,57 @@ function getRialoProvider() {
|
|
|
45
53
|
const rialo = window.rialo;
|
|
46
54
|
return rialo?.isRialo ? rialo : void 0;
|
|
47
55
|
}
|
|
56
|
+
function waitForRialoProvider(timeout = 3e3) {
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
if (isRialoInstalled()) {
|
|
59
|
+
resolve(getRialoProvider());
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let resolved = false;
|
|
63
|
+
const checkInterval = setInterval(() => {
|
|
64
|
+
if (isRialoInstalled() && !resolved) {
|
|
65
|
+
resolved = true;
|
|
66
|
+
clearInterval(checkInterval);
|
|
67
|
+
resolve(getRialoProvider());
|
|
68
|
+
}
|
|
69
|
+
}, 100);
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
if (!resolved) {
|
|
72
|
+
resolved = true;
|
|
73
|
+
clearInterval(checkInterval);
|
|
74
|
+
resolve(void 0);
|
|
75
|
+
}
|
|
76
|
+
}, timeout);
|
|
77
|
+
const handler = () => {
|
|
78
|
+
if (!resolved) {
|
|
79
|
+
resolved = true;
|
|
80
|
+
clearInterval(checkInterval);
|
|
81
|
+
resolve(getRialoProvider());
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
window.addEventListener("rialo#initialized", handler, { once: true });
|
|
85
|
+
});
|
|
86
|
+
}
|
|
48
87
|
function formatAddress(address, chars = 4) {
|
|
49
88
|
if (!address) return "";
|
|
50
89
|
if (address.length <= chars * 2 + 3) return address;
|
|
51
90
|
return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
|
|
52
91
|
}
|
|
53
92
|
function formatBalance(kelvins, decimals = 4) {
|
|
54
|
-
const value = typeof kelvins === "string" ? BigInt(kelvins) : kelvins;
|
|
93
|
+
const value = typeof kelvins === "string" ? BigInt(kelvins || "0") : kelvins;
|
|
55
94
|
const rlo = Number(value) / 1e9;
|
|
56
95
|
return rlo.toFixed(decimals);
|
|
57
96
|
}
|
|
97
|
+
function isValidAddress(address) {
|
|
98
|
+
if (!address || typeof address !== "string") return false;
|
|
99
|
+
if (address.length < 32 || address.length > 50) return false;
|
|
100
|
+
return /^[1-9A-HJ-NP-Za-km-z]+$/.test(address);
|
|
101
|
+
}
|
|
58
102
|
var DEFAULT_WALLETS = [
|
|
59
103
|
{
|
|
60
|
-
id: "
|
|
61
|
-
name: "
|
|
62
|
-
icon: "data:image/svg+xml;base64,
|
|
104
|
+
id: "sheep-wallet",
|
|
105
|
+
name: "Sheep Wallet",
|
|
106
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHJ4PSI4IiBmaWxsPSIjMDExQjI5Ii8+PHRleHQgeD0iNTAlIiB5PSI1NSUiIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXdlaWdodD0iYm9sZCIgZm9udC1zaXplPSIxNiIgZmlsbD0iIzZFQjlBOCI+Uzwvc2VsZj48L3N2Zz4=",
|
|
63
107
|
downloadUrl: "https://rialo.io/wallet"
|
|
64
108
|
}
|
|
65
109
|
];
|
|
@@ -71,7 +115,8 @@ function WalletProvider({
|
|
|
71
115
|
wallets: customWallets = [],
|
|
72
116
|
onConnect,
|
|
73
117
|
onDisconnect,
|
|
74
|
-
onError
|
|
118
|
+
onError,
|
|
119
|
+
onNetworkChange
|
|
75
120
|
}) {
|
|
76
121
|
const [connected, setConnected] = react.useState(false);
|
|
77
122
|
const [connecting, setConnecting] = react.useState(false);
|
|
@@ -81,79 +126,150 @@ function WalletProvider({
|
|
|
81
126
|
const [selectedWallet, setSelectedWallet] = react.useState(null);
|
|
82
127
|
const [isModalOpen, setIsModalOpen] = react.useState(false);
|
|
83
128
|
const [provider, setProvider] = react.useState();
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
installed: w.id === "rialo" ? isRialoInstalled() : false
|
|
87
|
-
}));
|
|
129
|
+
const [error, setError] = react.useState(null);
|
|
130
|
+
const chainId = react.useMemo(() => `rialo:${network}`, [network]);
|
|
88
131
|
const activeAccount = accounts[0] || null;
|
|
89
132
|
const isInstalled = isRialoInstalled();
|
|
133
|
+
const wallets = react.useMemo(() => {
|
|
134
|
+
const installed = isRialoInstalled();
|
|
135
|
+
return [...DEFAULT_WALLETS, ...customWallets].map((w) => ({
|
|
136
|
+
...w,
|
|
137
|
+
installed: w.id === "sheep-wallet" ? installed : false
|
|
138
|
+
}));
|
|
139
|
+
}, [customWallets]);
|
|
90
140
|
react.useEffect(() => {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
141
|
+
const init = async () => {
|
|
142
|
+
const p = await waitForRialoProvider(3e3);
|
|
143
|
+
setProvider(p);
|
|
144
|
+
if (p) {
|
|
145
|
+
setSelectedWallet(wallets.find((w) => w.id === "sheep-wallet") || wallets[0] || null);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
init();
|
|
149
|
+
}, [wallets]);
|
|
150
|
+
const refreshBalance = react.useCallback(async () => {
|
|
151
|
+
if (!provider || !activeAccount) return;
|
|
152
|
+
try {
|
|
153
|
+
const result = await provider.getBalance(activeAccount.address);
|
|
154
|
+
const bal = typeof result === "string" ? result : result.balance;
|
|
155
|
+
setBalance(bal);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
console.error("Balance fetch error:", e);
|
|
95
158
|
}
|
|
96
|
-
}, []);
|
|
159
|
+
}, [provider, activeAccount]);
|
|
160
|
+
react.useEffect(() => {
|
|
161
|
+
if (connected && activeAccount && provider) {
|
|
162
|
+
refreshBalance();
|
|
163
|
+
const interval = setInterval(refreshBalance, 3e4);
|
|
164
|
+
return () => clearInterval(interval);
|
|
165
|
+
}
|
|
166
|
+
}, [connected, activeAccount, provider, refreshBalance]);
|
|
97
167
|
react.useEffect(() => {
|
|
98
168
|
if (autoConnect && provider && !connected && !connecting) {
|
|
99
169
|
provider.isConnected().then((isConn) => {
|
|
100
170
|
if (isConn) {
|
|
101
171
|
handleConnect();
|
|
102
172
|
}
|
|
173
|
+
}).catch(() => {
|
|
103
174
|
});
|
|
104
175
|
}
|
|
105
|
-
}, [provider, autoConnect]);
|
|
106
|
-
react.useEffect(() => {
|
|
107
|
-
if (connected && activeAccount && provider) {
|
|
108
|
-
provider.getBalance(activeAccount.address).then(setBalance).catch(console.error);
|
|
109
|
-
}
|
|
110
|
-
}, [connected, activeAccount, provider]);
|
|
176
|
+
}, [provider, autoConnect, connected, connecting]);
|
|
111
177
|
react.useEffect(() => {
|
|
112
178
|
if (!provider) return;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
179
|
+
const cleanupFns = [];
|
|
180
|
+
cleanupFns.push(
|
|
181
|
+
provider.on("connect", (data) => {
|
|
182
|
+
console.log("[Adapter] Connect event received:", data);
|
|
183
|
+
const eventData = data;
|
|
184
|
+
if (eventData?.accounts) {
|
|
185
|
+
const normalized = eventData.accounts.map((a) => {
|
|
186
|
+
if (typeof a === "string") return { address: a, publicKey: a };
|
|
187
|
+
return { address: a.address, publicKey: a.publicKey || a.address };
|
|
188
|
+
});
|
|
189
|
+
setAccounts(normalized);
|
|
190
|
+
setConnected(true);
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
);
|
|
194
|
+
cleanupFns.push(
|
|
195
|
+
provider.on("disconnect", () => {
|
|
196
|
+
setConnected(false);
|
|
197
|
+
setAccounts([]);
|
|
198
|
+
setBalance(null);
|
|
199
|
+
onDisconnect?.();
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
cleanupFns.push(
|
|
203
|
+
provider.on("accountsChanged", (data) => {
|
|
204
|
+
console.log("[Adapter] Accounts changed:", data);
|
|
205
|
+
const rawAccounts = data;
|
|
206
|
+
const normalized = (rawAccounts || []).map((a) => {
|
|
207
|
+
if (typeof a === "string") return { address: a, publicKey: a };
|
|
208
|
+
return { address: a.address, publicKey: a.publicKey || a.address };
|
|
209
|
+
});
|
|
210
|
+
setAccounts(normalized);
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
cleanupFns.push(
|
|
214
|
+
provider.on("networkChanged", (data) => {
|
|
215
|
+
const { network: net } = data;
|
|
216
|
+
if (net) {
|
|
217
|
+
setNetwork(net);
|
|
218
|
+
onNetworkChange?.(net);
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
);
|
|
126
222
|
return () => {
|
|
127
|
-
|
|
128
|
-
unsubDisconnect();
|
|
129
|
-
unsubAccountChange();
|
|
223
|
+
cleanupFns.forEach((fn) => fn?.());
|
|
130
224
|
};
|
|
131
|
-
}, [provider, onDisconnect]);
|
|
225
|
+
}, [provider, onDisconnect, onNetworkChange]);
|
|
132
226
|
const handleConnect = react.useCallback(async () => {
|
|
133
227
|
if (!provider) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
228
|
+
const err = new Error("Rialo Wallet not installed");
|
|
229
|
+
setError(err);
|
|
230
|
+
onError?.(err);
|
|
231
|
+
throw err;
|
|
137
232
|
}
|
|
138
233
|
setConnecting(true);
|
|
234
|
+
setError(null);
|
|
139
235
|
try {
|
|
140
|
-
|
|
141
|
-
const
|
|
236
|
+
console.log("[Adapter] Calling provider.connect()...");
|
|
237
|
+
const result = await provider.connect();
|
|
238
|
+
console.log("[Adapter] Connect result:", result);
|
|
239
|
+
const walletAccounts = result.map((acc) => {
|
|
240
|
+
if (typeof acc === "string") {
|
|
241
|
+
return { address: acc, publicKey: acc };
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
address: acc.address,
|
|
245
|
+
publicKey: acc.publicKey || acc.address
|
|
246
|
+
};
|
|
247
|
+
});
|
|
142
248
|
setAccounts(walletAccounts);
|
|
143
249
|
setConnected(true);
|
|
144
250
|
setIsModalOpen(false);
|
|
251
|
+
try {
|
|
252
|
+
const net = await provider.getNetwork();
|
|
253
|
+
setNetwork(net);
|
|
254
|
+
} catch {
|
|
255
|
+
}
|
|
145
256
|
onConnect?.(walletAccounts);
|
|
146
257
|
return walletAccounts;
|
|
147
|
-
} catch (
|
|
148
|
-
|
|
149
|
-
|
|
258
|
+
} catch (e) {
|
|
259
|
+
const err = e;
|
|
260
|
+
setError(err);
|
|
261
|
+
onError?.(err);
|
|
262
|
+
throw err;
|
|
150
263
|
} finally {
|
|
151
264
|
setConnecting(false);
|
|
152
265
|
}
|
|
153
266
|
}, [provider, onConnect, onError]);
|
|
154
267
|
const handleDisconnect = react.useCallback(async () => {
|
|
155
|
-
|
|
156
|
-
|
|
268
|
+
try {
|
|
269
|
+
if (provider) {
|
|
270
|
+
await provider.disconnect();
|
|
271
|
+
}
|
|
272
|
+
} catch {
|
|
157
273
|
}
|
|
158
274
|
setConnected(false);
|
|
159
275
|
setAccounts([]);
|
|
@@ -176,7 +292,8 @@ function WalletProvider({
|
|
|
176
292
|
await provider.switchNetwork(newNetwork);
|
|
177
293
|
}
|
|
178
294
|
setNetwork(newNetwork);
|
|
179
|
-
|
|
295
|
+
onNetworkChange?.(newNetwork);
|
|
296
|
+
}, [provider, onNetworkChange]);
|
|
180
297
|
const handleSignMessage = react.useCallback(async (message) => {
|
|
181
298
|
if (!provider || !connected) {
|
|
182
299
|
throw new Error("Wallet not connected");
|
|
@@ -210,7 +327,9 @@ function WalletProvider({
|
|
|
210
327
|
accounts,
|
|
211
328
|
activeAccount,
|
|
212
329
|
network,
|
|
330
|
+
chainId,
|
|
213
331
|
balance,
|
|
332
|
+
error,
|
|
214
333
|
wallets,
|
|
215
334
|
selectedWallet,
|
|
216
335
|
isInstalled,
|
|
@@ -218,6 +337,7 @@ function WalletProvider({
|
|
|
218
337
|
disconnect: handleDisconnect,
|
|
219
338
|
selectWallet,
|
|
220
339
|
switchNetwork: handleSwitchNetwork,
|
|
340
|
+
refreshBalance,
|
|
221
341
|
signMessage: handleSignMessage,
|
|
222
342
|
signTransaction: handleSignTransaction,
|
|
223
343
|
sendTransaction: handleSendTransaction,
|
|
@@ -248,33 +368,58 @@ function useAccounts() {
|
|
|
248
368
|
return accounts;
|
|
249
369
|
}
|
|
250
370
|
function useBalance() {
|
|
251
|
-
const { balance } = useWallet();
|
|
371
|
+
const { balance, refreshBalance } = useWallet();
|
|
252
372
|
return {
|
|
253
373
|
balance,
|
|
254
|
-
formatted: balance ? formatBalance(balance) : "0.0000"
|
|
374
|
+
formatted: balance ? formatBalance(balance) : "0.0000",
|
|
375
|
+
refresh: refreshBalance
|
|
255
376
|
};
|
|
256
377
|
}
|
|
257
378
|
function useNetwork() {
|
|
258
|
-
const { network } = useWallet();
|
|
379
|
+
const { network, chainId } = useWallet();
|
|
259
380
|
return {
|
|
260
381
|
network,
|
|
382
|
+
chainId,
|
|
261
383
|
config: NETWORKS[network]
|
|
262
384
|
};
|
|
263
385
|
}
|
|
386
|
+
function useChainId() {
|
|
387
|
+
const { chainId } = useWallet();
|
|
388
|
+
return chainId;
|
|
389
|
+
}
|
|
390
|
+
function useSwitchNetwork() {
|
|
391
|
+
const { switchNetwork, network } = useWallet();
|
|
392
|
+
const [switching, setSwitching] = react.useState(false);
|
|
393
|
+
const [error, setError] = react.useState(null);
|
|
394
|
+
const doSwitch = react.useCallback(async (newNetwork) => {
|
|
395
|
+
setSwitching(true);
|
|
396
|
+
setError(null);
|
|
397
|
+
try {
|
|
398
|
+
await switchNetwork(newNetwork);
|
|
399
|
+
} catch (e) {
|
|
400
|
+
setError(e);
|
|
401
|
+
throw e;
|
|
402
|
+
} finally {
|
|
403
|
+
setSwitching(false);
|
|
404
|
+
}
|
|
405
|
+
}, [switchNetwork]);
|
|
406
|
+
return { switchNetwork: doSwitch, switching, error, currentNetwork: network };
|
|
407
|
+
}
|
|
264
408
|
function useConnectWallet() {
|
|
265
|
-
const { connect, connecting, openModal, isInstalled } = useWallet();
|
|
409
|
+
const { connect, connecting, openModal, isInstalled, error } = useWallet();
|
|
266
410
|
return {
|
|
267
411
|
connect: isInstalled ? connect : openModal,
|
|
268
412
|
connecting,
|
|
269
|
-
isInstalled
|
|
413
|
+
isInstalled,
|
|
414
|
+
error
|
|
270
415
|
};
|
|
271
416
|
}
|
|
272
417
|
function useDisconnectWallet() {
|
|
273
|
-
const { disconnect } = useWallet();
|
|
274
|
-
return { disconnect };
|
|
418
|
+
const { disconnect, connected } = useWallet();
|
|
419
|
+
return { disconnect, connected };
|
|
275
420
|
}
|
|
276
421
|
function useSignMessage() {
|
|
277
|
-
const { signMessage, connected } = useWallet();
|
|
422
|
+
const { signMessage, connected, activeAccount } = useWallet();
|
|
278
423
|
const [signing, setSigning] = react.useState(false);
|
|
279
424
|
const [signature, setSignature] = react.useState(null);
|
|
280
425
|
const [error, setError] = react.useState(null);
|
|
@@ -296,7 +441,7 @@ function useSignMessage() {
|
|
|
296
441
|
setSigning(false);
|
|
297
442
|
}
|
|
298
443
|
}, [signMessage, connected]);
|
|
299
|
-
return { sign, signing, signature, error };
|
|
444
|
+
return { sign, signing, signature, error, address: activeAccount?.address };
|
|
300
445
|
}
|
|
301
446
|
function useSendTransaction() {
|
|
302
447
|
const { signAndSendTransaction, connected } = useWallet();
|
|
@@ -321,32 +466,84 @@ function useSendTransaction() {
|
|
|
321
466
|
setSending(false);
|
|
322
467
|
}
|
|
323
468
|
}, [signAndSendTransaction, connected]);
|
|
324
|
-
return { send, sending, txHash, error
|
|
469
|
+
return { send, sending, txHash, error, reset: () => {
|
|
470
|
+
setTxHash(null);
|
|
471
|
+
setError(null);
|
|
472
|
+
} };
|
|
473
|
+
}
|
|
474
|
+
function useSignTransaction() {
|
|
475
|
+
const { signTransaction, connected } = useWallet();
|
|
476
|
+
const [signing, setSigning] = react.useState(false);
|
|
477
|
+
const [signature, setSignature] = react.useState(null);
|
|
478
|
+
const [error, setError] = react.useState(null);
|
|
479
|
+
const sign = react.useCallback(async (tx) => {
|
|
480
|
+
if (!connected) {
|
|
481
|
+
setError(new Error("Wallet not connected"));
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
setSigning(true);
|
|
485
|
+
setError(null);
|
|
486
|
+
try {
|
|
487
|
+
const result = await signTransaction(tx);
|
|
488
|
+
setSignature(result);
|
|
489
|
+
return result;
|
|
490
|
+
} catch (err) {
|
|
491
|
+
setError(err);
|
|
492
|
+
return null;
|
|
493
|
+
} finally {
|
|
494
|
+
setSigning(false);
|
|
495
|
+
}
|
|
496
|
+
}, [signTransaction, connected]);
|
|
497
|
+
return { sign, signing, signature, error };
|
|
325
498
|
}
|
|
326
499
|
function ConnectButton({
|
|
327
500
|
connectLabel = "Connect Wallet",
|
|
501
|
+
disconnectLabel = "Disconnect",
|
|
328
502
|
showAddress = true,
|
|
503
|
+
showBalance = false,
|
|
329
504
|
className = "",
|
|
330
505
|
style
|
|
331
506
|
}) {
|
|
332
|
-
const { connected, connecting, activeAccount, openModal, disconnect } = useWallet();
|
|
333
|
-
|
|
507
|
+
const { connected, connecting, activeAccount, balance, openModal, disconnect } = useWallet();
|
|
508
|
+
const buttonStyle = {
|
|
509
|
+
padding: "10px 20px",
|
|
510
|
+
borderRadius: "8px",
|
|
511
|
+
border: "none",
|
|
512
|
+
cursor: "pointer",
|
|
513
|
+
fontWeight: 500,
|
|
514
|
+
fontSize: "14px",
|
|
515
|
+
transition: "all 0.2s ease",
|
|
516
|
+
...style
|
|
517
|
+
};
|
|
518
|
+
if (connecting) {
|
|
334
519
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
335
520
|
"button",
|
|
336
521
|
{
|
|
337
|
-
|
|
522
|
+
disabled: true,
|
|
523
|
+
className,
|
|
524
|
+
style: { ...buttonStyle, opacity: 0.7, cursor: "not-allowed" },
|
|
525
|
+
children: "Connecting..."
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
if (connected && activeAccount) {
|
|
530
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
531
|
+
"button",
|
|
532
|
+
{
|
|
533
|
+
onClick: () => disconnect(),
|
|
338
534
|
className,
|
|
339
535
|
style: {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
backgroundColor: "#1a1a2e",
|
|
344
|
-
color: "#6eb9a8",
|
|
345
|
-
cursor: "pointer",
|
|
346
|
-
fontWeight: 500,
|
|
347
|
-
...style
|
|
536
|
+
...buttonStyle,
|
|
537
|
+
background: "linear-gradient(135deg, #6EB9A8 0%, #4A9A8A 100%)",
|
|
538
|
+
color: "white"
|
|
348
539
|
},
|
|
349
|
-
children:
|
|
540
|
+
children: [
|
|
541
|
+
showBalance && balance && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { marginRight: 8 }, children: [
|
|
542
|
+
formatBalance(balance),
|
|
543
|
+
" RLO"
|
|
544
|
+
] }),
|
|
545
|
+
showAddress ? formatAddress(activeAccount.address) : disconnectLabel
|
|
546
|
+
]
|
|
350
547
|
}
|
|
351
548
|
);
|
|
352
549
|
}
|
|
@@ -354,27 +551,17 @@ function ConnectButton({
|
|
|
354
551
|
"button",
|
|
355
552
|
{
|
|
356
553
|
onClick: openModal,
|
|
357
|
-
disabled: connecting,
|
|
358
554
|
className,
|
|
359
555
|
style: {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
backgroundColor: "#6eb9a8",
|
|
364
|
-
color: "#0f0f1a",
|
|
365
|
-
cursor: connecting ? "not-allowed" : "pointer",
|
|
366
|
-
fontWeight: 600,
|
|
367
|
-
opacity: connecting ? 0.7 : 1,
|
|
368
|
-
...style
|
|
556
|
+
...buttonStyle,
|
|
557
|
+
background: "linear-gradient(135deg, #6EB9A8 0%, #4A9A8A 100%)",
|
|
558
|
+
color: "white"
|
|
369
559
|
},
|
|
370
|
-
children:
|
|
560
|
+
children: connectLabel
|
|
371
561
|
}
|
|
372
562
|
);
|
|
373
563
|
}
|
|
374
|
-
function WalletModal({
|
|
375
|
-
title = "Connect Wallet",
|
|
376
|
-
className = ""
|
|
377
|
-
}) {
|
|
564
|
+
function WalletModal({ title = "Connect Wallet", className = "" }) {
|
|
378
565
|
const { isModalOpen, closeModal, wallets, selectWallet, connecting } = useWallet();
|
|
379
566
|
if (!isModalOpen) return null;
|
|
380
567
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -388,34 +575,30 @@ function WalletModal({
|
|
|
388
575
|
display: "flex",
|
|
389
576
|
alignItems: "center",
|
|
390
577
|
justifyContent: "center",
|
|
391
|
-
backgroundColor: "rgba(0, 0, 0, 0.
|
|
578
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
392
579
|
},
|
|
393
580
|
onClick: closeModal,
|
|
394
581
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
395
582
|
"div",
|
|
396
583
|
{
|
|
397
584
|
style: {
|
|
398
|
-
|
|
585
|
+
background: "white",
|
|
399
586
|
borderRadius: "16px",
|
|
400
587
|
padding: "24px",
|
|
401
|
-
|
|
402
|
-
|
|
588
|
+
maxWidth: "400px",
|
|
589
|
+
width: "90%",
|
|
590
|
+
maxHeight: "80vh",
|
|
591
|
+
overflow: "auto"
|
|
403
592
|
},
|
|
404
593
|
onClick: (e) => e.stopPropagation(),
|
|
405
594
|
children: [
|
|
406
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "20px" }, children: [
|
|
407
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: 0,
|
|
595
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: 0, fontSize: "18px", fontWeight: 600 }, children: title }),
|
|
408
597
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
409
598
|
"button",
|
|
410
599
|
{
|
|
411
600
|
onClick: closeModal,
|
|
412
|
-
style: {
|
|
413
|
-
background: "none",
|
|
414
|
-
border: "none",
|
|
415
|
-
color: "#888",
|
|
416
|
-
cursor: "pointer",
|
|
417
|
-
fontSize: "20px"
|
|
418
|
-
},
|
|
601
|
+
style: { background: "none", border: "none", fontSize: "24px", cursor: "pointer", padding: 0 },
|
|
419
602
|
children: "\xD7"
|
|
420
603
|
}
|
|
421
604
|
)
|
|
@@ -431,30 +614,24 @@ function WalletModal({
|
|
|
431
614
|
gap: "12px",
|
|
432
615
|
padding: "16px",
|
|
433
616
|
borderRadius: "12px",
|
|
434
|
-
border: "1px solid #
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
transition: "all 0.2s"
|
|
617
|
+
border: "1px solid #e5e5e5",
|
|
618
|
+
background: "white",
|
|
619
|
+
cursor: connecting ? "not-allowed" : "pointer",
|
|
620
|
+
opacity: connecting ? 0.7 : 1,
|
|
621
|
+
transition: "all 0.2s ease"
|
|
439
622
|
},
|
|
440
623
|
children: [
|
|
441
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
442
|
-
|
|
443
|
-
{
|
|
444
|
-
|
|
445
|
-
alt: wallet.name,
|
|
446
|
-
style: { width: "32px", height: "32px", borderRadius: "8px" }
|
|
447
|
-
}
|
|
448
|
-
),
|
|
449
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, textAlign: "left" }, children: [
|
|
450
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 600 }, children: wallet.name }),
|
|
451
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "#888" }, children: wallet.installed ? "Detected" : "Not installed" })
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: wallet.icon, alt: wallet.name, style: { width: 40, height: 40, borderRadius: 8 } }),
|
|
625
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "left", flex: 1 }, children: [
|
|
626
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 500 }, children: wallet.name }),
|
|
627
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "#666" }, children: wallet.installed ? "Detected" : "Not installed" })
|
|
452
628
|
] }),
|
|
453
|
-
!wallet.installed && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "12px", color: "#
|
|
629
|
+
!wallet.installed && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "12px", color: "#6EB9A8" }, children: "Install \u2192" })
|
|
454
630
|
]
|
|
455
631
|
},
|
|
456
632
|
wallet.id
|
|
457
|
-
)) })
|
|
633
|
+
)) }),
|
|
634
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "20px", textAlign: "center", fontSize: "12px", color: "#999" }, children: "Powered by CookilLabs" })
|
|
458
635
|
]
|
|
459
636
|
}
|
|
460
637
|
)
|
|
@@ -468,16 +645,21 @@ exports.WalletModal = WalletModal;
|
|
|
468
645
|
exports.WalletProvider = WalletProvider;
|
|
469
646
|
exports.formatAddress = formatAddress;
|
|
470
647
|
exports.formatBalance = formatBalance;
|
|
648
|
+
exports.getRialoProvider = getRialoProvider;
|
|
471
649
|
exports.isRialoInstalled = isRialoInstalled;
|
|
650
|
+
exports.isValidAddress = isValidAddress;
|
|
472
651
|
exports.useAccounts = useAccounts;
|
|
473
652
|
exports.useActiveAccount = useActiveAccount;
|
|
474
653
|
exports.useBalance = useBalance;
|
|
654
|
+
exports.useChainId = useChainId;
|
|
475
655
|
exports.useConnectWallet = useConnectWallet;
|
|
476
656
|
exports.useDisconnectWallet = useDisconnectWallet;
|
|
477
657
|
exports.useIsConnected = useIsConnected;
|
|
478
658
|
exports.useNetwork = useNetwork;
|
|
479
659
|
exports.useSendTransaction = useSendTransaction;
|
|
480
660
|
exports.useSignMessage = useSignMessage;
|
|
661
|
+
exports.useSignTransaction = useSignTransaction;
|
|
662
|
+
exports.useSwitchNetwork = useSwitchNetwork;
|
|
481
663
|
exports.useWallet = useWallet;
|
|
482
664
|
//# sourceMappingURL=react.cjs.map
|
|
483
665
|
//# sourceMappingURL=react.cjs.map
|