anymal-protocol 1.0.11 → 1.0.12
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 +58 -2
- package/dist/index.mjs +57 -2
- package/package.json +2 -1
- package/src/index.ts +2 -0
- 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,
|
|
@@ -1234,11 +1235,65 @@ function useUploadAnymalImage() {
|
|
|
1234
1235
|
);
|
|
1235
1236
|
}
|
|
1236
1237
|
|
|
1237
|
-
// src/utils/
|
|
1238
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
1238
1239
|
var import_react15 = require("react");
|
|
1240
|
+
var import_uuid = require("uuid");
|
|
1241
|
+
function useCreateUserAppData() {
|
|
1242
|
+
return (0, import_react15.useCallback)(
|
|
1243
|
+
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1244
|
+
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1245
|
+
const appValues = {
|
|
1246
|
+
id: (0, import_uuid.v4)(),
|
|
1247
|
+
userPid: pid,
|
|
1248
|
+
appId,
|
|
1249
|
+
settings: {
|
|
1250
|
+
darkMode: false
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
try {
|
|
1254
|
+
const mutation = `
|
|
1255
|
+
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1256
|
+
create_UserAppSettings (input: $input) {
|
|
1257
|
+
id
|
|
1258
|
+
userPid
|
|
1259
|
+
appId
|
|
1260
|
+
settings
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
`;
|
|
1264
|
+
const variables = {
|
|
1265
|
+
input: [appValues]
|
|
1266
|
+
};
|
|
1267
|
+
const response = await fetch(endpoint, {
|
|
1268
|
+
method: "POST",
|
|
1269
|
+
headers: {
|
|
1270
|
+
"Content-Type": "application/json",
|
|
1271
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1272
|
+
},
|
|
1273
|
+
body: JSON.stringify({ query: mutation, variables })
|
|
1274
|
+
});
|
|
1275
|
+
if (!response.ok) {
|
|
1276
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1277
|
+
}
|
|
1278
|
+
const { data, errors } = await response.json();
|
|
1279
|
+
if (errors) {
|
|
1280
|
+
return [];
|
|
1281
|
+
}
|
|
1282
|
+
return data.create_UserAppSettings[0];
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
console.error("Error creating application:", error);
|
|
1285
|
+
return [];
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
[]
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// src/utils/balance/useFetchBalance.ts
|
|
1293
|
+
var import_react16 = require("react");
|
|
1239
1294
|
var import_viem3 = require("viem");
|
|
1240
1295
|
function useFetchBalance() {
|
|
1241
|
-
return (0,
|
|
1296
|
+
return (0, import_react16.useCallback)(
|
|
1242
1297
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
1243
1298
|
try {
|
|
1244
1299
|
const balance = await publicClient.readContract({
|
|
@@ -1258,6 +1313,7 @@ function useFetchBalance() {
|
|
|
1258
1313
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1259
1314
|
0 && (module.exports = {
|
|
1260
1315
|
useAddAnymalToDatabase,
|
|
1316
|
+
useCreateUserAppData,
|
|
1261
1317
|
useCreateWeb3Account,
|
|
1262
1318
|
useDeleteAnymalFromDatabase,
|
|
1263
1319
|
useFetchBalance,
|
package/dist/index.mjs
CHANGED
|
@@ -1194,11 +1194,65 @@ function useUploadAnymalImage() {
|
|
|
1194
1194
|
);
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
|
-
// src/utils/
|
|
1197
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
1198
1198
|
import { useCallback as useCallback15 } from "react";
|
|
1199
|
+
import { v4 as uuid } from "uuid";
|
|
1200
|
+
function useCreateUserAppData() {
|
|
1201
|
+
return useCallback15(
|
|
1202
|
+
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1203
|
+
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1204
|
+
const appValues = {
|
|
1205
|
+
id: uuid(),
|
|
1206
|
+
userPid: pid,
|
|
1207
|
+
appId,
|
|
1208
|
+
settings: {
|
|
1209
|
+
darkMode: false
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
try {
|
|
1213
|
+
const mutation = `
|
|
1214
|
+
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1215
|
+
create_UserAppSettings (input: $input) {
|
|
1216
|
+
id
|
|
1217
|
+
userPid
|
|
1218
|
+
appId
|
|
1219
|
+
settings
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
`;
|
|
1223
|
+
const variables = {
|
|
1224
|
+
input: [appValues]
|
|
1225
|
+
};
|
|
1226
|
+
const response = await fetch(endpoint, {
|
|
1227
|
+
method: "POST",
|
|
1228
|
+
headers: {
|
|
1229
|
+
"Content-Type": "application/json",
|
|
1230
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1231
|
+
},
|
|
1232
|
+
body: JSON.stringify({ query: mutation, variables })
|
|
1233
|
+
});
|
|
1234
|
+
if (!response.ok) {
|
|
1235
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1236
|
+
}
|
|
1237
|
+
const { data, errors } = await response.json();
|
|
1238
|
+
if (errors) {
|
|
1239
|
+
return [];
|
|
1240
|
+
}
|
|
1241
|
+
return data.create_UserAppSettings[0];
|
|
1242
|
+
} catch (error) {
|
|
1243
|
+
console.error("Error creating application:", error);
|
|
1244
|
+
return [];
|
|
1245
|
+
}
|
|
1246
|
+
},
|
|
1247
|
+
[]
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// src/utils/balance/useFetchBalance.ts
|
|
1252
|
+
import { useCallback as useCallback16 } from "react";
|
|
1199
1253
|
import { erc20Abi, getAddress } from "viem";
|
|
1200
1254
|
function useFetchBalance() {
|
|
1201
|
-
return
|
|
1255
|
+
return useCallback16(
|
|
1202
1256
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
1203
1257
|
try {
|
|
1204
1258
|
const balance = await publicClient.readContract({
|
|
@@ -1217,6 +1271,7 @@ function useFetchBalance() {
|
|
|
1217
1271
|
}
|
|
1218
1272
|
export {
|
|
1219
1273
|
useAddAnymalToDatabase,
|
|
1274
|
+
useCreateUserAppData,
|
|
1220
1275
|
useCreateWeb3Account,
|
|
1221
1276
|
useDeleteAnymalFromDatabase,
|
|
1222
1277
|
useFetchBalance,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anymal-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
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";
|
|
@@ -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
|
+
}
|