anymal-protocol 1.0.57 → 1.0.60
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 +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +176 -19
- package/dist/index.mjs +97 -19
- package/package.json +17 -3
package/dist/index.js
CHANGED
|
@@ -20,7 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AUTH_API_ENDPOINTS: () => AUTH_API_ENDPOINTS,
|
|
24
|
+
NETWORK_HOSTS: () => NETWORK_HOSTS,
|
|
25
|
+
Network: () => Network,
|
|
26
|
+
createAuthEnvelope: () => createAuthEnvelope,
|
|
27
|
+
fetchAnymals: () => fetchAnymals,
|
|
28
|
+
generateAppSignature: () => generateAppSignature,
|
|
23
29
|
generateBytes32Nonce: () => generateBytes32Nonce,
|
|
30
|
+
generateJWT: () => generateJWT,
|
|
31
|
+
loadExistingSecp256k1PrivateKey: () => loadExistingSecp256k1PrivateKey,
|
|
32
|
+
serializePublicKeyCompressed: () => serializePublicKeyCompressed,
|
|
24
33
|
useAddAnymalToDatabase: () => useAddAnymalToDatabase,
|
|
25
34
|
useApproveKibbleToken: () => useApproveKibbleToken,
|
|
26
35
|
useApproveOrgPartialPayment: () => useApproveOrgPartialPayment,
|
|
@@ -29,6 +38,7 @@ __export(index_exports, {
|
|
|
29
38
|
useCreateUserAppData: () => useCreateUserAppData,
|
|
30
39
|
useCreateWeb3Account: () => useCreateWeb3Account,
|
|
31
40
|
useDeleteAnymalFromDatabase: () => useDeleteAnymalFromDatabase,
|
|
41
|
+
useFetchAnymals: () => useFetchAnymals,
|
|
32
42
|
useFetchBalance: () => useFetchBalance,
|
|
33
43
|
useFetchNotifications: () => useFetchNotifications,
|
|
34
44
|
useFetchUserData: () => useFetchUserData,
|
|
@@ -1598,11 +1608,68 @@ function useUploadAnymalImage() {
|
|
|
1598
1608
|
);
|
|
1599
1609
|
}
|
|
1600
1610
|
|
|
1611
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1612
|
+
var import_react16 = require("react");
|
|
1613
|
+
|
|
1614
|
+
// src/utils/anymals/fetchAnymals.ts
|
|
1615
|
+
async function fetchAnymals({
|
|
1616
|
+
dbAuthToken,
|
|
1617
|
+
endpoint,
|
|
1618
|
+
userPid
|
|
1619
|
+
}) {
|
|
1620
|
+
const query = `
|
|
1621
|
+
query Anymal($filter: AnymalFilterArg, $order: [AnymalOrderArg]) {
|
|
1622
|
+
Anymal(filter: $filter, order: $order) {
|
|
1623
|
+
_docID
|
|
1624
|
+
name
|
|
1625
|
+
breed
|
|
1626
|
+
passportID
|
|
1627
|
+
profileImageUrl
|
|
1628
|
+
caregiverNearId
|
|
1629
|
+
caregiverId
|
|
1630
|
+
lifestage
|
|
1631
|
+
gender
|
|
1632
|
+
petType
|
|
1633
|
+
products
|
|
1634
|
+
timeAddedUtc
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
`;
|
|
1638
|
+
const variables = {
|
|
1639
|
+
filter: {
|
|
1640
|
+
caregiverId: { _eq: userPid }
|
|
1641
|
+
},
|
|
1642
|
+
order: [
|
|
1643
|
+
{
|
|
1644
|
+
timeAddedUtc: "ASC"
|
|
1645
|
+
}
|
|
1646
|
+
]
|
|
1647
|
+
};
|
|
1648
|
+
const response = await fetch(endpoint, {
|
|
1649
|
+
method: "POST",
|
|
1650
|
+
headers: {
|
|
1651
|
+
"Content-Type": "application/json",
|
|
1652
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1653
|
+
},
|
|
1654
|
+
body: JSON.stringify({ query, variables })
|
|
1655
|
+
});
|
|
1656
|
+
if (!response.ok) {
|
|
1657
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1658
|
+
}
|
|
1659
|
+
const data = await response.json();
|
|
1660
|
+
return data?.data?.Anymal ?? [];
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1664
|
+
function useFetchAnymals() {
|
|
1665
|
+
return (0, import_react16.useCallback)(fetchAnymals, []);
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1601
1668
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
1602
1669
|
var import_viem3 = require("viem");
|
|
1603
|
-
var
|
|
1670
|
+
var import_react17 = require("react");
|
|
1604
1671
|
function useProcessPartialKibblePayment() {
|
|
1605
|
-
return (0,
|
|
1672
|
+
return (0, import_react17.useCallback)(
|
|
1606
1673
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1607
1674
|
if (!orderId || !dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !marketplaceContract || !amountInTokens || !maxTokenPayment || !nonce || !deadline) {
|
|
1608
1675
|
return {
|
|
@@ -1665,9 +1732,9 @@ function useProcessPartialKibblePayment() {
|
|
|
1665
1732
|
|
|
1666
1733
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
1667
1734
|
var import_viem4 = require("viem");
|
|
1668
|
-
var
|
|
1735
|
+
var import_react18 = require("react");
|
|
1669
1736
|
function useApproveKibbleToken() {
|
|
1670
|
-
return (0,
|
|
1737
|
+
return (0, import_react18.useCallback)(
|
|
1671
1738
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
1672
1739
|
try {
|
|
1673
1740
|
const callData = (0, import_viem4.encodeFunctionData)({
|
|
@@ -1717,10 +1784,10 @@ function useApproveKibbleToken() {
|
|
|
1717
1784
|
}
|
|
1718
1785
|
|
|
1719
1786
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
1720
|
-
var
|
|
1787
|
+
var import_react19 = require("react");
|
|
1721
1788
|
var import_viem5 = require("viem");
|
|
1722
1789
|
function useCreateOrganizationBase() {
|
|
1723
|
-
return (0,
|
|
1790
|
+
return (0, import_react19.useCallback)(
|
|
1724
1791
|
/**
|
|
1725
1792
|
* Creates a new organization on-chain.
|
|
1726
1793
|
*
|
|
@@ -1806,10 +1873,10 @@ function useCreateOrganizationBase() {
|
|
|
1806
1873
|
}
|
|
1807
1874
|
|
|
1808
1875
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1809
|
-
var
|
|
1876
|
+
var import_react20 = require("react");
|
|
1810
1877
|
var import_viem6 = require("viem");
|
|
1811
1878
|
function useApproveOrgPartialPayment() {
|
|
1812
|
-
return (0,
|
|
1879
|
+
return (0, import_react20.useCallback)(
|
|
1813
1880
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
1814
1881
|
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
1815
1882
|
return {
|
|
@@ -1851,10 +1918,10 @@ function useApproveOrgPartialPayment() {
|
|
|
1851
1918
|
}
|
|
1852
1919
|
|
|
1853
1920
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1854
|
-
var
|
|
1921
|
+
var import_react21 = require("react");
|
|
1855
1922
|
var import_viem7 = require("viem");
|
|
1856
1923
|
function useProcessOrgPartialKibblePayment() {
|
|
1857
|
-
return (0,
|
|
1924
|
+
return (0, import_react21.useCallback)(
|
|
1858
1925
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1859
1926
|
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
1860
1927
|
return {
|
|
@@ -1905,9 +1972,9 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
1905
1972
|
}
|
|
1906
1973
|
|
|
1907
1974
|
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
1908
|
-
var
|
|
1975
|
+
var import_react22 = require("react");
|
|
1909
1976
|
function useUpdateOrgWalletAddress() {
|
|
1910
|
-
return (0,
|
|
1977
|
+
return (0, import_react22.useCallback)(
|
|
1911
1978
|
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
1912
1979
|
try {
|
|
1913
1980
|
const mutation = `
|
|
@@ -1953,11 +2020,91 @@ var generateBytes32Nonce = () => {
|
|
|
1953
2020
|
return (0, import_viem8.padHex)(`0x${uuid3}`, { size: 32 });
|
|
1954
2021
|
};
|
|
1955
2022
|
|
|
2023
|
+
// src/helpers/CryptoUtils.tsx
|
|
2024
|
+
var import_elliptic = require("elliptic");
|
|
2025
|
+
var ec = new import_elliptic.ec("secp256k1");
|
|
2026
|
+
var Network = /* @__PURE__ */ ((Network2) => {
|
|
2027
|
+
Network2["Testnet"] = "testnet";
|
|
2028
|
+
Network2["Localnet"] = "localnet";
|
|
2029
|
+
return Network2;
|
|
2030
|
+
})(Network || {});
|
|
2031
|
+
var NETWORK_HOSTS = {
|
|
2032
|
+
["testnet" /* Testnet */]: "dev-db.petastic.com",
|
|
2033
|
+
["localnet" /* Localnet */]: "host.docker.internal:9181"
|
|
2034
|
+
};
|
|
2035
|
+
var AUTH_API_ENDPOINTS = {
|
|
2036
|
+
["testnet" /* Testnet */]: "https://dev-auth-api.petastic.com",
|
|
2037
|
+
["localnet" /* Localnet */]: "http://localhost:3005"
|
|
2038
|
+
};
|
|
2039
|
+
function loadExistingSecp256k1PrivateKey(hexKey) {
|
|
2040
|
+
if (!hexKey) {
|
|
2041
|
+
throw new Error("Private key hex must be provided");
|
|
2042
|
+
}
|
|
2043
|
+
return ec.keyFromPrivate(hexKey, "hex");
|
|
2044
|
+
}
|
|
2045
|
+
function serializePublicKeyCompressed(keyPair) {
|
|
2046
|
+
return keyPair.getPublic(true, "hex");
|
|
2047
|
+
}
|
|
2048
|
+
function base64url(input) {
|
|
2049
|
+
let buf;
|
|
2050
|
+
if (typeof input === "string") buf = Buffer.from(input);
|
|
2051
|
+
else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
|
|
2052
|
+
else buf = input;
|
|
2053
|
+
return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
2054
|
+
}
|
|
2055
|
+
function sha256HashNode(data) {
|
|
2056
|
+
const { createHash } = require("crypto");
|
|
2057
|
+
return createHash("sha256").update(data).digest();
|
|
2058
|
+
}
|
|
2059
|
+
async function hashInput(data) {
|
|
2060
|
+
if (typeof window !== "undefined" && window.crypto?.subtle) {
|
|
2061
|
+
const encoder = new TextEncoder();
|
|
2062
|
+
const encoded = encoder.encode(data);
|
|
2063
|
+
const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
|
|
2064
|
+
return Buffer.from(hashBuffer);
|
|
2065
|
+
} else {
|
|
2066
|
+
return sha256HashNode(data);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
|
|
2070
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
2071
|
+
const exp = iat + expiresInSeconds;
|
|
2072
|
+
const header = { alg: "ES256", typ: "JWT" };
|
|
2073
|
+
const payload = { sub, aud, iat, exp };
|
|
2074
|
+
const encodedHeader = base64url(JSON.stringify(header));
|
|
2075
|
+
const encodedPayload = base64url(JSON.stringify(payload));
|
|
2076
|
+
const signingInput = `${encodedHeader}.${encodedPayload}`;
|
|
2077
|
+
const hash = await hashInput(signingInput);
|
|
2078
|
+
const signature = keyPair.sign(hash, { canonical: true });
|
|
2079
|
+
const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
|
|
2080
|
+
const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
|
|
2081
|
+
const rawSig = Buffer.concat([rBuf, sBuf]);
|
|
2082
|
+
const encodedSig = base64url(rawSig);
|
|
2083
|
+
return `${signingInput}.${encodedSig}`;
|
|
2084
|
+
}
|
|
2085
|
+
async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
|
|
2086
|
+
const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
|
|
2087
|
+
const publicKey = serializePublicKeyCompressed(keyPair);
|
|
2088
|
+
const host = NETWORK_HOSTS[network];
|
|
2089
|
+
if (!host) {
|
|
2090
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
2091
|
+
}
|
|
2092
|
+
const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
|
|
2093
|
+
return { publicKey, token };
|
|
2094
|
+
}
|
|
2095
|
+
async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
|
|
2096
|
+
const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
|
|
2097
|
+
const message = `${clientId}:${redirectUri}:${state}`;
|
|
2098
|
+
const hash = await hashInput(message);
|
|
2099
|
+
const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
|
|
2100
|
+
return Buffer.from(signatureDER).toString("hex");
|
|
2101
|
+
}
|
|
2102
|
+
|
|
1956
2103
|
// src/utils/application/useCreateUserAppData.ts
|
|
1957
|
-
var
|
|
2104
|
+
var import_react23 = require("react");
|
|
1958
2105
|
var import_uuid2 = require("uuid");
|
|
1959
2106
|
function useCreateUserAppData() {
|
|
1960
|
-
return (0,
|
|
2107
|
+
return (0, import_react23.useCallback)(
|
|
1961
2108
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1962
2109
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1963
2110
|
const appValues = {
|
|
@@ -1972,7 +2119,7 @@ function useCreateUserAppData() {
|
|
|
1972
2119
|
const mutation = `
|
|
1973
2120
|
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1974
2121
|
create_UserAppSettings (input: $input) {
|
|
1975
|
-
|
|
2122
|
+
_docID
|
|
1976
2123
|
id
|
|
1977
2124
|
appId
|
|
1978
2125
|
settings
|
|
@@ -2012,10 +2159,10 @@ function useCreateUserAppData() {
|
|
|
2012
2159
|
}
|
|
2013
2160
|
|
|
2014
2161
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
2015
|
-
var
|
|
2162
|
+
var import_react24 = require("react");
|
|
2016
2163
|
var import_uuid3 = require("uuid");
|
|
2017
2164
|
function useCreateOrganizationAppData() {
|
|
2018
|
-
return (0,
|
|
2165
|
+
return (0, import_react24.useCallback)(
|
|
2019
2166
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
2020
2167
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
2021
2168
|
const appValues = {
|
|
@@ -2069,10 +2216,10 @@ function useCreateOrganizationAppData() {
|
|
|
2069
2216
|
}
|
|
2070
2217
|
|
|
2071
2218
|
// src/utils/balance/useFetchBalance.ts
|
|
2072
|
-
var
|
|
2219
|
+
var import_react25 = require("react");
|
|
2073
2220
|
var import_viem9 = require("viem");
|
|
2074
2221
|
function useFetchBalance() {
|
|
2075
|
-
return (0,
|
|
2222
|
+
return (0, import_react25.useCallback)(
|
|
2076
2223
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2077
2224
|
try {
|
|
2078
2225
|
const balance = await publicClient.readContract({
|
|
@@ -2091,7 +2238,16 @@ function useFetchBalance() {
|
|
|
2091
2238
|
}
|
|
2092
2239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2093
2240
|
0 && (module.exports = {
|
|
2241
|
+
AUTH_API_ENDPOINTS,
|
|
2242
|
+
NETWORK_HOSTS,
|
|
2243
|
+
Network,
|
|
2244
|
+
createAuthEnvelope,
|
|
2245
|
+
fetchAnymals,
|
|
2246
|
+
generateAppSignature,
|
|
2094
2247
|
generateBytes32Nonce,
|
|
2248
|
+
generateJWT,
|
|
2249
|
+
loadExistingSecp256k1PrivateKey,
|
|
2250
|
+
serializePublicKeyCompressed,
|
|
2095
2251
|
useAddAnymalToDatabase,
|
|
2096
2252
|
useApproveKibbleToken,
|
|
2097
2253
|
useApproveOrgPartialPayment,
|
|
@@ -2100,6 +2256,7 @@ function useFetchBalance() {
|
|
|
2100
2256
|
useCreateUserAppData,
|
|
2101
2257
|
useCreateWeb3Account,
|
|
2102
2258
|
useDeleteAnymalFromDatabase,
|
|
2259
|
+
useFetchAnymals,
|
|
2103
2260
|
useFetchBalance,
|
|
2104
2261
|
useFetchNotifications,
|
|
2105
2262
|
useFetchUserData,
|
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";
|
|
@@ -1548,11 +1559,68 @@ function useUploadAnymalImage() {
|
|
|
1548
1559
|
);
|
|
1549
1560
|
}
|
|
1550
1561
|
|
|
1562
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1563
|
+
import { useCallback as useCallback16 } from "react";
|
|
1564
|
+
|
|
1565
|
+
// src/utils/anymals/fetchAnymals.ts
|
|
1566
|
+
async function fetchAnymals({
|
|
1567
|
+
dbAuthToken,
|
|
1568
|
+
endpoint,
|
|
1569
|
+
userPid
|
|
1570
|
+
}) {
|
|
1571
|
+
const query = `
|
|
1572
|
+
query Anymal($filter: AnymalFilterArg, $order: [AnymalOrderArg]) {
|
|
1573
|
+
Anymal(filter: $filter, order: $order) {
|
|
1574
|
+
_docID
|
|
1575
|
+
name
|
|
1576
|
+
breed
|
|
1577
|
+
passportID
|
|
1578
|
+
profileImageUrl
|
|
1579
|
+
caregiverNearId
|
|
1580
|
+
caregiverId
|
|
1581
|
+
lifestage
|
|
1582
|
+
gender
|
|
1583
|
+
petType
|
|
1584
|
+
products
|
|
1585
|
+
timeAddedUtc
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
`;
|
|
1589
|
+
const variables = {
|
|
1590
|
+
filter: {
|
|
1591
|
+
caregiverId: { _eq: userPid }
|
|
1592
|
+
},
|
|
1593
|
+
order: [
|
|
1594
|
+
{
|
|
1595
|
+
timeAddedUtc: "ASC"
|
|
1596
|
+
}
|
|
1597
|
+
]
|
|
1598
|
+
};
|
|
1599
|
+
const response = await fetch(endpoint, {
|
|
1600
|
+
method: "POST",
|
|
1601
|
+
headers: {
|
|
1602
|
+
"Content-Type": "application/json",
|
|
1603
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1604
|
+
},
|
|
1605
|
+
body: JSON.stringify({ query, variables })
|
|
1606
|
+
});
|
|
1607
|
+
if (!response.ok) {
|
|
1608
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1609
|
+
}
|
|
1610
|
+
const data = await response.json();
|
|
1611
|
+
return data?.data?.Anymal ?? [];
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
// src/utils/anymals/useFetchAnymals.ts
|
|
1615
|
+
function useFetchAnymals() {
|
|
1616
|
+
return useCallback16(fetchAnymals, []);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1551
1619
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
1552
1620
|
import { encodeFunctionData as encodeFunctionData3, parseGwei as parseGwei3 } from "viem";
|
|
1553
|
-
import { useCallback as
|
|
1621
|
+
import { useCallback as useCallback17 } from "react";
|
|
1554
1622
|
function useProcessPartialKibblePayment() {
|
|
1555
|
-
return
|
|
1623
|
+
return useCallback17(
|
|
1556
1624
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1557
1625
|
if (!orderId || !dbAuthToken || !nftId || !bundlerClient || !smartAccount || !pid || !marketplaceContract || !amountInTokens || !maxTokenPayment || !nonce || !deadline) {
|
|
1558
1626
|
return {
|
|
@@ -1615,9 +1683,9 @@ function useProcessPartialKibblePayment() {
|
|
|
1615
1683
|
|
|
1616
1684
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
1617
1685
|
import { encodeFunctionData as encodeFunctionData4, erc20Abi, parseGwei as parseGwei4 } from "viem";
|
|
1618
|
-
import { useCallback as
|
|
1686
|
+
import { useCallback as useCallback18 } from "react";
|
|
1619
1687
|
function useApproveKibbleToken() {
|
|
1620
|
-
return
|
|
1688
|
+
return useCallback18(
|
|
1621
1689
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
1622
1690
|
try {
|
|
1623
1691
|
const callData = encodeFunctionData4({
|
|
@@ -1667,10 +1735,10 @@ function useApproveKibbleToken() {
|
|
|
1667
1735
|
}
|
|
1668
1736
|
|
|
1669
1737
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
1670
|
-
import { useCallback as
|
|
1738
|
+
import { useCallback as useCallback19 } from "react";
|
|
1671
1739
|
import { decodeEventLog, encodeFunctionData as encodeFunctionData5, parseGwei as parseGwei5 } from "viem";
|
|
1672
1740
|
function useCreateOrganizationBase() {
|
|
1673
|
-
return
|
|
1741
|
+
return useCallback19(
|
|
1674
1742
|
/**
|
|
1675
1743
|
* Creates a new organization on-chain.
|
|
1676
1744
|
*
|
|
@@ -1756,10 +1824,10 @@ function useCreateOrganizationBase() {
|
|
|
1756
1824
|
}
|
|
1757
1825
|
|
|
1758
1826
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1759
|
-
import { useCallback as
|
|
1827
|
+
import { useCallback as useCallback20 } from "react";
|
|
1760
1828
|
import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi2, parseGwei as parseGwei6 } from "viem";
|
|
1761
1829
|
function useApproveOrgPartialPayment() {
|
|
1762
|
-
return
|
|
1830
|
+
return useCallback20(
|
|
1763
1831
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
1764
1832
|
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
1765
1833
|
return {
|
|
@@ -1801,10 +1869,10 @@ function useApproveOrgPartialPayment() {
|
|
|
1801
1869
|
}
|
|
1802
1870
|
|
|
1803
1871
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1804
|
-
import { useCallback as
|
|
1872
|
+
import { useCallback as useCallback21 } from "react";
|
|
1805
1873
|
import { encodeFunctionData as encodeFunctionData7, parseGwei as parseGwei7 } from "viem";
|
|
1806
1874
|
function useProcessOrgPartialKibblePayment() {
|
|
1807
|
-
return
|
|
1875
|
+
return useCallback21(
|
|
1808
1876
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1809
1877
|
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
1810
1878
|
return {
|
|
@@ -1855,9 +1923,9 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
1855
1923
|
}
|
|
1856
1924
|
|
|
1857
1925
|
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
1858
|
-
import { useCallback as
|
|
1926
|
+
import { useCallback as useCallback22 } from "react";
|
|
1859
1927
|
function useUpdateOrgWalletAddress() {
|
|
1860
|
-
return
|
|
1928
|
+
return useCallback22(
|
|
1861
1929
|
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
1862
1930
|
try {
|
|
1863
1931
|
const mutation = `
|
|
@@ -1904,10 +1972,10 @@ var generateBytes32Nonce = () => {
|
|
|
1904
1972
|
};
|
|
1905
1973
|
|
|
1906
1974
|
// src/utils/application/useCreateUserAppData.ts
|
|
1907
|
-
import { useCallback as
|
|
1975
|
+
import { useCallback as useCallback23 } from "react";
|
|
1908
1976
|
import { v4 as uuid } from "uuid";
|
|
1909
1977
|
function useCreateUserAppData() {
|
|
1910
|
-
return
|
|
1978
|
+
return useCallback23(
|
|
1911
1979
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1912
1980
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1913
1981
|
const appValues = {
|
|
@@ -1922,7 +1990,7 @@ function useCreateUserAppData() {
|
|
|
1922
1990
|
const mutation = `
|
|
1923
1991
|
mutation Create_UserAppSettings($input: [UserAppSettingsMutationInputArg!]) {
|
|
1924
1992
|
create_UserAppSettings (input: $input) {
|
|
1925
|
-
|
|
1993
|
+
_docID
|
|
1926
1994
|
id
|
|
1927
1995
|
appId
|
|
1928
1996
|
settings
|
|
@@ -1962,10 +2030,10 @@ function useCreateUserAppData() {
|
|
|
1962
2030
|
}
|
|
1963
2031
|
|
|
1964
2032
|
// src/utils/application/useCreateOrganizationAppData.ts
|
|
1965
|
-
import { useCallback as
|
|
2033
|
+
import { useCallback as useCallback24 } from "react";
|
|
1966
2034
|
import { v4 as uuid2 } from "uuid";
|
|
1967
2035
|
function useCreateOrganizationAppData() {
|
|
1968
|
-
return
|
|
2036
|
+
return useCallback24(
|
|
1969
2037
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
1970
2038
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
1971
2039
|
const appValues = {
|
|
@@ -2019,10 +2087,10 @@ function useCreateOrganizationAppData() {
|
|
|
2019
2087
|
}
|
|
2020
2088
|
|
|
2021
2089
|
// src/utils/balance/useFetchBalance.ts
|
|
2022
|
-
import { useCallback as
|
|
2090
|
+
import { useCallback as useCallback25 } from "react";
|
|
2023
2091
|
import { erc20Abi as erc20Abi3, getAddress } from "viem";
|
|
2024
2092
|
function useFetchBalance() {
|
|
2025
|
-
return
|
|
2093
|
+
return useCallback25(
|
|
2026
2094
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2027
2095
|
try {
|
|
2028
2096
|
const balance = await publicClient.readContract({
|
|
@@ -2040,7 +2108,16 @@ function useFetchBalance() {
|
|
|
2040
2108
|
);
|
|
2041
2109
|
}
|
|
2042
2110
|
export {
|
|
2111
|
+
AUTH_API_ENDPOINTS,
|
|
2112
|
+
NETWORK_HOSTS,
|
|
2113
|
+
Network,
|
|
2114
|
+
createAuthEnvelope,
|
|
2115
|
+
fetchAnymals,
|
|
2116
|
+
generateAppSignature,
|
|
2043
2117
|
generateBytes32Nonce,
|
|
2118
|
+
generateJWT,
|
|
2119
|
+
loadExistingSecp256k1PrivateKey,
|
|
2120
|
+
serializePublicKeyCompressed,
|
|
2044
2121
|
useAddAnymalToDatabase,
|
|
2045
2122
|
useApproveKibbleToken,
|
|
2046
2123
|
useApproveOrgPartialPayment,
|
|
@@ -2049,6 +2126,7 @@ export {
|
|
|
2049
2126
|
useCreateUserAppData,
|
|
2050
2127
|
useCreateWeb3Account,
|
|
2051
2128
|
useDeleteAnymalFromDatabase,
|
|
2129
|
+
useFetchAnymals,
|
|
2052
2130
|
useFetchBalance,
|
|
2053
2131
|
useFetchNotifications,
|
|
2054
2132
|
useFetchUserData,
|
package/package.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anymal-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
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",
|