anymal-protocol 1.0.117 → 1.0.119
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-F72KTNHS.mjs → chunk-OBXCSRGF.mjs} +109 -1
- package/dist/cli/index.mjs +2 -36
- package/dist/index.d.mts +59 -11
- package/dist/index.d.ts +59 -11
- package/dist/index.js +487 -160
- package/dist/index.mjs +368 -151
- package/package.json +1 -1
- package/dist/chunk-43I5M7QS.mjs +0 -93
- package/dist/chunk-5UXBNDDZ.mjs +0 -93
- package/dist/chunk-DIGESQEI.mjs +0 -91
- package/dist/chunk-KEC6WLEL.mjs +0 -93
- package/dist/chunk-QHK3YPLJ.mjs +0 -93
|
@@ -21,6 +21,14 @@ var AUTH_API_ENDPOINTS = {
|
|
|
21
21
|
["testnet" /* Testnet */]: "https://dev-auth-api.petastic.com",
|
|
22
22
|
["localnet" /* Localnet */]: "http://localhost:3005"
|
|
23
23
|
};
|
|
24
|
+
var FIREBASE_WEB_API_KEYS = {
|
|
25
|
+
["testnet" /* Testnet */]: "AIzaSyC7Q-uzAzNSx6-cj_-LyNkFCWzB6RsmYzI",
|
|
26
|
+
["localnet" /* Localnet */]: "AIzaSyC7Q-uzAzNSx6-cj_-LyNkFCWzB6RsmYzI"
|
|
27
|
+
};
|
|
28
|
+
var FIREBASE_WEB_AUTH_API_ENDPOINTS = {
|
|
29
|
+
["testnet" /* Testnet */]: "https://identitytoolkit.googleapis.com/v1/accounts",
|
|
30
|
+
["localnet" /* Localnet */]: "http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts"
|
|
31
|
+
};
|
|
24
32
|
function loadExistingSecp256k1PrivateKey(hexKey) {
|
|
25
33
|
if (!hexKey) {
|
|
26
34
|
throw new Error("Private key hex must be provided");
|
|
@@ -85,14 +93,114 @@ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state)
|
|
|
85
93
|
return Buffer.from(signatureDER).toString("hex");
|
|
86
94
|
}
|
|
87
95
|
|
|
96
|
+
// src/helpers/AppHelpers.tsx
|
|
97
|
+
async function createApp(privateKeyHex, name, metadataURI, ownerEmail, network = "testnet" /* Testnet */, options) {
|
|
98
|
+
const { publicKey, token } = await createAuthEnvelope(
|
|
99
|
+
privateKeyHex,
|
|
100
|
+
network,
|
|
101
|
+
options
|
|
102
|
+
);
|
|
103
|
+
const host = AUTH_API_ENDPOINTS[network];
|
|
104
|
+
if (!host) {
|
|
105
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
106
|
+
}
|
|
107
|
+
const url = `${host}/create-app`;
|
|
108
|
+
const response = await fetch(url, {
|
|
109
|
+
method: "POST",
|
|
110
|
+
headers: {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
Authorization: `Bearer ${token}`
|
|
113
|
+
},
|
|
114
|
+
body: JSON.stringify({
|
|
115
|
+
name,
|
|
116
|
+
publicKey,
|
|
117
|
+
metadataURI,
|
|
118
|
+
ownerEmail
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
const text = await response.text();
|
|
123
|
+
throw new Error(`Error creating app (${response.status}): ${text}`);
|
|
124
|
+
}
|
|
125
|
+
return response.json();
|
|
126
|
+
}
|
|
127
|
+
async function getFirebaseTokenForApp(privateKeyHex, appId, network = "testnet" /* Testnet */) {
|
|
128
|
+
const { token } = await createAuthEnvelope(privateKeyHex, network);
|
|
129
|
+
const host = AUTH_API_ENDPOINTS[network];
|
|
130
|
+
if (!host) {
|
|
131
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
132
|
+
}
|
|
133
|
+
const response = await fetch(`${host}/exchange-jwt-for-app-token`, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: {
|
|
136
|
+
Authorization: `Bearer ${token}`
|
|
137
|
+
},
|
|
138
|
+
body: JSON.stringify({
|
|
139
|
+
appId
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
const text = await response.text();
|
|
144
|
+
throw new Error(`Failed to get Firebase token: ${response.status} ${text}`);
|
|
145
|
+
}
|
|
146
|
+
const { firebaseToken: customToken } = await response.json();
|
|
147
|
+
const firebaseApiKey = FIREBASE_WEB_API_KEYS[network];
|
|
148
|
+
if (!firebaseApiKey) {
|
|
149
|
+
throw new Error("FIREBASE_WEB_API_KEY is not set");
|
|
150
|
+
}
|
|
151
|
+
const fbAuthEndpoint = FIREBASE_WEB_AUTH_API_ENDPOINTS[network];
|
|
152
|
+
const firebaseResponse = await fetch(
|
|
153
|
+
`${fbAuthEndpoint}:signInWithCustomToken?key=${firebaseApiKey}`,
|
|
154
|
+
{
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: {
|
|
157
|
+
"Content-Type": "application/json"
|
|
158
|
+
},
|
|
159
|
+
body: JSON.stringify({
|
|
160
|
+
token: customToken,
|
|
161
|
+
returnSecureToken: true
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
if (!firebaseResponse.ok) {
|
|
166
|
+
const text = await firebaseResponse.text();
|
|
167
|
+
throw new Error(`Firebase token exchange failed: ${firebaseResponse.status} ${text}`);
|
|
168
|
+
}
|
|
169
|
+
const { idToken } = await firebaseResponse.json();
|
|
170
|
+
return { firebaseToken: idToken };
|
|
171
|
+
}
|
|
172
|
+
function flattenFirestoreData(fields) {
|
|
173
|
+
const parseValue = (val) => {
|
|
174
|
+
if (val === null || typeof val !== "object") return val;
|
|
175
|
+
if ("stringValue" in val) return val.stringValue;
|
|
176
|
+
if ("integerValue" in val) return parseInt(val.integerValue, 10);
|
|
177
|
+
if ("doubleValue" in val) return parseFloat(val.doubleValue);
|
|
178
|
+
if ("booleanValue" in val) return val.booleanValue;
|
|
179
|
+
if ("timestampValue" in val) return val.timestampValue;
|
|
180
|
+
if ("nullValue" in val) return null;
|
|
181
|
+
if ("mapValue" in val) return flattenFirestoreData(val.mapValue.fields || {});
|
|
182
|
+
if ("arrayValue" in val)
|
|
183
|
+
return (val.arrayValue.values || []).map(parseValue);
|
|
184
|
+
return val;
|
|
185
|
+
};
|
|
186
|
+
return Object.fromEntries(
|
|
187
|
+
Object.entries(fields).map(([key, value]) => [key, parseValue(value)])
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
88
191
|
export {
|
|
89
192
|
__require,
|
|
90
193
|
Network,
|
|
91
194
|
NETWORK_HOSTS,
|
|
92
195
|
AUTH_API_ENDPOINTS,
|
|
196
|
+
FIREBASE_WEB_API_KEYS,
|
|
197
|
+
FIREBASE_WEB_AUTH_API_ENDPOINTS,
|
|
93
198
|
loadExistingSecp256k1PrivateKey,
|
|
94
199
|
serializePublicKeyCompressed,
|
|
95
200
|
generateJWT,
|
|
96
201
|
createAuthEnvelope,
|
|
97
|
-
generateAppSignature
|
|
202
|
+
generateAppSignature,
|
|
203
|
+
createApp,
|
|
204
|
+
getFirebaseTokenForApp,
|
|
205
|
+
flattenFirestoreData
|
|
98
206
|
};
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,46 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
AUTH_API_ENDPOINTS,
|
|
4
3
|
__require,
|
|
4
|
+
createApp,
|
|
5
5
|
createAuthEnvelope
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-OBXCSRGF.mjs";
|
|
7
7
|
|
|
8
8
|
// src/cli/index.ts
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
-
|
|
11
|
-
// src/helpers/AppHelpers.tsx
|
|
12
|
-
async function createApp(privateKeyHex, name, metadataURI, ownerEmail, network = "testnet" /* Testnet */, options) {
|
|
13
|
-
const { publicKey, token } = await createAuthEnvelope(
|
|
14
|
-
privateKeyHex,
|
|
15
|
-
network,
|
|
16
|
-
options
|
|
17
|
-
);
|
|
18
|
-
const host = AUTH_API_ENDPOINTS[network];
|
|
19
|
-
if (!host) {
|
|
20
|
-
throw new Error(`Unsupported network: ${network}`);
|
|
21
|
-
}
|
|
22
|
-
const url = `${host}/create-app`;
|
|
23
|
-
const response = await fetch(url, {
|
|
24
|
-
method: "POST",
|
|
25
|
-
headers: {
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
Authorization: `Bearer ${token}`
|
|
28
|
-
},
|
|
29
|
-
body: JSON.stringify({
|
|
30
|
-
name,
|
|
31
|
-
publicKey,
|
|
32
|
-
metadataURI,
|
|
33
|
-
ownerEmail
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
if (!response.ok) {
|
|
37
|
-
const text = await response.text();
|
|
38
|
-
throw new Error(`Error creating app (${response.status}): ${text}`);
|
|
39
|
-
}
|
|
40
|
-
return response.json();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/cli/index.ts
|
|
44
10
|
var program = new Command();
|
|
45
11
|
program.name("anymal").description("Anymal Protocol helper CLI").version("1.0.0");
|
|
46
12
|
program.command("keygen").description("Generate a new secp256k1 private key (hex)").action(() => {
|
package/dist/index.d.mts
CHANGED
|
@@ -104,12 +104,12 @@ declare function fetchAnymals({ dbAuthToken, endpoint, userPid, }: {
|
|
|
104
104
|
|
|
105
105
|
declare function useFetchAnymals(): typeof fetchAnymals;
|
|
106
106
|
|
|
107
|
-
declare function useProcessPartialKibblePayment(): (pid: string, nftId: string, orderId: string, dbAuthToken: string, marketplaceContract: string, smartAccount: any, bundlerClient: any, amountInTokens:
|
|
107
|
+
declare function useProcessPartialKibblePayment(): (pid: string, nftId: string, orderId: string, dbAuthToken: string, marketplaceContract: string, smartAccount: any, bundlerClient: any, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string, deadline: number, backendSignature: string) => Promise<{
|
|
108
108
|
success: boolean;
|
|
109
109
|
message: string;
|
|
110
110
|
}>;
|
|
111
111
|
|
|
112
|
-
declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketplaceContract: string, amount:
|
|
112
|
+
declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketplaceContract: string, amount: bigint, smartAccount: any, bundlerClient: any) => Promise<{
|
|
113
113
|
success: boolean;
|
|
114
114
|
message: string;
|
|
115
115
|
}>;
|
|
@@ -133,9 +133,7 @@ declare function useCreateOrganizationBase(): (orgPid: string, orgName: string,
|
|
|
133
133
|
/**
|
|
134
134
|
* React hook to approve the PartialPaymentModule to spend tokens on behalf of the organization.
|
|
135
135
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @returns {Function} - Async function to process the approval.
|
|
136
|
+
* Uses the helper logic from `processApproval` to perform the operation with retries and gas estimation.
|
|
139
137
|
*/
|
|
140
138
|
declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint) => Promise<{
|
|
141
139
|
success: boolean;
|
|
@@ -145,12 +143,9 @@ declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kib
|
|
|
145
143
|
/**
|
|
146
144
|
* React hook to process a partial KIBBLE payment via the Organization contract.
|
|
147
145
|
*
|
|
148
|
-
*
|
|
149
|
-
* to execute the partialPay call on the PartialPaymentModule.
|
|
150
|
-
*
|
|
151
|
-
* @returns {Function} - Async function to process the partial payment.
|
|
146
|
+
* Uses the `processPartialPayment` helper to encapsulate bundler logic and retries.
|
|
152
147
|
*/
|
|
153
|
-
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string
|
|
148
|
+
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`) => Promise<{
|
|
154
149
|
success: boolean;
|
|
155
150
|
message: string;
|
|
156
151
|
}>;
|
|
@@ -174,6 +169,14 @@ declare const NETWORK_HOSTS: Record<Network, string>;
|
|
|
174
169
|
* Mapping from network to audience host
|
|
175
170
|
*/
|
|
176
171
|
declare const AUTH_API_ENDPOINTS: Record<Network, string>;
|
|
172
|
+
/**
|
|
173
|
+
* Mapping for public fb api key
|
|
174
|
+
*/
|
|
175
|
+
declare const FIREBASE_WEB_API_KEYS: Record<Network, string>;
|
|
176
|
+
/**
|
|
177
|
+
* Mapping for fb auth
|
|
178
|
+
*/
|
|
179
|
+
declare const FIREBASE_WEB_AUTH_API_ENDPOINTS: Record<Network, string>;
|
|
177
180
|
/**
|
|
178
181
|
* Output of authentication envelope
|
|
179
182
|
*/
|
|
@@ -227,6 +230,51 @@ declare function createAuthEnvelope(privateKeyHex: string, network?: Network, op
|
|
|
227
230
|
*/
|
|
228
231
|
declare function generateAppSignature(privateKeyHex: string, clientId: string, redirectUri: string, state: string): Promise<string>;
|
|
229
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Create a new application via the Anymal backend.
|
|
235
|
+
* @param privateKeyHex - Hex‑encoded secp256k1 private key
|
|
236
|
+
* @param name - Name of your application
|
|
237
|
+
* @param metadataURI - Metadata URI for your application (can be blank)
|
|
238
|
+
* @param ownerEmail - Owner email address
|
|
239
|
+
* @param network - Target network (defaults to testnet)
|
|
240
|
+
* @param options - Optional JWT settings (e.g., expiresInSeconds)
|
|
241
|
+
*/
|
|
242
|
+
declare function createApp(privateKeyHex: string, name: string, metadataURI: string, ownerEmail: string, network?: Network, options?: JWTOptions): Promise<any>;
|
|
243
|
+
declare function getFirebaseTokenForApp(privateKeyHex: string, appId: string, network?: Network): Promise<{
|
|
244
|
+
firebaseToken: string;
|
|
245
|
+
}>;
|
|
246
|
+
declare function flattenFirestoreData(fields: any): Record<string, any>;
|
|
247
|
+
|
|
248
|
+
declare function processDirectKibbleApproval(kibbleTokenAddress: string, spenderAddress: string, smartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint): Promise<{
|
|
249
|
+
success: boolean;
|
|
250
|
+
message: string;
|
|
251
|
+
opHash?: string;
|
|
252
|
+
}>;
|
|
253
|
+
|
|
254
|
+
declare function processDirectPartialPayment(marketplaceContract: string, smartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`): Promise<{
|
|
255
|
+
success: boolean;
|
|
256
|
+
message: string;
|
|
257
|
+
opHash?: string;
|
|
258
|
+
}>;
|
|
259
|
+
|
|
260
|
+
declare function processOrgKibbleApproval(orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint): Promise<{
|
|
261
|
+
success: boolean;
|
|
262
|
+
message: string;
|
|
263
|
+
opHash?: string;
|
|
264
|
+
}>;
|
|
265
|
+
|
|
266
|
+
declare function processOrgPartialPayment(orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`): Promise<{
|
|
267
|
+
success: boolean;
|
|
268
|
+
message: string;
|
|
269
|
+
opHash?: string;
|
|
270
|
+
}>;
|
|
271
|
+
|
|
272
|
+
declare function sendUserOpWithRetries(bundlerClient: BundlerClient, params: Parameters<BundlerClient["sendUserOperation"]>[0], retries?: number, delay?: number): Promise<`0x${string}`>;
|
|
273
|
+
|
|
274
|
+
declare function waitForAllowance(publicClient: any, tokenAddress: `0x${string}`, ownerAddress: `0x${string}`, spenderAddress: `0x${string}`, expectedAmount: bigint): Promise<boolean>;
|
|
275
|
+
|
|
276
|
+
declare function waitForReceiptWithRetries(bundlerClient: BundlerClient, hash: `0x${string}`, retries?: number, delay?: number): Promise<Awaited<ReturnType<typeof bundlerClient.waitForUserOperationReceipt>>>;
|
|
277
|
+
|
|
230
278
|
/**
|
|
231
279
|
* Types of actions you can submit
|
|
232
280
|
*/
|
|
@@ -449,4 +497,4 @@ declare function useClaimOrgActionReward(): (orgContractAddress: string, rewarda
|
|
|
449
497
|
|
|
450
498
|
declare function useSubmitContractAction(): (idToken: string, pid: string, source: ActionSourceType, endpoint: string, payload: ActionPayload) => Promise<SubmitResponse> | undefined;
|
|
451
499
|
|
|
452
|
-
export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
500
|
+
export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
|
package/dist/index.d.ts
CHANGED
|
@@ -104,12 +104,12 @@ declare function fetchAnymals({ dbAuthToken, endpoint, userPid, }: {
|
|
|
104
104
|
|
|
105
105
|
declare function useFetchAnymals(): typeof fetchAnymals;
|
|
106
106
|
|
|
107
|
-
declare function useProcessPartialKibblePayment(): (pid: string, nftId: string, orderId: string, dbAuthToken: string, marketplaceContract: string, smartAccount: any, bundlerClient: any, amountInTokens:
|
|
107
|
+
declare function useProcessPartialKibblePayment(): (pid: string, nftId: string, orderId: string, dbAuthToken: string, marketplaceContract: string, smartAccount: any, bundlerClient: any, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string, deadline: number, backendSignature: string) => Promise<{
|
|
108
108
|
success: boolean;
|
|
109
109
|
message: string;
|
|
110
110
|
}>;
|
|
111
111
|
|
|
112
|
-
declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketplaceContract: string, amount:
|
|
112
|
+
declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketplaceContract: string, amount: bigint, smartAccount: any, bundlerClient: any) => Promise<{
|
|
113
113
|
success: boolean;
|
|
114
114
|
message: string;
|
|
115
115
|
}>;
|
|
@@ -133,9 +133,7 @@ declare function useCreateOrganizationBase(): (orgPid: string, orgName: string,
|
|
|
133
133
|
/**
|
|
134
134
|
* React hook to approve the PartialPaymentModule to spend tokens on behalf of the organization.
|
|
135
135
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @returns {Function} - Async function to process the approval.
|
|
136
|
+
* Uses the helper logic from `processApproval` to perform the operation with retries and gas estimation.
|
|
139
137
|
*/
|
|
140
138
|
declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint) => Promise<{
|
|
141
139
|
success: boolean;
|
|
@@ -145,12 +143,9 @@ declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kib
|
|
|
145
143
|
/**
|
|
146
144
|
* React hook to process a partial KIBBLE payment via the Organization contract.
|
|
147
145
|
*
|
|
148
|
-
*
|
|
149
|
-
* to execute the partialPay call on the PartialPaymentModule.
|
|
150
|
-
*
|
|
151
|
-
* @returns {Function} - Async function to process the partial payment.
|
|
146
|
+
* Uses the `processPartialPayment` helper to encapsulate bundler logic and retries.
|
|
152
147
|
*/
|
|
153
|
-
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string
|
|
148
|
+
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`) => Promise<{
|
|
154
149
|
success: boolean;
|
|
155
150
|
message: string;
|
|
156
151
|
}>;
|
|
@@ -174,6 +169,14 @@ declare const NETWORK_HOSTS: Record<Network, string>;
|
|
|
174
169
|
* Mapping from network to audience host
|
|
175
170
|
*/
|
|
176
171
|
declare const AUTH_API_ENDPOINTS: Record<Network, string>;
|
|
172
|
+
/**
|
|
173
|
+
* Mapping for public fb api key
|
|
174
|
+
*/
|
|
175
|
+
declare const FIREBASE_WEB_API_KEYS: Record<Network, string>;
|
|
176
|
+
/**
|
|
177
|
+
* Mapping for fb auth
|
|
178
|
+
*/
|
|
179
|
+
declare const FIREBASE_WEB_AUTH_API_ENDPOINTS: Record<Network, string>;
|
|
177
180
|
/**
|
|
178
181
|
* Output of authentication envelope
|
|
179
182
|
*/
|
|
@@ -227,6 +230,51 @@ declare function createAuthEnvelope(privateKeyHex: string, network?: Network, op
|
|
|
227
230
|
*/
|
|
228
231
|
declare function generateAppSignature(privateKeyHex: string, clientId: string, redirectUri: string, state: string): Promise<string>;
|
|
229
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Create a new application via the Anymal backend.
|
|
235
|
+
* @param privateKeyHex - Hex‑encoded secp256k1 private key
|
|
236
|
+
* @param name - Name of your application
|
|
237
|
+
* @param metadataURI - Metadata URI for your application (can be blank)
|
|
238
|
+
* @param ownerEmail - Owner email address
|
|
239
|
+
* @param network - Target network (defaults to testnet)
|
|
240
|
+
* @param options - Optional JWT settings (e.g., expiresInSeconds)
|
|
241
|
+
*/
|
|
242
|
+
declare function createApp(privateKeyHex: string, name: string, metadataURI: string, ownerEmail: string, network?: Network, options?: JWTOptions): Promise<any>;
|
|
243
|
+
declare function getFirebaseTokenForApp(privateKeyHex: string, appId: string, network?: Network): Promise<{
|
|
244
|
+
firebaseToken: string;
|
|
245
|
+
}>;
|
|
246
|
+
declare function flattenFirestoreData(fields: any): Record<string, any>;
|
|
247
|
+
|
|
248
|
+
declare function processDirectKibbleApproval(kibbleTokenAddress: string, spenderAddress: string, smartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint): Promise<{
|
|
249
|
+
success: boolean;
|
|
250
|
+
message: string;
|
|
251
|
+
opHash?: string;
|
|
252
|
+
}>;
|
|
253
|
+
|
|
254
|
+
declare function processDirectPartialPayment(marketplaceContract: string, smartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`): Promise<{
|
|
255
|
+
success: boolean;
|
|
256
|
+
message: string;
|
|
257
|
+
opHash?: string;
|
|
258
|
+
}>;
|
|
259
|
+
|
|
260
|
+
declare function processOrgKibbleApproval(orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint): Promise<{
|
|
261
|
+
success: boolean;
|
|
262
|
+
message: string;
|
|
263
|
+
opHash?: string;
|
|
264
|
+
}>;
|
|
265
|
+
|
|
266
|
+
declare function processOrgPartialPayment(orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: `0x${string}`, deadline: number, backendSignature: `0x${string}`): Promise<{
|
|
267
|
+
success: boolean;
|
|
268
|
+
message: string;
|
|
269
|
+
opHash?: string;
|
|
270
|
+
}>;
|
|
271
|
+
|
|
272
|
+
declare function sendUserOpWithRetries(bundlerClient: BundlerClient, params: Parameters<BundlerClient["sendUserOperation"]>[0], retries?: number, delay?: number): Promise<`0x${string}`>;
|
|
273
|
+
|
|
274
|
+
declare function waitForAllowance(publicClient: any, tokenAddress: `0x${string}`, ownerAddress: `0x${string}`, spenderAddress: `0x${string}`, expectedAmount: bigint): Promise<boolean>;
|
|
275
|
+
|
|
276
|
+
declare function waitForReceiptWithRetries(bundlerClient: BundlerClient, hash: `0x${string}`, retries?: number, delay?: number): Promise<Awaited<ReturnType<typeof bundlerClient.waitForUserOperationReceipt>>>;
|
|
277
|
+
|
|
230
278
|
/**
|
|
231
279
|
* Types of actions you can submit
|
|
232
280
|
*/
|
|
@@ -449,4 +497,4 @@ declare function useClaimOrgActionReward(): (orgContractAddress: string, rewarda
|
|
|
449
497
|
|
|
450
498
|
declare function useSubmitContractAction(): (idToken: string, pid: string, source: ActionSourceType, endpoint: string, payload: ActionPayload) => Promise<SubmitResponse> | undefined;
|
|
451
499
|
|
|
452
|
-
export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createAuthEnvelope, fetchAnymals, generateAppSignature, generateBytes32Nonce, generateJWT, loadExistingSecp256k1PrivateKey, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
500
|
+
export { AUTH_API_ENDPOINTS, type ActionDefinition, type ActionPayload, type ActionRecord, type ActionReferral, ActionSourceType, ActionStatus, ActionType, type AnymalNftMetadataInputData, type AuthEnvelope, type ContractActionPayload, type CreateAnymalInputData, type ExternalActionPayload, FIREBASE_WEB_API_KEYS, FIREBASE_WEB_AUTH_API_ENDPOINTS, type GraphQLActionPayload, type JWTOptions, type MarketplaceActionPayload, MarketplacePaymentType, NETWORK_HOSTS, Network, type NotificationData, type NotificationEventData, type SubmitResponse, type WishlistPurchaseActionPayload, convertToActionDefinition, convertToActionRecord, convertToMultipleActionDefinitions, convertToMultipleActionRecords, createApp, createAuthEnvelope, fetchAnymals, flattenFirestoreData, generateAppSignature, generateBytes32Nonce, generateJWT, getFirebaseTokenForApp, loadExistingSecp256k1PrivateKey, processDirectKibbleApproval, processDirectPartialPayment, processOrgKibbleApproval, processOrgPartialPayment, sendUserOpWithRetries, serializePublicKeyCompressed, submitAction, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useClaimActionReward, useClaimOrgActionReward, useCreateOrganizationAppData, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchActionDefinitions, useFetchActions, useFetchAnymals, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useSubmitContractAction, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession, waitForAllowance, waitForReceiptWithRetries };
|