@volr/react 0.1.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 +124 -0
- package/dist/index.cjs +2611 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +640 -0
- package/dist/index.d.ts +640 -0
- package/dist/index.js +2559 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { KeyStorageType as KeyStorageType$1, WalletProviderPort, PrecheckInput, PrecheckQuote, RelayInput, RelayResult, SignerPort, ExtendedRPCClient, Call, PasskeyProviderPort } from '@volr/sdk-core';
|
|
4
|
+
export { AuthorizationTuple, Call, MpcTransport, PrecheckInput, PrecheckQuote, PrfInput, RelayInput, RelayMode, RelayResult, SessionAuth, UploadBlobOptions, createMasterKeyProvider, createMpcProvider, createPasskeyProvider, deriveEvmKey, deriveWrapKey, sealMasterSeed, uploadBlob } from '@volr/sdk-core';
|
|
5
|
+
import { Address, Abi, PublicClient } from 'viem';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API client with automatic token refresh
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* API client configuration
|
|
12
|
+
*/
|
|
13
|
+
type APIClientConfig = {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* API client
|
|
19
|
+
*/
|
|
20
|
+
declare class APIClient {
|
|
21
|
+
private refreshPromise;
|
|
22
|
+
private accessToken;
|
|
23
|
+
private apiKey;
|
|
24
|
+
private api;
|
|
25
|
+
constructor(config: APIClientConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Set API key
|
|
28
|
+
*/
|
|
29
|
+
setApiKey(apiKey: string | null): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get API key
|
|
32
|
+
*/
|
|
33
|
+
getApiKey(): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Set access token
|
|
36
|
+
*/
|
|
37
|
+
setAccessToken(token: string | null): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get access token
|
|
40
|
+
*/
|
|
41
|
+
getAccessToken(): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Refresh access token (single-flight)
|
|
44
|
+
*/
|
|
45
|
+
private refreshAccessToken;
|
|
46
|
+
/**
|
|
47
|
+
* Make API request with automatic retry on 401
|
|
48
|
+
*/
|
|
49
|
+
request<T>(endpoint: string, options?: RequestInit, idempotencyKey?: string): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* POST request
|
|
52
|
+
*/
|
|
53
|
+
post<T>(endpoint: string, body: any, idempotencyKey?: string): Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* POST request that returns raw binary (ArrayBuffer)
|
|
56
|
+
* - Uses axios instance with interceptors (auto 401 refresh)
|
|
57
|
+
* - Applies X-API-Key and Authorization automatically
|
|
58
|
+
*/
|
|
59
|
+
postBinary(endpoint: string, body: any): Promise<ArrayBuffer>;
|
|
60
|
+
/**
|
|
61
|
+
* GET request
|
|
62
|
+
*/
|
|
63
|
+
get<T>(endpoint: string): Promise<T>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* API Response DTOs
|
|
68
|
+
* Backend API로부터 받는 응답 타입 정의
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* PRF Input DTO
|
|
73
|
+
* WebAuthn PRF 확장을 위한 입력 파라미터
|
|
74
|
+
*/
|
|
75
|
+
interface PrfInputDto {
|
|
76
|
+
origin: string;
|
|
77
|
+
projectId: string;
|
|
78
|
+
credentialId: string;
|
|
79
|
+
salt?: Uint8Array;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* User DTO
|
|
83
|
+
* 백엔드로부터 받는 사용자 정보
|
|
84
|
+
*/
|
|
85
|
+
interface UserDto {
|
|
86
|
+
id: string;
|
|
87
|
+
email: string;
|
|
88
|
+
accountId?: string;
|
|
89
|
+
evmAddress?: `0x${string}`;
|
|
90
|
+
keyStorageType?: KeyStorageType$1;
|
|
91
|
+
signerType?: 'passkey' | 'external_wallet' | 'mpc';
|
|
92
|
+
walletConnector?: string;
|
|
93
|
+
lastWalletChainId?: number;
|
|
94
|
+
blobUrl?: string;
|
|
95
|
+
prfInput?: PrfInputDto;
|
|
96
|
+
credentialId?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Auth Refresh Response DTO
|
|
100
|
+
* /auth/refresh 엔드포인트 응답
|
|
101
|
+
*/
|
|
102
|
+
interface AuthRefreshResponseDto {
|
|
103
|
+
accessToken: string;
|
|
104
|
+
user?: UserDto;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Network DTO
|
|
108
|
+
* /networks/:chainId 엔드포인트 응답
|
|
109
|
+
*/
|
|
110
|
+
interface NetworkDto {
|
|
111
|
+
chainId: string;
|
|
112
|
+
name: string;
|
|
113
|
+
rpcUrl?: string;
|
|
114
|
+
isActive: boolean;
|
|
115
|
+
invokerAddress: `0x${string}`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Transaction Status
|
|
119
|
+
* 트랜잭션 상태 값
|
|
120
|
+
*/
|
|
121
|
+
type TransactionStatus = 'QUEUED' | 'PENDING' | 'CONFIRMED' | 'FAILED';
|
|
122
|
+
/**
|
|
123
|
+
* Transaction DTO
|
|
124
|
+
* /wallet/transactions/:txId 엔드포인트 응답
|
|
125
|
+
*/
|
|
126
|
+
interface TransactionDto {
|
|
127
|
+
txId: string;
|
|
128
|
+
status: TransactionStatus;
|
|
129
|
+
txHash?: `0x${string}`;
|
|
130
|
+
gasUsed?: string;
|
|
131
|
+
meta?: any;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* API Response Wrapper
|
|
135
|
+
* 모든 API 응답의 공통 래퍼
|
|
136
|
+
*/
|
|
137
|
+
interface ApiResponse<T> {
|
|
138
|
+
ok: boolean;
|
|
139
|
+
data?: T;
|
|
140
|
+
error?: {
|
|
141
|
+
code: string;
|
|
142
|
+
message: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
type KeyStorageType = "passkey" | "mpc";
|
|
147
|
+
type SignerType = "passkey" | "external_wallet" | "mpc";
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* ERC-20 token configuration
|
|
151
|
+
*/
|
|
152
|
+
interface Erc20Token$1 {
|
|
153
|
+
address: `0x${string}`;
|
|
154
|
+
symbol: string;
|
|
155
|
+
decimals: number;
|
|
156
|
+
iconUrl?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deposit asset configuration (native or ERC-20)
|
|
160
|
+
*/
|
|
161
|
+
interface DepositAsset$1 {
|
|
162
|
+
chainId: number;
|
|
163
|
+
token: "native" | Erc20Token$1;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Deposit/Topup configuration
|
|
167
|
+
*/
|
|
168
|
+
interface DepositConfig {
|
|
169
|
+
supportedAssets: DepositAsset$1[];
|
|
170
|
+
pollIntervalMs?: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* User information
|
|
174
|
+
*/
|
|
175
|
+
interface VolrUser {
|
|
176
|
+
id?: string;
|
|
177
|
+
email?: string;
|
|
178
|
+
accountId?: string;
|
|
179
|
+
evmAddress?: `0x${string}`;
|
|
180
|
+
keyStorageType?: KeyStorageType;
|
|
181
|
+
signerType?: SignerType;
|
|
182
|
+
walletConnector?: string;
|
|
183
|
+
lastWalletChainId?: number;
|
|
184
|
+
blobUrl?: string;
|
|
185
|
+
prfInput?: PrfInputDto;
|
|
186
|
+
credentialId?: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Volr configuration
|
|
190
|
+
*/
|
|
191
|
+
type VolrConfig = {
|
|
192
|
+
apiBaseUrl: string;
|
|
193
|
+
defaultChainId: number;
|
|
194
|
+
projectApiKey: string;
|
|
195
|
+
rpcOverrides?: Record<string, string>;
|
|
196
|
+
autoRecoverOnLogin?: boolean;
|
|
197
|
+
providerPolicy?: {
|
|
198
|
+
enforceOnFirstLogin?: boolean;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Deposit/Topup configuration for multi-chain, multi-token support
|
|
202
|
+
*/
|
|
203
|
+
deposit?: DepositConfig;
|
|
204
|
+
/**
|
|
205
|
+
* @internal 개발용: API Base URL 오버라이드
|
|
206
|
+
* 일반 사용자는 타입 체크로 접근 불가
|
|
207
|
+
* 개발 시에는 @ts-expect-error 주석 필요
|
|
208
|
+
*/
|
|
209
|
+
__devApiBaseUrl?: string;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Public context value
|
|
213
|
+
*/
|
|
214
|
+
type VolrContextValue = {
|
|
215
|
+
config: VolrConfig;
|
|
216
|
+
user: VolrUser | null;
|
|
217
|
+
provider: WalletProviderPort | null;
|
|
218
|
+
setProvider: (provider: WalletProviderPort) => Promise<void>;
|
|
219
|
+
setUser: (user: VolrUser | null) => void;
|
|
220
|
+
chainId: number;
|
|
221
|
+
precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
|
|
222
|
+
relay: (input: RelayInput, opts?: {
|
|
223
|
+
idempotencyKey?: string;
|
|
224
|
+
}) => Promise<RelayResult>;
|
|
225
|
+
logout: () => Promise<void>;
|
|
226
|
+
isLoading: boolean;
|
|
227
|
+
error: Error | null;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Internal auth context (for advanced use)
|
|
231
|
+
*/
|
|
232
|
+
type InternalAuthContextType = {
|
|
233
|
+
session: {
|
|
234
|
+
accessToken: string | null;
|
|
235
|
+
refreshToken: string | null;
|
|
236
|
+
};
|
|
237
|
+
refreshAccessToken: () => Promise<void>;
|
|
238
|
+
setAccessToken: (token: string) => void;
|
|
239
|
+
client: APIClient;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* VolrProvider props
|
|
244
|
+
*/
|
|
245
|
+
type VolrProviderProps = {
|
|
246
|
+
config: VolrConfig;
|
|
247
|
+
children: ReactNode;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* VolrProvider component
|
|
251
|
+
*/
|
|
252
|
+
declare function VolrProvider({ config, children }: VolrProviderProps): react_jsx_runtime.JSX.Element;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* useVolr hook - Access Volr context
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* Get Volr context value
|
|
259
|
+
* @throws Error if used outside VolrProvider
|
|
260
|
+
*/
|
|
261
|
+
declare function useVolr(): VolrContextValue;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* usePrecheck hook - Precheck transaction batch
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* usePrecheck return type
|
|
269
|
+
*/
|
|
270
|
+
type UsePrecheckReturn = {
|
|
271
|
+
precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
|
|
272
|
+
isLoading: boolean;
|
|
273
|
+
error: Error | null;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* usePrecheck hook
|
|
277
|
+
*/
|
|
278
|
+
declare function usePrecheck(): UsePrecheckReturn;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* useRelay hook - Relay transaction batch
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* useRelay return type
|
|
286
|
+
*/
|
|
287
|
+
type UseRelayReturn = {
|
|
288
|
+
relay: (input: Omit<RelayInput, "sessionSig" | "authorizationList">, opts?: {
|
|
289
|
+
signer: SignerPort;
|
|
290
|
+
rpcClient?: ExtendedRPCClient;
|
|
291
|
+
idempotencyKey?: string;
|
|
292
|
+
}) => Promise<RelayResult>;
|
|
293
|
+
isLoading: boolean;
|
|
294
|
+
error: Error | null;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* useRelay hook
|
|
298
|
+
*/
|
|
299
|
+
declare function useRelay(): UseRelayReturn;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Call builder utilities for better developer experience
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Options for building a call from function data
|
|
307
|
+
*/
|
|
308
|
+
type BuildCallOptions = {
|
|
309
|
+
target: Address;
|
|
310
|
+
abi: Abi;
|
|
311
|
+
functionName: string;
|
|
312
|
+
args?: readonly unknown[];
|
|
313
|
+
value?: bigint;
|
|
314
|
+
gasLimit?: bigint;
|
|
315
|
+
/**
|
|
316
|
+
* Estimate gas automatically (future feature)
|
|
317
|
+
* Currently noop - will use precheck result to inject gasLimit
|
|
318
|
+
*/
|
|
319
|
+
estimateGas?: boolean;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Build a Call object from function data (auto-encodes data)
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* const call = buildCall({
|
|
327
|
+
* target: '0x...',
|
|
328
|
+
* abi: erc20Abi,
|
|
329
|
+
* functionName: 'transfer',
|
|
330
|
+
* args: ['0x...', BigInt(1000000)],
|
|
331
|
+
* value: BigInt(0),
|
|
332
|
+
* gasLimit: BigInt(100000),
|
|
333
|
+
* estimateGas: true, // Future: will auto-estimate from precheck
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
declare function buildCall(options: BuildCallOptions): Call;
|
|
338
|
+
/**
|
|
339
|
+
* Build multiple calls from function data
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```ts
|
|
343
|
+
* const calls = buildCalls([
|
|
344
|
+
* {
|
|
345
|
+
* target: tokenAddress,
|
|
346
|
+
* abi: erc20Abi,
|
|
347
|
+
* functionName: 'approve',
|
|
348
|
+
* args: [spender, amount],
|
|
349
|
+
* gasLimit: BigInt(50000),
|
|
350
|
+
* },
|
|
351
|
+
* {
|
|
352
|
+
* target: routerAddress,
|
|
353
|
+
* abi: routerAbi,
|
|
354
|
+
* functionName: 'swap',
|
|
355
|
+
* args: [tokenIn, tokenOut, amountIn],
|
|
356
|
+
* gasLimit: BigInt(200000),
|
|
357
|
+
* },
|
|
358
|
+
* ]);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare function buildCalls(options: BuildCallOptions[]): Call[];
|
|
362
|
+
|
|
363
|
+
type SendTxOptions = {
|
|
364
|
+
/**
|
|
365
|
+
* 프로젝트별 policyId. 제공하지 않으면 백엔드에서 자동으로 계산됩니다.
|
|
366
|
+
* Zero policyId (0x0000...0000)는 사용할 수 없습니다.
|
|
367
|
+
*/
|
|
368
|
+
policyId?: `0x${string}`;
|
|
369
|
+
signer?: SignerPort;
|
|
370
|
+
expiresInSec?: number;
|
|
371
|
+
idempotencyKey?: string;
|
|
372
|
+
mode?: 'sponsored' | 'self';
|
|
373
|
+
from?: `0x${string}`;
|
|
374
|
+
/**
|
|
375
|
+
* Run best-effort RPC preflight (eth_estimateGas) before prompting passkey.
|
|
376
|
+
* Defaults to true.
|
|
377
|
+
*/
|
|
378
|
+
preflight?: boolean;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* useVolrWallet hook - Developer-friendly facade for wallet operations
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* sendBatch function overloads
|
|
387
|
+
*/
|
|
388
|
+
type SendBatchOverloads = {
|
|
389
|
+
/**
|
|
390
|
+
* Send a batch of pre-built Call objects
|
|
391
|
+
* @param calls - Array of Call objects with target, data, value, gasLimit
|
|
392
|
+
* @param opts - Transaction options including policyId, expiresInSec, from
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* const calls: Call[] = [
|
|
396
|
+
* { target: '0x...', data: '0x...', value: 0n, gasLimit: 100000n }
|
|
397
|
+
* ];
|
|
398
|
+
* await evm(chainId).sendBatch(calls, { policyId: '0x...' });
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
(calls: Call[], opts: SendTxOptions & {
|
|
402
|
+
from?: `0x${string}`;
|
|
403
|
+
}): Promise<RelayResult>;
|
|
404
|
+
/**
|
|
405
|
+
* Send a batch by providing BuildCallOptions - calls will be built internally
|
|
406
|
+
* @param calls - Array of BuildCallOptions with target, abi, functionName, args
|
|
407
|
+
* @param opts - Transaction options including policyId, expiresInSec, from
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* await evm(chainId).sendBatch(
|
|
411
|
+
* [
|
|
412
|
+
* {
|
|
413
|
+
* target: tokenAddress,
|
|
414
|
+
* abi: erc20Abi,
|
|
415
|
+
* functionName: 'transfer',
|
|
416
|
+
* args: [recipient, amount],
|
|
417
|
+
* gasLimit: 100000n,
|
|
418
|
+
* }
|
|
419
|
+
* ],
|
|
420
|
+
* { policyId: '0x...' }
|
|
421
|
+
* );
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
(calls: BuildCallOptions[], opts: SendTxOptions & {
|
|
425
|
+
from?: `0x${string}`;
|
|
426
|
+
}): Promise<RelayResult>;
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* useVolrWallet hook return type
|
|
430
|
+
*/
|
|
431
|
+
type UseVolrWalletReturn = {
|
|
432
|
+
evm: (chainId: number) => {
|
|
433
|
+
readContract: <TAbi extends readonly unknown[], TFunctionName extends string, TReturnType = Awaited<ReturnType<PublicClient['readContract']>>>(args: Parameters<PublicClient['readContract']>[0] & {
|
|
434
|
+
abi: TAbi;
|
|
435
|
+
functionName: TFunctionName;
|
|
436
|
+
}) => Promise<TReturnType>;
|
|
437
|
+
sendTransaction: (tx: {
|
|
438
|
+
to: `0x${string}`;
|
|
439
|
+
data: `0x${string}`;
|
|
440
|
+
value?: bigint;
|
|
441
|
+
}, opts: SendTxOptions) => Promise<RelayResult>;
|
|
442
|
+
sendBatch: SendBatchOverloads;
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* useVolrWallet hook - Developer-friendly facade
|
|
447
|
+
*/
|
|
448
|
+
declare function useVolrWallet(): UseVolrWalletReturn;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* useVolrLogin hook - Login handlers for various authentication methods
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
type SocialProvider = "google" | "twitter" | "apple";
|
|
455
|
+
/**
|
|
456
|
+
* Authentication result after successful login/verification
|
|
457
|
+
*/
|
|
458
|
+
interface AuthResult {
|
|
459
|
+
userId: string;
|
|
460
|
+
isNewUser: boolean;
|
|
461
|
+
/** Key storage type: 'passkey' or 'mpc'. Null if user hasn't set up key storage yet. */
|
|
462
|
+
keyStorageType: KeyStorageType | null;
|
|
463
|
+
/** Signer type: how the user signs transactions */
|
|
464
|
+
signerType?: SignerType | null;
|
|
465
|
+
/** Access token for API authentication. Always present after successful login. */
|
|
466
|
+
accessToken: string;
|
|
467
|
+
}
|
|
468
|
+
interface UseVolrLoginReturn {
|
|
469
|
+
requestEmailCode: (email: string) => Promise<void>;
|
|
470
|
+
verifyEmailCode: (email: string, code: string) => Promise<AuthResult>;
|
|
471
|
+
handleSocialLogin: (provider: SocialProvider) => Promise<void>;
|
|
472
|
+
requestSiweNonce: () => Promise<string>;
|
|
473
|
+
verifySiweSignature: (message: string, signature: string, options?: {
|
|
474
|
+
walletConnector?: string;
|
|
475
|
+
chainId?: number;
|
|
476
|
+
}) => Promise<AuthResult>;
|
|
477
|
+
handlePasskeyComplete: () => Promise<void>;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* useVolrLogin hook
|
|
481
|
+
* Provides login handlers for email, social, wallet, and passkey authentication
|
|
482
|
+
*/
|
|
483
|
+
declare function useVolrLogin(): UseVolrLoginReturn;
|
|
484
|
+
|
|
485
|
+
type Erc20Token = {
|
|
486
|
+
address: `0x${string}`;
|
|
487
|
+
decimals: number;
|
|
488
|
+
};
|
|
489
|
+
type DepositAsset = {
|
|
490
|
+
kind: "native";
|
|
491
|
+
} | {
|
|
492
|
+
kind: "erc20";
|
|
493
|
+
token: Erc20Token;
|
|
494
|
+
};
|
|
495
|
+
type DepositStatus = {
|
|
496
|
+
state: "idle";
|
|
497
|
+
} | {
|
|
498
|
+
state: "listening";
|
|
499
|
+
balance: bigint;
|
|
500
|
+
} | {
|
|
501
|
+
state: "detected";
|
|
502
|
+
previousBalance: bigint;
|
|
503
|
+
newBalance: bigint;
|
|
504
|
+
delta: bigint;
|
|
505
|
+
} | {
|
|
506
|
+
state: "error";
|
|
507
|
+
message: string;
|
|
508
|
+
};
|
|
509
|
+
declare function useDepositListener(input: {
|
|
510
|
+
chainId: number;
|
|
511
|
+
asset: DepositAsset;
|
|
512
|
+
address: `0x${string}`;
|
|
513
|
+
pollIntervalMs?: number;
|
|
514
|
+
}): DepositStatus;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* usePasskeyEnrollment hook
|
|
518
|
+
* React-specific logic for passkey enrollment
|
|
519
|
+
*/
|
|
520
|
+
type PasskeyEnrollmentStep = 'idle' | 'creating' | 'encrypting' | 'uploading' | 'registering';
|
|
521
|
+
interface UsePasskeyEnrollmentReturn {
|
|
522
|
+
/** Start passkey enrollment */
|
|
523
|
+
enroll: () => Promise<void>;
|
|
524
|
+
/** Current enrollment step */
|
|
525
|
+
step: PasskeyEnrollmentStep;
|
|
526
|
+
/** Whether enrollment is in progress */
|
|
527
|
+
isEnrolling: boolean;
|
|
528
|
+
/** Error message if enrollment failed */
|
|
529
|
+
error: Error | null;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* usePasskeyEnrollment hook
|
|
533
|
+
* Provides passkey enrollment functionality
|
|
534
|
+
*/
|
|
535
|
+
declare function usePasskeyEnrollment(): UsePasskeyEnrollmentReturn;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* useMpcConnection hook
|
|
539
|
+
* React-specific logic for MPC connection
|
|
540
|
+
*/
|
|
541
|
+
type MpcConnectionStep = 'idle' | 'connecting' | 'registering';
|
|
542
|
+
interface UseMpcConnectionReturn {
|
|
543
|
+
/** Start MPC connection */
|
|
544
|
+
connect: () => Promise<void>;
|
|
545
|
+
/** Current connection step */
|
|
546
|
+
step: MpcConnectionStep;
|
|
547
|
+
/** Whether connection is in progress */
|
|
548
|
+
isConnecting: boolean;
|
|
549
|
+
/** Error message if connection failed */
|
|
550
|
+
error: Error | null;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* useMpcConnection hook
|
|
554
|
+
* Provides MPC connection functionality
|
|
555
|
+
*/
|
|
556
|
+
declare function useMpcConnection(): UseMpcConnectionReturn;
|
|
557
|
+
|
|
558
|
+
declare function uploadBlobViaPresign(params: {
|
|
559
|
+
baseUrl: string;
|
|
560
|
+
apiKey: string;
|
|
561
|
+
blob: Blob;
|
|
562
|
+
contentType?: string;
|
|
563
|
+
}): Promise<{
|
|
564
|
+
s3Key: string;
|
|
565
|
+
}>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* useInternalAuth hook - Access internal auth context
|
|
569
|
+
*/
|
|
570
|
+
/**
|
|
571
|
+
* Get internal auth context value
|
|
572
|
+
* @throws Error if used outside VolrProvider
|
|
573
|
+
*/
|
|
574
|
+
declare function useInternalAuth(): InternalAuthContextType;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Passkey adapter for WebAuthn
|
|
578
|
+
* Implements PasskeyProviderPort interface
|
|
579
|
+
*/
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Passkey adapter options
|
|
583
|
+
*/
|
|
584
|
+
type PasskeyAdapterOptions = {
|
|
585
|
+
rpId?: string;
|
|
586
|
+
rpName?: string;
|
|
587
|
+
userDisplayName?: string;
|
|
588
|
+
userHandle?: Uint8Array;
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Create passkey adapter
|
|
592
|
+
*/
|
|
593
|
+
declare function createPasskeyAdapter(options?: PasskeyAdapterOptions): PasskeyProviderPort;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Default constants for wallet facade
|
|
597
|
+
*/
|
|
598
|
+
/**
|
|
599
|
+
* Default session expiry time in seconds (15 minutes)
|
|
600
|
+
*/
|
|
601
|
+
declare const DEFAULT_EXPIRES_IN_SEC = 900;
|
|
602
|
+
/**
|
|
603
|
+
* Default relay mode
|
|
604
|
+
*/
|
|
605
|
+
declare const DEFAULT_MODE: 'sponsored' | 'self';
|
|
606
|
+
/**
|
|
607
|
+
* Generate default idempotency key
|
|
608
|
+
* Uses crypto.randomUUID() if available, otherwise falls back to time+random
|
|
609
|
+
*/
|
|
610
|
+
declare function defaultIdempotencyKey(): string;
|
|
611
|
+
|
|
612
|
+
type NetworkInfo = {
|
|
613
|
+
name: string;
|
|
614
|
+
rpcUrl?: string;
|
|
615
|
+
};
|
|
616
|
+
type CreateGetNetworkInfoDeps = {
|
|
617
|
+
client: APIClient;
|
|
618
|
+
rpcOverrides?: Record<string, string>;
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* Factory to create a getNetworkInfo resolver bound to provided deps.
|
|
622
|
+
* Returns chain name and optionally RPC URL.
|
|
623
|
+
* Priority: 1) rpcOverrides (for RPC URL) 2) Backend API (cached)
|
|
624
|
+
*/
|
|
625
|
+
declare function createGetNetworkInfo(deps: CreateGetNetworkInfoDeps): (chainId: number, includeRpcUrl?: boolean) => Promise<NetworkInfo>;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Hex string normalization utilities
|
|
629
|
+
*/
|
|
630
|
+
/**
|
|
631
|
+
* Normalize hex string to lowercase with 0x prefix
|
|
632
|
+
* Ensures consistent format for hashing and comparison
|
|
633
|
+
*/
|
|
634
|
+
declare function normalizeHex(value: `0x${string}` | string): `0x${string}`;
|
|
635
|
+
/**
|
|
636
|
+
* Normalize multiple hex strings
|
|
637
|
+
*/
|
|
638
|
+
declare function normalizeHexArray(values: (`0x${string}` | string)[]): `0x${string}`[];
|
|
639
|
+
|
|
640
|
+
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type Erc20Token$1 as Erc20Token, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, type PrfInputDto, type SendTxOptions, type SignerType, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UsePrecheckReturn, type UseRelayReturn, type UseVolrLoginReturn, type UseVolrWalletReturn, type UserDto, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, buildCall, buildCalls, createGetNetworkInfo, createPasskeyAdapter, defaultIdempotencyKey, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useVolr, useVolrLogin, useVolrWallet };
|