@volr/react 0.1.48 → 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 +86 -54
- package/dist/index.cjs +29 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -79
- package/dist/index.d.ts +68 -79
- package/dist/index.js +30 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { KeyStorageType as KeyStorageType$1, WalletProviderPort, PrecheckInput, PrecheckQuote, RelayInput, RelayResult,
|
|
3
|
+
import { KeyStorageType as KeyStorageType$1, WalletProviderPort, PrecheckInput, PrecheckQuote, RelayInput, RelayResult, Call, PasskeyProviderPort } from '@volr/sdk-core';
|
|
4
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
5
|
import { Address, Abi, PublicClient } from 'viem';
|
|
6
6
|
|
|
@@ -270,53 +270,6 @@ type VolrProviderProps = {
|
|
|
270
270
|
*/
|
|
271
271
|
declare function VolrProvider({ config, children }: VolrProviderProps): react_jsx_runtime.JSX.Element;
|
|
272
272
|
|
|
273
|
-
/**
|
|
274
|
-
* useVolr hook - Access Volr context
|
|
275
|
-
*/
|
|
276
|
-
/**
|
|
277
|
-
* Get Volr context value
|
|
278
|
-
* @throws Error if used outside VolrProvider
|
|
279
|
-
*/
|
|
280
|
-
declare function useVolr(): VolrContextValue;
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* usePrecheck hook - Precheck transaction batch
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* usePrecheck return type
|
|
288
|
-
*/
|
|
289
|
-
type UsePrecheckReturn = {
|
|
290
|
-
precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
|
|
291
|
-
isLoading: boolean;
|
|
292
|
-
error: Error | null;
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* usePrecheck hook
|
|
296
|
-
*/
|
|
297
|
-
declare function usePrecheck(): UsePrecheckReturn;
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* useRelay hook - Relay transaction batch
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* useRelay return type
|
|
305
|
-
*/
|
|
306
|
-
type UseRelayReturn = {
|
|
307
|
-
relay: (input: Omit<RelayInput, "sessionSig" | "authorizationList">, opts?: {
|
|
308
|
-
signer: SignerPort;
|
|
309
|
-
rpcClient?: ExtendedRPCClient;
|
|
310
|
-
idempotencyKey?: string;
|
|
311
|
-
}) => Promise<RelayResult>;
|
|
312
|
-
isLoading: boolean;
|
|
313
|
-
error: Error | null;
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* useRelay hook
|
|
317
|
-
*/
|
|
318
|
-
declare function useRelay(): UseRelayReturn;
|
|
319
|
-
|
|
320
273
|
/**
|
|
321
274
|
* Call builder utilities for better developer experience
|
|
322
275
|
*/
|
|
@@ -400,7 +353,7 @@ type SendTxOptions = {
|
|
|
400
353
|
};
|
|
401
354
|
|
|
402
355
|
/**
|
|
403
|
-
*
|
|
356
|
+
* useVolr hook - Main developer-facing hook for Volr SDK
|
|
404
357
|
*/
|
|
405
358
|
|
|
406
359
|
/**
|
|
@@ -410,46 +363,43 @@ type SendBatchOverloads = {
|
|
|
410
363
|
/**
|
|
411
364
|
* Send a batch of pre-built Call objects
|
|
412
365
|
* @param calls - Array of Call objects with target, data, value, gasLimit
|
|
413
|
-
* @param opts -
|
|
366
|
+
* @param opts - Optional transaction options including expiresInSec, from
|
|
414
367
|
* @example
|
|
415
368
|
* ```ts
|
|
416
369
|
* const calls: Call[] = [
|
|
417
370
|
* { target: '0x...', data: '0x...', value: 0n, gasLimit: 100000n }
|
|
418
371
|
* ];
|
|
419
|
-
* await evm(chainId).sendBatch(calls
|
|
372
|
+
* await evm(chainId).sendBatch(calls);
|
|
420
373
|
* ```
|
|
421
374
|
*/
|
|
422
|
-
(calls: Call[], opts
|
|
375
|
+
(calls: Call[], opts?: SendTxOptions & {
|
|
423
376
|
from?: `0x${string}`;
|
|
424
377
|
}): Promise<RelayResult>;
|
|
425
378
|
/**
|
|
426
379
|
* Send a batch by providing BuildCallOptions - calls will be built internally
|
|
427
380
|
* @param calls - Array of BuildCallOptions with target, abi, functionName, args
|
|
428
|
-
* @param opts -
|
|
381
|
+
* @param opts - Optional transaction options including expiresInSec, from
|
|
429
382
|
* @example
|
|
430
383
|
* ```ts
|
|
431
|
-
* await evm(chainId).sendBatch(
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* ],
|
|
441
|
-
* { policyId: '0x...' }
|
|
442
|
-
* );
|
|
384
|
+
* await evm(chainId).sendBatch([
|
|
385
|
+
* {
|
|
386
|
+
* target: tokenAddress,
|
|
387
|
+
* abi: erc20Abi,
|
|
388
|
+
* functionName: 'transfer',
|
|
389
|
+
* args: [recipient, amount],
|
|
390
|
+
* gasLimit: 100000n,
|
|
391
|
+
* }
|
|
392
|
+
* ]);
|
|
443
393
|
* ```
|
|
444
394
|
*/
|
|
445
|
-
(calls: BuildCallOptions[], opts
|
|
395
|
+
(calls: BuildCallOptions[], opts?: SendTxOptions & {
|
|
446
396
|
from?: `0x${string}`;
|
|
447
397
|
}): Promise<RelayResult>;
|
|
448
398
|
};
|
|
449
399
|
/**
|
|
450
|
-
* EVM
|
|
400
|
+
* EVM client interface
|
|
451
401
|
*/
|
|
452
|
-
type
|
|
402
|
+
type EvmClient = {
|
|
453
403
|
/**
|
|
454
404
|
* Read data from a smart contract
|
|
455
405
|
* @example
|
|
@@ -471,8 +421,7 @@ type EvmChainOperations = {
|
|
|
471
421
|
* @example
|
|
472
422
|
* ```ts
|
|
473
423
|
* const result = await evm(1).sendTransaction(
|
|
474
|
-
* { to: '0x...', data: '0x...'
|
|
475
|
-
* { policyId: '0x...' }
|
|
424
|
+
* { to: '0x...', data: '0x...' },
|
|
476
425
|
* );
|
|
477
426
|
* ```
|
|
478
427
|
*/
|
|
@@ -480,27 +429,67 @@ type EvmChainOperations = {
|
|
|
480
429
|
to: `0x${string}`;
|
|
481
430
|
data: `0x${string}`;
|
|
482
431
|
value?: bigint;
|
|
483
|
-
|
|
432
|
+
gasLimit?: bigint;
|
|
433
|
+
}, opts?: SendTxOptions) => Promise<RelayResult>;
|
|
484
434
|
/**
|
|
485
435
|
* Send a batch of transactions
|
|
486
436
|
*/
|
|
487
437
|
sendBatch: SendBatchOverloads;
|
|
488
438
|
};
|
|
489
439
|
/**
|
|
490
|
-
*
|
|
440
|
+
* Volr client interface
|
|
491
441
|
*/
|
|
492
|
-
type
|
|
442
|
+
type VolrClient = {
|
|
493
443
|
/**
|
|
494
|
-
* Get EVM
|
|
444
|
+
* Get EVM client for a specific chain
|
|
495
445
|
* @param chainId - The chain ID to operate on
|
|
496
|
-
* @returns EVM
|
|
446
|
+
* @returns EVM client interface
|
|
447
|
+
*/
|
|
448
|
+
evm: (chainId: number) => EvmClient;
|
|
449
|
+
/**
|
|
450
|
+
* User's EVM wallet address
|
|
451
|
+
*/
|
|
452
|
+
address: `0x${string}` | undefined;
|
|
453
|
+
/**
|
|
454
|
+
* User's email (if logged in with email)
|
|
455
|
+
*/
|
|
456
|
+
email: string | undefined;
|
|
457
|
+
/**
|
|
458
|
+
* Whether user is logged in
|
|
459
|
+
*/
|
|
460
|
+
isLoggedIn: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* How the user signs transactions
|
|
463
|
+
*/
|
|
464
|
+
signerType: SignerType | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Logout the user
|
|
497
467
|
*/
|
|
498
|
-
|
|
468
|
+
logout: () => Promise<void>;
|
|
469
|
+
/**
|
|
470
|
+
* Whether SDK is loading
|
|
471
|
+
*/
|
|
472
|
+
isLoading: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Error if any
|
|
475
|
+
*/
|
|
476
|
+
error: Error | null;
|
|
499
477
|
};
|
|
500
478
|
/**
|
|
501
|
-
*
|
|
479
|
+
* useVolr hook - Main developer-facing hook
|
|
480
|
+
*/
|
|
481
|
+
declare function useVolr(): VolrClient;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* useVolrContext hook - Internal access to Volr context
|
|
485
|
+
* @internal This hook is for SDK internal use only. Use useVolr instead.
|
|
486
|
+
*/
|
|
487
|
+
/**
|
|
488
|
+
* Get full Volr context value (internal use only)
|
|
489
|
+
* @throws Error if used outside VolrProvider
|
|
490
|
+
* @internal
|
|
502
491
|
*/
|
|
503
|
-
declare function
|
|
492
|
+
declare function useVolrContext(): VolrContextValue;
|
|
504
493
|
|
|
505
494
|
/**
|
|
506
495
|
* useVolrLogin hook - Login handlers for various authentication methods
|
|
@@ -835,4 +824,4 @@ declare function debugTransactionFailure(publicClient: PublicClient, failingWall
|
|
|
835
824
|
analysis: string[];
|
|
836
825
|
}>;
|
|
837
826
|
|
|
838
|
-
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type
|
|
827
|
+
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, type PrfInputDto, type SendBatchOverloads, type SendTxOptions, type SignerType, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getWalletState, isEIP7702Delegated, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { KeyStorageType as KeyStorageType$1, WalletProviderPort, PrecheckInput, PrecheckQuote, RelayInput, RelayResult,
|
|
3
|
+
import { KeyStorageType as KeyStorageType$1, WalletProviderPort, PrecheckInput, PrecheckQuote, RelayInput, RelayResult, Call, PasskeyProviderPort } from '@volr/sdk-core';
|
|
4
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
5
|
import { Address, Abi, PublicClient } from 'viem';
|
|
6
6
|
|
|
@@ -270,53 +270,6 @@ type VolrProviderProps = {
|
|
|
270
270
|
*/
|
|
271
271
|
declare function VolrProvider({ config, children }: VolrProviderProps): react_jsx_runtime.JSX.Element;
|
|
272
272
|
|
|
273
|
-
/**
|
|
274
|
-
* useVolr hook - Access Volr context
|
|
275
|
-
*/
|
|
276
|
-
/**
|
|
277
|
-
* Get Volr context value
|
|
278
|
-
* @throws Error if used outside VolrProvider
|
|
279
|
-
*/
|
|
280
|
-
declare function useVolr(): VolrContextValue;
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* usePrecheck hook - Precheck transaction batch
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* usePrecheck return type
|
|
288
|
-
*/
|
|
289
|
-
type UsePrecheckReturn = {
|
|
290
|
-
precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
|
|
291
|
-
isLoading: boolean;
|
|
292
|
-
error: Error | null;
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* usePrecheck hook
|
|
296
|
-
*/
|
|
297
|
-
declare function usePrecheck(): UsePrecheckReturn;
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* useRelay hook - Relay transaction batch
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* useRelay return type
|
|
305
|
-
*/
|
|
306
|
-
type UseRelayReturn = {
|
|
307
|
-
relay: (input: Omit<RelayInput, "sessionSig" | "authorizationList">, opts?: {
|
|
308
|
-
signer: SignerPort;
|
|
309
|
-
rpcClient?: ExtendedRPCClient;
|
|
310
|
-
idempotencyKey?: string;
|
|
311
|
-
}) => Promise<RelayResult>;
|
|
312
|
-
isLoading: boolean;
|
|
313
|
-
error: Error | null;
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* useRelay hook
|
|
317
|
-
*/
|
|
318
|
-
declare function useRelay(): UseRelayReturn;
|
|
319
|
-
|
|
320
273
|
/**
|
|
321
274
|
* Call builder utilities for better developer experience
|
|
322
275
|
*/
|
|
@@ -400,7 +353,7 @@ type SendTxOptions = {
|
|
|
400
353
|
};
|
|
401
354
|
|
|
402
355
|
/**
|
|
403
|
-
*
|
|
356
|
+
* useVolr hook - Main developer-facing hook for Volr SDK
|
|
404
357
|
*/
|
|
405
358
|
|
|
406
359
|
/**
|
|
@@ -410,46 +363,43 @@ type SendBatchOverloads = {
|
|
|
410
363
|
/**
|
|
411
364
|
* Send a batch of pre-built Call objects
|
|
412
365
|
* @param calls - Array of Call objects with target, data, value, gasLimit
|
|
413
|
-
* @param opts -
|
|
366
|
+
* @param opts - Optional transaction options including expiresInSec, from
|
|
414
367
|
* @example
|
|
415
368
|
* ```ts
|
|
416
369
|
* const calls: Call[] = [
|
|
417
370
|
* { target: '0x...', data: '0x...', value: 0n, gasLimit: 100000n }
|
|
418
371
|
* ];
|
|
419
|
-
* await evm(chainId).sendBatch(calls
|
|
372
|
+
* await evm(chainId).sendBatch(calls);
|
|
420
373
|
* ```
|
|
421
374
|
*/
|
|
422
|
-
(calls: Call[], opts
|
|
375
|
+
(calls: Call[], opts?: SendTxOptions & {
|
|
423
376
|
from?: `0x${string}`;
|
|
424
377
|
}): Promise<RelayResult>;
|
|
425
378
|
/**
|
|
426
379
|
* Send a batch by providing BuildCallOptions - calls will be built internally
|
|
427
380
|
* @param calls - Array of BuildCallOptions with target, abi, functionName, args
|
|
428
|
-
* @param opts -
|
|
381
|
+
* @param opts - Optional transaction options including expiresInSec, from
|
|
429
382
|
* @example
|
|
430
383
|
* ```ts
|
|
431
|
-
* await evm(chainId).sendBatch(
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* ],
|
|
441
|
-
* { policyId: '0x...' }
|
|
442
|
-
* );
|
|
384
|
+
* await evm(chainId).sendBatch([
|
|
385
|
+
* {
|
|
386
|
+
* target: tokenAddress,
|
|
387
|
+
* abi: erc20Abi,
|
|
388
|
+
* functionName: 'transfer',
|
|
389
|
+
* args: [recipient, amount],
|
|
390
|
+
* gasLimit: 100000n,
|
|
391
|
+
* }
|
|
392
|
+
* ]);
|
|
443
393
|
* ```
|
|
444
394
|
*/
|
|
445
|
-
(calls: BuildCallOptions[], opts
|
|
395
|
+
(calls: BuildCallOptions[], opts?: SendTxOptions & {
|
|
446
396
|
from?: `0x${string}`;
|
|
447
397
|
}): Promise<RelayResult>;
|
|
448
398
|
};
|
|
449
399
|
/**
|
|
450
|
-
* EVM
|
|
400
|
+
* EVM client interface
|
|
451
401
|
*/
|
|
452
|
-
type
|
|
402
|
+
type EvmClient = {
|
|
453
403
|
/**
|
|
454
404
|
* Read data from a smart contract
|
|
455
405
|
* @example
|
|
@@ -471,8 +421,7 @@ type EvmChainOperations = {
|
|
|
471
421
|
* @example
|
|
472
422
|
* ```ts
|
|
473
423
|
* const result = await evm(1).sendTransaction(
|
|
474
|
-
* { to: '0x...', data: '0x...'
|
|
475
|
-
* { policyId: '0x...' }
|
|
424
|
+
* { to: '0x...', data: '0x...' },
|
|
476
425
|
* );
|
|
477
426
|
* ```
|
|
478
427
|
*/
|
|
@@ -480,27 +429,67 @@ type EvmChainOperations = {
|
|
|
480
429
|
to: `0x${string}`;
|
|
481
430
|
data: `0x${string}`;
|
|
482
431
|
value?: bigint;
|
|
483
|
-
|
|
432
|
+
gasLimit?: bigint;
|
|
433
|
+
}, opts?: SendTxOptions) => Promise<RelayResult>;
|
|
484
434
|
/**
|
|
485
435
|
* Send a batch of transactions
|
|
486
436
|
*/
|
|
487
437
|
sendBatch: SendBatchOverloads;
|
|
488
438
|
};
|
|
489
439
|
/**
|
|
490
|
-
*
|
|
440
|
+
* Volr client interface
|
|
491
441
|
*/
|
|
492
|
-
type
|
|
442
|
+
type VolrClient = {
|
|
493
443
|
/**
|
|
494
|
-
* Get EVM
|
|
444
|
+
* Get EVM client for a specific chain
|
|
495
445
|
* @param chainId - The chain ID to operate on
|
|
496
|
-
* @returns EVM
|
|
446
|
+
* @returns EVM client interface
|
|
447
|
+
*/
|
|
448
|
+
evm: (chainId: number) => EvmClient;
|
|
449
|
+
/**
|
|
450
|
+
* User's EVM wallet address
|
|
451
|
+
*/
|
|
452
|
+
address: `0x${string}` | undefined;
|
|
453
|
+
/**
|
|
454
|
+
* User's email (if logged in with email)
|
|
455
|
+
*/
|
|
456
|
+
email: string | undefined;
|
|
457
|
+
/**
|
|
458
|
+
* Whether user is logged in
|
|
459
|
+
*/
|
|
460
|
+
isLoggedIn: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* How the user signs transactions
|
|
463
|
+
*/
|
|
464
|
+
signerType: SignerType | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Logout the user
|
|
497
467
|
*/
|
|
498
|
-
|
|
468
|
+
logout: () => Promise<void>;
|
|
469
|
+
/**
|
|
470
|
+
* Whether SDK is loading
|
|
471
|
+
*/
|
|
472
|
+
isLoading: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Error if any
|
|
475
|
+
*/
|
|
476
|
+
error: Error | null;
|
|
499
477
|
};
|
|
500
478
|
/**
|
|
501
|
-
*
|
|
479
|
+
* useVolr hook - Main developer-facing hook
|
|
480
|
+
*/
|
|
481
|
+
declare function useVolr(): VolrClient;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* useVolrContext hook - Internal access to Volr context
|
|
485
|
+
* @internal This hook is for SDK internal use only. Use useVolr instead.
|
|
486
|
+
*/
|
|
487
|
+
/**
|
|
488
|
+
* Get full Volr context value (internal use only)
|
|
489
|
+
* @throws Error if used outside VolrProvider
|
|
490
|
+
* @internal
|
|
502
491
|
*/
|
|
503
|
-
declare function
|
|
492
|
+
declare function useVolrContext(): VolrContextValue;
|
|
504
493
|
|
|
505
494
|
/**
|
|
506
495
|
* useVolrLogin hook - Login handlers for various authentication methods
|
|
@@ -835,4 +824,4 @@ declare function debugTransactionFailure(publicClient: PublicClient, failingWall
|
|
|
835
824
|
analysis: string[];
|
|
836
825
|
}>;
|
|
837
826
|
|
|
838
|
-
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type
|
|
827
|
+
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, type PrfInputDto, type SendBatchOverloads, type SendTxOptions, type SignerType, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getWalletState, isEIP7702Delegated, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as nc from 'crypto';
|
|
2
2
|
import { createContext, useRef, useEffect, useMemo, useState, useCallback, useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { createPasskeyProvider, createMpcProvider, signSession, getAuthNonce, signAuthorization, deriveWrapKey, createMasterKeyProvider, sealMasterSeed, uploadBlob, deriveEvmKey, ZERO_HASH, selectSigner, VolrError } from '@volr/sdk-core';
|
|
4
4
|
export { createMasterKeyProvider, createMpcProvider, createPasskeyProvider, deriveEvmKey, deriveWrapKey, sealMasterSeed, uploadBlob } from '@volr/sdk-core';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -10080,10 +10080,10 @@ function VolrProvider({ config, children }) {
|
|
|
10080
10080
|
);
|
|
10081
10081
|
return /* @__PURE__ */ jsx(VolrContext.Provider, { value: publicValue, children: /* @__PURE__ */ jsx(InternalAuthContext.Provider, { value: internalValue, children }) });
|
|
10082
10082
|
}
|
|
10083
|
-
function
|
|
10083
|
+
function useVolrContext() {
|
|
10084
10084
|
const context = useContext(VolrContext);
|
|
10085
10085
|
if (!context) {
|
|
10086
|
-
throw new Error("
|
|
10086
|
+
throw new Error("useVolrContext must be used within VolrProvider");
|
|
10087
10087
|
}
|
|
10088
10088
|
return context;
|
|
10089
10089
|
}
|
|
@@ -10165,7 +10165,7 @@ function validateRelayInput(input, config = {}) {
|
|
|
10165
10165
|
|
|
10166
10166
|
// src/hooks/usePrecheck.ts
|
|
10167
10167
|
function usePrecheck() {
|
|
10168
|
-
const { precheck: precheckContext } =
|
|
10168
|
+
const { precheck: precheckContext } = useVolrContext();
|
|
10169
10169
|
const [isLoading, setIsLoading] = useState(false);
|
|
10170
10170
|
const [error, setError] = useState(null);
|
|
10171
10171
|
const precheck = useCallback(
|
|
@@ -10199,7 +10199,7 @@ function useInternalAuth() {
|
|
|
10199
10199
|
return context;
|
|
10200
10200
|
}
|
|
10201
10201
|
function useRelay() {
|
|
10202
|
-
const { relay: relayContext } =
|
|
10202
|
+
const { relay: relayContext } = useVolrContext();
|
|
10203
10203
|
const { client } = useInternalAuth();
|
|
10204
10204
|
const [isLoading, setIsLoading] = useState(false);
|
|
10205
10205
|
const [error, setError] = useState(null);
|
|
@@ -10255,7 +10255,7 @@ function useRelay() {
|
|
|
10255
10255
|
authorizationList: [authorizationTuple]
|
|
10256
10256
|
};
|
|
10257
10257
|
validateRelayInput(relayInput);
|
|
10258
|
-
return
|
|
10258
|
+
return relayContext(relayInput, {
|
|
10259
10259
|
idempotencyKey: opts.idempotencyKey
|
|
10260
10260
|
});
|
|
10261
10261
|
} catch (err) {
|
|
@@ -18359,9 +18359,9 @@ async function sendCalls(args) {
|
|
|
18359
18359
|
}
|
|
18360
18360
|
}
|
|
18361
18361
|
|
|
18362
|
-
// src/hooks/
|
|
18363
|
-
function
|
|
18364
|
-
const { user, config, provider, setProvider } =
|
|
18362
|
+
// src/hooks/useVolr.ts
|
|
18363
|
+
function useVolr() {
|
|
18364
|
+
const { user, config, provider, setProvider, logout, isLoading, error } = useVolrContext();
|
|
18365
18365
|
const { precheck } = usePrecheck();
|
|
18366
18366
|
const { relay } = useRelay();
|
|
18367
18367
|
const { client } = useInternalAuth();
|
|
@@ -18378,14 +18378,11 @@ function useVolrWallet() {
|
|
|
18378
18378
|
let extendedRpcClient = null;
|
|
18379
18379
|
const ensureRpcClient = async () => {
|
|
18380
18380
|
if (!publicClient) {
|
|
18381
|
-
console.log("[ensureRpcClient] Getting RPC URL for chainId:", chainId);
|
|
18382
18381
|
const rpcUrl = await getRpcUrl(chainId);
|
|
18383
|
-
console.log("[ensureRpcClient] Got RPC URL:", rpcUrl);
|
|
18384
18382
|
publicClient = createPublicClient({
|
|
18385
18383
|
transport: http(rpcUrl)
|
|
18386
18384
|
});
|
|
18387
18385
|
extendedRpcClient = createExtendedRPCClient(publicClient);
|
|
18388
|
-
console.log("[ensureRpcClient] Public client created");
|
|
18389
18386
|
}
|
|
18390
18387
|
return { publicClient, extendedRpcClient };
|
|
18391
18388
|
};
|
|
@@ -18394,12 +18391,12 @@ function useVolrWallet() {
|
|
|
18394
18391
|
const { publicClient: client2 } = await ensureRpcClient();
|
|
18395
18392
|
return client2.readContract(args);
|
|
18396
18393
|
},
|
|
18397
|
-
sendTransaction: async (tx, opts) => {
|
|
18394
|
+
sendTransaction: async (tx, opts = {}) => {
|
|
18398
18395
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
18399
18396
|
const from14 = opts.from ?? user?.evmAddress;
|
|
18400
18397
|
if (!from14) {
|
|
18401
18398
|
throw new Error(
|
|
18402
|
-
"from address is required. Provide it in opts.from or
|
|
18399
|
+
"from address is required. Provide it in opts.from or ensure user is logged in."
|
|
18403
18400
|
);
|
|
18404
18401
|
}
|
|
18405
18402
|
const call2 = {
|
|
@@ -18425,25 +18422,18 @@ function useVolrWallet() {
|
|
|
18425
18422
|
}
|
|
18426
18423
|
});
|
|
18427
18424
|
},
|
|
18428
|
-
sendBatch: (async (calls, opts) => {
|
|
18429
|
-
console.log("[sendBatch] Starting sendBatch...", { chainId, callsCount: calls.length });
|
|
18430
|
-
console.log("[sendBatch] Ensuring RPC client...");
|
|
18425
|
+
sendBatch: (async (calls, opts = {}) => {
|
|
18431
18426
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
18432
|
-
console.log("[sendBatch] RPC client ready");
|
|
18433
18427
|
const from14 = opts.from ?? user?.evmAddress;
|
|
18434
|
-
console.log("[sendBatch] From address:", from14);
|
|
18435
18428
|
if (!from14) {
|
|
18436
18429
|
throw new Error(
|
|
18437
|
-
"from address is required. Provide it in opts.from or
|
|
18430
|
+
"from address is required. Provide it in opts.from or ensure user is logged in."
|
|
18438
18431
|
);
|
|
18439
18432
|
}
|
|
18440
18433
|
const isCallArray = (calls2) => {
|
|
18441
18434
|
return Array.isArray(calls2) && calls2.length > 0 && "data" in calls2[0] && !("abi" in calls2[0]);
|
|
18442
18435
|
};
|
|
18443
|
-
console.log("[sendBatch] Building calls...");
|
|
18444
18436
|
const builtCalls = isCallArray(calls) ? calls : buildCalls(calls);
|
|
18445
|
-
console.log("[sendBatch] Calls built:", builtCalls.length);
|
|
18446
|
-
console.log("[sendBatch] Calling sendCalls...");
|
|
18447
18437
|
return sendCalls({
|
|
18448
18438
|
chainId,
|
|
18449
18439
|
from: getAddress(from14),
|
|
@@ -18468,12 +18458,21 @@ function useVolrWallet() {
|
|
|
18468
18458
|
})
|
|
18469
18459
|
};
|
|
18470
18460
|
},
|
|
18471
|
-
[user, config, provider, precheck, relay, getRpcUrl]
|
|
18461
|
+
[user, config, provider, precheck, relay, getRpcUrl, setProvider, client]
|
|
18472
18462
|
);
|
|
18473
|
-
return {
|
|
18463
|
+
return {
|
|
18464
|
+
evm,
|
|
18465
|
+
address: user?.evmAddress,
|
|
18466
|
+
email: user?.email,
|
|
18467
|
+
isLoggedIn: user !== null,
|
|
18468
|
+
signerType: user?.signerType,
|
|
18469
|
+
logout,
|
|
18470
|
+
isLoading,
|
|
18471
|
+
error
|
|
18472
|
+
};
|
|
18474
18473
|
}
|
|
18475
18474
|
function useVolrLogin() {
|
|
18476
|
-
const { config, setUser } =
|
|
18475
|
+
const { config, setUser } = useVolrContext();
|
|
18477
18476
|
const { setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
18478
18477
|
const toVolrUser = useCallback((u) => {
|
|
18479
18478
|
return {
|
|
@@ -18640,7 +18639,7 @@ function createAxiosInstance(baseUrl, apiKey) {
|
|
|
18640
18639
|
|
|
18641
18640
|
// src/hooks/useVolrAuthCallback.ts
|
|
18642
18641
|
function useVolrAuthCallback(options = {}) {
|
|
18643
|
-
const { config, setUser } =
|
|
18642
|
+
const { config, setUser } = useVolrContext();
|
|
18644
18643
|
const { refreshAccessToken, setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
18645
18644
|
const [isLoading, setIsLoading] = useState(true);
|
|
18646
18645
|
const [error, setError] = useState(null);
|
|
@@ -18765,7 +18764,7 @@ function balanceOfCalldata(address) {
|
|
|
18765
18764
|
return `${selector}${pad32(address).slice(2)}`;
|
|
18766
18765
|
}
|
|
18767
18766
|
function useDepositListener(input) {
|
|
18768
|
-
const { config } =
|
|
18767
|
+
const { config } = useVolrContext();
|
|
18769
18768
|
const { client } = useInternalAuth();
|
|
18770
18769
|
const [status, setStatus] = useState({ state: "idle" });
|
|
18771
18770
|
const intervalRef = useRef(null);
|
|
@@ -19019,7 +19018,7 @@ async function enrollPasskey(params) {
|
|
|
19019
19018
|
}
|
|
19020
19019
|
}
|
|
19021
19020
|
function usePasskeyEnrollment() {
|
|
19022
|
-
const { config, setProvider, setUser, user } =
|
|
19021
|
+
const { config, setProvider, setUser, user } = useVolrContext();
|
|
19023
19022
|
const { client } = useInternalAuth();
|
|
19024
19023
|
const [step, setStep] = useState("idle");
|
|
19025
19024
|
const [isEnrolling, setIsEnrolling] = useState(false);
|
|
@@ -19208,7 +19207,7 @@ async function registerWalletProvider(params) {
|
|
|
19208
19207
|
});
|
|
19209
19208
|
}
|
|
19210
19209
|
function useMpcConnection() {
|
|
19211
|
-
const { setProvider } =
|
|
19210
|
+
const { setProvider } = useVolrContext();
|
|
19212
19211
|
const { client } = useInternalAuth();
|
|
19213
19212
|
const [step, setStep] = useState("idle");
|
|
19214
19213
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
@@ -19501,6 +19500,6 @@ async function debugTransactionFailure(publicClient, failingWallet, workingWalle
|
|
|
19501
19500
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19502
19501
|
*/
|
|
19503
19502
|
|
|
19504
|
-
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, VolrProvider, analyzeContractForEIP7702, buildCall, buildCalls, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getWalletState, isEIP7702Delegated, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment,
|
|
19503
|
+
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, VolrProvider, analyzeContractForEIP7702, buildCall, buildCalls, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getWalletState, isEIP7702Delegated, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
|
19505
19504
|
//# sourceMappingURL=index.js.map
|
|
19506
19505
|
//# sourceMappingURL=index.js.map
|