@cookill/wallet-adapter 3.1.0 → 3.1.2
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 +146 -289
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/react.cjs +1378 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +131 -1
- package/dist/react.d.ts +131 -1
- package/dist/react.js +1354 -1
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
# @cookill/wallet-adapter
|
|
1
|
+
# @cookill/wallet-adapter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Wallet adapter for **Sheep Wallet** — the browser extension wallet for the Rialo blockchain.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **REX (Rialo Extended Execution)**: Submit confidential transactions using TEE/MPC/FHE
|
|
8
|
-
- **SfS (Stake-for-Service)**: Gasless transactions — pay fees from staking yield
|
|
9
|
-
- **Scan-to-Connect**: Bidirectional QR code pairing across devices
|
|
10
|
-
- **Anti-freeze architecture**: All provider calls wrapped with timeouts
|
|
11
|
-
- **Silent auto-connect**: Uses `checkSession()` for session restoration
|
|
5
|
+
Provides a drop-in React provider, responsive connect modal, and vanilla JS class so dApp developers can integrate Sheep Wallet without writing custom UI.
|
|
12
6
|
|
|
13
7
|
## Installation
|
|
14
8
|
|
|
15
9
|
```bash
|
|
16
10
|
npm install @cookill/wallet-adapter
|
|
17
|
-
# or
|
|
18
|
-
pnpm add @cookill/wallet-adapter
|
|
19
11
|
```
|
|
20
12
|
|
|
21
13
|
## Quick Start (React)
|
|
22
14
|
|
|
23
15
|
```tsx
|
|
24
|
-
import { WalletProvider, ConnectButton
|
|
16
|
+
import { WalletProvider, ConnectButton } from '@cookill/wallet-adapter/react';
|
|
25
17
|
|
|
26
18
|
function App() {
|
|
27
19
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</WalletProvider>
|
|
33
|
-
</WalletErrorBoundary>
|
|
20
|
+
<WalletProvider network="devnet" autoConnect>
|
|
21
|
+
<ConnectButton />
|
|
22
|
+
<YourDApp />
|
|
23
|
+
</WalletProvider>
|
|
34
24
|
);
|
|
35
25
|
}
|
|
36
26
|
```
|
|
37
27
|
|
|
28
|
+
`WalletProvider` renders a built-in connect modal automatically. On desktop the modal opens centered; on mobile it slides up from the bottom as a sheet. No custom modal code needed.
|
|
29
|
+
|
|
38
30
|
## React Hooks
|
|
39
31
|
|
|
40
32
|
### useWallet
|
|
@@ -44,143 +36,64 @@ import { useWallet } from '@cookill/wallet-adapter/react';
|
|
|
44
36
|
|
|
45
37
|
function MyComponent() {
|
|
46
38
|
const {
|
|
47
|
-
connected,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
|
|
39
|
+
connected, // boolean — is wallet connected
|
|
40
|
+
connecting, // boolean — connection in progress
|
|
41
|
+
activeAccount, // WalletAccount | null — first connected account
|
|
42
|
+
chainId, // string — e.g. "rialo:devnet"
|
|
43
|
+
isInstalled, // boolean — extension detected in browser
|
|
44
|
+
|
|
45
|
+
// Actions
|
|
46
|
+
connect, // () => Promise<WalletAccount[]>
|
|
47
|
+
disconnect, // () => Promise<void>
|
|
48
|
+
switchNetwork, // (network) => Promise<void>
|
|
49
|
+
refreshBalance, // () => Promise<void>
|
|
50
|
+
|
|
51
|
+
// Signing & Transactions
|
|
52
|
+
signMessage, // (msg: string) => Promise<SignedMessage>
|
|
53
|
+
signTransaction, // (tx) => Promise<string>
|
|
54
|
+
sendTransaction, // (tx) => Promise<TransactionResult>
|
|
55
|
+
signAndSendTransaction, // (tx) => Promise<TransactionResult>
|
|
56
|
+
|
|
57
|
+
// Modal control
|
|
58
|
+
openModal, // () => void — open the connect modal
|
|
59
|
+
closeModal, // () => void — close it
|
|
56
60
|
} = useWallet();
|
|
57
61
|
}
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
###
|
|
64
|
+
### Focused Hooks
|
|
61
65
|
|
|
62
66
|
```tsx
|
|
63
|
-
// Connection
|
|
64
67
|
const { connect, connecting, isInstalled, error } = useConnectWallet();
|
|
65
68
|
const { disconnect, connected } = useDisconnectWallet();
|
|
66
69
|
const connected = useIsConnected();
|
|
67
|
-
|
|
68
|
-
// Account & Balance
|
|
69
70
|
const account = useActiveAccount();
|
|
70
71
|
const accounts = useAccounts();
|
|
71
72
|
const { balance, refresh } = useBalance();
|
|
72
|
-
|
|
73
|
-
// Network
|
|
74
73
|
const { network, chainId } = useNetwork();
|
|
75
|
-
const { switchNetwork
|
|
76
|
-
|
|
77
|
-
// Transactions (now includes gasless)
|
|
78
|
-
const { sendTransaction, signAndSendTransaction, sendGaslessTransaction } = useSendTransaction();
|
|
74
|
+
const { switchNetwork } = useSwitchNetwork();
|
|
75
|
+
const { sendTransaction, signAndSendTransaction } = useSendTransaction();
|
|
79
76
|
const { signMessage } = useSignMessage();
|
|
80
77
|
```
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```tsx
|
|
85
|
-
import { useREX } from '@cookill/wallet-adapter/react';
|
|
86
|
-
|
|
87
|
-
function ConfidentialTransfer() {
|
|
88
|
-
const { capabilities, supported, submitREXTransaction } = useREX();
|
|
89
|
-
|
|
90
|
-
const handleConfidentialSend = async () => {
|
|
91
|
-
const result = await submitREXTransaction({
|
|
92
|
-
to: 'RecipientAddress...',
|
|
93
|
-
value: '1000000000',
|
|
94
|
-
rex: {
|
|
95
|
-
confidential: true,
|
|
96
|
-
privacyMode: 'auto', // 'tee' | 'mpc' | 'fhe' | 'auto'
|
|
97
|
-
keepEncrypted: false, // true = output stays encrypted
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
console.log('TX hash:', result.hash);
|
|
102
|
-
console.log('Attestation:', result.attestation);
|
|
103
|
-
};
|
|
79
|
+
## Connect Modal
|
|
104
80
|
|
|
105
|
-
|
|
106
|
-
<div>
|
|
107
|
-
<p>REX supported: {supported ? 'Yes' : 'No'}</p>
|
|
108
|
-
{supported && (
|
|
109
|
-
<div>
|
|
110
|
-
<p>Privacy modes: {capabilities?.privacyModes.join(', ')}</p>
|
|
111
|
-
<button onClick={handleConfidentialSend}>
|
|
112
|
-
Send Confidential Transaction
|
|
113
|
-
</button>
|
|
114
|
-
</div>
|
|
115
|
-
)}
|
|
116
|
-
</div>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
```
|
|
81
|
+
The modal is rendered automatically by `WalletProvider`. It has two tabs:
|
|
120
82
|
|
|
121
|
-
|
|
83
|
+
1. **Extension** — Detects the installed Sheep Wallet extension and connects directly. If the extension is not installed, a download link is shown.
|
|
84
|
+
2. **Scan to Connect** — Generates a QR code that a mobile Sheep Wallet can scan to pair cross-device. Also supports the reverse flow (wallet shows QR, dApp scans).
|
|
122
85
|
|
|
123
|
-
|
|
124
|
-
import { useSfS } from '@cookill/wallet-adapter/react';
|
|
125
|
-
|
|
126
|
-
function GaslessDemo() {
|
|
127
|
-
const { positions, credits, hasCredits, createPosition, sendGasless, refresh } = useSfS();
|
|
128
|
-
|
|
129
|
-
// Create an SfS position to generate service credits
|
|
130
|
-
const handleStake = async () => {
|
|
131
|
-
await createPosition({
|
|
132
|
-
amount: '10000000000', // 10 RLO in kelvins
|
|
133
|
-
validator: 'ValidatorAddr...',
|
|
134
|
-
routingFraction: 0.5, // Route 50% of yield to service credits
|
|
135
|
-
});
|
|
136
|
-
await refresh();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// Send a gasless transaction (paid from SfS credits)
|
|
140
|
-
const handleGaslessSend = async () => {
|
|
141
|
-
const result = await sendGasless({
|
|
142
|
-
to: 'RecipientAddress...',
|
|
143
|
-
value: '1000000000', // 1 RLO
|
|
144
|
-
});
|
|
145
|
-
console.log('Gasless TX:', result.hash);
|
|
146
|
-
};
|
|
86
|
+
On mobile viewports the modal slides up from the bottom as a sheet and can be dismissed by swiping down. On desktop it opens as a centered dialog.
|
|
147
87
|
|
|
148
|
-
|
|
149
|
-
<div>
|
|
150
|
-
<p>SfS Positions: {positions.length}</p>
|
|
151
|
-
<p>Available Credits: {credits?.available || '0'}</p>
|
|
152
|
-
<p>Credits/Epoch: {credits?.estimatedPerEpoch || '0'}</p>
|
|
153
|
-
|
|
154
|
-
{!hasCredits ? (
|
|
155
|
-
<button onClick={handleStake}>Stake for Gasless TX</button>
|
|
156
|
-
) : (
|
|
157
|
-
<button onClick={handleGaslessSend}>Send (Gasless)</button>
|
|
158
|
-
)}
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
```
|
|
88
|
+
When the user clicks **Connect** and the extension is installed, the extension popup opens automatically — no manual action required.
|
|
163
89
|
|
|
164
|
-
###
|
|
90
|
+
### Controlling the Modal
|
|
165
91
|
|
|
166
92
|
```tsx
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
function ScanConnectDemo() {
|
|
170
|
-
const { scanURI, status, generateQR, approveSession, rejectSession } = useScanConnect();
|
|
93
|
+
const { openModal, closeModal } = useWallet();
|
|
171
94
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
<button onClick={generateQR}>Generate QR</button>
|
|
175
|
-
{scanURI && (
|
|
176
|
-
<div>
|
|
177
|
-
<p>Scan this URI: {scanURI.uri}</p>
|
|
178
|
-
<p>Status: {status}</p>
|
|
179
|
-
</div>
|
|
180
|
-
)}
|
|
181
|
-
</div>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
95
|
+
// Or use the built-in button
|
|
96
|
+
<ConnectButton />
|
|
184
97
|
```
|
|
185
98
|
|
|
186
99
|
## Vanilla JavaScript
|
|
@@ -190,213 +103,157 @@ import { SheepWallet, isInstalled, formatBalance } from '@cookill/wallet-adapter
|
|
|
190
103
|
|
|
191
104
|
const wallet = new SheepWallet();
|
|
192
105
|
|
|
193
|
-
|
|
106
|
+
if (!wallet.isInstalled) {
|
|
107
|
+
console.log('Extension not found');
|
|
108
|
+
}
|
|
109
|
+
|
|
194
110
|
const accounts = await wallet.connect();
|
|
111
|
+
console.log('Address:', accounts[0].address);
|
|
195
112
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
to: 'RecipientAddress...',
|
|
199
|
-
value: '1000000000',
|
|
200
|
-
rex: { confidential: true, privacyMode: 'auto' },
|
|
201
|
-
});
|
|
113
|
+
const balance = await wallet.getBalance();
|
|
114
|
+
console.log('Balance:', formatBalance(balance));
|
|
202
115
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
validator: 'ValidatorAddr...',
|
|
207
|
-
routingFraction: 0.5,
|
|
116
|
+
await wallet.signAndSendTransaction({
|
|
117
|
+
to: 'RecipientAddress',
|
|
118
|
+
value: '1000000000', // 1 RLO in kelvins
|
|
208
119
|
});
|
|
209
120
|
|
|
210
|
-
|
|
211
|
-
const result = await wallet.sendGaslessTransaction({
|
|
212
|
-
to: 'RecipientAddress...',
|
|
213
|
-
value: '1000000000',
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Scan-to-Connect — Generate session QR
|
|
217
|
-
const session = await wallet.createScanSession();
|
|
218
|
-
console.log('QR URI:', session.uri);
|
|
121
|
+
await wallet.disconnect();
|
|
219
122
|
```
|
|
220
123
|
|
|
221
|
-
##
|
|
222
|
-
|
|
223
|
-
### ConnectButton
|
|
124
|
+
## ConnectButton
|
|
224
125
|
|
|
225
126
|
```tsx
|
|
226
127
|
<ConnectButton
|
|
227
|
-
connectLabel="Connect Wallet"
|
|
228
|
-
disconnectLabel="Disconnect"
|
|
229
|
-
showAddress={true}
|
|
230
|
-
showBalance={false}
|
|
231
|
-
showFeatures={true} // Show REX/SfS badges
|
|
128
|
+
connectLabel="Connect Wallet" // label when disconnected
|
|
129
|
+
disconnectLabel="Disconnect" // dropdown label when connected
|
|
130
|
+
showAddress={true} // show truncated address when connected
|
|
131
|
+
showBalance={false} // show RLO balance next to address
|
|
232
132
|
/>
|
|
233
133
|
```
|
|
234
134
|
|
|
235
|
-
|
|
135
|
+
## WalletProvider Props
|
|
236
136
|
|
|
237
137
|
```tsx
|
|
238
138
|
<WalletProvider
|
|
239
|
-
network="devnet"
|
|
240
|
-
autoConnect={true}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
onError={(error) => console.error(error)}
|
|
139
|
+
network="devnet" // default network
|
|
140
|
+
autoConnect={true} // silently restore previous session on load
|
|
141
|
+
onConnect={(accounts) => {}}
|
|
142
|
+
onDisconnect={() => {}}
|
|
143
|
+
onNetworkChange={(net) => {}}
|
|
144
|
+
onError={(error) => {}}
|
|
246
145
|
>
|
|
247
146
|
{children}
|
|
248
147
|
</WalletProvider>
|
|
249
148
|
```
|
|
250
149
|
|
|
251
|
-
The connect modal includes two tabs:
|
|
252
|
-
- **Extension**: Direct browser extension connection
|
|
253
|
-
- **Scan to Connect**: Bidirectional QR code (show QR or scan QR)
|
|
254
|
-
|
|
255
150
|
## Networks
|
|
256
151
|
|
|
257
|
-
| Network | Chain ID | RPC URL
|
|
258
|
-
|
|
259
|
-
| Mainnet | rialo:mainnet | https://mainnet.rialo.io:4101
|
|
260
|
-
| Testnet | rialo:testnet | https://testnet.rialo.io:4101
|
|
261
|
-
| Devnet | rialo:devnet | https://devnet.rialo.io:4101
|
|
262
|
-
| Localnet | rialo:localnet | http://localhost:4101 | lRLO |
|
|
152
|
+
| Network | Chain ID | RPC URL | Symbol |
|
|
153
|
+
|----------|-----------------|--------------------------------|--------|
|
|
154
|
+
| Mainnet | rialo:mainnet | https://mainnet.rialo.io:4101 | RLO |
|
|
155
|
+
| Testnet | rialo:testnet | https://testnet.rialo.io:4101 | tRLO |
|
|
156
|
+
| Devnet | rialo:devnet | https://devnet.rialo.io:4101 | dRLO |
|
|
157
|
+
| Localnet | rialo:localnet | http://localhost:4101 | lRLO |
|
|
263
158
|
|
|
264
|
-
##
|
|
159
|
+
## Provider Interface (window.rialo)
|
|
265
160
|
|
|
266
|
-
|
|
267
|
-
- **TEE** (Trusted Execution Environments) — fastest, hardware-isolated
|
|
268
|
-
- **MPC** (Multi-Party Computation) — distributed, no single trust point
|
|
269
|
-
- **FHE** (Fully Homomorphic Encryption) — compute on encrypted data
|
|
270
|
-
- **Auto** — protocol selects optimal privacy technology
|
|
271
|
-
|
|
272
|
-
### REX Transaction Flow
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
1. User encrypts inputs with network public key
|
|
276
|
-
2. Wallet submits encrypted TX to REX execution layer
|
|
277
|
-
3. Nodes execute confidentially (inputs never exposed)
|
|
278
|
-
4. Result is cryptographically attested
|
|
279
|
-
5. Only authorized parties can decrypt output
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### REX Config Options
|
|
161
|
+
When the Sheep Wallet extension is installed, it injects `window.rialo` with this interface:
|
|
283
162
|
|
|
284
163
|
```typescript
|
|
285
|
-
interface
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
164
|
+
interface RialoProvider {
|
|
165
|
+
isRialo: boolean;
|
|
166
|
+
isSheepWallet: boolean;
|
|
167
|
+
version: string;
|
|
168
|
+
|
|
169
|
+
// Connection
|
|
170
|
+
connect(): Promise<WalletAccount[]>;
|
|
171
|
+
disconnect(): Promise<void>;
|
|
172
|
+
isConnected(): Promise<boolean>;
|
|
173
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
174
|
+
|
|
175
|
+
// Transactions
|
|
176
|
+
signTransaction(tx: TransactionRequest): Promise<{ signature: string }>;
|
|
177
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
178
|
+
signAndSendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
179
|
+
|
|
180
|
+
// Message Signing
|
|
181
|
+
signMessage(message: string | Uint8Array): Promise<SignedMessage>;
|
|
182
|
+
|
|
183
|
+
// Network
|
|
184
|
+
getNetwork(): Promise<RialoNetwork>;
|
|
185
|
+
switchNetwork(network: RialoNetwork): Promise<void>;
|
|
186
|
+
getBalance(address?: string): Promise<BalanceResult>;
|
|
187
|
+
|
|
188
|
+
// Events
|
|
189
|
+
on(event: WalletEvent, callback: Function): () => void;
|
|
190
|
+
|
|
191
|
+
// State (synchronous getters)
|
|
192
|
+
readonly connected: boolean;
|
|
193
|
+
readonly accounts: WalletAccount[];
|
|
194
|
+
readonly address: string | null;
|
|
195
|
+
readonly network: RialoNetwork;
|
|
196
|
+
readonly chainId: string;
|
|
295
197
|
}
|
|
296
198
|
```
|
|
297
199
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
Stake-for-Service converts staking yield into service credits that pay for gas automatically.
|
|
301
|
-
|
|
302
|
-
### How It Works
|
|
200
|
+
### Supported Events
|
|
303
201
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
```
|
|
202
|
+
| Event | Payload |
|
|
203
|
+
|-------------------|-----------------------------------|
|
|
204
|
+
| `connect` | `{ accounts: WalletAccount[] }` |
|
|
205
|
+
| `disconnect` | — |
|
|
206
|
+
| `accountsChanged` | `WalletAccount[]` |
|
|
207
|
+
| `networkChanged` | `{ network, chainId }` |
|
|
311
208
|
|
|
312
|
-
|
|
209
|
+
## Key Types
|
|
313
210
|
|
|
314
211
|
```typescript
|
|
315
|
-
interface
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
validator: string; // Validator address
|
|
319
|
-
routingFraction: number; // 0.0 - 1.0
|
|
320
|
-
creditBalance: string; // Current credits
|
|
321
|
-
creditsPerEpoch: string; // Estimated yield
|
|
322
|
-
status: 'active' | 'pending' | 'closed';
|
|
212
|
+
interface WalletAccount {
|
|
213
|
+
address: string;
|
|
214
|
+
publicKey: string;
|
|
323
215
|
}
|
|
324
216
|
|
|
325
|
-
interface
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
217
|
+
interface TransactionRequest {
|
|
218
|
+
to: string;
|
|
219
|
+
value: string; // amount in kelvins (1 RLO = 1_000_000_000 kelvins)
|
|
220
|
+
data?: string;
|
|
221
|
+
memo?: string;
|
|
330
222
|
}
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
## Scan-to-Connect
|
|
334
223
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
**Wallet → dApp**: Wallet shows QR (Settings → Show Connect QR), dApp scans
|
|
224
|
+
interface TransactionResult {
|
|
225
|
+
hash: string;
|
|
226
|
+
signature?: string;
|
|
227
|
+
status: 'pending' | 'confirmed' | 'failed';
|
|
228
|
+
}
|
|
341
229
|
|
|
342
|
-
|
|
230
|
+
interface SignedMessage {
|
|
231
|
+
signature: string;
|
|
232
|
+
message: string;
|
|
233
|
+
address: string;
|
|
234
|
+
}
|
|
343
235
|
|
|
344
|
-
|
|
345
|
-
rialo-wc://{sessionId}?relay={relayUrl}&topic={topic}&networks=devnet
|
|
236
|
+
type RialoNetwork = 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
346
237
|
```
|
|
347
238
|
|
|
348
239
|
## Utilities
|
|
349
240
|
|
|
350
241
|
```typescript
|
|
351
|
-
import {
|
|
352
|
-
formatAddress,
|
|
353
|
-
formatBalance,
|
|
354
|
-
parseBalance,
|
|
355
|
-
isValidAddress,
|
|
356
|
-
isInstalled,
|
|
357
|
-
NETWORKS,
|
|
358
|
-
} from '@cookill/wallet-adapter';
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
## TypeScript
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
import type {
|
|
365
|
-
WalletAccount, TransactionRequest, TransactionResult,
|
|
366
|
-
SignedMessage, NetworkConfig, WalletInfo, RialoProvider,
|
|
367
|
-
RialoNetwork, RialoChainId,
|
|
368
|
-
// REX
|
|
369
|
-
REXConfig, REXCapabilities, REXTransactionResult, REXPrivacyMode,
|
|
370
|
-
// SfS
|
|
371
|
-
SfSPosition, SfSCreateParams, SfSUpdateParams, SfSCreditBalance,
|
|
372
|
-
// Scan-to-Connect
|
|
373
|
-
ScanConnectSession, ScanConnectURI, ScanConnectStatus,
|
|
242
|
+
import {
|
|
243
|
+
formatAddress, // (address, chars?) => "5YNm...VWr8"
|
|
244
|
+
formatBalance, // (kelvins, decimals?) => "1.0000"
|
|
245
|
+
parseBalance, // (rlo) => bigint (kelvins)
|
|
246
|
+
isValidAddress, // (address) => boolean
|
|
247
|
+
isInstalled, // () => boolean
|
|
248
|
+
NETWORKS, // Record<RialoNetwork, NetworkConfig>
|
|
374
249
|
} from '@cookill/wallet-adapter';
|
|
375
250
|
```
|
|
376
251
|
|
|
377
|
-
##
|
|
252
|
+
## Architecture Notes
|
|
378
253
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
// Hook usage unchanged
|
|
384
|
-
const { connect, connected } = useWallet();
|
|
385
|
-
|
|
386
|
-
// New in v3.1:
|
|
387
|
-
+ import { useREX, useSfS, useScanConnect } from '@cookill/wallet-adapter/react';
|
|
388
|
-
+ const { submitREXTransaction } = useREX();
|
|
389
|
-
+ const { sendGasless, hasCredits } = useSfS();
|
|
390
|
-
+ const { generateQR, scanURI } = useScanConnect();
|
|
391
|
-
|
|
392
|
-
// WalletProvider now supports scanConnectRelay prop
|
|
393
|
-
+ <WalletProvider scanConnectRelay="wss://relay.rialo.io">
|
|
394
|
-
|
|
395
|
-
// ConnectButton now shows feature badges
|
|
396
|
-
+ <ConnectButton showFeatures={true} />
|
|
397
|
-
|
|
398
|
-
// Connect modal now has "Scan to Connect" tab built-in
|
|
399
|
-
```
|
|
254
|
+
- All provider calls are wrapped with a 20-second timeout to prevent dApp freezes if the extension stops responding.
|
|
255
|
+
- `autoConnect` uses a silent `checkSession()` that never triggers a user-facing approval popup — it only restores an existing session.
|
|
256
|
+
- The connect modal is rendered inside `WalletProvider` so you never need to manage modal state yourself.
|
|
400
257
|
|
|
401
258
|
## License
|
|
402
259
|
|
package/dist/index.d.cts
CHANGED
|
@@ -190,6 +190,7 @@ interface ScanConnectURI {
|
|
|
190
190
|
/** Parsed session info */
|
|
191
191
|
session: ScanConnectSession;
|
|
192
192
|
}
|
|
193
|
+
type ScanConnectStatus = 'idle' | 'generating' | 'waiting' | 'scanned' | 'approving' | 'connected' | 'expired' | 'rejected' | 'error';
|
|
193
194
|
interface WalletInfo {
|
|
194
195
|
id: string;
|
|
195
196
|
name: string;
|
|
@@ -405,4 +406,4 @@ declare class SheepWallet {
|
|
|
405
406
|
private _setupEvents;
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
export { type BalanceResult, NETWORKS, type NetworkConfig, type RialoChainId, type RialoNetwork, type RialoProvider, SheepWallet as RialoWallet, SheepWallet, type SignedMessage, type TransactionRequest, type TransactionResult, type WalletAccount, type WalletEventType, type WalletInfo, SheepWallet as default, formatAddress, formatBalance, fromChainId, getProvider, getProvider as getRialoProvider, isInstalled, isInstalled as isRialoInstalled, isValidAddress, normalizeAccounts, parseBalance, toChainId, waitForProvider, waitForProvider as waitForRialoProvider, withTimeout };
|
|
409
|
+
export { type BalanceResult, NETWORKS, type NetworkConfig, type REXAccessPolicy, type REXCapabilities, type REXConfig, type REXPrivacyMode, type REXTransactionResult, type RialoChainId, type RialoNetwork, type RialoProvider, SheepWallet as RialoWallet, type ScanConnectDAppMetadata, type ScanConnectSession, type ScanConnectStatus, type ScanConnectURI, type ScanConnectWalletMetadata, type SfSCreateParams, type SfSCreditBalance, type SfSPosition, type SfSUpdateParams, SheepWallet, type SignedMessage, type TransactionRequest, type TransactionResult, type WalletAccount, type WalletEventType, type WalletInfo, SheepWallet as default, formatAddress, formatBalance, fromChainId, getProvider, getProvider as getRialoProvider, isInstalled, isInstalled as isRialoInstalled, isValidAddress, normalizeAccounts, parseBalance, toChainId, waitForProvider, waitForProvider as waitForRialoProvider, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -190,6 +190,7 @@ interface ScanConnectURI {
|
|
|
190
190
|
/** Parsed session info */
|
|
191
191
|
session: ScanConnectSession;
|
|
192
192
|
}
|
|
193
|
+
type ScanConnectStatus = 'idle' | 'generating' | 'waiting' | 'scanned' | 'approving' | 'connected' | 'expired' | 'rejected' | 'error';
|
|
193
194
|
interface WalletInfo {
|
|
194
195
|
id: string;
|
|
195
196
|
name: string;
|
|
@@ -405,4 +406,4 @@ declare class SheepWallet {
|
|
|
405
406
|
private _setupEvents;
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
export { type BalanceResult, NETWORKS, type NetworkConfig, type RialoChainId, type RialoNetwork, type RialoProvider, SheepWallet as RialoWallet, SheepWallet, type SignedMessage, type TransactionRequest, type TransactionResult, type WalletAccount, type WalletEventType, type WalletInfo, SheepWallet as default, formatAddress, formatBalance, fromChainId, getProvider, getProvider as getRialoProvider, isInstalled, isInstalled as isRialoInstalled, isValidAddress, normalizeAccounts, parseBalance, toChainId, waitForProvider, waitForProvider as waitForRialoProvider, withTimeout };
|
|
409
|
+
export { type BalanceResult, NETWORKS, type NetworkConfig, type REXAccessPolicy, type REXCapabilities, type REXConfig, type REXPrivacyMode, type REXTransactionResult, type RialoChainId, type RialoNetwork, type RialoProvider, SheepWallet as RialoWallet, type ScanConnectDAppMetadata, type ScanConnectSession, type ScanConnectStatus, type ScanConnectURI, type ScanConnectWalletMetadata, type SfSCreateParams, type SfSCreditBalance, type SfSPosition, type SfSUpdateParams, SheepWallet, type SignedMessage, type TransactionRequest, type TransactionResult, type WalletAccount, type WalletEventType, type WalletInfo, SheepWallet as default, formatAddress, formatBalance, fromChainId, getProvider, getProvider as getRialoProvider, isInstalled, isInstalled as isRialoInstalled, isValidAddress, normalizeAccounts, parseBalance, toChainId, waitForProvider, waitForProvider as waitForRialoProvider, withTimeout };
|