anymal-protocol 1.0.131 → 1.0.133

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
@@ -54,7 +54,7 @@ declare function useUpdateUserName(): (dbAuthToken: string, docID: string, name:
54
54
  declare function useFetchNotifications(): (pid: string, dbAuthToken: string, endpoint: string, additionalFilters?: Record<string, any>) => Promise<any>;
55
55
 
56
56
  declare function useSendCoinbaseUserOperation(): {
57
- sendOperationFn: (evmAddress: `0x${string}`, callData: any, contractAddress: `0x${string}`) => Promise<{
57
+ sendOperationFn: (evmAddress: `0x${string}`, contractAddress: `0x${string}`, abi: any, functionName: string, args: any[]) => Promise<{
58
58
  success: boolean;
59
59
  message: string;
60
60
  }>;
package/dist/index.d.ts CHANGED
@@ -54,7 +54,7 @@ declare function useUpdateUserName(): (dbAuthToken: string, docID: string, name:
54
54
  declare function useFetchNotifications(): (pid: string, dbAuthToken: string, endpoint: string, additionalFilters?: Record<string, any>) => Promise<any>;
55
55
 
56
56
  declare function useSendCoinbaseUserOperation(): {
57
- sendOperationFn: (evmAddress: `0x${string}`, callData: any, contractAddress: `0x${string}`) => Promise<{
57
+ sendOperationFn: (evmAddress: `0x${string}`, contractAddress: `0x${string}`, abi: any, functionName: string, args: any[]) => Promise<{
58
58
  success: boolean;
59
59
  message: string;
60
60
  }>;
package/dist/index.js CHANGED
@@ -471,30 +471,47 @@ var import_viem = require("viem");
471
471
  var import_chains = require("viem/chains");
472
472
  function useSendCoinbaseUserOperation() {
473
473
  const { sendUserOperation, data, error, status } = (0, import_cdp_hooks.useSendUserOperation)();
474
+ const publicClient = (0, import_react10.useMemo)(
475
+ () => (0, import_viem.createPublicClient)({
476
+ chain: import_chains.baseSepolia,
477
+ transport: (0, import_viem.http)()
478
+ }),
479
+ []
480
+ );
474
481
  const sendOperationFn = (0, import_react10.useCallback)(
475
- async (evmAddress, callData, contractAddress) => {
476
- if (!evmAddress || !callData || !contractAddress) {
482
+ async (evmAddress, contractAddress, abi, functionName, args) => {
483
+ if (!evmAddress || !contractAddress || !abi || !functionName) {
477
484
  return { success: false, message: "Missing required information" };
478
485
  }
479
- const publicClient = (0, import_viem.createPublicClient)({
480
- chain: import_chains.baseSepolia,
481
- transport: (0, import_viem.http)()
482
- });
486
+ console.log("=== Contract Call Details ===");
487
+ console.log("Function:", functionName);
488
+ console.log("Args:", args);
489
+ console.log("Contract:", contractAddress);
490
+ console.log("Account:", evmAddress);
491
+ console.log("============================");
483
492
  try {
484
- const result = await publicClient.call({
485
- account: evmAddress,
486
- to: contractAddress,
487
- data: callData
493
+ await publicClient.simulateContract({
494
+ address: contractAddress,
495
+ abi,
496
+ functionName,
497
+ args,
498
+ account: evmAddress
488
499
  });
489
- console.log("Simulation successful:", result);
500
+ console.log("\u2705 Simulation successful");
490
501
  } catch (simError) {
491
- console.error("Simulation failed:", simError);
502
+ console.error("\u274C Simulation failed:", simError);
503
+ console.log("Failed with args:", JSON.stringify(args, null, 2));
492
504
  return {
493
505
  success: false,
494
- message: `Simulation failed: ${simError.message}`
506
+ message: `Simulation failed: ${simError.shortMessage || simError.message}`
495
507
  };
496
508
  }
497
509
  try {
510
+ const callData = (0, import_viem.encodeFunctionData)({
511
+ abi,
512
+ functionName,
513
+ args
514
+ });
498
515
  await sendUserOperation({
499
516
  evmSmartAccount: evmAddress,
500
517
  network: "base-sepolia",
@@ -503,18 +520,15 @@ function useSendCoinbaseUserOperation() {
503
520
  });
504
521
  return { success: true, message: "Operation submitted." };
505
522
  } catch (e) {
506
- console.error("Full error:", e);
523
+ console.error("\u274C Operation failed:", e);
507
524
  return { success: false, message: e.message };
508
525
  }
509
526
  },
510
- [sendUserOperation]
527
+ [sendUserOperation, publicClient]
511
528
  );
512
529
  return { sendOperationFn, data, status, error };
513
530
  }
514
531
 
515
- // src/utils/coinbase/useCoinbaseClaimActionReward.ts
516
- var import_viem3 = require("viem");
517
-
518
532
  // src/helpers/BlockchainAbiHelper.tsx
519
533
  var import_viem2 = require("viem");
520
534
  var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {
@@ -2959,35 +2973,20 @@ function useCoinbaseClaimActionReward() {
2959
2973
  status: "error"
2960
2974
  };
2961
2975
  }
2962
- try {
2963
- const args = [actionId, claimIndex];
2964
- const functionName = "claimByIndex";
2965
- const callData = (0, import_viem3.encodeFunctionData)({
2966
- abi: REWARDABLE_ACTIONS_ABI,
2967
- functionName,
2968
- args
2969
- });
2970
- const opsRes = await sendOperationFn(
2971
- evmAddress,
2972
- callData,
2973
- validationContractAddress
2974
- );
2975
- return { success: opsRes.success, message: opsRes.message, status };
2976
- } catch (error) {
2977
- console.error(error);
2978
- return {
2979
- success: false,
2980
- message: "Reward not claimed",
2981
- status: "error"
2982
- };
2983
- }
2976
+ const result = await sendOperationFn(
2977
+ evmAddress,
2978
+ validationContractAddress,
2979
+ REWARDABLE_ACTIONS_ABI,
2980
+ "claimByIndex",
2981
+ [actionId, claimIndex]
2982
+ );
2983
+ return { ...result, status };
2984
2984
  },
2985
- []
2985
+ [sendOperationFn, status]
2986
2986
  );
2987
2987
  }
2988
2988
 
2989
2989
  // src/utils/coinbase/useCoinbaseMintAnymalNFT.ts
2990
- var import_viem4 = require("viem");
2991
2990
  var import_react12 = require("react");
2992
2991
  function useCoinbaseMintAnymalNFT() {
2993
2992
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
@@ -3000,37 +2999,27 @@ function useCoinbaseMintAnymalNFT() {
3000
2999
  status: "error"
3001
3000
  };
3002
3001
  }
3003
- try {
3004
- const functionName = "submitMetadataByCampaignName";
3005
- const args = [
3002
+ const result = await sendOperationFn(
3003
+ evmAddress,
3004
+ validationContractAddress,
3005
+ PET_NFT_ABI,
3006
+ "submitMetadataByCampaignName",
3007
+ [
3006
3008
  pid,
3007
3009
  nftId,
3008
3010
  `https://dev-nft.petastic.com/metadata/${nftId}`,
3009
3011
  "petastic-signup-campaign-1",
3010
3012
  anymalTxId
3011
- ];
3012
- const callData = (0, import_viem4.encodeFunctionData)({
3013
- abi: PET_NFT_ABI,
3014
- functionName,
3015
- args
3016
- });
3017
- const opsRes = await sendOperationFn(
3018
- evmAddress,
3019
- callData,
3020
- validationContractAddress
3021
- );
3022
- return { success: opsRes.success, message: opsRes.message, status };
3023
- } catch (error) {
3024
- console.error(error);
3025
- return { success: false, message: "Error", status: "error" };
3026
- }
3013
+ ]
3014
+ );
3015
+ return { ...result, status };
3027
3016
  },
3028
- []
3017
+ [sendOperationFn, status]
3029
3018
  );
3030
3019
  }
3031
3020
 
3032
3021
  // src/utils/anymals/useMintAnymalNFT.ts
3033
- var import_viem6 = require("viem");
3022
+ var import_viem4 = require("viem");
3034
3023
  var import_react13 = require("react");
3035
3024
 
3036
3025
  // src/helpers/GasEstimateHelper.tsx
@@ -3075,18 +3064,18 @@ async function applyBundlerGasEstimator(account, bundlerClient, options) {
3075
3064
  }
3076
3065
 
3077
3066
  // src/helpers/HumanRevert.tsx
3078
- var import_viem5 = require("viem");
3067
+ var import_viem3 = require("viem");
3079
3068
  function humanRevert(raw, shortMessage) {
3080
3069
  if (!raw) return shortMessage ?? "Simulation reverted";
3081
3070
  try {
3082
- const { errorName, args } = (0, import_viem5.decodeErrorResult)({
3071
+ const { errorName, args } = (0, import_viem3.decodeErrorResult)({
3083
3072
  abi: ERROR_ABI,
3084
3073
  data: raw
3085
3074
  });
3086
3075
  return `${errorName}(${args.map(String).join(", ")})`;
3087
3076
  } catch {
3088
3077
  if (raw.startsWith("0x08c379a0") && raw.length >= 138) {
3089
- return (0, import_viem5.hexToString)(`0x${raw.slice(138)}`);
3078
+ return (0, import_viem3.hexToString)(`0x${raw.slice(138)}`);
3090
3079
  }
3091
3080
  return `${raw.slice(0, 10)}\u2026`;
3092
3081
  }
@@ -3128,7 +3117,7 @@ function useMintAnymalNFT() {
3128
3117
  "petastic-signup-campaign-1",
3129
3118
  anymalTxId
3130
3119
  ];
3131
- const callData = (0, import_viem6.encodeFunctionData)({
3120
+ const callData = (0, import_viem4.encodeFunctionData)({
3132
3121
  abi: PET_NFT_ABI,
3133
3122
  functionName,
3134
3123
  args
@@ -3315,7 +3304,7 @@ function useUploadAnymalImage() {
3315
3304
  var import_react16 = require("react");
3316
3305
 
3317
3306
  // src/helpers/ProcessDirectPartialPayment.tsx
3318
- var import_viem7 = require("viem");
3307
+ var import_viem5 = require("viem");
3319
3308
 
3320
3309
  // src/helpers/SendUserOpWithRetries.tsx
3321
3310
  async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
@@ -3375,7 +3364,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
3375
3364
  deadline,
3376
3365
  backendSignature
3377
3366
  ];
3378
- const partialPayCalldata = (0, import_viem7.encodeFunctionData)({
3367
+ const partialPayCalldata = (0, import_viem5.encodeFunctionData)({
3379
3368
  abi: MARKETPLACE_ABI,
3380
3369
  functionName,
3381
3370
  args
@@ -3471,20 +3460,20 @@ function useProcessPartialKibblePayment() {
3471
3460
  var import_react17 = require("react");
3472
3461
 
3473
3462
  // src/helpers/ProcessDirectKibbleApproval.tsx
3474
- var import_viem8 = require("viem");
3463
+ var import_viem6 = require("viem");
3475
3464
  async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
3476
3465
  try {
3477
3466
  const functionName = "approve";
3478
3467
  const args = [spenderAddress, approveAmount];
3479
- const approveCalldata = (0, import_viem8.encodeFunctionData)({
3480
- abi: import_viem8.erc20Abi,
3468
+ const approveCalldata = (0, import_viem6.encodeFunctionData)({
3469
+ abi: import_viem6.erc20Abi,
3481
3470
  functionName,
3482
3471
  args
3483
3472
  });
3484
3473
  await simulateCall(
3485
3474
  bundlerClient.client,
3486
3475
  kibbleTokenAddress,
3487
- import_viem8.erc20Abi,
3476
+ import_viem6.erc20Abi,
3488
3477
  functionName,
3489
3478
  args,
3490
3479
  smartAccount.address
@@ -3541,7 +3530,7 @@ function useApproveKibbleToken() {
3541
3530
 
3542
3531
  // src/utils/organization/useCreateOrganizationBase.ts
3543
3532
  var import_react18 = require("react");
3544
- var import_viem9 = require("viem");
3533
+ var import_viem7 = require("viem");
3545
3534
  function useCreateOrganizationBase() {
3546
3535
  return (0, import_react18.useCallback)(
3547
3536
  /**
@@ -3565,7 +3554,7 @@ function useCreateOrganizationBase() {
3565
3554
  try {
3566
3555
  const functionName = "createOrganizationProxy";
3567
3556
  const args = [ownerAddress, orgName, orgPid];
3568
- const callData = (0, import_viem9.encodeFunctionData)({
3557
+ const callData = (0, import_viem7.encodeFunctionData)({
3569
3558
  abi: ORGANIZATION_BEACON_ABI,
3570
3559
  functionName,
3571
3560
  args
@@ -3603,7 +3592,7 @@ function useCreateOrganizationBase() {
3603
3592
  let proxyAddress;
3604
3593
  for (const log of txReceipt.logs) {
3605
3594
  try {
3606
- const decoded = (0, import_viem9.decodeEventLog)({
3595
+ const decoded = (0, import_viem7.decodeEventLog)({
3607
3596
  abi: ORGANIZATION_BEACON_ABI,
3608
3597
  data: log.data,
3609
3598
  topics: log.topics
@@ -3642,10 +3631,10 @@ function useCreateOrganizationBase() {
3642
3631
  var import_react19 = require("react");
3643
3632
 
3644
3633
  // src/helpers/ProcessOrgKibbleApproval.tsx
3645
- var import_viem11 = require("viem");
3634
+ var import_viem9 = require("viem");
3646
3635
 
3647
3636
  // src/helpers/WaitForAllowance.tsx
3648
- var import_viem10 = require("viem");
3637
+ var import_viem8 = require("viem");
3649
3638
  async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spenderAddress, expectedAmount) {
3650
3639
  const MAX_RETRIES = 10;
3651
3640
  const RETRY_INTERVAL = 2e3;
@@ -3654,7 +3643,7 @@ async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spende
3654
3643
  try {
3655
3644
  const currentAllowance = await publicClient.readContract({
3656
3645
  address: tokenAddress,
3657
- abi: import_viem10.erc20Abi,
3646
+ abi: import_viem8.erc20Abi,
3658
3647
  functionName: "allowance",
3659
3648
  args: [ownerAddress, spenderAddress]
3660
3649
  });
@@ -3679,13 +3668,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
3679
3668
  if (approveAmount <= 0n) {
3680
3669
  return { success: false, message: "Approval amount must be greater than zero." };
3681
3670
  }
3682
- const approveCalldata = (0, import_viem11.encodeFunctionData)({
3683
- abi: import_viem11.erc20Abi,
3671
+ const approveCalldata = (0, import_viem9.encodeFunctionData)({
3672
+ abi: import_viem9.erc20Abi,
3684
3673
  functionName: "approve",
3685
3674
  args: [partialPaymentModuleAddress, approveAmount]
3686
3675
  });
3687
3676
  const args = [kibbleTokenAddress, approveCalldata];
3688
- const executeApproveCalldata = (0, import_viem11.encodeFunctionData)({
3677
+ const executeApproveCalldata = (0, import_viem9.encodeFunctionData)({
3689
3678
  abi: ORGANIZATION_IMPL_ABI,
3690
3679
  functionName: ORG_FUNCTION,
3691
3680
  args
@@ -3772,10 +3761,10 @@ function useApproveOrgPartialPayment() {
3772
3761
  var import_react20 = require("react");
3773
3762
 
3774
3763
  // src/helpers/ProcessOrgPartialPayment.tsx
3775
- var import_viem12 = require("viem");
3764
+ var import_viem10 = require("viem");
3776
3765
  async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
3777
3766
  try {
3778
- const partialPayCalldata = (0, import_viem12.encodeFunctionData)({
3767
+ const partialPayCalldata = (0, import_viem10.encodeFunctionData)({
3779
3768
  abi: MARKETPLACE_ABI,
3780
3769
  functionName: "partialPay",
3781
3770
  args: [
@@ -3790,7 +3779,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
3790
3779
  ]
3791
3780
  });
3792
3781
  const args = [partialPaymentModuleAddress, partialPayCalldata];
3793
- const executePartialPayCalldata = (0, import_viem12.encodeFunctionData)({
3782
+ const executePartialPayCalldata = (0, import_viem10.encodeFunctionData)({
3794
3783
  abi: ORGANIZATION_IMPL_ABI,
3795
3784
  functionName: ORG_FUNCTION,
3796
3785
  args
@@ -3906,7 +3895,7 @@ function useUpdateOrgWalletAddress() {
3906
3895
  }
3907
3896
 
3908
3897
  // src/utils/organization/useMintOrgAnymalNFT.ts
3909
- var import_viem13 = require("viem");
3898
+ var import_viem11 = require("viem");
3910
3899
  var import_react22 = require("react");
3911
3900
  function useMintOrgAnymalNFT() {
3912
3901
  return (0, import_react22.useCallback)(
@@ -3925,13 +3914,13 @@ function useMintOrgAnymalNFT() {
3925
3914
  "petastic-signup-campaign-1",
3926
3915
  anymalTxId
3927
3916
  ];
3928
- const callData = (0, import_viem13.encodeFunctionData)({
3917
+ const callData = (0, import_viem11.encodeFunctionData)({
3929
3918
  abi: PET_NFT_ABI,
3930
3919
  functionName,
3931
3920
  args
3932
3921
  });
3933
3922
  const executeArgs = [validationContractAddress, callData];
3934
- const executeSubmitMetaCalldata = (0, import_viem13.encodeFunctionData)({
3923
+ const executeSubmitMetaCalldata = (0, import_viem11.encodeFunctionData)({
3935
3924
  abi: ORGANIZATION_IMPL_ABI,
3936
3925
  functionName: ORG_FUNCTION,
3937
3926
  args: executeArgs
@@ -3964,10 +3953,10 @@ function useMintOrgAnymalNFT() {
3964
3953
 
3965
3954
  // src/helpers/NonceHelper.tsx
3966
3955
  var import_uuid = require("uuid");
3967
- var import_viem14 = require("viem");
3956
+ var import_viem12 = require("viem");
3968
3957
  var generateBytes32Nonce = () => {
3969
3958
  const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
3970
- return (0, import_viem14.padHex)(`0x${uuid3}`, { size: 32 });
3959
+ return (0, import_viem12.padHex)(`0x${uuid3}`, { size: 32 });
3971
3960
  };
3972
3961
 
3973
3962
  // src/helpers/CryptoUtils.tsx
@@ -4423,16 +4412,16 @@ function useCreateOrganizationAppData() {
4423
4412
 
4424
4413
  // src/utils/balance/useFetchBalance.ts
4425
4414
  var import_react27 = require("react");
4426
- var import_viem15 = require("viem");
4415
+ var import_viem13 = require("viem");
4427
4416
  function useFetchBalance() {
4428
4417
  return (0, import_react27.useCallback)(
4429
4418
  async (publicClient, walletAddress, kibbleTokenAddress) => {
4430
4419
  try {
4431
4420
  const balance = await publicClient.readContract({
4432
- address: (0, import_viem15.getAddress)(kibbleTokenAddress),
4433
- abi: import_viem15.erc20Abi,
4421
+ address: (0, import_viem13.getAddress)(kibbleTokenAddress),
4422
+ abi: import_viem13.erc20Abi,
4434
4423
  functionName: "balanceOf",
4435
- args: [(0, import_viem15.getAddress)(walletAddress)]
4424
+ args: [(0, import_viem13.getAddress)(walletAddress)]
4436
4425
  });
4437
4426
  return Number(balance);
4438
4427
  } catch (error) {
@@ -4444,7 +4433,7 @@ function useFetchBalance() {
4444
4433
  }
4445
4434
 
4446
4435
  // src/utils/actions/useClaimActionReward.ts
4447
- var import_viem16 = require("viem");
4436
+ var import_viem14 = require("viem");
4448
4437
  var import_react28 = require("react");
4449
4438
  function useClaimActionReward() {
4450
4439
  return (0, import_react28.useCallback)(
@@ -4457,7 +4446,7 @@ function useClaimActionReward() {
4457
4446
  }
4458
4447
  const args = [actionId, claimIndex];
4459
4448
  const functionName = "claimByIndex";
4460
- const callData = (0, import_viem16.encodeFunctionData)({
4449
+ const callData = (0, import_viem14.encodeFunctionData)({
4461
4450
  abi: REWARDABLE_ACTIONS_ABI,
4462
4451
  functionName,
4463
4452
  args
@@ -4493,7 +4482,7 @@ function useClaimActionReward() {
4493
4482
  }
4494
4483
 
4495
4484
  // src/utils/actions/useClaimOrgActionReward.ts
4496
- var import_viem17 = require("viem");
4485
+ var import_viem15 = require("viem");
4497
4486
  var import_react29 = require("react");
4498
4487
  function useClaimOrgActionReward() {
4499
4488
  return (0, import_react29.useCallback)(
@@ -4504,13 +4493,13 @@ function useClaimOrgActionReward() {
4504
4493
  message: "Missing web3auth account info or contract address."
4505
4494
  };
4506
4495
  }
4507
- const claimCallData = (0, import_viem17.encodeFunctionData)({
4496
+ const claimCallData = (0, import_viem15.encodeFunctionData)({
4508
4497
  abi: REWARDABLE_ACTIONS_ABI,
4509
4498
  functionName: "claimByIndex",
4510
4499
  args: [actionId, claimIndex]
4511
4500
  });
4512
4501
  const args = [rewardableActionContractAddress, claimCallData];
4513
- const executeClaimCalldata = (0, import_viem17.encodeFunctionData)({
4502
+ const executeClaimCalldata = (0, import_viem15.encodeFunctionData)({
4514
4503
  abi: ORGANIZATION_IMPL_ABI,
4515
4504
  functionName: ORG_FUNCTION,
4516
4505
  args
package/dist/index.mjs CHANGED
@@ -387,36 +387,53 @@ function useFetchNotifications() {
387
387
  }
388
388
 
389
389
  // src/utils/coinbase/useSendCoinbaseUserOperation.ts
390
- import { useCallback as useCallback10 } from "react";
390
+ import { useCallback as useCallback10, useMemo } from "react";
391
391
  import { useSendUserOperation } from "@coinbase/cdp-hooks";
392
- import { createPublicClient, http } from "viem";
392
+ import { createPublicClient, encodeFunctionData, http } from "viem";
393
393
  import { baseSepolia } from "viem/chains";
394
394
  function useSendCoinbaseUserOperation() {
395
395
  const { sendUserOperation, data, error, status } = useSendUserOperation();
396
+ const publicClient = useMemo(
397
+ () => createPublicClient({
398
+ chain: baseSepolia,
399
+ transport: http()
400
+ }),
401
+ []
402
+ );
396
403
  const sendOperationFn = useCallback10(
397
- async (evmAddress, callData, contractAddress) => {
398
- if (!evmAddress || !callData || !contractAddress) {
404
+ async (evmAddress, contractAddress, abi, functionName, args) => {
405
+ if (!evmAddress || !contractAddress || !abi || !functionName) {
399
406
  return { success: false, message: "Missing required information" };
400
407
  }
401
- const publicClient = createPublicClient({
402
- chain: baseSepolia,
403
- transport: http()
404
- });
408
+ console.log("=== Contract Call Details ===");
409
+ console.log("Function:", functionName);
410
+ console.log("Args:", args);
411
+ console.log("Contract:", contractAddress);
412
+ console.log("Account:", evmAddress);
413
+ console.log("============================");
405
414
  try {
406
- const result = await publicClient.call({
407
- account: evmAddress,
408
- to: contractAddress,
409
- data: callData
415
+ await publicClient.simulateContract({
416
+ address: contractAddress,
417
+ abi,
418
+ functionName,
419
+ args,
420
+ account: evmAddress
410
421
  });
411
- console.log("Simulation successful:", result);
422
+ console.log("\u2705 Simulation successful");
412
423
  } catch (simError) {
413
- console.error("Simulation failed:", simError);
424
+ console.error("\u274C Simulation failed:", simError);
425
+ console.log("Failed with args:", JSON.stringify(args, null, 2));
414
426
  return {
415
427
  success: false,
416
- message: `Simulation failed: ${simError.message}`
428
+ message: `Simulation failed: ${simError.shortMessage || simError.message}`
417
429
  };
418
430
  }
419
431
  try {
432
+ const callData = encodeFunctionData({
433
+ abi,
434
+ functionName,
435
+ args
436
+ });
420
437
  await sendUserOperation({
421
438
  evmSmartAccount: evmAddress,
422
439
  network: "base-sepolia",
@@ -425,18 +442,15 @@ function useSendCoinbaseUserOperation() {
425
442
  });
426
443
  return { success: true, message: "Operation submitted." };
427
444
  } catch (e) {
428
- console.error("Full error:", e);
445
+ console.error("\u274C Operation failed:", e);
429
446
  return { success: false, message: e.message };
430
447
  }
431
448
  },
432
- [sendUserOperation]
449
+ [sendUserOperation, publicClient]
433
450
  );
434
451
  return { sendOperationFn, data, status, error };
435
452
  }
436
453
 
437
- // src/utils/coinbase/useCoinbaseClaimActionReward.ts
438
- import { encodeFunctionData } from "viem";
439
-
440
454
  // src/helpers/BlockchainAbiHelper.tsx
441
455
  import { parseAbi } from "viem";
442
456
  var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {
@@ -2881,35 +2895,20 @@ function useCoinbaseClaimActionReward() {
2881
2895
  status: "error"
2882
2896
  };
2883
2897
  }
2884
- try {
2885
- const args = [actionId, claimIndex];
2886
- const functionName = "claimByIndex";
2887
- const callData = encodeFunctionData({
2888
- abi: REWARDABLE_ACTIONS_ABI,
2889
- functionName,
2890
- args
2891
- });
2892
- const opsRes = await sendOperationFn(
2893
- evmAddress,
2894
- callData,
2895
- validationContractAddress
2896
- );
2897
- return { success: opsRes.success, message: opsRes.message, status };
2898
- } catch (error) {
2899
- console.error(error);
2900
- return {
2901
- success: false,
2902
- message: "Reward not claimed",
2903
- status: "error"
2904
- };
2905
- }
2898
+ const result = await sendOperationFn(
2899
+ evmAddress,
2900
+ validationContractAddress,
2901
+ REWARDABLE_ACTIONS_ABI,
2902
+ "claimByIndex",
2903
+ [actionId, claimIndex]
2904
+ );
2905
+ return { ...result, status };
2906
2906
  },
2907
- []
2907
+ [sendOperationFn, status]
2908
2908
  );
2909
2909
  }
2910
2910
 
2911
2911
  // src/utils/coinbase/useCoinbaseMintAnymalNFT.ts
2912
- import { encodeFunctionData as encodeFunctionData2 } from "viem";
2913
2912
  import { useCallback as useCallback12 } from "react";
2914
2913
  function useCoinbaseMintAnymalNFT() {
2915
2914
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
@@ -2922,37 +2921,27 @@ function useCoinbaseMintAnymalNFT() {
2922
2921
  status: "error"
2923
2922
  };
2924
2923
  }
2925
- try {
2926
- const functionName = "submitMetadataByCampaignName";
2927
- const args = [
2924
+ const result = await sendOperationFn(
2925
+ evmAddress,
2926
+ validationContractAddress,
2927
+ PET_NFT_ABI,
2928
+ "submitMetadataByCampaignName",
2929
+ [
2928
2930
  pid,
2929
2931
  nftId,
2930
2932
  `https://dev-nft.petastic.com/metadata/${nftId}`,
2931
2933
  "petastic-signup-campaign-1",
2932
2934
  anymalTxId
2933
- ];
2934
- const callData = encodeFunctionData2({
2935
- abi: PET_NFT_ABI,
2936
- functionName,
2937
- args
2938
- });
2939
- const opsRes = await sendOperationFn(
2940
- evmAddress,
2941
- callData,
2942
- validationContractAddress
2943
- );
2944
- return { success: opsRes.success, message: opsRes.message, status };
2945
- } catch (error) {
2946
- console.error(error);
2947
- return { success: false, message: "Error", status: "error" };
2948
- }
2935
+ ]
2936
+ );
2937
+ return { ...result, status };
2949
2938
  },
2950
- []
2939
+ [sendOperationFn, status]
2951
2940
  );
2952
2941
  }
2953
2942
 
2954
2943
  // src/utils/anymals/useMintAnymalNFT.ts
2955
- import { encodeFunctionData as encodeFunctionData3 } from "viem";
2944
+ import { encodeFunctionData as encodeFunctionData2 } from "viem";
2956
2945
  import { useCallback as useCallback13 } from "react";
2957
2946
 
2958
2947
  // src/helpers/GasEstimateHelper.tsx
@@ -3050,7 +3039,7 @@ function useMintAnymalNFT() {
3050
3039
  "petastic-signup-campaign-1",
3051
3040
  anymalTxId
3052
3041
  ];
3053
- const callData = encodeFunctionData3({
3042
+ const callData = encodeFunctionData2({
3054
3043
  abi: PET_NFT_ABI,
3055
3044
  functionName,
3056
3045
  args
@@ -3237,7 +3226,7 @@ function useUploadAnymalImage() {
3237
3226
  import { useCallback as useCallback16 } from "react";
3238
3227
 
3239
3228
  // src/helpers/ProcessDirectPartialPayment.tsx
3240
- import { encodeFunctionData as encodeFunctionData4 } from "viem";
3229
+ import { encodeFunctionData as encodeFunctionData3 } from "viem";
3241
3230
 
3242
3231
  // src/helpers/SendUserOpWithRetries.tsx
3243
3232
  async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
@@ -3297,7 +3286,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
3297
3286
  deadline,
3298
3287
  backendSignature
3299
3288
  ];
3300
- const partialPayCalldata = encodeFunctionData4({
3289
+ const partialPayCalldata = encodeFunctionData3({
3301
3290
  abi: MARKETPLACE_ABI,
3302
3291
  functionName,
3303
3292
  args
@@ -3393,12 +3382,12 @@ function useProcessPartialKibblePayment() {
3393
3382
  import { useCallback as useCallback17 } from "react";
3394
3383
 
3395
3384
  // src/helpers/ProcessDirectKibbleApproval.tsx
3396
- import { encodeFunctionData as encodeFunctionData5, erc20Abi } from "viem";
3385
+ import { encodeFunctionData as encodeFunctionData4, erc20Abi } from "viem";
3397
3386
  async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
3398
3387
  try {
3399
3388
  const functionName = "approve";
3400
3389
  const args = [spenderAddress, approveAmount];
3401
- const approveCalldata = encodeFunctionData5({
3390
+ const approveCalldata = encodeFunctionData4({
3402
3391
  abi: erc20Abi,
3403
3392
  functionName,
3404
3393
  args
@@ -3463,7 +3452,7 @@ function useApproveKibbleToken() {
3463
3452
 
3464
3453
  // src/utils/organization/useCreateOrganizationBase.ts
3465
3454
  import { useCallback as useCallback18 } from "react";
3466
- import { decodeEventLog, encodeFunctionData as encodeFunctionData6 } from "viem";
3455
+ import { decodeEventLog, encodeFunctionData as encodeFunctionData5 } from "viem";
3467
3456
  function useCreateOrganizationBase() {
3468
3457
  return useCallback18(
3469
3458
  /**
@@ -3487,7 +3476,7 @@ function useCreateOrganizationBase() {
3487
3476
  try {
3488
3477
  const functionName = "createOrganizationProxy";
3489
3478
  const args = [ownerAddress, orgName, orgPid];
3490
- const callData = encodeFunctionData6({
3479
+ const callData = encodeFunctionData5({
3491
3480
  abi: ORGANIZATION_BEACON_ABI,
3492
3481
  functionName,
3493
3482
  args
@@ -3564,7 +3553,7 @@ function useCreateOrganizationBase() {
3564
3553
  import { useCallback as useCallback19 } from "react";
3565
3554
 
3566
3555
  // src/helpers/ProcessOrgKibbleApproval.tsx
3567
- import { encodeFunctionData as encodeFunctionData7, erc20Abi as erc20Abi3 } from "viem";
3556
+ import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi3 } from "viem";
3568
3557
 
3569
3558
  // src/helpers/WaitForAllowance.tsx
3570
3559
  import { erc20Abi as erc20Abi2 } from "viem";
@@ -3601,13 +3590,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
3601
3590
  if (approveAmount <= 0n) {
3602
3591
  return { success: false, message: "Approval amount must be greater than zero." };
3603
3592
  }
3604
- const approveCalldata = encodeFunctionData7({
3593
+ const approveCalldata = encodeFunctionData6({
3605
3594
  abi: erc20Abi3,
3606
3595
  functionName: "approve",
3607
3596
  args: [partialPaymentModuleAddress, approveAmount]
3608
3597
  });
3609
3598
  const args = [kibbleTokenAddress, approveCalldata];
3610
- const executeApproveCalldata = encodeFunctionData7({
3599
+ const executeApproveCalldata = encodeFunctionData6({
3611
3600
  abi: ORGANIZATION_IMPL_ABI,
3612
3601
  functionName: ORG_FUNCTION,
3613
3602
  args
@@ -3694,10 +3683,10 @@ function useApproveOrgPartialPayment() {
3694
3683
  import { useCallback as useCallback20 } from "react";
3695
3684
 
3696
3685
  // src/helpers/ProcessOrgPartialPayment.tsx
3697
- import { encodeFunctionData as encodeFunctionData8 } from "viem";
3686
+ import { encodeFunctionData as encodeFunctionData7 } from "viem";
3698
3687
  async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
3699
3688
  try {
3700
- const partialPayCalldata = encodeFunctionData8({
3689
+ const partialPayCalldata = encodeFunctionData7({
3701
3690
  abi: MARKETPLACE_ABI,
3702
3691
  functionName: "partialPay",
3703
3692
  args: [
@@ -3712,7 +3701,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
3712
3701
  ]
3713
3702
  });
3714
3703
  const args = [partialPaymentModuleAddress, partialPayCalldata];
3715
- const executePartialPayCalldata = encodeFunctionData8({
3704
+ const executePartialPayCalldata = encodeFunctionData7({
3716
3705
  abi: ORGANIZATION_IMPL_ABI,
3717
3706
  functionName: ORG_FUNCTION,
3718
3707
  args
@@ -3828,7 +3817,7 @@ function useUpdateOrgWalletAddress() {
3828
3817
  }
3829
3818
 
3830
3819
  // src/utils/organization/useMintOrgAnymalNFT.ts
3831
- import { encodeFunctionData as encodeFunctionData9 } from "viem";
3820
+ import { encodeFunctionData as encodeFunctionData8 } from "viem";
3832
3821
  import { useCallback as useCallback22 } from "react";
3833
3822
  function useMintOrgAnymalNFT() {
3834
3823
  return useCallback22(
@@ -3847,13 +3836,13 @@ function useMintOrgAnymalNFT() {
3847
3836
  "petastic-signup-campaign-1",
3848
3837
  anymalTxId
3849
3838
  ];
3850
- const callData = encodeFunctionData9({
3839
+ const callData = encodeFunctionData8({
3851
3840
  abi: PET_NFT_ABI,
3852
3841
  functionName,
3853
3842
  args
3854
3843
  });
3855
3844
  const executeArgs = [validationContractAddress, callData];
3856
- const executeSubmitMetaCalldata = encodeFunctionData9({
3845
+ const executeSubmitMetaCalldata = encodeFunctionData8({
3857
3846
  abi: ORGANIZATION_IMPL_ABI,
3858
3847
  functionName: ORG_FUNCTION,
3859
3848
  args: executeArgs
@@ -4183,7 +4172,7 @@ function useFetchBalance() {
4183
4172
  }
4184
4173
 
4185
4174
  // src/utils/actions/useClaimActionReward.ts
4186
- import { encodeFunctionData as encodeFunctionData10 } from "viem";
4175
+ import { encodeFunctionData as encodeFunctionData9 } from "viem";
4187
4176
  import { useCallback as useCallback28 } from "react";
4188
4177
  function useClaimActionReward() {
4189
4178
  return useCallback28(
@@ -4196,7 +4185,7 @@ function useClaimActionReward() {
4196
4185
  }
4197
4186
  const args = [actionId, claimIndex];
4198
4187
  const functionName = "claimByIndex";
4199
- const callData = encodeFunctionData10({
4188
+ const callData = encodeFunctionData9({
4200
4189
  abi: REWARDABLE_ACTIONS_ABI,
4201
4190
  functionName,
4202
4191
  args
@@ -4232,7 +4221,7 @@ function useClaimActionReward() {
4232
4221
  }
4233
4222
 
4234
4223
  // src/utils/actions/useClaimOrgActionReward.ts
4235
- import { encodeFunctionData as encodeFunctionData11 } from "viem";
4224
+ import { encodeFunctionData as encodeFunctionData10 } from "viem";
4236
4225
  import { useCallback as useCallback29 } from "react";
4237
4226
  function useClaimOrgActionReward() {
4238
4227
  return useCallback29(
@@ -4243,13 +4232,13 @@ function useClaimOrgActionReward() {
4243
4232
  message: "Missing web3auth account info or contract address."
4244
4233
  };
4245
4234
  }
4246
- const claimCallData = encodeFunctionData11({
4235
+ const claimCallData = encodeFunctionData10({
4247
4236
  abi: REWARDABLE_ACTIONS_ABI,
4248
4237
  functionName: "claimByIndex",
4249
4238
  args: [actionId, claimIndex]
4250
4239
  });
4251
4240
  const args = [rewardableActionContractAddress, claimCallData];
4252
- const executeClaimCalldata = encodeFunctionData11({
4241
+ const executeClaimCalldata = encodeFunctionData10({
4253
4242
  abi: ORGANIZATION_IMPL_ABI,
4254
4243
  functionName: ORG_FUNCTION,
4255
4244
  args
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.131",
3
+ "version": "1.0.133",
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": {