@volr/react-ui 0.1.100 → 0.1.101
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 +42 -7
- package/dist/index.cjs +470 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +351 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -185,13 +185,13 @@ import { useVolrModal, useVolr } from '@volr/react-ui';
|
|
|
185
185
|
|
|
186
186
|
function AuthButton() {
|
|
187
187
|
const { open } = useVolrModal();
|
|
188
|
-
const {
|
|
188
|
+
const { evm, isLoggedIn, logout } = useVolr();
|
|
189
189
|
|
|
190
190
|
return (
|
|
191
191
|
<div>
|
|
192
192
|
{isLoggedIn ? (
|
|
193
193
|
<>
|
|
194
|
-
<p>Wallet: {
|
|
194
|
+
<p>Wallet: {evm.address}</p>
|
|
195
195
|
<button onClick={() => open({ mode: 'account' })}>My Account</button>
|
|
196
196
|
<button onClick={logout}>Logout</button>
|
|
197
197
|
</>
|
|
@@ -315,7 +315,8 @@ Hook for wallet and user state.
|
|
|
315
315
|
import { useVolr } from '@volr/react-ui';
|
|
316
316
|
|
|
317
317
|
const {
|
|
318
|
-
|
|
318
|
+
evm, // EvmNamespace (see below)
|
|
319
|
+
evmAddress, // `0x${string}` | undefined (deprecated, use evm.address)
|
|
319
320
|
email, // string | undefined
|
|
320
321
|
isLoggedIn, // boolean
|
|
321
322
|
signerType, // 'passkey' | 'external_wallet' | 'mpc' | undefined
|
|
@@ -327,27 +328,61 @@ const {
|
|
|
327
328
|
|
|
328
329
|
---
|
|
329
330
|
|
|
331
|
+
## Sign Request Confirmation
|
|
332
|
+
|
|
333
|
+
When using `@volr/react-ui`, signing operations (`signMessage`, `signTypedData`) automatically show a confirmation modal before signing. This protects users from signing malicious messages without their knowledge.
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
import { useVolr } from '@volr/react-ui';
|
|
337
|
+
|
|
338
|
+
function SignButton() {
|
|
339
|
+
const { evm } = useVolr();
|
|
340
|
+
|
|
341
|
+
const handleSign = async () => {
|
|
342
|
+
// Modal automatically appears showing the message content
|
|
343
|
+
// User must click "Sign" to proceed
|
|
344
|
+
const signature = await evm.signMessage('Hello, World!');
|
|
345
|
+
console.log('Signed:', signature);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
return <button onClick={handleSign}>Sign Message</button>;
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The modal displays:
|
|
353
|
+
- **For `signMessage`**: The original message content (string or hex)
|
|
354
|
+
- **For `signTypedData`**: Domain info and message fields in a readable format
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
330
358
|
## Advanced: Web3 Transactions
|
|
331
359
|
|
|
332
360
|
For advanced use cases beyond payments, you can send arbitrary transactions.
|
|
333
361
|
|
|
334
|
-
###
|
|
362
|
+
### EvmNamespace & EvmChainClient
|
|
335
363
|
|
|
336
364
|
```tsx
|
|
337
365
|
import { useVolr } from '@volr/react-ui';
|
|
338
366
|
|
|
339
367
|
function SendToken() {
|
|
340
|
-
const { evm
|
|
368
|
+
const { evm } = useVolr();
|
|
341
369
|
|
|
342
370
|
const handleSend = async () => {
|
|
343
|
-
|
|
371
|
+
// Chain-agnostic: Wallet address
|
|
372
|
+
const address = evm.address;
|
|
373
|
+
|
|
374
|
+
// Chain-agnostic: Sign a message (shows confirmation modal)
|
|
375
|
+
const signature = await evm.signMessage('Hello');
|
|
376
|
+
|
|
377
|
+
// Chain-specific: Get client for Base
|
|
378
|
+
const client = evm.client(8453);
|
|
344
379
|
|
|
345
380
|
// Read contract
|
|
346
381
|
const balance = await client.readContract({
|
|
347
382
|
address: tokenAddress,
|
|
348
383
|
abi: erc20Abi,
|
|
349
384
|
functionName: 'balanceOf',
|
|
350
|
-
args: [
|
|
385
|
+
args: [address],
|
|
351
386
|
});
|
|
352
387
|
|
|
353
388
|
// Send transaction
|