anymal-protocol 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -13,6 +13,11 @@ declare function useUpdateUserEmail(): (dbAuthToken: string, docID: string, emai
13
13
 
14
14
  declare function useUpdateUserPid(): (dbAuthToken: string, docID: string, pid: string, endpoint: string) => Promise<void>;
15
15
 
16
+ declare function useUpdateUserAsVerified(): (recaptchaToken: string | null, docID: string, dbAuthToken: string, endpoint: string) => Promise<{
17
+ success: boolean;
18
+ message: string;
19
+ } | undefined>;
20
+
16
21
  declare function useMintAnymalNFT(): (pid: string, nftId: string, dbAuthToken: string, validationContractAddress: string, smartAccount: any, bundlerClient: any) => Promise<{
17
22
  success: boolean;
18
23
  message: string;
@@ -53,4 +58,4 @@ declare function useUploadAnymalImage(): (imageFile: File, type: string, idToken
53
58
 
54
59
  declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
55
60
 
56
- export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserEmail, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
61
+ export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,11 @@ declare function useUpdateUserEmail(): (dbAuthToken: string, docID: string, emai
13
13
 
14
14
  declare function useUpdateUserPid(): (dbAuthToken: string, docID: string, pid: string, endpoint: string) => Promise<void>;
15
15
 
16
+ declare function useUpdateUserAsVerified(): (recaptchaToken: string | null, docID: string, dbAuthToken: string, endpoint: string) => Promise<{
17
+ success: boolean;
18
+ message: string;
19
+ } | undefined>;
20
+
16
21
  declare function useMintAnymalNFT(): (pid: string, nftId: string, dbAuthToken: string, validationContractAddress: string, smartAccount: any, bundlerClient: any) => Promise<{
17
22
  success: boolean;
18
23
  message: string;
@@ -53,4 +58,4 @@ declare function useUploadAnymalImage(): (imageFile: File, type: string, idToken
53
58
 
54
59
  declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
55
60
 
56
- export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserEmail, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
61
+ export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  useMintAnymalNFT: () => useMintAnymalNFT,
29
29
  useSaveAnymalMetadata: () => useSaveAnymalMetadata,
30
30
  useUpdateAnymalWithNFT: () => useUpdateAnymalWithNFT,
31
+ useUpdateUserAsVerified: () => useUpdateUserAsVerified,
31
32
  useUpdateUserEmail: () => useUpdateUserEmail,
32
33
  useUpdateUserPid: () => useUpdateUserPid,
33
34
  useUploadAnymalImage: () => useUploadAnymalImage,
@@ -604,7 +605,7 @@ function useVerifyAccount() {
604
605
  if (!dbAuthToken || !bundlerClient || !smartAccount || !accountRewardsContractAddress || !pid) {
605
606
  return {
606
607
  success: false,
607
- message: "Missing authentication token OR NFT ID."
608
+ message: "Missing crucial information"
608
609
  };
609
610
  }
610
611
  const callData = (0, import_viem.encodeFunctionData)({
@@ -806,11 +807,52 @@ function useUpdateUserPid() {
806
807
  );
807
808
  }
808
809
 
810
+ // src/utils/account/useUpdateUserAsVerified.ts
811
+ var import_react7 = require("react");
812
+ function useUpdateUserAsVerified() {
813
+ return (0, import_react7.useCallback)(
814
+ async (recaptchaToken, docID, dbAuthToken, endpoint) => {
815
+ if (!docID || !dbAuthToken || recaptchaToken === null) return;
816
+ try {
817
+ const mutation = `
818
+ mutation Update_User($docID: [ID], $input: UserMutationInputArg) {
819
+ update_User(docID: $docID, input: $input) {
820
+ isVerified
821
+ }
822
+ }
823
+ `;
824
+ const variables = {
825
+ docId: [docID],
826
+ input: {
827
+ isVerified: true
828
+ }
829
+ };
830
+ const response = await fetch(endpoint, {
831
+ method: "POST",
832
+ headers: {
833
+ "Content-Type": "application/json",
834
+ Authorization: `Bearer ${dbAuthToken}`
835
+ },
836
+ body: JSON.stringify({
837
+ query: mutation,
838
+ variables
839
+ })
840
+ });
841
+ const responseMessage = response.ok ? "Your account has been verified!" : "An error has occured, try again.";
842
+ return { success: response.ok, message: responseMessage };
843
+ } catch (error) {
844
+ return { success: false, message: error.message };
845
+ }
846
+ },
847
+ []
848
+ );
849
+ }
850
+
809
851
  // src/utils/anymals/useMintAnymalNFT.ts
810
852
  var import_viem2 = require("viem");
811
- var import_react7 = require("react");
853
+ var import_react8 = require("react");
812
854
  function useMintAnymalNFT() {
813
- return (0, import_react7.useCallback)(
855
+ return (0, import_react8.useCallback)(
814
856
  async (pid, nftId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
815
857
  if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
816
858
  return {
@@ -849,9 +891,9 @@ function useMintAnymalNFT() {
849
891
  }
850
892
 
851
893
  // src/utils/anymals/useAddAnymalToDatabase.ts
852
- var import_react8 = require("react");
894
+ var import_react9 = require("react");
853
895
  function useAddAnymalToDatabase() {
854
- return (0, import_react8.useCallback)(
896
+ return (0, import_react9.useCallback)(
855
897
  async (dbAuthToken, endpoint, anymalData) => {
856
898
  if (!dbAuthToken) {
857
899
  return {
@@ -916,9 +958,9 @@ function useAddAnymalToDatabase() {
916
958
  }
917
959
 
918
960
  // src/utils/anymals/useDeleteAnymalFromDatabase.ts
919
- var import_react9 = require("react");
961
+ var import_react10 = require("react");
920
962
  function useDeleteAnymalFromDatabase() {
921
- return (0, import_react9.useCallback)(
963
+ return (0, import_react10.useCallback)(
922
964
  async (dbAuthToken, endpoint, anymalDocID) => {
923
965
  if (!dbAuthToken || !endpoint || !anymalDocID) return;
924
966
  try {
@@ -956,9 +998,9 @@ function useDeleteAnymalFromDatabase() {
956
998
  }
957
999
 
958
1000
  // src/utils/anymals/useSaveAnymalMetadata.ts
959
- var import_react10 = require("react");
1001
+ var import_react11 = require("react");
960
1002
  function useSaveAnymalMetadata() {
961
- return (0, import_react10.useCallback)(
1003
+ return (0, import_react11.useCallback)(
962
1004
  async (idToken, publicKey, nftMetadataInput, authServiceBaseUrl) => {
963
1005
  const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
964
1006
  method: "POST",
@@ -985,9 +1027,9 @@ function useSaveAnymalMetadata() {
985
1027
  }
986
1028
 
987
1029
  // src/utils/anymals/useUpdateAnymalWithNFT.ts
988
- var import_react11 = require("react");
1030
+ var import_react12 = require("react");
989
1031
  function useUpdateAnymalWithNFT() {
990
- return (0, import_react11.useCallback)(
1032
+ return (0, import_react12.useCallback)(
991
1033
  async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
992
1034
  if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
993
1035
  return {
@@ -1034,7 +1076,7 @@ function useUpdateAnymalWithNFT() {
1034
1076
  }
1035
1077
 
1036
1078
  // src/utils/anymals/useUploadAnymalImage.ts
1037
- var import_react12 = require("react");
1079
+ var import_react13 = require("react");
1038
1080
 
1039
1081
  // src/helpers/UploadImageHelper.tsx
1040
1082
  function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
@@ -1091,7 +1133,7 @@ function toBase64(file) {
1091
1133
 
1092
1134
  // src/utils/anymals/useUploadAnymalImage.ts
1093
1135
  function useUploadAnymalImage() {
1094
- return (0, import_react12.useCallback)(
1136
+ return (0, import_react13.useCallback)(
1095
1137
  async (imageFile, type, idToken, publicKey, authServiceBaseUrl) => {
1096
1138
  if (!imageFile || !idToken) {
1097
1139
  return {
@@ -1146,10 +1188,10 @@ function useUploadAnymalImage() {
1146
1188
  }
1147
1189
 
1148
1190
  // src/utils/balance/useFetchBalance.ts
1149
- var import_react13 = require("react");
1191
+ var import_react14 = require("react");
1150
1192
  var import_viem3 = require("viem");
1151
1193
  function useFetchBalance() {
1152
- return (0, import_react13.useCallback)(
1194
+ return (0, import_react14.useCallback)(
1153
1195
  async (publicClient, walletAddress, kibbleTokenAddress) => {
1154
1196
  try {
1155
1197
  const balance = await publicClient.readContract({
@@ -1176,6 +1218,7 @@ function useFetchBalance() {
1176
1218
  useMintAnymalNFT,
1177
1219
  useSaveAnymalMetadata,
1178
1220
  useUpdateAnymalWithNFT,
1221
+ useUpdateUserAsVerified,
1179
1222
  useUpdateUserEmail,
1180
1223
  useUpdateUserPid,
1181
1224
  useUploadAnymalImage,
package/dist/index.mjs CHANGED
@@ -566,7 +566,7 @@ function useVerifyAccount() {
566
566
  if (!dbAuthToken || !bundlerClient || !smartAccount || !accountRewardsContractAddress || !pid) {
567
567
  return {
568
568
  success: false,
569
- message: "Missing authentication token OR NFT ID."
569
+ message: "Missing crucial information"
570
570
  };
571
571
  }
572
572
  const callData = encodeFunctionData({
@@ -768,11 +768,52 @@ function useUpdateUserPid() {
768
768
  );
769
769
  }
770
770
 
771
+ // src/utils/account/useUpdateUserAsVerified.ts
772
+ import { useCallback as useCallback7 } from "react";
773
+ function useUpdateUserAsVerified() {
774
+ return useCallback7(
775
+ async (recaptchaToken, docID, dbAuthToken, endpoint) => {
776
+ if (!docID || !dbAuthToken || recaptchaToken === null) return;
777
+ try {
778
+ const mutation = `
779
+ mutation Update_User($docID: [ID], $input: UserMutationInputArg) {
780
+ update_User(docID: $docID, input: $input) {
781
+ isVerified
782
+ }
783
+ }
784
+ `;
785
+ const variables = {
786
+ docId: [docID],
787
+ input: {
788
+ isVerified: true
789
+ }
790
+ };
791
+ const response = await fetch(endpoint, {
792
+ method: "POST",
793
+ headers: {
794
+ "Content-Type": "application/json",
795
+ Authorization: `Bearer ${dbAuthToken}`
796
+ },
797
+ body: JSON.stringify({
798
+ query: mutation,
799
+ variables
800
+ })
801
+ });
802
+ const responseMessage = response.ok ? "Your account has been verified!" : "An error has occured, try again.";
803
+ return { success: response.ok, message: responseMessage };
804
+ } catch (error) {
805
+ return { success: false, message: error.message };
806
+ }
807
+ },
808
+ []
809
+ );
810
+ }
811
+
771
812
  // src/utils/anymals/useMintAnymalNFT.ts
772
813
  import { encodeFunctionData as encodeFunctionData2, parseGwei as parseGwei2 } from "viem";
773
- import { useCallback as useCallback7 } from "react";
814
+ import { useCallback as useCallback8 } from "react";
774
815
  function useMintAnymalNFT() {
775
- return useCallback7(
816
+ return useCallback8(
776
817
  async (pid, nftId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
777
818
  if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
778
819
  return {
@@ -811,9 +852,9 @@ function useMintAnymalNFT() {
811
852
  }
812
853
 
813
854
  // src/utils/anymals/useAddAnymalToDatabase.ts
814
- import { useCallback as useCallback8 } from "react";
855
+ import { useCallback as useCallback9 } from "react";
815
856
  function useAddAnymalToDatabase() {
816
- return useCallback8(
857
+ return useCallback9(
817
858
  async (dbAuthToken, endpoint, anymalData) => {
818
859
  if (!dbAuthToken) {
819
860
  return {
@@ -878,9 +919,9 @@ function useAddAnymalToDatabase() {
878
919
  }
879
920
 
880
921
  // src/utils/anymals/useDeleteAnymalFromDatabase.ts
881
- import { useCallback as useCallback9 } from "react";
922
+ import { useCallback as useCallback10 } from "react";
882
923
  function useDeleteAnymalFromDatabase() {
883
- return useCallback9(
924
+ return useCallback10(
884
925
  async (dbAuthToken, endpoint, anymalDocID) => {
885
926
  if (!dbAuthToken || !endpoint || !anymalDocID) return;
886
927
  try {
@@ -918,9 +959,9 @@ function useDeleteAnymalFromDatabase() {
918
959
  }
919
960
 
920
961
  // src/utils/anymals/useSaveAnymalMetadata.ts
921
- import { useCallback as useCallback10 } from "react";
962
+ import { useCallback as useCallback11 } from "react";
922
963
  function useSaveAnymalMetadata() {
923
- return useCallback10(
964
+ return useCallback11(
924
965
  async (idToken, publicKey, nftMetadataInput, authServiceBaseUrl) => {
925
966
  const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
926
967
  method: "POST",
@@ -947,9 +988,9 @@ function useSaveAnymalMetadata() {
947
988
  }
948
989
 
949
990
  // src/utils/anymals/useUpdateAnymalWithNFT.ts
950
- import { useCallback as useCallback11 } from "react";
991
+ import { useCallback as useCallback12 } from "react";
951
992
  function useUpdateAnymalWithNFT() {
952
- return useCallback11(
993
+ return useCallback12(
953
994
  async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
954
995
  if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
955
996
  return {
@@ -996,7 +1037,7 @@ function useUpdateAnymalWithNFT() {
996
1037
  }
997
1038
 
998
1039
  // src/utils/anymals/useUploadAnymalImage.ts
999
- import { useCallback as useCallback12 } from "react";
1040
+ import { useCallback as useCallback13 } from "react";
1000
1041
 
1001
1042
  // src/helpers/UploadImageHelper.tsx
1002
1043
  function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
@@ -1053,7 +1094,7 @@ function toBase64(file) {
1053
1094
 
1054
1095
  // src/utils/anymals/useUploadAnymalImage.ts
1055
1096
  function useUploadAnymalImage() {
1056
- return useCallback12(
1097
+ return useCallback13(
1057
1098
  async (imageFile, type, idToken, publicKey, authServiceBaseUrl) => {
1058
1099
  if (!imageFile || !idToken) {
1059
1100
  return {
@@ -1108,10 +1149,10 @@ function useUploadAnymalImage() {
1108
1149
  }
1109
1150
 
1110
1151
  // src/utils/balance/useFetchBalance.ts
1111
- import { useCallback as useCallback13 } from "react";
1152
+ import { useCallback as useCallback14 } from "react";
1112
1153
  import { erc20Abi, getAddress } from "viem";
1113
1154
  function useFetchBalance() {
1114
- return useCallback13(
1155
+ return useCallback14(
1115
1156
  async (publicClient, walletAddress, kibbleTokenAddress) => {
1116
1157
  try {
1117
1158
  const balance = await publicClient.readContract({
@@ -1137,6 +1178,7 @@ export {
1137
1178
  useMintAnymalNFT,
1138
1179
  useSaveAnymalMetadata,
1139
1180
  useUpdateAnymalWithNFT,
1181
+ useUpdateUserAsVerified,
1140
1182
  useUpdateUserEmail,
1141
1183
  useUpdateUserPid,
1142
1184
  useUploadAnymalImage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./utils/account/useCreateWeb3Account";
4
4
  export * from "./utils/account/useFetchUserData";
5
5
  export * from "./utils/account/useUpdateUserEmail";
6
6
  export * from "./utils/account/useUpdateUserPid";
7
+ export * from "./utils/account/useUpdateUserAsVerified";
7
8
 
8
9
  export * from "./utils/anymals/useMintAnymalNFT";
9
10
  export * from "./utils/anymals/useAddAnymalToDatabase";
@@ -0,0 +1,52 @@
1
+ import { useCallback } from "react";
2
+
3
+ export function useUpdateUserAsVerified() {
4
+ return useCallback(
5
+ async (
6
+ recaptchaToken: string | null,
7
+ docID: string,
8
+ dbAuthToken: string,
9
+ endpoint: string
10
+ ) => {
11
+ if (!docID || !dbAuthToken || recaptchaToken === null) return;
12
+
13
+ try {
14
+ const mutation = `
15
+ mutation Update_User($docID: [ID], $input: UserMutationInputArg) {
16
+ update_User(docID: $docID, input: $input) {
17
+ isVerified
18
+ }
19
+ }
20
+ `;
21
+
22
+ const variables = {
23
+ docId: [docID],
24
+ input: {
25
+ isVerified: true,
26
+ },
27
+ };
28
+
29
+ const response = await fetch(endpoint, {
30
+ method: "POST",
31
+ headers: {
32
+ "Content-Type": "application/json",
33
+ Authorization: `Bearer ${dbAuthToken}`,
34
+ },
35
+ body: JSON.stringify({
36
+ query: mutation,
37
+ variables,
38
+ }),
39
+ });
40
+
41
+ const responseMessage = response.ok
42
+ ? "Your account has been verified!"
43
+ : "An error has occured, try again.";
44
+
45
+ return { success: response.ok, message: responseMessage };
46
+ } catch (error) {
47
+ return { success: false, message: (error as Error).message };
48
+ }
49
+ },
50
+ []
51
+ );
52
+ }
@@ -23,7 +23,7 @@ export function useVerifyAccount() {
23
23
  ) {
24
24
  return {
25
25
  success: false,
26
- message: "Missing authentication token OR NFT ID.",
26
+ message: "Missing crucial information",
27
27
  };
28
28
  }
29
29