anymal-protocol 1.0.11 → 1.0.13
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +67 -10
- package/dist/index.mjs +66 -10
- package/package.json +2 -1
- package/src/index.ts +2 -0
- package/src/utils/account/useFetchUserData.ts +9 -8
- package/src/utils/application/useCreateUserAppData.ts +66 -0
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,8 @@ declare function useUploadAnymalImage(): (imageFile: File, type: string, idToken
|
|
|
60
60
|
type: string;
|
|
61
61
|
}>;
|
|
62
62
|
|
|
63
|
+
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<any>;
|
|
64
|
+
|
|
63
65
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
64
66
|
|
|
65
|
-
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
67
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ declare function useUploadAnymalImage(): (imageFile: File, type: string, idToken
|
|
|
60
60
|
type: string;
|
|
61
61
|
}>;
|
|
62
62
|
|
|
63
|
+
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<any>;
|
|
64
|
+
|
|
63
65
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
64
66
|
|
|
65
|
-
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
67
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, useAddAnymalToDatabase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchUserData, useMintAnymalNFT, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
useAddAnymalToDatabase: () => useAddAnymalToDatabase,
|
|
24
|
+
useCreateUserAppData: () => useCreateUserAppData,
|
|
24
25
|
useCreateWeb3Account: () => useCreateWeb3Account,
|
|
25
26
|
useDeleteAnymalFromDatabase: () => useDeleteAnymalFromDatabase,
|
|
26
27
|
useFetchBalance: () => useFetchBalance,
|
|
@@ -692,15 +693,16 @@ function useFetchUserData() {
|
|
|
692
693
|
return (0, import_react4.useCallback)(async (dbAuthToken, endpoint) => {
|
|
693
694
|
try {
|
|
694
695
|
const query = `
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
696
|
+
query User {
|
|
697
|
+
User {
|
|
698
|
+
_docID
|
|
699
|
+
pid
|
|
700
|
+
email
|
|
701
|
+
name
|
|
702
|
+
isVerified
|
|
703
|
+
accountType
|
|
704
|
+
}
|
|
702
705
|
}
|
|
703
|
-
}
|
|
704
706
|
`;
|
|
705
707
|
const response = await fetch(endpoint, {
|
|
706
708
|
method: "POST",
|
|
@@ -1234,11 +1236,65 @@ function useUploadAnymalImage() {
|
|
|
1234
1236
|
);
|
|
1235
1237
|
}
|
|
1236
1238
|
|
|
1237
|
-
// src/utils/
|
|
1239
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
1238
1240
|
var import_react15 = require("react");
|
|
1241
|
+
var import_uuid = require("uuid");
|
|
1242
|
+
function useCreateUserAppData() {
|
|
1243
|
+
return (0, import_react15.useCallback)(
|
|
1244
|
+
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1245
|
+
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1246
|
+
const appValues = {
|
|
1247
|
+
id: (0, import_uuid.v4)(),
|
|
1248
|
+
userPid: pid,
|
|
1249
|
+
appId,
|
|
1250
|
+
settings: {
|
|
1251
|
+
darkMode: false
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
try {
|
|
1255
|
+
const mutation = `
|
|
1256
|
+
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1257
|
+
create_UserAppSettings (input: $input) {
|
|
1258
|
+
id
|
|
1259
|
+
userPid
|
|
1260
|
+
appId
|
|
1261
|
+
settings
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
`;
|
|
1265
|
+
const variables = {
|
|
1266
|
+
input: [appValues]
|
|
1267
|
+
};
|
|
1268
|
+
const response = await fetch(endpoint, {
|
|
1269
|
+
method: "POST",
|
|
1270
|
+
headers: {
|
|
1271
|
+
"Content-Type": "application/json",
|
|
1272
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1273
|
+
},
|
|
1274
|
+
body: JSON.stringify({ query: mutation, variables })
|
|
1275
|
+
});
|
|
1276
|
+
if (!response.ok) {
|
|
1277
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1278
|
+
}
|
|
1279
|
+
const { data, errors } = await response.json();
|
|
1280
|
+
if (errors) {
|
|
1281
|
+
return [];
|
|
1282
|
+
}
|
|
1283
|
+
return data.create_UserAppSettings[0];
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
console.error("Error creating application:", error);
|
|
1286
|
+
return [];
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
[]
|
|
1290
|
+
);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/utils/balance/useFetchBalance.ts
|
|
1294
|
+
var import_react16 = require("react");
|
|
1239
1295
|
var import_viem3 = require("viem");
|
|
1240
1296
|
function useFetchBalance() {
|
|
1241
|
-
return (0,
|
|
1297
|
+
return (0, import_react16.useCallback)(
|
|
1242
1298
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
1243
1299
|
try {
|
|
1244
1300
|
const balance = await publicClient.readContract({
|
|
@@ -1258,6 +1314,7 @@ function useFetchBalance() {
|
|
|
1258
1314
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1259
1315
|
0 && (module.exports = {
|
|
1260
1316
|
useAddAnymalToDatabase,
|
|
1317
|
+
useCreateUserAppData,
|
|
1261
1318
|
useCreateWeb3Account,
|
|
1262
1319
|
useDeleteAnymalFromDatabase,
|
|
1263
1320
|
useFetchBalance,
|
package/dist/index.mjs
CHANGED
|
@@ -652,15 +652,16 @@ function useFetchUserData() {
|
|
|
652
652
|
return useCallback4(async (dbAuthToken, endpoint) => {
|
|
653
653
|
try {
|
|
654
654
|
const query = `
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
655
|
+
query User {
|
|
656
|
+
User {
|
|
657
|
+
_docID
|
|
658
|
+
pid
|
|
659
|
+
email
|
|
660
|
+
name
|
|
661
|
+
isVerified
|
|
662
|
+
accountType
|
|
663
|
+
}
|
|
662
664
|
}
|
|
663
|
-
}
|
|
664
665
|
`;
|
|
665
666
|
const response = await fetch(endpoint, {
|
|
666
667
|
method: "POST",
|
|
@@ -1194,11 +1195,65 @@ function useUploadAnymalImage() {
|
|
|
1194
1195
|
);
|
|
1195
1196
|
}
|
|
1196
1197
|
|
|
1197
|
-
// src/utils/
|
|
1198
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
1198
1199
|
import { useCallback as useCallback15 } from "react";
|
|
1200
|
+
import { v4 as uuid } from "uuid";
|
|
1201
|
+
function useCreateUserAppData() {
|
|
1202
|
+
return useCallback15(
|
|
1203
|
+
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1204
|
+
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1205
|
+
const appValues = {
|
|
1206
|
+
id: uuid(),
|
|
1207
|
+
userPid: pid,
|
|
1208
|
+
appId,
|
|
1209
|
+
settings: {
|
|
1210
|
+
darkMode: false
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
try {
|
|
1214
|
+
const mutation = `
|
|
1215
|
+
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1216
|
+
create_UserAppSettings (input: $input) {
|
|
1217
|
+
id
|
|
1218
|
+
userPid
|
|
1219
|
+
appId
|
|
1220
|
+
settings
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
`;
|
|
1224
|
+
const variables = {
|
|
1225
|
+
input: [appValues]
|
|
1226
|
+
};
|
|
1227
|
+
const response = await fetch(endpoint, {
|
|
1228
|
+
method: "POST",
|
|
1229
|
+
headers: {
|
|
1230
|
+
"Content-Type": "application/json",
|
|
1231
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1232
|
+
},
|
|
1233
|
+
body: JSON.stringify({ query: mutation, variables })
|
|
1234
|
+
});
|
|
1235
|
+
if (!response.ok) {
|
|
1236
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1237
|
+
}
|
|
1238
|
+
const { data, errors } = await response.json();
|
|
1239
|
+
if (errors) {
|
|
1240
|
+
return [];
|
|
1241
|
+
}
|
|
1242
|
+
return data.create_UserAppSettings[0];
|
|
1243
|
+
} catch (error) {
|
|
1244
|
+
console.error("Error creating application:", error);
|
|
1245
|
+
return [];
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1248
|
+
[]
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// src/utils/balance/useFetchBalance.ts
|
|
1253
|
+
import { useCallback as useCallback16 } from "react";
|
|
1199
1254
|
import { erc20Abi, getAddress } from "viem";
|
|
1200
1255
|
function useFetchBalance() {
|
|
1201
|
-
return
|
|
1256
|
+
return useCallback16(
|
|
1202
1257
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
1203
1258
|
try {
|
|
1204
1259
|
const balance = await publicClient.readContract({
|
|
@@ -1217,6 +1272,7 @@ function useFetchBalance() {
|
|
|
1217
1272
|
}
|
|
1218
1273
|
export {
|
|
1219
1274
|
useAddAnymalToDatabase,
|
|
1275
|
+
useCreateUserAppData,
|
|
1220
1276
|
useCreateWeb3Account,
|
|
1221
1277
|
useDeleteAnymalFromDatabase,
|
|
1222
1278
|
useFetchBalance,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anymal-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"react": "^19.0.0",
|
|
17
17
|
"react-dom": "^19.0.0",
|
|
18
|
+
"uuid": "^11.0.5",
|
|
18
19
|
"viem": "^2.22.8"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -14,5 +14,7 @@ export * from "./utils/anymals/useSaveAnymalMetadata";
|
|
|
14
14
|
export * from "./utils/anymals/useUpdateAnymalWithNFT";
|
|
15
15
|
export * from "./utils/anymals/useUploadAnymalImage";
|
|
16
16
|
|
|
17
|
+
export * from "./utils/application/useCreateUserAppData";
|
|
18
|
+
|
|
17
19
|
export * from "./utils/balance/useFetchBalance";
|
|
18
20
|
export * from "./types/Anymal";
|
|
@@ -4,15 +4,16 @@ export function useFetchUserData() {
|
|
|
4
4
|
return useCallback(async (dbAuthToken: string, endpoint: string) => {
|
|
5
5
|
try {
|
|
6
6
|
const query = `
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
query User {
|
|
8
|
+
User {
|
|
9
|
+
_docID
|
|
10
|
+
pid
|
|
11
|
+
email
|
|
12
|
+
name
|
|
13
|
+
isVerified
|
|
14
|
+
accountType
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
|
-
}
|
|
16
17
|
`;
|
|
17
18
|
|
|
18
19
|
const response = await fetch(endpoint, {
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|