@silvana-one/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 (98) hide show
  1. package/README.md +1 -0
  2. package/dist/node/config.d.ts +8 -0
  3. package/dist/node/config.js +9 -0
  4. package/dist/node/config.js.map +1 -0
  5. package/dist/node/index.cjs +551 -0
  6. package/dist/node/index.d.ts +4 -0
  7. package/dist/node/index.js +5 -0
  8. package/dist/node/index.js.map +1 -0
  9. package/dist/node/networks.d.ts +32 -0
  10. package/dist/node/networks.js +81 -0
  11. package/dist/node/networks.js.map +1 -0
  12. package/dist/node/utils/base64.d.ts +6 -0
  13. package/dist/node/utils/base64.js +83 -0
  14. package/dist/node/utils/base64.js.map +1 -0
  15. package/dist/node/utils/graphql.d.ts +11 -0
  16. package/dist/node/utils/graphql.js +225 -0
  17. package/dist/node/utils/graphql.js.map +1 -0
  18. package/dist/node/utils/index.d.ts +3 -0
  19. package/dist/node/utils/index.js +4 -0
  20. package/dist/node/utils/index.js.map +1 -0
  21. package/dist/node/utils/utils.d.ts +8 -0
  22. package/dist/node/utils/utils.js +61 -0
  23. package/dist/node/utils/utils.js.map +1 -0
  24. package/dist/node/worker/cloud.d.ts +250 -0
  25. package/dist/node/worker/cloud.js +54 -0
  26. package/dist/node/worker/cloud.js.map +1 -0
  27. package/dist/node/worker/index.d.ts +5 -0
  28. package/dist/node/worker/index.js +6 -0
  29. package/dist/node/worker/index.js.map +1 -0
  30. package/dist/node/worker/job.d.ts +87 -0
  31. package/dist/node/worker/job.js +2 -0
  32. package/dist/node/worker/job.js.map +1 -0
  33. package/dist/node/worker/task.d.ts +32 -0
  34. package/dist/node/worker/task.js +2 -0
  35. package/dist/node/worker/task.js.map +1 -0
  36. package/dist/node/worker/transaction.d.ts +11 -0
  37. package/dist/node/worker/transaction.js +8 -0
  38. package/dist/node/worker/transaction.js.map +1 -0
  39. package/dist/node/worker/worker.d.ts +40 -0
  40. package/dist/node/worker/worker.js +53 -0
  41. package/dist/node/worker/worker.js.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/dist/tsconfig.web.tsbuildinfo +1 -0
  44. package/dist/web/config.d.ts +8 -0
  45. package/dist/web/config.js +9 -0
  46. package/dist/web/config.js.map +1 -0
  47. package/dist/web/index.d.ts +4 -0
  48. package/dist/web/index.js +5 -0
  49. package/dist/web/index.js.map +1 -0
  50. package/dist/web/networks.d.ts +32 -0
  51. package/dist/web/networks.js +81 -0
  52. package/dist/web/networks.js.map +1 -0
  53. package/dist/web/utils/base64.d.ts +6 -0
  54. package/dist/web/utils/base64.js +83 -0
  55. package/dist/web/utils/base64.js.map +1 -0
  56. package/dist/web/utils/graphql.d.ts +11 -0
  57. package/dist/web/utils/graphql.js +225 -0
  58. package/dist/web/utils/graphql.js.map +1 -0
  59. package/dist/web/utils/index.d.ts +3 -0
  60. package/dist/web/utils/index.js +4 -0
  61. package/dist/web/utils/index.js.map +1 -0
  62. package/dist/web/utils/utils.d.ts +8 -0
  63. package/dist/web/utils/utils.js +61 -0
  64. package/dist/web/utils/utils.js.map +1 -0
  65. package/dist/web/worker/cloud.d.ts +250 -0
  66. package/dist/web/worker/cloud.js +54 -0
  67. package/dist/web/worker/cloud.js.map +1 -0
  68. package/dist/web/worker/index.d.ts +5 -0
  69. package/dist/web/worker/index.js +6 -0
  70. package/dist/web/worker/index.js.map +1 -0
  71. package/dist/web/worker/job.d.ts +87 -0
  72. package/dist/web/worker/job.js +2 -0
  73. package/dist/web/worker/job.js.map +1 -0
  74. package/dist/web/worker/task.d.ts +32 -0
  75. package/dist/web/worker/task.js +2 -0
  76. package/dist/web/worker/task.js.map +1 -0
  77. package/dist/web/worker/transaction.d.ts +11 -0
  78. package/dist/web/worker/transaction.js +8 -0
  79. package/dist/web/worker/transaction.js.map +1 -0
  80. package/dist/web/worker/worker.d.ts +40 -0
  81. package/dist/web/worker/worker.js +53 -0
  82. package/dist/web/worker/worker.js.map +1 -0
  83. package/package.json +59 -0
  84. package/src/LICENSE +201 -0
  85. package/src/README.md +77 -0
  86. package/src/config.ts +10 -0
  87. package/src/index.ts +4 -0
  88. package/src/networks.ts +130 -0
  89. package/src/utils/base64.ts +87 -0
  90. package/src/utils/graphql.ts +252 -0
  91. package/src/utils/index.ts +3 -0
  92. package/src/utils/utils.ts +79 -0
  93. package/src/worker/cloud.ts +326 -0
  94. package/src/worker/index.ts +5 -0
  95. package/src/worker/job.ts +123 -0
  96. package/src/worker/task.ts +45 -0
  97. package/src/worker/transaction.ts +12 -0
  98. package/src/worker/worker.ts +62 -0
@@ -0,0 +1,250 @@
1
+ import { blockchain } from "../networks.js";
2
+ import { JobData } from "./job.js";
3
+ import { TransactionMetadata } from "./transaction.js";
4
+ /**
5
+ * Interface for the deployer key pair
6
+ * Used to get the public and private keys of the deployer for test networks only.
7
+ * Devnet and Zeko are supported.
8
+ */
9
+ export interface DeployerKeyPair {
10
+ /** The public key of the deployer */
11
+ publicKey: string;
12
+ /** The private key of the deployer */
13
+ privateKey: string;
14
+ }
15
+ /**
16
+ * Interface for the cloud transaction
17
+ * Used to get the transaction id, the transaction, and the time received
18
+ */
19
+ export interface CloudTransaction {
20
+ /** The transaction id */
21
+ txId: string;
22
+ /** The transaction */
23
+ transaction: string;
24
+ /** The time received */
25
+ timeReceived: number;
26
+ /** The status of the transaction */
27
+ status: string;
28
+ }
29
+ export declare abstract class Cloud {
30
+ readonly id: string;
31
+ readonly jobId: string;
32
+ readonly stepId: string;
33
+ readonly taskId: string;
34
+ readonly cache: string;
35
+ readonly developer: string;
36
+ readonly repo: string;
37
+ readonly task?: string;
38
+ readonly userId?: string;
39
+ readonly args?: string;
40
+ readonly metadata?: string;
41
+ readonly chain: blockchain;
42
+ readonly isLocalCloud: boolean;
43
+ /**
44
+ * Constructor for the Cloud class
45
+ * @param params the parameters for the Cloud class
46
+ * @param params.id the id of the user
47
+ * @param params.jobId the job id
48
+ * @param params.stepId the step id
49
+ * @param params.taskId the task id
50
+ * @param params.cache the cache folder. Use it to get the Cache object: cache = Cache.FileSystem(this.cloud.cache);
51
+ * @param params.developer the developer id
52
+ * @param params.repo the repo id
53
+ * @param params.task the task id
54
+ * @param params.userId the user id
55
+ * @param params.args the arguments, should be a string or serialized JSON
56
+ * @param params.metadata the metadata, should be a string or serialized JSON
57
+ * @param params.chain the blockchain network
58
+ * @param params.isLocalCloud a boolean to check if the cloud is local or not
59
+ */
60
+ constructor(params: {
61
+ id: string;
62
+ jobId: string;
63
+ stepId: string;
64
+ taskId: string;
65
+ cache: string;
66
+ developer: string;
67
+ repo: string;
68
+ task?: string;
69
+ userId?: string;
70
+ args?: string;
71
+ metadata?: string;
72
+ isLocalCloud?: boolean;
73
+ chain: blockchain;
74
+ });
75
+ /**
76
+ * Abstract method to get the deployer key pair
77
+ * Used to get the public and private keys of the deployer for test networks only
78
+ * Devnet and Zeko are supported
79
+ * @returns the deployer key pair
80
+ */
81
+ abstract getDeployer(): Promise<DeployerKeyPair | undefined>;
82
+ /**
83
+ * Abstract method to release the deployer
84
+ * @param params the public key of the deployer and the transactions hashes
85
+ * Used to release the deployer after the transactions are sent to the blockchain
86
+ * @param params.publicKey the public key of the deployer
87
+ * @param params.txsHashes the transactions hashes
88
+ */
89
+ abstract releaseDeployer(params: {
90
+ publicKey: string;
91
+ txsHashes: string[];
92
+ }): Promise<void>;
93
+ /**
94
+ * Abstract method to get the data by key
95
+ * Used to get the data by key from the cloud storage
96
+ * @param key the key
97
+ * @returns the value of the key
98
+ */
99
+ abstract getDataByKey(key: string): Promise<string | undefined>;
100
+ /**
101
+ * Abstract method to save the data by key
102
+ * Used to save the data by key to the cloud storage
103
+ * @param key the key
104
+ * @param value the value
105
+ */
106
+ abstract saveDataByKey(key: string, value: string | undefined): Promise<void>;
107
+ /**
108
+ * Abstract method to save the file
109
+ * Used to save the file to the cloud storage
110
+ * @param filename the filename
111
+ * @param value the value
112
+ */
113
+ abstract saveFile(filename: string, value: Buffer): Promise<void>;
114
+ /**
115
+ * Abstract method to load the file
116
+ * Used to load the file from the cloud storage
117
+ * @param filename the filename
118
+ * @returns the value of the file
119
+ */
120
+ abstract loadFile(filename: string): Promise<Buffer | undefined>;
121
+ /**
122
+ * Abstract method to encrypt the data
123
+ * @param params
124
+ * @param params.data the data
125
+ * @param params.context the context
126
+ * @param params.keyId the key id, optional
127
+ */
128
+ abstract encrypt(params: {
129
+ data: string;
130
+ context: string;
131
+ keyId?: string;
132
+ }): Promise<string | undefined>;
133
+ /**
134
+ * Abstract method to decrypt the data
135
+ * @param params
136
+ * @param params.data the data
137
+ * @param params.context the context
138
+ * @param params.keyId the key id, optional
139
+ */
140
+ abstract decrypt(params: {
141
+ data: string;
142
+ context: string;
143
+ keyId?: string;
144
+ }): Promise<string | undefined>;
145
+ /**
146
+ * Abstract method to calculate the recursive proof
147
+ * Used to calculate the recursive proof
148
+ * @param data the data
149
+ * @param data.transactions the transactions
150
+ * @param data.task the task
151
+ * @param data.userId the user id
152
+ * @param data.args the arguments
153
+ * @param data.metadata the metadata
154
+ * @returns the proof
155
+ */
156
+ abstract recursiveProof(data: {
157
+ transactions: string[];
158
+ task?: string;
159
+ userId?: string;
160
+ args?: string;
161
+ metadata?: string;
162
+ }): Promise<string>;
163
+ /**
164
+ * Abstract method to execute the transactions
165
+ * Used to execute the transactions
166
+ * @param data the data
167
+ * @param data.transactions the transactions
168
+ * @param data.task the task
169
+ * @param data.userId the user id
170
+ * @param data.args the arguments
171
+ * @param data.metadata the metadata
172
+ * @returns the result
173
+ */
174
+ abstract execute(data: {
175
+ transactions: string[];
176
+ task: string;
177
+ userId?: string;
178
+ args?: string;
179
+ metadata?: string;
180
+ }): Promise<string>;
181
+ /**
182
+ * Abstract method to add the task
183
+ * Used to add the task
184
+ * @param data the data
185
+ * @param data.task the task
186
+ * @param data.startTime the start time
187
+ * @param data.userId the user id
188
+ * @param data.args the arguments
189
+ * @param data.metadata the metadata
190
+ * @param data.maxAttempts the maximum attempts
191
+ * @returns the task id
192
+ */
193
+ abstract addTask(data: {
194
+ task: string;
195
+ startTime?: number;
196
+ userId?: string;
197
+ args?: string;
198
+ metadata?: string;
199
+ maxAttempts?: number;
200
+ }): Promise<string>;
201
+ /**
202
+ * Abstract method to send the transactions
203
+ * @param transactions
204
+ */
205
+ abstract sendTransactions(transactions: string[] | CloudTransaction[]): Promise<CloudTransaction[]>;
206
+ /**
207
+ * Abstract method to delete the transaction
208
+ * Used to delete the transaction
209
+ * @param txId the transaction id
210
+ */
211
+ abstract deleteTransaction(txId: string): Promise<void>;
212
+ /**
213
+ * Abstract method to get the transactions
214
+ * Used to get the transactions
215
+ * @returns the transactions
216
+ */
217
+ abstract getTransactions(): Promise<CloudTransaction[]>;
218
+ /**
219
+ * Publish the transaction metadata in human-readable format
220
+ * @param params
221
+ * @param params.txId the transaction id
222
+ * @param params.metadata the metadata
223
+ */
224
+ abstract publishTransactionMetadata(params: {
225
+ txId: string;
226
+ metadata: TransactionMetadata;
227
+ }): Promise<void>;
228
+ /**
229
+ * Abstract method to delete the task
230
+ * Used to delete the task
231
+ * @param taskId the task id
232
+ */
233
+ abstract deleteTask(taskId: string): Promise<void>;
234
+ /**
235
+ * Abstract method to process the tasks
236
+ */
237
+ abstract processTasks(): Promise<void>;
238
+ /**
239
+ * Abstract method to get the job result
240
+ * Used to get the job result
241
+ * @param jobId the job id
242
+ * @returns the job result
243
+ */
244
+ abstract jobResult(jobId: string): Promise<JobData | undefined>;
245
+ /**
246
+ * forces the worker to restart the AWS lambda container
247
+ * See https://github.com/o1-labs/o1js/issues/1651
248
+ */
249
+ abstract forceWorkerRestart(): Promise<void>;
250
+ }
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Abstract class for the cloud service
3
+ * Used to define the cloud methods and properties
4
+ * Should be implemented by for local testing and for the zkCloudWorker in the cloud
5
+ * @param id the id of the user
6
+ * @param jobId the job id
7
+ * @param stepId the step id
8
+ * @param taskId the task id
9
+ * @param cache the cache folder. Use it to get the Cache object: cache = Cache.FileSystem(this.cloud.cache);
10
+ * @param developer the developer id
11
+ * @param repo the repo id
12
+ * @param task the task id
13
+ * @param userId the user id
14
+ * @param args the arguments, should be a string or serialized JSON
15
+ * @param metadata the metadata, should be a string or serialized JSON
16
+ * @param chain the blockchain network
17
+ * @param isLocalCloud a boolean to check if the cloud is local or not
18
+ */
19
+ export class Cloud {
20
+ /**
21
+ * Constructor for the Cloud class
22
+ * @param params the parameters for the Cloud class
23
+ * @param params.id the id of the user
24
+ * @param params.jobId the job id
25
+ * @param params.stepId the step id
26
+ * @param params.taskId the task id
27
+ * @param params.cache the cache folder. Use it to get the Cache object: cache = Cache.FileSystem(this.cloud.cache);
28
+ * @param params.developer the developer id
29
+ * @param params.repo the repo id
30
+ * @param params.task the task id
31
+ * @param params.userId the user id
32
+ * @param params.args the arguments, should be a string or serialized JSON
33
+ * @param params.metadata the metadata, should be a string or serialized JSON
34
+ * @param params.chain the blockchain network
35
+ * @param params.isLocalCloud a boolean to check if the cloud is local or not
36
+ */
37
+ constructor(params) {
38
+ const { id, jobId, stepId, taskId, cache, developer, repo, task, userId, args, metadata, isLocalCloud, chain, } = params;
39
+ this.id = id;
40
+ this.jobId = jobId;
41
+ this.stepId = stepId;
42
+ this.taskId = taskId;
43
+ this.cache = cache;
44
+ this.developer = developer;
45
+ this.repo = repo;
46
+ this.task = task;
47
+ this.userId = userId;
48
+ this.args = args;
49
+ this.metadata = metadata;
50
+ this.isLocalCloud = isLocalCloud ?? false;
51
+ this.chain = chain;
52
+ }
53
+ }
54
+ //# sourceMappingURL=cloud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../src/worker/cloud.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,KAAK;IAezB;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,MAcX;QACC,MAAM,EACJ,EAAE,EACF,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,GACN,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAqMF"}
@@ -0,0 +1,5 @@
1
+ export * from "./cloud.js";
2
+ export * from "./job.js";
3
+ export * from "./task.js";
4
+ export * from "./transaction.js";
5
+ export * from "./worker.js";
@@ -0,0 +1,6 @@
1
+ export * from "./cloud.js";
2
+ export * from "./job.js";
3
+ export * from "./task.js";
4
+ export * from "./transaction.js";
5
+ export * from "./worker.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/worker/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { blockchain } from "../networks.js";
2
+ export type JobStatus = "created" | "started" | "finished" | "failed" | "used" | "restarted";
3
+ /**
4
+ * LogStream is a subset of the log stream data returned by AWS CloudWatch Logs when running the worker.
5
+ * @see {@link https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/command/GetLogEventsCommand/}
6
+ *
7
+ * Example:
8
+ * ```
9
+ * {
10
+ * logGroupName: '/aws/lambda/zkcloudworker-dev-test',
11
+ * logStreamName: '2024/05/09/[$LATEST]52d048f64e894d2e8ba2800df93629c5',
12
+ * awsRequestId: '581d0d45-9165-47e8-84d9-678599938811'
13
+ * }
14
+ * ```
15
+ */
16
+ export interface LogStream {
17
+ /** The log group name */
18
+ logGroupName: string;
19
+ /** The log stream name */
20
+ logStreamName: string;
21
+ /** The AWS request ID */
22
+ awsRequestId: string;
23
+ }
24
+ /**
25
+ * JobData is the data structure for a job, keeping track of the job status, result, logs, and metadata.
26
+ */
27
+ export interface JobData {
28
+ /** The ID of the user */
29
+ id: string;
30
+ /** The ID of the job */
31
+ jobId: string;
32
+ /** The ID of the task (optional) */
33
+ taskId?: string;
34
+ /** The developer of the repo executing the job */
35
+ developer: string;
36
+ /** The repo executing the job */
37
+ repo: string;
38
+ /** The task to execute (optional) */
39
+ task?: string;
40
+ /** The ID of the user (optional) */
41
+ userId?: string;
42
+ /** The arguments for the job (optional) */
43
+ args?: string;
44
+ /** The metadata for the job (optional) */
45
+ metadata?: string;
46
+ /** The blockchain to execute the job on */
47
+ chain: blockchain;
48
+ /** The filename where transactions data is stored (optional) */
49
+ filename?: string;
50
+ /** The number of transactions */
51
+ txNumber: number;
52
+ /** The time the job was created */
53
+ timeCreated: number;
54
+ /** The time the job was started (optional) */
55
+ timeStarted?: number;
56
+ /** The time the job was finished (optional) */
57
+ timeFinished?: number;
58
+ /** The time the job failed (optional) */
59
+ timeFailed?: number;
60
+ /** The time the job result was used (optional) */
61
+ timeUsed?: number;
62
+ /** The status of the job */
63
+ jobStatus: JobStatus;
64
+ /** The duration the job was billed for in ms (optional) */
65
+ billedDuration?: number;
66
+ /** The result of the job (optional) */
67
+ result?: string;
68
+ /** The log streams of the job (optional) */
69
+ logStreams?: LogStream[];
70
+ /** The logs of the job (optional) */
71
+ logs?: string[];
72
+ /** Whether the logs are full (optional) */
73
+ isFullLog?: boolean;
74
+ }
75
+ /**
76
+ * JobEvent is the data structure for a job events, keeping track of the job status changes.
77
+ */
78
+ export interface JobEvent {
79
+ /** The ID of the job */
80
+ jobId: string;
81
+ /** The time the event occurred */
82
+ eventTime: number;
83
+ /** The status of the job */
84
+ jobStatus: JobStatus;
85
+ /** The result of the job (optional) */
86
+ result?: string;
87
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/worker/job.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import { blockchain } from "../networks.js";
2
+ /**
3
+ * TaskData is the data structure for a task, keeping track of the task status, result, logs, and metadata.
4
+ */
5
+ export interface TaskData {
6
+ /** The ID of the user */
7
+ id: string;
8
+ /** The ID of the task */
9
+ taskId: string;
10
+ /** The time the task was started (optional) */
11
+ startTime?: number;
12
+ /** The time the task was created */
13
+ timeCreated: number;
14
+ /** The maximum number of attempts (default is 5) (optional) */
15
+ maxAttempts?: number;
16
+ /** The number of attempts */
17
+ attempts: number;
18
+ /** The developer of the repo executing the task */
19
+ developer: string;
20
+ /** The repo executing the task */
21
+ repo: string;
22
+ /** The task to execute */
23
+ task: string;
24
+ /** The ID of the user (optional) */
25
+ userId?: string;
26
+ /** The arguments for the task (optional) */
27
+ args?: string;
28
+ /** The metadata for the task (optional) */
29
+ metadata?: string;
30
+ /** The blockchain to execute the task on */
31
+ chain: blockchain;
32
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/worker/task.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Human-readable transaction metadata
3
+ * events: the events
4
+ * actions: the actions
5
+ * custom: the custom metadata defined by the developer
6
+ */
7
+ export interface TransactionMetadata {
8
+ events?: object[];
9
+ actions?: object[];
10
+ custom?: object;
11
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Human-readable transaction metadata
3
+ * events: the events
4
+ * actions: the actions
5
+ * custom: the custom metadata defined by the developer
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/worker/transaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,40 @@
1
+ import { Cloud, CloudTransaction } from "./cloud.js";
2
+ /**
3
+ * Abstract class for the zkCloudWorker
4
+ * Used to define the zkCloudWorker methods and properties
5
+ * Should be implemented for by the developer for the zkCloudWorker in the cloud
6
+ */
7
+ export declare abstract class zkCloudWorker {
8
+ /** cloud: the cloud instance */
9
+ readonly cloud: Cloud;
10
+ /**
11
+ * Constructor for the zkCloudWorker class
12
+ * @param cloud the cloud instance provided by the zkCloudWorker in the local environment or in the cloud
13
+ */
14
+ constructor(cloud: Cloud);
15
+ /**
16
+ * Creates a new proof from a transaction
17
+ * @param transaction the transaction
18
+ * @returns the serialized proof
19
+ */
20
+ create(transaction: string): Promise<string | undefined>;
21
+ /**
22
+ * Merges two proofs
23
+ * @param proof1 the first proof
24
+ * @param proof2 the second proof
25
+ * @returns the merged proof
26
+ */
27
+ merge(proof1: string, proof2: string): Promise<string | undefined>;
28
+ /**
29
+ * Executes the transactions
30
+ * @param transactions the transactions, can be empty list
31
+ * @returns the result
32
+ */
33
+ execute(transactions: string[]): Promise<string | undefined>;
34
+ processTransactions(transactions: CloudTransaction[]): Promise<void>;
35
+ /**
36
+ * process the task defined by the developer
37
+ * @returns the result
38
+ */
39
+ task(): Promise<string | undefined>;
40
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Abstract class for the zkCloudWorker
3
+ * Used to define the zkCloudWorker methods and properties
4
+ * Should be implemented for by the developer for the zkCloudWorker in the cloud
5
+ */
6
+ export class zkCloudWorker {
7
+ /**
8
+ * Constructor for the zkCloudWorker class
9
+ * @param cloud the cloud instance provided by the zkCloudWorker in the local environment or in the cloud
10
+ */
11
+ constructor(cloud) {
12
+ this.cloud = cloud;
13
+ }
14
+ // Those methods should be implemented for recursive proofs calculations
15
+ /**
16
+ * Creates a new proof from a transaction
17
+ * @param transaction the transaction
18
+ * @returns the serialized proof
19
+ */
20
+ async create(transaction) {
21
+ return undefined;
22
+ }
23
+ /**
24
+ * Merges two proofs
25
+ * @param proof1 the first proof
26
+ * @param proof2 the second proof
27
+ * @returns the merged proof
28
+ */
29
+ async merge(proof1, proof2) {
30
+ return undefined;
31
+ }
32
+ // Those methods should be implemented for anything except for recursive proofs
33
+ /**
34
+ * Executes the transactions
35
+ * @param transactions the transactions, can be empty list
36
+ * @returns the result
37
+ */
38
+ async execute(transactions) {
39
+ return undefined;
40
+ }
41
+ /* Process the transactions received by the cloud
42
+ * @param transactions: the transactions
43
+ */
44
+ async processTransactions(transactions) { }
45
+ /**
46
+ * process the task defined by the developer
47
+ * @returns the result
48
+ */
49
+ async task() {
50
+ return undefined;
51
+ }
52
+ }
53
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/worker/worker.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAIjC;;;OAGG;IACH,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,wEAAwE;IACxE;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,MAAc;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+EAA+E;IAC/E;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,YAAsB;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,mBAAmB,CAAC,YAAgC,IAAkB,CAAC;IAE7E;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}