anymal-protocol 1.0.158 → 1.0.160

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.d.mts CHANGED
@@ -70,6 +70,11 @@ declare function useSendCoinbaseUserOperation(): {
70
70
  sendOperationFn: (evmAddress: `0x${string}`, contractAddress: `0x${string}`, abi: any, functionName: string, args: any[]) => Promise<{
71
71
  success: boolean;
72
72
  message: string;
73
+ details?: undefined;
74
+ } | {
75
+ success: boolean;
76
+ message: string;
77
+ details: any;
73
78
  }>;
74
79
  data: _coinbase_cdp_api_client.EvmUserOperation | undefined;
75
80
  status: _coinbase_cdp_hooks.Status;
package/dist/index.d.ts CHANGED
@@ -70,6 +70,11 @@ declare function useSendCoinbaseUserOperation(): {
70
70
  sendOperationFn: (evmAddress: `0x${string}`, contractAddress: `0x${string}`, abi: any, functionName: string, args: any[]) => Promise<{
71
71
  success: boolean;
72
72
  message: string;
73
+ details?: undefined;
74
+ } | {
75
+ success: boolean;
76
+ message: string;
77
+ details: any;
73
78
  }>;
74
79
  data: _coinbase_cdp_api_client.EvmUserOperation | undefined;
75
80
  status: _coinbase_cdp_hooks.Status;
package/dist/index.js CHANGED
@@ -509,40 +509,162 @@ function useSendCoinbaseUserOperation() {
509
509
  if (!evmAddress || !contractAddress || !abi || !functionName) {
510
510
  return { success: false, message: "Missing required information" };
511
511
  }
512
+ console.log("\u{1F50D} Transaction Details:", {
513
+ network: isProduction ? "base" : "base-sepolia",
514
+ evmAddress,
515
+ contractAddress,
516
+ functionName,
517
+ args
518
+ });
512
519
  try {
513
- await publicClient.simulateContract({
520
+ console.log("\u23F3 Simulating contract call...");
521
+ const result = await publicClient.simulateContract({
514
522
  address: contractAddress,
515
523
  abi,
516
524
  functionName,
517
525
  args,
518
526
  account: evmAddress
519
527
  });
528
+ console.log("\u2705 Simulation successful:", result);
520
529
  } catch (simError) {
521
- console.error("\u274C Simulation failed:", simError);
530
+ console.error("=".repeat(80));
531
+ console.error("\u274C SIMULATION FAILED - DETAILED ERROR");
532
+ console.error("=".repeat(80));
533
+ let errorMessage = "Simulation failed";
534
+ let errorDetails = {};
535
+ if (simError instanceof import_viem.BaseError) {
536
+ console.error("\u{1F4CB} VIEM ERROR:");
537
+ console.error(" Name:", simError.name);
538
+ console.error(" Message:", simError.message);
539
+ console.error(" Short Message:", simError.shortMessage);
540
+ console.error(" Details:", simError.details);
541
+ const revertError = simError.walk(
542
+ (err) => err instanceof import_viem.ContractFunctionRevertedError
543
+ );
544
+ if (revertError instanceof import_viem.ContractFunctionRevertedError) {
545
+ console.error("\n\u{1F534} CONTRACT REVERT DETECTED:");
546
+ console.error(
547
+ " Error Name:",
548
+ revertError.data?.errorName ?? "Unknown"
549
+ );
550
+ console.error(" Error Args:", revertError.data?.args ?? []);
551
+ console.error(" Signature:", revertError.signature);
552
+ console.error(" Reason:", revertError.reason);
553
+ errorDetails = {
554
+ errorName: revertError.data?.errorName,
555
+ errorArgs: revertError.data?.args,
556
+ signature: revertError.signature,
557
+ reason: revertError.reason
558
+ };
559
+ const errorName = revertError.data?.errorName ?? "Unknown";
560
+ const errorArgs = revertError.data?.args ?? [];
561
+ if (errorName !== "Unknown") {
562
+ errorMessage = `Contract reverted: ${errorName}(${errorArgs.join(", ")})`;
563
+ } else {
564
+ errorMessage = revertError.shortMessage || revertError.message;
565
+ }
566
+ } else {
567
+ errorMessage = simError.shortMessage || simError.message;
568
+ }
569
+ } else {
570
+ console.error("\u26A0\uFE0F NON-VIEM ERROR:", {
571
+ name: simError?.name,
572
+ message: simError?.message,
573
+ cause: simError?.cause
574
+ });
575
+ errorMessage = simError?.message || "Unknown simulation error";
576
+ }
577
+ console.error("\n\u{1F4CD} CALL CONTEXT:");
578
+ console.error(" Contract:", contractAddress);
579
+ console.error(" Function:", functionName);
580
+ console.error(" Args:", JSON.stringify(args, null, 2));
581
+ console.error(" Sender:", evmAddress);
582
+ console.error(" Network:", isProduction ? "base" : "base-sepolia");
583
+ if (simError?.data) {
584
+ console.error("\n\u{1F4E6} RAW ERROR DATA:", simError.data);
585
+ }
586
+ if (simError?.cause) {
587
+ console.error("\n\u{1F517} ERROR CAUSE CHAIN:");
588
+ let cause = simError.cause;
589
+ let depth = 1;
590
+ while (cause && depth < 5) {
591
+ console.error(` ${depth}. ${cause.message || cause}`);
592
+ cause = cause.cause;
593
+ depth++;
594
+ }
595
+ }
596
+ console.error("=".repeat(80));
522
597
  return {
523
598
  success: false,
524
- message: `Simulation failed: ${simError.shortMessage || simError.message}`
599
+ message: errorMessage,
600
+ details: errorDetails
525
601
  };
526
602
  }
527
603
  try {
604
+ console.log("\u23F3 Encoding and sending user operation...");
528
605
  const callData = (0, import_viem.encodeFunctionData)({
529
606
  abi,
530
607
  functionName,
531
608
  args
532
609
  });
610
+ console.log("\u{1F4E4} Sending with paymaster:", {
611
+ evmSmartAccount: evmAddress,
612
+ network: isProduction ? "base" : "base-sepolia",
613
+ useCdpPaymaster: true,
614
+ to: contractAddress,
615
+ callDataLength: callData.length
616
+ });
533
617
  await sendUserOperation({
534
618
  evmSmartAccount: evmAddress,
535
619
  network: isProduction ? "base" : "base-sepolia",
536
620
  useCdpPaymaster: true,
537
621
  calls: [{ data: callData, to: contractAddress }]
538
622
  });
623
+ console.log("\u2705 User operation submitted successfully");
539
624
  return { success: true, message: "Operation submitted." };
540
- } catch (e) {
541
- console.error("\u274C Operation failed:", e);
542
- return { success: false, message: e.message };
625
+ } catch (opError) {
626
+ console.error("=".repeat(80));
627
+ console.error("\u274C USER OPERATION FAILED");
628
+ console.error("=".repeat(80));
629
+ console.error("Error:", opError);
630
+ let errorMessage = "Operation failed";
631
+ if (opError?.message?.includes("allowlist")) {
632
+ console.error("\n\u{1F6AB} PAYMASTER ALLOWLIST ERROR");
633
+ console.error(" The contract is not in the paymaster allowlist");
634
+ console.error(
635
+ " Add this contract to CDP Portal \u2192 Paymaster \u2192 Allowlist:"
636
+ );
637
+ console.error(" ", contractAddress);
638
+ errorMessage = `Contract ${contractAddress} not in paymaster allowlist`;
639
+ } else if (opError?.message?.includes("insufficient balance")) {
640
+ console.error("\n\u{1F4B0} INSUFFICIENT BALANCE ERROR");
641
+ console.error(" Paymaster or smart account has insufficient funds");
642
+ errorMessage = "Insufficient balance for gas payment";
643
+ } else if (opError?.code === -32002) {
644
+ console.error("\n\u{1F6AB} PAYMASTER POLICY ERROR");
645
+ console.error(" Code:", opError.code);
646
+ console.error(" Message:", opError.message);
647
+ errorMessage = `Paymaster policy error: ${opError.message}`;
648
+ } else {
649
+ errorMessage = opError?.message || "Unknown operation error";
650
+ }
651
+ console.error("\n\u{1F4CD} OPERATION CONTEXT:");
652
+ console.error(" Network:", isProduction ? "base" : "base-sepolia");
653
+ console.error(" Smart Account:", evmAddress);
654
+ console.error(" Target Contract:", contractAddress);
655
+ console.error(" Function:", functionName);
656
+ console.error("=".repeat(80));
657
+ return {
658
+ success: false,
659
+ message: errorMessage,
660
+ details: {
661
+ code: opError?.code,
662
+ originalError: opError?.message
663
+ }
664
+ };
543
665
  }
544
666
  },
545
- [sendUserOperation, publicClient]
667
+ [sendUserOperation, publicClient, isProduction]
546
668
  );
547
669
  return { sendOperationFn, data, status, error };
548
670
  }
package/dist/index.mjs CHANGED
@@ -409,7 +409,13 @@ function useFetchNotifications() {
409
409
  // src/utils/coinbase/useSendCoinbaseUserOperation.ts
410
410
  import { useSendUserOperation } from "@coinbase/cdp-hooks";
411
411
  import { useCallback as useCallback10, useMemo } from "react";
412
- import { createPublicClient, encodeFunctionData, http } from "viem";
412
+ import {
413
+ BaseError,
414
+ ContractFunctionRevertedError,
415
+ createPublicClient,
416
+ encodeFunctionData,
417
+ http
418
+ } from "viem";
413
419
  import { base, baseSepolia } from "viem/chains";
414
420
  function useSendCoinbaseUserOperation() {
415
421
  const { isProduction } = useAnymalConfig();
@@ -426,40 +432,162 @@ function useSendCoinbaseUserOperation() {
426
432
  if (!evmAddress || !contractAddress || !abi || !functionName) {
427
433
  return { success: false, message: "Missing required information" };
428
434
  }
435
+ console.log("\u{1F50D} Transaction Details:", {
436
+ network: isProduction ? "base" : "base-sepolia",
437
+ evmAddress,
438
+ contractAddress,
439
+ functionName,
440
+ args
441
+ });
429
442
  try {
430
- await publicClient.simulateContract({
443
+ console.log("\u23F3 Simulating contract call...");
444
+ const result = await publicClient.simulateContract({
431
445
  address: contractAddress,
432
446
  abi,
433
447
  functionName,
434
448
  args,
435
449
  account: evmAddress
436
450
  });
451
+ console.log("\u2705 Simulation successful:", result);
437
452
  } catch (simError) {
438
- console.error("\u274C Simulation failed:", simError);
453
+ console.error("=".repeat(80));
454
+ console.error("\u274C SIMULATION FAILED - DETAILED ERROR");
455
+ console.error("=".repeat(80));
456
+ let errorMessage = "Simulation failed";
457
+ let errorDetails = {};
458
+ if (simError instanceof BaseError) {
459
+ console.error("\u{1F4CB} VIEM ERROR:");
460
+ console.error(" Name:", simError.name);
461
+ console.error(" Message:", simError.message);
462
+ console.error(" Short Message:", simError.shortMessage);
463
+ console.error(" Details:", simError.details);
464
+ const revertError = simError.walk(
465
+ (err) => err instanceof ContractFunctionRevertedError
466
+ );
467
+ if (revertError instanceof ContractFunctionRevertedError) {
468
+ console.error("\n\u{1F534} CONTRACT REVERT DETECTED:");
469
+ console.error(
470
+ " Error Name:",
471
+ revertError.data?.errorName ?? "Unknown"
472
+ );
473
+ console.error(" Error Args:", revertError.data?.args ?? []);
474
+ console.error(" Signature:", revertError.signature);
475
+ console.error(" Reason:", revertError.reason);
476
+ errorDetails = {
477
+ errorName: revertError.data?.errorName,
478
+ errorArgs: revertError.data?.args,
479
+ signature: revertError.signature,
480
+ reason: revertError.reason
481
+ };
482
+ const errorName = revertError.data?.errorName ?? "Unknown";
483
+ const errorArgs = revertError.data?.args ?? [];
484
+ if (errorName !== "Unknown") {
485
+ errorMessage = `Contract reverted: ${errorName}(${errorArgs.join(", ")})`;
486
+ } else {
487
+ errorMessage = revertError.shortMessage || revertError.message;
488
+ }
489
+ } else {
490
+ errorMessage = simError.shortMessage || simError.message;
491
+ }
492
+ } else {
493
+ console.error("\u26A0\uFE0F NON-VIEM ERROR:", {
494
+ name: simError?.name,
495
+ message: simError?.message,
496
+ cause: simError?.cause
497
+ });
498
+ errorMessage = simError?.message || "Unknown simulation error";
499
+ }
500
+ console.error("\n\u{1F4CD} CALL CONTEXT:");
501
+ console.error(" Contract:", contractAddress);
502
+ console.error(" Function:", functionName);
503
+ console.error(" Args:", JSON.stringify(args, null, 2));
504
+ console.error(" Sender:", evmAddress);
505
+ console.error(" Network:", isProduction ? "base" : "base-sepolia");
506
+ if (simError?.data) {
507
+ console.error("\n\u{1F4E6} RAW ERROR DATA:", simError.data);
508
+ }
509
+ if (simError?.cause) {
510
+ console.error("\n\u{1F517} ERROR CAUSE CHAIN:");
511
+ let cause = simError.cause;
512
+ let depth = 1;
513
+ while (cause && depth < 5) {
514
+ console.error(` ${depth}. ${cause.message || cause}`);
515
+ cause = cause.cause;
516
+ depth++;
517
+ }
518
+ }
519
+ console.error("=".repeat(80));
439
520
  return {
440
521
  success: false,
441
- message: `Simulation failed: ${simError.shortMessage || simError.message}`
522
+ message: errorMessage,
523
+ details: errorDetails
442
524
  };
443
525
  }
444
526
  try {
527
+ console.log("\u23F3 Encoding and sending user operation...");
445
528
  const callData = encodeFunctionData({
446
529
  abi,
447
530
  functionName,
448
531
  args
449
532
  });
533
+ console.log("\u{1F4E4} Sending with paymaster:", {
534
+ evmSmartAccount: evmAddress,
535
+ network: isProduction ? "base" : "base-sepolia",
536
+ useCdpPaymaster: true,
537
+ to: contractAddress,
538
+ callDataLength: callData.length
539
+ });
450
540
  await sendUserOperation({
451
541
  evmSmartAccount: evmAddress,
452
542
  network: isProduction ? "base" : "base-sepolia",
453
543
  useCdpPaymaster: true,
454
544
  calls: [{ data: callData, to: contractAddress }]
455
545
  });
546
+ console.log("\u2705 User operation submitted successfully");
456
547
  return { success: true, message: "Operation submitted." };
457
- } catch (e) {
458
- console.error("\u274C Operation failed:", e);
459
- return { success: false, message: e.message };
548
+ } catch (opError) {
549
+ console.error("=".repeat(80));
550
+ console.error("\u274C USER OPERATION FAILED");
551
+ console.error("=".repeat(80));
552
+ console.error("Error:", opError);
553
+ let errorMessage = "Operation failed";
554
+ if (opError?.message?.includes("allowlist")) {
555
+ console.error("\n\u{1F6AB} PAYMASTER ALLOWLIST ERROR");
556
+ console.error(" The contract is not in the paymaster allowlist");
557
+ console.error(
558
+ " Add this contract to CDP Portal \u2192 Paymaster \u2192 Allowlist:"
559
+ );
560
+ console.error(" ", contractAddress);
561
+ errorMessage = `Contract ${contractAddress} not in paymaster allowlist`;
562
+ } else if (opError?.message?.includes("insufficient balance")) {
563
+ console.error("\n\u{1F4B0} INSUFFICIENT BALANCE ERROR");
564
+ console.error(" Paymaster or smart account has insufficient funds");
565
+ errorMessage = "Insufficient balance for gas payment";
566
+ } else if (opError?.code === -32002) {
567
+ console.error("\n\u{1F6AB} PAYMASTER POLICY ERROR");
568
+ console.error(" Code:", opError.code);
569
+ console.error(" Message:", opError.message);
570
+ errorMessage = `Paymaster policy error: ${opError.message}`;
571
+ } else {
572
+ errorMessage = opError?.message || "Unknown operation error";
573
+ }
574
+ console.error("\n\u{1F4CD} OPERATION CONTEXT:");
575
+ console.error(" Network:", isProduction ? "base" : "base-sepolia");
576
+ console.error(" Smart Account:", evmAddress);
577
+ console.error(" Target Contract:", contractAddress);
578
+ console.error(" Function:", functionName);
579
+ console.error("=".repeat(80));
580
+ return {
581
+ success: false,
582
+ message: errorMessage,
583
+ details: {
584
+ code: opError?.code,
585
+ originalError: opError?.message
586
+ }
587
+ };
460
588
  }
461
589
  },
462
- [sendUserOperation, publicClient]
590
+ [sendUserOperation, publicClient, isProduction]
463
591
  );
464
592
  return { sendOperationFn, data, status, error };
465
593
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.158",
3
+ "version": "1.0.160",
4
4
  "description": "A React/TypeScript-based utility library for reusable functions and hooks inside of the Anymal Ecosystem.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {