zkcloudworker 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/lib/ts/src/api/api.d.ts +37 -26
  2. package/lib/ts/src/api/api.js +26 -26
  3. package/lib/ts/src/cloud/cloud.d.ts +175 -0
  4. package/lib/ts/src/cloud/cloud.js +71 -3
  5. package/lib/ts/src/cloud/job.d.ts +47 -0
  6. package/lib/ts/src/cloud/local.d.ts +157 -1
  7. package/lib/ts/src/cloud/local.js +157 -3
  8. package/lib/ts/src/cloud/task.d.ts +18 -0
  9. package/lib/ts/src/networks.d.ts +20 -0
  10. package/lib/ts/src/utils/fee.d.ts +4 -0
  11. package/lib/ts/src/utils/fee.js +5 -1
  12. package/lib/ts/src/utils/fetch.d.ts +20 -0
  13. package/lib/ts/src/utils/fetch.js +20 -0
  14. package/lib/ts/src/utils/fields.d.ts +10 -0
  15. package/lib/ts/src/utils/fields.js +10 -0
  16. package/lib/ts/src/utils/mina.d.ts +24 -0
  17. package/lib/ts/src/utils/mina.js +18 -0
  18. package/lib/ts/tsconfig.tsbuildinfo +1 -1
  19. package/lib/web/src/api/api.d.ts +37 -26
  20. package/lib/web/src/api/api.js +26 -26
  21. package/lib/web/src/api/api.js.map +1 -1
  22. package/lib/web/src/cloud/cloud.d.ts +175 -0
  23. package/lib/web/src/cloud/cloud.js +71 -3
  24. package/lib/web/src/cloud/cloud.js.map +1 -1
  25. package/lib/web/src/cloud/job.d.ts +47 -0
  26. package/lib/web/src/cloud/local.d.ts +157 -1
  27. package/lib/web/src/cloud/local.js +157 -3
  28. package/lib/web/src/cloud/local.js.map +1 -1
  29. package/lib/web/src/cloud/task.d.ts +18 -0
  30. package/lib/web/src/networks.d.ts +20 -0
  31. package/lib/web/src/networks.js.map +1 -1
  32. package/lib/web/src/utils/fee.d.ts +4 -0
  33. package/lib/web/src/utils/fee.js +5 -1
  34. package/lib/web/src/utils/fee.js.map +1 -1
  35. package/lib/web/src/utils/fetch.d.ts +20 -0
  36. package/lib/web/src/utils/fetch.js +20 -0
  37. package/lib/web/src/utils/fetch.js.map +1 -1
  38. package/lib/web/src/utils/fields.d.ts +10 -0
  39. package/lib/web/src/utils/fields.js +10 -0
  40. package/lib/web/src/utils/fields.js.map +1 -1
  41. package/lib/web/src/utils/mina.d.ts +24 -0
  42. package/lib/web/src/utils/mina.js +18 -0
  43. package/lib/web/src/utils/mina.js.map +1 -1
  44. package/lib/web/tsconfig.web.tsbuildinfo +1 -1
  45. package/package.json +1 -1
@@ -5,8 +5,24 @@ import { TaskData } from "./task";
5
5
  import { blockchain } from "../networks";
6
6
  import { CloudTransaction, DeployerKeyPair } from "./cloud";
7
7
  import { ApiCommand } from "../api/api";
8
+ /**
9
+ * LocalCloud is a cloud that runs on the local machine for testing and development
10
+ * It uses LocalStorage to store jobs, tasks, transactions, and data
11
+ * It uses a localWorker to execute the tasks
12
+ * It can be used to test the cloud functionality without deploying to the cloud
13
+ * @param localWorker the worker to execute the tasks
14
+ */
8
15
  export declare class LocalCloud extends Cloud {
9
16
  readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
17
+ /**
18
+ * Constructor for LocalCloud
19
+ * @param params the parameters to create the LocalCloud
20
+ * @param job the job data
21
+ * @param chain the blockchain to execute the job on, can be any blockchain, not only local
22
+ * @param cache the cache folder
23
+ * @param stepId the step id
24
+ * @param localWorker the worker to execute the tasks
25
+ */
10
26
  constructor(params: {
11
27
  job: JobData;
12
28
  chain: blockchain;
@@ -14,21 +30,80 @@ export declare class LocalCloud extends Cloud {
14
30
  stepId?: string;
15
31
  localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
16
32
  });
33
+ /**
34
+ * Provides the deployer key pair for testing and development
35
+ * @returns the deployer key pair
36
+ */
17
37
  getDeployer(): Promise<DeployerKeyPair | undefined>;
38
+ /**
39
+ * Releases the deployer key pair
40
+ */
18
41
  releaseDeployer(params: {
19
42
  publicKey: string;
20
43
  txsHashes: string[];
21
44
  }): Promise<void>;
22
- log(msg: string): Promise<void>;
45
+ /**
46
+ * Gets the data by key
47
+ * @param key the key to get the data
48
+ * @returns the data
49
+ */
23
50
  getDataByKey(key: string): Promise<string | undefined>;
51
+ /**
52
+ * Saves the data by key
53
+ * @param key the key to save the data
54
+ * @param value the value to save
55
+ */
24
56
  saveDataByKey(key: string, value: string | undefined): Promise<void>;
57
+ /**
58
+ * Saves the file
59
+ * @param filename the filename to save
60
+ * @param value the value to save
61
+ */
25
62
  saveFile(filename: string, value: Buffer): Promise<void>;
63
+ /**
64
+ * Loads the file
65
+ * @param filename
66
+ * @returns the file data
67
+ */
26
68
  loadFile(filename: string): Promise<Buffer | undefined>;
69
+ /**
70
+ * Loads the environment
71
+ * @param password
72
+ */
27
73
  loadEnvironment(password: string): Promise<void>;
74
+ /**
75
+ * Generates an id for local cloud
76
+ * @returns generated unique id
77
+ */
28
78
  private static generateId;
79
+ /**
80
+ * Adds transactions to the local cloud
81
+ * @param transactions the transactions to add
82
+ * @returns the transaction ids
83
+ */
29
84
  static addTransactions(transactions: string[]): Promise<string[]>;
85
+ /**
86
+ * Deletes a transaction from the local cloud
87
+ * @param txId the transaction id to delete
88
+ */
30
89
  deleteTransaction(txId: string): Promise<void>;
31
90
  getTransactions(): Promise<CloudTransaction[]>;
91
+ /**
92
+ * Runs the worker in the local cloud
93
+ * @param params the parameters to run the worker
94
+ * @param params.command the command to run
95
+ * @param params.data the data to use
96
+ * @param params.data.developer the developer of the repo
97
+ * @param params.data.repo the repo
98
+ * @param params.data.transactions the transactions to process
99
+ * @param params.data.task the task to execute
100
+ * @param params.data.userId the user id
101
+ * @param params.data.args the arguments for the job
102
+ * @param params.data.metadata the metadata for the job
103
+ * @param params.chain the blockchain to execute the job on
104
+ * @param params.localWorker the worker to execute the tasks
105
+ * @returns the job id
106
+ */
32
107
  static run(params: {
33
108
  command: ApiCommand;
34
109
  data: {
@@ -43,6 +118,16 @@ export declare class LocalCloud extends Cloud {
43
118
  chain: blockchain;
44
119
  localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
45
120
  }): Promise<string>;
121
+ /**
122
+ * Runs the recursive proof in the local cloud
123
+ * @param data the data to use
124
+ * @param data.transactions the transactions to process
125
+ * @param data.task the task to execute
126
+ * @param data.userId the user id
127
+ * @param data.args the arguments for the job
128
+ * @param data.metadata the metadata for the job
129
+ * @returns the job id
130
+ */
46
131
  recursiveProof(data: {
47
132
  transactions: string[];
48
133
  task?: string;
@@ -50,6 +135,16 @@ export declare class LocalCloud extends Cloud {
50
135
  args?: string;
51
136
  metadata?: string;
52
137
  }): Promise<string>;
138
+ /**
139
+ * Executes the task in the local cloud
140
+ * @param data the data to use
141
+ * @param data.transactions the transactions to process
142
+ * @param data.task the task to execute
143
+ * @param data.userId the user id
144
+ * @param data.args the arguments for the job
145
+ * @param data.metadata the metadata for the job
146
+ * @returns the job id
147
+ */
53
148
  execute(data: {
54
149
  transactions: string[];
55
150
  task: string;
@@ -57,7 +152,22 @@ export declare class LocalCloud extends Cloud {
57
152
  args?: string;
58
153
  metadata?: string;
59
154
  }): Promise<string>;
155
+ /**
156
+ * Gets the job result
157
+ * @param jobId the job id
158
+ * @returns the job data
159
+ */
60
160
  jobResult(jobId: string): Promise<JobData | undefined>;
161
+ /**
162
+ * Adds a task to the local cloud
163
+ * @param data the data to use
164
+ * @param data.task the task to execute
165
+ * @param data.startTime the start time for the task
166
+ * @param data.userId the user id
167
+ * @param data.args the arguments for the job
168
+ * @param data.metadata the metadata for the job
169
+ * @returns the task id
170
+ */
61
171
  addTask(data: {
62
172
  task: string;
63
173
  startTime?: number;
@@ -65,14 +175,43 @@ export declare class LocalCloud extends Cloud {
65
175
  args?: string;
66
176
  metadata?: string;
67
177
  }): Promise<string>;
178
+ /**
179
+ * Deletes a task from the local cloud
180
+ * @param taskId the task id to delete
181
+ */
68
182
  deleteTask(taskId: string): Promise<void>;
183
+ /**
184
+ * Processes the tasks in the local cloud
185
+ */
69
186
  processTasks(): Promise<void>;
187
+ /**
188
+ * Processes the local tasks
189
+ * @param params the parameters to process the local tasks
190
+ * @param params.developer the developer of the repo
191
+ * @param params.repo the repo
192
+ * @param params.localWorker the worker to execute the tasks
193
+ * @param params.chain the blockchain to execute the job on
194
+ */
70
195
  static processLocalTasks(params: {
71
196
  developer: string;
72
197
  repo: string;
73
198
  localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
74
199
  chain: blockchain;
75
200
  }): Promise<number>;
201
+ /**
202
+ * Runs the sequencer in the local cloud
203
+ * @param params the parameters to run the sequencer
204
+ * @param params.worker the worker to execute the tasks
205
+ * @param params.data the data to use
206
+ * @param params.data.developer the developer of the repo
207
+ * @param params.data.repo the repo
208
+ * @param params.data.transactions the transactions to process
209
+ * @param params.data.task the task to execute
210
+ * @param params.data.userId the user id
211
+ * @param params.data.args the arguments for the job
212
+ * @param params.data.metadata the metadata for the job
213
+ * @returns the proof
214
+ */
76
215
  static sequencer(params: {
77
216
  worker: zkCloudWorker;
78
217
  data: {
@@ -86,6 +225,15 @@ export declare class LocalCloud extends Cloud {
86
225
  };
87
226
  }): Promise<string>;
88
227
  }
228
+ /**
229
+ * LocalStorage is a local storage for the local cloud
230
+ * It stores jobs, tasks, transactions, and data
231
+ * It can be used to test the cloud functionality without deploying to the cloud
232
+ * @param jobs the jobs
233
+ * @param data the data
234
+ * @param transactions the transactions
235
+ * @param tasks the tasks
236
+ */
89
237
  export declare class LocalStorage {
90
238
  static jobs: {
91
239
  [key: string]: JobData;
@@ -102,6 +250,14 @@ export declare class LocalStorage {
102
250
  static tasks: {
103
251
  [key: string]: TaskData;
104
252
  };
253
+ /**
254
+ * Saves the data
255
+ * @param name the name to save the data
256
+ */
105
257
  static saveData(name: string): Promise<void>;
258
+ /**
259
+ * Loads the data
260
+ * @param name the name to load the data
261
+ */
106
262
  static loadData(name: string): Promise<void>;
107
263
  }
@@ -4,7 +4,23 @@ exports.LocalStorage = exports.LocalCloud = void 0;
4
4
  const cloud_1 = require("./cloud");
5
5
  const utils_1 = require("../utils/utils");
6
6
  const files_1 = require("./files");
7
+ /**
8
+ * LocalCloud is a cloud that runs on the local machine for testing and development
9
+ * It uses LocalStorage to store jobs, tasks, transactions, and data
10
+ * It uses a localWorker to execute the tasks
11
+ * It can be used to test the cloud functionality without deploying to the cloud
12
+ * @param localWorker the worker to execute the tasks
13
+ */
7
14
  class LocalCloud extends cloud_1.Cloud {
15
+ /**
16
+ * Constructor for LocalCloud
17
+ * @param params the parameters to create the LocalCloud
18
+ * @param job the job data
19
+ * @param chain the blockchain to execute the job on, can be any blockchain, not only local
20
+ * @param cache the cache folder
21
+ * @param stepId the step id
22
+ * @param localWorker the worker to execute the tasks
23
+ */
8
24
  constructor(params) {
9
25
  const { job, chain, cache, stepId, localWorker } = params;
10
26
  const { id, jobId, developer, repo, task, userId, args, metadata, taskId } = job;
@@ -25,6 +41,10 @@ class LocalCloud extends cloud_1.Cloud {
25
41
  });
26
42
  this.localWorker = localWorker;
27
43
  }
44
+ /**
45
+ * Provides the deployer key pair for testing and development
46
+ * @returns the deployer key pair
47
+ */
28
48
  async getDeployer() {
29
49
  const privateKey = process.env.DEPLOYER_PRIVATE_KEY;
30
50
  const publicKey = process.env.DEPLOYER_PUBLIC_KEY;
@@ -41,35 +61,68 @@ class LocalCloud extends cloud_1.Cloud {
41
61
  return undefined;
42
62
  }
43
63
  }
64
+ /**
65
+ * Releases the deployer key pair
66
+ */
44
67
  async releaseDeployer(params) {
45
68
  console.log("LocalCloud: releaseDeployer", params);
46
69
  }
47
- async log(msg) {
48
- console.log("LocalCloud:", msg);
49
- }
70
+ /**
71
+ * Gets the data by key
72
+ * @param key the key to get the data
73
+ * @returns the data
74
+ */
50
75
  async getDataByKey(key) {
51
76
  const value = LocalStorage.data[key];
52
77
  return value;
53
78
  }
79
+ /**
80
+ * Saves the data by key
81
+ * @param key the key to save the data
82
+ * @param value the value to save
83
+ */
54
84
  async saveDataByKey(key, value) {
55
85
  if (value !== undefined)
56
86
  LocalStorage.data[key] = value;
57
87
  else
58
88
  delete LocalStorage.data[key];
59
89
  }
90
+ /**
91
+ * Saves the file
92
+ * @param filename the filename to save
93
+ * @param value the value to save
94
+ */
60
95
  async saveFile(filename, value) {
61
96
  await (0, files_1.saveBinaryFile)({ data: value, filename });
62
97
  }
98
+ /**
99
+ * Loads the file
100
+ * @param filename
101
+ * @returns the file data
102
+ */
63
103
  async loadFile(filename) {
64
104
  const data = await (0, files_1.loadBinaryFile)(filename);
65
105
  return data;
66
106
  }
107
+ /**
108
+ * Loads the environment
109
+ * @param password
110
+ */
67
111
  async loadEnvironment(password) {
68
112
  throw new Error("Method not implemented.");
69
113
  }
114
+ /**
115
+ * Generates an id for local cloud
116
+ * @returns generated unique id
117
+ */
70
118
  static generateId() {
71
119
  return "local." + Date.now().toString() + "." + (0, utils_1.makeString)(32);
72
120
  }
121
+ /**
122
+ * Adds transactions to the local cloud
123
+ * @param transactions the transactions to add
124
+ * @returns the transaction ids
125
+ */
73
126
  static async addTransactions(transactions) {
74
127
  const timeReceived = Date.now();
75
128
  const txId = [];
@@ -80,6 +133,10 @@ class LocalCloud extends cloud_1.Cloud {
80
133
  });
81
134
  return txId;
82
135
  }
136
+ /**
137
+ * Deletes a transaction from the local cloud
138
+ * @param txId the transaction id to delete
139
+ */
83
140
  async deleteTransaction(txId) {
84
141
  if (LocalStorage.transactions[txId] === undefined)
85
142
  throw new Error(`deleteTransaction: Transaction ${txId} not found`);
@@ -96,6 +153,22 @@ class LocalCloud extends cloud_1.Cloud {
96
153
  });
97
154
  return txs;
98
155
  }
156
+ /**
157
+ * Runs the worker in the local cloud
158
+ * @param params the parameters to run the worker
159
+ * @param params.command the command to run
160
+ * @param params.data the data to use
161
+ * @param params.data.developer the developer of the repo
162
+ * @param params.data.repo the repo
163
+ * @param params.data.transactions the transactions to process
164
+ * @param params.data.task the task to execute
165
+ * @param params.data.userId the user id
166
+ * @param params.data.args the arguments for the job
167
+ * @param params.data.metadata the metadata for the job
168
+ * @param params.chain the blockchain to execute the job on
169
+ * @param params.localWorker the worker to execute the tasks
170
+ * @returns the job id
171
+ */
99
172
  static async run(params) {
100
173
  const { command, data, chain, localWorker } = params;
101
174
  const { developer, repo, transactions, task, userId, args, metadata } = data;
@@ -148,6 +221,16 @@ class LocalCloud extends cloud_1.Cloud {
148
221
  LocalStorage.jobs[jobId] = job;
149
222
  return jobId;
150
223
  }
224
+ /**
225
+ * Runs the recursive proof in the local cloud
226
+ * @param data the data to use
227
+ * @param data.transactions the transactions to process
228
+ * @param data.task the task to execute
229
+ * @param data.userId the user id
230
+ * @param data.args the arguments for the job
231
+ * @param data.metadata the metadata for the job
232
+ * @returns the job id
233
+ */
151
234
  async recursiveProof(data) {
152
235
  return await LocalCloud.run({
153
236
  command: "recursiveProof",
@@ -164,6 +247,16 @@ class LocalCloud extends cloud_1.Cloud {
164
247
  localWorker: this.localWorker,
165
248
  });
166
249
  }
250
+ /**
251
+ * Executes the task in the local cloud
252
+ * @param data the data to use
253
+ * @param data.transactions the transactions to process
254
+ * @param data.task the task to execute
255
+ * @param data.userId the user id
256
+ * @param data.args the arguments for the job
257
+ * @param data.metadata the metadata for the job
258
+ * @returns the job id
259
+ */
167
260
  async execute(data) {
168
261
  return await LocalCloud.run({
169
262
  command: "execute",
@@ -180,9 +273,24 @@ class LocalCloud extends cloud_1.Cloud {
180
273
  localWorker: this.localWorker,
181
274
  });
182
275
  }
276
+ /**
277
+ * Gets the job result
278
+ * @param jobId the job id
279
+ * @returns the job data
280
+ */
183
281
  async jobResult(jobId) {
184
282
  return LocalStorage.jobs[jobId];
185
283
  }
284
+ /**
285
+ * Adds a task to the local cloud
286
+ * @param data the data to use
287
+ * @param data.task the task to execute
288
+ * @param data.startTime the start time for the task
289
+ * @param data.userId the user id
290
+ * @param data.args the arguments for the job
291
+ * @param data.metadata the metadata for the job
292
+ * @returns the task id
293
+ */
186
294
  async addTask(data) {
187
295
  const taskId = LocalCloud.generateId();
188
296
  LocalStorage.tasks[taskId] = {
@@ -196,11 +304,18 @@ class LocalCloud extends cloud_1.Cloud {
196
304
  };
197
305
  return taskId;
198
306
  }
307
+ /**
308
+ * Deletes a task from the local cloud
309
+ * @param taskId the task id to delete
310
+ */
199
311
  async deleteTask(taskId) {
200
312
  if (LocalStorage.tasks[taskId] === undefined)
201
313
  throw new Error(`deleteTask: Task ${taskId} not found`);
202
314
  delete LocalStorage.tasks[taskId];
203
315
  }
316
+ /**
317
+ * Processes the tasks in the local cloud
318
+ */
204
319
  async processTasks() {
205
320
  await LocalCloud.processLocalTasks({
206
321
  developer: this.developer,
@@ -209,6 +324,14 @@ class LocalCloud extends cloud_1.Cloud {
209
324
  chain: this.chain,
210
325
  });
211
326
  }
327
+ /**
328
+ * Processes the local tasks
329
+ * @param params the parameters to process the local tasks
330
+ * @param params.developer the developer of the repo
331
+ * @param params.repo the repo
332
+ * @param params.localWorker the worker to execute the tasks
333
+ * @param params.chain the blockchain to execute the job on
334
+ */
212
335
  static async processLocalTasks(params) {
213
336
  const { developer, repo, localWorker, chain } = params;
214
337
  for (const taskId in LocalStorage.tasks) {
@@ -258,6 +381,20 @@ class LocalCloud extends cloud_1.Cloud {
258
381
  count++;
259
382
  return count;
260
383
  }
384
+ /**
385
+ * Runs the sequencer in the local cloud
386
+ * @param params the parameters to run the sequencer
387
+ * @param params.worker the worker to execute the tasks
388
+ * @param params.data the data to use
389
+ * @param params.data.developer the developer of the repo
390
+ * @param params.data.repo the repo
391
+ * @param params.data.transactions the transactions to process
392
+ * @param params.data.task the task to execute
393
+ * @param params.data.userId the user id
394
+ * @param params.data.args the arguments for the job
395
+ * @param params.data.metadata the metadata for the job
396
+ * @returns the proof
397
+ */
261
398
  static async sequencer(params) {
262
399
  const { worker, data } = params;
263
400
  const { transactions } = data;
@@ -281,7 +418,20 @@ class LocalCloud extends cloud_1.Cloud {
281
418
  }
282
419
  }
283
420
  exports.LocalCloud = LocalCloud;
421
+ /**
422
+ * LocalStorage is a local storage for the local cloud
423
+ * It stores jobs, tasks, transactions, and data
424
+ * It can be used to test the cloud functionality without deploying to the cloud
425
+ * @param jobs the jobs
426
+ * @param data the data
427
+ * @param transactions the transactions
428
+ * @param tasks the tasks
429
+ */
284
430
  class LocalStorage {
431
+ /**
432
+ * Saves the data
433
+ * @param name the name to save the data
434
+ */
285
435
  static async saveData(name) {
286
436
  const data = {
287
437
  jobs: LocalStorage.jobs,
@@ -292,6 +442,10 @@ class LocalStorage {
292
442
  const filename = name + ".cloud";
293
443
  await (0, files_1.saveFile)({ data, filename });
294
444
  }
445
+ /**
446
+ * Loads the data
447
+ * @param name the name to load the data
448
+ */
295
449
  static async loadData(name) {
296
450
  const filename = name + ".cloud";
297
451
  const data = await (0, files_1.loadFile)(filename);
@@ -1,4 +1,22 @@
1
1
  import { blockchain } from "../networks";
2
+ /**
3
+ * TaskData is the data structure for a task, keeping track of the task status, result, logs, and metadata
4
+ * @param id the id of the user
5
+ * @param taskId the id of the task
6
+ *
7
+ * @param startTime the time the task was started
8
+ * @param timeCreated the time the task was created
9
+ * @param maxAttempts the maximum number of attempts
10
+ * @param attempts the number of attempts
11
+ *
12
+ * @param developer the developer of the repo executing the task
13
+ * @param repo the repo executing the task
14
+ * @param task the task to execute
15
+ * @param userId the id of the user
16
+ * @param args the arguments for the task
17
+ * @param metadata the metadata for the task
18
+ * @param chain the blockchain to execute the task on
19
+ */
2
20
  export interface TaskData {
3
21
  id: string;
4
22
  taskId: string;
@@ -1,5 +1,25 @@
1
1
  export { blockchain, MinaNetwork, networks, Mainnet, Devnet, Zeko, Lightnet, Local, };
2
+ /**
3
+ * blockchain is the type for the chain id
4
+ * @param local the local chain id
5
+ * @param devnet the devnet chain id
6
+ * @param lightnet the lightnet chain id
7
+ * @param mainnet the mainnet chain id
8
+ * @param zeko the zeko chain id
9
+ * @param mainnet the mainnet chain id
10
+ */
2
11
  type blockchain = "local" | "devnet" | "lightnet" | "mainnet" | "zeko" | "mainnet";
12
+ /**
13
+ * MinaNetwork is the data structure for a Mina network, keeping track of the mina and archive endpoints, chain id, name, account manager, explorer account url, explorer transaction url, and faucet
14
+ * @param mina the mina endpoints
15
+ * @param archive the archive endpoints
16
+ * @param chainId the chain id
17
+ * @param name the name of the network
18
+ * @param accountManager the account manager for Lightnet
19
+ * @param explorerAccountUrl the explorer account url
20
+ * @param explorerTransactionUrl the explorer transaction url
21
+ * @param faucet the faucet url
22
+ */
3
23
  interface MinaNetwork {
4
24
  mina: string[];
5
25
  archive: string[];
@@ -1,2 +1,6 @@
1
1
  import { UInt64 } from "o1js";
2
+ /**
3
+ * Calculate the fee for a transaction
4
+ * @returns the fee for a transaction
5
+ */
2
6
  export declare function fee(): Promise<UInt64>;
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fee = void 0;
7
7
  const o1js_1 = require("o1js");
8
8
  const config_1 = __importDefault(require("../config"));
9
+ /**
10
+ * Calculate the fee for a transaction
11
+ * @returns the fee for a transaction
12
+ */
9
13
  async function fee() {
10
- //TODO: update after mainnet launch
14
+ //TODO: update after mainnet launch and resolution of the issue https://github.com/o1-labs/o1js/issues/1626
11
15
  return o1js_1.UInt64.fromJSON(config_1.default.MINAFEE);
12
16
  }
13
17
  exports.fee = fee;
@@ -1,4 +1,12 @@
1
1
  import { PublicKey, Field } from "o1js";
2
+ /**
3
+ * Fetches the Mina account for a given public key with error handling
4
+ * @param params the parameters for fetching the account
5
+ * @param params.publicKey the public key of the account
6
+ * @param params.tokenId the token id of the account
7
+ * @param params.force whether to force the fetch - use it only if you are sure the account exists
8
+ * @returns the account object
9
+ */
2
10
  export declare function fetchMinaAccount(params: {
3
11
  publicKey: string | PublicKey;
4
12
  tokenId?: string | Field | undefined;
@@ -9,10 +17,22 @@ export declare function fetchMinaAccount(params: {
9
17
  account: import("o1js/dist/node/bindings/mina-transaction/gen/transaction").Account;
10
18
  error: undefined;
11
19
  }>;
20
+ /**
21
+ * Fetches the Mina actions for a given public key with error handling
22
+ * @param publicKey the public key of the contract
23
+ * @param fromActionState the starting action state
24
+ * @param endActionState the ending action state
25
+ * @returns the actions array
26
+ */
12
27
  export declare function fetchMinaActions(publicKey: PublicKey, fromActionState: Field, endActionState?: Field): Promise<{
13
28
  actions: string[][];
14
29
  hash: string;
15
30
  }[] | undefined>;
31
+ /**
32
+ * Fetches the Mina transaction for a given hash with error handling
33
+ * @param hash the hash of the transaction
34
+ * @returns the transaction object
35
+ */
16
36
  export declare function checkMinaZkappTransaction(hash: string): Promise<{
17
37
  success: boolean;
18
38
  failureReason: string[][][];
@@ -3,6 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkMinaZkappTransaction = exports.fetchMinaActions = exports.fetchMinaAccount = void 0;
4
4
  const o1js_1 = require("o1js");
5
5
  const utils_1 = require("./utils");
6
+ /**
7
+ * Fetches the Mina account for a given public key with error handling
8
+ * @param params the parameters for fetching the account
9
+ * @param params.publicKey the public key of the account
10
+ * @param params.tokenId the token id of the account
11
+ * @param params.force whether to force the fetch - use it only if you are sure the account exists
12
+ * @returns the account object
13
+ */
6
14
  async function fetchMinaAccount(params) {
7
15
  const { publicKey, tokenId, force } = params;
8
16
  const timeout = 1000 * 60 * 2; // 2 minutes
@@ -48,6 +56,13 @@ async function fetchMinaAccount(params) {
48
56
  return result;
49
57
  }
50
58
  exports.fetchMinaAccount = fetchMinaAccount;
59
+ /**
60
+ * Fetches the Mina actions for a given public key with error handling
61
+ * @param publicKey the public key of the contract
62
+ * @param fromActionState the starting action state
63
+ * @param endActionState the ending action state
64
+ * @returns the actions array
65
+ */
51
66
  async function fetchMinaActions(publicKey, fromActionState, endActionState) {
52
67
  const timeout = 1000 * 60 * 600; // 10 hours
53
68
  const startTime = Date.now();
@@ -71,6 +86,11 @@ async function fetchMinaActions(publicKey, fromActionState, endActionState) {
71
86
  return undefined;
72
87
  }
73
88
  exports.fetchMinaActions = fetchMinaActions;
89
+ /**
90
+ * Fetches the Mina transaction for a given hash with error handling
91
+ * @param hash the hash of the transaction
92
+ * @returns the transaction object
93
+ */
74
94
  async function checkMinaZkappTransaction(hash) {
75
95
  try {
76
96
  const result = await (0, o1js_1.checkZkappTransaction)(hash);
@@ -1,3 +1,13 @@
1
1
  import { Field } from "o1js";
2
+ /**
3
+ * Serialize fields to a string using base64 URL-friendly encoding
4
+ * @param fields the fields array to serialize
5
+ * @returns the serialized string
6
+ */
2
7
  export declare function serializeFields(fields: Field[]): string;
8
+ /**
9
+ * Deserialize fields from a string using base64 URL-friendly encoding
10
+ * @param s the string to deserialize
11
+ * @returns the deserialized fields array
12
+ */
3
13
  export declare function deserializeFields(s: string): Field[];