anymal-protocol 1.0.6 → 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,
@@ -602,13 +603,6 @@ function useVerifyAccount() {
602
603
  return (0, import_react.useCallback)(
603
604
  async (pid, dbAuthToken, bundlerClient, smartAccount, accountRewardsContractAddress) => {
604
605
  if (!dbAuthToken || !bundlerClient || !smartAccount || !accountRewardsContractAddress || !pid) {
605
- console.log({
606
- dbAuthToken,
607
- bundlerClient,
608
- smartAccount,
609
- accountRewardsContractAddress,
610
- pid
611
- });
612
606
  return {
613
607
  success: false,
614
608
  message: "Missing crucial information"
@@ -813,11 +807,52 @@ function useUpdateUserPid() {
813
807
  );
814
808
  }
815
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
+
816
851
  // src/utils/anymals/useMintAnymalNFT.ts
817
852
  var import_viem2 = require("viem");
818
- var import_react7 = require("react");
853
+ var import_react8 = require("react");
819
854
  function useMintAnymalNFT() {
820
- return (0, import_react7.useCallback)(
855
+ return (0, import_react8.useCallback)(
821
856
  async (pid, nftId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
822
857
  if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
823
858
  return {
@@ -856,9 +891,9 @@ function useMintAnymalNFT() {
856
891
  }
857
892
 
858
893
  // src/utils/anymals/useAddAnymalToDatabase.ts
859
- var import_react8 = require("react");
894
+ var import_react9 = require("react");
860
895
  function useAddAnymalToDatabase() {
861
- return (0, import_react8.useCallback)(
896
+ return (0, import_react9.useCallback)(
862
897
  async (dbAuthToken, endpoint, anymalData) => {
863
898
  if (!dbAuthToken) {
864
899
  return {
@@ -923,9 +958,9 @@ function useAddAnymalToDatabase() {
923
958
  }
924
959
 
925
960
  // src/utils/anymals/useDeleteAnymalFromDatabase.ts
926
- var import_react9 = require("react");
961
+ var import_react10 = require("react");
927
962
  function useDeleteAnymalFromDatabase() {
928
- return (0, import_react9.useCallback)(
963
+ return (0, import_react10.useCallback)(
929
964
  async (dbAuthToken, endpoint, anymalDocID) => {
930
965
  if (!dbAuthToken || !endpoint || !anymalDocID) return;
931
966
  try {
@@ -963,9 +998,9 @@ function useDeleteAnymalFromDatabase() {
963
998
  }
964
999
 
965
1000
  // src/utils/anymals/useSaveAnymalMetadata.ts
966
- var import_react10 = require("react");
1001
+ var import_react11 = require("react");
967
1002
  function useSaveAnymalMetadata() {
968
- return (0, import_react10.useCallback)(
1003
+ return (0, import_react11.useCallback)(
969
1004
  async (idToken, publicKey, nftMetadataInput, authServiceBaseUrl) => {
970
1005
  const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
971
1006
  method: "POST",
@@ -992,9 +1027,9 @@ function useSaveAnymalMetadata() {
992
1027
  }
993
1028
 
994
1029
  // src/utils/anymals/useUpdateAnymalWithNFT.ts
995
- var import_react11 = require("react");
1030
+ var import_react12 = require("react");
996
1031
  function useUpdateAnymalWithNFT() {
997
- return (0, import_react11.useCallback)(
1032
+ return (0, import_react12.useCallback)(
998
1033
  async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
999
1034
  if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
1000
1035
  return {
@@ -1041,7 +1076,7 @@ function useUpdateAnymalWithNFT() {
1041
1076
  }
1042
1077
 
1043
1078
  // src/utils/anymals/useUploadAnymalImage.ts
1044
- var import_react12 = require("react");
1079
+ var import_react13 = require("react");
1045
1080
 
1046
1081
  // src/helpers/UploadImageHelper.tsx
1047
1082
  function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
@@ -1098,7 +1133,7 @@ function toBase64(file) {
1098
1133
 
1099
1134
  // src/utils/anymals/useUploadAnymalImage.ts
1100
1135
  function useUploadAnymalImage() {
1101
- return (0, import_react12.useCallback)(
1136
+ return (0, import_react13.useCallback)(
1102
1137
  async (imageFile, type, idToken, publicKey, authServiceBaseUrl) => {
1103
1138
  if (!imageFile || !idToken) {
1104
1139
  return {
@@ -1153,10 +1188,10 @@ function useUploadAnymalImage() {
1153
1188
  }
1154
1189
 
1155
1190
  // src/utils/balance/useFetchBalance.ts
1156
- var import_react13 = require("react");
1191
+ var import_react14 = require("react");
1157
1192
  var import_viem3 = require("viem");
1158
1193
  function useFetchBalance() {
1159
- return (0, import_react13.useCallback)(
1194
+ return (0, import_react14.useCallback)(
1160
1195
  async (publicClient, walletAddress, kibbleTokenAddress) => {
1161
1196
  try {
1162
1197
  const balance = await publicClient.readContract({
@@ -1183,6 +1218,7 @@ function useFetchBalance() {
1183
1218
  useMintAnymalNFT,
1184
1219
  useSaveAnymalMetadata,
1185
1220
  useUpdateAnymalWithNFT,
1221
+ useUpdateUserAsVerified,
1186
1222
  useUpdateUserEmail,
1187
1223
  useUpdateUserPid,
1188
1224
  useUploadAnymalImage,
package/dist/index.mjs CHANGED
@@ -564,13 +564,6 @@ function useVerifyAccount() {
564
564
  return useCallback(
565
565
  async (pid, dbAuthToken, bundlerClient, smartAccount, accountRewardsContractAddress) => {
566
566
  if (!dbAuthToken || !bundlerClient || !smartAccount || !accountRewardsContractAddress || !pid) {
567
- console.log({
568
- dbAuthToken,
569
- bundlerClient,
570
- smartAccount,
571
- accountRewardsContractAddress,
572
- pid
573
- });
574
567
  return {
575
568
  success: false,
576
569
  message: "Missing crucial information"
@@ -775,11 +768,52 @@ function useUpdateUserPid() {
775
768
  );
776
769
  }
777
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
+
778
812
  // src/utils/anymals/useMintAnymalNFT.ts
779
813
  import { encodeFunctionData as encodeFunctionData2, parseGwei as parseGwei2 } from "viem";
780
- import { useCallback as useCallback7 } from "react";
814
+ import { useCallback as useCallback8 } from "react";
781
815
  function useMintAnymalNFT() {
782
- return useCallback7(
816
+ return useCallback8(
783
817
  async (pid, nftId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
784
818
  if (!dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !validationContractAddress) {
785
819
  return {
@@ -818,9 +852,9 @@ function useMintAnymalNFT() {
818
852
  }
819
853
 
820
854
  // src/utils/anymals/useAddAnymalToDatabase.ts
821
- import { useCallback as useCallback8 } from "react";
855
+ import { useCallback as useCallback9 } from "react";
822
856
  function useAddAnymalToDatabase() {
823
- return useCallback8(
857
+ return useCallback9(
824
858
  async (dbAuthToken, endpoint, anymalData) => {
825
859
  if (!dbAuthToken) {
826
860
  return {
@@ -885,9 +919,9 @@ function useAddAnymalToDatabase() {
885
919
  }
886
920
 
887
921
  // src/utils/anymals/useDeleteAnymalFromDatabase.ts
888
- import { useCallback as useCallback9 } from "react";
922
+ import { useCallback as useCallback10 } from "react";
889
923
  function useDeleteAnymalFromDatabase() {
890
- return useCallback9(
924
+ return useCallback10(
891
925
  async (dbAuthToken, endpoint, anymalDocID) => {
892
926
  if (!dbAuthToken || !endpoint || !anymalDocID) return;
893
927
  try {
@@ -925,9 +959,9 @@ function useDeleteAnymalFromDatabase() {
925
959
  }
926
960
 
927
961
  // src/utils/anymals/useSaveAnymalMetadata.ts
928
- import { useCallback as useCallback10 } from "react";
962
+ import { useCallback as useCallback11 } from "react";
929
963
  function useSaveAnymalMetadata() {
930
- return useCallback10(
964
+ return useCallback11(
931
965
  async (idToken, publicKey, nftMetadataInput, authServiceBaseUrl) => {
932
966
  const response = await fetch(`${authServiceBaseUrl}/process-nft`, {
933
967
  method: "POST",
@@ -954,9 +988,9 @@ function useSaveAnymalMetadata() {
954
988
  }
955
989
 
956
990
  // src/utils/anymals/useUpdateAnymalWithNFT.ts
957
- import { useCallback as useCallback11 } from "react";
991
+ import { useCallback as useCallback12 } from "react";
958
992
  function useUpdateAnymalWithNFT() {
959
- return useCallback11(
993
+ return useCallback12(
960
994
  async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
961
995
  if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
962
996
  return {
@@ -1003,7 +1037,7 @@ function useUpdateAnymalWithNFT() {
1003
1037
  }
1004
1038
 
1005
1039
  // src/utils/anymals/useUploadAnymalImage.ts
1006
- import { useCallback as useCallback12 } from "react";
1040
+ import { useCallback as useCallback13 } from "react";
1007
1041
 
1008
1042
  // src/helpers/UploadImageHelper.tsx
1009
1043
  function resizeImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
@@ -1060,7 +1094,7 @@ function toBase64(file) {
1060
1094
 
1061
1095
  // src/utils/anymals/useUploadAnymalImage.ts
1062
1096
  function useUploadAnymalImage() {
1063
- return useCallback12(
1097
+ return useCallback13(
1064
1098
  async (imageFile, type, idToken, publicKey, authServiceBaseUrl) => {
1065
1099
  if (!imageFile || !idToken) {
1066
1100
  return {
@@ -1115,10 +1149,10 @@ function useUploadAnymalImage() {
1115
1149
  }
1116
1150
 
1117
1151
  // src/utils/balance/useFetchBalance.ts
1118
- import { useCallback as useCallback13 } from "react";
1152
+ import { useCallback as useCallback14 } from "react";
1119
1153
  import { erc20Abi, getAddress } from "viem";
1120
1154
  function useFetchBalance() {
1121
- return useCallback13(
1155
+ return useCallback14(
1122
1156
  async (publicClient, walletAddress, kibbleTokenAddress) => {
1123
1157
  try {
1124
1158
  const balance = await publicClient.readContract({
@@ -1144,6 +1178,7 @@ export {
1144
1178
  useMintAnymalNFT,
1145
1179
  useSaveAnymalMetadata,
1146
1180
  useUpdateAnymalWithNFT,
1181
+ useUpdateUserAsVerified,
1147
1182
  useUpdateUserEmail,
1148
1183
  useUpdateUserPid,
1149
1184
  useUploadAnymalImage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.6",
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
+ }
@@ -21,13 +21,6 @@ export function useVerifyAccount() {
21
21
  !accountRewardsContractAddress ||
22
22
  !pid
23
23
  ) {
24
- console.log({
25
- dbAuthToken,
26
- bundlerClient,
27
- smartAccount,
28
- accountRewardsContractAddress,
29
- pid,
30
- });
31
24
  return {
32
25
  success: false,
33
26
  message: "Missing crucial information",