@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.
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/node/api/api.d.ts +211 -0
- package/dist/node/api/api.js +472 -0
- package/dist/node/api/api.js.map +1 -0
- package/dist/node/index.cjs +1161 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.js +5 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/local/local.d.ts +292 -0
- package/dist/node/local/local.js +528 -0
- package/dist/node/local/local.js.map +1 -0
- package/dist/node/tokens/index.d.ts +2 -0
- package/dist/node/tokens/index.js +3 -0
- package/dist/node/tokens/index.js.map +1 -0
- package/dist/node/tokens/nft.d.ts +29 -0
- package/dist/node/tokens/nft.js +107 -0
- package/dist/node/tokens/nft.js.map +1 -0
- package/dist/node/tokens/token.d.ts +29 -0
- package/dist/node/tokens/token.js +99 -0
- package/dist/node/tokens/token.js.map +1 -0
- package/dist/node/verification/index.d.ts +1 -0
- package/dist/node/verification/index.js +2 -0
- package/dist/node/verification/index.js.map +1 -0
- package/dist/node/verification/verification.d.ts +21 -0
- package/dist/node/verification/verification.js +2 -0
- package/dist/node/verification/verification.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.web.tsbuildinfo +1 -0
- package/dist/web/api/api.d.ts +211 -0
- package/dist/web/api/api.js +472 -0
- package/dist/web/api/api.js.map +1 -0
- package/dist/web/index.d.ts +4 -0
- package/dist/web/index.js +5 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/local/local.d.ts +292 -0
- package/dist/web/local/local.js +528 -0
- package/dist/web/local/local.js.map +1 -0
- package/dist/web/tokens/index.d.ts +2 -0
- package/dist/web/tokens/index.js +3 -0
- package/dist/web/tokens/index.js.map +1 -0
- package/dist/web/tokens/nft.d.ts +29 -0
- package/dist/web/tokens/nft.js +107 -0
- package/dist/web/tokens/nft.js.map +1 -0
- package/dist/web/tokens/token.d.ts +29 -0
- package/dist/web/tokens/token.js +99 -0
- package/dist/web/tokens/token.js.map +1 -0
- package/dist/web/verification/index.d.ts +1 -0
- package/dist/web/verification/index.js +2 -0
- package/dist/web/verification/index.js.map +1 -0
- package/dist/web/verification/verification.d.ts +21 -0
- package/dist/web/verification/verification.js +2 -0
- package/dist/web/verification/verification.js.map +1 -0
- package/package.json +68 -0
- package/src/api/api.ts +613 -0
- package/src/index.ts +4 -0
- package/src/local/local.ts +651 -0
- package/src/tokens/index.ts +2 -0
- package/src/tokens/nft.ts +147 -0
- package/src/tokens/token.ts +140 -0
- package/src/verification/index.ts +1 -0
- package/src/verification/verification.ts +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { CloudTransaction, DeployerKeyPair, Cloud, JobData, JobEvent, TaskData, zkCloudWorker, TransactionMetadata, blockchain } from "@silvana-one/prover";
|
|
2
|
+
import { ApiCommand } from "../api/api.js";
|
|
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 declare class LocalCloud extends Cloud {
|
|
11
|
+
readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor for LocalCloud
|
|
14
|
+
* @param params the parameters to create the LocalCloud
|
|
15
|
+
* @param params.job the job data
|
|
16
|
+
* @param params.chain the blockchain to execute the job on, can be any blockchain, not only local
|
|
17
|
+
* @param params.cache the cache folder
|
|
18
|
+
* @param params.stepId the step id
|
|
19
|
+
* @param params.localWorker the worker to execute the tasks
|
|
20
|
+
*/
|
|
21
|
+
constructor(params: {
|
|
22
|
+
job: JobData;
|
|
23
|
+
chain: blockchain;
|
|
24
|
+
cache?: string;
|
|
25
|
+
stepId?: string;
|
|
26
|
+
localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Provides the deployer key pair for testing and development
|
|
30
|
+
* @returns the deployer key pair
|
|
31
|
+
*/
|
|
32
|
+
getDeployer(): Promise<DeployerKeyPair | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Releases the deployer key pair
|
|
35
|
+
*/
|
|
36
|
+
releaseDeployer(params: {
|
|
37
|
+
publicKey: string;
|
|
38
|
+
txsHashes: string[];
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the data by key
|
|
42
|
+
* @param key the key to get the data
|
|
43
|
+
* @returns the data
|
|
44
|
+
*/
|
|
45
|
+
getDataByKey(key: string): Promise<string | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* Saves the data by key
|
|
48
|
+
* @param key the key to save the data
|
|
49
|
+
* @param value the value to save
|
|
50
|
+
*/
|
|
51
|
+
saveDataByKey(key: string, value: string | undefined): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Saves the file
|
|
54
|
+
* @param filename the filename to save
|
|
55
|
+
* @param value the value to save
|
|
56
|
+
*/
|
|
57
|
+
saveFile(filename: string, value: Buffer): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Loads the file
|
|
60
|
+
* @param filename
|
|
61
|
+
* @returns the file data
|
|
62
|
+
*/
|
|
63
|
+
loadFile(filename: string): Promise<Buffer | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Encrypts the data
|
|
66
|
+
* @param params
|
|
67
|
+
* @param params.data the data
|
|
68
|
+
* @param params.context the context
|
|
69
|
+
* @param params.keyId the key id, optional
|
|
70
|
+
* @returns encrypted data
|
|
71
|
+
*/
|
|
72
|
+
encrypt(params: {
|
|
73
|
+
data: string;
|
|
74
|
+
context: string;
|
|
75
|
+
keyId?: string;
|
|
76
|
+
}): Promise<string | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Decrypts the data
|
|
79
|
+
* @param params
|
|
80
|
+
* @param params.data the data
|
|
81
|
+
* @param params.context the context
|
|
82
|
+
* @param params.keyId the key id, optional
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
decrypt(params: {
|
|
86
|
+
data: string;
|
|
87
|
+
context: string;
|
|
88
|
+
keyId?: string;
|
|
89
|
+
}): Promise<string | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Generates an id for local cloud
|
|
92
|
+
* @returns generated unique id
|
|
93
|
+
*/
|
|
94
|
+
private static generateId;
|
|
95
|
+
/**
|
|
96
|
+
* Send transactions to the local cloud
|
|
97
|
+
* @param transactions the transactions to add
|
|
98
|
+
* @returns the transaction ids
|
|
99
|
+
*/
|
|
100
|
+
sendTransactions(transactions: string[]): Promise<CloudTransaction[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Adds transactions to the local cloud
|
|
103
|
+
* @param transactions the transactions to add
|
|
104
|
+
* @returns the transaction ids
|
|
105
|
+
*/
|
|
106
|
+
static addTransactions(transactions: string[] | CloudTransaction[]): Promise<CloudTransaction[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Deletes a transaction from the local cloud
|
|
109
|
+
* @param txId the transaction id to delete
|
|
110
|
+
*/
|
|
111
|
+
deleteTransaction(txId: string): Promise<void>;
|
|
112
|
+
getTransactions(): Promise<CloudTransaction[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Publish the transaction metadata in human-readable format
|
|
115
|
+
* @param params
|
|
116
|
+
* @param params.txId the transaction id
|
|
117
|
+
* @param params.metadata the metadata
|
|
118
|
+
*/
|
|
119
|
+
publishTransactionMetadata(params: {
|
|
120
|
+
txId: string;
|
|
121
|
+
metadata: TransactionMetadata;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Runs the worker in the local cloud
|
|
125
|
+
* @param params the parameters to run the worker
|
|
126
|
+
* @param params.command the command to run
|
|
127
|
+
* @param params.data the data to use
|
|
128
|
+
* @param params.chain the blockchain to execute the job on
|
|
129
|
+
* @param params.localWorker the worker to execute the tasks
|
|
130
|
+
* @returns the job id
|
|
131
|
+
*/
|
|
132
|
+
static run(params: {
|
|
133
|
+
command: ApiCommand;
|
|
134
|
+
data: {
|
|
135
|
+
developer: string;
|
|
136
|
+
repo: string;
|
|
137
|
+
transactions: string[];
|
|
138
|
+
task: string;
|
|
139
|
+
userId?: string;
|
|
140
|
+
args?: string;
|
|
141
|
+
metadata?: string;
|
|
142
|
+
};
|
|
143
|
+
chain: blockchain;
|
|
144
|
+
localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
|
145
|
+
}): Promise<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Runs the recursive proof in the local cloud
|
|
148
|
+
* @param data the data to use
|
|
149
|
+
* @param data.transactions the transactions to process
|
|
150
|
+
* @param data.task the task to execute
|
|
151
|
+
* @param data.userId the user id
|
|
152
|
+
* @param data.args the arguments for the job
|
|
153
|
+
* @param data.metadata the metadata for the job
|
|
154
|
+
* @returns the job id
|
|
155
|
+
*/
|
|
156
|
+
recursiveProof(data: {
|
|
157
|
+
transactions: string[];
|
|
158
|
+
task?: string;
|
|
159
|
+
userId?: string;
|
|
160
|
+
args?: string;
|
|
161
|
+
metadata?: string;
|
|
162
|
+
}): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Executes the task in the local cloud
|
|
165
|
+
* @param data the data to use
|
|
166
|
+
* @param data.transactions the transactions to process
|
|
167
|
+
* @param data.task the task to execute
|
|
168
|
+
* @param data.userId the user id
|
|
169
|
+
* @param data.args the arguments for the job
|
|
170
|
+
* @param data.metadata the metadata for the job
|
|
171
|
+
* @returns the job id
|
|
172
|
+
*/
|
|
173
|
+
execute(data: {
|
|
174
|
+
transactions: string[];
|
|
175
|
+
task: string;
|
|
176
|
+
userId?: string;
|
|
177
|
+
args?: string;
|
|
178
|
+
metadata?: string;
|
|
179
|
+
}): Promise<string>;
|
|
180
|
+
/**
|
|
181
|
+
* Gets the job result
|
|
182
|
+
* @param jobId the job id
|
|
183
|
+
* @returns the job data
|
|
184
|
+
*/
|
|
185
|
+
jobResult(jobId: string): Promise<JobData | undefined>;
|
|
186
|
+
/**
|
|
187
|
+
* Adds a task to the local cloud
|
|
188
|
+
* @param data the data to use
|
|
189
|
+
* @param data.task the task to execute
|
|
190
|
+
* @param data.startTime the start time for the task
|
|
191
|
+
* @param data.userId the user id
|
|
192
|
+
* @param data.args the arguments for the job
|
|
193
|
+
* @param data.metadata the metadata for the job
|
|
194
|
+
* @returns the task id
|
|
195
|
+
*/
|
|
196
|
+
addTask(data: {
|
|
197
|
+
task: string;
|
|
198
|
+
startTime?: number;
|
|
199
|
+
userId?: string;
|
|
200
|
+
args?: string;
|
|
201
|
+
metadata?: string;
|
|
202
|
+
}): Promise<string>;
|
|
203
|
+
/**
|
|
204
|
+
* Deletes a task from the local cloud
|
|
205
|
+
* @param taskId the task id to delete
|
|
206
|
+
*/
|
|
207
|
+
deleteTask(taskId: string): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Processes the tasks in the local cloud
|
|
210
|
+
*/
|
|
211
|
+
processTasks(): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Processes the local tasks
|
|
214
|
+
* @param params the parameters to process the local tasks
|
|
215
|
+
* @param params.developer the developer of the repo
|
|
216
|
+
* @param params.repo the repo
|
|
217
|
+
* @param params.localWorker the worker to execute the tasks
|
|
218
|
+
* @param params.chain the blockchain to execute the job on
|
|
219
|
+
*/
|
|
220
|
+
static processLocalTasks(params: {
|
|
221
|
+
developer: string;
|
|
222
|
+
repo: string;
|
|
223
|
+
localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
|
224
|
+
chain: blockchain;
|
|
225
|
+
}): Promise<number>;
|
|
226
|
+
/**
|
|
227
|
+
* Runs the sequencer in the local cloud
|
|
228
|
+
* @param params the parameters to run the sequencer
|
|
229
|
+
* @param params.worker the worker to execute the tasks
|
|
230
|
+
* @param params.data the data to use
|
|
231
|
+
* @returns the proof
|
|
232
|
+
*/
|
|
233
|
+
static sequencer(params: {
|
|
234
|
+
worker: zkCloudWorker;
|
|
235
|
+
data: {
|
|
236
|
+
developer: string;
|
|
237
|
+
repo: string;
|
|
238
|
+
transactions: string[];
|
|
239
|
+
task?: string;
|
|
240
|
+
userId?: string;
|
|
241
|
+
args?: string;
|
|
242
|
+
metadata?: string;
|
|
243
|
+
};
|
|
244
|
+
}): Promise<string>;
|
|
245
|
+
/**
|
|
246
|
+
* forces the worker to restart
|
|
247
|
+
*/
|
|
248
|
+
forceWorkerRestart(): Promise<void>;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* LocalStorage is a local storage for the local cloud.
|
|
252
|
+
* It stores jobs, tasks, transactions, and data.
|
|
253
|
+
* It can be used to test the cloud functionality without deploying to the cloud.
|
|
254
|
+
*/
|
|
255
|
+
export declare class LocalStorage {
|
|
256
|
+
/** The jobs */
|
|
257
|
+
static jobs: {
|
|
258
|
+
[key: string]: JobData;
|
|
259
|
+
};
|
|
260
|
+
/** The job events */
|
|
261
|
+
static jobEvents: {
|
|
262
|
+
[key: string]: JobEvent;
|
|
263
|
+
};
|
|
264
|
+
/** The data */
|
|
265
|
+
static data: {
|
|
266
|
+
[key: string]: string;
|
|
267
|
+
};
|
|
268
|
+
/** The files */
|
|
269
|
+
static files: {
|
|
270
|
+
[key: string]: Buffer;
|
|
271
|
+
};
|
|
272
|
+
/** The transactions */
|
|
273
|
+
static transactions: {
|
|
274
|
+
[key: string]: CloudTransaction;
|
|
275
|
+
};
|
|
276
|
+
/** The tasks */
|
|
277
|
+
static tasks: {
|
|
278
|
+
[key: string]: TaskData;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Saves the data.
|
|
282
|
+
* @param name The name to save the data under.
|
|
283
|
+
* @throws Error Method not implemented to keep web compatibility.
|
|
284
|
+
*/
|
|
285
|
+
static saveData(name: string): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Loads the data.
|
|
288
|
+
* @param name The name to load the data from.
|
|
289
|
+
* @throws Error Method not implemented to keep web compatibility.
|
|
290
|
+
*/
|
|
291
|
+
static loadData(name: string): Promise<void>;
|
|
292
|
+
}
|