@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.js CHANGED
@@ -17869,15 +17869,20 @@ var CACHE_TTL_MS = 5 * 60 * 1e3;
17869
17869
  function createGetRpcUrl(deps) {
17870
17870
  const { client, rpcOverrides } = deps;
17871
17871
  return async function getRpcUrl(chainId) {
17872
+ console.log("[getRpcUrl] Getting RPC URL for chainId:", chainId);
17872
17873
  const overrideUrl = rpcOverrides?.[chainId.toString()];
17873
17874
  if (overrideUrl) {
17875
+ console.log("[getRpcUrl] Using override URL");
17874
17876
  return overrideUrl;
17875
17877
  }
17876
17878
  const cached = networkCache.get(chainId);
17877
17879
  if (cached && cached.rpcUrl && Date.now() - cached.timestamp < CACHE_TTL_MS) {
17880
+ console.log("[getRpcUrl] Using cached URL");
17878
17881
  return cached.rpcUrl;
17879
17882
  }
17883
+ console.log("[getRpcUrl] Fetching from backend API...");
17880
17884
  const response = await client.get(`/networks/${chainId}?includeRpcUrl=true`);
17885
+ console.log("[getRpcUrl] Backend response received");
17881
17886
  if (!response.rpcUrl) {
17882
17887
  throw new Error(
17883
17888
  `RPC URL not available for chainId ${chainId}. Please provide it in config.rpcOverrides[${chainId}]`
@@ -17888,6 +17893,7 @@ function createGetRpcUrl(deps) {
17888
17893
  name: response.name,
17889
17894
  timestamp: Date.now()
17890
17895
  });
17896
+ console.log("[getRpcUrl] RPC URL fetched and cached");
17891
17897
  return response.rpcUrl;
17892
17898
  };
17893
17899
  }
@@ -18179,7 +18185,7 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18179
18185
  status: "CONFIRMED",
18180
18186
  txHash,
18181
18187
  gasUsed: response.gasUsed ? BigInt(response.gasUsed) : 0n,
18182
- blockNumber: response.blockNumber ? BigInt(response.blockNumber) : 0n
18188
+ blockNumber: response.blockNumber ? Number(response.blockNumber) : 0
18183
18189
  };
18184
18190
  }
18185
18191
  if (status === "FAILED") {
@@ -18210,15 +18216,19 @@ async function pollTransactionStatus(txId, client, maxAttempts = 60, intervalMs
18210
18216
 
18211
18217
  // src/wallet/sender.ts
18212
18218
  async function sendCalls(args) {
18219
+ console.log("[sendCalls] Starting sendCalls...");
18213
18220
  const { chainId, from: from14, calls, opts, deps } = args;
18214
18221
  if (chainId === 0) {
18215
18222
  throw new Error("chainId cannot be 0");
18216
18223
  }
18224
+ console.log("[sendCalls] Normalizing calls...");
18217
18225
  const normalizedFrom = from14;
18218
18226
  const normalizedCalls = normalizeCalls(calls);
18219
18227
  validateCalls2(normalizedCalls);
18228
+ console.log("[sendCalls] Calls normalized");
18220
18229
  let currentUser = deps.user;
18221
18230
  if (deps.user?.keyStorageType === "passkey" && !deps.provider) {
18231
+ console.log("[sendCalls] Refreshing user data...");
18222
18232
  try {
18223
18233
  const refreshResponse = await deps.client.post(
18224
18234
  "/auth/refresh",
@@ -18226,6 +18236,7 @@ async function sendCalls(args) {
18226
18236
  );
18227
18237
  if (refreshResponse.user) {
18228
18238
  currentUser = refreshResponse.user;
18239
+ console.log("[sendCalls] User data refreshed");
18229
18240
  }
18230
18241
  } catch (error) {
18231
18242
  console.warn(
@@ -18235,6 +18246,7 @@ async function sendCalls(args) {
18235
18246
  }
18236
18247
  }
18237
18248
  if (opts.preflight !== false) {
18249
+ console.log("[sendCalls] Running preflight estimate...");
18238
18250
  const tolerateFundingErrors = (opts.mode ?? "sponsored") !== "self";
18239
18251
  await preflightEstimate(
18240
18252
  deps.publicClient,
@@ -18242,7 +18254,11 @@ async function sendCalls(args) {
18242
18254
  normalizedCalls,
18243
18255
  { tolerateFundingErrors }
18244
18256
  );
18257
+ console.log("[sendCalls] Preflight estimate done");
18258
+ } else {
18259
+ console.log("[sendCalls] Preflight skipped");
18245
18260
  }
18261
+ console.log("[sendCalls] Building temp auth for first precheck...");
18246
18262
  const tempAuthForPrecheck = buildTempAuth({
18247
18263
  chainId,
18248
18264
  from: normalizedFrom,
@@ -18252,11 +18268,14 @@ async function sendCalls(args) {
18252
18268
  });
18253
18269
  let precheckQuote;
18254
18270
  try {
18271
+ console.log("[sendCalls] Running first precheck...");
18255
18272
  precheckQuote = await deps.precheck({
18256
18273
  auth: tempAuthForPrecheck,
18257
18274
  calls: normalizedCalls
18258
18275
  });
18276
+ console.log("[sendCalls] First precheck done, policyId:", precheckQuote.policyId);
18259
18277
  } catch (err) {
18278
+ console.error("[sendCalls] First precheck failed:", err);
18260
18279
  throw err instanceof Error ? err : new Error(String(err));
18261
18280
  }
18262
18281
  const quotePolicyId = precheckQuote.policyId;
@@ -18265,6 +18284,7 @@ async function sendCalls(args) {
18265
18284
  }
18266
18285
  const projectPolicyId = quotePolicyId;
18267
18286
  validatePolicyId2(projectPolicyId);
18287
+ console.log("[sendCalls] Building temp auth for second precheck...");
18268
18288
  const tempAuth = buildTempAuth({
18269
18289
  chainId,
18270
18290
  from: normalizedFrom,
@@ -18274,15 +18294,19 @@ async function sendCalls(args) {
18274
18294
  });
18275
18295
  let quote;
18276
18296
  try {
18297
+ console.log("[sendCalls] Running second precheck...");
18277
18298
  quote = await deps.precheck({ auth: tempAuth, calls: normalizedCalls });
18299
+ console.log("[sendCalls] Second precheck done");
18278
18300
  } catch (err) {
18279
- console.warn("[useVolrWallet] Precheck failed:", err);
18301
+ console.warn("[sendCalls] Second precheck failed:", err);
18280
18302
  }
18303
+ console.log("[sendCalls] Finalizing auth with nonce...");
18281
18304
  const auth = finalizeAuthWithNonce(tempAuth, quote);
18282
18305
  const idempotencyKey = opts.idempotencyKey ?? defaultIdempotencyKey();
18283
18306
  let signer;
18284
18307
  let activeProvider = null;
18285
18308
  try {
18309
+ console.log("[sendCalls] Resolving signer...");
18286
18310
  const resolved = await resolveSigner({
18287
18311
  explicitSigner: void 0,
18288
18312
  // Always resolve internally
@@ -18294,13 +18318,16 @@ async function sendCalls(args) {
18294
18318
  });
18295
18319
  signer = resolved.signer;
18296
18320
  activeProvider = resolved.activeProvider;
18321
+ console.log("[sendCalls] Signer resolved");
18322
+ console.log("[sendCalls] Calling relay...");
18297
18323
  const result = await deps.relay(
18298
18324
  { chainId, from: normalizedFrom, auth, calls: normalizedCalls },
18299
18325
  { signer, rpcClient: deps.rpcClient, idempotencyKey }
18300
18326
  );
18327
+ console.log("[sendCalls] Relay result:", result.status, result.txId);
18301
18328
  if (result.status === "QUEUED" || result.status === "PENDING") {
18302
18329
  console.log(
18303
- `[useVolrWallet] Transaction ${result.txId} is ${result.status}, starting polling...`
18330
+ `[sendCalls] Transaction ${result.txId} is ${result.status}, starting polling...`
18304
18331
  );
18305
18332
  return pollTransactionStatus(result.txId, deps.client);
18306
18333
  }
@@ -18334,11 +18361,14 @@ function useVolrWallet() {
18334
18361
  let extendedRpcClient = null;
18335
18362
  const ensureRpcClient = async () => {
18336
18363
  if (!publicClient) {
18364
+ console.log("[ensureRpcClient] Getting RPC URL for chainId:", chainId);
18337
18365
  const rpcUrl = await getRpcUrl(chainId);
18366
+ console.log("[ensureRpcClient] Got RPC URL:", rpcUrl);
18338
18367
  publicClient = createPublicClient({
18339
18368
  transport: http(rpcUrl)
18340
18369
  });
18341
18370
  extendedRpcClient = createExtendedRPCClient(publicClient);
18371
+ console.log("[ensureRpcClient] Public client created");
18342
18372
  }
18343
18373
  return { publicClient, extendedRpcClient };
18344
18374
  };
@@ -18379,8 +18409,12 @@ function useVolrWallet() {
18379
18409
  });
18380
18410
  },
18381
18411
  sendBatch: (async (calls, opts) => {
18412
+ console.log("[sendBatch] Starting sendBatch...", { chainId, callsCount: calls.length });
18413
+ console.log("[sendBatch] Ensuring RPC client...");
18382
18414
  const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
18415
+ console.log("[sendBatch] RPC client ready");
18383
18416
  const from14 = opts.from ?? user?.evmAddress;
18417
+ console.log("[sendBatch] From address:", from14);
18384
18418
  if (!from14) {
18385
18419
  throw new Error(
18386
18420
  "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."
@@ -18389,7 +18423,10 @@ function useVolrWallet() {
18389
18423
  const isCallArray = (calls2) => {
18390
18424
  return Array.isArray(calls2) && calls2.length > 0 && "data" in calls2[0] && !("abi" in calls2[0]);
18391
18425
  };
18426
+ console.log("[sendBatch] Building calls...");
18392
18427
  const builtCalls = isCallArray(calls) ? calls : buildCalls(calls);
18428
+ console.log("[sendBatch] Calls built:", builtCalls.length);
18429
+ console.log("[sendBatch] Calling sendCalls...");
18393
18430
  return sendCalls({
18394
18431
  chainId,
18395
18432
  from: getAddress(from14),