anymal-protocol 1.0.130 → 1.0.132

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}`, paymasterUrl: 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
  }>;
@@ -63,13 +63,13 @@ declare function useSendCoinbaseUserOperation(): {
63
63
  error: Error | undefined;
64
64
  };
65
65
 
66
- declare function useCoinbaseClaimActionReward(): (evmAddress: `0x${string}`, actionId: string, claimIndex: number, validationContractAddress: `0x${string}`, paymasterUrl: string) => Promise<{
66
+ declare function useCoinbaseClaimActionReward(): (evmAddress: `0x${string}`, actionId: string, claimIndex: number, validationContractAddress: `0x${string}`) => Promise<{
67
67
  success: boolean;
68
68
  message: string;
69
69
  status: string;
70
70
  }>;
71
71
 
72
- declare function useCoinbaseMintAnymalNFT(): (evmAddress: `0x${string}`, pid: string, nftId: string, anymalTxId: string, validationContractAddress: `0x${string}`, paymasterUrl: string) => Promise<{
72
+ declare function useCoinbaseMintAnymalNFT(): (evmAddress: `0x${string}`, pid: string, nftId: string, anymalTxId: string, validationContractAddress: `0x${string}`) => Promise<{
73
73
  success: boolean;
74
74
  message: string;
75
75
  status: string;
@@ -368,7 +368,7 @@ declare const KIBBLE_TOKEN_ABI: ({
368
368
  type: string;
369
369
  anonymous?: undefined;
370
370
  })[];
371
- declare const ERROR_ABI: ({
371
+ declare const ERROR_ABI: (abitype.Abi | {
372
372
  inputs: {
373
373
  internalType: string;
374
374
  name: string;
@@ -417,7 +417,7 @@ declare const ERROR_ABI: ({
417
417
  name?: undefined;
418
418
  anonymous?: undefined;
419
419
  outputs?: undefined;
420
- } | abitype.Abi)[];
420
+ })[];
421
421
  declare const ORG_FUNCTION = "executeCall";
422
422
 
423
423
  declare function useMintAnymalNFT(): (pid: string, nftId: string, anymalTxId: string, dbAuthToken: string, validationContractAddress: string, smartAccount: any, bundlerClient: any) => Promise<{
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}`, paymasterUrl: 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
  }>;
@@ -63,13 +63,13 @@ declare function useSendCoinbaseUserOperation(): {
63
63
  error: Error | undefined;
64
64
  };
65
65
 
66
- declare function useCoinbaseClaimActionReward(): (evmAddress: `0x${string}`, actionId: string, claimIndex: number, validationContractAddress: `0x${string}`, paymasterUrl: string) => Promise<{
66
+ declare function useCoinbaseClaimActionReward(): (evmAddress: `0x${string}`, actionId: string, claimIndex: number, validationContractAddress: `0x${string}`) => Promise<{
67
67
  success: boolean;
68
68
  message: string;
69
69
  status: string;
70
70
  }>;
71
71
 
72
- declare function useCoinbaseMintAnymalNFT(): (evmAddress: `0x${string}`, pid: string, nftId: string, anymalTxId: string, validationContractAddress: `0x${string}`, paymasterUrl: string) => Promise<{
72
+ declare function useCoinbaseMintAnymalNFT(): (evmAddress: `0x${string}`, pid: string, nftId: string, anymalTxId: string, validationContractAddress: `0x${string}`) => Promise<{
73
73
  success: boolean;
74
74
  message: string;
75
75
  status: string;
@@ -368,7 +368,7 @@ declare const KIBBLE_TOKEN_ABI: ({
368
368
  type: string;
369
369
  anonymous?: undefined;
370
370
  })[];
371
- declare const ERROR_ABI: ({
371
+ declare const ERROR_ABI: (abitype.Abi | {
372
372
  inputs: {
373
373
  internalType: string;
374
374
  name: string;
@@ -417,7 +417,7 @@ declare const ERROR_ABI: ({
417
417
  name?: undefined;
418
418
  anonymous?: undefined;
419
419
  outputs?: undefined;
420
- } | abitype.Abi)[];
420
+ })[];
421
421
  declare const ORG_FUNCTION = "executeCall";
422
422
 
423
423
  declare function useMintAnymalNFT(): (pid: string, nftId: string, anymalTxId: string, dbAuthToken: string, validationContractAddress: string, smartAccount: any, bundlerClient: any) => Promise<{
package/dist/index.js CHANGED
@@ -467,37 +467,63 @@ function useFetchNotifications() {
467
467
  // src/utils/coinbase/useSendCoinbaseUserOperation.ts
468
468
  var import_react10 = require("react");
469
469
  var import_cdp_hooks = require("@coinbase/cdp-hooks");
470
+ var import_viem = require("viem");
471
+ var import_chains = require("viem/chains");
470
472
  function useSendCoinbaseUserOperation() {
471
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
+ );
472
481
  const sendOperationFn = (0, import_react10.useCallback)(
473
- async (evmAddress, callData, contractAddress, paymasterUrl) => {
474
- if (!evmAddress || !callData || !contractAddress) {
482
+ async (evmAddress, contractAddress, abi, functionName, args) => {
483
+ if (!evmAddress || !contractAddress || !abi || !functionName) {
475
484
  return { success: false, message: "Missing required information" };
476
485
  }
477
486
  try {
487
+ await publicClient.simulateContract({
488
+ address: contractAddress,
489
+ abi,
490
+ functionName,
491
+ args,
492
+ account: evmAddress
493
+ });
494
+ console.log("\u2705 Simulation successful");
495
+ } catch (simError) {
496
+ console.error("\u274C Simulation failed:", simError);
497
+ return {
498
+ success: false,
499
+ message: `Simulation failed: ${simError.shortMessage || simError.message}`
500
+ };
501
+ }
502
+ try {
503
+ const callData = (0, import_viem.encodeFunctionData)({
504
+ abi,
505
+ functionName,
506
+ args
507
+ });
478
508
  await sendUserOperation({
479
509
  evmSmartAccount: evmAddress,
480
510
  network: "base-sepolia",
481
511
  useCdpPaymaster: true,
482
- paymasterUrl,
483
512
  calls: [{ data: callData, to: contractAddress }]
484
513
  });
485
514
  return { success: true, message: "Operation submitted." };
486
515
  } catch (e) {
487
- console.error(e);
516
+ console.error("\u274C Operation failed:", e);
488
517
  return { success: false, message: e.message };
489
518
  }
490
519
  },
491
- [sendUserOperation]
520
+ [sendUserOperation, publicClient]
492
521
  );
493
522
  return { sendOperationFn, data, status, error };
494
523
  }
495
524
 
496
- // src/utils/coinbase/useCoinbaseClaimActionReward.ts
497
- var import_viem2 = require("viem");
498
-
499
525
  // src/helpers/BlockchainAbiHelper.tsx
500
- var import_viem = require("viem");
526
+ var import_viem2 = require("viem");
501
527
  var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {
502
528
  "inputs": [],
503
529
  "name": "AccessControlBadConfirmation",
@@ -2924,7 +2950,7 @@ var OZ_ERROR_FRAGMENTS = [
2924
2950
  "error AddressLowLevelCallFailed(address target, bytes data)",
2925
2951
  "error AddressEmptyCode(address target)"
2926
2952
  ];
2927
- var ERROR_ABI = [...LOCAL_ERRORS, (0, import_viem.parseAbi)([...OZ_ERROR_FRAGMENTS])];
2953
+ var ERROR_ABI = [...LOCAL_ERRORS, (0, import_viem2.parseAbi)([...OZ_ERROR_FRAGMENTS])];
2928
2954
  var ORG_FUNCTION = "executeCall";
2929
2955
 
2930
2956
  // src/utils/coinbase/useCoinbaseClaimActionReward.ts
@@ -2932,7 +2958,7 @@ var import_react11 = require("react");
2932
2958
  function useCoinbaseClaimActionReward() {
2933
2959
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
2934
2960
  return (0, import_react11.useCallback)(
2935
- async (evmAddress, actionId, claimIndex, validationContractAddress, paymasterUrl) => {
2961
+ async (evmAddress, actionId, claimIndex, validationContractAddress) => {
2936
2962
  if (!evmAddress || !actionId || claimIndex === void 0 || !validationContractAddress) {
2937
2963
  return {
2938
2964
  success: false,
@@ -2940,41 +2966,25 @@ function useCoinbaseClaimActionReward() {
2940
2966
  status: "error"
2941
2967
  };
2942
2968
  }
2943
- try {
2944
- const args = [actionId, claimIndex];
2945
- const functionName = "claimByIndex";
2946
- const callData = (0, import_viem2.encodeFunctionData)({
2947
- abi: REWARDABLE_ACTIONS_ABI,
2948
- functionName,
2949
- args
2950
- });
2951
- const opsRes = await sendOperationFn(
2952
- evmAddress,
2953
- callData,
2954
- validationContractAddress,
2955
- paymasterUrl
2956
- );
2957
- return { success: opsRes.success, message: opsRes.message, status };
2958
- } catch (error) {
2959
- console.error(error);
2960
- return {
2961
- success: false,
2962
- message: "Reward not claimed",
2963
- status: "error"
2964
- };
2965
- }
2969
+ const result = await sendOperationFn(
2970
+ evmAddress,
2971
+ validationContractAddress,
2972
+ REWARDABLE_ACTIONS_ABI,
2973
+ "claimByIndex",
2974
+ [actionId, claimIndex]
2975
+ );
2976
+ return { ...result, status };
2966
2977
  },
2967
- []
2978
+ [sendOperationFn, status]
2968
2979
  );
2969
2980
  }
2970
2981
 
2971
2982
  // src/utils/coinbase/useCoinbaseMintAnymalNFT.ts
2972
- var import_viem3 = require("viem");
2973
2983
  var import_react12 = require("react");
2974
2984
  function useCoinbaseMintAnymalNFT() {
2975
2985
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
2976
2986
  return (0, import_react12.useCallback)(
2977
- async (evmAddress, pid, nftId, anymalTxId, validationContractAddress, paymasterUrl) => {
2987
+ async (evmAddress, pid, nftId, anymalTxId, validationContractAddress) => {
2978
2988
  if (!nftId || !pid || !validationContractAddress) {
2979
2989
  return {
2980
2990
  success: false,
@@ -2982,38 +2992,27 @@ function useCoinbaseMintAnymalNFT() {
2982
2992
  status: "error"
2983
2993
  };
2984
2994
  }
2985
- try {
2986
- const functionName = "submitMetadataByCampaignName";
2987
- const args = [
2995
+ const result = await sendOperationFn(
2996
+ evmAddress,
2997
+ validationContractAddress,
2998
+ PET_NFT_ABI,
2999
+ "submitMetadataByCampaignName",
3000
+ [
2988
3001
  pid,
2989
3002
  nftId,
2990
3003
  `https://dev-nft.petastic.com/metadata/${nftId}`,
2991
3004
  "petastic-signup-campaign-1",
2992
3005
  anymalTxId
2993
- ];
2994
- const callData = (0, import_viem3.encodeFunctionData)({
2995
- abi: PET_NFT_ABI,
2996
- functionName,
2997
- args
2998
- });
2999
- const opsRes = await sendOperationFn(
3000
- evmAddress,
3001
- callData,
3002
- validationContractAddress,
3003
- paymasterUrl
3004
- );
3005
- return { success: opsRes.success, message: opsRes.message, status };
3006
- } catch (error) {
3007
- console.error(error);
3008
- return { success: false, message: "Error", status: "error" };
3009
- }
3006
+ ]
3007
+ );
3008
+ return { ...result, status };
3010
3009
  },
3011
- []
3010
+ [sendOperationFn, status]
3012
3011
  );
3013
3012
  }
3014
3013
 
3015
3014
  // src/utils/anymals/useMintAnymalNFT.ts
3016
- var import_viem5 = require("viem");
3015
+ var import_viem4 = require("viem");
3017
3016
  var import_react13 = require("react");
3018
3017
 
3019
3018
  // src/helpers/GasEstimateHelper.tsx
@@ -3058,18 +3057,18 @@ async function applyBundlerGasEstimator(account, bundlerClient, options) {
3058
3057
  }
3059
3058
 
3060
3059
  // src/helpers/HumanRevert.tsx
3061
- var import_viem4 = require("viem");
3060
+ var import_viem3 = require("viem");
3062
3061
  function humanRevert(raw, shortMessage) {
3063
3062
  if (!raw) return shortMessage ?? "Simulation reverted";
3064
3063
  try {
3065
- const { errorName, args } = (0, import_viem4.decodeErrorResult)({
3064
+ const { errorName, args } = (0, import_viem3.decodeErrorResult)({
3066
3065
  abi: ERROR_ABI,
3067
3066
  data: raw
3068
3067
  });
3069
3068
  return `${errorName}(${args.map(String).join(", ")})`;
3070
3069
  } catch {
3071
3070
  if (raw.startsWith("0x08c379a0") && raw.length >= 138) {
3072
- return (0, import_viem4.hexToString)(`0x${raw.slice(138)}`);
3071
+ return (0, import_viem3.hexToString)(`0x${raw.slice(138)}`);
3073
3072
  }
3074
3073
  return `${raw.slice(0, 10)}\u2026`;
3075
3074
  }
@@ -3111,7 +3110,7 @@ function useMintAnymalNFT() {
3111
3110
  "petastic-signup-campaign-1",
3112
3111
  anymalTxId
3113
3112
  ];
3114
- const callData = (0, import_viem5.encodeFunctionData)({
3113
+ const callData = (0, import_viem4.encodeFunctionData)({
3115
3114
  abi: PET_NFT_ABI,
3116
3115
  functionName,
3117
3116
  args
@@ -3298,7 +3297,7 @@ function useUploadAnymalImage() {
3298
3297
  var import_react16 = require("react");
3299
3298
 
3300
3299
  // src/helpers/ProcessDirectPartialPayment.tsx
3301
- var import_viem6 = require("viem");
3300
+ var import_viem5 = require("viem");
3302
3301
 
3303
3302
  // src/helpers/SendUserOpWithRetries.tsx
3304
3303
  async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
@@ -3358,7 +3357,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
3358
3357
  deadline,
3359
3358
  backendSignature
3360
3359
  ];
3361
- const partialPayCalldata = (0, import_viem6.encodeFunctionData)({
3360
+ const partialPayCalldata = (0, import_viem5.encodeFunctionData)({
3362
3361
  abi: MARKETPLACE_ABI,
3363
3362
  functionName,
3364
3363
  args
@@ -3454,20 +3453,20 @@ function useProcessPartialKibblePayment() {
3454
3453
  var import_react17 = require("react");
3455
3454
 
3456
3455
  // src/helpers/ProcessDirectKibbleApproval.tsx
3457
- var import_viem7 = require("viem");
3456
+ var import_viem6 = require("viem");
3458
3457
  async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
3459
3458
  try {
3460
3459
  const functionName = "approve";
3461
3460
  const args = [spenderAddress, approveAmount];
3462
- const approveCalldata = (0, import_viem7.encodeFunctionData)({
3463
- abi: import_viem7.erc20Abi,
3461
+ const approveCalldata = (0, import_viem6.encodeFunctionData)({
3462
+ abi: import_viem6.erc20Abi,
3464
3463
  functionName,
3465
3464
  args
3466
3465
  });
3467
3466
  await simulateCall(
3468
3467
  bundlerClient.client,
3469
3468
  kibbleTokenAddress,
3470
- import_viem7.erc20Abi,
3469
+ import_viem6.erc20Abi,
3471
3470
  functionName,
3472
3471
  args,
3473
3472
  smartAccount.address
@@ -3524,7 +3523,7 @@ function useApproveKibbleToken() {
3524
3523
 
3525
3524
  // src/utils/organization/useCreateOrganizationBase.ts
3526
3525
  var import_react18 = require("react");
3527
- var import_viem8 = require("viem");
3526
+ var import_viem7 = require("viem");
3528
3527
  function useCreateOrganizationBase() {
3529
3528
  return (0, import_react18.useCallback)(
3530
3529
  /**
@@ -3548,7 +3547,7 @@ function useCreateOrganizationBase() {
3548
3547
  try {
3549
3548
  const functionName = "createOrganizationProxy";
3550
3549
  const args = [ownerAddress, orgName, orgPid];
3551
- const callData = (0, import_viem8.encodeFunctionData)({
3550
+ const callData = (0, import_viem7.encodeFunctionData)({
3552
3551
  abi: ORGANIZATION_BEACON_ABI,
3553
3552
  functionName,
3554
3553
  args
@@ -3586,7 +3585,7 @@ function useCreateOrganizationBase() {
3586
3585
  let proxyAddress;
3587
3586
  for (const log of txReceipt.logs) {
3588
3587
  try {
3589
- const decoded = (0, import_viem8.decodeEventLog)({
3588
+ const decoded = (0, import_viem7.decodeEventLog)({
3590
3589
  abi: ORGANIZATION_BEACON_ABI,
3591
3590
  data: log.data,
3592
3591
  topics: log.topics
@@ -3625,10 +3624,10 @@ function useCreateOrganizationBase() {
3625
3624
  var import_react19 = require("react");
3626
3625
 
3627
3626
  // src/helpers/ProcessOrgKibbleApproval.tsx
3628
- var import_viem10 = require("viem");
3627
+ var import_viem9 = require("viem");
3629
3628
 
3630
3629
  // src/helpers/WaitForAllowance.tsx
3631
- var import_viem9 = require("viem");
3630
+ var import_viem8 = require("viem");
3632
3631
  async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spenderAddress, expectedAmount) {
3633
3632
  const MAX_RETRIES = 10;
3634
3633
  const RETRY_INTERVAL = 2e3;
@@ -3637,7 +3636,7 @@ async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spende
3637
3636
  try {
3638
3637
  const currentAllowance = await publicClient.readContract({
3639
3638
  address: tokenAddress,
3640
- abi: import_viem9.erc20Abi,
3639
+ abi: import_viem8.erc20Abi,
3641
3640
  functionName: "allowance",
3642
3641
  args: [ownerAddress, spenderAddress]
3643
3642
  });
@@ -3662,13 +3661,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
3662
3661
  if (approveAmount <= 0n) {
3663
3662
  return { success: false, message: "Approval amount must be greater than zero." };
3664
3663
  }
3665
- const approveCalldata = (0, import_viem10.encodeFunctionData)({
3666
- abi: import_viem10.erc20Abi,
3664
+ const approveCalldata = (0, import_viem9.encodeFunctionData)({
3665
+ abi: import_viem9.erc20Abi,
3667
3666
  functionName: "approve",
3668
3667
  args: [partialPaymentModuleAddress, approveAmount]
3669
3668
  });
3670
3669
  const args = [kibbleTokenAddress, approveCalldata];
3671
- const executeApproveCalldata = (0, import_viem10.encodeFunctionData)({
3670
+ const executeApproveCalldata = (0, import_viem9.encodeFunctionData)({
3672
3671
  abi: ORGANIZATION_IMPL_ABI,
3673
3672
  functionName: ORG_FUNCTION,
3674
3673
  args
@@ -3755,10 +3754,10 @@ function useApproveOrgPartialPayment() {
3755
3754
  var import_react20 = require("react");
3756
3755
 
3757
3756
  // src/helpers/ProcessOrgPartialPayment.tsx
3758
- var import_viem11 = require("viem");
3757
+ var import_viem10 = require("viem");
3759
3758
  async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
3760
3759
  try {
3761
- const partialPayCalldata = (0, import_viem11.encodeFunctionData)({
3760
+ const partialPayCalldata = (0, import_viem10.encodeFunctionData)({
3762
3761
  abi: MARKETPLACE_ABI,
3763
3762
  functionName: "partialPay",
3764
3763
  args: [
@@ -3773,7 +3772,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
3773
3772
  ]
3774
3773
  });
3775
3774
  const args = [partialPaymentModuleAddress, partialPayCalldata];
3776
- const executePartialPayCalldata = (0, import_viem11.encodeFunctionData)({
3775
+ const executePartialPayCalldata = (0, import_viem10.encodeFunctionData)({
3777
3776
  abi: ORGANIZATION_IMPL_ABI,
3778
3777
  functionName: ORG_FUNCTION,
3779
3778
  args
@@ -3889,7 +3888,7 @@ function useUpdateOrgWalletAddress() {
3889
3888
  }
3890
3889
 
3891
3890
  // src/utils/organization/useMintOrgAnymalNFT.ts
3892
- var import_viem12 = require("viem");
3891
+ var import_viem11 = require("viem");
3893
3892
  var import_react22 = require("react");
3894
3893
  function useMintOrgAnymalNFT() {
3895
3894
  return (0, import_react22.useCallback)(
@@ -3908,13 +3907,13 @@ function useMintOrgAnymalNFT() {
3908
3907
  "petastic-signup-campaign-1",
3909
3908
  anymalTxId
3910
3909
  ];
3911
- const callData = (0, import_viem12.encodeFunctionData)({
3910
+ const callData = (0, import_viem11.encodeFunctionData)({
3912
3911
  abi: PET_NFT_ABI,
3913
3912
  functionName,
3914
3913
  args
3915
3914
  });
3916
3915
  const executeArgs = [validationContractAddress, callData];
3917
- const executeSubmitMetaCalldata = (0, import_viem12.encodeFunctionData)({
3916
+ const executeSubmitMetaCalldata = (0, import_viem11.encodeFunctionData)({
3918
3917
  abi: ORGANIZATION_IMPL_ABI,
3919
3918
  functionName: ORG_FUNCTION,
3920
3919
  args: executeArgs
@@ -3947,10 +3946,10 @@ function useMintOrgAnymalNFT() {
3947
3946
 
3948
3947
  // src/helpers/NonceHelper.tsx
3949
3948
  var import_uuid = require("uuid");
3950
- var import_viem13 = require("viem");
3949
+ var import_viem12 = require("viem");
3951
3950
  var generateBytes32Nonce = () => {
3952
3951
  const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
3953
- return (0, import_viem13.padHex)(`0x${uuid3}`, { size: 32 });
3952
+ return (0, import_viem12.padHex)(`0x${uuid3}`, { size: 32 });
3954
3953
  };
3955
3954
 
3956
3955
  // src/helpers/CryptoUtils.tsx
@@ -4406,16 +4405,16 @@ function useCreateOrganizationAppData() {
4406
4405
 
4407
4406
  // src/utils/balance/useFetchBalance.ts
4408
4407
  var import_react27 = require("react");
4409
- var import_viem14 = require("viem");
4408
+ var import_viem13 = require("viem");
4410
4409
  function useFetchBalance() {
4411
4410
  return (0, import_react27.useCallback)(
4412
4411
  async (publicClient, walletAddress, kibbleTokenAddress) => {
4413
4412
  try {
4414
4413
  const balance = await publicClient.readContract({
4415
- address: (0, import_viem14.getAddress)(kibbleTokenAddress),
4416
- abi: import_viem14.erc20Abi,
4414
+ address: (0, import_viem13.getAddress)(kibbleTokenAddress),
4415
+ abi: import_viem13.erc20Abi,
4417
4416
  functionName: "balanceOf",
4418
- args: [(0, import_viem14.getAddress)(walletAddress)]
4417
+ args: [(0, import_viem13.getAddress)(walletAddress)]
4419
4418
  });
4420
4419
  return Number(balance);
4421
4420
  } catch (error) {
@@ -4427,7 +4426,7 @@ function useFetchBalance() {
4427
4426
  }
4428
4427
 
4429
4428
  // src/utils/actions/useClaimActionReward.ts
4430
- var import_viem15 = require("viem");
4429
+ var import_viem14 = require("viem");
4431
4430
  var import_react28 = require("react");
4432
4431
  function useClaimActionReward() {
4433
4432
  return (0, import_react28.useCallback)(
@@ -4440,7 +4439,7 @@ function useClaimActionReward() {
4440
4439
  }
4441
4440
  const args = [actionId, claimIndex];
4442
4441
  const functionName = "claimByIndex";
4443
- const callData = (0, import_viem15.encodeFunctionData)({
4442
+ const callData = (0, import_viem14.encodeFunctionData)({
4444
4443
  abi: REWARDABLE_ACTIONS_ABI,
4445
4444
  functionName,
4446
4445
  args
@@ -4476,7 +4475,7 @@ function useClaimActionReward() {
4476
4475
  }
4477
4476
 
4478
4477
  // src/utils/actions/useClaimOrgActionReward.ts
4479
- var import_viem16 = require("viem");
4478
+ var import_viem15 = require("viem");
4480
4479
  var import_react29 = require("react");
4481
4480
  function useClaimOrgActionReward() {
4482
4481
  return (0, import_react29.useCallback)(
@@ -4487,13 +4486,13 @@ function useClaimOrgActionReward() {
4487
4486
  message: "Missing web3auth account info or contract address."
4488
4487
  };
4489
4488
  }
4490
- const claimCallData = (0, import_viem16.encodeFunctionData)({
4489
+ const claimCallData = (0, import_viem15.encodeFunctionData)({
4491
4490
  abi: REWARDABLE_ACTIONS_ABI,
4492
4491
  functionName: "claimByIndex",
4493
4492
  args: [actionId, claimIndex]
4494
4493
  });
4495
4494
  const args = [rewardableActionContractAddress, claimCallData];
4496
- const executeClaimCalldata = (0, import_viem16.encodeFunctionData)({
4495
+ const executeClaimCalldata = (0, import_viem15.encodeFunctionData)({
4497
4496
  abi: ORGANIZATION_IMPL_ABI,
4498
4497
  functionName: ORG_FUNCTION,
4499
4498
  args
package/dist/index.mjs CHANGED
@@ -387,37 +387,63 @@ 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, encodeFunctionData, http } from "viem";
393
+ import { baseSepolia } from "viem/chains";
392
394
  function useSendCoinbaseUserOperation() {
393
395
  const { sendUserOperation, data, error, status } = useSendUserOperation();
396
+ const publicClient = useMemo(
397
+ () => createPublicClient({
398
+ chain: baseSepolia,
399
+ transport: http()
400
+ }),
401
+ []
402
+ );
394
403
  const sendOperationFn = useCallback10(
395
- async (evmAddress, callData, contractAddress, paymasterUrl) => {
396
- if (!evmAddress || !callData || !contractAddress) {
404
+ async (evmAddress, contractAddress, abi, functionName, args) => {
405
+ if (!evmAddress || !contractAddress || !abi || !functionName) {
397
406
  return { success: false, message: "Missing required information" };
398
407
  }
399
408
  try {
409
+ await publicClient.simulateContract({
410
+ address: contractAddress,
411
+ abi,
412
+ functionName,
413
+ args,
414
+ account: evmAddress
415
+ });
416
+ console.log("\u2705 Simulation successful");
417
+ } catch (simError) {
418
+ console.error("\u274C Simulation failed:", simError);
419
+ return {
420
+ success: false,
421
+ message: `Simulation failed: ${simError.shortMessage || simError.message}`
422
+ };
423
+ }
424
+ try {
425
+ const callData = encodeFunctionData({
426
+ abi,
427
+ functionName,
428
+ args
429
+ });
400
430
  await sendUserOperation({
401
431
  evmSmartAccount: evmAddress,
402
432
  network: "base-sepolia",
403
433
  useCdpPaymaster: true,
404
- paymasterUrl,
405
434
  calls: [{ data: callData, to: contractAddress }]
406
435
  });
407
436
  return { success: true, message: "Operation submitted." };
408
437
  } catch (e) {
409
- console.error(e);
438
+ console.error("\u274C Operation failed:", e);
410
439
  return { success: false, message: e.message };
411
440
  }
412
441
  },
413
- [sendUserOperation]
442
+ [sendUserOperation, publicClient]
414
443
  );
415
444
  return { sendOperationFn, data, status, error };
416
445
  }
417
446
 
418
- // src/utils/coinbase/useCoinbaseClaimActionReward.ts
419
- import { encodeFunctionData } from "viem";
420
-
421
447
  // src/helpers/BlockchainAbiHelper.tsx
422
448
  import { parseAbi } from "viem";
423
449
  var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {
@@ -2854,7 +2880,7 @@ import { useCallback as useCallback11 } from "react";
2854
2880
  function useCoinbaseClaimActionReward() {
2855
2881
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
2856
2882
  return useCallback11(
2857
- async (evmAddress, actionId, claimIndex, validationContractAddress, paymasterUrl) => {
2883
+ async (evmAddress, actionId, claimIndex, validationContractAddress) => {
2858
2884
  if (!evmAddress || !actionId || claimIndex === void 0 || !validationContractAddress) {
2859
2885
  return {
2860
2886
  success: false,
@@ -2862,41 +2888,25 @@ function useCoinbaseClaimActionReward() {
2862
2888
  status: "error"
2863
2889
  };
2864
2890
  }
2865
- try {
2866
- const args = [actionId, claimIndex];
2867
- const functionName = "claimByIndex";
2868
- const callData = encodeFunctionData({
2869
- abi: REWARDABLE_ACTIONS_ABI,
2870
- functionName,
2871
- args
2872
- });
2873
- const opsRes = await sendOperationFn(
2874
- evmAddress,
2875
- callData,
2876
- validationContractAddress,
2877
- paymasterUrl
2878
- );
2879
- return { success: opsRes.success, message: opsRes.message, status };
2880
- } catch (error) {
2881
- console.error(error);
2882
- return {
2883
- success: false,
2884
- message: "Reward not claimed",
2885
- status: "error"
2886
- };
2887
- }
2891
+ const result = await sendOperationFn(
2892
+ evmAddress,
2893
+ validationContractAddress,
2894
+ REWARDABLE_ACTIONS_ABI,
2895
+ "claimByIndex",
2896
+ [actionId, claimIndex]
2897
+ );
2898
+ return { ...result, status };
2888
2899
  },
2889
- []
2900
+ [sendOperationFn, status]
2890
2901
  );
2891
2902
  }
2892
2903
 
2893
2904
  // src/utils/coinbase/useCoinbaseMintAnymalNFT.ts
2894
- import { encodeFunctionData as encodeFunctionData2 } from "viem";
2895
2905
  import { useCallback as useCallback12 } from "react";
2896
2906
  function useCoinbaseMintAnymalNFT() {
2897
2907
  const { sendOperationFn, status } = useSendCoinbaseUserOperation();
2898
2908
  return useCallback12(
2899
- async (evmAddress, pid, nftId, anymalTxId, validationContractAddress, paymasterUrl) => {
2909
+ async (evmAddress, pid, nftId, anymalTxId, validationContractAddress) => {
2900
2910
  if (!nftId || !pid || !validationContractAddress) {
2901
2911
  return {
2902
2912
  success: false,
@@ -2904,38 +2914,27 @@ function useCoinbaseMintAnymalNFT() {
2904
2914
  status: "error"
2905
2915
  };
2906
2916
  }
2907
- try {
2908
- const functionName = "submitMetadataByCampaignName";
2909
- const args = [
2917
+ const result = await sendOperationFn(
2918
+ evmAddress,
2919
+ validationContractAddress,
2920
+ PET_NFT_ABI,
2921
+ "submitMetadataByCampaignName",
2922
+ [
2910
2923
  pid,
2911
2924
  nftId,
2912
2925
  `https://dev-nft.petastic.com/metadata/${nftId}`,
2913
2926
  "petastic-signup-campaign-1",
2914
2927
  anymalTxId
2915
- ];
2916
- const callData = encodeFunctionData2({
2917
- abi: PET_NFT_ABI,
2918
- functionName,
2919
- args
2920
- });
2921
- const opsRes = await sendOperationFn(
2922
- evmAddress,
2923
- callData,
2924
- validationContractAddress,
2925
- paymasterUrl
2926
- );
2927
- return { success: opsRes.success, message: opsRes.message, status };
2928
- } catch (error) {
2929
- console.error(error);
2930
- return { success: false, message: "Error", status: "error" };
2931
- }
2928
+ ]
2929
+ );
2930
+ return { ...result, status };
2932
2931
  },
2933
- []
2932
+ [sendOperationFn, status]
2934
2933
  );
2935
2934
  }
2936
2935
 
2937
2936
  // src/utils/anymals/useMintAnymalNFT.ts
2938
- import { encodeFunctionData as encodeFunctionData3 } from "viem";
2937
+ import { encodeFunctionData as encodeFunctionData2 } from "viem";
2939
2938
  import { useCallback as useCallback13 } from "react";
2940
2939
 
2941
2940
  // src/helpers/GasEstimateHelper.tsx
@@ -3033,7 +3032,7 @@ function useMintAnymalNFT() {
3033
3032
  "petastic-signup-campaign-1",
3034
3033
  anymalTxId
3035
3034
  ];
3036
- const callData = encodeFunctionData3({
3035
+ const callData = encodeFunctionData2({
3037
3036
  abi: PET_NFT_ABI,
3038
3037
  functionName,
3039
3038
  args
@@ -3220,7 +3219,7 @@ function useUploadAnymalImage() {
3220
3219
  import { useCallback as useCallback16 } from "react";
3221
3220
 
3222
3221
  // src/helpers/ProcessDirectPartialPayment.tsx
3223
- import { encodeFunctionData as encodeFunctionData4 } from "viem";
3222
+ import { encodeFunctionData as encodeFunctionData3 } from "viem";
3224
3223
 
3225
3224
  // src/helpers/SendUserOpWithRetries.tsx
3226
3225
  async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
@@ -3280,7 +3279,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
3280
3279
  deadline,
3281
3280
  backendSignature
3282
3281
  ];
3283
- const partialPayCalldata = encodeFunctionData4({
3282
+ const partialPayCalldata = encodeFunctionData3({
3284
3283
  abi: MARKETPLACE_ABI,
3285
3284
  functionName,
3286
3285
  args
@@ -3376,12 +3375,12 @@ function useProcessPartialKibblePayment() {
3376
3375
  import { useCallback as useCallback17 } from "react";
3377
3376
 
3378
3377
  // src/helpers/ProcessDirectKibbleApproval.tsx
3379
- import { encodeFunctionData as encodeFunctionData5, erc20Abi } from "viem";
3378
+ import { encodeFunctionData as encodeFunctionData4, erc20Abi } from "viem";
3380
3379
  async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
3381
3380
  try {
3382
3381
  const functionName = "approve";
3383
3382
  const args = [spenderAddress, approveAmount];
3384
- const approveCalldata = encodeFunctionData5({
3383
+ const approveCalldata = encodeFunctionData4({
3385
3384
  abi: erc20Abi,
3386
3385
  functionName,
3387
3386
  args
@@ -3446,7 +3445,7 @@ function useApproveKibbleToken() {
3446
3445
 
3447
3446
  // src/utils/organization/useCreateOrganizationBase.ts
3448
3447
  import { useCallback as useCallback18 } from "react";
3449
- import { decodeEventLog, encodeFunctionData as encodeFunctionData6 } from "viem";
3448
+ import { decodeEventLog, encodeFunctionData as encodeFunctionData5 } from "viem";
3450
3449
  function useCreateOrganizationBase() {
3451
3450
  return useCallback18(
3452
3451
  /**
@@ -3470,7 +3469,7 @@ function useCreateOrganizationBase() {
3470
3469
  try {
3471
3470
  const functionName = "createOrganizationProxy";
3472
3471
  const args = [ownerAddress, orgName, orgPid];
3473
- const callData = encodeFunctionData6({
3472
+ const callData = encodeFunctionData5({
3474
3473
  abi: ORGANIZATION_BEACON_ABI,
3475
3474
  functionName,
3476
3475
  args
@@ -3547,7 +3546,7 @@ function useCreateOrganizationBase() {
3547
3546
  import { useCallback as useCallback19 } from "react";
3548
3547
 
3549
3548
  // src/helpers/ProcessOrgKibbleApproval.tsx
3550
- import { encodeFunctionData as encodeFunctionData7, erc20Abi as erc20Abi3 } from "viem";
3549
+ import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi3 } from "viem";
3551
3550
 
3552
3551
  // src/helpers/WaitForAllowance.tsx
3553
3552
  import { erc20Abi as erc20Abi2 } from "viem";
@@ -3584,13 +3583,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
3584
3583
  if (approveAmount <= 0n) {
3585
3584
  return { success: false, message: "Approval amount must be greater than zero." };
3586
3585
  }
3587
- const approveCalldata = encodeFunctionData7({
3586
+ const approveCalldata = encodeFunctionData6({
3588
3587
  abi: erc20Abi3,
3589
3588
  functionName: "approve",
3590
3589
  args: [partialPaymentModuleAddress, approveAmount]
3591
3590
  });
3592
3591
  const args = [kibbleTokenAddress, approveCalldata];
3593
- const executeApproveCalldata = encodeFunctionData7({
3592
+ const executeApproveCalldata = encodeFunctionData6({
3594
3593
  abi: ORGANIZATION_IMPL_ABI,
3595
3594
  functionName: ORG_FUNCTION,
3596
3595
  args
@@ -3677,10 +3676,10 @@ function useApproveOrgPartialPayment() {
3677
3676
  import { useCallback as useCallback20 } from "react";
3678
3677
 
3679
3678
  // src/helpers/ProcessOrgPartialPayment.tsx
3680
- import { encodeFunctionData as encodeFunctionData8 } from "viem";
3679
+ import { encodeFunctionData as encodeFunctionData7 } from "viem";
3681
3680
  async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
3682
3681
  try {
3683
- const partialPayCalldata = encodeFunctionData8({
3682
+ const partialPayCalldata = encodeFunctionData7({
3684
3683
  abi: MARKETPLACE_ABI,
3685
3684
  functionName: "partialPay",
3686
3685
  args: [
@@ -3695,7 +3694,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
3695
3694
  ]
3696
3695
  });
3697
3696
  const args = [partialPaymentModuleAddress, partialPayCalldata];
3698
- const executePartialPayCalldata = encodeFunctionData8({
3697
+ const executePartialPayCalldata = encodeFunctionData7({
3699
3698
  abi: ORGANIZATION_IMPL_ABI,
3700
3699
  functionName: ORG_FUNCTION,
3701
3700
  args
@@ -3811,7 +3810,7 @@ function useUpdateOrgWalletAddress() {
3811
3810
  }
3812
3811
 
3813
3812
  // src/utils/organization/useMintOrgAnymalNFT.ts
3814
- import { encodeFunctionData as encodeFunctionData9 } from "viem";
3813
+ import { encodeFunctionData as encodeFunctionData8 } from "viem";
3815
3814
  import { useCallback as useCallback22 } from "react";
3816
3815
  function useMintOrgAnymalNFT() {
3817
3816
  return useCallback22(
@@ -3830,13 +3829,13 @@ function useMintOrgAnymalNFT() {
3830
3829
  "petastic-signup-campaign-1",
3831
3830
  anymalTxId
3832
3831
  ];
3833
- const callData = encodeFunctionData9({
3832
+ const callData = encodeFunctionData8({
3834
3833
  abi: PET_NFT_ABI,
3835
3834
  functionName,
3836
3835
  args
3837
3836
  });
3838
3837
  const executeArgs = [validationContractAddress, callData];
3839
- const executeSubmitMetaCalldata = encodeFunctionData9({
3838
+ const executeSubmitMetaCalldata = encodeFunctionData8({
3840
3839
  abi: ORGANIZATION_IMPL_ABI,
3841
3840
  functionName: ORG_FUNCTION,
3842
3841
  args: executeArgs
@@ -4166,7 +4165,7 @@ function useFetchBalance() {
4166
4165
  }
4167
4166
 
4168
4167
  // src/utils/actions/useClaimActionReward.ts
4169
- import { encodeFunctionData as encodeFunctionData10 } from "viem";
4168
+ import { encodeFunctionData as encodeFunctionData9 } from "viem";
4170
4169
  import { useCallback as useCallback28 } from "react";
4171
4170
  function useClaimActionReward() {
4172
4171
  return useCallback28(
@@ -4179,7 +4178,7 @@ function useClaimActionReward() {
4179
4178
  }
4180
4179
  const args = [actionId, claimIndex];
4181
4180
  const functionName = "claimByIndex";
4182
- const callData = encodeFunctionData10({
4181
+ const callData = encodeFunctionData9({
4183
4182
  abi: REWARDABLE_ACTIONS_ABI,
4184
4183
  functionName,
4185
4184
  args
@@ -4215,7 +4214,7 @@ function useClaimActionReward() {
4215
4214
  }
4216
4215
 
4217
4216
  // src/utils/actions/useClaimOrgActionReward.ts
4218
- import { encodeFunctionData as encodeFunctionData11 } from "viem";
4217
+ import { encodeFunctionData as encodeFunctionData10 } from "viem";
4219
4218
  import { useCallback as useCallback29 } from "react";
4220
4219
  function useClaimOrgActionReward() {
4221
4220
  return useCallback29(
@@ -4226,13 +4225,13 @@ function useClaimOrgActionReward() {
4226
4225
  message: "Missing web3auth account info or contract address."
4227
4226
  };
4228
4227
  }
4229
- const claimCallData = encodeFunctionData11({
4228
+ const claimCallData = encodeFunctionData10({
4230
4229
  abi: REWARDABLE_ACTIONS_ABI,
4231
4230
  functionName: "claimByIndex",
4232
4231
  args: [actionId, claimIndex]
4233
4232
  });
4234
4233
  const args = [rewardableActionContractAddress, claimCallData];
4235
- const executeClaimCalldata = encodeFunctionData11({
4234
+ const executeClaimCalldata = encodeFunctionData10({
4236
4235
  abi: ORGANIZATION_IMPL_ABI,
4237
4236
  functionName: ORG_FUNCTION,
4238
4237
  args
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.130",
3
+ "version": "1.0.132",
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": {