anymal-protocol 1.0.159 → 1.0.161
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 +35 -18
- package/dist/index.mjs +42 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -509,15 +509,6 @@ 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,
|
|
514
|
-
evmAddress,
|
|
515
|
-
contractAddress,
|
|
516
|
-
abi,
|
|
517
|
-
functionName,
|
|
518
|
-
args,
|
|
519
|
-
publicClient
|
|
520
|
-
});
|
|
521
512
|
try {
|
|
522
513
|
await publicClient.simulateContract({
|
|
523
514
|
address: contractAddress,
|
|
@@ -527,11 +518,27 @@ function useSendCoinbaseUserOperation() {
|
|
|
527
518
|
account: evmAddress
|
|
528
519
|
});
|
|
529
520
|
} catch (simError) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
521
|
+
let errorMessage = "Simulation failed";
|
|
522
|
+
if (simError instanceof import_viem.BaseError) {
|
|
523
|
+
const revertError = simError.walk(
|
|
524
|
+
(err) => err instanceof import_viem.ContractFunctionRevertedError
|
|
525
|
+
);
|
|
526
|
+
if (revertError instanceof import_viem.ContractFunctionRevertedError) {
|
|
527
|
+
const errorName = revertError.data?.errorName ?? "Unknown";
|
|
528
|
+
const errorArgs = revertError.data?.args ?? [];
|
|
529
|
+
if (errorName !== "Unknown") {
|
|
530
|
+
errorMessage = `Contract reverted: ${errorName}(${errorArgs.join(", ")})`;
|
|
531
|
+
} else {
|
|
532
|
+
errorMessage = revertError.shortMessage || revertError.message;
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
errorMessage = simError.shortMessage || simError.message;
|
|
536
|
+
}
|
|
537
|
+
} else {
|
|
538
|
+
errorMessage = simError?.message || "Unknown simulation error";
|
|
539
|
+
}
|
|
540
|
+
console.error("\u274C Simulation failed:", errorMessage);
|
|
541
|
+
return { success: false, message: errorMessage };
|
|
535
542
|
}
|
|
536
543
|
try {
|
|
537
544
|
const callData = (0, import_viem.encodeFunctionData)({
|
|
@@ -546,12 +553,22 @@ function useSendCoinbaseUserOperation() {
|
|
|
546
553
|
calls: [{ data: callData, to: contractAddress }]
|
|
547
554
|
});
|
|
548
555
|
return { success: true, message: "Operation submitted." };
|
|
549
|
-
} catch (
|
|
550
|
-
|
|
551
|
-
|
|
556
|
+
} catch (opError) {
|
|
557
|
+
let errorMessage = "Operation failed";
|
|
558
|
+
if (opError?.message?.includes("allowlist")) {
|
|
559
|
+
errorMessage = `Contract ${contractAddress} not in paymaster allowlist`;
|
|
560
|
+
} else if (opError?.message?.includes("insufficient balance")) {
|
|
561
|
+
errorMessage = "Insufficient balance for gas payment";
|
|
562
|
+
} else if (opError?.code === -32002) {
|
|
563
|
+
errorMessage = `Paymaster policy error: ${opError.message}`;
|
|
564
|
+
} else {
|
|
565
|
+
errorMessage = opError?.message || "Unknown operation error";
|
|
566
|
+
}
|
|
567
|
+
console.error("\u274C Operation failed:", errorMessage);
|
|
568
|
+
return { success: false, message: errorMessage };
|
|
552
569
|
}
|
|
553
570
|
},
|
|
554
|
-
[sendUserOperation, publicClient]
|
|
571
|
+
[sendUserOperation, publicClient, isProduction]
|
|
555
572
|
);
|
|
556
573
|
return { sendOperationFn, data, status, error };
|
|
557
574
|
}
|
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 {
|
|
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,15 +432,6 @@ 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,
|
|
431
|
-
evmAddress,
|
|
432
|
-
contractAddress,
|
|
433
|
-
abi,
|
|
434
|
-
functionName,
|
|
435
|
-
args,
|
|
436
|
-
publicClient
|
|
437
|
-
});
|
|
438
435
|
try {
|
|
439
436
|
await publicClient.simulateContract({
|
|
440
437
|
address: contractAddress,
|
|
@@ -444,11 +441,27 @@ function useSendCoinbaseUserOperation() {
|
|
|
444
441
|
account: evmAddress
|
|
445
442
|
});
|
|
446
443
|
} catch (simError) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
444
|
+
let errorMessage = "Simulation failed";
|
|
445
|
+
if (simError instanceof BaseError) {
|
|
446
|
+
const revertError = simError.walk(
|
|
447
|
+
(err) => err instanceof ContractFunctionRevertedError
|
|
448
|
+
);
|
|
449
|
+
if (revertError instanceof ContractFunctionRevertedError) {
|
|
450
|
+
const errorName = revertError.data?.errorName ?? "Unknown";
|
|
451
|
+
const errorArgs = revertError.data?.args ?? [];
|
|
452
|
+
if (errorName !== "Unknown") {
|
|
453
|
+
errorMessage = `Contract reverted: ${errorName}(${errorArgs.join(", ")})`;
|
|
454
|
+
} else {
|
|
455
|
+
errorMessage = revertError.shortMessage || revertError.message;
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
errorMessage = simError.shortMessage || simError.message;
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
errorMessage = simError?.message || "Unknown simulation error";
|
|
462
|
+
}
|
|
463
|
+
console.error("\u274C Simulation failed:", errorMessage);
|
|
464
|
+
return { success: false, message: errorMessage };
|
|
452
465
|
}
|
|
453
466
|
try {
|
|
454
467
|
const callData = encodeFunctionData({
|
|
@@ -463,12 +476,22 @@ function useSendCoinbaseUserOperation() {
|
|
|
463
476
|
calls: [{ data: callData, to: contractAddress }]
|
|
464
477
|
});
|
|
465
478
|
return { success: true, message: "Operation submitted." };
|
|
466
|
-
} catch (
|
|
467
|
-
|
|
468
|
-
|
|
479
|
+
} catch (opError) {
|
|
480
|
+
let errorMessage = "Operation failed";
|
|
481
|
+
if (opError?.message?.includes("allowlist")) {
|
|
482
|
+
errorMessage = `Contract ${contractAddress} not in paymaster allowlist`;
|
|
483
|
+
} else if (opError?.message?.includes("insufficient balance")) {
|
|
484
|
+
errorMessage = "Insufficient balance for gas payment";
|
|
485
|
+
} else if (opError?.code === -32002) {
|
|
486
|
+
errorMessage = `Paymaster policy error: ${opError.message}`;
|
|
487
|
+
} else {
|
|
488
|
+
errorMessage = opError?.message || "Unknown operation error";
|
|
489
|
+
}
|
|
490
|
+
console.error("\u274C Operation failed:", errorMessage);
|
|
491
|
+
return { success: false, message: errorMessage };
|
|
469
492
|
}
|
|
470
493
|
},
|
|
471
|
-
[sendUserOperation, publicClient]
|
|
494
|
+
[sendUserOperation, publicClient, isProduction]
|
|
472
495
|
);
|
|
473
496
|
return { sendOperationFn, data, status, error };
|
|
474
497
|
}
|
package/package.json
CHANGED