anymal-protocol 1.0.121 → 1.0.123

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.
@@ -0,0 +1,98 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ Network2["Localnet"] = "localnet";
14
+ return Network2;
15
+ })(Network || {});
16
+ var NETWORK_HOSTS = {
17
+ ["testnet" /* Testnet */]: "dev-db.petastic.com",
18
+ ["localnet" /* Localnet */]: "host.docker.internal:9181"
19
+ };
20
+ var AUTH_API_ENDPOINTS = {
21
+ ["testnet" /* Testnet */]: "https://dev-auth-api.petastic.com",
22
+ ["localnet" /* Localnet */]: "http://localhost:3005"
23
+ };
24
+ function loadExistingSecp256k1PrivateKey(hexKey) {
25
+ if (!hexKey) {
26
+ throw new Error("Private key hex must be provided");
27
+ }
28
+ return ec.keyFromPrivate(hexKey, "hex");
29
+ }
30
+ function serializePublicKeyCompressed(keyPair) {
31
+ return keyPair.getPublic(true, "hex");
32
+ }
33
+ function base64url(input) {
34
+ let buf;
35
+ if (typeof input === "string") buf = Buffer.from(input);
36
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
37
+ else buf = input;
38
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
39
+ }
40
+ function sha256HashNode(data) {
41
+ const { createHash } = __require("crypto");
42
+ return createHash("sha256").update(data).digest();
43
+ }
44
+ async function hashInput(data) {
45
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
46
+ const encoder = new TextEncoder();
47
+ const encoded = encoder.encode(data);
48
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
49
+ return Buffer.from(hashBuffer);
50
+ } else {
51
+ return sha256HashNode(data);
52
+ }
53
+ }
54
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
55
+ const iat = Math.floor(Date.now() / 1e3);
56
+ const exp = iat + expiresInSeconds;
57
+ const header = { alg: "ES256", typ: "JWT" };
58
+ const payload = { sub, aud, iat, exp };
59
+ const encodedHeader = base64url(JSON.stringify(header));
60
+ const encodedPayload = base64url(JSON.stringify(payload));
61
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
62
+ const hash = await hashInput(signingInput);
63
+ const signature = keyPair.sign(hash, { canonical: true });
64
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
65
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
66
+ const rawSig = Buffer.concat([rBuf, sBuf]);
67
+ const encodedSig = base64url(rawSig);
68
+ return `${signingInput}.${encodedSig}`;
69
+ }
70
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
71
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
72
+ const publicKey = serializePublicKeyCompressed(keyPair);
73
+ const host = NETWORK_HOSTS[network];
74
+ if (!host) {
75
+ throw new Error(`Unsupported network: ${network}`);
76
+ }
77
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
78
+ return { publicKey, token };
79
+ }
80
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
81
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
82
+ const message = `${clientId}:${redirectUri}:${state}`;
83
+ const hash = await hashInput(message);
84
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
85
+ return Buffer.from(signatureDER).toString("hex");
86
+ }
87
+
88
+ export {
89
+ __require,
90
+ Network,
91
+ NETWORK_HOSTS,
92
+ AUTH_API_ENDPOINTS,
93
+ loadExistingSecp256k1PrivateKey,
94
+ serializePublicKeyCompressed,
95
+ generateJWT,
96
+ createAuthEnvelope,
97
+ generateAppSignature
98
+ };
package/dist/index.d.mts CHANGED
@@ -8,7 +8,7 @@ declare function useVerifyAccount(): (pid: string, campaignId: string, dbAuthTok
8
8
 
9
9
  declare function useVerifyWeb3AuthSession(): (idToken: string, publicKey: string, authServiceBaseUrl: string) => Promise<any>;
10
10
 
11
- declare function useCreateWeb3Account(): (idToken: string, publicKey: string, userPid: string, authServiceBaseUrl: string, baseWalletAddress: string, requestedContext: string) => Promise<any>;
11
+ declare function useCreateWeb3Account(): (authToken: string, userPid: string, authServiceBaseUrl: string, baseWalletAddress: string, requestedContext: string) => Promise<any>;
12
12
 
13
13
  declare function useFetchUserData(): (dbAuthToken: string, endpoint: string, pid: string) => Promise<any>;
14
14
 
@@ -152,6 +152,11 @@ declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: strin
152
152
 
153
153
  declare function useUpdateOrgWalletAddress(): (dbAuthToken: string, docID: string, baseWalletAddress: string, endpoint: string) => Promise<void>;
154
154
 
155
+ declare function useMintOrgAnymalNFT(): (orgContractAddress: string, pid: string, nftId: string, anymalTxId: string, dbAuthToken: string, validationContractAddress: string, managerSmartAccount: any, bundlerClient: any) => Promise<{
156
+ success: boolean;
157
+ message: string;
158
+ }>;
159
+
155
160
  declare const generateBytes32Nonce: () => `0x${string}`;
156
161
 
157
162
  /**
@@ -502,4 +507,4 @@ declare function useSubmitContractAction(): (idToken: string, pid: string, sourc
502
507
  */
503
508
  declare function humanRevert(raw: `0x${string}` | undefined, shortMessage?: string): string;
504
509
 
505
- export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, humanRevert, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
510
+ export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, humanRevert, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useMintOrgAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ declare function useVerifyAccount(): (pid: string, campaignId: string, dbAuthTok
8
8
 
9
9
  declare function useVerifyWeb3AuthSession(): (idToken: string, publicKey: string, authServiceBaseUrl: string) => Promise<any>;
10
10
 
11
- declare function useCreateWeb3Account(): (idToken: string, publicKey: string, userPid: string, authServiceBaseUrl: string, baseWalletAddress: string, requestedContext: string) => Promise<any>;
11
+ declare function useCreateWeb3Account(): (authToken: string, userPid: string, authServiceBaseUrl: string, baseWalletAddress: string, requestedContext: string) => Promise<any>;
12
12
 
13
13
  declare function useFetchUserData(): (dbAuthToken: string, endpoint: string, pid: string) => Promise<any>;
14
14
 
@@ -152,6 +152,11 @@ declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: strin
152
152
 
153
153
  declare function useUpdateOrgWalletAddress(): (dbAuthToken: string, docID: string, baseWalletAddress: string, endpoint: string) => Promise<void>;
154
154
 
155
+ declare function useMintOrgAnymalNFT(): (orgContractAddress: string, pid: string, nftId: string, anymalTxId: string, dbAuthToken: string, validationContractAddress: string, managerSmartAccount: any, bundlerClient: any) => Promise<{
156
+ success: boolean;
157
+ message: string;
158
+ }>;
159
+
155
160
  declare const generateBytes32Nonce: () => `0x${string}`;
156
161
 
157
162
  /**
@@ -502,4 +507,4 @@ declare function useSubmitContractAction(): (idToken: string, pid: string, sourc
502
507
  */
503
508
  declare function humanRevert(raw: `0x${string}` | undefined, shortMessage?: string): string;
504
509
 
505
- export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, humanRevert, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
510
+ export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, humanRevert, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useMintOrgAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
package/dist/index.js CHANGED
@@ -67,6 +67,7 @@ __export(index_exports, {
67
67
  useFetchNotifications: () => useFetchNotifications,
68
68
  useFetchUserData: () => useFetchUserData,
69
69
  useMintAnymalNFT: () => useMintAnymalNFT,
70
+ useMintOrgAnymalNFT: () => useMintOrgAnymalNFT,
70
71
  useProcessOrgPartialKibblePayment: () => useProcessOrgPartialKibblePayment,
71
72
  useProcessPartialKibblePayment: () => useProcessPartialKibblePayment,
72
73
  useSaveAnymalMetadata: () => useSaveAnymalMetadata,
@@ -135,16 +136,15 @@ function useVerifyWeb3AuthSession() {
135
136
  var import_react3 = require("react");
136
137
  function useCreateWeb3Account() {
137
138
  return (0, import_react3.useCallback)(
138
- async (idToken, publicKey, userPid, authServiceBaseUrl, baseWalletAddress, requestedContext) => {
139
+ async (authToken, userPid, authServiceBaseUrl, baseWalletAddress, requestedContext) => {
139
140
  try {
140
141
  const response = await fetch(`${authServiceBaseUrl}/create-account`, {
141
142
  method: "POST",
142
143
  headers: {
143
144
  "Content-Type": "application/json",
144
- Authorization: "Bearer " + idToken
145
+ Authorization: "Bearer " + authToken
145
146
  },
146
147
  body: JSON.stringify({
147
- appPubKey: publicKey,
148
148
  pid: userPid,
149
149
  baseWalletAddress,
150
150
  requestedContext
@@ -2391,12 +2391,64 @@ function useUpdateOrgWalletAddress() {
2391
2391
  );
2392
2392
  }
2393
2393
 
2394
+ // src/utils/organization/useMintOrgAnymalNFT.ts
2395
+ var import_viem10 = require("viem");
2396
+ var import_react23 = require("react");
2397
+ function useMintOrgAnymalNFT() {
2398
+ return (0, import_react23.useCallback)(
2399
+ async (orgContractAddress, pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, managerSmartAccount, bundlerClient) => {
2400
+ if (!dbAuthToken || !nftId || !bundlerClient || !managerSmartAccount || !pid || !validationContractAddress || !orgContractAddress) {
2401
+ return {
2402
+ success: false,
2403
+ message: "Missing authentication token OR NFT ID."
2404
+ };
2405
+ }
2406
+ const functionName = "submitMetadataByCampaignName";
2407
+ const args = [
2408
+ pid,
2409
+ nftId,
2410
+ `https://dev-nft.petastic.com/metadata/${nftId}`,
2411
+ "petastic-signup-campaign-1",
2412
+ anymalTxId
2413
+ ];
2414
+ const callData = (0, import_viem10.encodeFunctionData)({
2415
+ abi: PET_NFT_ABI,
2416
+ functionName,
2417
+ args
2418
+ });
2419
+ const executeArgs = [validationContractAddress, callData];
2420
+ const executeSubmitMetaCalldata = (0, import_viem10.encodeFunctionData)({
2421
+ abi: ORGANIZATION_IMPL_ABI,
2422
+ functionName: ORG_FUNCTION,
2423
+ args: executeArgs
2424
+ });
2425
+ await simulateCall(
2426
+ bundlerClient.client,
2427
+ orgContractAddress,
2428
+ ORGANIZATION_IMPL_ABI,
2429
+ ORG_FUNCTION,
2430
+ executeArgs,
2431
+ managerSmartAccount.address
2432
+ );
2433
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2434
+ const userOpHash = await sendUserOpWithRetries(bundlerClient, {
2435
+ account: managerSmartAccount,
2436
+ calls: [{ to: orgContractAddress, data: executeSubmitMetaCalldata }],
2437
+ paymaster: true
2438
+ });
2439
+ await waitForReceiptWithRetries(bundlerClient, userOpHash);
2440
+ return { success: true, message: "Pet Passport Created!" };
2441
+ },
2442
+ []
2443
+ );
2444
+ }
2445
+
2394
2446
  // src/helpers/NonceHelper.tsx
2395
2447
  var import_uuid = require("uuid");
2396
- var import_viem10 = require("viem");
2448
+ var import_viem11 = require("viem");
2397
2449
  var generateBytes32Nonce = () => {
2398
2450
  const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
2399
- return (0, import_viem10.padHex)(`0x${uuid3}`, { size: 32 });
2451
+ return (0, import_viem11.padHex)(`0x${uuid3}`, { size: 32 });
2400
2452
  };
2401
2453
 
2402
2454
  // src/helpers/CryptoUtils.tsx
@@ -2606,9 +2658,9 @@ async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl)
2606
2658
  }
2607
2659
 
2608
2660
  // src/utils/actions/useFetchActions.ts
2609
- var import_react23 = require("react");
2661
+ var import_react24 = require("react");
2610
2662
  function useFetchActions() {
2611
- return (0, import_react23.useCallback)(
2663
+ return (0, import_react24.useCallback)(
2612
2664
  async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
2613
2665
  const params = new URLSearchParams({ pid });
2614
2666
  if (status) params.set("status", status);
@@ -2637,9 +2689,9 @@ function useFetchActions() {
2637
2689
  }
2638
2690
 
2639
2691
  // src/utils/actions/useFetchActionDefinitions.ts
2640
- var import_react24 = require("react");
2692
+ var import_react25 = require("react");
2641
2693
  function useFetchActionDefinitions() {
2642
- return (0, import_react24.useCallback)(
2694
+ return (0, import_react25.useCallback)(
2643
2695
  async (idToken, actionsServiceBaseUrl) => {
2644
2696
  try {
2645
2697
  const response = await fetch(
@@ -2736,10 +2788,10 @@ var convertToMultipleActionRecords = (frs) => frs.map(convertToActionRecord);
2736
2788
  var convertToMultipleActionDefinitions = (frs) => frs.map(convertToActionDefinition);
2737
2789
 
2738
2790
  // src/utils/application/useCreateUserAppData.ts
2739
- var import_react25 = require("react");
2791
+ var import_react26 = require("react");
2740
2792
  var import_uuid2 = require("uuid");
2741
2793
  function useCreateUserAppData() {
2742
- return (0, import_react25.useCallback)(
2794
+ return (0, import_react26.useCallback)(
2743
2795
  async (appId, pid, dbAuthToken, endpoint) => {
2744
2796
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2745
2797
  const appValues = {
@@ -2794,10 +2846,10 @@ function useCreateUserAppData() {
2794
2846
  }
2795
2847
 
2796
2848
  // src/utils/application/useCreateOrganizationAppData.ts
2797
- var import_react26 = require("react");
2849
+ var import_react27 = require("react");
2798
2850
  var import_uuid3 = require("uuid");
2799
2851
  function useCreateOrganizationAppData() {
2800
- return (0, import_react26.useCallback)(
2852
+ return (0, import_react27.useCallback)(
2801
2853
  async (appId, pid, dbAuthToken, endpoint) => {
2802
2854
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2803
2855
  const appValues = {
@@ -2851,17 +2903,17 @@ function useCreateOrganizationAppData() {
2851
2903
  }
2852
2904
 
2853
2905
  // src/utils/balance/useFetchBalance.ts
2854
- var import_react27 = require("react");
2855
- var import_viem11 = require("viem");
2906
+ var import_react28 = require("react");
2907
+ var import_viem12 = require("viem");
2856
2908
  function useFetchBalance() {
2857
- return (0, import_react27.useCallback)(
2909
+ return (0, import_react28.useCallback)(
2858
2910
  async (publicClient, walletAddress, kibbleTokenAddress) => {
2859
2911
  try {
2860
2912
  const balance = await publicClient.readContract({
2861
- address: (0, import_viem11.getAddress)(kibbleTokenAddress),
2862
- abi: import_viem11.erc20Abi,
2913
+ address: (0, import_viem12.getAddress)(kibbleTokenAddress),
2914
+ abi: import_viem12.erc20Abi,
2863
2915
  functionName: "balanceOf",
2864
- args: [(0, import_viem11.getAddress)(walletAddress)]
2916
+ args: [(0, import_viem12.getAddress)(walletAddress)]
2865
2917
  });
2866
2918
  return Number(balance);
2867
2919
  } catch (error) {
@@ -2873,10 +2925,10 @@ function useFetchBalance() {
2873
2925
  }
2874
2926
 
2875
2927
  // src/utils/actions/useClaimActionReward.ts
2876
- var import_viem12 = require("viem");
2877
- var import_react28 = require("react");
2928
+ var import_viem13 = require("viem");
2929
+ var import_react29 = require("react");
2878
2930
  function useClaimActionReward() {
2879
- return (0, import_react28.useCallback)(
2931
+ return (0, import_react29.useCallback)(
2880
2932
  async (actionId, claimIndex, rewardableActionContractAddress, smartAccount, bundlerClient) => {
2881
2933
  if (!actionId || claimIndex === void 0 || !bundlerClient || !smartAccount || !rewardableActionContractAddress) {
2882
2934
  return {
@@ -2886,7 +2938,7 @@ function useClaimActionReward() {
2886
2938
  }
2887
2939
  const args = [actionId, claimIndex];
2888
2940
  const functionName = "claimByIndex";
2889
- const callData = (0, import_viem12.encodeFunctionData)({
2941
+ const callData = (0, import_viem13.encodeFunctionData)({
2890
2942
  abi: REWARDABLE_ACTIONS_ABI,
2891
2943
  functionName,
2892
2944
  args
@@ -2922,10 +2974,10 @@ function useClaimActionReward() {
2922
2974
  }
2923
2975
 
2924
2976
  // src/utils/actions/useClaimOrgActionReward.ts
2925
- var import_viem13 = require("viem");
2926
- var import_react29 = require("react");
2977
+ var import_viem14 = require("viem");
2978
+ var import_react30 = require("react");
2927
2979
  function useClaimOrgActionReward() {
2928
- return (0, import_react29.useCallback)(
2980
+ return (0, import_react30.useCallback)(
2929
2981
  async (orgContractAddress, rewardableActionContractAddress, actionId, claimIndex, smartAccount, bundlerClient) => {
2930
2982
  if (!orgContractAddress || !actionId || claimIndex === void 0 || !bundlerClient || !smartAccount) {
2931
2983
  return {
@@ -2933,13 +2985,13 @@ function useClaimOrgActionReward() {
2933
2985
  message: "Missing web3auth account info or contract address."
2934
2986
  };
2935
2987
  }
2936
- const claimCallData = (0, import_viem13.encodeFunctionData)({
2988
+ const claimCallData = (0, import_viem14.encodeFunctionData)({
2937
2989
  abi: REWARDABLE_ACTIONS_ABI,
2938
2990
  functionName: "claimByIndex",
2939
2991
  args: [actionId, claimIndex]
2940
2992
  });
2941
2993
  const args = [rewardableActionContractAddress, claimCallData];
2942
- const executeClaimCalldata = (0, import_viem13.encodeFunctionData)({
2994
+ const executeClaimCalldata = (0, import_viem14.encodeFunctionData)({
2943
2995
  abi: ORGANIZATION_IMPL_ABI,
2944
2996
  functionName: ORG_FUNCTION,
2945
2997
  args
@@ -2975,9 +3027,9 @@ function useClaimOrgActionReward() {
2975
3027
  }
2976
3028
 
2977
3029
  // src/utils/actions/useSubmitContractAction.ts
2978
- var import_react30 = require("react");
3030
+ var import_react31 = require("react");
2979
3031
  function useSubmitContractAction() {
2980
- return (0, import_react30.useCallback)(
3032
+ return (0, import_react31.useCallback)(
2981
3033
  (idToken, pid, source, endpoint, payload) => {
2982
3034
  if (!idToken || !pid || !source || !endpoint || !payload) return;
2983
3035
  let sourceTypePayload = {};
@@ -3141,6 +3193,7 @@ function isMarketplacePurchaseAction(payload) {
3141
3193
  useFetchNotifications,
3142
3194
  useFetchUserData,
3143
3195
  useMintAnymalNFT,
3196
+ useMintOrgAnymalNFT,
3144
3197
  useProcessOrgPartialKibblePayment,
3145
3198
  useProcessPartialKibblePayment,
3146
3199
  useSaveAnymalMetadata,
package/dist/index.mjs CHANGED
@@ -64,16 +64,15 @@ function useVerifyWeb3AuthSession() {
64
64
  import { useCallback as useCallback3 } from "react";
65
65
  function useCreateWeb3Account() {
66
66
  return useCallback3(
67
- async (idToken, publicKey, userPid, authServiceBaseUrl, baseWalletAddress, requestedContext) => {
67
+ async (authToken, userPid, authServiceBaseUrl, baseWalletAddress, requestedContext) => {
68
68
  try {
69
69
  const response = await fetch(`${authServiceBaseUrl}/create-account`, {
70
70
  method: "POST",
71
71
  headers: {
72
72
  "Content-Type": "application/json",
73
- Authorization: "Bearer " + idToken
73
+ Authorization: "Bearer " + authToken
74
74
  },
75
75
  body: JSON.stringify({
76
- appPubKey: publicKey,
77
76
  pid: userPid,
78
77
  baseWalletAddress,
79
78
  requestedContext
@@ -2320,6 +2319,58 @@ function useUpdateOrgWalletAddress() {
2320
2319
  );
2321
2320
  }
2322
2321
 
2322
+ // src/utils/organization/useMintOrgAnymalNFT.ts
2323
+ import { encodeFunctionData as encodeFunctionData7 } from "viem";
2324
+ import { useCallback as useCallback23 } from "react";
2325
+ function useMintOrgAnymalNFT() {
2326
+ return useCallback23(
2327
+ async (orgContractAddress, pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, managerSmartAccount, bundlerClient) => {
2328
+ if (!dbAuthToken || !nftId || !bundlerClient || !managerSmartAccount || !pid || !validationContractAddress || !orgContractAddress) {
2329
+ return {
2330
+ success: false,
2331
+ message: "Missing authentication token OR NFT ID."
2332
+ };
2333
+ }
2334
+ const functionName = "submitMetadataByCampaignName";
2335
+ const args = [
2336
+ pid,
2337
+ nftId,
2338
+ `https://dev-nft.petastic.com/metadata/${nftId}`,
2339
+ "petastic-signup-campaign-1",
2340
+ anymalTxId
2341
+ ];
2342
+ const callData = encodeFunctionData7({
2343
+ abi: PET_NFT_ABI,
2344
+ functionName,
2345
+ args
2346
+ });
2347
+ const executeArgs = [validationContractAddress, callData];
2348
+ const executeSubmitMetaCalldata = encodeFunctionData7({
2349
+ abi: ORGANIZATION_IMPL_ABI,
2350
+ functionName: ORG_FUNCTION,
2351
+ args: executeArgs
2352
+ });
2353
+ await simulateCall(
2354
+ bundlerClient.client,
2355
+ orgContractAddress,
2356
+ ORGANIZATION_IMPL_ABI,
2357
+ ORG_FUNCTION,
2358
+ executeArgs,
2359
+ managerSmartAccount.address
2360
+ );
2361
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2362
+ const userOpHash = await sendUserOpWithRetries(bundlerClient, {
2363
+ account: managerSmartAccount,
2364
+ calls: [{ to: orgContractAddress, data: executeSubmitMetaCalldata }],
2365
+ paymaster: true
2366
+ });
2367
+ await waitForReceiptWithRetries(bundlerClient, userOpHash);
2368
+ return { success: true, message: "Pet Passport Created!" };
2369
+ },
2370
+ []
2371
+ );
2372
+ }
2373
+
2323
2374
  // src/helpers/NonceHelper.tsx
2324
2375
  import { v4 as uuidv4 } from "uuid";
2325
2376
  import { padHex } from "viem";
@@ -2352,9 +2403,9 @@ async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl)
2352
2403
  }
2353
2404
 
2354
2405
  // src/utils/actions/useFetchActions.ts
2355
- import { useCallback as useCallback23 } from "react";
2406
+ import { useCallback as useCallback24 } from "react";
2356
2407
  function useFetchActions() {
2357
- return useCallback23(
2408
+ return useCallback24(
2358
2409
  async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
2359
2410
  const params = new URLSearchParams({ pid });
2360
2411
  if (status) params.set("status", status);
@@ -2383,9 +2434,9 @@ function useFetchActions() {
2383
2434
  }
2384
2435
 
2385
2436
  // src/utils/actions/useFetchActionDefinitions.ts
2386
- import { useCallback as useCallback24 } from "react";
2437
+ import { useCallback as useCallback25 } from "react";
2387
2438
  function useFetchActionDefinitions() {
2388
- return useCallback24(
2439
+ return useCallback25(
2389
2440
  async (idToken, actionsServiceBaseUrl) => {
2390
2441
  try {
2391
2442
  const response = await fetch(
@@ -2482,10 +2533,10 @@ var convertToMultipleActionRecords = (frs) => frs.map(convertToActionRecord);
2482
2533
  var convertToMultipleActionDefinitions = (frs) => frs.map(convertToActionDefinition);
2483
2534
 
2484
2535
  // src/utils/application/useCreateUserAppData.ts
2485
- import { useCallback as useCallback25 } from "react";
2536
+ import { useCallback as useCallback26 } from "react";
2486
2537
  import { v4 as uuid } from "uuid";
2487
2538
  function useCreateUserAppData() {
2488
- return useCallback25(
2539
+ return useCallback26(
2489
2540
  async (appId, pid, dbAuthToken, endpoint) => {
2490
2541
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2491
2542
  const appValues = {
@@ -2540,10 +2591,10 @@ function useCreateUserAppData() {
2540
2591
  }
2541
2592
 
2542
2593
  // src/utils/application/useCreateOrganizationAppData.ts
2543
- import { useCallback as useCallback26 } from "react";
2594
+ import { useCallback as useCallback27 } from "react";
2544
2595
  import { v4 as uuid2 } from "uuid";
2545
2596
  function useCreateOrganizationAppData() {
2546
- return useCallback26(
2597
+ return useCallback27(
2547
2598
  async (appId, pid, dbAuthToken, endpoint) => {
2548
2599
  if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
2549
2600
  const appValues = {
@@ -2597,10 +2648,10 @@ function useCreateOrganizationAppData() {
2597
2648
  }
2598
2649
 
2599
2650
  // src/utils/balance/useFetchBalance.ts
2600
- import { useCallback as useCallback27 } from "react";
2651
+ import { useCallback as useCallback28 } from "react";
2601
2652
  import { erc20Abi as erc20Abi4, getAddress } from "viem";
2602
2653
  function useFetchBalance() {
2603
- return useCallback27(
2654
+ return useCallback28(
2604
2655
  async (publicClient, walletAddress, kibbleTokenAddress) => {
2605
2656
  try {
2606
2657
  const balance = await publicClient.readContract({
@@ -2619,10 +2670,10 @@ function useFetchBalance() {
2619
2670
  }
2620
2671
 
2621
2672
  // src/utils/actions/useClaimActionReward.ts
2622
- import { encodeFunctionData as encodeFunctionData7 } from "viem";
2623
- import { useCallback as useCallback28 } from "react";
2673
+ import { encodeFunctionData as encodeFunctionData8 } from "viem";
2674
+ import { useCallback as useCallback29 } from "react";
2624
2675
  function useClaimActionReward() {
2625
- return useCallback28(
2676
+ return useCallback29(
2626
2677
  async (actionId, claimIndex, rewardableActionContractAddress, smartAccount, bundlerClient) => {
2627
2678
  if (!actionId || claimIndex === void 0 || !bundlerClient || !smartAccount || !rewardableActionContractAddress) {
2628
2679
  return {
@@ -2632,7 +2683,7 @@ function useClaimActionReward() {
2632
2683
  }
2633
2684
  const args = [actionId, claimIndex];
2634
2685
  const functionName = "claimByIndex";
2635
- const callData = encodeFunctionData7({
2686
+ const callData = encodeFunctionData8({
2636
2687
  abi: REWARDABLE_ACTIONS_ABI,
2637
2688
  functionName,
2638
2689
  args
@@ -2668,10 +2719,10 @@ function useClaimActionReward() {
2668
2719
  }
2669
2720
 
2670
2721
  // src/utils/actions/useClaimOrgActionReward.ts
2671
- import { encodeFunctionData as encodeFunctionData8 } from "viem";
2672
- import { useCallback as useCallback29 } from "react";
2722
+ import { encodeFunctionData as encodeFunctionData9 } from "viem";
2723
+ import { useCallback as useCallback30 } from "react";
2673
2724
  function useClaimOrgActionReward() {
2674
- return useCallback29(
2725
+ return useCallback30(
2675
2726
  async (orgContractAddress, rewardableActionContractAddress, actionId, claimIndex, smartAccount, bundlerClient) => {
2676
2727
  if (!orgContractAddress || !actionId || claimIndex === void 0 || !bundlerClient || !smartAccount) {
2677
2728
  return {
@@ -2679,13 +2730,13 @@ function useClaimOrgActionReward() {
2679
2730
  message: "Missing web3auth account info or contract address."
2680
2731
  };
2681
2732
  }
2682
- const claimCallData = encodeFunctionData8({
2733
+ const claimCallData = encodeFunctionData9({
2683
2734
  abi: REWARDABLE_ACTIONS_ABI,
2684
2735
  functionName: "claimByIndex",
2685
2736
  args: [actionId, claimIndex]
2686
2737
  });
2687
2738
  const args = [rewardableActionContractAddress, claimCallData];
2688
- const executeClaimCalldata = encodeFunctionData8({
2739
+ const executeClaimCalldata = encodeFunctionData9({
2689
2740
  abi: ORGANIZATION_IMPL_ABI,
2690
2741
  functionName: ORG_FUNCTION,
2691
2742
  args
@@ -2721,9 +2772,9 @@ function useClaimOrgActionReward() {
2721
2772
  }
2722
2773
 
2723
2774
  // src/utils/actions/useSubmitContractAction.ts
2724
- import { useCallback as useCallback30 } from "react";
2775
+ import { useCallback as useCallback31 } from "react";
2725
2776
  function useSubmitContractAction() {
2726
- return useCallback30(
2777
+ return useCallback31(
2727
2778
  (idToken, pid, source, endpoint, payload) => {
2728
2779
  if (!idToken || !pid || !source || !endpoint || !payload) return;
2729
2780
  let sourceTypePayload = {};
@@ -2886,6 +2937,7 @@ export {
2886
2937
  useFetchNotifications,
2887
2938
  useFetchUserData,
2888
2939
  useMintAnymalNFT,
2940
+ useMintOrgAnymalNFT,
2889
2941
  useProcessOrgPartialKibblePayment,
2890
2942
  useProcessPartialKibblePayment,
2891
2943
  useSaveAnymalMetadata,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.121",
3
+ "version": "1.0.123",
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": {