anymal-protocol 1.0.12 → 1.0.14

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.
@@ -1,59 +0,0 @@
1
- import { useCallback } from "react";
2
-
3
- export function useUpdateAnymalWithNFT() {
4
- return useCallback(
5
- async (
6
- anymalPassportId: string,
7
- anymalDocId: string,
8
- dbAuthToken: string,
9
- endpoint: string
10
- ): Promise<{ success: boolean }> => {
11
- if (!dbAuthToken || !anymalPassportId || !anymalDocId || !endpoint) {
12
- return {
13
- success: false,
14
- };
15
- }
16
-
17
- try {
18
- const mutation = `
19
- mutation {
20
- update_Anymal(
21
- docID: [${JSON.stringify(anymalDocId)}],
22
- input: {
23
- passportID: "${anymalPassportId}"
24
- }
25
- ) {
26
- passportID
27
- }
28
- }
29
- `;
30
-
31
- const response = await fetch(endpoint, {
32
- method: "POST",
33
- headers: {
34
- "Content-Type": "application/json",
35
- Authorization: `Bearer ${dbAuthToken}`,
36
- },
37
- body: JSON.stringify({ query: mutation }),
38
- });
39
-
40
- if (!response.ok) {
41
- return { success: false };
42
- }
43
-
44
- const { errors } = await response.json();
45
-
46
- if (errors) {
47
- console.log(`GQL error: ${JSON.stringify(errors)}`);
48
- return { success: false };
49
- }
50
-
51
- return { success: true };
52
- } catch (error) {
53
- console.error("Error updating Anymal with NFT ID:", error);
54
- return { success: false };
55
- }
56
- },
57
- []
58
- );
59
- }
@@ -1,70 +0,0 @@
1
- import { useCallback } from "react";
2
- import { prepareImage } from "../../helpers/UploadImageHelper";
3
-
4
- export function useUploadAnymalImage() {
5
- return useCallback(
6
- async (
7
- imageFile: File,
8
- type: string,
9
- idToken: string,
10
- publicKey: string,
11
- authServiceBaseUrl: string
12
- ) => {
13
- if (!imageFile || !idToken) {
14
- return {
15
- success: false,
16
- message: "No image file selected or not authenticated.",
17
- url: null,
18
- type,
19
- };
20
- }
21
-
22
- try {
23
- const base64Image = await prepareImage(imageFile);
24
-
25
- const payload = {
26
- appPubKey: publicKey,
27
- imageData: base64Image,
28
- imageName: imageFile.name.split(".")[0],
29
- };
30
-
31
- const response = await fetch(`${authServiceBaseUrl}/process-image`, {
32
- method: "POST",
33
- headers: {
34
- "Content-Type": "application/json",
35
- Authorization: `Bearer ${idToken}`,
36
- },
37
- body: JSON.stringify(payload),
38
- });
39
-
40
- const data = await response.json();
41
-
42
- if (response.ok) {
43
- return {
44
- success: true,
45
- message: "Image uploaded successfully.",
46
- url: data.ipfsUrl,
47
- type,
48
- };
49
- } else {
50
- return {
51
- success: false,
52
- message: "Image failed to upload.",
53
- url: null,
54
- type,
55
- };
56
- }
57
- } catch (error) {
58
- return {
59
- success: false,
60
- message: `An error occurred during image upload: ${
61
- (error as Error).message
62
- }`,
63
- url: null,
64
- type,
65
- };
66
- }
67
- },
68
- []
69
- );
70
- }
@@ -1,66 +0,0 @@
1
- import { useCallback } from "react";
2
- import { v4 as uuid } from "uuid";
3
-
4
- export function useCreateUserAppData() {
5
- return useCallback(
6
- async (
7
- appId: string,
8
- pid: string,
9
- dbAuthToken: string,
10
- endpoint: string
11
- ) => {
12
- if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
13
-
14
- const appValues = {
15
- id: uuid(),
16
- userPid: pid,
17
- appId: appId,
18
- settings: {
19
- darkMode: false,
20
- },
21
- };
22
-
23
- try {
24
- const mutation = `
25
- mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
26
- create_UserAppSettings (input: $input) {
27
- id
28
- userPid
29
- appId
30
- settings
31
- }
32
- }
33
- `;
34
-
35
- const variables = {
36
- input: [appValues],
37
- };
38
-
39
- const response = await fetch(endpoint, {
40
- method: "POST",
41
- headers: {
42
- "Content-Type": "application/json",
43
- Authorization: `Bearer ${dbAuthToken}`,
44
- },
45
- body: JSON.stringify({ query: mutation, variables }),
46
- });
47
-
48
- if (!response.ok) {
49
- throw new Error(`HTTP error! Status: ${response.status}`);
50
- }
51
-
52
- const { data, errors } = await response.json();
53
-
54
- if (errors) {
55
- return [];
56
- }
57
-
58
- return data.create_UserAppSettings[0];
59
- } catch (error) {
60
- console.error("Error creating application:", error);
61
- return [];
62
- }
63
- },
64
- []
65
- );
66
- }
@@ -1,26 +0,0 @@
1
- import { useCallback } from "react";
2
- import { erc20Abi, getAddress } from "viem";
3
-
4
- export function useFetchBalance() {
5
- return useCallback(
6
- async (
7
- publicClient: any,
8
- walletAddress: string,
9
- kibbleTokenAddress: string
10
- ) => {
11
- try {
12
- const balance = await publicClient.readContract({
13
- address: getAddress(kibbleTokenAddress),
14
- abi: erc20Abi,
15
- functionName: "balanceOf",
16
- args: [getAddress(walletAddress)],
17
- });
18
-
19
- return Number(balance);
20
- } catch (error) {
21
- console.error("Failed to fetch token balance:", error);
22
- }
23
- },
24
- []
25
- );
26
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["DOM", "ESNext"],
6
- "declaration": true,
7
- "declarationDir": "dist/types",
8
- "outDir": "dist",
9
- "strict": true,
10
- "jsx": "react-jsx",
11
- "moduleResolution": "node",
12
- "esModuleInterop": true,
13
- "skipLibCheck": true
14
- },
15
- "include": ["src/**/*"],
16
- "exclude": ["node_modules", "dist"]
17
- }