anymal-protocol 1.0.124 → 1.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15 -24
- package/dist/index.d.ts +15 -24
- package/dist/index.js +149 -309
- package/dist/index.mjs +132 -289
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -414,6 +414,9 @@ function useSendCoinbaseUserOperation() {
|
|
|
414
414
|
return { sendOperationFn, data, status, error };
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
// src/utils/coinbase/useCoinbaseClaimActionReward.ts
|
|
418
|
+
import { encodeFunctionData } from "viem";
|
|
419
|
+
|
|
417
420
|
// src/helpers/BlockchainAbiHelper.tsx
|
|
418
421
|
import { parseAbi } from "viem";
|
|
419
422
|
var PET_NFT_ABI = [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {
|
|
@@ -2845,9 +2848,70 @@ var OZ_ERROR_FRAGMENTS = [
|
|
|
2845
2848
|
var ERROR_ABI = [...LOCAL_ERRORS, parseAbi([...OZ_ERROR_FRAGMENTS])];
|
|
2846
2849
|
var ORG_FUNCTION = "executeCall";
|
|
2847
2850
|
|
|
2848
|
-
// src/utils/
|
|
2849
|
-
import { encodeFunctionData } from "viem";
|
|
2851
|
+
// src/utils/coinbase/useCoinbaseClaimActionReward.ts
|
|
2850
2852
|
import { useCallback as useCallback11 } from "react";
|
|
2853
|
+
function useCoinbaseClaimActionReward() {
|
|
2854
|
+
const { sendOperationFn, status } = useSendCoinbaseUserOperation();
|
|
2855
|
+
return useCallback11(
|
|
2856
|
+
async (evmAddress, actionId, claimIndex, validationContractAddress) => {
|
|
2857
|
+
if (!evmAddress || !actionId || claimIndex === void 0 || !validationContractAddress) {
|
|
2858
|
+
return {
|
|
2859
|
+
success: false,
|
|
2860
|
+
message: "Missing information",
|
|
2861
|
+
status: "error"
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
const args = [actionId, claimIndex];
|
|
2865
|
+
const functionName = "claimByIndex";
|
|
2866
|
+
const callData = encodeFunctionData({
|
|
2867
|
+
abi: REWARDABLE_ACTIONS_ABI,
|
|
2868
|
+
functionName,
|
|
2869
|
+
args
|
|
2870
|
+
});
|
|
2871
|
+
await sendOperationFn(evmAddress, callData, validationContractAddress);
|
|
2872
|
+
return { success: true, message: "Reward claimed", status };
|
|
2873
|
+
},
|
|
2874
|
+
[]
|
|
2875
|
+
);
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
// src/utils/coinbase/useCoinbaseMintAnymalNFT.ts
|
|
2879
|
+
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
2880
|
+
import { useCallback as useCallback12 } from "react";
|
|
2881
|
+
function useCoinbaseMintAnymalNFT() {
|
|
2882
|
+
const { sendOperationFn, status } = useSendCoinbaseUserOperation();
|
|
2883
|
+
return useCallback12(
|
|
2884
|
+
async (evmAddress, pid, nftId, anymalTxId, validationContractAddress) => {
|
|
2885
|
+
if (!nftId || !pid || !validationContractAddress) {
|
|
2886
|
+
return {
|
|
2887
|
+
success: false,
|
|
2888
|
+
message: "Coinbase Mint NFT: Missing authentication token OR NFT ID.",
|
|
2889
|
+
status: "error"
|
|
2890
|
+
};
|
|
2891
|
+
}
|
|
2892
|
+
const functionName = "submitMetadataByCampaignName";
|
|
2893
|
+
const args = [
|
|
2894
|
+
pid,
|
|
2895
|
+
nftId,
|
|
2896
|
+
`https://dev-nft.petastic.com/metadata/${nftId}`,
|
|
2897
|
+
"petastic-signup-campaign-1",
|
|
2898
|
+
anymalTxId
|
|
2899
|
+
];
|
|
2900
|
+
const callData = encodeFunctionData2({
|
|
2901
|
+
abi: PET_NFT_ABI,
|
|
2902
|
+
functionName,
|
|
2903
|
+
args
|
|
2904
|
+
});
|
|
2905
|
+
await sendOperationFn(evmAddress, callData, validationContractAddress);
|
|
2906
|
+
return { success: true, message: "Pet Passport Created", status };
|
|
2907
|
+
},
|
|
2908
|
+
[]
|
|
2909
|
+
);
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
// src/utils/anymals/useMintAnymalNFT.ts
|
|
2913
|
+
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
2914
|
+
import { useCallback as useCallback13 } from "react";
|
|
2851
2915
|
|
|
2852
2916
|
// src/helpers/GasEstimateHelper.tsx
|
|
2853
2917
|
async function applyBundlerGasEstimator(account, bundlerClient, options) {
|
|
@@ -2928,12 +2992,12 @@ async function simulateCall(publicClient, target, abi, functionName, args, calle
|
|
|
2928
2992
|
|
|
2929
2993
|
// src/utils/anymals/useMintAnymalNFT.ts
|
|
2930
2994
|
function useMintAnymalNFT() {
|
|
2931
|
-
return
|
|
2995
|
+
return useCallback13(
|
|
2932
2996
|
async (pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
|
|
2933
2997
|
if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
|
|
2934
2998
|
return {
|
|
2935
2999
|
success: false,
|
|
2936
|
-
message: "Missing authentication token OR NFT ID."
|
|
3000
|
+
message: "Mint NFT: Missing authentication token OR NFT ID."
|
|
2937
3001
|
};
|
|
2938
3002
|
}
|
|
2939
3003
|
const functionName = "submitMetadataByCampaignName";
|
|
@@ -2944,7 +3008,7 @@ function useMintAnymalNFT() {
|
|
|
2944
3008
|
"petastic-signup-campaign-1",
|
|
2945
3009
|
anymalTxId
|
|
2946
3010
|
];
|
|
2947
|
-
const callData =
|
|
3011
|
+
const callData = encodeFunctionData3({
|
|
2948
3012
|
abi: PET_NFT_ABI,
|
|
2949
3013
|
functionName,
|
|
2950
3014
|
args
|
|
@@ -2979,126 +3043,11 @@ function useMintAnymalNFT() {
|
|
|
2979
3043
|
);
|
|
2980
3044
|
}
|
|
2981
3045
|
|
|
2982
|
-
// src/utils/anymals/useAddAnymalToDatabase.ts
|
|
2983
|
-
import { useCallback as useCallback12 } from "react";
|
|
2984
|
-
function useAddAnymalToDatabase() {
|
|
2985
|
-
return useCallback12(
|
|
2986
|
-
async (dbAuthToken, endpoint, anymalData) => {
|
|
2987
|
-
if (!dbAuthToken) {
|
|
2988
|
-
return {
|
|
2989
|
-
success: false,
|
|
2990
|
-
message: "Authentication token is missing.",
|
|
2991
|
-
_docID: null,
|
|
2992
|
-
dbCid: null
|
|
2993
|
-
};
|
|
2994
|
-
}
|
|
2995
|
-
let anymalDocID = null;
|
|
2996
|
-
let dbCid = null;
|
|
2997
|
-
try {
|
|
2998
|
-
const mutation = `
|
|
2999
|
-
mutation Create_Anymal($input: [AnymalMutationInputArg!]) {
|
|
3000
|
-
create_Anymal(input: $input) {
|
|
3001
|
-
_docID
|
|
3002
|
-
name
|
|
3003
|
-
passportID
|
|
3004
|
-
_version {
|
|
3005
|
-
cid
|
|
3006
|
-
}
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
`;
|
|
3010
|
-
const response = await fetch(endpoint, {
|
|
3011
|
-
method: "POST",
|
|
3012
|
-
headers: {
|
|
3013
|
-
"Content-Type": "application/json",
|
|
3014
|
-
Authorization: `Bearer ${dbAuthToken}`
|
|
3015
|
-
},
|
|
3016
|
-
body: JSON.stringify({
|
|
3017
|
-
query: mutation,
|
|
3018
|
-
variables: { input: [anymalData] }
|
|
3019
|
-
})
|
|
3020
|
-
});
|
|
3021
|
-
if (!response.ok) {
|
|
3022
|
-
throw new Error(
|
|
3023
|
-
`Failed to create pet. HTTP status ${response.status}`
|
|
3024
|
-
);
|
|
3025
|
-
}
|
|
3026
|
-
const { data, errors } = await response.json();
|
|
3027
|
-
if (errors) {
|
|
3028
|
-
const errorMessage = JSON.stringify(errors);
|
|
3029
|
-
if (errorMessage.includes("given ID already exists")) {
|
|
3030
|
-
console.warn("Duplicate document ID detected.");
|
|
3031
|
-
anymalDocID = data?.create_Anymal[0]?._docID || null;
|
|
3032
|
-
throw new Error("Document with the given ID already exists.");
|
|
3033
|
-
}
|
|
3034
|
-
throw new Error(`GraphQL error: ${errorMessage}`);
|
|
3035
|
-
}
|
|
3036
|
-
anymalDocID = data.create_Anymal[0]._docID;
|
|
3037
|
-
dbCid = data.create_Anymal[0]._version[0].cid;
|
|
3038
|
-
return {
|
|
3039
|
-
success: true,
|
|
3040
|
-
_docID: anymalDocID,
|
|
3041
|
-
dbCid,
|
|
3042
|
-
message: "Anymal added to account"
|
|
3043
|
-
};
|
|
3044
|
-
} catch (error) {
|
|
3045
|
-
return {
|
|
3046
|
-
success: false,
|
|
3047
|
-
_docID: null,
|
|
3048
|
-
dbCid: null,
|
|
3049
|
-
message: "Error adding anymal to account"
|
|
3050
|
-
};
|
|
3051
|
-
}
|
|
3052
|
-
},
|
|
3053
|
-
[]
|
|
3054
|
-
);
|
|
3055
|
-
}
|
|
3056
|
-
|
|
3057
|
-
// src/utils/anymals/useDeleteAnymalFromDatabase.ts
|
|
3058
|
-
import { useCallback as useCallback13 } from "react";
|
|
3059
|
-
function useDeleteAnymalFromDatabase() {
|
|
3060
|
-
return useCallback13(
|
|
3061
|
-
async (dbAuthToken, endpoint, anymalDocID) => {
|
|
3062
|
-
if (!dbAuthToken || !endpoint || !anymalDocID) return;
|
|
3063
|
-
try {
|
|
3064
|
-
const mutation = `
|
|
3065
|
-
mutation Delete_Anymal($docId: [ID]) {
|
|
3066
|
-
delete_Anymal(docID: $docId) {
|
|
3067
|
-
_docID
|
|
3068
|
-
}
|
|
3069
|
-
}
|
|
3070
|
-
`;
|
|
3071
|
-
const response = await fetch(endpoint, {
|
|
3072
|
-
method: "POST",
|
|
3073
|
-
headers: {
|
|
3074
|
-
"Content-Type": "application/json",
|
|
3075
|
-
Authorization: `Bearer ${dbAuthToken}`
|
|
3076
|
-
},
|
|
3077
|
-
body: JSON.stringify({
|
|
3078
|
-
query: mutation,
|
|
3079
|
-
variables: { docID: [anymalDocID] }
|
|
3080
|
-
})
|
|
3081
|
-
});
|
|
3082
|
-
if (!response.ok)
|
|
3083
|
-
throw new Error(
|
|
3084
|
-
`Failed to delete anymal. HTTP status ${response.status}`
|
|
3085
|
-
);
|
|
3086
|
-
const { errors } = await response.json();
|
|
3087
|
-
if (errors) throw new Error(`GraphQL error: ${JSON.stringify(errors)}`);
|
|
3088
|
-
} catch (error) {
|
|
3089
|
-
console.error("Error deleting anymal from database:", error);
|
|
3090
|
-
throw error;
|
|
3091
|
-
}
|
|
3092
|
-
},
|
|
3093
|
-
[]
|
|
3094
|
-
);
|
|
3095
|
-
}
|
|
3096
|
-
|
|
3097
3046
|
// src/utils/anymals/useSaveAnymalMetadata.ts
|
|
3098
3047
|
import { useCallback as useCallback14 } from "react";
|
|
3099
3048
|
function useSaveAnymalMetadata() {
|
|
3100
3049
|
return useCallback14(
|
|
3101
|
-
async (userPid, anymalTxId, idToken,
|
|
3050
|
+
async (userPid, anymalTxId, idToken, nftMetadataInput, authServiceBaseUrl) => {
|
|
3102
3051
|
const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
|
|
3103
3052
|
method: "POST",
|
|
3104
3053
|
headers: {
|
|
@@ -3106,7 +3055,6 @@ function useSaveAnymalMetadata() {
|
|
|
3106
3055
|
Authorization: "Bearer " + idToken
|
|
3107
3056
|
},
|
|
3108
3057
|
body: JSON.stringify({
|
|
3109
|
-
appPubKey: publicKey,
|
|
3110
3058
|
nftMetadataInput,
|
|
3111
3059
|
pid: userPid,
|
|
3112
3060
|
anymalTxId
|
|
@@ -3125,57 +3073,8 @@ function useSaveAnymalMetadata() {
|
|
|
3125
3073
|
);
|
|
3126
3074
|
}
|
|
3127
3075
|
|
|
3128
|
-
// src/utils/anymals/useUpdateAnymalWithNFT.ts
|
|
3129
|
-
import { useCallback as useCallback15 } from "react";
|
|
3130
|
-
function useUpdateAnymalWithNFT() {
|
|
3131
|
-
return useCallback15(
|
|
3132
|
-
async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
|
|
3133
|
-
if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
|
|
3134
|
-
return {
|
|
3135
|
-
success: false
|
|
3136
|
-
};
|
|
3137
|
-
}
|
|
3138
|
-
try {
|
|
3139
|
-
const mutation = `
|
|
3140
|
-
mutation {
|
|
3141
|
-
update_Anymal(
|
|
3142
|
-
docID: [${JSON.stringify(anymalDocId)}],
|
|
3143
|
-
input: {
|
|
3144
|
-
passportID: "${anymalPassportId}"
|
|
3145
|
-
}
|
|
3146
|
-
) {
|
|
3147
|
-
passportID
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
`;
|
|
3151
|
-
const response = await fetch(endpoint, {
|
|
3152
|
-
method: "POST",
|
|
3153
|
-
headers: {
|
|
3154
|
-
"Content-Type": "application/json",
|
|
3155
|
-
Authorization: `Bearer ${dbAuthToken}`
|
|
3156
|
-
},
|
|
3157
|
-
body: JSON.stringify({ query: mutation })
|
|
3158
|
-
});
|
|
3159
|
-
if (!response.ok) {
|
|
3160
|
-
return { success: false };
|
|
3161
|
-
}
|
|
3162
|
-
const { errors } = await response.json();
|
|
3163
|
-
if (errors) {
|
|
3164
|
-
console.log(`GQL error: ${JSON.stringify(errors)}`);
|
|
3165
|
-
return { success: false };
|
|
3166
|
-
}
|
|
3167
|
-
return { success: true };
|
|
3168
|
-
} catch (error) {
|
|
3169
|
-
console.error("Error updating Anymal with NFT ID:", error);
|
|
3170
|
-
return { success: false };
|
|
3171
|
-
}
|
|
3172
|
-
},
|
|
3173
|
-
[]
|
|
3174
|
-
);
|
|
3175
|
-
}
|
|
3176
|
-
|
|
3177
3076
|
// src/utils/anymals/useUploadAnymalImage.ts
|
|
3178
|
-
import { useCallback as
|
|
3077
|
+
import { useCallback as useCallback15 } from "react";
|
|
3179
3078
|
|
|
3180
3079
|
// src/helpers/UploadImageHelper.tsx
|
|
3181
3080
|
function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
|
|
@@ -3232,8 +3131,8 @@ function toBase64(file) {
|
|
|
3232
3131
|
|
|
3233
3132
|
// src/utils/anymals/useUploadAnymalImage.ts
|
|
3234
3133
|
function useUploadAnymalImage() {
|
|
3235
|
-
return
|
|
3236
|
-
async (imageFile, type, idToken,
|
|
3134
|
+
return useCallback15(
|
|
3135
|
+
async (imageFile, type, idToken, authServiceBaseUrl, petType, breed, lifestage, anymalPid) => {
|
|
3237
3136
|
if (!imageFile || !idToken) {
|
|
3238
3137
|
return {
|
|
3239
3138
|
success: false,
|
|
@@ -3245,7 +3144,6 @@ function useUploadAnymalImage() {
|
|
|
3245
3144
|
try {
|
|
3246
3145
|
const base64Image = await prepareImage(imageFile);
|
|
3247
3146
|
const payload = {
|
|
3248
|
-
appPubKey: publicKey,
|
|
3249
3147
|
imageData: base64Image,
|
|
3250
3148
|
imageName: imageFile.name.split(".")[0],
|
|
3251
3149
|
petType,
|
|
@@ -3293,68 +3191,11 @@ function useUploadAnymalImage() {
|
|
|
3293
3191
|
);
|
|
3294
3192
|
}
|
|
3295
3193
|
|
|
3296
|
-
// src/utils/anymals/useFetchAnymals.ts
|
|
3297
|
-
import { useCallback as useCallback17 } from "react";
|
|
3298
|
-
|
|
3299
|
-
// src/utils/anymals/fetchAnymals.ts
|
|
3300
|
-
async function fetchAnymals({
|
|
3301
|
-
dbAuthToken,
|
|
3302
|
-
endpoint,
|
|
3303
|
-
userPid
|
|
3304
|
-
}) {
|
|
3305
|
-
const query = `
|
|
3306
|
-
query Anymal($filter: AnymalFilterArg, $order: [AnymalOrderArg]) {
|
|
3307
|
-
Anymal(filter: $filter, order: $order) {
|
|
3308
|
-
_docID
|
|
3309
|
-
name
|
|
3310
|
-
breed
|
|
3311
|
-
passportID
|
|
3312
|
-
profileImageUrl
|
|
3313
|
-
caregiverNearId
|
|
3314
|
-
caregiverId
|
|
3315
|
-
lifestage
|
|
3316
|
-
gender
|
|
3317
|
-
petType
|
|
3318
|
-
products
|
|
3319
|
-
timeAddedUtc
|
|
3320
|
-
}
|
|
3321
|
-
}
|
|
3322
|
-
`;
|
|
3323
|
-
const variables = {
|
|
3324
|
-
filter: {
|
|
3325
|
-
caregiverId: { _eq: userPid }
|
|
3326
|
-
},
|
|
3327
|
-
order: [
|
|
3328
|
-
{
|
|
3329
|
-
timeAddedUtc: "ASC"
|
|
3330
|
-
}
|
|
3331
|
-
]
|
|
3332
|
-
};
|
|
3333
|
-
const response = await fetch(endpoint, {
|
|
3334
|
-
method: "POST",
|
|
3335
|
-
headers: {
|
|
3336
|
-
"Content-Type": "application/json",
|
|
3337
|
-
Authorization: `Bearer ${dbAuthToken}`
|
|
3338
|
-
},
|
|
3339
|
-
body: JSON.stringify({ query, variables })
|
|
3340
|
-
});
|
|
3341
|
-
if (!response.ok) {
|
|
3342
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
3343
|
-
}
|
|
3344
|
-
const data = await response.json();
|
|
3345
|
-
return data?.data?.Anymal ?? [];
|
|
3346
|
-
}
|
|
3347
|
-
|
|
3348
|
-
// src/utils/anymals/useFetchAnymals.ts
|
|
3349
|
-
function useFetchAnymals() {
|
|
3350
|
-
return useCallback17(fetchAnymals, []);
|
|
3351
|
-
}
|
|
3352
|
-
|
|
3353
3194
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
3354
|
-
import { useCallback as
|
|
3195
|
+
import { useCallback as useCallback16 } from "react";
|
|
3355
3196
|
|
|
3356
3197
|
// src/helpers/ProcessDirectPartialPayment.tsx
|
|
3357
|
-
import { encodeFunctionData as
|
|
3198
|
+
import { encodeFunctionData as encodeFunctionData4 } from "viem";
|
|
3358
3199
|
|
|
3359
3200
|
// src/helpers/SendUserOpWithRetries.tsx
|
|
3360
3201
|
async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
|
|
@@ -3414,7 +3255,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
|
|
|
3414
3255
|
deadline,
|
|
3415
3256
|
backendSignature
|
|
3416
3257
|
];
|
|
3417
|
-
const partialPayCalldata =
|
|
3258
|
+
const partialPayCalldata = encodeFunctionData4({
|
|
3418
3259
|
abi: MARKETPLACE_ABI,
|
|
3419
3260
|
functionName,
|
|
3420
3261
|
args
|
|
@@ -3451,7 +3292,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
|
|
|
3451
3292
|
|
|
3452
3293
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
3453
3294
|
function useProcessPartialKibblePayment() {
|
|
3454
|
-
return
|
|
3295
|
+
return useCallback16(
|
|
3455
3296
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
3456
3297
|
if (!orderId || !dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !marketplaceContract || !amountInTokens || !maxTokenPayment || !nonce || !deadline) {
|
|
3457
3298
|
return {
|
|
@@ -3507,15 +3348,15 @@ function useProcessPartialKibblePayment() {
|
|
|
3507
3348
|
}
|
|
3508
3349
|
|
|
3509
3350
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
3510
|
-
import { useCallback as
|
|
3351
|
+
import { useCallback as useCallback17 } from "react";
|
|
3511
3352
|
|
|
3512
3353
|
// src/helpers/ProcessDirectKibbleApproval.tsx
|
|
3513
|
-
import { encodeFunctionData as
|
|
3354
|
+
import { encodeFunctionData as encodeFunctionData5, erc20Abi } from "viem";
|
|
3514
3355
|
async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
|
|
3515
3356
|
try {
|
|
3516
3357
|
const functionName = "approve";
|
|
3517
3358
|
const args = [spenderAddress, approveAmount];
|
|
3518
|
-
const approveCalldata =
|
|
3359
|
+
const approveCalldata = encodeFunctionData5({
|
|
3519
3360
|
abi: erc20Abi,
|
|
3520
3361
|
functionName,
|
|
3521
3362
|
args
|
|
@@ -3552,7 +3393,7 @@ async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, s
|
|
|
3552
3393
|
|
|
3553
3394
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
3554
3395
|
function useApproveKibbleToken() {
|
|
3555
|
-
return
|
|
3396
|
+
return useCallback17(
|
|
3556
3397
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
3557
3398
|
try {
|
|
3558
3399
|
const result = await processDirectKibbleApproval(
|
|
@@ -3579,10 +3420,10 @@ function useApproveKibbleToken() {
|
|
|
3579
3420
|
}
|
|
3580
3421
|
|
|
3581
3422
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
3582
|
-
import { useCallback as
|
|
3583
|
-
import { decodeEventLog, encodeFunctionData as
|
|
3423
|
+
import { useCallback as useCallback18 } from "react";
|
|
3424
|
+
import { decodeEventLog, encodeFunctionData as encodeFunctionData6 } from "viem";
|
|
3584
3425
|
function useCreateOrganizationBase() {
|
|
3585
|
-
return
|
|
3426
|
+
return useCallback18(
|
|
3586
3427
|
/**
|
|
3587
3428
|
* Creates a new organization on-chain.
|
|
3588
3429
|
*
|
|
@@ -3604,7 +3445,7 @@ function useCreateOrganizationBase() {
|
|
|
3604
3445
|
try {
|
|
3605
3446
|
const functionName = "createOrganizationProxy";
|
|
3606
3447
|
const args = [ownerAddress, orgName, orgPid];
|
|
3607
|
-
const callData =
|
|
3448
|
+
const callData = encodeFunctionData6({
|
|
3608
3449
|
abi: ORGANIZATION_BEACON_ABI,
|
|
3609
3450
|
functionName,
|
|
3610
3451
|
args
|
|
@@ -3678,10 +3519,10 @@ function useCreateOrganizationBase() {
|
|
|
3678
3519
|
}
|
|
3679
3520
|
|
|
3680
3521
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
3681
|
-
import { useCallback as
|
|
3522
|
+
import { useCallback as useCallback19 } from "react";
|
|
3682
3523
|
|
|
3683
3524
|
// src/helpers/ProcessOrgKibbleApproval.tsx
|
|
3684
|
-
import { encodeFunctionData as
|
|
3525
|
+
import { encodeFunctionData as encodeFunctionData7, erc20Abi as erc20Abi3 } from "viem";
|
|
3685
3526
|
|
|
3686
3527
|
// src/helpers/WaitForAllowance.tsx
|
|
3687
3528
|
import { erc20Abi as erc20Abi2 } from "viem";
|
|
@@ -3718,13 +3559,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
|
|
|
3718
3559
|
if (approveAmount <= 0n) {
|
|
3719
3560
|
return { success: false, message: "Approval amount must be greater than zero." };
|
|
3720
3561
|
}
|
|
3721
|
-
const approveCalldata =
|
|
3562
|
+
const approveCalldata = encodeFunctionData7({
|
|
3722
3563
|
abi: erc20Abi3,
|
|
3723
3564
|
functionName: "approve",
|
|
3724
3565
|
args: [partialPaymentModuleAddress, approveAmount]
|
|
3725
3566
|
});
|
|
3726
3567
|
const args = [kibbleTokenAddress, approveCalldata];
|
|
3727
|
-
const executeApproveCalldata =
|
|
3568
|
+
const executeApproveCalldata = encodeFunctionData7({
|
|
3728
3569
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3729
3570
|
functionName: ORG_FUNCTION,
|
|
3730
3571
|
args
|
|
@@ -3776,7 +3617,7 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
|
|
|
3776
3617
|
|
|
3777
3618
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
3778
3619
|
function useApproveOrgPartialPayment() {
|
|
3779
|
-
return
|
|
3620
|
+
return useCallback19(
|
|
3780
3621
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
3781
3622
|
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
3782
3623
|
return {
|
|
@@ -3808,13 +3649,13 @@ function useApproveOrgPartialPayment() {
|
|
|
3808
3649
|
}
|
|
3809
3650
|
|
|
3810
3651
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
3811
|
-
import { useCallback as
|
|
3652
|
+
import { useCallback as useCallback20 } from "react";
|
|
3812
3653
|
|
|
3813
3654
|
// src/helpers/ProcessOrgPartialPayment.tsx
|
|
3814
|
-
import { encodeFunctionData as
|
|
3655
|
+
import { encodeFunctionData as encodeFunctionData8 } from "viem";
|
|
3815
3656
|
async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
|
|
3816
3657
|
try {
|
|
3817
|
-
const partialPayCalldata =
|
|
3658
|
+
const partialPayCalldata = encodeFunctionData8({
|
|
3818
3659
|
abi: MARKETPLACE_ABI,
|
|
3819
3660
|
functionName: "partialPay",
|
|
3820
3661
|
args: [
|
|
@@ -3829,7 +3670,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
|
|
|
3829
3670
|
]
|
|
3830
3671
|
});
|
|
3831
3672
|
const args = [partialPaymentModuleAddress, partialPayCalldata];
|
|
3832
|
-
const executePartialPayCalldata =
|
|
3673
|
+
const executePartialPayCalldata = encodeFunctionData8({
|
|
3833
3674
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3834
3675
|
functionName: ORG_FUNCTION,
|
|
3835
3676
|
args
|
|
@@ -3866,7 +3707,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
|
|
|
3866
3707
|
|
|
3867
3708
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
3868
3709
|
function useProcessOrgPartialKibblePayment() {
|
|
3869
|
-
return
|
|
3710
|
+
return useCallback20(
|
|
3870
3711
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
3871
3712
|
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
3872
3713
|
return {
|
|
@@ -3904,9 +3745,9 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
3904
3745
|
}
|
|
3905
3746
|
|
|
3906
3747
|
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
3907
|
-
import { useCallback as
|
|
3748
|
+
import { useCallback as useCallback21 } from "react";
|
|
3908
3749
|
function useUpdateOrgWalletAddress() {
|
|
3909
|
-
return
|
|
3750
|
+
return useCallback21(
|
|
3910
3751
|
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
3911
3752
|
try {
|
|
3912
3753
|
const mutation = `
|
|
@@ -3945,15 +3786,15 @@ function useUpdateOrgWalletAddress() {
|
|
|
3945
3786
|
}
|
|
3946
3787
|
|
|
3947
3788
|
// src/utils/organization/useMintOrgAnymalNFT.ts
|
|
3948
|
-
import { encodeFunctionData as
|
|
3949
|
-
import { useCallback as
|
|
3789
|
+
import { encodeFunctionData as encodeFunctionData9 } from "viem";
|
|
3790
|
+
import { useCallback as useCallback22 } from "react";
|
|
3950
3791
|
function useMintOrgAnymalNFT() {
|
|
3951
|
-
return
|
|
3792
|
+
return useCallback22(
|
|
3952
3793
|
async (orgContractAddress, pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, managerSmartAccount, bundlerClient) => {
|
|
3953
3794
|
if (!dbAuthToken || !nftId || !bundlerClient || !managerSmartAccount || !pid || !validationContractAddress || !orgContractAddress) {
|
|
3954
3795
|
return {
|
|
3955
3796
|
success: false,
|
|
3956
|
-
message: "Missing authentication token OR NFT ID."
|
|
3797
|
+
message: "Mint Org NFT: Missing authentication token OR NFT ID."
|
|
3957
3798
|
};
|
|
3958
3799
|
}
|
|
3959
3800
|
const functionName = "submitMetadataByCampaignName";
|
|
@@ -3964,13 +3805,13 @@ function useMintOrgAnymalNFT() {
|
|
|
3964
3805
|
"petastic-signup-campaign-1",
|
|
3965
3806
|
anymalTxId
|
|
3966
3807
|
];
|
|
3967
|
-
const callData =
|
|
3808
|
+
const callData = encodeFunctionData9({
|
|
3968
3809
|
abi: PET_NFT_ABI,
|
|
3969
3810
|
functionName,
|
|
3970
3811
|
args
|
|
3971
3812
|
});
|
|
3972
3813
|
const executeArgs = [validationContractAddress, callData];
|
|
3973
|
-
const executeSubmitMetaCalldata =
|
|
3814
|
+
const executeSubmitMetaCalldata = encodeFunctionData9({
|
|
3974
3815
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3975
3816
|
functionName: ORG_FUNCTION,
|
|
3976
3817
|
args: executeArgs
|
|
@@ -3986,7 +3827,12 @@ function useMintOrgAnymalNFT() {
|
|
|
3986
3827
|
await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
|
|
3987
3828
|
const userOpHash = await sendUserOpWithRetries(bundlerClient, {
|
|
3988
3829
|
account: managerSmartAccount,
|
|
3989
|
-
calls: [
|
|
3830
|
+
calls: [
|
|
3831
|
+
{
|
|
3832
|
+
to: orgContractAddress,
|
|
3833
|
+
data: executeSubmitMetaCalldata
|
|
3834
|
+
}
|
|
3835
|
+
],
|
|
3990
3836
|
paymaster: true
|
|
3991
3837
|
});
|
|
3992
3838
|
await waitForReceiptWithRetries(bundlerClient, userOpHash);
|
|
@@ -4028,9 +3874,9 @@ async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl)
|
|
|
4028
3874
|
}
|
|
4029
3875
|
|
|
4030
3876
|
// src/utils/actions/useFetchActions.ts
|
|
4031
|
-
import { useCallback as
|
|
3877
|
+
import { useCallback as useCallback23 } from "react";
|
|
4032
3878
|
function useFetchActions() {
|
|
4033
|
-
return
|
|
3879
|
+
return useCallback23(
|
|
4034
3880
|
async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
|
|
4035
3881
|
const params = new URLSearchParams({ pid });
|
|
4036
3882
|
if (status) params.set("status", status);
|
|
@@ -4059,9 +3905,9 @@ function useFetchActions() {
|
|
|
4059
3905
|
}
|
|
4060
3906
|
|
|
4061
3907
|
// src/utils/actions/useFetchActionDefinitions.ts
|
|
4062
|
-
import { useCallback as
|
|
3908
|
+
import { useCallback as useCallback24 } from "react";
|
|
4063
3909
|
function useFetchActionDefinitions() {
|
|
4064
|
-
return
|
|
3910
|
+
return useCallback24(
|
|
4065
3911
|
async (idToken, actionsServiceBaseUrl) => {
|
|
4066
3912
|
try {
|
|
4067
3913
|
const response = await fetch(
|
|
@@ -4158,10 +4004,10 @@ var convertToMultipleActionRecords = (frs) => frs.map(convertToActionRecord);
|
|
|
4158
4004
|
var convertToMultipleActionDefinitions = (frs) => frs.map(convertToActionDefinition);
|
|
4159
4005
|
|
|
4160
4006
|
// src/utils/application/useCreateUserAppData.ts
|
|
4161
|
-
import { useCallback as
|
|
4007
|
+
import { useCallback as useCallback25 } from "react";
|
|
4162
4008
|
import { v4 as uuid } from "uuid";
|
|
4163
4009
|
function useCreateUserAppData() {
|
|
4164
|
-
return
|
|
4010
|
+
return useCallback25(
|
|
4165
4011
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
4166
4012
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
4167
4013
|
const appValues = {
|
|
@@ -4216,10 +4062,10 @@ function useCreateUserAppData() {
|
|
|
4216
4062
|
}
|
|
4217
4063
|
|
|
4218
4064
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
4219
|
-
import { useCallback as
|
|
4065
|
+
import { useCallback as useCallback26 } from "react";
|
|
4220
4066
|
import { v4 as uuid2 } from "uuid";
|
|
4221
4067
|
function useCreateOrganizationAppData() {
|
|
4222
|
-
return
|
|
4068
|
+
return useCallback26(
|
|
4223
4069
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
4224
4070
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
4225
4071
|
const appValues = {
|
|
@@ -4273,10 +4119,10 @@ function useCreateOrganizationAppData() {
|
|
|
4273
4119
|
}
|
|
4274
4120
|
|
|
4275
4121
|
// src/utils/balance/useFetchBalance.ts
|
|
4276
|
-
import { useCallback as
|
|
4122
|
+
import { useCallback as useCallback27 } from "react";
|
|
4277
4123
|
import { erc20Abi as erc20Abi4, getAddress } from "viem";
|
|
4278
4124
|
function useFetchBalance() {
|
|
4279
|
-
return
|
|
4125
|
+
return useCallback27(
|
|
4280
4126
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
4281
4127
|
try {
|
|
4282
4128
|
const balance = await publicClient.readContract({
|
|
@@ -4295,10 +4141,10 @@ function useFetchBalance() {
|
|
|
4295
4141
|
}
|
|
4296
4142
|
|
|
4297
4143
|
// src/utils/actions/useClaimActionReward.ts
|
|
4298
|
-
import { encodeFunctionData as
|
|
4299
|
-
import { useCallback as
|
|
4144
|
+
import { encodeFunctionData as encodeFunctionData10 } from "viem";
|
|
4145
|
+
import { useCallback as useCallback28 } from "react";
|
|
4300
4146
|
function useClaimActionReward() {
|
|
4301
|
-
return
|
|
4147
|
+
return useCallback28(
|
|
4302
4148
|
async (actionId, claimIndex, rewardableActionContractAddress, smartAccount, bundlerClient) => {
|
|
4303
4149
|
if (!actionId || claimIndex === void 0 || !bundlerClient || !smartAccount || !rewardableActionContractAddress) {
|
|
4304
4150
|
return {
|
|
@@ -4308,7 +4154,7 @@ function useClaimActionReward() {
|
|
|
4308
4154
|
}
|
|
4309
4155
|
const args = [actionId, claimIndex];
|
|
4310
4156
|
const functionName = "claimByIndex";
|
|
4311
|
-
const callData =
|
|
4157
|
+
const callData = encodeFunctionData10({
|
|
4312
4158
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4313
4159
|
functionName,
|
|
4314
4160
|
args
|
|
@@ -4344,10 +4190,10 @@ function useClaimActionReward() {
|
|
|
4344
4190
|
}
|
|
4345
4191
|
|
|
4346
4192
|
// src/utils/actions/useClaimOrgActionReward.ts
|
|
4347
|
-
import { encodeFunctionData as
|
|
4348
|
-
import { useCallback as
|
|
4193
|
+
import { encodeFunctionData as encodeFunctionData11 } from "viem";
|
|
4194
|
+
import { useCallback as useCallback29 } from "react";
|
|
4349
4195
|
function useClaimOrgActionReward() {
|
|
4350
|
-
return
|
|
4196
|
+
return useCallback29(
|
|
4351
4197
|
async (orgContractAddress, rewardableActionContractAddress, actionId, claimIndex, smartAccount, bundlerClient) => {
|
|
4352
4198
|
if (!orgContractAddress || !actionId || claimIndex === void 0 || !bundlerClient || !smartAccount) {
|
|
4353
4199
|
return {
|
|
@@ -4355,13 +4201,13 @@ function useClaimOrgActionReward() {
|
|
|
4355
4201
|
message: "Missing web3auth account info or contract address."
|
|
4356
4202
|
};
|
|
4357
4203
|
}
|
|
4358
|
-
const claimCallData =
|
|
4204
|
+
const claimCallData = encodeFunctionData11({
|
|
4359
4205
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4360
4206
|
functionName: "claimByIndex",
|
|
4361
4207
|
args: [actionId, claimIndex]
|
|
4362
4208
|
});
|
|
4363
4209
|
const args = [rewardableActionContractAddress, claimCallData];
|
|
4364
|
-
const executeClaimCalldata =
|
|
4210
|
+
const executeClaimCalldata = encodeFunctionData11({
|
|
4365
4211
|
abi: ORGANIZATION_IMPL_ABI,
|
|
4366
4212
|
functionName: ORG_FUNCTION,
|
|
4367
4213
|
args
|
|
@@ -4397,9 +4243,9 @@ function useClaimOrgActionReward() {
|
|
|
4397
4243
|
}
|
|
4398
4244
|
|
|
4399
4245
|
// src/utils/actions/useSubmitContractAction.ts
|
|
4400
|
-
import { useCallback as
|
|
4246
|
+
import { useCallback as useCallback30 } from "react";
|
|
4401
4247
|
function useSubmitContractAction() {
|
|
4402
|
-
return
|
|
4248
|
+
return useCallback30(
|
|
4403
4249
|
(idToken, pid, source, endpoint, payload) => {
|
|
4404
4250
|
if (!idToken || !pid || !source || !endpoint || !payload) return;
|
|
4405
4251
|
let sourceTypePayload = {};
|
|
@@ -4538,7 +4384,6 @@ export {
|
|
|
4538
4384
|
convertToMultipleActionRecords,
|
|
4539
4385
|
createApp,
|
|
4540
4386
|
createAuthEnvelope,
|
|
4541
|
-
fetchAnymals,
|
|
4542
4387
|
flattenFirestoreData,
|
|
4543
4388
|
generateAppSignature,
|
|
4544
4389
|
generateBytes32Nonce,
|
|
@@ -4553,19 +4398,18 @@ export {
|
|
|
4553
4398
|
sendUserOpWithRetries,
|
|
4554
4399
|
serializePublicKeyCompressed,
|
|
4555
4400
|
submitAction,
|
|
4556
|
-
useAddAnymalToDatabase,
|
|
4557
4401
|
useApproveKibbleToken,
|
|
4558
4402
|
useApproveOrgPartialPayment,
|
|
4559
4403
|
useClaimActionReward,
|
|
4560
4404
|
useClaimOrgActionReward,
|
|
4405
|
+
useCoinbaseClaimActionReward,
|
|
4406
|
+
useCoinbaseMintAnymalNFT,
|
|
4561
4407
|
useCreateOrganizationAppData,
|
|
4562
4408
|
useCreateOrganizationBase,
|
|
4563
4409
|
useCreateUserAppData,
|
|
4564
4410
|
useCreateWeb3Account,
|
|
4565
|
-
useDeleteAnymalFromDatabase,
|
|
4566
4411
|
useFetchActionDefinitions,
|
|
4567
4412
|
useFetchActions,
|
|
4568
|
-
useFetchAnymals,
|
|
4569
4413
|
useFetchBalance,
|
|
4570
4414
|
useFetchNotifications,
|
|
4571
4415
|
useFetchUserData,
|
|
@@ -4576,7 +4420,6 @@ export {
|
|
|
4576
4420
|
useSaveAnymalMetadata,
|
|
4577
4421
|
useSendCoinbaseUserOperation,
|
|
4578
4422
|
useSubmitContractAction,
|
|
4579
|
-
useUpdateAnymalWithNFT,
|
|
4580
4423
|
useUpdateOrgWalletAddress,
|
|
4581
4424
|
useUpdateUserAsVerified,
|
|
4582
4425
|
useUpdateUserEmail,
|