anymal-protocol 1.0.159 → 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,49 +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({
513
- isProduction,
512
+ console.log("\u{1F50D} Transaction Details:", {
513
+ network: isProduction ? "base" : "base-sepolia",
514
514
  evmAddress,
515
515
  contractAddress,
516
- abi,
517
516
  functionName,
518
- args,
519
- publicClient
517
+ args
520
518
  });
521
519
  try {
522
- await publicClient.simulateContract({
520
+ console.log("\u23F3 Simulating contract call...");
521
+ const result = await publicClient.simulateContract({
523
522
  address: contractAddress,
524
523
  abi,
525
524
  functionName,
526
525
  args,
527
526
  account: evmAddress
528
527
  });
528
+ console.log("\u2705 Simulation successful:", result);
529
529
  } catch (simError) {
530
- 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));
531
597
  return {
532
598
  success: false,
533
- message: `Simulation failed: ${simError.shortMessage || simError.message}`
599
+ message: errorMessage,
600
+ details: errorDetails
534
601
  };
535
602
  }
536
603
  try {
604
+ console.log("\u23F3 Encoding and sending user operation...");
537
605
  const callData = (0, import_viem.encodeFunctionData)({
538
606
  abi,
539
607
  functionName,
540
608
  args
541
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
+ });
542
617
  await sendUserOperation({
543
618
  evmSmartAccount: evmAddress,
544
619
  network: isProduction ? "base" : "base-sepolia",
545
620
  useCdpPaymaster: true,
546
621
  calls: [{ data: callData, to: contractAddress }]
547
622
  });
623
+ console.log("\u2705 User operation submitted successfully");
548
624
  return { success: true, message: "Operation submitted." };
549
- } catch (e) {
550
- console.error("\u274C Operation failed:", e);
551
- 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
+ };
552
665
  }
553
666
  },
554
- [sendUserOperation, publicClient]
667
+ [sendUserOperation, publicClient, isProduction]
555
668
  );
556
669
  return { sendOperationFn, data, status, error };
557
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,49 +432,162 @@ function useSendCoinbaseUserOperation() {
426
432
  if (!evmAddress || !contractAddress || !abi || !functionName) {
427
433
  return { success: false, message: "Missing required information" };
428
434
  }
429
- console.log({
430
- isProduction,
435
+ console.log("\u{1F50D} Transaction Details:", {
436
+ network: isProduction ? "base" : "base-sepolia",
431
437
  evmAddress,
432
438
  contractAddress,
433
- abi,
434
439
  functionName,
435
- args,
436
- publicClient
440
+ args
437
441
  });
438
442
  try {
439
- await publicClient.simulateContract({
443
+ console.log("\u23F3 Simulating contract call...");
444
+ const result = await publicClient.simulateContract({
440
445
  address: contractAddress,
441
446
  abi,
442
447
  functionName,
443
448
  args,
444
449
  account: evmAddress
445
450
  });
451
+ console.log("\u2705 Simulation successful:", result);
446
452
  } catch (simError) {
447
- 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));
448
520
  return {
449
521
  success: false,
450
- message: `Simulation failed: ${simError.shortMessage || simError.message}`
522
+ message: errorMessage,
523
+ details: errorDetails
451
524
  };
452
525
  }
453
526
  try {
527
+ console.log("\u23F3 Encoding and sending user operation...");
454
528
  const callData = encodeFunctionData({
455
529
  abi,
456
530
  functionName,
457
531
  args
458
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
+ });
459
540
  await sendUserOperation({
460
541
  evmSmartAccount: evmAddress,
461
542
  network: isProduction ? "base" : "base-sepolia",
462
543
  useCdpPaymaster: true,
463
544
  calls: [{ data: callData, to: contractAddress }]
464
545
  });
546
+ console.log("\u2705 User operation submitted successfully");
465
547
  return { success: true, message: "Operation submitted." };
466
- } catch (e) {
467
- console.error("\u274C Operation failed:", e);
468
- 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
+ };
469
588
  }
470
589
  },
471
- [sendUserOperation, publicClient]
590
+ [sendUserOperation, publicClient, isProduction]
472
591
  );
473
592
  return { sendOperationFn, data, status, error };
474
593
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.159",
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": {