anymal-protocol 1.0.60 → 1.0.61
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 +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +75 -7
- package/dist/index.mjs +72 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -61,6 +61,7 @@ interface AnymalNftMetadataInputData {
|
|
|
61
61
|
|
|
62
62
|
declare function useAddAnymalToDatabase(): (dbAuthToken: string, endpoint: string, anymalData: CreateAnymalInputData) => Promise<{
|
|
63
63
|
_docID: string | null;
|
|
64
|
+
dbCid: string | null;
|
|
64
65
|
success: boolean;
|
|
65
66
|
message: string;
|
|
66
67
|
}>;
|
|
@@ -214,6 +215,101 @@ declare function createAuthEnvelope(privateKeyHex: string, network?: Network, op
|
|
|
214
215
|
*/
|
|
215
216
|
declare function generateAppSignature(privateKeyHex: string, clientId: string, redirectUri: string, state: string): Promise<string>;
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Types of actions you can submit
|
|
220
|
+
*/
|
|
221
|
+
declare enum ActionType {
|
|
222
|
+
GRAPHQL = "GRAPHQL",
|
|
223
|
+
CONTRACT = "CONTRACT",
|
|
224
|
+
EXTERNAL = "EXTERNAL"
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Represents a single action record returned by the backend.
|
|
228
|
+
*/
|
|
229
|
+
interface ActionRecord {
|
|
230
|
+
id: string;
|
|
231
|
+
wallet: string;
|
|
232
|
+
pid: string;
|
|
233
|
+
action_id: string;
|
|
234
|
+
metadata: Record<string, any>;
|
|
235
|
+
version_cid?: string;
|
|
236
|
+
quantity: number;
|
|
237
|
+
reward_amount?: number;
|
|
238
|
+
status: 'PENDING' | 'VALIDATED' | 'CLAIMED';
|
|
239
|
+
createdAt: string;
|
|
240
|
+
validatedAt?: string | null;
|
|
241
|
+
claimedAt?: string | null;
|
|
242
|
+
claimQuantity?: number | null;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* API response for fetching action records.
|
|
246
|
+
*/
|
|
247
|
+
interface FetchActionsResponse {
|
|
248
|
+
data: ActionRecord[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Base fields sent with every action
|
|
253
|
+
*/
|
|
254
|
+
interface BaseActionPayload {
|
|
255
|
+
actionId: string;
|
|
256
|
+
timestamp: string;
|
|
257
|
+
nonce: string;
|
|
258
|
+
source: ActionType;
|
|
259
|
+
clientInfo?: {
|
|
260
|
+
userAgent?: string;
|
|
261
|
+
locale?: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Payload for GraphQL-based actions
|
|
266
|
+
*/
|
|
267
|
+
interface GraphQLActionPayload extends BaseActionPayload {
|
|
268
|
+
versionCid: string;
|
|
269
|
+
resource: string;
|
|
270
|
+
resourceId: string;
|
|
271
|
+
changedFields?: string[];
|
|
272
|
+
previousValues?: Record<string, any>;
|
|
273
|
+
mutation?: string;
|
|
274
|
+
variables?: Record<string, any>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Payload for on-chain contract actions
|
|
278
|
+
*/
|
|
279
|
+
interface ContractActionPayload extends BaseActionPayload {
|
|
280
|
+
txHash: string;
|
|
281
|
+
chainId: number;
|
|
282
|
+
contract: string;
|
|
283
|
+
functionName: string;
|
|
284
|
+
args: any[];
|
|
285
|
+
receipt: {
|
|
286
|
+
blockNumber: number;
|
|
287
|
+
status: number;
|
|
288
|
+
gasUsed: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Payload for external web-service actions
|
|
293
|
+
*/
|
|
294
|
+
interface ExternalActionPayload extends BaseActionPayload {
|
|
295
|
+
endpoint: string;
|
|
296
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
297
|
+
requestBody?: Record<string, any>;
|
|
298
|
+
responseStatus?: number;
|
|
299
|
+
responseBody?: any;
|
|
300
|
+
}
|
|
301
|
+
type ActionPayload = GraphQLActionPayload | ContractActionPayload | ExternalActionPayload;
|
|
302
|
+
interface SubmitResponse {
|
|
303
|
+
ok: boolean;
|
|
304
|
+
id: string;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Generic submission function
|
|
308
|
+
*/
|
|
309
|
+
declare function submitAction(idToken: string, pid: string, payload: ActionPayload, endpointBaseUrl: string): Promise<SubmitResponse>;
|
|
310
|
+
|
|
311
|
+
declare function useFetchActions(): (idToken: string, actionsServiceBaseUrl: string, pid: string, status?: string, limit?: number, offset?: number) => Promise<FetchActionsResponse | null>;
|
|
312
|
+
|
|
217
313
|
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
218
314
|
success: boolean;
|
|
219
315
|
data: any;
|
|
@@ -226,4 +322,4 @@ declare function useCreateOrganizationAppData(): (appId: string, pid: string, db
|
|
|
226
322
|
|
|
227
323
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
228
324
|
|
|
229
|
-
export { AUTH_API_ENDPOINTS, type AnymalNftMetadataInputData, type AuthEnvelope, type CreateAnymalInputData, type JWTOptions, NETWORK_HOSTS, Network, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
325
|
+
export { AUTH_API_ENDPOINTS, type ActionPayload, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, type GraphQLActionPayload, type JWTOptions, NETWORK_HOSTS, Network, type SubmitResponse, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ interface AnymalNftMetadataInputData {
|
|
|
61
61
|
|
|
62
62
|
declare function useAddAnymalToDatabase(): (dbAuthToken: string, endpoint: string, anymalData: CreateAnymalInputData) => Promise<{
|
|
63
63
|
_docID: string | null;
|
|
64
|
+
dbCid: string | null;
|
|
64
65
|
success: boolean;
|
|
65
66
|
message: string;
|
|
66
67
|
}>;
|
|
@@ -214,6 +215,101 @@ declare function createAuthEnvelope(privateKeyHex: string, network?: Network, op
|
|
|
214
215
|
*/
|
|
215
216
|
declare function generateAppSignature(privateKeyHex: string, clientId: string, redirectUri: string, state: string): Promise<string>;
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Types of actions you can submit
|
|
220
|
+
*/
|
|
221
|
+
declare enum ActionType {
|
|
222
|
+
GRAPHQL = "GRAPHQL",
|
|
223
|
+
CONTRACT = "CONTRACT",
|
|
224
|
+
EXTERNAL = "EXTERNAL"
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Represents a single action record returned by the backend.
|
|
228
|
+
*/
|
|
229
|
+
interface ActionRecord {
|
|
230
|
+
id: string;
|
|
231
|
+
wallet: string;
|
|
232
|
+
pid: string;
|
|
233
|
+
action_id: string;
|
|
234
|
+
metadata: Record<string, any>;
|
|
235
|
+
version_cid?: string;
|
|
236
|
+
quantity: number;
|
|
237
|
+
reward_amount?: number;
|
|
238
|
+
status: 'PENDING' | 'VALIDATED' | 'CLAIMED';
|
|
239
|
+
createdAt: string;
|
|
240
|
+
validatedAt?: string | null;
|
|
241
|
+
claimedAt?: string | null;
|
|
242
|
+
claimQuantity?: number | null;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* API response for fetching action records.
|
|
246
|
+
*/
|
|
247
|
+
interface FetchActionsResponse {
|
|
248
|
+
data: ActionRecord[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Base fields sent with every action
|
|
253
|
+
*/
|
|
254
|
+
interface BaseActionPayload {
|
|
255
|
+
actionId: string;
|
|
256
|
+
timestamp: string;
|
|
257
|
+
nonce: string;
|
|
258
|
+
source: ActionType;
|
|
259
|
+
clientInfo?: {
|
|
260
|
+
userAgent?: string;
|
|
261
|
+
locale?: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Payload for GraphQL-based actions
|
|
266
|
+
*/
|
|
267
|
+
interface GraphQLActionPayload extends BaseActionPayload {
|
|
268
|
+
versionCid: string;
|
|
269
|
+
resource: string;
|
|
270
|
+
resourceId: string;
|
|
271
|
+
changedFields?: string[];
|
|
272
|
+
previousValues?: Record<string, any>;
|
|
273
|
+
mutation?: string;
|
|
274
|
+
variables?: Record<string, any>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Payload for on-chain contract actions
|
|
278
|
+
*/
|
|
279
|
+
interface ContractActionPayload extends BaseActionPayload {
|
|
280
|
+
txHash: string;
|
|
281
|
+
chainId: number;
|
|
282
|
+
contract: string;
|
|
283
|
+
functionName: string;
|
|
284
|
+
args: any[];
|
|
285
|
+
receipt: {
|
|
286
|
+
blockNumber: number;
|
|
287
|
+
status: number;
|
|
288
|
+
gasUsed: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Payload for external web-service actions
|
|
293
|
+
*/
|
|
294
|
+
interface ExternalActionPayload extends BaseActionPayload {
|
|
295
|
+
endpoint: string;
|
|
296
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
297
|
+
requestBody?: Record<string, any>;
|
|
298
|
+
responseStatus?: number;
|
|
299
|
+
responseBody?: any;
|
|
300
|
+
}
|
|
301
|
+
type ActionPayload = GraphQLActionPayload | ContractActionPayload | ExternalActionPayload;
|
|
302
|
+
interface SubmitResponse {
|
|
303
|
+
ok: boolean;
|
|
304
|
+
id: string;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Generic submission function
|
|
308
|
+
*/
|
|
309
|
+
declare function submitAction(idToken: string, pid: string, payload: ActionPayload, endpointBaseUrl: string): Promise<SubmitResponse>;
|
|
310
|
+
|
|
311
|
+
declare function useFetchActions(): (idToken: string, actionsServiceBaseUrl: string, pid: string, status?: string, limit?: number, offset?: number) => Promise<FetchActionsResponse | null>;
|
|
312
|
+
|
|
217
313
|
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
218
314
|
success: boolean;
|
|
219
315
|
data: any;
|
|
@@ -226,4 +322,4 @@ declare function useCreateOrganizationAppData(): (appId: string, pid: string, db
|
|
|
226
322
|
|
|
227
323
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
228
324
|
|
|
229
|
-
export { AUTH_API_ENDPOINTS, type AnymalNftMetadataInputData, type AuthEnvelope, type CreateAnymalInputData, type JWTOptions, NETWORK_HOSTS, Network, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
325
|
+
export { AUTH_API_ENDPOINTS, type ActionPayload, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, type GraphQLActionPayload, type JWTOptions, NETWORK_HOSTS, Network, type SubmitResponse, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, 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
|
AUTH_API_ENDPOINTS: () => AUTH_API_ENDPOINTS,
|
|
24
|
+
ActionType: () => ActionType,
|
|
24
25
|
NETWORK_HOSTS: () => NETWORK_HOSTS,
|
|
25
26
|
Network: () => Network,
|
|
26
27
|
createAuthEnvelope: () => createAuthEnvelope,
|
|
@@ -30,6 +31,7 @@ __export(index_exports, {
|
|
|
30
31
|
generateJWT: () => generateJWT,
|
|
31
32
|
loadExistingSecp256k1PrivateKey: () => loadExistingSecp256k1PrivateKey,
|
|
32
33
|
serializePublicKeyCompressed: () => serializePublicKeyCompressed,
|
|
34
|
+
submitAction: () => submitAction,
|
|
33
35
|
useAddAnymalToDatabase: () => useAddAnymalToDatabase,
|
|
34
36
|
useApproveKibbleToken: () => useApproveKibbleToken,
|
|
35
37
|
useApproveOrgPartialPayment: () => useApproveOrgPartialPayment,
|
|
@@ -38,6 +40,7 @@ __export(index_exports, {
|
|
|
38
40
|
useCreateUserAppData: () => useCreateUserAppData,
|
|
39
41
|
useCreateWeb3Account: () => useCreateWeb3Account,
|
|
40
42
|
useDeleteAnymalFromDatabase: () => useDeleteAnymalFromDatabase,
|
|
43
|
+
useFetchActions: () => useFetchActions,
|
|
41
44
|
useFetchAnymals: () => useFetchAnymals,
|
|
42
45
|
useFetchBalance: () => useFetchBalance,
|
|
43
46
|
useFetchNotifications: () => useFetchNotifications,
|
|
@@ -1318,10 +1321,12 @@ function useAddAnymalToDatabase() {
|
|
|
1318
1321
|
return {
|
|
1319
1322
|
success: false,
|
|
1320
1323
|
message: "Authentication token is missing.",
|
|
1321
|
-
_docID: null
|
|
1324
|
+
_docID: null,
|
|
1325
|
+
dbCid: null
|
|
1322
1326
|
};
|
|
1323
1327
|
}
|
|
1324
1328
|
let anymalDocID = null;
|
|
1329
|
+
let dbCid = null;
|
|
1325
1330
|
try {
|
|
1326
1331
|
const mutation = `
|
|
1327
1332
|
mutation Create_Anymal($input: [AnymalMutationInputArg!]) {
|
|
@@ -1329,6 +1334,9 @@ function useAddAnymalToDatabase() {
|
|
|
1329
1334
|
_docID
|
|
1330
1335
|
name
|
|
1331
1336
|
passportID
|
|
1337
|
+
_version {
|
|
1338
|
+
cid
|
|
1339
|
+
}
|
|
1332
1340
|
}
|
|
1333
1341
|
}
|
|
1334
1342
|
`;
|
|
@@ -1359,15 +1367,18 @@ function useAddAnymalToDatabase() {
|
|
|
1359
1367
|
throw new Error(`GraphQL error: ${errorMessage}`);
|
|
1360
1368
|
}
|
|
1361
1369
|
anymalDocID = data.create_Anymal[0]._docID;
|
|
1370
|
+
dbCid = data.create_Anymal[0]._version[0].cid;
|
|
1362
1371
|
return {
|
|
1363
1372
|
success: true,
|
|
1364
1373
|
_docID: anymalDocID,
|
|
1374
|
+
dbCid,
|
|
1365
1375
|
message: "Anymal added to account"
|
|
1366
1376
|
};
|
|
1367
1377
|
} catch (error) {
|
|
1368
1378
|
return {
|
|
1369
1379
|
success: false,
|
|
1370
1380
|
_docID: null,
|
|
1381
|
+
dbCid: null,
|
|
1371
1382
|
message: "Error adding anymal to account"
|
|
1372
1383
|
};
|
|
1373
1384
|
}
|
|
@@ -2100,11 +2111,65 @@ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state)
|
|
|
2100
2111
|
return Buffer.from(signatureDER).toString("hex");
|
|
2101
2112
|
}
|
|
2102
2113
|
|
|
2103
|
-
// src/
|
|
2114
|
+
// src/helpers/ActionHelpers.tsx
|
|
2115
|
+
async function submitAction(idToken, pid, payload, endpointBaseUrl) {
|
|
2116
|
+
const api = endpointBaseUrl + "/actions";
|
|
2117
|
+
const response = await fetch(api, {
|
|
2118
|
+
method: "POST",
|
|
2119
|
+
headers: { "Content-Type": "application/json", "Authorization": "Bearer " + idToken },
|
|
2120
|
+
body: JSON.stringify({ actionId: payload.actionId, pid, payload })
|
|
2121
|
+
});
|
|
2122
|
+
if (!response.ok) {
|
|
2123
|
+
const err = await response.json();
|
|
2124
|
+
throw new Error(err.error || "Failed to submit action");
|
|
2125
|
+
}
|
|
2126
|
+
return response.json();
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
// src/utils/actions/useFetchActions.ts
|
|
2104
2130
|
var import_react23 = require("react");
|
|
2131
|
+
function useFetchActions() {
|
|
2132
|
+
return (0, import_react23.useCallback)(
|
|
2133
|
+
async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
|
|
2134
|
+
const params = new URLSearchParams({ pid });
|
|
2135
|
+
if (status) params.set("status", status);
|
|
2136
|
+
if (limit != null) params.set("limit", `${limit}`);
|
|
2137
|
+
if (offset != null) params.set("offset", `${offset}`);
|
|
2138
|
+
try {
|
|
2139
|
+
const response = await fetch(
|
|
2140
|
+
`${actionsServiceBaseUrl}/actions?${params.toString()}`,
|
|
2141
|
+
{
|
|
2142
|
+
method: "GET",
|
|
2143
|
+
headers: {
|
|
2144
|
+
"Content-Type": "application/json",
|
|
2145
|
+
Authorization: "Bearer " + idToken
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
);
|
|
2149
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
2150
|
+
return await response.json();
|
|
2151
|
+
} catch (error) {
|
|
2152
|
+
console.error("useFetchActions error:", error);
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2155
|
+
},
|
|
2156
|
+
[]
|
|
2157
|
+
);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
// src/types/Actions.ts
|
|
2161
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
2162
|
+
ActionType2["GRAPHQL"] = "GRAPHQL";
|
|
2163
|
+
ActionType2["CONTRACT"] = "CONTRACT";
|
|
2164
|
+
ActionType2["EXTERNAL"] = "EXTERNAL";
|
|
2165
|
+
return ActionType2;
|
|
2166
|
+
})(ActionType || {});
|
|
2167
|
+
|
|
2168
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
2169
|
+
var import_react24 = require("react");
|
|
2105
2170
|
var import_uuid2 = require("uuid");
|
|
2106
2171
|
function useCreateUserAppData() {
|
|
2107
|
-
return (0,
|
|
2172
|
+
return (0, import_react24.useCallback)(
|
|
2108
2173
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
2109
2174
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
2110
2175
|
const appValues = {
|
|
@@ -2159,10 +2224,10 @@ function useCreateUserAppData() {
|
|
|
2159
2224
|
}
|
|
2160
2225
|
|
|
2161
2226
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
2162
|
-
var
|
|
2227
|
+
var import_react25 = require("react");
|
|
2163
2228
|
var import_uuid3 = require("uuid");
|
|
2164
2229
|
function useCreateOrganizationAppData() {
|
|
2165
|
-
return (0,
|
|
2230
|
+
return (0, import_react25.useCallback)(
|
|
2166
2231
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
2167
2232
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
2168
2233
|
const appValues = {
|
|
@@ -2216,10 +2281,10 @@ function useCreateOrganizationAppData() {
|
|
|
2216
2281
|
}
|
|
2217
2282
|
|
|
2218
2283
|
// src/utils/balance/useFetchBalance.ts
|
|
2219
|
-
var
|
|
2284
|
+
var import_react26 = require("react");
|
|
2220
2285
|
var import_viem9 = require("viem");
|
|
2221
2286
|
function useFetchBalance() {
|
|
2222
|
-
return (0,
|
|
2287
|
+
return (0, import_react26.useCallback)(
|
|
2223
2288
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2224
2289
|
try {
|
|
2225
2290
|
const balance = await publicClient.readContract({
|
|
@@ -2239,6 +2304,7 @@ function useFetchBalance() {
|
|
|
2239
2304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2240
2305
|
0 && (module.exports = {
|
|
2241
2306
|
AUTH_API_ENDPOINTS,
|
|
2307
|
+
ActionType,
|
|
2242
2308
|
NETWORK_HOSTS,
|
|
2243
2309
|
Network,
|
|
2244
2310
|
createAuthEnvelope,
|
|
@@ -2248,6 +2314,7 @@ function useFetchBalance() {
|
|
|
2248
2314
|
generateJWT,
|
|
2249
2315
|
loadExistingSecp256k1PrivateKey,
|
|
2250
2316
|
serializePublicKeyCompressed,
|
|
2317
|
+
submitAction,
|
|
2251
2318
|
useAddAnymalToDatabase,
|
|
2252
2319
|
useApproveKibbleToken,
|
|
2253
2320
|
useApproveOrgPartialPayment,
|
|
@@ -2256,6 +2323,7 @@ function useFetchBalance() {
|
|
|
2256
2323
|
useCreateUserAppData,
|
|
2257
2324
|
useCreateWeb3Account,
|
|
2258
2325
|
useDeleteAnymalFromDatabase,
|
|
2326
|
+
useFetchActions,
|
|
2259
2327
|
useFetchAnymals,
|
|
2260
2328
|
useFetchBalance,
|
|
2261
2329
|
useFetchNotifications,
|
package/dist/index.mjs
CHANGED
|
@@ -1269,10 +1269,12 @@ function useAddAnymalToDatabase() {
|
|
|
1269
1269
|
return {
|
|
1270
1270
|
success: false,
|
|
1271
1271
|
message: "Authentication token is missing.",
|
|
1272
|
-
_docID: null
|
|
1272
|
+
_docID: null,
|
|
1273
|
+
dbCid: null
|
|
1273
1274
|
};
|
|
1274
1275
|
}
|
|
1275
1276
|
let anymalDocID = null;
|
|
1277
|
+
let dbCid = null;
|
|
1276
1278
|
try {
|
|
1277
1279
|
const mutation = `
|
|
1278
1280
|
mutation Create_Anymal($input: [AnymalMutationInputArg!]) {
|
|
@@ -1280,6 +1282,9 @@ function useAddAnymalToDatabase() {
|
|
|
1280
1282
|
_docID
|
|
1281
1283
|
name
|
|
1282
1284
|
passportID
|
|
1285
|
+
_version {
|
|
1286
|
+
cid
|
|
1287
|
+
}
|
|
1283
1288
|
}
|
|
1284
1289
|
}
|
|
1285
1290
|
`;
|
|
@@ -1310,15 +1315,18 @@ function useAddAnymalToDatabase() {
|
|
|
1310
1315
|
throw new Error(`GraphQL error: ${errorMessage}`);
|
|
1311
1316
|
}
|
|
1312
1317
|
anymalDocID = data.create_Anymal[0]._docID;
|
|
1318
|
+
dbCid = data.create_Anymal[0]._version[0].cid;
|
|
1313
1319
|
return {
|
|
1314
1320
|
success: true,
|
|
1315
1321
|
_docID: anymalDocID,
|
|
1322
|
+
dbCid,
|
|
1316
1323
|
message: "Anymal added to account"
|
|
1317
1324
|
};
|
|
1318
1325
|
} catch (error) {
|
|
1319
1326
|
return {
|
|
1320
1327
|
success: false,
|
|
1321
1328
|
_docID: null,
|
|
1329
|
+
dbCid: null,
|
|
1322
1330
|
message: "Error adding anymal to account"
|
|
1323
1331
|
};
|
|
1324
1332
|
}
|
|
@@ -1971,11 +1979,65 @@ var generateBytes32Nonce = () => {
|
|
|
1971
1979
|
return padHex(`0x${uuid3}`, { size: 32 });
|
|
1972
1980
|
};
|
|
1973
1981
|
|
|
1974
|
-
// src/
|
|
1982
|
+
// src/helpers/ActionHelpers.tsx
|
|
1983
|
+
async function submitAction(idToken, pid, payload, endpointBaseUrl) {
|
|
1984
|
+
const api = endpointBaseUrl + "/actions";
|
|
1985
|
+
const response = await fetch(api, {
|
|
1986
|
+
method: "POST",
|
|
1987
|
+
headers: { "Content-Type": "application/json", "Authorization": "Bearer " + idToken },
|
|
1988
|
+
body: JSON.stringify({ actionId: payload.actionId, pid, payload })
|
|
1989
|
+
});
|
|
1990
|
+
if (!response.ok) {
|
|
1991
|
+
const err = await response.json();
|
|
1992
|
+
throw new Error(err.error || "Failed to submit action");
|
|
1993
|
+
}
|
|
1994
|
+
return response.json();
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
// src/utils/actions/useFetchActions.ts
|
|
1975
1998
|
import { useCallback as useCallback23 } from "react";
|
|
1999
|
+
function useFetchActions() {
|
|
2000
|
+
return useCallback23(
|
|
2001
|
+
async (idToken, actionsServiceBaseUrl, pid, status, limit, offset) => {
|
|
2002
|
+
const params = new URLSearchParams({ pid });
|
|
2003
|
+
if (status) params.set("status", status);
|
|
2004
|
+
if (limit != null) params.set("limit", `${limit}`);
|
|
2005
|
+
if (offset != null) params.set("offset", `${offset}`);
|
|
2006
|
+
try {
|
|
2007
|
+
const response = await fetch(
|
|
2008
|
+
`${actionsServiceBaseUrl}/actions?${params.toString()}`,
|
|
2009
|
+
{
|
|
2010
|
+
method: "GET",
|
|
2011
|
+
headers: {
|
|
2012
|
+
"Content-Type": "application/json",
|
|
2013
|
+
Authorization: "Bearer " + idToken
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
);
|
|
2017
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
2018
|
+
return await response.json();
|
|
2019
|
+
} catch (error) {
|
|
2020
|
+
console.error("useFetchActions error:", error);
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
[]
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
// src/types/Actions.ts
|
|
2029
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
2030
|
+
ActionType2["GRAPHQL"] = "GRAPHQL";
|
|
2031
|
+
ActionType2["CONTRACT"] = "CONTRACT";
|
|
2032
|
+
ActionType2["EXTERNAL"] = "EXTERNAL";
|
|
2033
|
+
return ActionType2;
|
|
2034
|
+
})(ActionType || {});
|
|
2035
|
+
|
|
2036
|
+
// src/utils/application/useCreateUserAppData.ts
|
|
2037
|
+
import { useCallback as useCallback24 } from "react";
|
|
1976
2038
|
import { v4 as uuid } from "uuid";
|
|
1977
2039
|
function useCreateUserAppData() {
|
|
1978
|
-
return
|
|
2040
|
+
return useCallback24(
|
|
1979
2041
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1980
2042
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1981
2043
|
const appValues = {
|
|
@@ -2030,10 +2092,10 @@ function useCreateUserAppData() {
|
|
|
2030
2092
|
}
|
|
2031
2093
|
|
|
2032
2094
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
2033
|
-
import { useCallback as
|
|
2095
|
+
import { useCallback as useCallback25 } from "react";
|
|
2034
2096
|
import { v4 as uuid2 } from "uuid";
|
|
2035
2097
|
function useCreateOrganizationAppData() {
|
|
2036
|
-
return
|
|
2098
|
+
return useCallback25(
|
|
2037
2099
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
2038
2100
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
2039
2101
|
const appValues = {
|
|
@@ -2087,10 +2149,10 @@ function useCreateOrganizationAppData() {
|
|
|
2087
2149
|
}
|
|
2088
2150
|
|
|
2089
2151
|
// src/utils/balance/useFetchBalance.ts
|
|
2090
|
-
import { useCallback as
|
|
2152
|
+
import { useCallback as useCallback26 } from "react";
|
|
2091
2153
|
import { erc20Abi as erc20Abi3, getAddress } from "viem";
|
|
2092
2154
|
function useFetchBalance() {
|
|
2093
|
-
return
|
|
2155
|
+
return useCallback26(
|
|
2094
2156
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2095
2157
|
try {
|
|
2096
2158
|
const balance = await publicClient.readContract({
|
|
@@ -2109,6 +2171,7 @@ function useFetchBalance() {
|
|
|
2109
2171
|
}
|
|
2110
2172
|
export {
|
|
2111
2173
|
AUTH_API_ENDPOINTS,
|
|
2174
|
+
ActionType,
|
|
2112
2175
|
NETWORK_HOSTS,
|
|
2113
2176
|
Network,
|
|
2114
2177
|
createAuthEnvelope,
|
|
@@ -2118,6 +2181,7 @@ export {
|
|
|
2118
2181
|
generateJWT,
|
|
2119
2182
|
loadExistingSecp256k1PrivateKey,
|
|
2120
2183
|
serializePublicKeyCompressed,
|
|
2184
|
+
submitAction,
|
|
2121
2185
|
useAddAnymalToDatabase,
|
|
2122
2186
|
useApproveKibbleToken,
|
|
2123
2187
|
useApproveOrgPartialPayment,
|
|
@@ -2126,6 +2190,7 @@ export {
|
|
|
2126
2190
|
useCreateUserAppData,
|
|
2127
2191
|
useCreateWeb3Account,
|
|
2128
2192
|
useDeleteAnymalFromDatabase,
|
|
2193
|
+
useFetchActions,
|
|
2129
2194
|
useFetchAnymals,
|
|
2130
2195
|
useFetchBalance,
|
|
2131
2196
|
useFetchNotifications,
|
package/package.json
CHANGED