@volr/react 0.1.100 → 0.1.102
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 +62 -13
- package/dist/index.cjs +68 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -16
- package/dist/index.d.ts +62 -16
- package/dist/index.js +68 -59
- 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, Call,
|
|
3
|
+
import { KeyStorageType as KeyStorageType$1, TypedDataInput, 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
|
|
|
@@ -174,6 +174,22 @@ interface ApiResponse<T> {
|
|
|
174
174
|
|
|
175
175
|
type KeyStorageType = "passkey" | "mpc";
|
|
176
176
|
type SignerType = "passkey" | "external_wallet" | "mpc";
|
|
177
|
+
/**
|
|
178
|
+
* Sign request types for confirmation modal
|
|
179
|
+
*/
|
|
180
|
+
type SignRequest = {
|
|
181
|
+
type: "message";
|
|
182
|
+
message: string | Uint8Array;
|
|
183
|
+
} | {
|
|
184
|
+
type: "typedData";
|
|
185
|
+
typedData: TypedDataInput;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Callback for sign request confirmation
|
|
189
|
+
* Called before signing to allow UI to show confirmation modal
|
|
190
|
+
* Resolve to proceed, reject to cancel
|
|
191
|
+
*/
|
|
192
|
+
type OnSignRequest = (request: SignRequest) => Promise<void>;
|
|
177
193
|
|
|
178
194
|
/**
|
|
179
195
|
* ERC-20 token configuration
|
|
@@ -230,6 +246,13 @@ type VolrConfig = {
|
|
|
230
246
|
* Deposit/Topup configuration for multi-chain, multi-token support
|
|
231
247
|
*/
|
|
232
248
|
deposit?: DepositConfig;
|
|
249
|
+
/**
|
|
250
|
+
* Callback for sign request confirmation.
|
|
251
|
+
* If provided, this callback is called before signing to allow UI to show confirmation modal.
|
|
252
|
+
* The callback should resolve to proceed with signing, or reject to cancel.
|
|
253
|
+
* Used by @volr/react-ui to show sign confirmation modal.
|
|
254
|
+
*/
|
|
255
|
+
onSignRequest?: OnSignRequest;
|
|
233
256
|
};
|
|
234
257
|
/**
|
|
235
258
|
* Public context value
|
|
@@ -374,7 +397,7 @@ type SendBatchOverloads = {
|
|
|
374
397
|
* const calls: Call[] = [
|
|
375
398
|
* { target: '0x...', data: '0x...', value: 0n, gasLimit: 100000n }
|
|
376
399
|
* ];
|
|
377
|
-
* await evm(chainId).sendBatch(calls);
|
|
400
|
+
* await evm.client(chainId).sendBatch(calls);
|
|
378
401
|
* ```
|
|
379
402
|
*/
|
|
380
403
|
(calls: Call[], opts?: SendTxOptions & {
|
|
@@ -386,7 +409,7 @@ type SendBatchOverloads = {
|
|
|
386
409
|
* @param opts - Optional transaction options including expiresInSec, from
|
|
387
410
|
* @example
|
|
388
411
|
* ```ts
|
|
389
|
-
* await evm(chainId).sendBatch([
|
|
412
|
+
* await evm.client(chainId).sendBatch([
|
|
390
413
|
* {
|
|
391
414
|
* target: tokenAddress,
|
|
392
415
|
* abi: erc20Abi,
|
|
@@ -402,14 +425,14 @@ type SendBatchOverloads = {
|
|
|
402
425
|
}): Promise<RelayResult>;
|
|
403
426
|
};
|
|
404
427
|
/**
|
|
405
|
-
* EVM client interface
|
|
428
|
+
* EVM chain client interface (chain-specific operations)
|
|
406
429
|
*/
|
|
407
|
-
type
|
|
430
|
+
type EvmChainClient = {
|
|
408
431
|
/**
|
|
409
432
|
* Get native token balance for an address
|
|
410
433
|
* @example
|
|
411
434
|
* ```ts
|
|
412
|
-
* const balance = await evm(1).getBalance('0x...');
|
|
435
|
+
* const balance = await evm.client(1).getBalance('0x...');
|
|
413
436
|
* // Returns bigint (in wei)
|
|
414
437
|
* ```
|
|
415
438
|
*/
|
|
@@ -418,7 +441,7 @@ type EvmClient = {
|
|
|
418
441
|
* Read data from a smart contract
|
|
419
442
|
* @example
|
|
420
443
|
* ```ts
|
|
421
|
-
* const balance = await evm(1).readContract({
|
|
444
|
+
* const balance = await evm.client(1).readContract({
|
|
422
445
|
* address: tokenAddress,
|
|
423
446
|
* abi: erc20Abi,
|
|
424
447
|
* functionName: 'balanceOf',
|
|
@@ -434,7 +457,7 @@ type EvmClient = {
|
|
|
434
457
|
* Send a single transaction
|
|
435
458
|
* @example
|
|
436
459
|
* ```ts
|
|
437
|
-
* const result = await evm(1).sendTransaction(
|
|
460
|
+
* const result = await evm.client(1).sendTransaction(
|
|
438
461
|
* { to: '0x...', data: '0x...' },
|
|
439
462
|
* );
|
|
440
463
|
* ```
|
|
@@ -449,25 +472,37 @@ type EvmClient = {
|
|
|
449
472
|
* Send a batch of transactions
|
|
450
473
|
*/
|
|
451
474
|
sendBatch: SendBatchOverloads;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* EVM namespace interface (chain-agnostic operations)
|
|
478
|
+
*/
|
|
479
|
+
type EvmNamespace = {
|
|
480
|
+
/**
|
|
481
|
+
* User's EVM wallet address
|
|
482
|
+
* undefined if not logged in
|
|
483
|
+
*/
|
|
484
|
+
address: `0x${string}` | undefined;
|
|
452
485
|
/**
|
|
453
486
|
* Sign a message (EIP-191 personal_sign)
|
|
487
|
+
* This is chain-agnostic - uses the same private key regardless of chain
|
|
454
488
|
* @param message - String or bytes to sign
|
|
455
489
|
* @returns Signature hex string
|
|
456
490
|
* @example
|
|
457
491
|
* ```ts
|
|
458
|
-
* const signature = await evm
|
|
492
|
+
* const signature = await evm.signMessage('Hello, World!');
|
|
459
493
|
* // or with raw bytes
|
|
460
|
-
* const signature = await evm
|
|
494
|
+
* const signature = await evm.signMessage(new Uint8Array([1, 2, 3]));
|
|
461
495
|
* ```
|
|
462
496
|
*/
|
|
463
497
|
signMessage: (message: string | Uint8Array) => Promise<`0x${string}`>;
|
|
464
498
|
/**
|
|
465
499
|
* Sign EIP-712 typed data
|
|
500
|
+
* This is chain-agnostic - uses the same private key regardless of chain
|
|
466
501
|
* @param typedData - Typed data with domain, types, and message
|
|
467
502
|
* @returns Signature hex string
|
|
468
503
|
* @example
|
|
469
504
|
* ```ts
|
|
470
|
-
* const signature = await evm
|
|
505
|
+
* const signature = await evm.signTypedData({
|
|
471
506
|
* domain: {
|
|
472
507
|
* name: 'MyApp',
|
|
473
508
|
* version: '1',
|
|
@@ -482,19 +517,30 @@ type EvmClient = {
|
|
|
482
517
|
* ```
|
|
483
518
|
*/
|
|
484
519
|
signTypedData: (typedData: TypedDataInput) => Promise<`0x${string}`>;
|
|
520
|
+
/**
|
|
521
|
+
* Get chain-specific client for operations that require a chain
|
|
522
|
+
* @param chainId - The chain ID to operate on
|
|
523
|
+
* @returns EVM chain client with readContract, sendTransaction, sendBatch
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* const client = evm.client(1); // Ethereum mainnet
|
|
527
|
+
* const balance = await client.getBalance('0x...');
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
client: (chainId: number) => EvmChainClient;
|
|
485
531
|
};
|
|
532
|
+
type EvmClient = EvmChainClient;
|
|
486
533
|
/**
|
|
487
534
|
* Volr client interface
|
|
488
535
|
*/
|
|
489
536
|
type VolrClient = {
|
|
490
537
|
/**
|
|
491
|
-
*
|
|
492
|
-
* @param chainId - The chain ID to operate on
|
|
493
|
-
* @returns EVM client with readContract, sendTransaction, sendBatch
|
|
538
|
+
* EVM namespace with address, signing methods, and chain client
|
|
494
539
|
*/
|
|
495
|
-
evm:
|
|
540
|
+
evm: EvmNamespace;
|
|
496
541
|
/**
|
|
497
542
|
* User's EVM wallet address
|
|
543
|
+
* @deprecated Use evm.address instead
|
|
498
544
|
*/
|
|
499
545
|
evmAddress: `0x${string}` | undefined;
|
|
500
546
|
/**
|
|
@@ -1303,4 +1349,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1303
1349
|
createdAt: string;
|
|
1304
1350
|
}>>;
|
|
1305
1351
|
|
|
1306
|
-
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 MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi };
|
|
1352
|
+
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 EvmChainClient, type EvmClient, type EvmNamespace, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OnSignRequest, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi };
|
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, Call,
|
|
3
|
+
import { KeyStorageType as KeyStorageType$1, TypedDataInput, 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
|
|
|
@@ -174,6 +174,22 @@ interface ApiResponse<T> {
|
|
|
174
174
|
|
|
175
175
|
type KeyStorageType = "passkey" | "mpc";
|
|
176
176
|
type SignerType = "passkey" | "external_wallet" | "mpc";
|
|
177
|
+
/**
|
|
178
|
+
* Sign request types for confirmation modal
|
|
179
|
+
*/
|
|
180
|
+
type SignRequest = {
|
|
181
|
+
type: "message";
|
|
182
|
+
message: string | Uint8Array;
|
|
183
|
+
} | {
|
|
184
|
+
type: "typedData";
|
|
185
|
+
typedData: TypedDataInput;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Callback for sign request confirmation
|
|
189
|
+
* Called before signing to allow UI to show confirmation modal
|
|
190
|
+
* Resolve to proceed, reject to cancel
|
|
191
|
+
*/
|
|
192
|
+
type OnSignRequest = (request: SignRequest) => Promise<void>;
|
|
177
193
|
|
|
178
194
|
/**
|
|
179
195
|
* ERC-20 token configuration
|
|
@@ -230,6 +246,13 @@ type VolrConfig = {
|
|
|
230
246
|
* Deposit/Topup configuration for multi-chain, multi-token support
|
|
231
247
|
*/
|
|
232
248
|
deposit?: DepositConfig;
|
|
249
|
+
/**
|
|
250
|
+
* Callback for sign request confirmation.
|
|
251
|
+
* If provided, this callback is called before signing to allow UI to show confirmation modal.
|
|
252
|
+
* The callback should resolve to proceed with signing, or reject to cancel.
|
|
253
|
+
* Used by @volr/react-ui to show sign confirmation modal.
|
|
254
|
+
*/
|
|
255
|
+
onSignRequest?: OnSignRequest;
|
|
233
256
|
};
|
|
234
257
|
/**
|
|
235
258
|
* Public context value
|
|
@@ -374,7 +397,7 @@ type SendBatchOverloads = {
|
|
|
374
397
|
* const calls: Call[] = [
|
|
375
398
|
* { target: '0x...', data: '0x...', value: 0n, gasLimit: 100000n }
|
|
376
399
|
* ];
|
|
377
|
-
* await evm(chainId).sendBatch(calls);
|
|
400
|
+
* await evm.client(chainId).sendBatch(calls);
|
|
378
401
|
* ```
|
|
379
402
|
*/
|
|
380
403
|
(calls: Call[], opts?: SendTxOptions & {
|
|
@@ -386,7 +409,7 @@ type SendBatchOverloads = {
|
|
|
386
409
|
* @param opts - Optional transaction options including expiresInSec, from
|
|
387
410
|
* @example
|
|
388
411
|
* ```ts
|
|
389
|
-
* await evm(chainId).sendBatch([
|
|
412
|
+
* await evm.client(chainId).sendBatch([
|
|
390
413
|
* {
|
|
391
414
|
* target: tokenAddress,
|
|
392
415
|
* abi: erc20Abi,
|
|
@@ -402,14 +425,14 @@ type SendBatchOverloads = {
|
|
|
402
425
|
}): Promise<RelayResult>;
|
|
403
426
|
};
|
|
404
427
|
/**
|
|
405
|
-
* EVM client interface
|
|
428
|
+
* EVM chain client interface (chain-specific operations)
|
|
406
429
|
*/
|
|
407
|
-
type
|
|
430
|
+
type EvmChainClient = {
|
|
408
431
|
/**
|
|
409
432
|
* Get native token balance for an address
|
|
410
433
|
* @example
|
|
411
434
|
* ```ts
|
|
412
|
-
* const balance = await evm(1).getBalance('0x...');
|
|
435
|
+
* const balance = await evm.client(1).getBalance('0x...');
|
|
413
436
|
* // Returns bigint (in wei)
|
|
414
437
|
* ```
|
|
415
438
|
*/
|
|
@@ -418,7 +441,7 @@ type EvmClient = {
|
|
|
418
441
|
* Read data from a smart contract
|
|
419
442
|
* @example
|
|
420
443
|
* ```ts
|
|
421
|
-
* const balance = await evm(1).readContract({
|
|
444
|
+
* const balance = await evm.client(1).readContract({
|
|
422
445
|
* address: tokenAddress,
|
|
423
446
|
* abi: erc20Abi,
|
|
424
447
|
* functionName: 'balanceOf',
|
|
@@ -434,7 +457,7 @@ type EvmClient = {
|
|
|
434
457
|
* Send a single transaction
|
|
435
458
|
* @example
|
|
436
459
|
* ```ts
|
|
437
|
-
* const result = await evm(1).sendTransaction(
|
|
460
|
+
* const result = await evm.client(1).sendTransaction(
|
|
438
461
|
* { to: '0x...', data: '0x...' },
|
|
439
462
|
* );
|
|
440
463
|
* ```
|
|
@@ -449,25 +472,37 @@ type EvmClient = {
|
|
|
449
472
|
* Send a batch of transactions
|
|
450
473
|
*/
|
|
451
474
|
sendBatch: SendBatchOverloads;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* EVM namespace interface (chain-agnostic operations)
|
|
478
|
+
*/
|
|
479
|
+
type EvmNamespace = {
|
|
480
|
+
/**
|
|
481
|
+
* User's EVM wallet address
|
|
482
|
+
* undefined if not logged in
|
|
483
|
+
*/
|
|
484
|
+
address: `0x${string}` | undefined;
|
|
452
485
|
/**
|
|
453
486
|
* Sign a message (EIP-191 personal_sign)
|
|
487
|
+
* This is chain-agnostic - uses the same private key regardless of chain
|
|
454
488
|
* @param message - String or bytes to sign
|
|
455
489
|
* @returns Signature hex string
|
|
456
490
|
* @example
|
|
457
491
|
* ```ts
|
|
458
|
-
* const signature = await evm
|
|
492
|
+
* const signature = await evm.signMessage('Hello, World!');
|
|
459
493
|
* // or with raw bytes
|
|
460
|
-
* const signature = await evm
|
|
494
|
+
* const signature = await evm.signMessage(new Uint8Array([1, 2, 3]));
|
|
461
495
|
* ```
|
|
462
496
|
*/
|
|
463
497
|
signMessage: (message: string | Uint8Array) => Promise<`0x${string}`>;
|
|
464
498
|
/**
|
|
465
499
|
* Sign EIP-712 typed data
|
|
500
|
+
* This is chain-agnostic - uses the same private key regardless of chain
|
|
466
501
|
* @param typedData - Typed data with domain, types, and message
|
|
467
502
|
* @returns Signature hex string
|
|
468
503
|
* @example
|
|
469
504
|
* ```ts
|
|
470
|
-
* const signature = await evm
|
|
505
|
+
* const signature = await evm.signTypedData({
|
|
471
506
|
* domain: {
|
|
472
507
|
* name: 'MyApp',
|
|
473
508
|
* version: '1',
|
|
@@ -482,19 +517,30 @@ type EvmClient = {
|
|
|
482
517
|
* ```
|
|
483
518
|
*/
|
|
484
519
|
signTypedData: (typedData: TypedDataInput) => Promise<`0x${string}`>;
|
|
520
|
+
/**
|
|
521
|
+
* Get chain-specific client for operations that require a chain
|
|
522
|
+
* @param chainId - The chain ID to operate on
|
|
523
|
+
* @returns EVM chain client with readContract, sendTransaction, sendBatch
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* const client = evm.client(1); // Ethereum mainnet
|
|
527
|
+
* const balance = await client.getBalance('0x...');
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
client: (chainId: number) => EvmChainClient;
|
|
485
531
|
};
|
|
532
|
+
type EvmClient = EvmChainClient;
|
|
486
533
|
/**
|
|
487
534
|
* Volr client interface
|
|
488
535
|
*/
|
|
489
536
|
type VolrClient = {
|
|
490
537
|
/**
|
|
491
|
-
*
|
|
492
|
-
* @param chainId - The chain ID to operate on
|
|
493
|
-
* @returns EVM client with readContract, sendTransaction, sendBatch
|
|
538
|
+
* EVM namespace with address, signing methods, and chain client
|
|
494
539
|
*/
|
|
495
|
-
evm:
|
|
540
|
+
evm: EvmNamespace;
|
|
496
541
|
/**
|
|
497
542
|
* User's EVM wallet address
|
|
543
|
+
* @deprecated Use evm.address instead
|
|
498
544
|
*/
|
|
499
545
|
evmAddress: `0x${string}` | undefined;
|
|
500
546
|
/**
|
|
@@ -1303,4 +1349,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1303
1349
|
createdAt: string;
|
|
1304
1350
|
}>>;
|
|
1305
1351
|
|
|
1306
|
-
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 MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi };
|
|
1352
|
+
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 EvmChainClient, type EvmClient, type EvmNamespace, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OnSignRequest, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi };
|
package/dist/index.js
CHANGED
|
@@ -18508,12 +18508,54 @@ function useVolr() {
|
|
|
18508
18508
|
const { user, config, provider, setProvider, logout, isLoading, error } = useVolrContext();
|
|
18509
18509
|
const { precheck } = usePrecheck();
|
|
18510
18510
|
const { relay } = useRelay();
|
|
18511
|
-
const { client } = useInternalAuth();
|
|
18511
|
+
const { client: apiClient } = useInternalAuth();
|
|
18512
18512
|
const getRpcUrl = useCallback(
|
|
18513
|
-
createGetRpcUrl({ client, rpcOverrides: config.rpcOverrides }),
|
|
18514
|
-
[
|
|
18513
|
+
createGetRpcUrl({ client: apiClient, rpcOverrides: config.rpcOverrides }),
|
|
18514
|
+
[apiClient, config.rpcOverrides]
|
|
18515
|
+
);
|
|
18516
|
+
const signMessage = useCallback(
|
|
18517
|
+
async (message) => {
|
|
18518
|
+
if (!provider) {
|
|
18519
|
+
throw new Error(
|
|
18520
|
+
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign messages."
|
|
18521
|
+
);
|
|
18522
|
+
}
|
|
18523
|
+
if (config.onSignRequest) {
|
|
18524
|
+
await config.onSignRequest({ type: "message", message });
|
|
18525
|
+
}
|
|
18526
|
+
await provider.ensureSession({ interactive: true });
|
|
18527
|
+
const messageHash = hashMessage(
|
|
18528
|
+
typeof message === "string" ? message : { raw: message }
|
|
18529
|
+
);
|
|
18530
|
+
const hashBytes = new Uint8Array(32);
|
|
18531
|
+
const hex = messageHash.slice(2);
|
|
18532
|
+
for (let i = 0; i < 32; i++) {
|
|
18533
|
+
hashBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
18534
|
+
}
|
|
18535
|
+
const sig = await provider.signMessage(hashBytes);
|
|
18536
|
+
const v = sig.yParity + 27;
|
|
18537
|
+
const rHex = Array.from(sig.r).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18538
|
+
const sHex = Array.from(sig.s).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18539
|
+
const vHex = v.toString(16).padStart(2, "0");
|
|
18540
|
+
return `0x${rHex}${sHex}${vHex}`;
|
|
18541
|
+
},
|
|
18542
|
+
[provider, config.onSignRequest]
|
|
18543
|
+
);
|
|
18544
|
+
const signTypedData = useCallback(
|
|
18545
|
+
async (typedData) => {
|
|
18546
|
+
if (!provider) {
|
|
18547
|
+
throw new Error(
|
|
18548
|
+
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign typed data."
|
|
18549
|
+
);
|
|
18550
|
+
}
|
|
18551
|
+
if (config.onSignRequest) {
|
|
18552
|
+
await config.onSignRequest({ type: "typedData", typedData });
|
|
18553
|
+
}
|
|
18554
|
+
return provider.signTypedData(typedData);
|
|
18555
|
+
},
|
|
18556
|
+
[provider, config.onSignRequest]
|
|
18515
18557
|
);
|
|
18516
|
-
const
|
|
18558
|
+
const createChainClient = useCallback(
|
|
18517
18559
|
(chainId) => {
|
|
18518
18560
|
if (chainId === 0) {
|
|
18519
18561
|
throw new Error("chainId cannot be 0");
|
|
@@ -18532,12 +18574,12 @@ function useVolr() {
|
|
|
18532
18574
|
};
|
|
18533
18575
|
return {
|
|
18534
18576
|
getBalance: async (address) => {
|
|
18535
|
-
const { publicClient:
|
|
18536
|
-
return
|
|
18577
|
+
const { publicClient: client } = await ensureRpcClient();
|
|
18578
|
+
return client.getBalance({ address });
|
|
18537
18579
|
},
|
|
18538
18580
|
readContract: async (args) => {
|
|
18539
|
-
const { publicClient:
|
|
18540
|
-
return
|
|
18581
|
+
const { publicClient: client } = await ensureRpcClient();
|
|
18582
|
+
return client.readContract(args);
|
|
18541
18583
|
},
|
|
18542
18584
|
sendTransaction: async (tx, opts = {}) => {
|
|
18543
18585
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
@@ -18563,7 +18605,7 @@ function useVolr() {
|
|
|
18563
18605
|
rpcClient,
|
|
18564
18606
|
precheck,
|
|
18565
18607
|
relay,
|
|
18566
|
-
client,
|
|
18608
|
+
client: apiClient,
|
|
18567
18609
|
user: user ?? null,
|
|
18568
18610
|
provider: provider ?? null,
|
|
18569
18611
|
setProvider
|
|
@@ -18597,50 +18639,30 @@ function useVolr() {
|
|
|
18597
18639
|
rpcClient,
|
|
18598
18640
|
precheck,
|
|
18599
18641
|
relay,
|
|
18600
|
-
client,
|
|
18642
|
+
client: apiClient,
|
|
18601
18643
|
user: user ?? null,
|
|
18602
18644
|
provider: provider ?? null,
|
|
18603
18645
|
setProvider
|
|
18604
18646
|
}
|
|
18605
18647
|
});
|
|
18606
|
-
})
|
|
18607
|
-
signMessage: async (message) => {
|
|
18608
|
-
if (!provider) {
|
|
18609
|
-
throw new Error(
|
|
18610
|
-
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign messages."
|
|
18611
|
-
);
|
|
18612
|
-
}
|
|
18613
|
-
await provider.ensureSession({ interactive: true });
|
|
18614
|
-
const messageHash = hashMessage(
|
|
18615
|
-
typeof message === "string" ? message : { raw: message }
|
|
18616
|
-
);
|
|
18617
|
-
const hashBytes = new Uint8Array(32);
|
|
18618
|
-
const hex = messageHash.slice(2);
|
|
18619
|
-
for (let i = 0; i < 32; i++) {
|
|
18620
|
-
hashBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
18621
|
-
}
|
|
18622
|
-
const sig = await provider.signMessage(hashBytes);
|
|
18623
|
-
const v = sig.yParity + 27;
|
|
18624
|
-
const rHex = Array.from(sig.r).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18625
|
-
const sHex = Array.from(sig.s).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18626
|
-
const vHex = v.toString(16).padStart(2, "0");
|
|
18627
|
-
return `0x${rHex}${sHex}${vHex}`;
|
|
18628
|
-
},
|
|
18629
|
-
signTypedData: async (typedData) => {
|
|
18630
|
-
if (!provider) {
|
|
18631
|
-
throw new Error(
|
|
18632
|
-
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign typed data."
|
|
18633
|
-
);
|
|
18634
|
-
}
|
|
18635
|
-
return provider.signTypedData(typedData);
|
|
18636
|
-
}
|
|
18648
|
+
})
|
|
18637
18649
|
};
|
|
18638
18650
|
},
|
|
18639
|
-
[user,
|
|
18651
|
+
[user, provider, precheck, relay, getRpcUrl, setProvider, apiClient]
|
|
18652
|
+
);
|
|
18653
|
+
const evm = useMemo(
|
|
18654
|
+
() => ({
|
|
18655
|
+
address: user?.evmAddress,
|
|
18656
|
+
signMessage,
|
|
18657
|
+
signTypedData,
|
|
18658
|
+
client: createChainClient
|
|
18659
|
+
}),
|
|
18660
|
+
[user?.evmAddress, signMessage, signTypedData, createChainClient]
|
|
18640
18661
|
);
|
|
18641
18662
|
return {
|
|
18642
18663
|
evm,
|
|
18643
18664
|
evmAddress: user?.evmAddress,
|
|
18665
|
+
// deprecated, kept for backward compatibility
|
|
18644
18666
|
email: user?.email,
|
|
18645
18667
|
isLoggedIn: user !== null,
|
|
18646
18668
|
signerType: user?.signerType,
|
|
@@ -18664,19 +18686,6 @@ function toChecksumAddress(address) {
|
|
|
18664
18686
|
}
|
|
18665
18687
|
return checksummed;
|
|
18666
18688
|
}
|
|
18667
|
-
function detectWalletConnector() {
|
|
18668
|
-
if (typeof window === "undefined" || !window.ethereum) {
|
|
18669
|
-
return void 0;
|
|
18670
|
-
}
|
|
18671
|
-
const provider = window.ethereum;
|
|
18672
|
-
if (provider.info?.rdns) return provider.info.rdns;
|
|
18673
|
-
if (provider.isMetaMask) return "io.metamask";
|
|
18674
|
-
if (provider.isCoinbaseWallet) return "com.coinbase.wallet";
|
|
18675
|
-
if (provider.isRabby) return "io.rabby";
|
|
18676
|
-
if (provider.isZerion) return "io.zerion";
|
|
18677
|
-
if (provider.isBraveWallet) return "com.brave.wallet";
|
|
18678
|
-
return "unknown";
|
|
18679
|
-
}
|
|
18680
18689
|
function useVolrLogin() {
|
|
18681
18690
|
const { config, setUser } = useVolrContext();
|
|
18682
18691
|
const { setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
@@ -18809,11 +18818,11 @@ function useVolrLogin() {
|
|
|
18809
18818
|
[client, setAccessToken, setRefreshToken, setUser, toVolrUser]
|
|
18810
18819
|
);
|
|
18811
18820
|
const signWithWallet = useCallback(
|
|
18812
|
-
async (walletAddress) => {
|
|
18813
|
-
|
|
18821
|
+
async (walletAddress, options) => {
|
|
18822
|
+
const ethereum = options?.provider ?? (typeof window !== "undefined" ? window.ethereum : null);
|
|
18823
|
+
if (!ethereum) {
|
|
18814
18824
|
throw new Error("No Ethereum wallet found. Please install MetaMask or another wallet.");
|
|
18815
18825
|
}
|
|
18816
|
-
const ethereum = window.ethereum;
|
|
18817
18826
|
const chainIdHex = await ethereum.request({ method: "eth_chainId" });
|
|
18818
18827
|
const chainId = parseInt(chainIdHex, 16);
|
|
18819
18828
|
const nonce = await requestSiweNonce();
|
|
@@ -18836,7 +18845,7 @@ Issued At: ${issuedAt}`;
|
|
|
18836
18845
|
method: "personal_sign",
|
|
18837
18846
|
params: [message, walletAddress]
|
|
18838
18847
|
});
|
|
18839
|
-
const walletConnector =
|
|
18848
|
+
const walletConnector = options?.walletConnector ?? ethereum.info?.rdns ?? "unknown";
|
|
18840
18849
|
return verifySiweSignature(message, signature, { walletConnector, chainId });
|
|
18841
18850
|
},
|
|
18842
18851
|
[requestSiweNonce, verifySiweSignature]
|