anymal-protocol 1.0.2 → 1.0.3
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +51 -0
- package/dist/index.mjs +50 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -30,4 +30,8 @@ declare function useSaveAnymalMetadata(): (idToken: string, publicKey: string, n
|
|
|
30
30
|
message: any;
|
|
31
31
|
}>;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
declare function useUpdateAnymalWithNFT(): (anymalPassportId: string, anymalDocId: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useDeleteAnymalFromDatabase, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useVerifyAccount };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,4 +30,8 @@ declare function useSaveAnymalMetadata(): (idToken: string, publicKey: string, n
|
|
|
30
30
|
message: any;
|
|
31
31
|
}>;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
declare function useUpdateAnymalWithNFT(): (anymalPassportId: string, anymalDocId: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useDeleteAnymalFromDatabase, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useVerifyAccount };
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
useDeleteAnymalFromDatabase: () => useDeleteAnymalFromDatabase,
|
|
25
25
|
useMintAnymalNFT: () => useMintAnymalNFT,
|
|
26
26
|
useSaveAnymalMetadata: () => useSaveAnymalMetadata,
|
|
27
|
+
useUpdateAnymalWithNFT: () => useUpdateAnymalWithNFT,
|
|
27
28
|
useVerifyAccount: () => useVerifyAccount
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -806,11 +807,61 @@ function useSaveAnymalMetadata() {
|
|
|
806
807
|
[]
|
|
807
808
|
);
|
|
808
809
|
}
|
|
810
|
+
|
|
811
|
+
// src/utils/anymals/useUpdateAnymalWithNFT.ts
|
|
812
|
+
var import_react6 = require("react");
|
|
813
|
+
function useUpdateAnymalWithNFT() {
|
|
814
|
+
return (0, import_react6.useCallback)(
|
|
815
|
+
async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
|
|
816
|
+
if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
|
|
817
|
+
return {
|
|
818
|
+
success: false
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
try {
|
|
822
|
+
const mutation = `
|
|
823
|
+
mutation {
|
|
824
|
+
update_Anymal(
|
|
825
|
+
docID: [${JSON.stringify(anymalDocId)}],
|
|
826
|
+
input: {
|
|
827
|
+
passportID: "${anymalPassportId}"
|
|
828
|
+
}
|
|
829
|
+
) {
|
|
830
|
+
passportID
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
`;
|
|
834
|
+
const response = await fetch(endpoint, {
|
|
835
|
+
method: "POST",
|
|
836
|
+
headers: {
|
|
837
|
+
"Content-Type": "application/json",
|
|
838
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
839
|
+
},
|
|
840
|
+
body: JSON.stringify({ query: mutation })
|
|
841
|
+
});
|
|
842
|
+
if (!response.ok) {
|
|
843
|
+
return { success: false };
|
|
844
|
+
}
|
|
845
|
+
const { errors } = await response.json();
|
|
846
|
+
if (errors) {
|
|
847
|
+
console.log(`GQL error: ${JSON.stringify(errors)}`);
|
|
848
|
+
return { success: false };
|
|
849
|
+
}
|
|
850
|
+
return { success: true };
|
|
851
|
+
} catch (error) {
|
|
852
|
+
console.error("Error updating Anymal with NFT ID:", error);
|
|
853
|
+
return { success: false };
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
[]
|
|
857
|
+
);
|
|
858
|
+
}
|
|
809
859
|
// Annotate the CommonJS export names for ESM import in node:
|
|
810
860
|
0 && (module.exports = {
|
|
811
861
|
useAddAnymalToDatabase,
|
|
812
862
|
useDeleteAnymalFromDatabase,
|
|
813
863
|
useMintAnymalNFT,
|
|
814
864
|
useSaveAnymalMetadata,
|
|
865
|
+
useUpdateAnymalWithNFT,
|
|
815
866
|
useVerifyAccount
|
|
816
867
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -776,10 +776,60 @@ function useSaveAnymalMetadata() {
|
|
|
776
776
|
[]
|
|
777
777
|
);
|
|
778
778
|
}
|
|
779
|
+
|
|
780
|
+
// src/utils/anymals/useUpdateAnymalWithNFT.ts
|
|
781
|
+
import { useCallback as useCallback6 } from "react";
|
|
782
|
+
function useUpdateAnymalWithNFT() {
|
|
783
|
+
return useCallback6(
|
|
784
|
+
async (anymalPassportId, anymalDocId, dbAuthToken, endpoint) => {
|
|
785
|
+
if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
|
|
786
|
+
return {
|
|
787
|
+
success: false
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
try {
|
|
791
|
+
const mutation = `
|
|
792
|
+
mutation {
|
|
793
|
+
update_Anymal(
|
|
794
|
+
docID: [${JSON.stringify(anymalDocId)}],
|
|
795
|
+
input: {
|
|
796
|
+
passportID: "${anymalPassportId}"
|
|
797
|
+
}
|
|
798
|
+
) {
|
|
799
|
+
passportID
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
`;
|
|
803
|
+
const response = await fetch(endpoint, {
|
|
804
|
+
method: "POST",
|
|
805
|
+
headers: {
|
|
806
|
+
"Content-Type": "application/json",
|
|
807
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
808
|
+
},
|
|
809
|
+
body: JSON.stringify({ query: mutation })
|
|
810
|
+
});
|
|
811
|
+
if (!response.ok) {
|
|
812
|
+
return { success: false };
|
|
813
|
+
}
|
|
814
|
+
const { errors } = await response.json();
|
|
815
|
+
if (errors) {
|
|
816
|
+
console.log(`GQL error: ${JSON.stringify(errors)}`);
|
|
817
|
+
return { success: false };
|
|
818
|
+
}
|
|
819
|
+
return { success: true };
|
|
820
|
+
} catch (error) {
|
|
821
|
+
console.error("Error updating Anymal with NFT ID:", error);
|
|
822
|
+
return { success: false };
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
[]
|
|
826
|
+
);
|
|
827
|
+
}
|
|
779
828
|
export {
|
|
780
829
|
useAddAnymalToDatabase,
|
|
781
830
|
useDeleteAnymalFromDatabase,
|
|
782
831
|
useMintAnymalNFT,
|
|
783
832
|
useSaveAnymalMetadata,
|
|
833
|
+
useUpdateAnymalWithNFT,
|
|
784
834
|
useVerifyAccount
|
|
785
835
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from "./utils/anymals/useMintAnymalNFT";
|
|
|
3
3
|
export * from "./utils/anymals/useAddAnymalToDatabase";
|
|
4
4
|
export * from "./utils/anymals/useDeleteAnymalFromDatabase";
|
|
5
5
|
export * from "./utils/anymals/useSaveAnymalMetadata";
|
|
6
|
+
export * from "./utils/anymals/useUpdateAnymalWithNFT";
|
|
6
7
|
export * from "./types/Anymal";
|