@1shotapi/client-sdk 1.0.0
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/README.md +162 -0
- package/dist/categories/chains.d.ts +21 -0
- package/dist/categories/chains.js +44 -0
- package/dist/categories/chains.js.map +1 -0
- package/dist/categories/contractEvents.d.ts +103 -0
- package/dist/categories/contractEvents.js +115 -0
- package/dist/categories/contractEvents.js.map +1 -0
- package/dist/categories/contractMethods.d.ts +377 -0
- package/dist/categories/contractMethods.js +317 -0
- package/dist/categories/contractMethods.js.map +1 -0
- package/dist/categories/structs.d.ts +40 -0
- package/dist/categories/structs.js +68 -0
- package/dist/categories/structs.js.map +1 -0
- package/dist/categories/transactions.d.ts +31 -0
- package/dist/categories/transactions.js +51 -0
- package/dist/categories/transactions.js.map +1 -0
- package/dist/categories/wallets.d.ts +167 -0
- package/dist/categories/wallets.js +238 -0
- package/dist/categories/wallets.js.map +1 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +61 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/types/abi.d.ts +32 -0
- package/dist/types/abi.js +2 -0
- package/dist/types/abi.js.map +1 -0
- package/dist/types/chain.d.ts +26 -0
- package/dist/types/chain.js +2 -0
- package/dist/types/chain.js.map +1 -0
- package/dist/types/client.d.ts +13 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/common.d.ts +8 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/contract.d.ts +5 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/contractEvent.d.ts +46 -0
- package/dist/types/contractEvent.js +2 -0
- package/dist/types/contractEvent.js.map +1 -0
- package/dist/types/contractMethod.d.ts +31 -0
- package/dist/types/contractMethod.js +2 -0
- package/dist/types/contractMethod.js.map +1 -0
- package/dist/types/struct.d.ts +8 -0
- package/dist/types/struct.js +2 -0
- package/dist/types/struct.js.map +1 -0
- package/dist/types/transaction.d.ts +12 -0
- package/dist/types/transaction.js +2 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/types/wallet.d.ts +30 -0
- package/dist/types/wallet.js +2 -0
- package/dist/types/wallet.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/webhook.d.ts +19 -0
- package/dist/utils/webhook.js +66 -0
- package/dist/utils/webhook.js.map +1 -0
- package/dist/validation/abi.d.ts +470 -0
- package/dist/validation/abi.js +99 -0
- package/dist/validation/abi.js.map +1 -0
- package/dist/validation/chain.d.ts +157 -0
- package/dist/validation/chain.js +71 -0
- package/dist/validation/chain.js.map +1 -0
- package/dist/validation/common.d.ts +17 -0
- package/dist/validation/common.js +16 -0
- package/dist/validation/common.js.map +1 -0
- package/dist/validation/contractEvent.d.ts +323 -0
- package/dist/validation/contractEvent.js +148 -0
- package/dist/validation/contractEvent.js.map +1 -0
- package/dist/validation/contractMethod.d.ts +2746 -0
- package/dist/validation/contractMethod.js +787 -0
- package/dist/validation/contractMethod.js.map +1 -0
- package/dist/validation/struct.d.ts +495 -0
- package/dist/validation/struct.js +291 -0
- package/dist/validation/struct.js.map +1 -0
- package/dist/validation/transaction.d.ts +359 -0
- package/dist/validation/transaction.js +206 -0
- package/dist/validation/transaction.js.map +1 -0
- package/dist/validation/wallet.d.ts +537 -0
- package/dist/validation/wallet.js +287 -0
- package/dist/validation/wallet.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { z } from "zod/index.js";
|
|
2
|
+
import { EthereumAbi } from "../types/abi.js";
|
|
3
|
+
import { IOneShotClient } from "../types/client.js";
|
|
4
|
+
import { FullPrompt } from "../types/contract.js";
|
|
5
|
+
import { ContractMethod, ContractMethodList, ContractMethodEstimate, ContractMethodTestResult, ContractMethodEncodeResult, ContractMethodParams, ContractMethodStateMutability, ERC7702Authorization, ExecuteBatchContractMethod, ExecuteBatchAsDelegatorContractMethod } from "../types/contractMethod.js";
|
|
6
|
+
import { NewSolidityStructParam } from "../types/struct.js";
|
|
7
|
+
import { Transaction } from "../types/transaction.js";
|
|
8
|
+
declare const listContractMethodsSchemaOptions: z.ZodObject<Omit<{
|
|
9
|
+
businessId: z.ZodString;
|
|
10
|
+
pageSize: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
11
|
+
page: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
+
chainId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
13
|
+
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
status: z.ZodNullable<z.ZodOptional<z.ZodEnum<["live", "archived", "both"]>>>;
|
|
15
|
+
contractAddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
16
|
+
promptId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
methodType: z.ZodNullable<z.ZodOptional<z.ZodEnum<["read", "write"]>>>;
|
|
18
|
+
}, "businessId">, "strip", z.ZodTypeAny, {
|
|
19
|
+
status?: "live" | "archived" | "both" | null | undefined;
|
|
20
|
+
name?: string | null | undefined;
|
|
21
|
+
chainId?: number | null | undefined;
|
|
22
|
+
page?: number | null | undefined;
|
|
23
|
+
pageSize?: number | null | undefined;
|
|
24
|
+
contractAddress?: string | null | undefined;
|
|
25
|
+
promptId?: string | null | undefined;
|
|
26
|
+
methodType?: "read" | "write" | null | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
status?: "live" | "archived" | "both" | null | undefined;
|
|
29
|
+
name?: string | null | undefined;
|
|
30
|
+
chainId?: number | null | undefined;
|
|
31
|
+
page?: number | null | undefined;
|
|
32
|
+
pageSize?: number | null | undefined;
|
|
33
|
+
contractAddress?: string | null | undefined;
|
|
34
|
+
promptId?: string | null | undefined;
|
|
35
|
+
methodType?: "read" | "write" | null | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
declare const assureContractMethodsFromPromptSchemaOptions: z.ZodObject<Omit<{
|
|
38
|
+
businessId: z.ZodString;
|
|
39
|
+
chainId: z.ZodNumber;
|
|
40
|
+
contractAddress: z.ZodString;
|
|
41
|
+
walletId: z.ZodString;
|
|
42
|
+
promptId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
43
|
+
}, "businessId">, "strip", z.ZodTypeAny, {
|
|
44
|
+
chainId: number;
|
|
45
|
+
contractAddress: string;
|
|
46
|
+
walletId: string;
|
|
47
|
+
promptId?: string | null | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
chainId: number;
|
|
50
|
+
contractAddress: string;
|
|
51
|
+
walletId: string;
|
|
52
|
+
promptId?: string | null | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
declare const encodeContractMethodSchemaOptions: z.ZodObject<Omit<{
|
|
55
|
+
contractMethodId: z.ZodString;
|
|
56
|
+
params: z.ZodType<{
|
|
57
|
+
[key: string]: string | number | boolean | any[] | {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
} | null | undefined;
|
|
60
|
+
}, z.ZodTypeDef, {
|
|
61
|
+
[key: string]: string | number | boolean | any[] | {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
} | null | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
authorizationList: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
66
|
+
address: z.ZodString;
|
|
67
|
+
nonce: z.ZodString;
|
|
68
|
+
chainId: z.ZodNumber;
|
|
69
|
+
signature: z.ZodString;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
chainId: number;
|
|
72
|
+
address: string;
|
|
73
|
+
nonce: string;
|
|
74
|
+
signature: string;
|
|
75
|
+
}, {
|
|
76
|
+
chainId: number;
|
|
77
|
+
address: string;
|
|
78
|
+
nonce: string;
|
|
79
|
+
signature: string;
|
|
80
|
+
}>, "many">>>;
|
|
81
|
+
value: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
82
|
+
}, "params" | "contractMethodId">, "strip", z.ZodTypeAny, {
|
|
83
|
+
value?: string | null | undefined;
|
|
84
|
+
authorizationList?: {
|
|
85
|
+
chainId: number;
|
|
86
|
+
address: string;
|
|
87
|
+
nonce: string;
|
|
88
|
+
signature: string;
|
|
89
|
+
}[] | null | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
value?: string | null | undefined;
|
|
92
|
+
authorizationList?: {
|
|
93
|
+
chainId: number;
|
|
94
|
+
address: string;
|
|
95
|
+
nonce: string;
|
|
96
|
+
signature: string;
|
|
97
|
+
}[] | null | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
declare const executeContractMethodSchemaOptions: z.ZodObject<Omit<{
|
|
100
|
+
contractMethodId: z.ZodString;
|
|
101
|
+
params: z.ZodType<{
|
|
102
|
+
[key: string]: string | number | boolean | any[] | {
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
} | null | undefined;
|
|
105
|
+
}, z.ZodTypeDef, {
|
|
106
|
+
[key: string]: string | number | boolean | any[] | {
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
} | null | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
walletId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
111
|
+
memo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
112
|
+
authorizationList: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
113
|
+
address: z.ZodString;
|
|
114
|
+
nonce: z.ZodString;
|
|
115
|
+
chainId: z.ZodNumber;
|
|
116
|
+
signature: z.ZodString;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
chainId: number;
|
|
119
|
+
address: string;
|
|
120
|
+
nonce: string;
|
|
121
|
+
signature: string;
|
|
122
|
+
}, {
|
|
123
|
+
chainId: number;
|
|
124
|
+
address: string;
|
|
125
|
+
nonce: string;
|
|
126
|
+
signature: string;
|
|
127
|
+
}>, "many">>>;
|
|
128
|
+
value: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
129
|
+
contractAddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
130
|
+
authorizationDataAddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
131
|
+
}, "params" | "contractMethodId">, "strip", z.ZodTypeAny, {
|
|
132
|
+
value?: string | null | undefined;
|
|
133
|
+
contractAddress?: string | null | undefined;
|
|
134
|
+
walletId?: string | null | undefined;
|
|
135
|
+
memo?: string | null | undefined;
|
|
136
|
+
authorizationList?: {
|
|
137
|
+
chainId: number;
|
|
138
|
+
address: string;
|
|
139
|
+
nonce: string;
|
|
140
|
+
signature: string;
|
|
141
|
+
}[] | null | undefined;
|
|
142
|
+
authorizationDataAddress?: string | null | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
value?: string | null | undefined;
|
|
145
|
+
contractAddress?: string | null | undefined;
|
|
146
|
+
walletId?: string | null | undefined;
|
|
147
|
+
memo?: string | null | undefined;
|
|
148
|
+
authorizationList?: {
|
|
149
|
+
chainId: number;
|
|
150
|
+
address: string;
|
|
151
|
+
nonce: string;
|
|
152
|
+
signature: string;
|
|
153
|
+
}[] | null | undefined;
|
|
154
|
+
authorizationDataAddress?: string | null | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
declare const executeAsDelegatorContractMethodSchemaOptions: z.ZodObject<Omit<{
|
|
157
|
+
contractMethodId: z.ZodString;
|
|
158
|
+
params: z.ZodType<{
|
|
159
|
+
[key: string]: string | number | boolean | any[] | {
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
} | null | undefined;
|
|
162
|
+
}, z.ZodTypeDef, {
|
|
163
|
+
[key: string]: string | number | boolean | any[] | {
|
|
164
|
+
[key: string]: any;
|
|
165
|
+
} | null | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
walletId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
168
|
+
memo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
169
|
+
authorizationList: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
170
|
+
address: z.ZodString;
|
|
171
|
+
nonce: z.ZodString;
|
|
172
|
+
chainId: z.ZodNumber;
|
|
173
|
+
signature: z.ZodString;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
chainId: number;
|
|
176
|
+
address: string;
|
|
177
|
+
nonce: string;
|
|
178
|
+
signature: string;
|
|
179
|
+
}, {
|
|
180
|
+
chainId: number;
|
|
181
|
+
address: string;
|
|
182
|
+
nonce: string;
|
|
183
|
+
signature: string;
|
|
184
|
+
}>, "many">>>;
|
|
185
|
+
delegatorAddress: z.ZodString;
|
|
186
|
+
value: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
187
|
+
}, "params" | "contractMethodId" | "delegatorAddress">, "strip", z.ZodTypeAny, {
|
|
188
|
+
value?: string | null | undefined;
|
|
189
|
+
walletId?: string | null | undefined;
|
|
190
|
+
memo?: string | null | undefined;
|
|
191
|
+
authorizationList?: {
|
|
192
|
+
chainId: number;
|
|
193
|
+
address: string;
|
|
194
|
+
nonce: string;
|
|
195
|
+
signature: string;
|
|
196
|
+
}[] | null | undefined;
|
|
197
|
+
}, {
|
|
198
|
+
value?: string | null | undefined;
|
|
199
|
+
walletId?: string | null | undefined;
|
|
200
|
+
memo?: string | null | undefined;
|
|
201
|
+
authorizationList?: {
|
|
202
|
+
chainId: number;
|
|
203
|
+
address: string;
|
|
204
|
+
nonce: string;
|
|
205
|
+
signature: string;
|
|
206
|
+
}[] | null | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
export declare class ContractMethods {
|
|
209
|
+
private client;
|
|
210
|
+
constructor(client: IOneShotClient);
|
|
211
|
+
/**
|
|
212
|
+
* Execute a contractMethod
|
|
213
|
+
* @param contractMethodId The ID of the contractMethod to execute
|
|
214
|
+
* @param params Configuration parameters for the contractMethod
|
|
215
|
+
* @param options Optional execution options
|
|
216
|
+
* @returns Promise<Transaction>
|
|
217
|
+
* @throws {ZodError} If the parameters are invalid
|
|
218
|
+
*/
|
|
219
|
+
execute(contractMethodId: string, params: ContractMethodParams, options?: z.infer<typeof executeContractMethodSchemaOptions>): Promise<Transaction>;
|
|
220
|
+
/**
|
|
221
|
+
* Execute a contractMethod as a delegator
|
|
222
|
+
* @param contractMethodId The ID of the contractMethod to execute as a delegator
|
|
223
|
+
* @param params Configuration parameters for the contractMethod
|
|
224
|
+
* @param options Optional execution options
|
|
225
|
+
* @returns Promise<Transaction>
|
|
226
|
+
* @throws {ZodError} If the parameters are invalid
|
|
227
|
+
*/
|
|
228
|
+
executeAsDelegator(contractMethodId: string, delegatorAddress: string, params: ContractMethodParams, options: z.infer<typeof executeAsDelegatorContractMethodSchemaOptions>): Promise<Transaction>;
|
|
229
|
+
/**
|
|
230
|
+
* Execute multiple contract methods in a single batch transaction
|
|
231
|
+
* @param params Batch execution parameters including contract methods and wallet ID
|
|
232
|
+
* @returns Promise<Transaction>
|
|
233
|
+
* @throws {ZodError} If the parameters are invalid
|
|
234
|
+
*/
|
|
235
|
+
executeBatch(params: ExecuteBatchContractMethod): Promise<Transaction>;
|
|
236
|
+
/**
|
|
237
|
+
* Execute multiple contract methods in a single batch transaction as delegator
|
|
238
|
+
* @param params Batch execution parameters including contract methods, wallet ID, and delegator addresses
|
|
239
|
+
* @returns Promise<Transaction>
|
|
240
|
+
* @throws {ZodError} If the parameters are invalid
|
|
241
|
+
*/
|
|
242
|
+
executeBatchAsDelegator(params: ExecuteBatchAsDelegatorContractMethod): Promise<Transaction>;
|
|
243
|
+
/**
|
|
244
|
+
* Test a contractMethod without actually executing it
|
|
245
|
+
* @param contractMethodId The ID of the contractMethod to test
|
|
246
|
+
* @param params Configuration parameters for the contractMethod
|
|
247
|
+
* @param options Optional test options
|
|
248
|
+
* @returns Promise<ContractMethodTestResult>
|
|
249
|
+
* @throws {ZodError} If the parameters are invalid
|
|
250
|
+
*/
|
|
251
|
+
test(contractMethodId: string, params: ContractMethodParams, options?: {
|
|
252
|
+
authorizationList?: ERC7702Authorization[];
|
|
253
|
+
value?: string;
|
|
254
|
+
contractAddress?: string;
|
|
255
|
+
}): Promise<ContractMethodTestResult>;
|
|
256
|
+
/**
|
|
257
|
+
* Get a contractMethod by ID
|
|
258
|
+
* @param id ContractMethod ID
|
|
259
|
+
* @returns Promise<ContractMethod>
|
|
260
|
+
* @throws {ZodError} If the ID is invalid
|
|
261
|
+
*/
|
|
262
|
+
get(id: string): Promise<ContractMethod>;
|
|
263
|
+
/**
|
|
264
|
+
* List contractMethods for a business
|
|
265
|
+
* @param businessId The business ID to list contractMethods for
|
|
266
|
+
* @param params Optional filter parameters
|
|
267
|
+
* @returns Promise<ContractMethodList>
|
|
268
|
+
* @throws {ZodError} If the parameters are invalid
|
|
269
|
+
*/
|
|
270
|
+
list(businessId: string, params?: z.infer<typeof listContractMethodsSchemaOptions>): Promise<ContractMethodList>;
|
|
271
|
+
/**
|
|
272
|
+
* Estimate the cost of executing a contractMethod
|
|
273
|
+
* @param contractMethodId The ID of the contractMethod to estimate
|
|
274
|
+
* @param params Configuration parameters for the contractMethod
|
|
275
|
+
* @param options Optional estimation options
|
|
276
|
+
* @returns Promise<ContractMethodEstimate>
|
|
277
|
+
* @throws {ZodError} If the parameters are invalid
|
|
278
|
+
*/
|
|
279
|
+
estimate(contractMethodId: string, params: ContractMethodParams, options?: {
|
|
280
|
+
authorizationList?: ERC7702Authorization[];
|
|
281
|
+
value?: string;
|
|
282
|
+
}): Promise<ContractMethodEstimate>;
|
|
283
|
+
/**
|
|
284
|
+
* Encode a contractMethod to get the transaction data
|
|
285
|
+
* @param contractMethodId The ID of the contractMethod to encode
|
|
286
|
+
* @param params Configuration parameters for the contractMethod
|
|
287
|
+
* @param options Optional encoding options
|
|
288
|
+
* @returns Promise<ContractMethodEncodeResult>
|
|
289
|
+
* @throws {ZodError} If the parameters are invalid
|
|
290
|
+
*/
|
|
291
|
+
encode(contractMethodId: string, params: ContractMethodParams, options?: z.infer<typeof encodeContractMethodSchemaOptions>): Promise<ContractMethodEncodeResult>;
|
|
292
|
+
/**
|
|
293
|
+
* Read the result of a view or pure function
|
|
294
|
+
* @param contractMethodId The ID of the contractMethod to read
|
|
295
|
+
* @param params Configuration parameters for the contractMethod
|
|
296
|
+
* @returns Promise<any> The JSON value returned by the function
|
|
297
|
+
* @throws {ZodError} If the parameters are invalid
|
|
298
|
+
*/
|
|
299
|
+
read(contractMethodId: string, params: ContractMethodParams): Promise<any>;
|
|
300
|
+
/**
|
|
301
|
+
* Create a new contractMethod
|
|
302
|
+
* @param businessId The business ID to create the contractMethod for
|
|
303
|
+
* @param params ContractMethod creation parameters
|
|
304
|
+
* @returns Promise<ContractMethod>
|
|
305
|
+
* @throws {ZodError} If the parameters are invalid
|
|
306
|
+
*/
|
|
307
|
+
create(businessId: string, params: {
|
|
308
|
+
chainId: number;
|
|
309
|
+
contractAddress: string;
|
|
310
|
+
walletId: string;
|
|
311
|
+
name: string;
|
|
312
|
+
description: string;
|
|
313
|
+
functionName: string;
|
|
314
|
+
stateMutability: ContractMethodStateMutability;
|
|
315
|
+
inputs: NewSolidityStructParam[];
|
|
316
|
+
outputs: NewSolidityStructParam[];
|
|
317
|
+
callbackUrl?: string | null;
|
|
318
|
+
}): Promise<ContractMethod>;
|
|
319
|
+
/**
|
|
320
|
+
* Import contractMethods from an ABI
|
|
321
|
+
* @param businessId The business ID to create the contractMethods for
|
|
322
|
+
* @param params ABI import parameters
|
|
323
|
+
* @returns Promise<ContractMethod[]>
|
|
324
|
+
* @throws {ZodError} If the parameters are invalid
|
|
325
|
+
*/
|
|
326
|
+
importFromABI(businessId: string, params: {
|
|
327
|
+
chainId: number;
|
|
328
|
+
contractAddress: string;
|
|
329
|
+
walletId: string;
|
|
330
|
+
name: string;
|
|
331
|
+
description: string;
|
|
332
|
+
abi: EthereumAbi;
|
|
333
|
+
}): Promise<ContractMethod[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Update a contractMethod
|
|
336
|
+
* @param contractMethodId The ID of the contractMethod to update
|
|
337
|
+
* @param params Update parameters
|
|
338
|
+
* @returns Promise<ContractMethod>
|
|
339
|
+
* @throws {ZodError} If the parameters are invalid
|
|
340
|
+
*/
|
|
341
|
+
update(contractMethodId: string, params: {
|
|
342
|
+
chainId?: number;
|
|
343
|
+
contractAddress?: string;
|
|
344
|
+
walletId?: string;
|
|
345
|
+
name?: string;
|
|
346
|
+
description?: string;
|
|
347
|
+
functionName?: string;
|
|
348
|
+
stateMutability?: ContractMethodStateMutability;
|
|
349
|
+
callbackUrl?: string | null;
|
|
350
|
+
}): Promise<ContractMethod>;
|
|
351
|
+
/**
|
|
352
|
+
* Delete a contractMethod
|
|
353
|
+
* @param contractMethodId The ID of the contractMethod to delete
|
|
354
|
+
* @returns Promise<void>
|
|
355
|
+
* @throws {ZodError} If the ID is invalid
|
|
356
|
+
*/
|
|
357
|
+
delete(contractMethodId: string): Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Search for contracts
|
|
360
|
+
* @param query The search query
|
|
361
|
+
* @param params Optional search parameters
|
|
362
|
+
* @returns Promise<FullPrompt[]>
|
|
363
|
+
* @throws {ZodError} If the parameters are invalid
|
|
364
|
+
*/
|
|
365
|
+
search(query: string, params?: {
|
|
366
|
+
chainId?: number;
|
|
367
|
+
}): Promise<FullPrompt[]>;
|
|
368
|
+
/**
|
|
369
|
+
* Assure contract methods exist for a given Prompt
|
|
370
|
+
* @param businessId The business ID to create the contract methods for
|
|
371
|
+
* @param params Parameters for creating contract methods from a Prompt
|
|
372
|
+
* @returns Promise<ContractMethod[]>
|
|
373
|
+
* @throws {ZodError} If the parameters are invalid
|
|
374
|
+
*/
|
|
375
|
+
assureContractMethodsFromPrompt(businessId: string, params: z.infer<typeof assureContractMethodsFromPromptSchemaOptions>): Promise<ContractMethod[]>;
|
|
376
|
+
}
|
|
377
|
+
export {};
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { contractMethodSchema, contractMethodListSchema, contractMethodEstimateSchema, listContractMethodsSchema, executeContractMethodSchema, executeAsDelegatorContractMethodSchema, executeBatchContractMethodSchema, executeBatchAsDelegatorContractMethodSchema, testContractMethodSchema, getContractMethodSchema, estimateContractMethodSchema, encodeContractMethodSchema, readContractMethodSchema, createContractMethodSchema, importFromABISchema, updateContractMethodSchema, deleteContractMethodSchema, contractSearchSchema, fullPromptSchema, contractMethodTestResultSchema, contractMethodEncodeResultSchema, assureContractMethodsFromPromptSchema, } from "../validation/contractMethod.js";
|
|
2
|
+
import { transactionSchema } from "../validation/transaction.js";
|
|
3
|
+
const listContractMethodsSchemaOptions = listContractMethodsSchema.omit({
|
|
4
|
+
businessId: true,
|
|
5
|
+
});
|
|
6
|
+
const assureContractMethodsFromPromptSchemaOptions = assureContractMethodsFromPromptSchema.omit({
|
|
7
|
+
businessId: true,
|
|
8
|
+
});
|
|
9
|
+
const encodeContractMethodSchemaOptions = encodeContractMethodSchema.omit({
|
|
10
|
+
contractMethodId: true,
|
|
11
|
+
params: true,
|
|
12
|
+
});
|
|
13
|
+
const executeContractMethodSchemaOptions = executeContractMethodSchema.omit({
|
|
14
|
+
contractMethodId: true,
|
|
15
|
+
params: true,
|
|
16
|
+
});
|
|
17
|
+
const executeAsDelegatorContractMethodSchemaOptions = executeAsDelegatorContractMethodSchema.omit({
|
|
18
|
+
contractMethodId: true,
|
|
19
|
+
params: true,
|
|
20
|
+
delegatorAddress: true,
|
|
21
|
+
});
|
|
22
|
+
export class ContractMethods {
|
|
23
|
+
constructor(client) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute a contractMethod
|
|
28
|
+
* @param contractMethodId The ID of the contractMethod to execute
|
|
29
|
+
* @param params Configuration parameters for the contractMethod
|
|
30
|
+
* @param options Optional execution options
|
|
31
|
+
* @returns Promise<Transaction>
|
|
32
|
+
* @throws {ZodError} If the parameters are invalid
|
|
33
|
+
*/
|
|
34
|
+
async execute(contractMethodId, params, options) {
|
|
35
|
+
const validatedParams = executeContractMethodSchema.parse({
|
|
36
|
+
contractMethodId,
|
|
37
|
+
params,
|
|
38
|
+
...options,
|
|
39
|
+
});
|
|
40
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/execute`, {
|
|
41
|
+
params: validatedParams.params,
|
|
42
|
+
walletId: validatedParams.walletId,
|
|
43
|
+
memo: validatedParams.memo,
|
|
44
|
+
authorizationList: validatedParams.authorizationList,
|
|
45
|
+
value: validatedParams.value,
|
|
46
|
+
contractAddress: validatedParams.contractAddress,
|
|
47
|
+
authorizationDataAddress: validatedParams.authorizationDataAddress,
|
|
48
|
+
});
|
|
49
|
+
return transactionSchema.parse(response);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Execute a contractMethod as a delegator
|
|
53
|
+
* @param contractMethodId The ID of the contractMethod to execute as a delegator
|
|
54
|
+
* @param params Configuration parameters for the contractMethod
|
|
55
|
+
* @param options Optional execution options
|
|
56
|
+
* @returns Promise<Transaction>
|
|
57
|
+
* @throws {ZodError} If the parameters are invalid
|
|
58
|
+
*/
|
|
59
|
+
async executeAsDelegator(contractMethodId, delegatorAddress, params, options) {
|
|
60
|
+
const validatedParams = executeAsDelegatorContractMethodSchema.parse({
|
|
61
|
+
contractMethodId,
|
|
62
|
+
delegatorAddress,
|
|
63
|
+
params,
|
|
64
|
+
...options,
|
|
65
|
+
});
|
|
66
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/executeAsDelegator`, {
|
|
67
|
+
params: validatedParams.params,
|
|
68
|
+
walletId: validatedParams.walletId,
|
|
69
|
+
memo: validatedParams.memo,
|
|
70
|
+
authorizationList: validatedParams.authorizationList,
|
|
71
|
+
delegatorAddress: validatedParams.delegatorAddress,
|
|
72
|
+
value: validatedParams.value,
|
|
73
|
+
});
|
|
74
|
+
return transactionSchema.parse(response);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Execute multiple contract methods in a single batch transaction
|
|
78
|
+
* @param params Batch execution parameters including contract methods and wallet ID
|
|
79
|
+
* @returns Promise<Transaction>
|
|
80
|
+
* @throws {ZodError} If the parameters are invalid
|
|
81
|
+
*/
|
|
82
|
+
async executeBatch(params) {
|
|
83
|
+
const validatedParams = executeBatchContractMethodSchema.parse(params);
|
|
84
|
+
const response = await this.client.request("POST", "/methods/executeBatch", {
|
|
85
|
+
contractMethods: validatedParams.contractMethods,
|
|
86
|
+
walletId: validatedParams.walletId,
|
|
87
|
+
atomic: validatedParams.atomic,
|
|
88
|
+
memo: validatedParams.memo,
|
|
89
|
+
authorizationList: validatedParams.authorizationList,
|
|
90
|
+
gasLimit: validatedParams.gasLimit,
|
|
91
|
+
});
|
|
92
|
+
return transactionSchema.parse(response);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute multiple contract methods in a single batch transaction as delegator
|
|
96
|
+
* @param params Batch execution parameters including contract methods, wallet ID, and delegator addresses
|
|
97
|
+
* @returns Promise<Transaction>
|
|
98
|
+
* @throws {ZodError} If the parameters are invalid
|
|
99
|
+
*/
|
|
100
|
+
async executeBatchAsDelegator(params) {
|
|
101
|
+
const validatedParams = executeBatchAsDelegatorContractMethodSchema.parse(params);
|
|
102
|
+
const response = await this.client.request("POST", "/methods/executeAsDelegatorBatch", {
|
|
103
|
+
contractMethods: validatedParams.contractMethods,
|
|
104
|
+
walletId: validatedParams.walletId,
|
|
105
|
+
atomic: validatedParams.atomic,
|
|
106
|
+
memo: validatedParams.memo,
|
|
107
|
+
authorizationList: validatedParams.authorizationList,
|
|
108
|
+
gasLimit: validatedParams.gasLimit,
|
|
109
|
+
});
|
|
110
|
+
return transactionSchema.parse(response);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Test a contractMethod without actually executing it
|
|
114
|
+
* @param contractMethodId The ID of the contractMethod to test
|
|
115
|
+
* @param params Configuration parameters for the contractMethod
|
|
116
|
+
* @param options Optional test options
|
|
117
|
+
* @returns Promise<ContractMethodTestResult>
|
|
118
|
+
* @throws {ZodError} If the parameters are invalid
|
|
119
|
+
*/
|
|
120
|
+
async test(contractMethodId, params, options) {
|
|
121
|
+
const validatedParams = testContractMethodSchema.parse({
|
|
122
|
+
contractMethodId,
|
|
123
|
+
params,
|
|
124
|
+
...options,
|
|
125
|
+
});
|
|
126
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/test`, {
|
|
127
|
+
params: validatedParams.params,
|
|
128
|
+
authorizationList: validatedParams.authorizationList,
|
|
129
|
+
value: validatedParams.value,
|
|
130
|
+
contractAddress: validatedParams.contractAddress,
|
|
131
|
+
});
|
|
132
|
+
return contractMethodTestResultSchema.parse(response);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get a contractMethod by ID
|
|
136
|
+
* @param id ContractMethod ID
|
|
137
|
+
* @returns Promise<ContractMethod>
|
|
138
|
+
* @throws {ZodError} If the ID is invalid
|
|
139
|
+
*/
|
|
140
|
+
async get(id) {
|
|
141
|
+
const validatedParams = getContractMethodSchema.parse({ id });
|
|
142
|
+
const response = await this.client.request("GET", `/methods/${validatedParams.id}`);
|
|
143
|
+
return contractMethodSchema.parse(response);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* List contractMethods for a business
|
|
147
|
+
* @param businessId The business ID to list contractMethods for
|
|
148
|
+
* @param params Optional filter parameters
|
|
149
|
+
* @returns Promise<ContractMethodList>
|
|
150
|
+
* @throws {ZodError} If the parameters are invalid
|
|
151
|
+
*/
|
|
152
|
+
async list(businessId, params) {
|
|
153
|
+
// Validate all parameters using the schema
|
|
154
|
+
const validatedParams = listContractMethodsSchema.parse({
|
|
155
|
+
businessId,
|
|
156
|
+
...params,
|
|
157
|
+
});
|
|
158
|
+
const queryParams = new URLSearchParams();
|
|
159
|
+
Object.entries(validatedParams).forEach(([key, value]) => {
|
|
160
|
+
if (value != undefined && key != "businessId") {
|
|
161
|
+
queryParams.append(key, value.toString());
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const queryString = queryParams.toString();
|
|
165
|
+
const path = queryString
|
|
166
|
+
? `/business/${validatedParams.businessId}/methods?${queryString}`
|
|
167
|
+
: `/business/${validatedParams.businessId}/methods`;
|
|
168
|
+
const response = await this.client.request("GET", path);
|
|
169
|
+
// Validate the response
|
|
170
|
+
return contractMethodListSchema.parse(response);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Estimate the cost of executing a contractMethod
|
|
174
|
+
* @param contractMethodId The ID of the contractMethod to estimate
|
|
175
|
+
* @param params Configuration parameters for the contractMethod
|
|
176
|
+
* @param options Optional estimation options
|
|
177
|
+
* @returns Promise<ContractMethodEstimate>
|
|
178
|
+
* @throws {ZodError} If the parameters are invalid
|
|
179
|
+
*/
|
|
180
|
+
async estimate(contractMethodId, params, options) {
|
|
181
|
+
const validatedParams = estimateContractMethodSchema.parse({
|
|
182
|
+
contractMethodId,
|
|
183
|
+
params,
|
|
184
|
+
...options,
|
|
185
|
+
});
|
|
186
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/estimate`, {
|
|
187
|
+
params: validatedParams.params,
|
|
188
|
+
authorizationList: validatedParams.authorizationList,
|
|
189
|
+
value: validatedParams.value,
|
|
190
|
+
});
|
|
191
|
+
return contractMethodEstimateSchema.parse(response);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Encode a contractMethod to get the transaction data
|
|
195
|
+
* @param contractMethodId The ID of the contractMethod to encode
|
|
196
|
+
* @param params Configuration parameters for the contractMethod
|
|
197
|
+
* @param options Optional encoding options
|
|
198
|
+
* @returns Promise<ContractMethodEncodeResult>
|
|
199
|
+
* @throws {ZodError} If the parameters are invalid
|
|
200
|
+
*/
|
|
201
|
+
async encode(contractMethodId, params, options) {
|
|
202
|
+
const validatedParams = encodeContractMethodSchema.parse({
|
|
203
|
+
contractMethodId,
|
|
204
|
+
params,
|
|
205
|
+
...options,
|
|
206
|
+
});
|
|
207
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/encode`, {
|
|
208
|
+
params: validatedParams.params,
|
|
209
|
+
authorizationList: validatedParams.authorizationList,
|
|
210
|
+
value: validatedParams.value,
|
|
211
|
+
});
|
|
212
|
+
return contractMethodEncodeResultSchema.parse(response);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Read the result of a view or pure function
|
|
216
|
+
* @param contractMethodId The ID of the contractMethod to read
|
|
217
|
+
* @param params Configuration parameters for the contractMethod
|
|
218
|
+
* @returns Promise<any> The JSON value returned by the function
|
|
219
|
+
* @throws {ZodError} If the parameters are invalid
|
|
220
|
+
*/
|
|
221
|
+
async read(contractMethodId, params) {
|
|
222
|
+
const validatedParams = readContractMethodSchema.parse({
|
|
223
|
+
contractMethodId,
|
|
224
|
+
params,
|
|
225
|
+
});
|
|
226
|
+
const response = await this.client.request("POST", `/methods/${validatedParams.contractMethodId}/read`, { params: validatedParams.params });
|
|
227
|
+
return response;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Create a new contractMethod
|
|
231
|
+
* @param businessId The business ID to create the contractMethod for
|
|
232
|
+
* @param params ContractMethod creation parameters
|
|
233
|
+
* @returns Promise<ContractMethod>
|
|
234
|
+
* @throws {ZodError} If the parameters are invalid
|
|
235
|
+
*/
|
|
236
|
+
async create(businessId, params) {
|
|
237
|
+
const validatedParams = createContractMethodSchema.parse({
|
|
238
|
+
businessId,
|
|
239
|
+
...params,
|
|
240
|
+
});
|
|
241
|
+
const response = await this.client.request("POST", `/business/${validatedParams.businessId}/methods`, validatedParams);
|
|
242
|
+
return contractMethodSchema.parse(response);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Import contractMethods from an ABI
|
|
246
|
+
* @param businessId The business ID to create the contractMethods for
|
|
247
|
+
* @param params ABI import parameters
|
|
248
|
+
* @returns Promise<ContractMethod[]>
|
|
249
|
+
* @throws {ZodError} If the parameters are invalid
|
|
250
|
+
*/
|
|
251
|
+
async importFromABI(businessId, params) {
|
|
252
|
+
const validatedParams = importFromABISchema.parse({
|
|
253
|
+
businessId,
|
|
254
|
+
...params,
|
|
255
|
+
});
|
|
256
|
+
const response = await this.client.request("POST", `/business/${validatedParams.businessId}/methods/abi`, validatedParams);
|
|
257
|
+
return response.map((item) => contractMethodSchema.parse(item));
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Update a contractMethod
|
|
261
|
+
* @param contractMethodId The ID of the contractMethod to update
|
|
262
|
+
* @param params Update parameters
|
|
263
|
+
* @returns Promise<ContractMethod>
|
|
264
|
+
* @throws {ZodError} If the parameters are invalid
|
|
265
|
+
*/
|
|
266
|
+
async update(contractMethodId, params) {
|
|
267
|
+
const validatedParams = updateContractMethodSchema.parse({
|
|
268
|
+
contractMethodId,
|
|
269
|
+
...params,
|
|
270
|
+
});
|
|
271
|
+
const response = await this.client.request("PUT", `/methods/${validatedParams.contractMethodId}`, validatedParams);
|
|
272
|
+
return contractMethodSchema.parse(response);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Delete a contractMethod
|
|
276
|
+
* @param contractMethodId The ID of the contractMethod to delete
|
|
277
|
+
* @returns Promise<void>
|
|
278
|
+
* @throws {ZodError} If the ID is invalid
|
|
279
|
+
*/
|
|
280
|
+
async delete(contractMethodId) {
|
|
281
|
+
const validatedParams = deleteContractMethodSchema.parse({
|
|
282
|
+
contractMethodId,
|
|
283
|
+
});
|
|
284
|
+
await this.client.request("DELETE", `/methods/${validatedParams.contractMethodId}`);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Search for contracts
|
|
288
|
+
* @param query The search query
|
|
289
|
+
* @param params Optional search parameters
|
|
290
|
+
* @returns Promise<FullPrompt[]>
|
|
291
|
+
* @throws {ZodError} If the parameters are invalid
|
|
292
|
+
*/
|
|
293
|
+
async search(query, params) {
|
|
294
|
+
const validatedParams = contractSearchSchema.parse({
|
|
295
|
+
query,
|
|
296
|
+
...params,
|
|
297
|
+
});
|
|
298
|
+
const response = await this.client.request("POST", "/prompts/search", validatedParams);
|
|
299
|
+
return fullPromptSchema.array().parse(response);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Assure contract methods exist for a given Prompt
|
|
303
|
+
* @param businessId The business ID to create the contract methods for
|
|
304
|
+
* @param params Parameters for creating contract methods from a Prompt
|
|
305
|
+
* @returns Promise<ContractMethod[]>
|
|
306
|
+
* @throws {ZodError} If the parameters are invalid
|
|
307
|
+
*/
|
|
308
|
+
async assureContractMethodsFromPrompt(businessId, params) {
|
|
309
|
+
const validatedParams = assureContractMethodsFromPromptSchema.parse({
|
|
310
|
+
businessId,
|
|
311
|
+
...params,
|
|
312
|
+
});
|
|
313
|
+
const response = await this.client.request("POST", `/business/${validatedParams.businessId}/methods/prompt`, validatedParams);
|
|
314
|
+
return contractMethodSchema.array().parse(response);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=contractMethods.js.map
|