anymal-protocol 1.0.124 → 1.0.125
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 +9 -24
- package/dist/index.d.ts +9 -24
- package/dist/index.js +113 -308
- package/dist/index.mjs +97 -288
- 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/useCoinbaseMintAnymalNFT.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,42 @@ 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/useCoinbaseMintAnymalNFT.ts
|
|
2850
2852
|
import { useCallback as useCallback11 } from "react";
|
|
2853
|
+
function useCoinbaseMintAnymalNFT() {
|
|
2854
|
+
const { sendOperationFn, status } = useSendCoinbaseUserOperation();
|
|
2855
|
+
return useCallback11(
|
|
2856
|
+
async (evmAddress, pid, nftId, anymalTxId, validationContractAddress) => {
|
|
2857
|
+
if (!nftId || !pid || !validationContractAddress) {
|
|
2858
|
+
return {
|
|
2859
|
+
success: false,
|
|
2860
|
+
message: "Missing authentication token OR NFT ID.",
|
|
2861
|
+
status: "error"
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
const functionName = "submitMetadataByCampaignName";
|
|
2865
|
+
const args = [
|
|
2866
|
+
pid,
|
|
2867
|
+
nftId,
|
|
2868
|
+
`https://dev-nft.petastic.com/metadata/${nftId}`,
|
|
2869
|
+
"petastic-signup-campaign-1",
|
|
2870
|
+
anymalTxId
|
|
2871
|
+
];
|
|
2872
|
+
const callData = encodeFunctionData({
|
|
2873
|
+
abi: PET_NFT_ABI,
|
|
2874
|
+
functionName,
|
|
2875
|
+
args
|
|
2876
|
+
});
|
|
2877
|
+
await sendOperationFn(evmAddress, callData, validationContractAddress);
|
|
2878
|
+
return { success: true, message: "Pet Passport Created", status };
|
|
2879
|
+
},
|
|
2880
|
+
[]
|
|
2881
|
+
);
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
// src/utils/anymals/useMintAnymalNFT.ts
|
|
2885
|
+
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
2886
|
+
import { useCallback as useCallback12 } from "react";
|
|
2851
2887
|
|
|
2852
2888
|
// src/helpers/GasEstimateHelper.tsx
|
|
2853
2889
|
async function applyBundlerGasEstimator(account, bundlerClient, options) {
|
|
@@ -2928,7 +2964,7 @@ async function simulateCall(publicClient, target, abi, functionName, args, calle
|
|
|
2928
2964
|
|
|
2929
2965
|
// src/utils/anymals/useMintAnymalNFT.ts
|
|
2930
2966
|
function useMintAnymalNFT() {
|
|
2931
|
-
return
|
|
2967
|
+
return useCallback12(
|
|
2932
2968
|
async (pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
|
|
2933
2969
|
if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
|
|
2934
2970
|
return {
|
|
@@ -2944,7 +2980,7 @@ function useMintAnymalNFT() {
|
|
|
2944
2980
|
"petastic-signup-campaign-1",
|
|
2945
2981
|
anymalTxId
|
|
2946
2982
|
];
|
|
2947
|
-
const callData =
|
|
2983
|
+
const callData = encodeFunctionData2({
|
|
2948
2984
|
abi: PET_NFT_ABI,
|
|
2949
2985
|
functionName,
|
|
2950
2986
|
args
|
|
@@ -2979,126 +3015,11 @@ function useMintAnymalNFT() {
|
|
|
2979
3015
|
);
|
|
2980
3016
|
}
|
|
2981
3017
|
|
|
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
3018
|
// src/utils/anymals/useSaveAnymalMetadata.ts
|
|
3098
|
-
import { useCallback as
|
|
3019
|
+
import { useCallback as useCallback13 } from "react";
|
|
3099
3020
|
function useSaveAnymalMetadata() {
|
|
3100
|
-
return
|
|
3101
|
-
async (userPid, anymalTxId, idToken,
|
|
3021
|
+
return useCallback13(
|
|
3022
|
+
async (userPid, anymalTxId, idToken, nftMetadataInput, authServiceBaseUrl) => {
|
|
3102
3023
|
const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
|
|
3103
3024
|
method: "POST",
|
|
3104
3025
|
headers: {
|
|
@@ -3106,7 +3027,6 @@ function useSaveAnymalMetadata() {
|
|
|
3106
3027
|
Authorization: "Bearer " + idToken
|
|
3107
3028
|
},
|
|
3108
3029
|
body: JSON.stringify({
|
|
3109
|
-
appPubKey: publicKey,
|
|
3110
3030
|
nftMetadataInput,
|
|
3111
3031
|
pid: userPid,
|
|
3112
3032
|
anymalTxId
|
|
@@ -3125,57 +3045,8 @@ function useSaveAnymalMetadata() {
|
|
|
3125
3045
|
);
|
|
3126
3046
|
}
|
|
3127
3047
|
|
|
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
3048
|
// src/utils/anymals/useUploadAnymalImage.ts
|
|
3178
|
-
import { useCallback as
|
|
3049
|
+
import { useCallback as useCallback14 } from "react";
|
|
3179
3050
|
|
|
3180
3051
|
// src/helpers/UploadImageHelper.tsx
|
|
3181
3052
|
function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
|
|
@@ -3232,8 +3103,8 @@ function toBase64(file) {
|
|
|
3232
3103
|
|
|
3233
3104
|
// src/utils/anymals/useUploadAnymalImage.ts
|
|
3234
3105
|
function useUploadAnymalImage() {
|
|
3235
|
-
return
|
|
3236
|
-
async (imageFile, type, idToken,
|
|
3106
|
+
return useCallback14(
|
|
3107
|
+
async (imageFile, type, idToken, authServiceBaseUrl, petType, breed, lifestage, anymalPid) => {
|
|
3237
3108
|
if (!imageFile || !idToken) {
|
|
3238
3109
|
return {
|
|
3239
3110
|
success: false,
|
|
@@ -3245,7 +3116,6 @@ function useUploadAnymalImage() {
|
|
|
3245
3116
|
try {
|
|
3246
3117
|
const base64Image = await prepareImage(imageFile);
|
|
3247
3118
|
const payload = {
|
|
3248
|
-
appPubKey: publicKey,
|
|
3249
3119
|
imageData: base64Image,
|
|
3250
3120
|
imageName: imageFile.name.split(".")[0],
|
|
3251
3121
|
petType,
|
|
@@ -3293,68 +3163,11 @@ function useUploadAnymalImage() {
|
|
|
3293
3163
|
);
|
|
3294
3164
|
}
|
|
3295
3165
|
|
|
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
3166
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
3354
|
-
import { useCallback as
|
|
3167
|
+
import { useCallback as useCallback15 } from "react";
|
|
3355
3168
|
|
|
3356
3169
|
// src/helpers/ProcessDirectPartialPayment.tsx
|
|
3357
|
-
import { encodeFunctionData as
|
|
3170
|
+
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
3358
3171
|
|
|
3359
3172
|
// src/helpers/SendUserOpWithRetries.tsx
|
|
3360
3173
|
async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
|
|
@@ -3414,7 +3227,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
|
|
|
3414
3227
|
deadline,
|
|
3415
3228
|
backendSignature
|
|
3416
3229
|
];
|
|
3417
|
-
const partialPayCalldata =
|
|
3230
|
+
const partialPayCalldata = encodeFunctionData3({
|
|
3418
3231
|
abi: MARKETPLACE_ABI,
|
|
3419
3232
|
functionName,
|
|
3420
3233
|
args
|
|
@@ -3451,7 +3264,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
|
|
|
3451
3264
|
|
|
3452
3265
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
3453
3266
|
function useProcessPartialKibblePayment() {
|
|
3454
|
-
return
|
|
3267
|
+
return useCallback15(
|
|
3455
3268
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
3456
3269
|
if (!orderId || !dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !marketplaceContract || !amountInTokens || !maxTokenPayment || !nonce || !deadline) {
|
|
3457
3270
|
return {
|
|
@@ -3507,15 +3320,15 @@ function useProcessPartialKibblePayment() {
|
|
|
3507
3320
|
}
|
|
3508
3321
|
|
|
3509
3322
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
3510
|
-
import { useCallback as
|
|
3323
|
+
import { useCallback as useCallback16 } from "react";
|
|
3511
3324
|
|
|
3512
3325
|
// src/helpers/ProcessDirectKibbleApproval.tsx
|
|
3513
|
-
import { encodeFunctionData as
|
|
3326
|
+
import { encodeFunctionData as encodeFunctionData4, erc20Abi } from "viem";
|
|
3514
3327
|
async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
|
|
3515
3328
|
try {
|
|
3516
3329
|
const functionName = "approve";
|
|
3517
3330
|
const args = [spenderAddress, approveAmount];
|
|
3518
|
-
const approveCalldata =
|
|
3331
|
+
const approveCalldata = encodeFunctionData4({
|
|
3519
3332
|
abi: erc20Abi,
|
|
3520
3333
|
functionName,
|
|
3521
3334
|
args
|
|
@@ -3552,7 +3365,7 @@ async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, s
|
|
|
3552
3365
|
|
|
3553
3366
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
3554
3367
|
function useApproveKibbleToken() {
|
|
3555
|
-
return
|
|
3368
|
+
return useCallback16(
|
|
3556
3369
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
3557
3370
|
try {
|
|
3558
3371
|
const result = await processDirectKibbleApproval(
|
|
@@ -3579,10 +3392,10 @@ function useApproveKibbleToken() {
|
|
|
3579
3392
|
}
|
|
3580
3393
|
|
|
3581
3394
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
3582
|
-
import { useCallback as
|
|
3583
|
-
import { decodeEventLog, encodeFunctionData as
|
|
3395
|
+
import { useCallback as useCallback17 } from "react";
|
|
3396
|
+
import { decodeEventLog, encodeFunctionData as encodeFunctionData5 } from "viem";
|
|
3584
3397
|
function useCreateOrganizationBase() {
|
|
3585
|
-
return
|
|
3398
|
+
return useCallback17(
|
|
3586
3399
|
/**
|
|
3587
3400
|
* Creates a new organization on-chain.
|
|
3588
3401
|
*
|
|
@@ -3604,7 +3417,7 @@ function useCreateOrganizationBase() {
|
|
|
3604
3417
|
try {
|
|
3605
3418
|
const functionName = "createOrganizationProxy";
|
|
3606
3419
|
const args = [ownerAddress, orgName, orgPid];
|
|
3607
|
-
const callData =
|
|
3420
|
+
const callData = encodeFunctionData5({
|
|
3608
3421
|
abi: ORGANIZATION_BEACON_ABI,
|
|
3609
3422
|
functionName,
|
|
3610
3423
|
args
|
|
@@ -3678,10 +3491,10 @@ function useCreateOrganizationBase() {
|
|
|
3678
3491
|
}
|
|
3679
3492
|
|
|
3680
3493
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
3681
|
-
import { useCallback as
|
|
3494
|
+
import { useCallback as useCallback18 } from "react";
|
|
3682
3495
|
|
|
3683
3496
|
// src/helpers/ProcessOrgKibbleApproval.tsx
|
|
3684
|
-
import { encodeFunctionData as
|
|
3497
|
+
import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi3 } from "viem";
|
|
3685
3498
|
|
|
3686
3499
|
// src/helpers/WaitForAllowance.tsx
|
|
3687
3500
|
import { erc20Abi as erc20Abi2 } from "viem";
|
|
@@ -3718,13 +3531,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
|
|
|
3718
3531
|
if (approveAmount <= 0n) {
|
|
3719
3532
|
return { success: false, message: "Approval amount must be greater than zero." };
|
|
3720
3533
|
}
|
|
3721
|
-
const approveCalldata =
|
|
3534
|
+
const approveCalldata = encodeFunctionData6({
|
|
3722
3535
|
abi: erc20Abi3,
|
|
3723
3536
|
functionName: "approve",
|
|
3724
3537
|
args: [partialPaymentModuleAddress, approveAmount]
|
|
3725
3538
|
});
|
|
3726
3539
|
const args = [kibbleTokenAddress, approveCalldata];
|
|
3727
|
-
const executeApproveCalldata =
|
|
3540
|
+
const executeApproveCalldata = encodeFunctionData6({
|
|
3728
3541
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3729
3542
|
functionName: ORG_FUNCTION,
|
|
3730
3543
|
args
|
|
@@ -3776,7 +3589,7 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
|
|
|
3776
3589
|
|
|
3777
3590
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
3778
3591
|
function useApproveOrgPartialPayment() {
|
|
3779
|
-
return
|
|
3592
|
+
return useCallback18(
|
|
3780
3593
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
3781
3594
|
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
3782
3595
|
return {
|
|
@@ -3808,13 +3621,13 @@ function useApproveOrgPartialPayment() {
|
|
|
3808
3621
|
}
|
|
3809
3622
|
|
|
3810
3623
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
3811
|
-
import { useCallback as
|
|
3624
|
+
import { useCallback as useCallback19 } from "react";
|
|
3812
3625
|
|
|
3813
3626
|
// src/helpers/ProcessOrgPartialPayment.tsx
|
|
3814
|
-
import { encodeFunctionData as
|
|
3627
|
+
import { encodeFunctionData as encodeFunctionData7 } from "viem";
|
|
3815
3628
|
async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
|
|
3816
3629
|
try {
|
|
3817
|
-
const partialPayCalldata =
|
|
3630
|
+
const partialPayCalldata = encodeFunctionData7({
|
|
3818
3631
|
abi: MARKETPLACE_ABI,
|
|
3819
3632
|
functionName: "partialPay",
|
|
3820
3633
|
args: [
|
|
@@ -3829,7 +3642,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
|
|
|
3829
3642
|
]
|
|
3830
3643
|
});
|
|
3831
3644
|
const args = [partialPaymentModuleAddress, partialPayCalldata];
|
|
3832
|
-
const executePartialPayCalldata =
|
|
3645
|
+
const executePartialPayCalldata = encodeFunctionData7({
|
|
3833
3646
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3834
3647
|
functionName: ORG_FUNCTION,
|
|
3835
3648
|
args
|
|
@@ -3866,7 +3679,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
|
|
|
3866
3679
|
|
|
3867
3680
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
3868
3681
|
function useProcessOrgPartialKibblePayment() {
|
|
3869
|
-
return
|
|
3682
|
+
return useCallback19(
|
|
3870
3683
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
3871
3684
|
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
3872
3685
|
return {
|
|
@@ -3904,9 +3717,9 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
3904
3717
|
}
|
|
3905
3718
|
|
|
3906
3719
|
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
3907
|
-
import { useCallback as
|
|
3720
|
+
import { useCallback as useCallback20 } from "react";
|
|
3908
3721
|
function useUpdateOrgWalletAddress() {
|
|
3909
|
-
return
|
|
3722
|
+
return useCallback20(
|
|
3910
3723
|
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
3911
3724
|
try {
|
|
3912
3725
|
const mutation = `
|
|
@@ -3945,10 +3758,10 @@ function useUpdateOrgWalletAddress() {
|
|
|
3945
3758
|
}
|
|
3946
3759
|
|
|
3947
3760
|
// src/utils/organization/useMintOrgAnymalNFT.ts
|
|
3948
|
-
import { encodeFunctionData as
|
|
3949
|
-
import { useCallback as
|
|
3761
|
+
import { encodeFunctionData as encodeFunctionData8 } from "viem";
|
|
3762
|
+
import { useCallback as useCallback21 } from "react";
|
|
3950
3763
|
function useMintOrgAnymalNFT() {
|
|
3951
|
-
return
|
|
3764
|
+
return useCallback21(
|
|
3952
3765
|
async (orgContractAddress, pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, managerSmartAccount, bundlerClient) => {
|
|
3953
3766
|
if (!dbAuthToken || !nftId || !bundlerClient || !managerSmartAccount || !pid || !validationContractAddress || !orgContractAddress) {
|
|
3954
3767
|
return {
|
|
@@ -3964,13 +3777,13 @@ function useMintOrgAnymalNFT() {
|
|
|
3964
3777
|
"petastic-signup-campaign-1",
|
|
3965
3778
|
anymalTxId
|
|
3966
3779
|
];
|
|
3967
|
-
const callData =
|
|
3780
|
+
const callData = encodeFunctionData8({
|
|
3968
3781
|
abi: PET_NFT_ABI,
|
|
3969
3782
|
functionName,
|
|
3970
3783
|
args
|
|
3971
3784
|
});
|
|
3972
3785
|
const executeArgs = [validationContractAddress, callData];
|
|
3973
|
-
const executeSubmitMetaCalldata =
|
|
3786
|
+
const executeSubmitMetaCalldata = encodeFunctionData8({
|
|
3974
3787
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3975
3788
|
functionName: ORG_FUNCTION,
|
|
3976
3789
|
args: executeArgs
|
|
@@ -4028,9 +3841,9 @@ async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl)
|
|
|
4028
3841
|
}
|
|
4029
3842
|
|
|
4030
3843
|
// src/utils/actions/useFetchActions.ts
|
|
4031
|
-
import { useCallback as
|
|
3844
|
+
import { useCallback as useCallback22 } from "react";
|
|
4032
3845
|
function useFetchActions() {
|
|
4033
|
-
return
|
|
3846
|
+
return useCallback22(
|
|
4034
3847
|
async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
|
|
4035
3848
|
const params = new URLSearchParams({ pid });
|
|
4036
3849
|
if (status) params.set("status", status);
|
|
@@ -4059,9 +3872,9 @@ function useFetchActions() {
|
|
|
4059
3872
|
}
|
|
4060
3873
|
|
|
4061
3874
|
// src/utils/actions/useFetchActionDefinitions.ts
|
|
4062
|
-
import { useCallback as
|
|
3875
|
+
import { useCallback as useCallback23 } from "react";
|
|
4063
3876
|
function useFetchActionDefinitions() {
|
|
4064
|
-
return
|
|
3877
|
+
return useCallback23(
|
|
4065
3878
|
async (idToken, actionsServiceBaseUrl) => {
|
|
4066
3879
|
try {
|
|
4067
3880
|
const response = await fetch(
|
|
@@ -4158,10 +3971,10 @@ var convertToMultipleActionRecords = (frs) => frs.map(convertToActionRecord);
|
|
|
4158
3971
|
var convertToMultipleActionDefinitions = (frs) => frs.map(convertToActionDefinition);
|
|
4159
3972
|
|
|
4160
3973
|
// src/utils/application/useCreateUserAppData.ts
|
|
4161
|
-
import { useCallback as
|
|
3974
|
+
import { useCallback as useCallback24 } from "react";
|
|
4162
3975
|
import { v4 as uuid } from "uuid";
|
|
4163
3976
|
function useCreateUserAppData() {
|
|
4164
|
-
return
|
|
3977
|
+
return useCallback24(
|
|
4165
3978
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
4166
3979
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
4167
3980
|
const appValues = {
|
|
@@ -4216,10 +4029,10 @@ function useCreateUserAppData() {
|
|
|
4216
4029
|
}
|
|
4217
4030
|
|
|
4218
4031
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
4219
|
-
import { useCallback as
|
|
4032
|
+
import { useCallback as useCallback25 } from "react";
|
|
4220
4033
|
import { v4 as uuid2 } from "uuid";
|
|
4221
4034
|
function useCreateOrganizationAppData() {
|
|
4222
|
-
return
|
|
4035
|
+
return useCallback25(
|
|
4223
4036
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
4224
4037
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
4225
4038
|
const appValues = {
|
|
@@ -4273,10 +4086,10 @@ function useCreateOrganizationAppData() {
|
|
|
4273
4086
|
}
|
|
4274
4087
|
|
|
4275
4088
|
// src/utils/balance/useFetchBalance.ts
|
|
4276
|
-
import { useCallback as
|
|
4089
|
+
import { useCallback as useCallback26 } from "react";
|
|
4277
4090
|
import { erc20Abi as erc20Abi4, getAddress } from "viem";
|
|
4278
4091
|
function useFetchBalance() {
|
|
4279
|
-
return
|
|
4092
|
+
return useCallback26(
|
|
4280
4093
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
4281
4094
|
try {
|
|
4282
4095
|
const balance = await publicClient.readContract({
|
|
@@ -4295,10 +4108,10 @@ function useFetchBalance() {
|
|
|
4295
4108
|
}
|
|
4296
4109
|
|
|
4297
4110
|
// src/utils/actions/useClaimActionReward.ts
|
|
4298
|
-
import { encodeFunctionData as
|
|
4299
|
-
import { useCallback as
|
|
4111
|
+
import { encodeFunctionData as encodeFunctionData9 } from "viem";
|
|
4112
|
+
import { useCallback as useCallback27 } from "react";
|
|
4300
4113
|
function useClaimActionReward() {
|
|
4301
|
-
return
|
|
4114
|
+
return useCallback27(
|
|
4302
4115
|
async (actionId, claimIndex, rewardableActionContractAddress, smartAccount, bundlerClient) => {
|
|
4303
4116
|
if (!actionId || claimIndex === void 0 || !bundlerClient || !smartAccount || !rewardableActionContractAddress) {
|
|
4304
4117
|
return {
|
|
@@ -4308,7 +4121,7 @@ function useClaimActionReward() {
|
|
|
4308
4121
|
}
|
|
4309
4122
|
const args = [actionId, claimIndex];
|
|
4310
4123
|
const functionName = "claimByIndex";
|
|
4311
|
-
const callData =
|
|
4124
|
+
const callData = encodeFunctionData9({
|
|
4312
4125
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4313
4126
|
functionName,
|
|
4314
4127
|
args
|
|
@@ -4344,10 +4157,10 @@ function useClaimActionReward() {
|
|
|
4344
4157
|
}
|
|
4345
4158
|
|
|
4346
4159
|
// src/utils/actions/useClaimOrgActionReward.ts
|
|
4347
|
-
import { encodeFunctionData as
|
|
4348
|
-
import { useCallback as
|
|
4160
|
+
import { encodeFunctionData as encodeFunctionData10 } from "viem";
|
|
4161
|
+
import { useCallback as useCallback28 } from "react";
|
|
4349
4162
|
function useClaimOrgActionReward() {
|
|
4350
|
-
return
|
|
4163
|
+
return useCallback28(
|
|
4351
4164
|
async (orgContractAddress, rewardableActionContractAddress, actionId, claimIndex, smartAccount, bundlerClient) => {
|
|
4352
4165
|
if (!orgContractAddress || !actionId || claimIndex === void 0 || !bundlerClient || !smartAccount) {
|
|
4353
4166
|
return {
|
|
@@ -4355,13 +4168,13 @@ function useClaimOrgActionReward() {
|
|
|
4355
4168
|
message: "Missing web3auth account info or contract address."
|
|
4356
4169
|
};
|
|
4357
4170
|
}
|
|
4358
|
-
const claimCallData =
|
|
4171
|
+
const claimCallData = encodeFunctionData10({
|
|
4359
4172
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4360
4173
|
functionName: "claimByIndex",
|
|
4361
4174
|
args: [actionId, claimIndex]
|
|
4362
4175
|
});
|
|
4363
4176
|
const args = [rewardableActionContractAddress, claimCallData];
|
|
4364
|
-
const executeClaimCalldata =
|
|
4177
|
+
const executeClaimCalldata = encodeFunctionData10({
|
|
4365
4178
|
abi: ORGANIZATION_IMPL_ABI,
|
|
4366
4179
|
functionName: ORG_FUNCTION,
|
|
4367
4180
|
args
|
|
@@ -4397,9 +4210,9 @@ function useClaimOrgActionReward() {
|
|
|
4397
4210
|
}
|
|
4398
4211
|
|
|
4399
4212
|
// src/utils/actions/useSubmitContractAction.ts
|
|
4400
|
-
import { useCallback as
|
|
4213
|
+
import { useCallback as useCallback29 } from "react";
|
|
4401
4214
|
function useSubmitContractAction() {
|
|
4402
|
-
return
|
|
4215
|
+
return useCallback29(
|
|
4403
4216
|
(idToken, pid, source, endpoint, payload) => {
|
|
4404
4217
|
if (!idToken || !pid || !source || !endpoint || !payload) return;
|
|
4405
4218
|
let sourceTypePayload = {};
|
|
@@ -4538,7 +4351,6 @@ export {
|
|
|
4538
4351
|
convertToMultipleActionRecords,
|
|
4539
4352
|
createApp,
|
|
4540
4353
|
createAuthEnvelope,
|
|
4541
|
-
fetchAnymals,
|
|
4542
4354
|
flattenFirestoreData,
|
|
4543
4355
|
generateAppSignature,
|
|
4544
4356
|
generateBytes32Nonce,
|
|
@@ -4553,19 +4365,17 @@ export {
|
|
|
4553
4365
|
sendUserOpWithRetries,
|
|
4554
4366
|
serializePublicKeyCompressed,
|
|
4555
4367
|
submitAction,
|
|
4556
|
-
useAddAnymalToDatabase,
|
|
4557
4368
|
useApproveKibbleToken,
|
|
4558
4369
|
useApproveOrgPartialPayment,
|
|
4559
4370
|
useClaimActionReward,
|
|
4560
4371
|
useClaimOrgActionReward,
|
|
4372
|
+
useCoinbaseMintAnymalNFT,
|
|
4561
4373
|
useCreateOrganizationAppData,
|
|
4562
4374
|
useCreateOrganizationBase,
|
|
4563
4375
|
useCreateUserAppData,
|
|
4564
4376
|
useCreateWeb3Account,
|
|
4565
|
-
useDeleteAnymalFromDatabase,
|
|
4566
4377
|
useFetchActionDefinitions,
|
|
4567
4378
|
useFetchActions,
|
|
4568
|
-
useFetchAnymals,
|
|
4569
4379
|
useFetchBalance,
|
|
4570
4380
|
useFetchNotifications,
|
|
4571
4381
|
useFetchUserData,
|
|
@@ -4576,7 +4386,6 @@ export {
|
|
|
4576
4386
|
useSaveAnymalMetadata,
|
|
4577
4387
|
useSendCoinbaseUserOperation,
|
|
4578
4388
|
useSubmitContractAction,
|
|
4579
|
-
useUpdateAnymalWithNFT,
|
|
4580
4389
|
useUpdateOrgWalletAddress,
|
|
4581
4390
|
useUpdateUserAsVerified,
|
|
4582
4391
|
useUpdateUserEmail,
|