@silvana-one/mina-prover 0.2.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.
Files changed (62) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -0
  3. package/dist/node/api/api.d.ts +211 -0
  4. package/dist/node/api/api.js +472 -0
  5. package/dist/node/api/api.js.map +1 -0
  6. package/dist/node/index.cjs +1161 -0
  7. package/dist/node/index.d.ts +4 -0
  8. package/dist/node/index.js +5 -0
  9. package/dist/node/index.js.map +1 -0
  10. package/dist/node/local/local.d.ts +292 -0
  11. package/dist/node/local/local.js +528 -0
  12. package/dist/node/local/local.js.map +1 -0
  13. package/dist/node/tokens/index.d.ts +2 -0
  14. package/dist/node/tokens/index.js +3 -0
  15. package/dist/node/tokens/index.js.map +1 -0
  16. package/dist/node/tokens/nft.d.ts +29 -0
  17. package/dist/node/tokens/nft.js +107 -0
  18. package/dist/node/tokens/nft.js.map +1 -0
  19. package/dist/node/tokens/token.d.ts +29 -0
  20. package/dist/node/tokens/token.js +99 -0
  21. package/dist/node/tokens/token.js.map +1 -0
  22. package/dist/node/verification/index.d.ts +1 -0
  23. package/dist/node/verification/index.js +2 -0
  24. package/dist/node/verification/index.js.map +1 -0
  25. package/dist/node/verification/verification.d.ts +21 -0
  26. package/dist/node/verification/verification.js +2 -0
  27. package/dist/node/verification/verification.js.map +1 -0
  28. package/dist/tsconfig.tsbuildinfo +1 -0
  29. package/dist/tsconfig.web.tsbuildinfo +1 -0
  30. package/dist/web/api/api.d.ts +211 -0
  31. package/dist/web/api/api.js +472 -0
  32. package/dist/web/api/api.js.map +1 -0
  33. package/dist/web/index.d.ts +4 -0
  34. package/dist/web/index.js +5 -0
  35. package/dist/web/index.js.map +1 -0
  36. package/dist/web/local/local.d.ts +292 -0
  37. package/dist/web/local/local.js +528 -0
  38. package/dist/web/local/local.js.map +1 -0
  39. package/dist/web/tokens/index.d.ts +2 -0
  40. package/dist/web/tokens/index.js +3 -0
  41. package/dist/web/tokens/index.js.map +1 -0
  42. package/dist/web/tokens/nft.d.ts +29 -0
  43. package/dist/web/tokens/nft.js +107 -0
  44. package/dist/web/tokens/nft.js.map +1 -0
  45. package/dist/web/tokens/token.d.ts +29 -0
  46. package/dist/web/tokens/token.js +99 -0
  47. package/dist/web/tokens/token.js.map +1 -0
  48. package/dist/web/verification/index.d.ts +1 -0
  49. package/dist/web/verification/index.js +2 -0
  50. package/dist/web/verification/index.js.map +1 -0
  51. package/dist/web/verification/verification.d.ts +21 -0
  52. package/dist/web/verification/verification.js +2 -0
  53. package/dist/web/verification/verification.js.map +1 -0
  54. package/package.json +68 -0
  55. package/src/api/api.ts +613 -0
  56. package/src/index.ts +4 -0
  57. package/src/local/local.ts +651 -0
  58. package/src/tokens/index.ts +2 -0
  59. package/src/tokens/nft.ts +147 -0
  60. package/src/tokens/token.ts +140 -0
  61. package/src/verification/index.ts +1 -0
  62. package/src/verification/verification.ts +23 -0
@@ -0,0 +1,472 @@
1
+ import chalk from "chalk";
2
+ import { sleep } from "@silvana-one/mina-utils";
3
+ import { LocalCloud, LocalStorage } from "../local/local.js";
4
+ import { config, } from "@silvana-one/prover";
5
+ const { ZKCLOUDWORKER_AUTH, ZKCLOUDWORKER_API } = config;
6
+ /**
7
+ * API class for interacting with the zkCloudWorker
8
+ * @property jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
9
+ * @property endpoint The endpoint of the serverless api
10
+ * @property chain The blockchain network to use
11
+ * @property webhook The webhook for the serverless api to get the results
12
+ * @property localWorker The local worker for the serverless api to test the code locally
13
+ */
14
+ export class zkCloudWorkerClient {
15
+ /**
16
+ * Constructor for the API class
17
+ * @param params the parameters for the API class
18
+ * @param params.jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
19
+ * @param params.zkcloudworker The local worker for the serverless api to test the code locally
20
+ * @param params.chain The blockchain network to use
21
+ * @param params.webhook The webhook for the serverless api to get the results
22
+ */
23
+ constructor(params) {
24
+ const { jwt, zkcloudworker, webhook } = params;
25
+ this.jwt = jwt;
26
+ const chain = params.chain ?? "devnet";
27
+ this.chain = chain;
28
+ this.endpoint =
29
+ chain === "devnet" || chain === "zeko" || chain === "mainnet"
30
+ ? ZKCLOUDWORKER_API + chain
31
+ : undefined;
32
+ this.webhook = webhook;
33
+ if (jwt === "local") {
34
+ if (zkcloudworker === undefined)
35
+ throw new Error("worker is required for local mode");
36
+ this.localWorker = zkcloudworker;
37
+ }
38
+ }
39
+ /**
40
+ * Starts a new job for the proof calculation using serverless api call
41
+ * @param data the data for the proof call
42
+ * @param data.developer the developer
43
+ * @param data.repo the repo to use
44
+ * @param data.transactions the transactions
45
+ * @param data.task the task of the job
46
+ * @param data.userId the userId of the job
47
+ * @param data.args the arguments of the job, should be serialized JSON or string
48
+ * @param data.metadata the metadata of the job, should be serialized JSON or string
49
+ * @param data.webhook the webhook for the job
50
+ * @returns { success: boolean, error?: string, jobId?: string }
51
+ * where jonId is the jobId of the job
52
+ *
53
+ * The developers repo should provide a zkcloudworker function
54
+ * that can be called with the given parameters, see the examples
55
+ */
56
+ async recursiveProof(data) {
57
+ const result = await this.apiHub("recursiveProof", data);
58
+ if (result.data === "error" ||
59
+ (typeof result.data === "string" && result.data.startsWith("error")))
60
+ return {
61
+ success: false,
62
+ error: result.error,
63
+ };
64
+ else if (result.success === false || result.data?.success === false)
65
+ return {
66
+ success: false,
67
+ error: result.error ?? result.data?.error ?? "recursiveProof call failed",
68
+ };
69
+ else if (result.success === true &&
70
+ result.data?.success === true &&
71
+ result.data?.jobId !== undefined)
72
+ return {
73
+ success: result.success,
74
+ jobId: result.data.jobId,
75
+ error: result.error,
76
+ };
77
+ else
78
+ return {
79
+ success: false,
80
+ error: "recursiveProof call error",
81
+ };
82
+ }
83
+ /**
84
+ * Starts a new job for the function call using serverless api call
85
+ * @param data the data for the proof call
86
+ * @param data.developer the developer
87
+ * @param data.repo the repo to use
88
+ * @param data.transactions the transactions
89
+ * @param data.task the task of the job
90
+ * @param data.userId the userId of the job
91
+ * @param data.args the arguments of the job
92
+ * @param data.metadata the metadata of the job
93
+ * @param data.mode the mode of the job execution: "sync" will not create a job, it will execute the function synchronously within 30 seconds and with the memory limit of 256 MB
94
+ * @returns { success: boolean, error?: string, jobId?: string, result?: any }
95
+ * where jonId is the jobId of the job (for async calls), result is the result of the job (for sync calls)
96
+ */
97
+ async execute(data) {
98
+ const result = await this.apiHub("execute", data);
99
+ if (result.data === "error" ||
100
+ (typeof result.data === "string" && result.data.startsWith("error")))
101
+ return {
102
+ success: false,
103
+ error: result.error,
104
+ };
105
+ else if (result.success === false || result.data?.success === false)
106
+ return {
107
+ success: false,
108
+ error: result.error ?? result.data?.error ?? "execute call failed",
109
+ };
110
+ else if (result.success === true &&
111
+ data.mode === "sync" &&
112
+ result.data !== undefined)
113
+ return {
114
+ success: result.success,
115
+ jobId: undefined,
116
+ result: result.data,
117
+ error: result.error,
118
+ };
119
+ else if (result.success === true &&
120
+ data.mode !== "sync" &&
121
+ result.data?.success === true &&
122
+ result.data?.jobId !== undefined)
123
+ return {
124
+ success: result.success,
125
+ jobId: result.data.jobId,
126
+ result: undefined,
127
+ error: result.error,
128
+ };
129
+ else
130
+ return {
131
+ success: false,
132
+ error: "execute call error",
133
+ };
134
+ }
135
+ /**
136
+ * Sends transactions to the blockchain using serverless api call
137
+ * @param data the data for the proof call
138
+ * @param data.developer the developer
139
+ * @param data.repo the repo to use
140
+ * @param data.transactions the transactions
141
+ * @returns { success: boolean, error?: string, txId?: string[] }
142
+ * where txId is the transaction id of the transaction, in the sequence of the input transactions
143
+ */
144
+ async sendTransactions(data) {
145
+ const result = await this.apiHub("sendTransactions", data);
146
+ if (result.data === "error")
147
+ // TODO: check if this is correct in AWS code
148
+ return {
149
+ success: false,
150
+ error: result.error,
151
+ };
152
+ else
153
+ return {
154
+ success: result.success,
155
+ txId: result.data,
156
+ error: result.error,
157
+ };
158
+ }
159
+ /**
160
+ * Gets the result of the job using serverless api call
161
+ * @param data the data for the jobResult call
162
+ * @param data.jobId the jobId of the job
163
+ * @param data.includeLogs include logs in the result, default is false
164
+ * @returns { success: boolean, error?: string, result?: any }
165
+ * where result is the result of the job
166
+ * if the job is not finished yet, the result will be undefined
167
+ * if the job failed, the result will be undefined and error will be set
168
+ * if the job is finished, the result will be set and error will be undefined
169
+ * if the job is not found, the result will be undefined and error will be set
170
+ */
171
+ async jobResult(data) {
172
+ const result = await this.apiHub("jobResult", data);
173
+ if (this.isError(result.data))
174
+ return {
175
+ success: false,
176
+ error: result.error,
177
+ result: result.data,
178
+ };
179
+ else
180
+ return {
181
+ success: result.success,
182
+ error: result.error,
183
+ result: result.success ? result.data : result.data,
184
+ };
185
+ }
186
+ /**
187
+ * Deploys the code to the cloud using serverless api call
188
+ * @param data the data for the deploy call
189
+ * @param data.repo the repo to use
190
+ * @param data.developer the developer
191
+ * @param data.packageManager the package manager to use
192
+ * @returns { success: boolean, error?: string, jobId?: string}
193
+ * where jobId is the jobId of the job
194
+ */
195
+ async deploy(data) {
196
+ // TODO: encrypt env.json
197
+ const { repo, developer, packageManager } = data;
198
+ const result = await this.apiHub("deploy", {
199
+ developer,
200
+ repo,
201
+ args: packageManager,
202
+ });
203
+ if (result.data === "error" ||
204
+ (typeof result.data === "string" && result.data.startsWith("error")))
205
+ return {
206
+ success: false,
207
+ error: result.error,
208
+ };
209
+ else
210
+ return {
211
+ success: result.success && result.data?.success,
212
+ jobId: result.data?.jobId,
213
+ error: result.error,
214
+ };
215
+ }
216
+ /**
217
+ * Gets the billing report for the jobs sent using JWT
218
+ * @returns { success: boolean, error?: string, result?: any }
219
+ * where result is the billing report
220
+ */
221
+ async queryBilling() {
222
+ const result = await this.apiHub("queryBilling", {});
223
+ if (this.isError(result.data))
224
+ return {
225
+ success: false,
226
+ error: result.error,
227
+ result: result.data,
228
+ };
229
+ else
230
+ return {
231
+ success: result.success,
232
+ error: result.error,
233
+ result: result.data,
234
+ };
235
+ }
236
+ /**
237
+ * Gets the remaining balance
238
+ * @returns { success: boolean, error?: string, result?: any }
239
+ * where result is the balance
240
+ */
241
+ async getBalance() {
242
+ const result = await this.apiHub("getBalance", {});
243
+ if (this.isError(result.data))
244
+ return {
245
+ success: false,
246
+ error: result.error,
247
+ result: result.data,
248
+ };
249
+ else
250
+ return {
251
+ success: result.success,
252
+ error: result.error,
253
+ result: result.data,
254
+ };
255
+ }
256
+ /**
257
+ * Waits for the job to finish
258
+ * @param data the data for the waitForJobResult call
259
+ * @param data.jobId the jobId of the job
260
+ * @param data.maxAttempts the maximum number of attempts, default is 360 (2 hours)
261
+ * @param data.interval the interval between attempts, default is 20000 (20 seconds)
262
+ * @param data.maxErrors the maximum number of network errors, default is 10
263
+ * @param data.printLogs print logs, default is true
264
+ * @returns { success: boolean, error?: string, result?: any }
265
+ * where result is the result of the job
266
+ */
267
+ async waitForJobResult(data) {
268
+ if (this.jwt === "local")
269
+ return this.jobResult({ jobId: data.jobId });
270
+ const maxAttempts = data?.maxAttempts ?? 360; // 1 hour
271
+ const interval = data?.interval ?? 10000;
272
+ const maxErrors = data?.maxErrors ?? 10;
273
+ const errorDelay = 30000; // 30 seconds
274
+ const printedLogs = [];
275
+ const printLogs = data.printLogs ?? true;
276
+ function print(logs) {
277
+ logs.forEach((log) => {
278
+ if (printedLogs.includes(log) === false) {
279
+ printedLogs.push(log);
280
+ if (printLogs) {
281
+ // replace all occurrences of "error" with red color
282
+ const text = log.replace(/error/gi, (matched) => chalk.red(matched));
283
+ console.log(text);
284
+ }
285
+ }
286
+ });
287
+ }
288
+ let attempts = 0;
289
+ let errors = 0;
290
+ while (attempts < maxAttempts) {
291
+ const result = await this.apiHub("jobResult", {
292
+ jobId: data.jobId,
293
+ includeLogs: printLogs,
294
+ });
295
+ const isAllLogsFetched = result?.data?.isFullLog === true || printLogs === false;
296
+ if (printLogs === true &&
297
+ result?.data?.logs !== undefined &&
298
+ result?.data?.logs !== null &&
299
+ Array.isArray(result.data.logs) === true)
300
+ print(result.data.logs);
301
+ if (result.success === false) {
302
+ errors++;
303
+ if (errors > maxErrors) {
304
+ return {
305
+ success: false,
306
+ error: "Too many network errors",
307
+ result: undefined,
308
+ };
309
+ }
310
+ await sleep(errorDelay * errors);
311
+ }
312
+ else {
313
+ if (this.isError(result.data) && isAllLogsFetched)
314
+ return {
315
+ success: false,
316
+ error: result.error,
317
+ result: result.data,
318
+ };
319
+ else if (result.data?.result !== undefined && isAllLogsFetched) {
320
+ return {
321
+ success: result.success,
322
+ error: result.error,
323
+ result: result.data,
324
+ };
325
+ }
326
+ else if (result.data?.jobStatus === "failed" && isAllLogsFetched) {
327
+ return {
328
+ success: false,
329
+ error: "Job failed",
330
+ result: result.data,
331
+ };
332
+ }
333
+ await sleep(interval);
334
+ }
335
+ attempts++;
336
+ }
337
+ return {
338
+ success: false,
339
+ error: "Timeout",
340
+ result: undefined,
341
+ };
342
+ }
343
+ /**
344
+ * Calls the serverless API
345
+ * @param command the command of the API
346
+ * @param data the data of the API
347
+ * */
348
+ async apiHub(command,
349
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
350
+ data
351
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
352
+ ) {
353
+ if (this.jwt === "local") {
354
+ if (this.localWorker === undefined)
355
+ throw new Error("localWorker is undefined");
356
+ switch (command) {
357
+ case "recursiveProof": {
358
+ const jobId = await LocalCloud.run({
359
+ command: "recursiveProof",
360
+ data,
361
+ chain: this.chain,
362
+ localWorker: this.localWorker,
363
+ });
364
+ return {
365
+ success: true,
366
+ data: { success: true, jobId },
367
+ };
368
+ }
369
+ case "execute": {
370
+ const jobId = await LocalCloud.run({
371
+ command: "execute",
372
+ data,
373
+ chain: this.chain,
374
+ localWorker: this.localWorker,
375
+ });
376
+ if (data.mode === "sync")
377
+ return {
378
+ success: true,
379
+ data: LocalStorage.jobEvents[jobId].result,
380
+ };
381
+ else
382
+ return {
383
+ success: true,
384
+ data: { success: true, jobId },
385
+ };
386
+ }
387
+ case "jobResult": {
388
+ const job = LocalStorage.jobs[data.jobId];
389
+ if (job === undefined) {
390
+ return {
391
+ success: false,
392
+ error: "local job not found",
393
+ };
394
+ }
395
+ else {
396
+ return {
397
+ success: true,
398
+ data: job,
399
+ };
400
+ }
401
+ }
402
+ case "sendTransactions": {
403
+ return {
404
+ success: true,
405
+ data: await LocalCloud.addTransactions(data.transactions),
406
+ };
407
+ }
408
+ case "deploy":
409
+ return {
410
+ success: true,
411
+ data: "local_deploy",
412
+ };
413
+ case "queryBilling":
414
+ return {
415
+ success: true,
416
+ data: "local_queryBilling",
417
+ };
418
+ default:
419
+ return {
420
+ success: false,
421
+ error: "local_error",
422
+ };
423
+ }
424
+ }
425
+ else {
426
+ if (this.endpoint === undefined)
427
+ throw new Error("zkCloudWorker supports only mainnet, devnet and zeko chains in the cloud.");
428
+ const apiData = {
429
+ auth: ZKCLOUDWORKER_AUTH,
430
+ command: command,
431
+ jwtToken: this.jwt,
432
+ data: data,
433
+ chain: this.chain,
434
+ webhook: this.webhook, // TODO: implement webhook code on AWS
435
+ };
436
+ try {
437
+ const response = await fetch(this.endpoint, {
438
+ method: "POST",
439
+ headers: {
440
+ "Content-Type": "application/json",
441
+ },
442
+ body: JSON.stringify(apiData),
443
+ });
444
+ if (!response.ok) {
445
+ return {
446
+ success: false,
447
+ error: `fetch error: ${response.statusText} status: ${response.status}`,
448
+ };
449
+ }
450
+ const data = await response.json();
451
+ return { success: true, data: data };
452
+ }
453
+ catch (error) {
454
+ console.error("apiHub error:", error.message ?? error);
455
+ return { success: false, error: error };
456
+ }
457
+ }
458
+ }
459
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
460
+ isError(data) {
461
+ if (data === "error")
462
+ return true;
463
+ if (data?.jobStatus === "failed")
464
+ return true;
465
+ if (typeof data === "string" && data.toLowerCase().startsWith("error"))
466
+ return true;
467
+ if (data !== undefined && data.error !== undefined)
468
+ return true;
469
+ return false;
470
+ }
471
+ }
472
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js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