@volr/react 0.1.29 → 0.1.30

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 CHANGED
@@ -9090,20 +9090,16 @@ var APIClient = class {
9090
9090
  (response) => response,
9091
9091
  async (error) => {
9092
9092
  const originalRequest = error.config;
9093
- console.log(`[APIClient] Response error:`, error.response?.status, originalRequest?.url);
9094
9093
  if (originalRequest?.url?.includes("/auth/refresh")) {
9095
- console.log("[APIClient] Refresh endpoint failed, not retrying");
9096
9094
  return Promise.reject(error);
9097
9095
  }
9098
9096
  if (error.response?.status === 401 && !originalRequest._retry) {
9099
- console.log("[APIClient] 401 received, attempting token refresh...");
9100
9097
  originalRequest._retry = true;
9101
9098
  try {
9102
9099
  await this.refreshAccessToken();
9103
9100
  if (this.accessToken) {
9104
9101
  originalRequest.headers["Authorization"] = `Bearer ${this.accessToken}`;
9105
9102
  }
9106
- console.log("[APIClient] Token refreshed, retrying original request");
9107
9103
  return this.api(originalRequest);
9108
9104
  } catch (refreshError) {
9109
9105
  console.error("[APIClient] Token refresh failed:", refreshError);
@@ -9275,7 +9271,6 @@ var APIClient = class {
9275
9271
  */
9276
9272
  async post(endpoint, body, idempotencyKey) {
9277
9273
  const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
9278
- console.log(`[APIClient] POST ${normalizedEndpoint}`);
9279
9274
  const config = {
9280
9275
  method: "POST",
9281
9276
  url: normalizedEndpoint,
@@ -9288,7 +9283,6 @@ var APIClient = class {
9288
9283
  }
9289
9284
  try {
9290
9285
  const response = await this.api.request(config);
9291
- console.log(`[APIClient] POST ${normalizedEndpoint} response:`, response.data);
9292
9286
  return unwrapResponse(response.data);
9293
9287
  } catch (error) {
9294
9288
  console.error(`[APIClient] POST ${normalizedEndpoint} error:`, error);
@@ -9680,29 +9674,12 @@ async function restorePasskey(params) {
9680
9674
  "Credential ID not found. Please provide credentialId in params, prfInput, or ensure it is stored in localStorage. If you recently enrolled a passkey, try refreshing the page or re-enrolling."
9681
9675
  );
9682
9676
  }
9683
- console.log("[restorePasskey] Using credentialId:", credentialId ? "present" : "MISSING");
9684
- console.log(
9685
- "[restorePasskey] credentialId source:",
9686
- providedCredentialId ? "params" : prfInput.credentialId ? "prfInput" : "localStorage"
9687
- );
9688
- console.log("[restorePasskey] prfInput:", prfInput);
9689
- console.log("[restorePasskey] Step 1: Ensuring access token is fresh...");
9690
- try {
9691
- await client.ensureAccessToken();
9692
- console.log("[restorePasskey] Access token ensured");
9693
- } catch (error) {
9694
- console.error("[restorePasskey] Failed to ensure access token:", error);
9695
- throw new Error("Failed to refresh access token. Please log in again.");
9696
- }
9697
- console.log("[restorePasskey] Step 2: Downloading blob via backend proxy for blobUrl:", blobUrl);
9698
9677
  const apiKey = client.getApiKey();
9699
9678
  if (!apiKey) {
9700
- console.error("[restorePasskey] API key not set in client. This is required for blob download.");
9701
9679
  throw new Error(
9702
9680
  "API key not configured. Please ensure VolrProvider is initialized with projectApiKey in config."
9703
9681
  );
9704
9682
  }
9705
- console.log("[restorePasskey] API key is set:", apiKey ? "present" : "MISSING");
9706
9683
  const arrayBuffer = await client.postBinary("/blob/download", { key: blobUrl });
9707
9684
  const blobBytes = new Uint8Array(arrayBuffer);
9708
9685
  const nonceLength = 12;
@@ -9723,7 +9700,6 @@ async function restorePasskey(params) {
9723
9700
  prfInput: {
9724
9701
  ...prfInput,
9725
9702
  credentialId
9726
- // Add credentialId to prfInput
9727
9703
  },
9728
9704
  encryptedBlob: {
9729
9705
  cipher,
@@ -9731,10 +9707,7 @@ async function restorePasskey(params) {
9731
9707
  },
9732
9708
  aad: aadBytes
9733
9709
  });
9734
- console.log("[restorePasskey] Provider created with credentialId:", credentialId);
9735
- return {
9736
- provider
9737
- };
9710
+ return { provider };
9738
9711
  }
9739
9712
 
9740
9713
  // src/react/hooks/useAutoRecover.ts
@@ -18241,13 +18214,17 @@ function extractFailureReason(response) {
18241
18214
  }
18242
18215
  return "Transaction failed on-chain (no specific reason provided)";
18243
18216
  }
18244
- async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs = 5e3) {
18217
+ function getPollingInterval(attempt) {
18218
+ if (attempt < 3) return 1e3;
18219
+ if (attempt < 8) return 2e3;
18220
+ return 5e3;
18221
+ }
18222
+ async function pollTransactionStatus(txId, client, maxAttempts = 60) {
18245
18223
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
18246
18224
  try {
18247
18225
  const response = await client.get(`/wallet/transactions/${txId}`);
18248
18226
  const { status, txHash } = response;
18249
18227
  if (status === "CONFIRMED") {
18250
- console.log(`[pollTransactionStatus] Transaction ${txId} confirmed with txHash ${txHash}`);
18251
18228
  return {
18252
18229
  txId,
18253
18230
  status: "CONFIRMED",
@@ -18271,10 +18248,11 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18271
18248
  };
18272
18249
  return failedResult;
18273
18250
  }
18274
- console.log(`[pollTransactionStatus] Transaction ${txId} is ${status}, attempt ${attempt + 1}/${maxAttempts}`);
18251
+ const intervalMs = getPollingInterval(attempt);
18275
18252
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
18276
18253
  } catch (error) {
18277
18254
  console.error(`[pollTransactionStatus] Error polling transaction ${txId}:`, error);
18255
+ const intervalMs = getPollingInterval(attempt);
18278
18256
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
18279
18257
  }
18280
18258
  }
@@ -18287,24 +18265,19 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18287
18265
 
18288
18266
  // src/wallet/sender.ts
18289
18267
  async function sendCalls(args) {
18290
- console.log("[sendCalls] Starting sendCalls...");
18291
18268
  const { chainId, from: from14, calls, opts, deps } = args;
18292
18269
  if (chainId === 0) {
18293
18270
  throw new Error("chainId cannot be 0");
18294
18271
  }
18295
- console.log("[sendCalls] Normalizing calls...");
18296
18272
  const normalizedFrom = from14;
18297
18273
  const normalizedCalls = normalizeCalls(calls);
18298
18274
  validateCalls2(normalizedCalls);
18299
- console.log("[sendCalls] Calls normalized");
18300
18275
  let currentUser = deps.user;
18301
18276
  if (deps.user?.keyStorageType === "passkey" && !deps.provider) {
18302
- console.log("[sendCalls] Refreshing user data (provider not available)...");
18303
18277
  try {
18304
18278
  const refreshedUser = await deps.client.refreshSession();
18305
18279
  if (refreshedUser) {
18306
18280
  currentUser = refreshedUser;
18307
- console.log("[sendCalls] User data refreshed successfully");
18308
18281
  }
18309
18282
  } catch (error) {
18310
18283
  console.error("[sendCalls] Failed to refresh session:", error);
@@ -18312,13 +18285,7 @@ async function sendCalls(args) {
18312
18285
  `Failed to refresh session before transaction. ${error instanceof Error ? error.message : "Unknown error"}. Please try logging in again.`
18313
18286
  );
18314
18287
  }
18315
- } else {
18316
- console.log("[sendCalls] Skipping user refresh:", {
18317
- hasProvider: !!deps.provider,
18318
- keyStorageType: deps.user?.keyStorageType
18319
- });
18320
18288
  }
18321
- console.log("[sendCalls] Building temp auth for first precheck...");
18322
18289
  const tempAuthForPrecheck = buildTempAuth({
18323
18290
  chainId,
18324
18291
  from: normalizedFrom,
@@ -18328,16 +18295,10 @@ async function sendCalls(args) {
18328
18295
  });
18329
18296
  let precheckQuote;
18330
18297
  try {
18331
- console.log("[sendCalls] Running first precheck...");
18332
18298
  precheckQuote = await deps.precheck({
18333
18299
  auth: tempAuthForPrecheck,
18334
18300
  calls: normalizedCalls
18335
18301
  });
18336
- console.log("[sendCalls] First precheck done:", {
18337
- policyId: precheckQuote.policyId,
18338
- simulationSuccess: precheckQuote.simulationSuccess,
18339
- estimatedGasPerCall: precheckQuote.estimatedGasPerCall
18340
- });
18341
18302
  } catch (err) {
18342
18303
  console.error("[sendCalls] First precheck failed:", err);
18343
18304
  throw err instanceof Error ? err : new Error(String(err));
@@ -18351,14 +18312,10 @@ async function sendCalls(args) {
18351
18312
  console.warn("[sendCalls] Proceeding despite simulation failure - EIP-7702 execution context may differ");
18352
18313
  }
18353
18314
  if (precheckQuote.estimatedGasPerCall?.length) {
18354
- console.log("[sendCalls] Applying estimated gas limits from backend...");
18355
18315
  for (let i = 0; i < normalizedCalls.length && i < precheckQuote.estimatedGasPerCall.length; i++) {
18356
18316
  const estimatedGas = BigInt(precheckQuote.estimatedGasPerCall[i] ?? "0");
18357
18317
  const currentGas = normalizedCalls[i]?.gasLimit ?? 0n;
18358
- if (currentGas > 0n) {
18359
- console.log(`[sendCalls] Call #${i}: keeping frontend gasLimit ${currentGas} (backend estimated: ${estimatedGas})`);
18360
- } else if (estimatedGas > 0n) {
18361
- console.log(`[sendCalls] Call #${i}: using backend gasLimit ${estimatedGas}`);
18318
+ if (currentGas === 0n && estimatedGas > 0n) {
18362
18319
  normalizedCalls[i].gasLimit = estimatedGas;
18363
18320
  }
18364
18321
  }
@@ -18369,7 +18326,6 @@ async function sendCalls(args) {
18369
18326
  }
18370
18327
  const projectPolicyId = quotePolicyId;
18371
18328
  validatePolicyId2(projectPolicyId);
18372
- console.log("[sendCalls] Building temp auth for second precheck...");
18373
18329
  const tempAuth = buildTempAuth({
18374
18330
  chainId,
18375
18331
  from: normalizedFrom,
@@ -18378,21 +18334,11 @@ async function sendCalls(args) {
18378
18334
  // Now with updated gas limits
18379
18335
  expiresInSec: opts.expiresInSec ?? DEFAULT_EXPIRES_IN_SEC
18380
18336
  });
18381
- let quote;
18382
- try {
18383
- console.log("[sendCalls] Running second precheck...");
18384
- quote = await deps.precheck({ auth: tempAuth, calls: normalizedCalls });
18385
- console.log("[sendCalls] Second precheck done");
18386
- } catch (err) {
18387
- console.warn("[sendCalls] Second precheck failed:", err);
18388
- }
18389
- console.log("[sendCalls] Finalizing auth with nonce...");
18390
- const auth = finalizeAuthWithNonce(tempAuth, quote);
18337
+ const auth = finalizeAuthWithNonce(tempAuth, precheckQuote);
18391
18338
  const idempotencyKey = opts.idempotencyKey ?? defaultIdempotencyKey();
18392
18339
  let signer;
18393
18340
  let activeProvider = null;
18394
18341
  try {
18395
- console.log("[sendCalls] Resolving signer...");
18396
18342
  const resolved = await resolveSigner({
18397
18343
  explicitSigner: void 0,
18398
18344
  // Always resolve internally
@@ -18404,17 +18350,11 @@ async function sendCalls(args) {
18404
18350
  });
18405
18351
  signer = resolved.signer;
18406
18352
  activeProvider = resolved.activeProvider;
18407
- console.log("[sendCalls] Signer resolved");
18408
- console.log("[sendCalls] Calling relay...");
18409
18353
  const result = await deps.relay(
18410
18354
  { chainId, from: normalizedFrom, auth, calls: normalizedCalls },
18411
18355
  { signer, rpcClient: deps.rpcClient, idempotencyKey }
18412
18356
  );
18413
- console.log("[sendCalls] Relay result:", result.status, result.txId);
18414
18357
  if (result.status === "QUEUED" || result.status === "PENDING") {
18415
- console.log(
18416
- `[sendCalls] Transaction ${result.txId} is ${result.status}, starting polling...`
18417
- );
18418
18358
  return pollTransactionStatus(result.txId, deps.client);
18419
18359
  }
18420
18360
  return result;