@volr/react-ui 0.1.57 → 0.1.58

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 CHANGED
@@ -22,7 +22,6 @@ const volrConfig: VolrUIConfig = {
22
22
  defaultChainId: 8453,
23
23
  projectApiKey: 'your-project-api-key',
24
24
  appName: 'My App',
25
- // keyStorageType defaults to 'passkey' if not specified
26
25
  accentColor: '#3b82f6',
27
26
  enabledLoginMethods: ['email', 'social', 'siwe'],
28
27
  socialProviders: ['google', 'twitter', 'apple'],
@@ -37,69 +36,52 @@ function App() {
37
36
  }
38
37
  ```
39
38
 
40
- ### 2. Use LoginModal
39
+ ### 2. Use useVolrModal Hook
41
40
 
42
41
  ```tsx
43
- import { useState } from 'react';
44
- import { LoginModal } from '@volr/react-ui';
42
+ import { useVolrModal, useVolr } from '@volr/react-ui';
45
43
 
46
- function LoginButton() {
47
- const [isOpen, setIsOpen] = useState(false);
44
+ function Example() {
45
+ const { open } = useVolrModal();
46
+ const { evmAddress, isLoggedIn, logout } = useVolr();
48
47
 
49
48
  return (
50
- <>
51
- <button onClick={() => setIsOpen(true)}>Login</button>
52
-
53
- <LoginModal
54
- isOpen={isOpen}
55
- onClose={() => setIsOpen(false)}
56
- onError={(error) => {
57
- console.error('Login error:', error);
58
- }}
59
- />
60
- </>
49
+ <div>
50
+ {isLoggedIn ? (
51
+ <>
52
+ <p>Wallet: {evmAddress}</p>
53
+ <button onClick={() => open({ mode: 'account' })}>
54
+ My Account
55
+ </button>
56
+ <button onClick={() => open({ mode: 'deposit' })}>
57
+ Deposit
58
+ </button>
59
+ <button onClick={logout}>Logout</button>
60
+ </>
61
+ ) : (
62
+ <button onClick={() => open()}>Login</button>
63
+ )}
64
+ </div>
61
65
  );
62
66
  }
63
67
  ```
64
68
 
65
- ### 3. Use Wallet
69
+ ### 3. Direct Asset Deposit
66
70
 
67
- After login, use `useVolr` to interact with the blockchain.
71
+ Open deposit modal with a specific asset pre-selected:
68
72
 
69
73
  ```tsx
70
- import { useVolr } from '@volr/react-ui';
71
-
72
- function Example() {
73
- const { evm, evmAddress, isLoggedIn, logout } = useVolr();
74
-
75
- if (!isLoggedIn) {
76
- return <LoginButton />;
77
- }
78
-
79
- const handleTransfer = async () => {
80
- await evm(8453).sendBatch([
81
- {
82
- target: tokenAddress,
83
- abi: erc20Abi,
84
- functionName: 'transfer',
85
- args: [recipient, amount],
86
- },
87
- ]);
74
+ function DepositButton() {
75
+ const { open } = useVolrModal();
76
+
77
+ const handleDeposit = () => {
78
+ open({
79
+ mode: 'deposit',
80
+ asset: { chainId: 8453, symbol: 'USDC' },
81
+ });
88
82
  };
89
83
 
90
- return (
91
- <div className="flex flex-col gap-4">
92
- <p className="text-sm text-gray-600">Wallet: {evmAddress}</p>
93
- <div className="flex gap-2">
94
- <button onClick={handleTransfer} className="bg-blue-500 text-white rounded">
95
- Transfer
96
- </button>
97
- <button onClick={logout} className="bg-gray-200 rounded">
98
- Logout
99
- </button>
100
- </div>
101
- </div>
102
- );
84
+ return <button onClick={handleDeposit}>Deposit USDC</button>;
103
85
  }
104
86
  ```
105
87
 
@@ -116,20 +98,45 @@ function Example() {
116
98
  | `config.accentColor` | `string` | `'#303030'` | Accent color for buttons and links |
117
99
  | `config.enabledLoginMethods` | `('email' \| 'social' \| 'siwe')[]` | `['email', 'social', 'siwe']` | Enabled login methods |
118
100
  | `config.socialProviders` | `('google' \| 'twitter' \| 'apple')[]` | `['google', 'twitter', 'apple']` | Enabled social providers |
119
- | `config.keyStorageType` | `'passkey' \| 'mpc'` | `'passkey'` | Key storage type (optional, defaults to passkey) |
101
+ | `config.keyStorageType` | `'passkey' \| 'mpc'` | `'passkey'` | Key storage type |
120
102
  | `config.branding` | `BrandingConfig` | `undefined` | Custom branding configuration |
121
103
  | `config.providerPolicy` | `object` | `{ enforceOnFirstLogin: true }` | Provider policy settings |
122
104
 
123
- ### LoginModal Props
124
-
125
- | Prop | Type | Default | Description |
126
- |------|------|---------|-------------|
127
- | `isOpen` | `boolean` | **Required** | Modal open/close state |
128
- | `onClose` | `() => void` | **Required** | Close callback |
129
- | `onError` | `(error: Error) => void` | `undefined` | Error callback |
105
+ > **Note:** Deposit assets are now configured via the Volr Dashboard, not in the SDK config.
130
106
 
131
107
  ## API Reference
132
108
 
109
+ ### useVolrModal
110
+
111
+ Hook for controlling modals.
112
+
113
+ ```tsx
114
+ import { useVolrModal } from '@volr/react-ui';
115
+
116
+ const { isOpen, mode, asset, open, close } = useVolrModal();
117
+
118
+ // Open account modal (default) - shows login if not logged in, account info if logged in
119
+ open();
120
+ open({ mode: 'account' });
121
+
122
+ // Open deposit modal
123
+ open({ mode: 'deposit' });
124
+
125
+ // Open deposit with specific asset
126
+ open({ mode: 'deposit', asset: { chainId: 8453, symbol: 'ETH' } });
127
+
128
+ // Close modal
129
+ close();
130
+ ```
131
+
132
+ | Property | Type | Description |
133
+ |----------|------|-------------|
134
+ | `isOpen` | `boolean` | Whether modal is open |
135
+ | `mode` | `'account' \| 'deposit'` | Current modal mode |
136
+ | `asset` | `{ chainId: number; symbol: string } \| null` | Selected asset for deposit |
137
+ | `open` | `(options?) => void` | Open modal with optional mode/asset |
138
+ | `close` | `() => void` | Close modal |
139
+
133
140
  ### useVolr
134
141
 
135
142
  ```tsx
@@ -179,25 +186,29 @@ const result = await client.sendBatch([
179
186
  gasLimit: 100000n,
180
187
  },
181
188
  ]);
182
-
183
- // Send batch (raw calls)
184
- const result = await client.sendBatch([
185
- {
186
- target: '0x...',
187
- data: '0x...',
188
- value: 0n,
189
- gasLimit: 100000n,
190
- },
191
- ]);
192
189
  ```
193
190
 
191
+ ## Modal Modes
192
+
193
+ ### Account Mode (`mode: 'account'`)
194
+
195
+ - **Not logged in**: Shows login screen (email, social, SIWE)
196
+ - **Logged in**: Shows account info (wallet address, email) and logout button
197
+
198
+ ### Deposit Mode (`mode: 'deposit'`)
199
+
200
+ - **Not logged in**: Shows login first, then deposit screen
201
+ - **Logged in**: Shows deposit QR code and address
202
+ - **With asset**: Pre-selects the specified asset
203
+
194
204
  ## Features
195
205
 
196
206
  - **Email Login**: Email verification with 6-digit code
197
207
  - **Social Login**: Google, Twitter, Apple OAuth
198
208
  - **SIWE**: Sign-In with Ethereum (wallet login)
199
- - **Passkey Wallet**: Automatic passkey-based wallet creation for new users
200
- - **Minimal Design**: Clean, modern UI without emojis
209
+ - **Passkey Wallet**: Automatic passkey-based wallet creation
210
+ - **Deposit**: QR code-based crypto deposits
211
+ - **Minimal Design**: Clean, modern UI
201
212
  - **Customizable**: Accent color and enabled methods
202
213
  - **Type-Safe**: Full TypeScript support
203
214
 
@@ -225,22 +236,50 @@ const result = await client.sendBatch([
225
236
  4. **New users**: Passkey setup
226
237
  5. **Existing users**: Success
227
238
 
228
- ## Passkey Setup
239
+ ## Examples
229
240
 
230
- For new users, a passkey-based wallet is automatically created:
241
+ ### Login/Account Button
231
242
 
232
- 1. **Create Passkey**: WebAuthn API with platform authenticator
233
- 2. **Derive Wrap Key**: From Passkey PRF
234
- 3. **Generate Master Seed**: 32-byte random seed
235
- 4. **Encrypt**: AES-256-GCM with Wrap Key
236
- 5. **Upload**: Encrypted seed to S3
237
- 6. **Register Provider**: Backend registration
238
- 7. **Derive EVM Key**: BIP-32 derivation
239
- 8. **Complete**: Wallet address confirmed
243
+ ```tsx
244
+ import { useVolrModal, useVolr } from '@volr/react-ui';
245
+
246
+ function AuthButton() {
247
+ const { open } = useVolrModal();
248
+ const { isLoggedIn, evmAddress } = useVolr();
249
+
250
+ if (isLoggedIn) {
251
+ return (
252
+ <button onClick={() => open({ mode: 'account' })}>
253
+ {evmAddress?.slice(0, 6)}...{evmAddress?.slice(-4)}
254
+ </button>
255
+ );
256
+ }
240
257
 
241
- ## Examples
258
+ return <button onClick={() => open()}>Connect</button>;
259
+ }
260
+ ```
261
+
262
+ ### Deposit Button
263
+
264
+ ```tsx
265
+ import { useVolrModal, useVolr } from '@volr/react-ui';
266
+
267
+ function DepositButton() {
268
+ const { open } = useVolrModal();
269
+ const { isLoggedIn } = useVolr();
270
+
271
+ return (
272
+ <button
273
+ onClick={() => open({ mode: 'deposit' })}
274
+ disabled={!isLoggedIn}
275
+ >
276
+ Deposit
277
+ </button>
278
+ );
279
+ }
280
+ ```
242
281
 
243
- ### Email Only
282
+ ### Email Only Config
244
283
 
245
284
  ```tsx
246
285
  const volrConfig: VolrUIConfig = {
@@ -250,10 +289,6 @@ const volrConfig: VolrUIConfig = {
250
289
  accentColor: '#6366f1',
251
290
  enabledLoginMethods: ['email'],
252
291
  };
253
-
254
- <VolrUIProvider config={volrConfig}>
255
- <App />
256
- </VolrUIProvider>
257
292
  ```
258
293
 
259
294
  ### Google and Apple Only
@@ -267,45 +302,8 @@ const volrConfig: VolrUIConfig = {
267
302
  enabledLoginMethods: ['social'],
268
303
  socialProviders: ['google', 'apple'],
269
304
  };
270
-
271
- <VolrUIProvider config={volrConfig}>
272
- <App />
273
- </VolrUIProvider>
274
- ```
275
-
276
- ### Custom Error Handling
277
-
278
- ```tsx
279
- function App() {
280
- const [showLogin, setShowLogin] = useState(false);
281
- const [error, setError] = useState<string | null>(null);
282
-
283
- return (
284
- <div className="flex flex-col gap-4">
285
- {error && (
286
- <div className="bg-red-50 text-red-800 rounded-lg">
287
- {error}
288
- </div>
289
- )}
290
-
291
- <button onClick={() => setShowLogin(true)}>Login</button>
292
-
293
- <LoginModal
294
- isOpen={showLogin}
295
- onClose={() => {
296
- setShowLogin(false);
297
- setError(null);
298
- }}
299
- onError={(err) => {
300
- setError(err.message);
301
- setTimeout(() => setError(null), 3000);
302
- }}
303
- />
304
- </div>
305
- );
306
- }
307
305
  ```
308
306
 
309
307
  ## License
310
308
 
311
- MIT
309
+ MIT