anymal-protocol 1.0.120 → 1.0.122

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 CHANGED
@@ -41,6 +41,7 @@ __export(index_exports, {
41
41
  generateBytes32Nonce: () => generateBytes32Nonce,
42
42
  generateJWT: () => generateJWT,
43
43
  getFirebaseTokenForApp: () => getFirebaseTokenForApp,
44
+ humanRevert: () => humanRevert,
44
45
  loadExistingSecp256k1PrivateKey: () => loadExistingSecp256k1PrivateKey,
45
46
  processDirectKibbleApproval: () => processDirectKibbleApproval,
46
47
  processDirectPartialPayment: () => processDirectPartialPayment,
@@ -66,6 +67,7 @@ __export(index_exports, {
66
67
  useFetchNotifications: () => useFetchNotifications,
67
68
  useFetchUserData: () => useFetchUserData,
68
69
  useMintAnymalNFT: () => useMintAnymalNFT,
70
+ useMintOrgAnymalNFT: () => useMintOrgAnymalNFT,
69
71
  useProcessOrgPartialKibblePayment: () => useProcessOrgPartialKibblePayment,
70
72
  useProcessPartialKibblePayment: () => useProcessPartialKibblePayment,
71
73
  useSaveAnymalMetadata: () => useSaveAnymalMetadata,
@@ -458,9 +460,10 @@ function useFetchNotifications() {
458
460
  }
459
461
 
460
462
  // src/utils/anymals/useMintAnymalNFT.ts
461
- var import_viem = require("viem");
463
+ var import_viem3 = require("viem");
462
464
 
463
465
  // src/helpers/BlockchainAbiHelper.tsx
466
+ var import_viem = require("viem");
464
467
  var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "AccessControlBadConfirmation", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "bytes32", "name": "neededRole", "type": "bytes32" }], "name": "AccessControlUnauthorizedAccount", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "ERC1967InvalidImplementation", "type": "error" }, { "inputs": [], "name": "ERC1967NonPayable", "type": "error" }, { "inputs": [], "name": "EnforcedPause", "type": "error" }, { "inputs": [], "name": "ExpectedPause", "type": "error" }, { "inputs": [], "name": "FailedCall", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }], "name": "UUPSUnsupportedProxiableUUID", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "nftId", "type": "string" }, { "indexed": false, "internalType": "string", "name": "metadataURL", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "campaignId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "MetadataApproved", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "string", "name": "anymalTxId", "type": "string" }, { "indexed": false, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "nftId", "type": "string" }, { "indexed": false, "internalType": "string", "name": "metadataURL", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "campaignId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "MetadataRejected", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "nftId", "type": "string" }, { "indexed": false, "internalType": "string", "name": "metadataURL", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "campaignId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "MetadataSubmitted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], "name": "Paused", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "nftId", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "campaignId", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "RewardDistributed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" }], "name": "RoleAdminChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleGranted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleRevoked", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], "name": "Unpaused", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "APPROVER_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "string", "name": "_pid", "type": "string" }, { "internalType": "string", "name": "_nftId", "type": "string" }, { "internalType": "string", "name": "_metadataURL", "type": "string" }, { "internalType": "uint256", "name": "_campaignId", "type": "uint256" }, { "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "approveMetadata", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "campaignCount", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "campaigns", "outputs": [{ "internalType": "string", "name": "name", "type": "string" }, { "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }, { "internalType": "bool", "name": "isActive", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "_name", "type": "string" }, { "internalType": "uint256", "name": "_rewardAmount", "type": "uint256" }], "name": "createCampaign", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "defaultRewardAmount", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleAdmin", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "hasRole", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "contract IERC20", "name": "_rewardToken", "type": "address" }, { "internalType": "contract IPetToken", "name": "_petToken", "type": "address" }, { "internalType": "uint256", "name": "_defaultRewardAmount", "type": "uint256" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "paused", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "petToken", "outputs": [{ "internalType": "contract IPetToken", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "proxiableUUID", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "callerConfirmation", "type": "address" }], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "rewardToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "_pid", "type": "string" }, { "internalType": "string", "name": "_nftId", "type": "string" }, { "internalType": "string", "name": "_metadataURL", "type": "string" }, { "internalType": "uint256", "name": "_campaignId", "type": "uint256" }, { "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "submitMetadata", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "_pid", "type": "string" }, { "internalType": "string", "name": "_nftId", "type": "string" }, { "internalType": "string", "name": "_metadataURL", "type": "string" }, { "internalType": "string", "name": "_campaignName", "type": "string" }, { "internalType": "string", "name": "_anymalTxId", "type": "string" }], "name": "submitMetadataByCampaignName", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], "name": "supportsInterface", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_campaignId", "type": "uint256" }, { "internalType": "uint256", "name": "_rewardAmount", "type": "uint256" }, { "internalType": "bool", "name": "_isActive", "type": "bool" }], "name": "updateCampaign", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_rewardAmount", "type": "uint256" }], "name": "updateDefaultReward", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" }];
465
468
  var MARKETPLACE_ABI = [{ "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [], "name": "ECDSAInvalidSignature", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "length", "type": "uint256" }], "name": "ECDSAInvalidSignatureLength", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "ECDSAInvalidSignatureS", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "ERC1967InvalidImplementation", "type": "error" }, { "inputs": [], "name": "ERC1967NonPayable", "type": "error" }, { "inputs": [], "name": "FailedCall", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "OwnableInvalidOwner", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "OwnableUnauthorizedAccount", "type": "error" }, { "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }], "name": "UUPSUnsupportedProxiableUUID", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "anymalNftId", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PartialPaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "refundedAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "RefundProcessed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "SignatureCheckToggled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "authorizer", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_initialOwner", "type": "address" }, { "internalType": "address", "name": "_authorizer", "type": "address" }, { "internalType": "address", "name": "_kibbleToken", "type": "address" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "kibbleToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }, { "internalType": "address", "name": "", "type": "address" }], "name": "paidAmounts", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "string", "name": "anymalNftId", "type": "string" }, { "internalType": "string", "name": "pid", "type": "string" }, { "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "internalType": "uint256", "name": "maxTokenPayment", "type": "uint256" }, { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "bytes", "name": "backendSignature", "type": "bytes" }], "name": "partialPay", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proxiableUUID", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "address", "name": "payer", "type": "address" }, { "internalType": "string", "name": "pid", "type": "string" }], "name": "refund", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_authorizer", "type": "address" }], "name": "setAuthorizer", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "setSignatureCheckEnabled", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "signatureCheckEnabled", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "name": "usedNonces", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdrawKibble", "outputs": [], "stateMutability": "nonpayable", "type": "function" }];
466
469
  var ORGANIZATION_BEACON_ABI = [{ "inputs": [{ "internalType": "address", "name": "_initialImplementation", "type": "address" }, { "internalType": "address", "name": "_initialOwner", "type": "address" }, { "internalType": "address", "name": "_anymalNFTProxy", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "BeaconInvalidImplementation", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "OwnableInvalidOwner", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "OwnableUnauthorizedAccount", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "name", "type": "string" }, { "indexed": false, "internalType": "address", "name": "proxyAddress", "type": "address" }, { "indexed": false, "internalType": "address", "name": "networkAdmin", "type": "address" }, { "indexed": false, "internalType": "address", "name": "userAdmin", "type": "address" }], "name": "NewOrganizationCreated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "anymalNFTProxy", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_userAdmin", "type": "address" }, { "internalType": "string", "name": "_orgName", "type": "string" }, { "internalType": "string", "name": "_orgPid", "type": "string" }], "name": "createOrganizationProxy", "outputs": [{ "internalType": "address", "name": "proxyAddress", "type": "address" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "implementation", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }], "name": "upgradeBeaconTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }], "name": "upgradeTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }];
@@ -1275,6 +1278,21 @@ var ORGANIZATION_IMPL_ABI = [
1275
1278
  "type": "function"
1276
1279
  }
1277
1280
  ];
1281
+ var KIBBLE_TOKEN_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [], "name": "CheckpointUnorderedInsertion", "type": "error" }, { "inputs": [], "name": "ECDSAInvalidSignature", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "length", "type": "uint256" }], "name": "ECDSAInvalidSignatureLength", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "ECDSAInvalidSignatureS", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "ERC1967InvalidImplementation", "type": "error" }, { "inputs": [], "name": "ERC1967NonPayable", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "increasedSupply", "type": "uint256" }, { "internalType": "uint256", "name": "cap", "type": "uint256" }], "name": "ERC20ExceededSafeSupply", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "allowance", "type": "uint256" }, { "internalType": "uint256", "name": "needed", "type": "uint256" }], "name": "ERC20InsufficientAllowance", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "sender", "type": "address" }, { "internalType": "uint256", "name": "balance", "type": "uint256" }, { "internalType": "uint256", "name": "needed", "type": "uint256" }], "name": "ERC20InsufficientBalance", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "approver", "type": "address" }], "name": "ERC20InvalidApprover", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "receiver", "type": "address" }], "name": "ERC20InvalidReceiver", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "sender", "type": "address" }], "name": "ERC20InvalidSender", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }], "name": "ERC20InvalidSpender", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "deadline", "type": "uint256" }], "name": "ERC2612ExpiredSignature", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "signer", "type": "address" }, { "internalType": "address", "name": "owner", "type": "address" }], "name": "ERC2612InvalidSigner", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "timepoint", "type": "uint256" }, { "internalType": "uint48", "name": "clock", "type": "uint48" }], "name": "ERC5805FutureLookup", "type": "error" }, { "inputs": [], "name": "ERC6372InconsistentClock", "type": "error" }, { "inputs": [], "name": "EnforcedPause", "type": "error" }, { "inputs": [], "name": "ExpectedPause", "type": "error" }, { "inputs": [], "name": "FailedCall", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "uint256", "name": "currentNonce", "type": "uint256" }], "name": "InvalidAccountNonce", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "OwnableInvalidOwner", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "OwnableUnauthorizedAccount", "type": "error" }, { "inputs": [{ "internalType": "uint8", "name": "bits", "type": "uint8" }, { "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "SafeCastOverflowedUintDowncast", "type": "error" }, { "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }], "name": "UUPSUnsupportedProxiableUUID", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "expiry", "type": "uint256" }], "name": "VotesExpiredSignature", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "delegator", "type": "address" }, { "indexed": true, "internalType": "address", "name": "fromDelegate", "type": "address" }, { "indexed": true, "internalType": "address", "name": "toDelegate", "type": "address" }], "name": "DelegateChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "delegate", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "previousVotes", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "newVotes", "type": "uint256" }], "name": "DelegateVotesChanged", "type": "event" }, { "anonymous": false, "inputs": [], "name": "EIP712DomainChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], "name": "Paused", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "Transfer", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], "name": "Unpaused", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "CLOCK_MODE", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "DOMAIN_SEPARATOR", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" }], "name": "allowance", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "approve", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "burn", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "burnFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "uint32", "name": "pos", "type": "uint32" }], "name": "checkpoints", "outputs": [{ "components": [{ "internalType": "uint48", "name": "_key", "type": "uint48" }, { "internalType": "uint208", "name": "_value", "type": "uint208" }], "internalType": "struct Checkpoints.Checkpoint208", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "clock", "outputs": [{ "internalType": "uint48", "name": "", "type": "uint48" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "delegatee", "type": "address" }], "name": "delegate", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "delegatee", "type": "address" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint8", "name": "v", "type": "uint8" }, { "internalType": "bytes32", "name": "r", "type": "bytes32" }, { "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "delegateBySig", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "delegates", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "eip712Domain", "outputs": [{ "internalType": "bytes1", "name": "fields", "type": "bytes1" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "version", "type": "string" }, { "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "verifyingContract", "type": "address" }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256[]", "name": "extensions", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "timepoint", "type": "uint256" }], "name": "getPastTotalSupply", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "uint256", "name": "timepoint", "type": "uint256" }], "name": "getPastVotes", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "getVotes", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "initialOwner", "type": "address" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "mint", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "name", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "nonces", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "numCheckpoints", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "paused", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "uint8", "name": "v", "type": "uint8" }, { "internalType": "bytes32", "name": "r", "type": "bytes32" }, { "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "permit", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proxiableUUID", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "symbol", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalSupply", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "transfer", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }], "name": "transferFrom", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" }];
1282
+ var LOCAL_ERRORS = [
1283
+ ...KIBBLE_TOKEN_ABI.filter((item) => item.type === "error"),
1284
+ ...ORGANIZATION_IMPL_ABI.filter((item) => item.type === "error"),
1285
+ ...MARKETPLACE_ABI.filter((item) => item.type === "error"),
1286
+ ...REWARDABLE_ACTIONS_ABI.filter((item) => item.type === "error"),
1287
+ ...PET_NFT_ABI.filter((item) => item.type === "error"),
1288
+ ...ORGANIZATION_BEACON_ABI.filter((item) => item.type === "error")
1289
+ ];
1290
+ var OZ_ERROR_FRAGMENTS = [
1291
+ "error AddressLowLevelCallFailed(address target, bytes data)",
1292
+ "error AddressEmptyCode(address target)"
1293
+ ];
1294
+ var ERROR_ABI = [...LOCAL_ERRORS, (0, import_viem.parseAbi)([...OZ_ERROR_FRAGMENTS])];
1295
+ var ORG_FUNCTION = "executeCall";
1278
1296
 
1279
1297
  // src/utils/anymals/useMintAnymalNFT.ts
1280
1298
  var import_react10 = require("react");
@@ -1320,6 +1338,42 @@ async function applyBundlerGasEstimator(account, bundlerClient, options) {
1320
1338
  };
1321
1339
  }
1322
1340
 
1341
+ // src/helpers/HumanRevert.tsx
1342
+ var import_viem2 = require("viem");
1343
+ function humanRevert(raw, shortMessage) {
1344
+ if (!raw) return shortMessage ?? "Simulation reverted";
1345
+ try {
1346
+ const { errorName, args } = (0, import_viem2.decodeErrorResult)({
1347
+ abi: ERROR_ABI,
1348
+ data: raw
1349
+ });
1350
+ return `${errorName}(${args.map(String).join(", ")})`;
1351
+ } catch {
1352
+ if (raw.startsWith("0x08c379a0") && raw.length >= 138) {
1353
+ return (0, import_viem2.hexToString)(`0x${raw.slice(138)}`);
1354
+ }
1355
+ return `${raw.slice(0, 10)}\u2026`;
1356
+ }
1357
+ }
1358
+
1359
+ // src/helpers/SimulationHelper.tsx
1360
+ async function simulateCall(publicClient, target, abi, functionName, args, caller) {
1361
+ try {
1362
+ await publicClient.simulateContract({
1363
+ address: target,
1364
+ abi,
1365
+ functionName,
1366
+ args,
1367
+ account: caller
1368
+ });
1369
+ } catch (simErr) {
1370
+ const raw = simErr.raw ?? simErr.cause?.raw;
1371
+ const shortMsg = simErr.shortMessage;
1372
+ const reason = humanRevert(raw, shortMsg);
1373
+ throw new Error(`Simulation failed: ${reason}`);
1374
+ }
1375
+ }
1376
+
1323
1377
  // src/utils/anymals/useMintAnymalNFT.ts
1324
1378
  function useMintAnymalNFT() {
1325
1379
  return (0, import_react10.useCallback)(
@@ -1330,17 +1384,27 @@ function useMintAnymalNFT() {
1330
1384
  message: "Missing authentication token OR NFT ID."
1331
1385
  };
1332
1386
  }
1333
- const callData = (0, import_viem.encodeFunctionData)({
1387
+ const functionName = "submitMetadataByCampaignName";
1388
+ const args = [
1389
+ pid,
1390
+ nftId,
1391
+ `https://dev-nft.petastic.com/metadata/${nftId}`,
1392
+ "petastic-signup-campaign-1",
1393
+ anymalTxId
1394
+ ];
1395
+ const callData = (0, import_viem3.encodeFunctionData)({
1334
1396
  abi: PET_NFT_ABI,
1335
- functionName: "submitMetadataByCampaignName",
1336
- args: [
1337
- pid,
1338
- nftId,
1339
- `https://dev-nft.petastic.com/metadata/${nftId}`,
1340
- "petastic-signup-campaign-1",
1341
- anymalTxId
1342
- ]
1397
+ functionName,
1398
+ args
1343
1399
  });
1400
+ await simulateCall(
1401
+ bundlerClient.client,
1402
+ validationContractAddress,
1403
+ PET_NFT_ABI,
1404
+ functionName,
1405
+ args,
1406
+ smartAccount.address
1407
+ );
1344
1408
  await applyBundlerGasEstimator(smartAccount, bundlerClient);
1345
1409
  const userOpHash = await bundlerClient.sendUserOperation({
1346
1410
  account: smartAccount,
@@ -1738,7 +1802,7 @@ function useFetchAnymals() {
1738
1802
  var import_react17 = require("react");
1739
1803
 
1740
1804
  // src/helpers/ProcessDirectPartialPayment.tsx
1741
- var import_viem2 = require("viem");
1805
+ var import_viem4 = require("viem");
1742
1806
 
1743
1807
  // src/helpers/SendUserOpWithRetries.tsx
1744
1808
  async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
@@ -1787,20 +1851,30 @@ async function waitForReceiptWithRetries(bundlerClient, hash, retries = 3, delay
1787
1851
  // src/helpers/ProcessDirectPartialPayment.tsx
1788
1852
  async function processDirectPartialPayment(marketplaceContract, smartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
1789
1853
  try {
1790
- const partialPayCalldata = (0, import_viem2.encodeFunctionData)({
1854
+ const functionName = "partialPay";
1855
+ const args = [
1856
+ orderId,
1857
+ anymalNftId,
1858
+ pid,
1859
+ amountInTokens,
1860
+ maxTokenPayment,
1861
+ nonce,
1862
+ deadline,
1863
+ backendSignature
1864
+ ];
1865
+ const partialPayCalldata = (0, import_viem4.encodeFunctionData)({
1791
1866
  abi: MARKETPLACE_ABI,
1792
- functionName: "partialPay",
1793
- args: [
1794
- orderId,
1795
- anymalNftId,
1796
- pid,
1797
- amountInTokens,
1798
- maxTokenPayment,
1799
- nonce,
1800
- deadline,
1801
- backendSignature
1802
- ]
1867
+ functionName,
1868
+ args
1803
1869
  });
1870
+ await simulateCall(
1871
+ bundlerClient.client,
1872
+ marketplaceContract,
1873
+ MARKETPLACE_ABI,
1874
+ functionName,
1875
+ args,
1876
+ smartAccount.address
1877
+ );
1804
1878
  await applyBundlerGasEstimator(smartAccount, bundlerClient);
1805
1879
  const userOpHash = await sendUserOpWithRetries(bundlerClient, {
1806
1880
  account: smartAccount,
@@ -1815,6 +1889,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
1815
1889
  };
1816
1890
  } catch (error) {
1817
1891
  const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
1892
+ console.error(errorMessage);
1818
1893
  return {
1819
1894
  success: false,
1820
1895
  message: `Error during direct payment processing: ${errorMessage}`
@@ -1883,14 +1958,24 @@ function useProcessPartialKibblePayment() {
1883
1958
  var import_react18 = require("react");
1884
1959
 
1885
1960
  // src/helpers/ProcessDirectKibbleApproval.tsx
1886
- var import_viem3 = require("viem");
1961
+ var import_viem5 = require("viem");
1887
1962
  async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
1888
1963
  try {
1889
- const approveCalldata = (0, import_viem3.encodeFunctionData)({
1890
- abi: import_viem3.erc20Abi,
1891
- functionName: "approve",
1892
- args: [spenderAddress, approveAmount]
1964
+ const functionName = "approve";
1965
+ const args = [spenderAddress, approveAmount];
1966
+ const approveCalldata = (0, import_viem5.encodeFunctionData)({
1967
+ abi: import_viem5.erc20Abi,
1968
+ functionName,
1969
+ args
1893
1970
  });
1971
+ await simulateCall(
1972
+ bundlerClient.client,
1973
+ kibbleTokenAddress,
1974
+ import_viem5.erc20Abi,
1975
+ functionName,
1976
+ args,
1977
+ smartAccount.address
1978
+ );
1894
1979
  await applyBundlerGasEstimator(smartAccount, bundlerClient);
1895
1980
  const userOpHash = await sendUserOpWithRetries(bundlerClient, {
1896
1981
  account: smartAccount,
@@ -1905,6 +1990,7 @@ async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, s
1905
1990
  };
1906
1991
  } catch (error) {
1907
1992
  const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
1993
+ console.error(errorMessage);
1908
1994
  return {
1909
1995
  success: false,
1910
1996
  message: `Error during direct approval processing: ${errorMessage}`
@@ -1942,7 +2028,7 @@ function useApproveKibbleToken() {
1942
2028
 
1943
2029
  // src/utils/organization/useCreateOrganizationBase.ts
1944
2030
  var import_react19 = require("react");
1945
- var import_viem4 = require("viem");
2031
+ var import_viem6 = require("viem");
1946
2032
  function useCreateOrganizationBase() {
1947
2033
  return (0, import_react19.useCallback)(
1948
2034
  /**
@@ -1964,11 +2050,21 @@ function useCreateOrganizationBase() {
1964
2050
  };
1965
2051
  }
1966
2052
  try {
1967
- const callData = (0, import_viem4.encodeFunctionData)({
2053
+ const functionName = "createOrganizationProxy";
2054
+ const args = [ownerAddress, orgName, orgPid];
2055
+ const callData = (0, import_viem6.encodeFunctionData)({
1968
2056
  abi: ORGANIZATION_BEACON_ABI,
1969
- functionName: "createOrganizationProxy",
1970
- args: [ownerAddress, orgName, orgPid]
2057
+ functionName,
2058
+ args
1971
2059
  });
2060
+ await simulateCall(
2061
+ bundlerClient.client,
2062
+ orgContractAddress,
2063
+ ORGANIZATION_BEACON_ABI,
2064
+ functionName,
2065
+ args,
2066
+ adminSmartAccount.address
2067
+ );
1972
2068
  await applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1973
2069
  const userOpHash = await bundlerClient.sendUserOperation({
1974
2070
  account: adminSmartAccount,
@@ -1994,7 +2090,7 @@ function useCreateOrganizationBase() {
1994
2090
  let proxyAddress;
1995
2091
  for (const log of txReceipt.logs) {
1996
2092
  try {
1997
- const decoded = (0, import_viem4.decodeEventLog)({
2093
+ const decoded = (0, import_viem6.decodeEventLog)({
1998
2094
  abi: ORGANIZATION_BEACON_ABI,
1999
2095
  data: log.data,
2000
2096
  topics: log.topics
@@ -2033,10 +2129,10 @@ function useCreateOrganizationBase() {
2033
2129
  var import_react20 = require("react");
2034
2130
 
2035
2131
  // src/helpers/ProcessOrgKibbleApproval.tsx
2036
- var import_viem6 = require("viem");
2132
+ var import_viem8 = require("viem");
2037
2133
 
2038
2134
  // src/helpers/WaitForAllowance.tsx
2039
- var import_viem5 = require("viem");
2135
+ var import_viem7 = require("viem");
2040
2136
  async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spenderAddress, expectedAmount) {
2041
2137
  const MAX_RETRIES = 10;
2042
2138
  const RETRY_INTERVAL = 2e3;
@@ -2045,7 +2141,7 @@ async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spende
2045
2141
  try {
2046
2142
  const currentAllowance = await publicClient.readContract({
2047
2143
  address: tokenAddress,
2048
- abi: import_viem5.erc20Abi,
2144
+ abi: import_viem7.erc20Abi,
2049
2145
  functionName: "allowance",
2050
2146
  args: [ownerAddress, spenderAddress]
2051
2147
  });
@@ -2070,16 +2166,25 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
2070
2166
  if (approveAmount <= 0n) {
2071
2167
  return { success: false, message: "Approval amount must be greater than zero." };
2072
2168
  }
2073
- const approveCalldata = (0, import_viem6.encodeFunctionData)({
2074
- abi: import_viem6.erc20Abi,
2169
+ const approveCalldata = (0, import_viem8.encodeFunctionData)({
2170
+ abi: import_viem8.erc20Abi,
2075
2171
  functionName: "approve",
2076
2172
  args: [partialPaymentModuleAddress, approveAmount]
2077
2173
  });
2078
- const executeApproveCalldata = (0, import_viem6.encodeFunctionData)({
2174
+ const args = [kibbleTokenAddress, approveCalldata];
2175
+ const executeApproveCalldata = (0, import_viem8.encodeFunctionData)({
2079
2176
  abi: ORGANIZATION_IMPL_ABI,
2080
- functionName: "executeCall",
2081
- args: [kibbleTokenAddress, approveCalldata]
2177
+ functionName: ORG_FUNCTION,
2178
+ args
2082
2179
  });
2180
+ await simulateCall(
2181
+ bundlerClient.client,
2182
+ orgContractAddress,
2183
+ ORGANIZATION_IMPL_ABI,
2184
+ ORG_FUNCTION,
2185
+ args,
2186
+ managerSmartAccount.address
2187
+ );
2083
2188
  await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2084
2189
  const userOpApproveHash = await sendUserOpWithRetries(bundlerClient, {
2085
2190
  account: managerSmartAccount,
@@ -2109,6 +2214,7 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
2109
2214
  };
2110
2215
  } catch (error) {
2111
2216
  const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
2217
+ console.error(errorMessage);
2112
2218
  return {
2113
2219
  success: false,
2114
2220
  message: `Error during approval processing: ${errorMessage}`
@@ -2153,10 +2259,10 @@ function useApproveOrgPartialPayment() {
2153
2259
  var import_react21 = require("react");
2154
2260
 
2155
2261
  // src/helpers/ProcessOrgPartialPayment.tsx
2156
- var import_viem7 = require("viem");
2262
+ var import_viem9 = require("viem");
2157
2263
  async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
2158
2264
  try {
2159
- const partialPayCalldata = (0, import_viem7.encodeFunctionData)({
2265
+ const partialPayCalldata = (0, import_viem9.encodeFunctionData)({
2160
2266
  abi: MARKETPLACE_ABI,
2161
2267
  functionName: "partialPay",
2162
2268
  args: [
@@ -2170,11 +2276,20 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
2170
2276
  backendSignature
2171
2277
  ]
2172
2278
  });
2173
- const executePartialPayCalldata = (0, import_viem7.encodeFunctionData)({
2279
+ const args = [partialPaymentModuleAddress, partialPayCalldata];
2280
+ const executePartialPayCalldata = (0, import_viem9.encodeFunctionData)({
2174
2281
  abi: ORGANIZATION_IMPL_ABI,
2175
- functionName: "executeCall",
2176
- args: [partialPaymentModuleAddress, partialPayCalldata]
2282
+ functionName: ORG_FUNCTION,
2283
+ args
2177
2284
  });
2285
+ await simulateCall(
2286
+ bundlerClient.client,
2287
+ orgContractAddress,
2288
+ ORGANIZATION_IMPL_ABI,
2289
+ ORG_FUNCTION,
2290
+ args,
2291
+ managerSmartAccount.address
2292
+ );
2178
2293
  await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2179
2294
  const userOpHash = await sendUserOpWithRetries(bundlerClient, {
2180
2295
  account: managerSmartAccount,
@@ -2189,6 +2304,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
2189
2304
  };
2190
2305
  } catch (error) {
2191
2306
  const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
2307
+ console.error(errorMessage);
2192
2308
  return {
2193
2309
  success: false,
2194
2310
  message: `Error during payment processing: ${errorMessage}`
@@ -2276,12 +2392,64 @@ function useUpdateOrgWalletAddress() {
2276
2392
  );
2277
2393
  }
2278
2394
 
2395
+ // src/utils/organization/useMintOrgAnymalNFT.ts
2396
+ var import_viem10 = require("viem");
2397
+ var import_react23 = require("react");
2398
+ function useMintOrgAnymalNFT() {
2399
+ return (0, import_react23.useCallback)(
2400
+ async (orgContractAddress, pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, managerSmartAccount, bundlerClient) => {
2401
+ if (!dbAuthToken || !nftId || !bundlerClient || !managerSmartAccount || !pid || !validationContractAddress || !orgContractAddress) {
2402
+ return {
2403
+ success: false,
2404
+ message: "Missing authentication token OR NFT ID."
2405
+ };
2406
+ }
2407
+ const functionName = "submitMetadataByCampaignName";
2408
+ const args = [
2409
+ pid,
2410
+ nftId,
2411
+ `https://dev-nft.petastic.com/metadata/${nftId}`,
2412
+ "petastic-signup-campaign-1",
2413
+ anymalTxId
2414
+ ];
2415
+ const callData = (0, import_viem10.encodeFunctionData)({
2416
+ abi: PET_NFT_ABI,
2417
+ functionName,
2418
+ args
2419
+ });
2420
+ const executeArgs = [validationContractAddress, callData];
2421
+ const executeSubmitMetaCalldata = (0, import_viem10.encodeFunctionData)({
2422
+ abi: ORGANIZATION_IMPL_ABI,
2423
+ functionName: ORG_FUNCTION,
2424
+ args: executeArgs
2425
+ });
2426
+ await simulateCall(
2427
+ bundlerClient.client,
2428
+ orgContractAddress,
2429
+ ORGANIZATION_IMPL_ABI,
2430
+ ORG_FUNCTION,
2431
+ executeArgs,
2432
+ managerSmartAccount.address
2433
+ );
2434
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2435
+ const userOpHash = await sendUserOpWithRetries(bundlerClient, {
2436
+ account: managerSmartAccount,
2437
+ calls: [{ to: orgContractAddress, data: executeSubmitMetaCalldata }],
2438
+ paymaster: true
2439
+ });
2440
+ await waitForReceiptWithRetries(bundlerClient, userOpHash);
2441
+ return { success: true, message: "Pet Passport Created!" };
2442
+ },
2443
+ []
2444
+ );
2445
+ }
2446
+
2279
2447
  // src/helpers/NonceHelper.tsx
2280
2448
  var import_uuid = require("uuid");
2281
- var import_viem8 = require("viem");
2449
+ var import_viem11 = require("viem");
2282
2450
  var generateBytes32Nonce = () => {
2283
2451
  const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
2284
- return (0, import_viem8.padHex)(`0x${uuid3}`, { size: 32 });
2452
+ return (0, import_viem11.padHex)(`0x${uuid3}`, { size: 32 });
2285
2453
  };
2286
2454
 
2287
2455
  // src/helpers/CryptoUtils.tsx
@@ -2491,9 +2659,9 @@ async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl)
2491
2659
  }
2492
2660
 
2493
2661
  // src/utils/actions/useFetchActions.ts
2494
- var import_react23 = require("react");
2662
+ var import_react24 = require("react");
2495
2663
  function useFetchActions() {
2496
- return (0, import_react23.useCallback)(
2664
+ return (0, import_react24.useCallback)(
2497
2665
  async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
2498
2666
  const params = new URLSearchParams({ pid });
2499
2667
  if (status) params.set("status", status);
@@ -2522,9 +2690,9 @@ function useFetchActions() {
2522
2690
  }
2523
2691
 
2524
2692
  // src/utils/actions/useFetchActionDefinitions.ts
2525
- var import_react24 = require("react");
2693
+ var import_react25 = require("react");
2526
2694
  function useFetchActionDefinitions() {
2527
- return (0, import_react24.useCallback)(
2695
+ return (0, import_react25.useCallback)(
2528
2696
  async (idToken, actionsServiceBaseUrl) => {
2529
2697
  try {
2530
2698
  const response = await fetch(
@@ -2621,10 +2789,10 @@ var convertToMultipleActionRecords = (frs) => frs.map(convertToActionRecord);
2621
2789
  var convertToMultipleActionDefinitions = (frs) => frs.map(convertToActionDefinition);
2622
2790
 
2623
2791
  // src/utils/application/useCreateUserAppData.ts
2624
- var import_react25 = require("react");
2792
+ var import_react26 = require("react");
2625
2793
  var import_uuid2 = require("uuid");
2626
2794
  function useCreateUserAppData() {
2627
- return (0, import_react25.useCallback)(
2795
+ return (0, import_react26.useCallback)(
2628
2796
  async (appId, pid, dbAuthToken, endpoint) => {
2629
2797
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2630
2798
  const appValues = {
@@ -2679,10 +2847,10 @@ function useCreateUserAppData() {
2679
2847
  }
2680
2848
 
2681
2849
  // src/utils/application/useCreateOrganizationAppData.ts
2682
- var import_react26 = require("react");
2850
+ var import_react27 = require("react");
2683
2851
  var import_uuid3 = require("uuid");
2684
2852
  function useCreateOrganizationAppData() {
2685
- return (0, import_react26.useCallback)(
2853
+ return (0, import_react27.useCallback)(
2686
2854
  async (appId, pid, dbAuthToken, endpoint) => {
2687
2855
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2688
2856
  const appValues = {
@@ -2736,17 +2904,17 @@ function useCreateOrganizationAppData() {
2736
2904
  }
2737
2905
 
2738
2906
  // src/utils/balance/useFetchBalance.ts
2739
- var import_react27 = require("react");
2740
- var import_viem9 = require("viem");
2907
+ var import_react28 = require("react");
2908
+ var import_viem12 = require("viem");
2741
2909
  function useFetchBalance() {
2742
- return (0, import_react27.useCallback)(
2910
+ return (0, import_react28.useCallback)(
2743
2911
  async (publicClient, walletAddress, kibbleTokenAddress) => {
2744
2912
  try {
2745
2913
  const balance = await publicClient.readContract({
2746
- address: (0, import_viem9.getAddress)(kibbleTokenAddress),
2747
- abi: import_viem9.erc20Abi,
2914
+ address: (0, import_viem12.getAddress)(kibbleTokenAddress),
2915
+ abi: import_viem12.erc20Abi,
2748
2916
  functionName: "balanceOf",
2749
- args: [(0, import_viem9.getAddress)(walletAddress)]
2917
+ args: [(0, import_viem12.getAddress)(walletAddress)]
2750
2918
  });
2751
2919
  return Number(balance);
2752
2920
  } catch (error) {
@@ -2758,10 +2926,10 @@ function useFetchBalance() {
2758
2926
  }
2759
2927
 
2760
2928
  // src/utils/actions/useClaimActionReward.ts
2761
- var import_viem10 = require("viem");
2762
- var import_react28 = require("react");
2929
+ var import_viem13 = require("viem");
2930
+ var import_react29 = require("react");
2763
2931
  function useClaimActionReward() {
2764
- return (0, import_react28.useCallback)(
2932
+ return (0, import_react29.useCallback)(
2765
2933
  async (actionId, claimIndex, rewardableActionContractAddress, smartAccount, bundlerClient) => {
2766
2934
  if (!actionId || claimIndex === void 0 || !bundlerClient || !smartAccount || !rewardableActionContractAddress) {
2767
2935
  return {
@@ -2769,11 +2937,21 @@ function useClaimActionReward() {
2769
2937
  message: "Missing web3auth account info or contract address."
2770
2938
  };
2771
2939
  }
2772
- const callData = (0, import_viem10.encodeFunctionData)({
2940
+ const args = [actionId, claimIndex];
2941
+ const functionName = "claimByIndex";
2942
+ const callData = (0, import_viem13.encodeFunctionData)({
2773
2943
  abi: REWARDABLE_ACTIONS_ABI,
2774
- functionName: "claimByIndex",
2775
- args: [actionId, claimIndex]
2944
+ functionName,
2945
+ args
2776
2946
  });
2947
+ await simulateCall(
2948
+ bundlerClient.client,
2949
+ rewardableActionContractAddress,
2950
+ REWARDABLE_ACTIONS_ABI,
2951
+ functionName,
2952
+ args,
2953
+ smartAccount.address
2954
+ );
2777
2955
  await applyBundlerGasEstimator(smartAccount, bundlerClient);
2778
2956
  const userOpHash = await bundlerClient.sendUserOperation({
2779
2957
  account: smartAccount,
@@ -2797,10 +2975,10 @@ function useClaimActionReward() {
2797
2975
  }
2798
2976
 
2799
2977
  // src/utils/actions/useClaimOrgActionReward.ts
2800
- var import_viem11 = require("viem");
2801
- var import_react29 = require("react");
2978
+ var import_viem14 = require("viem");
2979
+ var import_react30 = require("react");
2802
2980
  function useClaimOrgActionReward() {
2803
- return (0, import_react29.useCallback)(
2981
+ return (0, import_react30.useCallback)(
2804
2982
  async (orgContractAddress, rewardableActionContractAddress, actionId, claimIndex, smartAccount, bundlerClient) => {
2805
2983
  if (!orgContractAddress || !actionId || claimIndex === void 0 || !bundlerClient || !smartAccount) {
2806
2984
  return {
@@ -2808,16 +2986,25 @@ function useClaimOrgActionReward() {
2808
2986
  message: "Missing web3auth account info or contract address."
2809
2987
  };
2810
2988
  }
2811
- const claimCallData = (0, import_viem11.encodeFunctionData)({
2989
+ const claimCallData = (0, import_viem14.encodeFunctionData)({
2812
2990
  abi: REWARDABLE_ACTIONS_ABI,
2813
2991
  functionName: "claimByIndex",
2814
2992
  args: [actionId, claimIndex]
2815
2993
  });
2816
- const executeClaimCalldata = (0, import_viem11.encodeFunctionData)({
2994
+ const args = [rewardableActionContractAddress, claimCallData];
2995
+ const executeClaimCalldata = (0, import_viem14.encodeFunctionData)({
2817
2996
  abi: ORGANIZATION_IMPL_ABI,
2818
- functionName: "executeCall",
2819
- args: [rewardableActionContractAddress, claimCallData]
2997
+ functionName: ORG_FUNCTION,
2998
+ args
2820
2999
  });
3000
+ await simulateCall(
3001
+ bundlerClient.client,
3002
+ orgContractAddress,
3003
+ ORGANIZATION_IMPL_ABI,
3004
+ ORG_FUNCTION,
3005
+ args,
3006
+ smartAccount.address
3007
+ );
2821
3008
  await applyBundlerGasEstimator(smartAccount, bundlerClient);
2822
3009
  const userOpHash = await bundlerClient.sendUserOperation({
2823
3010
  account: smartAccount,
@@ -2841,9 +3028,9 @@ function useClaimOrgActionReward() {
2841
3028
  }
2842
3029
 
2843
3030
  // src/utils/actions/useSubmitContractAction.ts
2844
- var import_react30 = require("react");
3031
+ var import_react31 = require("react");
2845
3032
  function useSubmitContractAction() {
2846
- return (0, import_react30.useCallback)(
3033
+ return (0, import_react31.useCallback)(
2847
3034
  (idToken, pid, source, endpoint, payload) => {
2848
3035
  if (!idToken || !pid || !source || !endpoint || !payload) return;
2849
3036
  let sourceTypePayload = {};
@@ -2981,6 +3168,7 @@ function isMarketplacePurchaseAction(payload) {
2981
3168
  generateBytes32Nonce,
2982
3169
  generateJWT,
2983
3170
  getFirebaseTokenForApp,
3171
+ humanRevert,
2984
3172
  loadExistingSecp256k1PrivateKey,
2985
3173
  processDirectKibbleApproval,
2986
3174
  processDirectPartialPayment,
@@ -3006,6 +3194,7 @@ function isMarketplacePurchaseAction(payload) {
3006
3194
  useFetchNotifications,
3007
3195
  useFetchUserData,
3008
3196
  useMintAnymalNFT,
3197
+ useMintOrgAnymalNFT,
3009
3198
  useProcessOrgPartialKibblePayment,
3010
3199
  useProcessPartialKibblePayment,
3011
3200
  useSaveAnymalMetadata,