@volr/react 0.1.12 → 0.1.14

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
@@ -17893,15 +17893,20 @@ var CACHE_TTL_MS = 5 * 60 * 1e3;
17893
17893
  function createGetRpcUrl(deps) {
17894
17894
  const { client, rpcOverrides } = deps;
17895
17895
  return async function getRpcUrl(chainId) {
17896
+ console.log("[getRpcUrl] Getting RPC URL for chainId:", chainId);
17896
17897
  const overrideUrl = rpcOverrides?.[chainId.toString()];
17897
17898
  if (overrideUrl) {
17899
+ console.log("[getRpcUrl] Using override URL");
17898
17900
  return overrideUrl;
17899
17901
  }
17900
17902
  const cached = networkCache.get(chainId);
17901
17903
  if (cached && cached.rpcUrl && Date.now() - cached.timestamp < CACHE_TTL_MS) {
17904
+ console.log("[getRpcUrl] Using cached URL");
17902
17905
  return cached.rpcUrl;
17903
17906
  }
17907
+ console.log("[getRpcUrl] Fetching from backend API...");
17904
17908
  const response = await client.get(`/networks/${chainId}?includeRpcUrl=true`);
17909
+ console.log("[getRpcUrl] Backend response received");
17905
17910
  if (!response.rpcUrl) {
17906
17911
  throw new Error(
17907
17912
  `RPC URL not available for chainId ${chainId}. Please provide it in config.rpcOverrides[${chainId}]`
@@ -17912,6 +17917,7 @@ function createGetRpcUrl(deps) {
17912
17917
  name: response.name,
17913
17918
  timestamp: Date.now()
17914
17919
  });
17920
+ console.log("[getRpcUrl] RPC URL fetched and cached");
17915
17921
  return response.rpcUrl;
17916
17922
  };
17917
17923
  }
@@ -18203,7 +18209,7 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18203
18209
  status: "CONFIRMED",
18204
18210
  txHash,
18205
18211
  gasUsed: response.gasUsed ? BigInt(response.gasUsed) : 0n,
18206
- blockNumber: response.blockNumber ? BigInt(response.blockNumber) : 0n
18212
+ blockNumber: response.blockNumber ? Number(response.blockNumber) : 0
18207
18213
  };
18208
18214
  }
18209
18215
  if (status === "FAILED") {
@@ -18234,15 +18240,19 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18234
18240
 
18235
18241
  // src/wallet/sender.ts
18236
18242
  async function sendCalls(args) {
18243
+ console.log("[sendCalls] Starting sendCalls...");
18237
18244
  const { chainId, from: from14, calls, opts, deps } = args;
18238
18245
  if (chainId === 0) {
18239
18246
  throw new Error("chainId cannot be 0");
18240
18247
  }
18248
+ console.log("[sendCalls] Normalizing calls...");
18241
18249
  const normalizedFrom = from14;
18242
18250
  const normalizedCalls = normalizeCalls(calls);
18243
18251
  validateCalls2(normalizedCalls);
18252
+ console.log("[sendCalls] Calls normalized");
18244
18253
  let currentUser = deps.user;
18245
18254
  if (deps.user?.keyStorageType === "passkey" && !deps.provider) {
18255
+ console.log("[sendCalls] Refreshing user data...");
18246
18256
  try {
18247
18257
  const refreshResponse = await deps.client.post(
18248
18258
  "/auth/refresh",
@@ -18250,6 +18260,7 @@ async function sendCalls(args) {
18250
18260
  );
18251
18261
  if (refreshResponse.user) {
18252
18262
  currentUser = refreshResponse.user;
18263
+ console.log("[sendCalls] User data refreshed");
18253
18264
  }
18254
18265
  } catch (error) {
18255
18266
  console.warn(
@@ -18259,6 +18270,7 @@ async function sendCalls(args) {
18259
18270
  }
18260
18271
  }
18261
18272
  if (opts.preflight !== false) {
18273
+ console.log("[sendCalls] Running preflight estimate...");
18262
18274
  const tolerateFundingErrors = (opts.mode ?? "sponsored") !== "self";
18263
18275
  await preflightEstimate(
18264
18276
  deps.publicClient,
@@ -18266,7 +18278,11 @@ async function sendCalls(args) {
18266
18278
  normalizedCalls,
18267
18279
  { tolerateFundingErrors }
18268
18280
  );
18281
+ console.log("[sendCalls] Preflight estimate done");
18282
+ } else {
18283
+ console.log("[sendCalls] Preflight skipped");
18269
18284
  }
18285
+ console.log("[sendCalls] Building temp auth for first precheck...");
18270
18286
  const tempAuthForPrecheck = buildTempAuth({
18271
18287
  chainId,
18272
18288
  from: normalizedFrom,
@@ -18276,11 +18292,14 @@ async function sendCalls(args) {
18276
18292
  });
18277
18293
  let precheckQuote;
18278
18294
  try {
18295
+ console.log("[sendCalls] Running first precheck...");
18279
18296
  precheckQuote = await deps.precheck({
18280
18297
  auth: tempAuthForPrecheck,
18281
18298
  calls: normalizedCalls
18282
18299
  });
18300
+ console.log("[sendCalls] First precheck done, policyId:", precheckQuote.policyId);
18283
18301
  } catch (err) {
18302
+ console.error("[sendCalls] First precheck failed:", err);
18284
18303
  throw err instanceof Error ? err : new Error(String(err));
18285
18304
  }
18286
18305
  const quotePolicyId = precheckQuote.policyId;
@@ -18289,6 +18308,7 @@ async function sendCalls(args) {
18289
18308
  }
18290
18309
  const projectPolicyId = quotePolicyId;
18291
18310
  validatePolicyId2(projectPolicyId);
18311
+ console.log("[sendCalls] Building temp auth for second precheck...");
18292
18312
  const tempAuth = buildTempAuth({
18293
18313
  chainId,
18294
18314
  from: normalizedFrom,
@@ -18298,15 +18318,19 @@ async function sendCalls(args) {
18298
18318
  });
18299
18319
  let quote;
18300
18320
  try {
18321
+ console.log("[sendCalls] Running second precheck...");
18301
18322
  quote = await deps.precheck({ auth: tempAuth, calls: normalizedCalls });
18323
+ console.log("[sendCalls] Second precheck done");
18302
18324
  } catch (err) {
18303
- console.warn("[useVolrWallet] Precheck failed:", err);
18325
+ console.warn("[sendCalls] Second precheck failed:", err);
18304
18326
  }
18327
+ console.log("[sendCalls] Finalizing auth with nonce...");
18305
18328
  const auth = finalizeAuthWithNonce(tempAuth, quote);
18306
18329
  const idempotencyKey = opts.idempotencyKey ?? defaultIdempotencyKey();
18307
18330
  let signer;
18308
18331
  let activeProvider = null;
18309
18332
  try {
18333
+ console.log("[sendCalls] Resolving signer...");
18310
18334
  const resolved = await resolveSigner({
18311
18335
  explicitSigner: void 0,
18312
18336
  // Always resolve internally
@@ -18318,13 +18342,16 @@ async function sendCalls(args) {
18318
18342
  });
18319
18343
  signer = resolved.signer;
18320
18344
  activeProvider = resolved.activeProvider;
18345
+ console.log("[sendCalls] Signer resolved");
18346
+ console.log("[sendCalls] Calling relay...");
18321
18347
  const result = await deps.relay(
18322
18348
  { chainId, from: normalizedFrom, auth, calls: normalizedCalls },
18323
18349
  { signer, rpcClient: deps.rpcClient, idempotencyKey }
18324
18350
  );
18351
+ console.log("[sendCalls] Relay result:", result.status, result.txId);
18325
18352
  if (result.status === "QUEUED" || result.status === "PENDING") {
18326
18353
  console.log(
18327
- `[useVolrWallet] Transaction ${result.txId} is ${result.status}, starting polling...`
18354
+ `[sendCalls] Transaction ${result.txId} is ${result.status}, starting polling...`
18328
18355
  );
18329
18356
  return pollTransactionStatus(result.txId, deps.client);
18330
18357
  }
@@ -18358,11 +18385,14 @@ function useVolrWallet() {
18358
18385
  let extendedRpcClient = null;
18359
18386
  const ensureRpcClient = async () => {
18360
18387
  if (!publicClient) {
18388
+ console.log("[ensureRpcClient] Getting RPC URL for chainId:", chainId);
18361
18389
  const rpcUrl = await getRpcUrl(chainId);
18390
+ console.log("[ensureRpcClient] Got RPC URL:", rpcUrl);
18362
18391
  publicClient = createPublicClient({
18363
18392
  transport: http(rpcUrl)
18364
18393
  });
18365
18394
  extendedRpcClient = createExtendedRPCClient(publicClient);
18395
+ console.log("[ensureRpcClient] Public client created");
18366
18396
  }
18367
18397
  return { publicClient, extendedRpcClient };
18368
18398
  };
@@ -18403,8 +18433,12 @@ function useVolrWallet() {
18403
18433
  });
18404
18434
  },
18405
18435
  sendBatch: (async (calls, opts) => {
18436
+ console.log("[sendBatch] Starting sendBatch...", { chainId, callsCount: calls.length });
18437
+ console.log("[sendBatch] Ensuring RPC client...");
18406
18438
  const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
18439
+ console.log("[sendBatch] RPC client ready");
18407
18440
  const from14 = opts.from ?? user?.evmAddress;
18441
+ console.log("[sendBatch] From address:", from14);
18408
18442
  if (!from14) {
18409
18443
  throw new Error(
18410
18444
  "from address is required. Provide it in opts.from or set user.evmAddress in VolrProvider. If you haven't set up a wallet provider yet, please complete the onboarding flow."
@@ -18413,7 +18447,10 @@ function useVolrWallet() {
18413
18447
  const isCallArray = (calls2) => {
18414
18448
  return Array.isArray(calls2) && calls2.length > 0 && "data" in calls2[0] && !("abi" in calls2[0]);
18415
18449
  };
18450
+ console.log("[sendBatch] Building calls...");
18416
18451
  const builtCalls = isCallArray(calls) ? calls : buildCalls(calls);
18452
+ console.log("[sendBatch] Calls built:", builtCalls.length);
18453
+ console.log("[sendBatch] Calling sendCalls...");
18417
18454
  return sendCalls({
18418
18455
  chainId,
18419
18456
  from: getAddress(from14),