@volr/react-ui 0.1.49 → 0.1.53
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 +107 -93
- package/dist/index.cjs +7 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -62,25 +62,46 @@ function LoginButton() {
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
### 3. Use Wallet
|
|
66
|
+
|
|
67
|
+
After login, use `useVolr` to interact with the blockchain.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { useVolr } from '@volr/react-ui';
|
|
71
|
+
|
|
72
|
+
function Example() {
|
|
73
|
+
const { evm, address, 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
|
+
]);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div className="flex flex-col gap-4">
|
|
92
|
+
<p className="text-sm text-gray-600">Wallet: {address}</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
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
84
105
|
|
|
85
106
|
## Configuration
|
|
86
107
|
|
|
@@ -107,6 +128,69 @@ resets so they do not apply under the `[data-volr-root]` subtree.
|
|
|
107
128
|
| `onClose` | `() => void` | **Required** | Close callback |
|
|
108
129
|
| `onError` | `(error: Error) => void` | `undefined` | Error callback |
|
|
109
130
|
|
|
131
|
+
## API Reference
|
|
132
|
+
|
|
133
|
+
### useVolr
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { useVolr } from '@volr/react-ui';
|
|
137
|
+
|
|
138
|
+
const {
|
|
139
|
+
evm, // (chainId: number) => EvmClient
|
|
140
|
+
address, // `0x${string}` | undefined
|
|
141
|
+
email, // string | undefined
|
|
142
|
+
isLoggedIn, // boolean
|
|
143
|
+
signerType, // 'passkey' | 'external_wallet' | 'mpc' | undefined
|
|
144
|
+
logout, // () => Promise<void>
|
|
145
|
+
isLoading, // boolean
|
|
146
|
+
error, // Error | null
|
|
147
|
+
} = useVolr();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### EvmClient
|
|
151
|
+
|
|
152
|
+
Returned by `evm(chainId)`.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const client = evm(8453);
|
|
156
|
+
|
|
157
|
+
// Read contract
|
|
158
|
+
const balance = await client.readContract({
|
|
159
|
+
address: tokenAddress,
|
|
160
|
+
abi: erc20Abi,
|
|
161
|
+
functionName: 'balanceOf',
|
|
162
|
+
args: [userAddress],
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Send single transaction
|
|
166
|
+
const result = await client.sendTransaction({
|
|
167
|
+
to: '0x...',
|
|
168
|
+
data: '0x...',
|
|
169
|
+
value: 0n,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Send batch (with ABI)
|
|
173
|
+
const result = await client.sendBatch([
|
|
174
|
+
{
|
|
175
|
+
target: tokenAddress,
|
|
176
|
+
abi: erc20Abi,
|
|
177
|
+
functionName: 'transfer',
|
|
178
|
+
args: [recipient, amount],
|
|
179
|
+
gasLimit: 100000n,
|
|
180
|
+
},
|
|
181
|
+
]);
|
|
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
|
+
```
|
|
193
|
+
|
|
110
194
|
## Features
|
|
111
195
|
|
|
112
196
|
- **Email Login**: Email verification with 6-digit code
|
|
@@ -197,15 +281,9 @@ function App() {
|
|
|
197
281
|
const [error, setError] = useState<string | null>(null);
|
|
198
282
|
|
|
199
283
|
return (
|
|
200
|
-
|
|
284
|
+
<div className="flex flex-col gap-4">
|
|
201
285
|
{error && (
|
|
202
|
-
<div
|
|
203
|
-
padding: '12px',
|
|
204
|
-
backgroundColor: '#fef2f2',
|
|
205
|
-
color: '#991b1b',
|
|
206
|
-
borderRadius: '8px',
|
|
207
|
-
marginBottom: '16px'
|
|
208
|
-
}}>
|
|
286
|
+
<div className="bg-red-50 text-red-800 rounded-lg">
|
|
209
287
|
{error}
|
|
210
288
|
</div>
|
|
211
289
|
)}
|
|
@@ -223,75 +301,11 @@ function App() {
|
|
|
223
301
|
setTimeout(() => setError(null), 3000);
|
|
224
302
|
}}
|
|
225
303
|
/>
|
|
226
|
-
|
|
304
|
+
</div>
|
|
227
305
|
);
|
|
228
306
|
}
|
|
229
307
|
```
|
|
230
308
|
|
|
231
|
-
## Backend Requirements
|
|
232
|
-
|
|
233
|
-
### Environment Variables
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# Google OAuth
|
|
237
|
-
GOOGLE_CLIENT_ID=your_google_client_id
|
|
238
|
-
GOOGLE_CLIENT_SECRET=your_google_client_secret
|
|
239
|
-
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback
|
|
240
|
-
|
|
241
|
-
# Twitter OAuth
|
|
242
|
-
TWITTER_CLIENT_ID=your_twitter_client_id
|
|
243
|
-
TWITTER_CLIENT_SECRET=your_twitter_client_secret
|
|
244
|
-
TWITTER_REDIRECT_URI=http://localhost:3000/auth/twitter/callback
|
|
245
|
-
|
|
246
|
-
# Apple OAuth
|
|
247
|
-
APPLE_CLIENT_ID=your_apple_client_id
|
|
248
|
-
APPLE_REDIRECT_URI=http://localhost:3000/auth/apple/callback
|
|
249
|
-
|
|
250
|
-
# Frontend URL (OAuth callback redirect)
|
|
251
|
-
FRONTEND_URL=http://localhost:5173
|
|
252
|
-
|
|
253
|
-
# API Base URL
|
|
254
|
-
API_BASE_URL=http://localhost:3000
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### Required Endpoints
|
|
258
|
-
|
|
259
|
-
**Email Login**
|
|
260
|
-
- `POST /auth/email/send` - Send verification code
|
|
261
|
-
- `POST /auth/email/verify` - Verify code and login
|
|
262
|
-
|
|
263
|
-
**Social Login**
|
|
264
|
-
- `GET /auth/google` - Start Google OAuth
|
|
265
|
-
- `GET /auth/google/callback` - Google OAuth callback
|
|
266
|
-
- `GET /auth/twitter` - Start Twitter OAuth
|
|
267
|
-
- `GET /auth/twitter/callback` - Twitter OAuth callback
|
|
268
|
-
- `GET /auth/apple` - Start Apple OAuth
|
|
269
|
-
- `POST /auth/apple/callback` - Apple OAuth callback
|
|
270
|
-
|
|
271
|
-
**SIWE**
|
|
272
|
-
- `POST /auth/siwe/nonce` - Generate nonce
|
|
273
|
-
- `POST /auth/siwe/verify` - Verify SIWE signature
|
|
274
|
-
|
|
275
|
-
**Passkey**
|
|
276
|
-
- `POST /blob/presign` - Generate S3 upload URL
|
|
277
|
-
- `POST /wallet/provider/register` - Register provider
|
|
278
|
-
|
|
279
|
-
## Troubleshooting
|
|
280
|
-
|
|
281
|
-
### OAuth Redirect Failure
|
|
282
|
-
- Verify OAuth Client ID and Secret
|
|
283
|
-
- Check Redirect URI matches OAuth app settings
|
|
284
|
-
- Verify CORS configuration
|
|
285
|
-
|
|
286
|
-
### SIWE Signature Failure
|
|
287
|
-
- Ensure MetaMask or wallet is installed
|
|
288
|
-
- Check wallet is connected to correct network
|
|
289
|
-
|
|
290
|
-
### Passkey Creation Failure
|
|
291
|
-
- HTTPS or localhost required (HTTP not supported)
|
|
292
|
-
- Verify browser supports WebAuthn
|
|
293
|
-
- Check biometric authentication is enabled on device
|
|
294
|
-
|
|
295
309
|
## License
|
|
296
310
|
|
|
297
|
-
MIT
|
|
311
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -294,7 +294,7 @@ var VolrModalProvider = ({
|
|
|
294
294
|
}) => {
|
|
295
295
|
const [isOpen, setIsOpen] = React5.useState(false);
|
|
296
296
|
const [mode, setMode] = React5.useState("auth");
|
|
297
|
-
const { user } = react.
|
|
297
|
+
const { user } = react.useVolrContext();
|
|
298
298
|
const open = React5.useCallback(() => {
|
|
299
299
|
setMode(user ? "deposit" : "auth");
|
|
300
300
|
setIsOpen(true);
|
|
@@ -922,7 +922,7 @@ function PasskeyEnrollView({
|
|
|
922
922
|
isOpen = true,
|
|
923
923
|
wrapInModal = true
|
|
924
924
|
}) {
|
|
925
|
-
const { user, logout, setUser } = react.
|
|
925
|
+
const { user, logout, setUser } = react.useVolrContext();
|
|
926
926
|
const { client } = react.useInternalAuth();
|
|
927
927
|
const { t } = useI18n();
|
|
928
928
|
const { accentColor } = useVolrUI();
|
|
@@ -2364,7 +2364,7 @@ function LoginSuccessScreen({
|
|
|
2364
2364
|
] });
|
|
2365
2365
|
}
|
|
2366
2366
|
function SigninModal({ isOpen, onClose, onError }) {
|
|
2367
|
-
const { logout, user } = react.
|
|
2367
|
+
const { logout, user } = react.useVolrContext();
|
|
2368
2368
|
const { appName, branding } = useVolrUI();
|
|
2369
2369
|
const { requestEmailCode, verifyEmailCode, handleSocialLogin } = react.useVolrLogin();
|
|
2370
2370
|
const [currentScreen, setCurrentScreen] = React5.useState("method-select");
|
|
@@ -2974,7 +2974,7 @@ var DepositCompletedToast = ({
|
|
|
2974
2974
|
};
|
|
2975
2975
|
function DepositQRView(props) {
|
|
2976
2976
|
const { t } = useI18n();
|
|
2977
|
-
const { config } = react.
|
|
2977
|
+
const { config } = react.useVolrContext();
|
|
2978
2978
|
const { client } = react.useInternalAuth();
|
|
2979
2979
|
const [chainName, setChainName] = React5.useState(null);
|
|
2980
2980
|
const [showOtherTokenModal, setShowOtherTokenModal] = React5.useState(false);
|
|
@@ -3107,7 +3107,7 @@ var DepositModal = ({
|
|
|
3107
3107
|
open,
|
|
3108
3108
|
onOpenChange
|
|
3109
3109
|
}) => {
|
|
3110
|
-
const { config, user } = react.
|
|
3110
|
+
const { config, user } = react.useVolrContext();
|
|
3111
3111
|
const supportedAssets = config.deposit?.supportedAssets ?? [];
|
|
3112
3112
|
const hasAssets = supportedAssets.length > 0;
|
|
3113
3113
|
const [selectedIdx, setSelectedIdx] = React5.useState(
|
|
@@ -3187,7 +3187,7 @@ function OnboardingFlow({
|
|
|
3187
3187
|
keyStorageType,
|
|
3188
3188
|
onComplete
|
|
3189
3189
|
}) {
|
|
3190
|
-
const { logout } = react.
|
|
3190
|
+
const { logout } = react.useVolrContext();
|
|
3191
3191
|
const handleEnrollComplete = () => {
|
|
3192
3192
|
onComplete();
|
|
3193
3193
|
};
|
|
@@ -3394,7 +3394,7 @@ function OnboardingChecker({
|
|
|
3394
3394
|
onShowOnboarding,
|
|
3395
3395
|
onHideOnboarding
|
|
3396
3396
|
}) {
|
|
3397
|
-
const { user, provider, isLoading } = react.
|
|
3397
|
+
const { user, provider, isLoading } = react.useVolrContext();
|
|
3398
3398
|
const { isOpen: isLoginModalOpen } = useVolrModal();
|
|
3399
3399
|
React5.useEffect(() => {
|
|
3400
3400
|
if (isLoading) {
|
|
@@ -3521,10 +3521,6 @@ Object.defineProperty(exports, "useVolrLogin", {
|
|
|
3521
3521
|
enumerable: true,
|
|
3522
3522
|
get: function () { return react.useVolrLogin; }
|
|
3523
3523
|
});
|
|
3524
|
-
Object.defineProperty(exports, "useVolrWallet", {
|
|
3525
|
-
enumerable: true,
|
|
3526
|
-
get: function () { return react.useVolrWallet; }
|
|
3527
|
-
});
|
|
3528
3524
|
exports.I18nContext = I18nContext;
|
|
3529
3525
|
exports.I18nProvider = I18nProvider;
|
|
3530
3526
|
exports.MpcConnectView = MpcConnectView;
|