anymal-protocol 1.0.59 → 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/chunk-43I5M7QS.mjs +93 -0
- package/dist/chunk-5UXBNDDZ.mjs +93 -0
- package/dist/chunk-DIGESQEI.mjs +91 -0
- package/dist/chunk-F72KTNHS.mjs +98 -0
- package/dist/chunk-KEC6WLEL.mjs +93 -0
- package/dist/chunk-QHK3YPLJ.mjs +93 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +165 -0
- package/dist/cli/index.mjs +101 -0
- package/dist/index.d.mts +174 -1
- package/dist/index.d.ts +174 -1
- package/dist/index.js +244 -19
- package/dist/index.mjs +162 -19
- package/package.json +17 -3
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTH_API_ENDPOINTS,
|
|
3
|
+
NETWORK_HOSTS,
|
|
4
|
+
Network,
|
|
5
|
+
createAuthEnvelope,
|
|
6
|
+
generateAppSignature,
|
|
7
|
+
generateJWT,
|
|
8
|
+
loadExistingSecp256k1PrivateKey,
|
|
9
|
+
serializePublicKeyCompressed
|
|
10
|
+
} from "./chunk-F72KTNHS.mjs";
|
|
11
|
+
|
|
1
12
|
// src/utils/account/useVerifyAccount.ts
|
|
2
13
|
import { useCallback } from "react";
|
|
3
14
|
import { encodeFunctionData, parseGwei } from "viem";
|
|
@@ -1258,10 +1269,12 @@ function useAddAnymalToDatabase() {
|
|
|
1258
1269
|
return {
|
|
1259
1270
|
success: false,
|
|
1260
1271
|
message: "Authentication token is missing.",
|
|
1261
|
-
_docID: null
|
|
1272
|
+
_docID: null,
|
|
1273
|
+
dbCid: null
|
|
1262
1274
|
};
|
|
1263
1275
|
}
|
|
1264
1276
|
let anymalDocID = null;
|
|
1277
|
+
let dbCid = null;
|
|
1265
1278
|
try {
|
|
1266
1279
|
const mutation = `
|
|
1267
1280
|
mutation Create_Anymal($input: [AnymalMutationInputArg!]) {
|
|
@@ -1269,6 +1282,9 @@ function useAddAnymalToDatabase() {
|
|
|
1269
1282
|
_docID
|
|
1270
1283
|
name
|
|
1271
1284
|
passportID
|
|
1285
|
+
_version {
|
|
1286
|
+
cid
|
|
1287
|
+
}
|
|
1272
1288
|
}
|
|
1273
1289
|
}
|
|
1274
1290
|
`;
|
|
@@ -1299,15 +1315,18 @@ function useAddAnymalToDatabase() {
|
|
|
1299
1315
|
throw new Error(`GraphQL error: ${errorMessage}`);
|
|
1300
1316
|
}
|
|
1301
1317
|
anymalDocID = data.create_Anymal[0]._docID;
|
|
1318
|
+
dbCid = data.create_Anymal[0]._version[0].cid;
|
|
1302
1319
|
return {
|
|
1303
1320
|
success: true,
|
|
1304
1321
|
_docID: anymalDocID,
|
|
1322
|
+
dbCid,
|
|
1305
1323
|
message: "Anymal added to account"
|
|
1306
1324
|
};
|
|
1307
1325
|
} catch (error) {
|
|
1308
1326
|
return {
|
|
1309
1327
|
success: false,
|
|
1310
1328
|
_docID: null,
|
|
1329
|
+
dbCid: null,
|
|
1311
1330
|
message: "Error adding anymal to account"
|
|
1312
1331
|
};
|
|
1313
1332
|
}
|
|
@@ -1548,11 +1567,68 @@ function useUploadAnymalImage() {
|
|
|
1548
1567
|
);
|
|
1549
1568
|
}
|
|
1550
1569
|
|
|
1570
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1571
|
+
import { useCallback as useCallback16 } from "react";
|
|
1572
|
+
|
|
1573
|
+
// src/utils/anymals/fetchAnymals.ts
|
|
1574
|
+
async function fetchAnymals({
|
|
1575
|
+
dbAuthToken,
|
|
1576
|
+
endpoint,
|
|
1577
|
+
userPid
|
|
1578
|
+
}) {
|
|
1579
|
+
const query = `
|
|
1580
|
+
query Anymal($filter: AnymalFilterArg, $order: [AnymalOrderArg]) {
|
|
1581
|
+
Anymal(filter: $filter, order: $order) {
|
|
1582
|
+
_docID
|
|
1583
|
+
name
|
|
1584
|
+
breed
|
|
1585
|
+
passportID
|
|
1586
|
+
profileImageUrl
|
|
1587
|
+
caregiverNearId
|
|
1588
|
+
caregiverId
|
|
1589
|
+
lifestage
|
|
1590
|
+
gender
|
|
1591
|
+
petType
|
|
1592
|
+
products
|
|
1593
|
+
timeAddedUtc
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
`;
|
|
1597
|
+
const variables = {
|
|
1598
|
+
filter: {
|
|
1599
|
+
caregiverId: { _eq: userPid }
|
|
1600
|
+
},
|
|
1601
|
+
order: [
|
|
1602
|
+
{
|
|
1603
|
+
timeAddedUtc: "ASC"
|
|
1604
|
+
}
|
|
1605
|
+
]
|
|
1606
|
+
};
|
|
1607
|
+
const response = await fetch(endpoint, {
|
|
1608
|
+
method: "POST",
|
|
1609
|
+
headers: {
|
|
1610
|
+
"Content-Type": "application/json",
|
|
1611
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1612
|
+
},
|
|
1613
|
+
body: JSON.stringify({ query, variables })
|
|
1614
|
+
});
|
|
1615
|
+
if (!response.ok) {
|
|
1616
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1617
|
+
}
|
|
1618
|
+
const data = await response.json();
|
|
1619
|
+
return data?.data?.Anymal ?? [];
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1623
|
+
function useFetchAnymals() {
|
|
1624
|
+
return useCallback16(fetchAnymals, []);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1551
1627
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
1552
1628
|
import { encodeFunctionData as encodeFunctionData3, parseGwei as parseGwei3 } from "viem";
|
|
1553
|
-
import { useCallback as
|
|
1629
|
+
import { useCallback as useCallback17 } from "react";
|
|
1554
1630
|
function useProcessPartialKibblePayment() {
|
|
1555
|
-
return
|
|
1631
|
+
return useCallback17(
|
|
1556
1632
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1557
1633
|
if (!orderId || !dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !marketplaceContract || !amountInTokens || !maxTokenPayment || !nonce || !deadline) {
|
|
1558
1634
|
return {
|
|
@@ -1615,9 +1691,9 @@ function useProcessPartialKibblePayment() {
|
|
|
1615
1691
|
|
|
1616
1692
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
1617
1693
|
import { encodeFunctionData as encodeFunctionData4, erc20Abi, parseGwei as parseGwei4 } from "viem";
|
|
1618
|
-
import { useCallback as
|
|
1694
|
+
import { useCallback as useCallback18 } from "react";
|
|
1619
1695
|
function useApproveKibbleToken() {
|
|
1620
|
-
return
|
|
1696
|
+
return useCallback18(
|
|
1621
1697
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
1622
1698
|
try {
|
|
1623
1699
|
const callData = encodeFunctionData4({
|
|
@@ -1667,10 +1743,10 @@ function useApproveKibbleToken() {
|
|
|
1667
1743
|
}
|
|
1668
1744
|
|
|
1669
1745
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
1670
|
-
import { useCallback as
|
|
1746
|
+
import { useCallback as useCallback19 } from "react";
|
|
1671
1747
|
import { decodeEventLog, encodeFunctionData as encodeFunctionData5, parseGwei as parseGwei5 } from "viem";
|
|
1672
1748
|
function useCreateOrganizationBase() {
|
|
1673
|
-
return
|
|
1749
|
+
return useCallback19(
|
|
1674
1750
|
/**
|
|
1675
1751
|
* Creates a new organization on-chain.
|
|
1676
1752
|
*
|
|
@@ -1756,10 +1832,10 @@ function useCreateOrganizationBase() {
|
|
|
1756
1832
|
}
|
|
1757
1833
|
|
|
1758
1834
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1759
|
-
import { useCallback as
|
|
1835
|
+
import { useCallback as useCallback20 } from "react";
|
|
1760
1836
|
import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi2, parseGwei as parseGwei6 } from "viem";
|
|
1761
1837
|
function useApproveOrgPartialPayment() {
|
|
1762
|
-
return
|
|
1838
|
+
return useCallback20(
|
|
1763
1839
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
1764
1840
|
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
1765
1841
|
return {
|
|
@@ -1801,10 +1877,10 @@ function useApproveOrgPartialPayment() {
|
|
|
1801
1877
|
}
|
|
1802
1878
|
|
|
1803
1879
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1804
|
-
import { useCallback as
|
|
1880
|
+
import { useCallback as useCallback21 } from "react";
|
|
1805
1881
|
import { encodeFunctionData as encodeFunctionData7, parseGwei as parseGwei7 } from "viem";
|
|
1806
1882
|
function useProcessOrgPartialKibblePayment() {
|
|
1807
|
-
return
|
|
1883
|
+
return useCallback21(
|
|
1808
1884
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1809
1885
|
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
1810
1886
|
return {
|
|
@@ -1855,9 +1931,9 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
1855
1931
|
}
|
|
1856
1932
|
|
|
1857
1933
|
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
1858
|
-
import { useCallback as
|
|
1934
|
+
import { useCallback as useCallback22 } from "react";
|
|
1859
1935
|
function useUpdateOrgWalletAddress() {
|
|
1860
|
-
return
|
|
1936
|
+
return useCallback22(
|
|
1861
1937
|
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
1862
1938
|
try {
|
|
1863
1939
|
const mutation = `
|
|
@@ -1903,11 +1979,65 @@ var generateBytes32Nonce = () => {
|
|
|
1903
1979
|
return padHex(`0x${uuid3}`, { size: 32 });
|
|
1904
1980
|
};
|
|
1905
1981
|
|
|
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
|
|
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
|
+
|
|
1906
2036
|
// src/utils/application/useCreateUserAppData.ts
|
|
1907
|
-
import { useCallback as
|
|
2037
|
+
import { useCallback as useCallback24 } from "react";
|
|
1908
2038
|
import { v4 as uuid } from "uuid";
|
|
1909
2039
|
function useCreateUserAppData() {
|
|
1910
|
-
return
|
|
2040
|
+
return useCallback24(
|
|
1911
2041
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1912
2042
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1913
2043
|
const appValues = {
|
|
@@ -1962,10 +2092,10 @@ function useCreateUserAppData() {
|
|
|
1962
2092
|
}
|
|
1963
2093
|
|
|
1964
2094
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
1965
|
-
import { useCallback as
|
|
2095
|
+
import { useCallback as useCallback25 } from "react";
|
|
1966
2096
|
import { v4 as uuid2 } from "uuid";
|
|
1967
2097
|
function useCreateOrganizationAppData() {
|
|
1968
|
-
return
|
|
2098
|
+
return useCallback25(
|
|
1969
2099
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1970
2100
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1971
2101
|
const appValues = {
|
|
@@ -2019,10 +2149,10 @@ function useCreateOrganizationAppData() {
|
|
|
2019
2149
|
}
|
|
2020
2150
|
|
|
2021
2151
|
// src/utils/balance/useFetchBalance.ts
|
|
2022
|
-
import { useCallback as
|
|
2152
|
+
import { useCallback as useCallback26 } from "react";
|
|
2023
2153
|
import { erc20Abi as erc20Abi3, getAddress } from "viem";
|
|
2024
2154
|
function useFetchBalance() {
|
|
2025
|
-
return
|
|
2155
|
+
return useCallback26(
|
|
2026
2156
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2027
2157
|
try {
|
|
2028
2158
|
const balance = await publicClient.readContract({
|
|
@@ -2040,7 +2170,18 @@ function useFetchBalance() {
|
|
|
2040
2170
|
);
|
|
2041
2171
|
}
|
|
2042
2172
|
export {
|
|
2173
|
+
AUTH_API_ENDPOINTS,
|
|
2174
|
+
ActionType,
|
|
2175
|
+
NETWORK_HOSTS,
|
|
2176
|
+
Network,
|
|
2177
|
+
createAuthEnvelope,
|
|
2178
|
+
fetchAnymals,
|
|
2179
|
+
generateAppSignature,
|
|
2043
2180
|
generateBytes32Nonce,
|
|
2181
|
+
generateJWT,
|
|
2182
|
+
loadExistingSecp256k1PrivateKey,
|
|
2183
|
+
serializePublicKeyCompressed,
|
|
2184
|
+
submitAction,
|
|
2044
2185
|
useAddAnymalToDatabase,
|
|
2045
2186
|
useApproveKibbleToken,
|
|
2046
2187
|
useApproveOrgPartialPayment,
|
|
@@ -2049,6 +2190,8 @@ export {
|
|
|
2049
2190
|
useCreateUserAppData,
|
|
2050
2191
|
useCreateWeb3Account,
|
|
2051
2192
|
useDeleteAnymalFromDatabase,
|
|
2193
|
+
useFetchActions,
|
|
2194
|
+
useFetchAnymals,
|
|
2052
2195
|
useFetchBalance,
|
|
2053
2196
|
useFetchNotifications,
|
|
2054
2197
|
useFetchUserData,
|
package/package.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anymal-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"description": "A React/TypeScript-based utility library for reusable functions and hooks inside of the Anymal Ecosystem.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"
|
|
6
|
+
"bin": {
|
|
7
|
+
"anymal": "./dist/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
7
16
|
"types": "dist/index.d.ts",
|
|
8
17
|
"files": [
|
|
9
18
|
"dist"
|
|
10
19
|
],
|
|
11
20
|
"scripts": {
|
|
12
21
|
"test": "jest",
|
|
13
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
22
|
+
"build": "tsup src/index.ts src/cli/index.ts --format cjs,esm --dts",
|
|
14
23
|
"prepublishOnly": "npm run build"
|
|
15
24
|
},
|
|
16
25
|
"keywords": [
|
|
@@ -23,6 +32,10 @@
|
|
|
23
32
|
"author": "",
|
|
24
33
|
"license": "ISC",
|
|
25
34
|
"dependencies": {
|
|
35
|
+
"@types/elliptic": "^6.4.18",
|
|
36
|
+
"commander": "^13.1.0",
|
|
37
|
+
"elliptic": "^6.6.1",
|
|
38
|
+
"jose": "^6.0.10",
|
|
26
39
|
"react": "^19.0.0",
|
|
27
40
|
"react-dom": "^19.0.0",
|
|
28
41
|
"uuid": "^11.0.5",
|
|
@@ -31,6 +44,7 @@
|
|
|
31
44
|
"devDependencies": {
|
|
32
45
|
"@testing-library/jest-dom": "^6.6.3",
|
|
33
46
|
"@testing-library/react": "^16.2.0",
|
|
47
|
+
"@types/commander": "^2.12.5",
|
|
34
48
|
"@types/jest": "^29.5.14",
|
|
35
49
|
"@types/react": "^19.0.7",
|
|
36
50
|
"@types/react-dom": "^19.0.3",
|