@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,528 @@
1
+ import { Cloud, } from "@silvana-one/prover";
2
+ import { makeString } from "@silvana-one/mina-utils";
3
+ /**
4
+ * LocalCloud is a cloud that runs on the local machine for testing and development
5
+ * It uses LocalStorage to store jobs, tasks, transactions, and data
6
+ * It uses a localWorker to execute the tasks
7
+ * It can be used to test the cloud functionality without deploying to the cloud
8
+ * @param localWorker the worker to execute the tasks
9
+ */
10
+ export class LocalCloud extends Cloud {
11
+ /**
12
+ * Constructor for LocalCloud
13
+ * @param params the parameters to create the LocalCloud
14
+ * @param params.job the job data
15
+ * @param params.chain the blockchain to execute the job on, can be any blockchain, not only local
16
+ * @param params.cache the cache folder
17
+ * @param params.stepId the step id
18
+ * @param params.localWorker the worker to execute the tasks
19
+ */
20
+ constructor(params) {
21
+ const { job, chain, cache, stepId, localWorker } = params;
22
+ const { id, jobId, developer, repo, task, userId, args, metadata, taskId } = job;
23
+ super({
24
+ id: id,
25
+ jobId: jobId,
26
+ stepId: stepId ?? "stepId",
27
+ taskId: taskId ?? "taskId",
28
+ cache: cache ?? "./cache",
29
+ developer: developer,
30
+ repo: repo,
31
+ task: task,
32
+ userId: userId,
33
+ args: args,
34
+ metadata: metadata,
35
+ isLocalCloud: true,
36
+ chain,
37
+ });
38
+ this.localWorker = localWorker;
39
+ }
40
+ /**
41
+ * Provides the deployer key pair for testing and development
42
+ * @returns the deployer key pair
43
+ */
44
+ async getDeployer() {
45
+ const privateKey = process.env.DEPLOYER_PRIVATE_KEY;
46
+ const publicKey = process.env.DEPLOYER_PUBLIC_KEY;
47
+ try {
48
+ return privateKey === undefined || publicKey === undefined
49
+ ? undefined
50
+ : {
51
+ privateKey,
52
+ publicKey,
53
+ };
54
+ }
55
+ catch (error) {
56
+ console.error(`getDeployer: error getting deployer key pair: ${error}`, error);
57
+ return undefined;
58
+ }
59
+ }
60
+ /**
61
+ * Releases the deployer key pair
62
+ */
63
+ async releaseDeployer(params) {
64
+ console.log("LocalCloud: releaseDeployer", params);
65
+ }
66
+ /**
67
+ * Gets the data by key
68
+ * @param key the key to get the data
69
+ * @returns the data
70
+ */
71
+ async getDataByKey(key) {
72
+ const value = LocalStorage.data[key];
73
+ return value;
74
+ }
75
+ /**
76
+ * Saves the data by key
77
+ * @param key the key to save the data
78
+ * @param value the value to save
79
+ */
80
+ async saveDataByKey(key, value) {
81
+ if (value !== undefined)
82
+ LocalStorage.data[key] = value;
83
+ else
84
+ delete LocalStorage.data[key];
85
+ }
86
+ /**
87
+ * Saves the file
88
+ * @param filename the filename to save
89
+ * @param value the value to save
90
+ */
91
+ async saveFile(filename, value) {
92
+ LocalStorage.files[filename] = value;
93
+ //throw new Error("Method not implemented.");
94
+ //await saveBinaryFile({ data: value, filename });
95
+ }
96
+ /**
97
+ * Loads the file
98
+ * @param filename
99
+ * @returns the file data
100
+ */
101
+ async loadFile(filename) {
102
+ return LocalStorage.files[filename];
103
+ //throw new Error("Method not implemented.");
104
+ //const data = await loadBinaryFile(filename);
105
+ //return data;
106
+ }
107
+ /**
108
+ * Encrypts the data
109
+ * @param params
110
+ * @param params.data the data
111
+ * @param params.context the context
112
+ * @param params.keyId the key id, optional
113
+ * @returns encrypted data
114
+ */
115
+ async encrypt(params) {
116
+ return JSON.stringify(params);
117
+ }
118
+ /**
119
+ * Decrypts the data
120
+ * @param params
121
+ * @param params.data the data
122
+ * @param params.context the context
123
+ * @param params.keyId the key id, optional
124
+ * @returns
125
+ */
126
+ async decrypt(params) {
127
+ const { data, context, keyId } = JSON.parse(params.data);
128
+ if (context !== params.context) {
129
+ console.error("decrypt: context mismatch");
130
+ return undefined;
131
+ }
132
+ if (keyId !== params.keyId) {
133
+ console.error("decrypt: keyId mismatch");
134
+ return undefined;
135
+ }
136
+ return data;
137
+ }
138
+ /**
139
+ * Generates an id for local cloud
140
+ * @returns generated unique id
141
+ */
142
+ static generateId(tx = undefined) {
143
+ //const data =
144
+ // tx ?? JSON.stringify({ time: Date.now(), data: makeString(32) });
145
+ //return stringHash(data);
146
+ return Date.now() + "." + makeString(32);
147
+ }
148
+ /**
149
+ * Send transactions to the local cloud
150
+ * @param transactions the transactions to add
151
+ * @returns the transaction ids
152
+ */
153
+ async sendTransactions(transactions) {
154
+ return await LocalCloud.addTransactions(transactions);
155
+ }
156
+ /**
157
+ * Adds transactions to the local cloud
158
+ * @param transactions the transactions to add
159
+ * @returns the transaction ids
160
+ */
161
+ static async addTransactions(transactions) {
162
+ const timeReceived = Date.now();
163
+ const txs = [];
164
+ transactions.forEach((tx) => {
165
+ if (typeof tx === "string") {
166
+ const txId = LocalCloud.generateId(JSON.stringify({ tx, time: timeReceived }));
167
+ const transaction = {
168
+ txId,
169
+ transaction: tx,
170
+ timeReceived,
171
+ status: "accepted",
172
+ };
173
+ LocalStorage.transactions[txId] = transaction;
174
+ txs.push(transaction);
175
+ }
176
+ else {
177
+ LocalStorage.transactions[tx.txId] = tx;
178
+ txs.push(tx);
179
+ }
180
+ });
181
+ return txs;
182
+ }
183
+ /**
184
+ * Deletes a transaction from the local cloud
185
+ * @param txId the transaction id to delete
186
+ */
187
+ async deleteTransaction(txId) {
188
+ if (LocalStorage.transactions[txId] === undefined)
189
+ throw new Error(`deleteTransaction: Transaction ${txId} not found`);
190
+ delete LocalStorage.transactions[txId];
191
+ }
192
+ async getTransactions() {
193
+ const txs = Object.keys(LocalStorage.transactions).map((txId) => {
194
+ return LocalStorage.transactions[txId];
195
+ });
196
+ return txs;
197
+ }
198
+ /**
199
+ * Publish the transaction metadata in human-readable format
200
+ * @param params
201
+ * @param params.txId the transaction id
202
+ * @param params.metadata the metadata
203
+ */
204
+ async publishTransactionMetadata(params) {
205
+ console.log("publishTransactionMetadata:", params);
206
+ }
207
+ /**
208
+ * Runs the worker in the local cloud
209
+ * @param params the parameters to run the worker
210
+ * @param params.command the command to run
211
+ * @param params.data the data to use
212
+ * @param params.chain the blockchain to execute the job on
213
+ * @param params.localWorker the worker to execute the tasks
214
+ * @returns the job id
215
+ */
216
+ static async run(params) {
217
+ const { command, data, chain, localWorker } = params;
218
+ const { developer, repo, transactions, task, userId, args, metadata } = data;
219
+ const timeCreated = Date.now();
220
+ const jobId = LocalCloud.generateId();
221
+ const job = {
222
+ id: "local",
223
+ jobId,
224
+ developer,
225
+ repo,
226
+ task,
227
+ userId,
228
+ args,
229
+ metadata,
230
+ txNumber: command === "recursiveProof" ? transactions.length : 1,
231
+ timeCreated,
232
+ timeStarted: timeCreated,
233
+ chain,
234
+ };
235
+ const cloud = new LocalCloud({
236
+ job,
237
+ chain,
238
+ localWorker,
239
+ });
240
+ const worker = await localWorker(cloud);
241
+ if (worker === undefined)
242
+ throw new Error("worker is undefined");
243
+ const result = command === "recursiveProof"
244
+ ? await LocalCloud.sequencer({
245
+ worker,
246
+ data,
247
+ })
248
+ : command === "execute"
249
+ ? await worker.execute(transactions)
250
+ : undefined;
251
+ const timeFinished = Date.now();
252
+ if (result !== undefined) {
253
+ LocalStorage.jobEvents[jobId] = {
254
+ jobId,
255
+ jobStatus: "finished",
256
+ eventTime: timeFinished,
257
+ result,
258
+ };
259
+ job.timeFinished = timeFinished;
260
+ job.jobStatus = "finished";
261
+ job.result = result;
262
+ }
263
+ else {
264
+ LocalStorage.jobEvents[jobId] = {
265
+ jobId,
266
+ jobStatus: "failed",
267
+ eventTime: timeFinished,
268
+ };
269
+ job.timeFailed = timeFinished;
270
+ job.jobStatus = "failed";
271
+ }
272
+ job.billedDuration = timeFinished - timeCreated;
273
+ LocalStorage.jobs[jobId] = job;
274
+ return jobId;
275
+ }
276
+ /**
277
+ * Runs the recursive proof in the local cloud
278
+ * @param data the data to use
279
+ * @param data.transactions the transactions to process
280
+ * @param data.task the task to execute
281
+ * @param data.userId the user id
282
+ * @param data.args the arguments for the job
283
+ * @param data.metadata the metadata for the job
284
+ * @returns the job id
285
+ */
286
+ async recursiveProof(data) {
287
+ return await LocalCloud.run({
288
+ command: "recursiveProof",
289
+ data: {
290
+ developer: this.developer,
291
+ repo: this.repo,
292
+ transactions: data.transactions,
293
+ task: data.task ?? "recursiveProof",
294
+ userId: data.userId,
295
+ args: data.args,
296
+ metadata: data.metadata,
297
+ },
298
+ chain: this.chain,
299
+ localWorker: this.localWorker,
300
+ });
301
+ }
302
+ /**
303
+ * Executes the task in the local cloud
304
+ * @param data the data to use
305
+ * @param data.transactions the transactions to process
306
+ * @param data.task the task to execute
307
+ * @param data.userId the user id
308
+ * @param data.args the arguments for the job
309
+ * @param data.metadata the metadata for the job
310
+ * @returns the job id
311
+ */
312
+ async execute(data) {
313
+ return await LocalCloud.run({
314
+ command: "execute",
315
+ data: {
316
+ developer: this.developer,
317
+ repo: this.repo,
318
+ transactions: data.transactions,
319
+ task: data.task,
320
+ userId: data.userId,
321
+ args: data.args,
322
+ metadata: data.metadata,
323
+ },
324
+ chain: this.chain,
325
+ localWorker: this.localWorker,
326
+ });
327
+ }
328
+ /**
329
+ * Gets the job result
330
+ * @param jobId the job id
331
+ * @returns the job data
332
+ */
333
+ async jobResult(jobId) {
334
+ return LocalStorage.jobs[jobId];
335
+ }
336
+ /**
337
+ * Adds a task to the local cloud
338
+ * @param data the data to use
339
+ * @param data.task the task to execute
340
+ * @param data.startTime the start time for the task
341
+ * @param data.userId the user id
342
+ * @param data.args the arguments for the job
343
+ * @param data.metadata the metadata for the job
344
+ * @returns the task id
345
+ */
346
+ async addTask(data) {
347
+ const taskId = LocalCloud.generateId();
348
+ LocalStorage.tasks[taskId] = {
349
+ ...data,
350
+ id: "local",
351
+ taskId,
352
+ timeCreated: Date.now(),
353
+ developer: this.developer,
354
+ repo: this.repo,
355
+ chain: this.chain,
356
+ };
357
+ return taskId;
358
+ }
359
+ /**
360
+ * Deletes a task from the local cloud
361
+ * @param taskId the task id to delete
362
+ */
363
+ async deleteTask(taskId) {
364
+ if (LocalStorage.tasks[taskId] === undefined)
365
+ throw new Error(`deleteTask: Task ${taskId} not found`);
366
+ delete LocalStorage.tasks[taskId];
367
+ }
368
+ /**
369
+ * Processes the tasks in the local cloud
370
+ */
371
+ async processTasks() {
372
+ await LocalCloud.processLocalTasks({
373
+ developer: this.developer,
374
+ repo: this.repo,
375
+ localWorker: this.localWorker,
376
+ chain: this.chain,
377
+ });
378
+ }
379
+ /**
380
+ * Processes the local tasks
381
+ * @param params the parameters to process the local tasks
382
+ * @param params.developer the developer of the repo
383
+ * @param params.repo the repo
384
+ * @param params.localWorker the worker to execute the tasks
385
+ * @param params.chain the blockchain to execute the job on
386
+ */
387
+ static async processLocalTasks(params) {
388
+ const { developer, repo, localWorker, chain } = params;
389
+ for (const taskId in LocalStorage.tasks) {
390
+ const data = LocalStorage.tasks[taskId];
391
+ const jobId = LocalCloud.generateId();
392
+ const timeCreated = Date.now();
393
+ if (data.startTime !== undefined && data.startTime < timeCreated)
394
+ continue;
395
+ const job = {
396
+ id: "local",
397
+ jobId: jobId,
398
+ taskId: taskId,
399
+ developer,
400
+ repo,
401
+ task: data.task,
402
+ userId: data.userId,
403
+ args: data.args,
404
+ metadata: data.metadata,
405
+ txNumber: 1,
406
+ timeCreated: timeCreated,
407
+ };
408
+ const cloud = new LocalCloud({
409
+ job,
410
+ chain,
411
+ localWorker,
412
+ });
413
+ const worker = await localWorker(cloud);
414
+ const result = await worker.task();
415
+ const timeFinished = Date.now();
416
+ if (result !== undefined) {
417
+ LocalStorage.jobEvents[jobId] = {
418
+ jobId,
419
+ jobStatus: "finished",
420
+ eventTime: timeFinished,
421
+ result,
422
+ };
423
+ job.timeFinished = timeFinished;
424
+ }
425
+ else {
426
+ LocalStorage.jobEvents[jobId] = {
427
+ jobId,
428
+ jobStatus: "failed",
429
+ eventTime: timeFinished,
430
+ };
431
+ job.timeFailed = timeFinished;
432
+ }
433
+ job.billedDuration = timeFinished - timeCreated;
434
+ LocalStorage.jobs[jobId] = job;
435
+ }
436
+ let count = 0;
437
+ for (const task in LocalStorage.tasks)
438
+ count++;
439
+ return count;
440
+ }
441
+ /**
442
+ * Runs the sequencer in the local cloud
443
+ * @param params the parameters to run the sequencer
444
+ * @param params.worker the worker to execute the tasks
445
+ * @param params.data the data to use
446
+ * @returns the proof
447
+ */
448
+ static async sequencer(params) {
449
+ const { worker, data } = params;
450
+ const { transactions } = data;
451
+ if (transactions.length === 0)
452
+ throw new Error("No transactions to process");
453
+ const proofs = [];
454
+ for (const transaction of transactions) {
455
+ const result = await worker.create(transaction);
456
+ if (result === undefined)
457
+ throw new Error("Failed to create proof");
458
+ proofs.push(result);
459
+ }
460
+ let proof = proofs[0];
461
+ for (let i = 1; i < proofs.length; i++) {
462
+ const result = await worker.merge(proof, proofs[i]);
463
+ if (result === undefined)
464
+ throw new Error("Failed to merge proofs");
465
+ proof = result;
466
+ }
467
+ return proof;
468
+ }
469
+ /**
470
+ * forces the worker to restart
471
+ */
472
+ async forceWorkerRestart() {
473
+ throw new Error("forceWorkerRestart called in LocalCloud");
474
+ }
475
+ }
476
+ /**
477
+ * LocalStorage is a local storage for the local cloud.
478
+ * It stores jobs, tasks, transactions, and data.
479
+ * It can be used to test the cloud functionality without deploying to the cloud.
480
+ */
481
+ export class LocalStorage {
482
+ /** The jobs */
483
+ static { this.jobs = {}; }
484
+ /** The job events */
485
+ static { this.jobEvents = {}; }
486
+ /** The data */
487
+ static { this.data = {}; }
488
+ /** The files */
489
+ static { this.files = {}; }
490
+ /** The transactions */
491
+ static { this.transactions = {}; }
492
+ /** The tasks */
493
+ static { this.tasks = {}; }
494
+ /**
495
+ * Saves the data.
496
+ * @param name The name to save the data under.
497
+ * @throws Error Method not implemented to keep web compatibility.
498
+ */
499
+ static async saveData(name) {
500
+ throw new Error("Method not implemented to keep web compatibility.");
501
+ const data = {
502
+ jobs: LocalStorage.jobs,
503
+ data: LocalStorage.data,
504
+ transactions: LocalStorage.transactions,
505
+ tasks: LocalStorage.tasks,
506
+ };
507
+ const filename = name + ".cloud";
508
+ // await saveFile({ data, filename });
509
+ }
510
+ /**
511
+ * Loads the data.
512
+ * @param name The name to load the data from.
513
+ * @throws Error Method not implemented to keep web compatibility.
514
+ */
515
+ static async loadData(name) {
516
+ throw new Error("Method not implemented to keep web compatibility.");
517
+ const filename = name + ".cloud";
518
+ /*
519
+ const data = await loadFile(filename);
520
+ if (data === undefined) return;
521
+ LocalStorage.jobs = data.jobs;
522
+ LocalStorage.data = data.data;
523
+ LocalStorage.transactions = data.transactions;
524
+ LocalStorage.tasks = data.tasks;
525
+ */
526
+ }
527
+ }
528
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../src/local/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAQN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGnC;;;;;;;;OAQG;IACH,YAAY,MAMX;QACC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAE1D,MAAM,EAAE,EAAE,EAAE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AI,GAA+B,EAAE,CAAC;IAE7C,qBAAqB;aACd,cAAS,GAAgC,EAAE,CAAC;IAEnD,eAAe;aACR,SAAI,GAA8B,EAAE,CAAC;IAE5C,gBAAgB;aACT,UAAK,GAA8B,EAAE,CAAC;IAE7C,uBAAuB;aAChB,iBAAY,GAEf,EAAE,CAAC;IAEP,gBAAgB;aACT,UAAK,GAAgC,EAAE,CAAC;IAE/C;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAY;QAChC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,YAAY,EAAE,YAAY,CAAC,YAAY;YACvC,KAAK,EAAE,YAAY,CAAC,KAAK;SAC1B,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC;QACjC,sCAAsC;IACxC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAY;QAChC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACrE,MAAM,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC;QACjC;;;;;;;UAOE;IACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./token.js";
2
+ export * from "./nft.js";
@@ -0,0 +1,3 @@
1
+ export * from "./token.js";
2
+ export * from "./nft.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { blockchain, Cloud, JobStatus, zkCloudWorker } from "@silvana-one/prover";
2
+ import { zkCloudWorkerClient } from "../api/api.js";
3
+ import { NftTransaction, JobResult } from "@silvana-one/api";
4
+ export declare class NftAPI {
5
+ readonly client: zkCloudWorkerClient;
6
+ constructor(params: {
7
+ jwt: string;
8
+ zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker>;
9
+ chain: blockchain;
10
+ });
11
+ proveTransaction(params: NftTransaction): Promise<string | undefined>;
12
+ proveTransactions(params: NftTransaction[], name?: string): Promise<string | undefined>;
13
+ waitForJobResults(params: {
14
+ jobId: string;
15
+ maxAttempts?: number;
16
+ interval?: number;
17
+ maxErrors?: number;
18
+ printLogs?: boolean;
19
+ }): Promise<(string | undefined)[]>;
20
+ getResults(jobId: string): Promise<{
21
+ success: true;
22
+ results?: JobResult[];
23
+ jobStatus?: JobStatus;
24
+ } | {
25
+ success: false;
26
+ error?: string;
27
+ jobStatus?: JobStatus;
28
+ }>;
29
+ }
@@ -0,0 +1,107 @@
1
+ import { zkCloudWorkerClient } from "../api/api.js";
2
+ export class NftAPI {
3
+ constructor(params) {
4
+ const { jwt, zkcloudworker, chain } = params;
5
+ if (jwt === undefined)
6
+ throw new Error("jwt is undefined");
7
+ this.client = new zkCloudWorkerClient({
8
+ jwt,
9
+ chain,
10
+ zkcloudworker,
11
+ });
12
+ }
13
+ async proveTransaction(params) {
14
+ return this.proveTransactions([params]);
15
+ }
16
+ async proveTransactions(params, name) {
17
+ const transactions = [];
18
+ for (const tx of params) {
19
+ const transaction = JSON.stringify(tx, null, 2);
20
+ transactions.push(transaction);
21
+ }
22
+ const { request, symbol } = params[0];
23
+ const { txType } = request;
24
+ const answer = await this.client.execute({
25
+ developer: "DFST",
26
+ repo: "nft-agent",
27
+ transactions,
28
+ task: "prove",
29
+ args: JSON.stringify({
30
+ collectionAddress: params[0].request.collectionAddress,
31
+ }),
32
+ metadata: `${params.length > 1 ? "mint" : txType.replace(/^nft:/, "")} ${symbol ? ` ${symbol}` : ""} ${params.length > 1
33
+ ? `(${params.length} txs)`
34
+ : txType === "nft:launch"
35
+ ? "Collection " + request.collectionName
36
+ : txType === "nft:mint"
37
+ ? request.nftMintParams.name
38
+ : name ?? ""}`,
39
+ });
40
+ const jobId = answer.jobId;
41
+ if (jobId === undefined)
42
+ console.error("Job ID is undefined", { answer, txType, symbol });
43
+ return jobId;
44
+ }
45
+ // Warning: this function will block the thread until the job is done and will print logs to the console
46
+ // Do not use it in "use server" functions, use getResults instead
47
+ async waitForJobResults(params) {
48
+ const deployResult = await this.client.waitForJobResult(params);
49
+ console.log("waitForJobResult result:", deployResult?.result?.result?.slice(0, 50));
50
+ return deployResult?.result?.result ?? "error";
51
+ }
52
+ async getResults(jobId) {
53
+ try {
54
+ const callResult = await this.client.jobResult({ jobId });
55
+ // TODO: filter the repo and developer
56
+ const jobStatus = typeof callResult?.result === "string"
57
+ ? undefined
58
+ : callResult?.result?.jobStatus;
59
+ if (!callResult.success) {
60
+ return {
61
+ success: false,
62
+ error: callResult?.error,
63
+ jobStatus,
64
+ };
65
+ }
66
+ const jobResult = callResult.result?.result;
67
+ if (callResult.error)
68
+ return {
69
+ success: false,
70
+ error: callResult.error,
71
+ jobStatus,
72
+ };
73
+ if (!jobResult)
74
+ return { success: true, jobStatus };
75
+ if (jobResult.toLowerCase().startsWith("error"))
76
+ return {
77
+ success: false,
78
+ error: jobResult,
79
+ jobStatus,
80
+ };
81
+ try {
82
+ const { proofs } = JSON.parse(jobResult);
83
+ const results = [];
84
+ for (const proof of proofs) {
85
+ const { success, tx, hash, error } = JSON.parse(proof);
86
+ results.push({ success, tx, hash, error });
87
+ }
88
+ return { success: true, results, jobStatus };
89
+ }
90
+ catch (e) {
91
+ return {
92
+ success: false,
93
+ error: `Error parsing job result: ${jobResult} ${e?.message ?? ""}`,
94
+ jobStatus,
95
+ };
96
+ }
97
+ }
98
+ catch (e) {
99
+ return {
100
+ success: false,
101
+ error: `Error getting job result: ${e?.message ?? ""}`,
102
+ jobStatus: undefined,
103
+ };
104
+ }
105
+ }
106
+ }
107
+ //# sourceMappingURL=nft.js.map