@volr/react 0.1.10 → 0.1.12
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/dist/index.cjs +27 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +28 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -66,12 +66,12 @@ declare class APIClient {
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* API Response DTOs
|
|
69
|
-
*
|
|
69
|
+
* Type definitions for responses from the backend API
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* PRF Input DTO
|
|
74
|
-
*
|
|
74
|
+
* Input parameters for WebAuthn PRF extension
|
|
75
75
|
*/
|
|
76
76
|
interface PrfInputDto {
|
|
77
77
|
origin: string;
|
|
@@ -81,7 +81,7 @@ interface PrfInputDto {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* User DTO
|
|
84
|
-
*
|
|
84
|
+
* User information received from the backend
|
|
85
85
|
*/
|
|
86
86
|
interface UserDto {
|
|
87
87
|
id: string;
|
|
@@ -98,7 +98,7 @@ interface UserDto {
|
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Auth Refresh Response DTO
|
|
101
|
-
* /auth/refresh
|
|
101
|
+
* Response from /auth/refresh endpoint
|
|
102
102
|
*/
|
|
103
103
|
interface AuthRefreshResponseDto {
|
|
104
104
|
accessToken: string;
|
|
@@ -106,7 +106,7 @@ interface AuthRefreshResponseDto {
|
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Network DTO
|
|
109
|
-
* /networks/:chainId
|
|
109
|
+
* Response from /networks/:chainId endpoint
|
|
110
110
|
*/
|
|
111
111
|
interface NetworkDto {
|
|
112
112
|
chainId: string;
|
|
@@ -117,12 +117,12 @@ interface NetworkDto {
|
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Transaction Status
|
|
120
|
-
*
|
|
120
|
+
* Possible transaction status values
|
|
121
121
|
*/
|
|
122
122
|
type TransactionStatus = 'QUEUED' | 'PENDING' | 'CONFIRMED' | 'FAILED';
|
|
123
123
|
/**
|
|
124
124
|
* Transaction DTO
|
|
125
|
-
* /wallet/transactions/:txId
|
|
125
|
+
* Response from /wallet/transactions/:txId endpoint
|
|
126
126
|
*/
|
|
127
127
|
interface TransactionDto {
|
|
128
128
|
txId: string;
|
|
@@ -133,7 +133,7 @@ interface TransactionDto {
|
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* API Response Wrapper
|
|
136
|
-
*
|
|
136
|
+
* Common wrapper for all API responses
|
|
137
137
|
*/
|
|
138
138
|
interface ApiResponse<T> {
|
|
139
139
|
ok: boolean;
|
|
@@ -356,14 +356,21 @@ declare function buildCalls(options: BuildCallOptions[]): Call[];
|
|
|
356
356
|
|
|
357
357
|
type SendTxOptions = {
|
|
358
358
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
359
|
+
* Transaction expiration time in seconds from now.
|
|
360
|
+
* Defaults to backend configuration if not provided.
|
|
361
361
|
*/
|
|
362
|
-
policyId?: `0x${string}`;
|
|
363
|
-
signer?: SignerPort;
|
|
364
362
|
expiresInSec?: number;
|
|
363
|
+
/**
|
|
364
|
+
* Idempotency key to prevent duplicate transactions.
|
|
365
|
+
*/
|
|
365
366
|
idempotencyKey?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Transaction mode: 'sponsored' for gas-sponsored, 'self' for self-paid.
|
|
369
|
+
*/
|
|
366
370
|
mode?: 'sponsored' | 'self';
|
|
371
|
+
/**
|
|
372
|
+
* Sender address override. If not provided, uses user.evmAddress.
|
|
373
|
+
*/
|
|
367
374
|
from?: `0x${string}`;
|
|
368
375
|
/**
|
|
369
376
|
* Run best-effort RPC preflight (eth_estimateGas) before prompting passkey.
|
|
@@ -677,4 +684,4 @@ declare function normalizeHex(value: `0x${string}` | string): `0x${string}`;
|
|
|
677
684
|
*/
|
|
678
685
|
declare function normalizeHexArray(values: (`0x${string}` | string)[]): `0x${string}`[];
|
|
679
686
|
|
|
680
|
-
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 UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, 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, useVolrAuthCallback, useVolrLogin, useVolrWallet };
|
|
687
|
+
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 EvmChainOperations, 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 UsePrecheckReturn, type UseRelayReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, 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, useVolrAuthCallback, useVolrLogin, useVolrWallet };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,12 +66,12 @@ declare class APIClient {
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* API Response DTOs
|
|
69
|
-
*
|
|
69
|
+
* Type definitions for responses from the backend API
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* PRF Input DTO
|
|
74
|
-
*
|
|
74
|
+
* Input parameters for WebAuthn PRF extension
|
|
75
75
|
*/
|
|
76
76
|
interface PrfInputDto {
|
|
77
77
|
origin: string;
|
|
@@ -81,7 +81,7 @@ interface PrfInputDto {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* User DTO
|
|
84
|
-
*
|
|
84
|
+
* User information received from the backend
|
|
85
85
|
*/
|
|
86
86
|
interface UserDto {
|
|
87
87
|
id: string;
|
|
@@ -98,7 +98,7 @@ interface UserDto {
|
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Auth Refresh Response DTO
|
|
101
|
-
* /auth/refresh
|
|
101
|
+
* Response from /auth/refresh endpoint
|
|
102
102
|
*/
|
|
103
103
|
interface AuthRefreshResponseDto {
|
|
104
104
|
accessToken: string;
|
|
@@ -106,7 +106,7 @@ interface AuthRefreshResponseDto {
|
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Network DTO
|
|
109
|
-
* /networks/:chainId
|
|
109
|
+
* Response from /networks/:chainId endpoint
|
|
110
110
|
*/
|
|
111
111
|
interface NetworkDto {
|
|
112
112
|
chainId: string;
|
|
@@ -117,12 +117,12 @@ interface NetworkDto {
|
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Transaction Status
|
|
120
|
-
*
|
|
120
|
+
* Possible transaction status values
|
|
121
121
|
*/
|
|
122
122
|
type TransactionStatus = 'QUEUED' | 'PENDING' | 'CONFIRMED' | 'FAILED';
|
|
123
123
|
/**
|
|
124
124
|
* Transaction DTO
|
|
125
|
-
* /wallet/transactions/:txId
|
|
125
|
+
* Response from /wallet/transactions/:txId endpoint
|
|
126
126
|
*/
|
|
127
127
|
interface TransactionDto {
|
|
128
128
|
txId: string;
|
|
@@ -133,7 +133,7 @@ interface TransactionDto {
|
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* API Response Wrapper
|
|
136
|
-
*
|
|
136
|
+
* Common wrapper for all API responses
|
|
137
137
|
*/
|
|
138
138
|
interface ApiResponse<T> {
|
|
139
139
|
ok: boolean;
|
|
@@ -356,14 +356,21 @@ declare function buildCalls(options: BuildCallOptions[]): Call[];
|
|
|
356
356
|
|
|
357
357
|
type SendTxOptions = {
|
|
358
358
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
359
|
+
* Transaction expiration time in seconds from now.
|
|
360
|
+
* Defaults to backend configuration if not provided.
|
|
361
361
|
*/
|
|
362
|
-
policyId?: `0x${string}`;
|
|
363
|
-
signer?: SignerPort;
|
|
364
362
|
expiresInSec?: number;
|
|
363
|
+
/**
|
|
364
|
+
* Idempotency key to prevent duplicate transactions.
|
|
365
|
+
*/
|
|
365
366
|
idempotencyKey?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Transaction mode: 'sponsored' for gas-sponsored, 'self' for self-paid.
|
|
369
|
+
*/
|
|
366
370
|
mode?: 'sponsored' | 'self';
|
|
371
|
+
/**
|
|
372
|
+
* Sender address override. If not provided, uses user.evmAddress.
|
|
373
|
+
*/
|
|
367
374
|
from?: `0x${string}`;
|
|
368
375
|
/**
|
|
369
376
|
* Run best-effort RPC preflight (eth_estimateGas) before prompting passkey.
|
|
@@ -677,4 +684,4 @@ declare function normalizeHex(value: `0x${string}` | string): `0x${string}`;
|
|
|
677
684
|
*/
|
|
678
685
|
declare function normalizeHexArray(values: (`0x${string}` | string)[]): `0x${string}`[];
|
|
679
686
|
|
|
680
|
-
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 UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, 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, useVolrAuthCallback, useVolrLogin, useVolrWallet };
|
|
687
|
+
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 EvmChainOperations, 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 UsePrecheckReturn, type UseRelayReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, 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, useVolrAuthCallback, useVolrLogin, useVolrWallet };
|
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 { signSession, getAuthNonce, signAuthorization, createPasskeyProvider, createMpcProvider,
|
|
3
|
+
import { signSession, getAuthNonce, signAuthorization, createPasskeyProvider, createMpcProvider, 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';
|
|
@@ -18177,7 +18177,9 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
|
|
|
18177
18177
|
return {
|
|
18178
18178
|
txId,
|
|
18179
18179
|
status: "CONFIRMED",
|
|
18180
|
-
txHash
|
|
18180
|
+
txHash,
|
|
18181
|
+
gasUsed: response.gasUsed ? BigInt(response.gasUsed) : 0n,
|
|
18182
|
+
blockNumber: response.blockNumber ? BigInt(response.blockNumber) : 0n
|
|
18181
18183
|
};
|
|
18182
18184
|
}
|
|
18183
18185
|
if (status === "FAILED") {
|
|
@@ -18212,8 +18214,6 @@ async function sendCalls(args) {
|
|
|
18212
18214
|
if (chainId === 0) {
|
|
18213
18215
|
throw new Error("chainId cannot be 0");
|
|
18214
18216
|
}
|
|
18215
|
-
const effectivePolicyId = opts.policyId?.toLowerCase() === ZERO_HASH.toLowerCase() ? void 0 : opts.policyId;
|
|
18216
|
-
validatePolicyId2(effectivePolicyId);
|
|
18217
18217
|
const normalizedFrom = from14;
|
|
18218
18218
|
const normalizedCalls = normalizeCalls(calls);
|
|
18219
18219
|
validateCalls2(normalizedCalls);
|
|
@@ -18243,32 +18243,28 @@ async function sendCalls(args) {
|
|
|
18243
18243
|
{ tolerateFundingErrors }
|
|
18244
18244
|
);
|
|
18245
18245
|
}
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18250
|
-
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18246
|
+
const tempAuthForPrecheck = buildTempAuth({
|
|
18247
|
+
chainId,
|
|
18248
|
+
from: normalizedFrom,
|
|
18249
|
+
policyId: ZERO_HASH,
|
|
18250
|
+
calls: normalizedCalls,
|
|
18251
|
+
expiresInSec: opts.expiresInSec ?? DEFAULT_EXPIRES_IN_SEC
|
|
18252
|
+
});
|
|
18253
|
+
let precheckQuote;
|
|
18254
|
+
try {
|
|
18255
|
+
precheckQuote = await deps.precheck({
|
|
18256
|
+
auth: tempAuthForPrecheck,
|
|
18257
|
+
calls: normalizedCalls
|
|
18254
18258
|
});
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
precheckQuote = await deps.precheck({
|
|
18258
|
-
auth: tempAuthForPrecheck,
|
|
18259
|
-
calls: normalizedCalls
|
|
18260
|
-
});
|
|
18261
|
-
} catch (err) {
|
|
18262
|
-
throw err instanceof Error ? err : new Error(String(err));
|
|
18263
|
-
}
|
|
18264
|
-
const quotePolicyId = precheckQuote.policyId;
|
|
18265
|
-
if (!quotePolicyId) {
|
|
18266
|
-
throw new Error("Backend did not return policyId in precheck response");
|
|
18267
|
-
}
|
|
18268
|
-
projectPolicyId = quotePolicyId;
|
|
18269
|
-
} else {
|
|
18270
|
-
projectPolicyId = effectivePolicyId;
|
|
18259
|
+
} catch (err) {
|
|
18260
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
18271
18261
|
}
|
|
18262
|
+
const quotePolicyId = precheckQuote.policyId;
|
|
18263
|
+
if (!quotePolicyId) {
|
|
18264
|
+
throw new Error("Backend did not return policyId in precheck response");
|
|
18265
|
+
}
|
|
18266
|
+
const projectPolicyId = quotePolicyId;
|
|
18267
|
+
validatePolicyId2(projectPolicyId);
|
|
18272
18268
|
const tempAuth = buildTempAuth({
|
|
18273
18269
|
chainId,
|
|
18274
18270
|
from: normalizedFrom,
|
|
@@ -18288,7 +18284,8 @@ async function sendCalls(args) {
|
|
|
18288
18284
|
let activeProvider = null;
|
|
18289
18285
|
try {
|
|
18290
18286
|
const resolved = await resolveSigner({
|
|
18291
|
-
explicitSigner:
|
|
18287
|
+
explicitSigner: void 0,
|
|
18288
|
+
// Always resolve internally
|
|
18292
18289
|
provider: deps.provider,
|
|
18293
18290
|
chainId,
|
|
18294
18291
|
client: deps.client,
|
|
@@ -18305,7 +18302,7 @@ async function sendCalls(args) {
|
|
|
18305
18302
|
console.log(
|
|
18306
18303
|
`[useVolrWallet] Transaction ${result.txId} is ${result.status}, starting polling...`
|
|
18307
18304
|
);
|
|
18308
|
-
return
|
|
18305
|
+
return pollTransactionStatus(result.txId, deps.client);
|
|
18309
18306
|
}
|
|
18310
18307
|
return result;
|
|
18311
18308
|
} finally {
|
|
@@ -18393,7 +18390,7 @@ function useVolrWallet() {
|
|
|
18393
18390
|
return Array.isArray(calls2) && calls2.length > 0 && "data" in calls2[0] && !("abi" in calls2[0]);
|
|
18394
18391
|
};
|
|
18395
18392
|
const builtCalls = isCallArray(calls) ? calls : buildCalls(calls);
|
|
18396
|
-
return
|
|
18393
|
+
return sendCalls({
|
|
18397
18394
|
chainId,
|
|
18398
18395
|
from: getAddress(from14),
|
|
18399
18396
|
calls: builtCalls.map((c) => ({
|