zkcloudworker 0.2.1 → 0.2.3
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/lib/ts/src/api/api.d.ts +9 -5
- package/lib/ts/src/api/api.js +84 -17
- package/lib/ts/src/cloud/cloud.d.ts +10 -2
- package/lib/ts/src/cloud/local.d.ts +18 -5
- package/lib/ts/src/cloud/local.js +32 -10
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/api/api.d.ts +9 -5
- package/lib/web/src/api/api.js +85 -18
- package/lib/web/src/api/api.js.map +1 -1
- package/lib/web/src/cloud/cloud.d.ts +10 -2
- package/lib/web/src/cloud/cloud.js.map +1 -1
- package/lib/web/src/cloud/local.d.ts +18 -5
- package/lib/web/src/cloud/local.js +36 -10
- package/lib/web/src/cloud/local.js.map +1 -1
- package/lib/web/tsconfig.web.tsbuildinfo +1 -1
- package/package.json +3 -3
package/lib/web/src/api/api.d.ts
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
+
import { zkCloudWorker, Cloud } from "../cloud/cloud";
|
1
2
|
/**
|
2
3
|
* API class for interacting with the zkCloudWorker
|
3
4
|
* @property jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
4
5
|
* @property endpoint The endpoint of the serverless api
|
5
6
|
*/
|
6
7
|
export declare class zkCloudWorkerClient {
|
7
|
-
jwt: string;
|
8
|
-
endpoint: string;
|
8
|
+
readonly jwt: string;
|
9
|
+
readonly endpoint: string;
|
10
|
+
readonly localJobs: Map<string, string>;
|
11
|
+
readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker> | undefined;
|
9
12
|
/**
|
10
13
|
* Constructor for the API class
|
11
14
|
* @param jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
12
15
|
*/
|
13
|
-
constructor(jwt: string);
|
16
|
+
constructor(jwt: string, zkcloudworker?: ((cloud: Cloud) => Promise<zkCloudWorker>) | undefined);
|
14
17
|
/**
|
15
18
|
* Starts a new job for the proof calculation using serverless api call
|
16
19
|
* The developer and name should correspond to the BackupPlugin of the API
|
@@ -27,7 +30,7 @@ export declare class zkCloudWorkerClient {
|
|
27
30
|
* The developers repo should provide a BackupPlugin with the name task
|
28
31
|
* that can be called with the given parameters
|
29
32
|
*/
|
30
|
-
|
33
|
+
recursiveProof(data: {
|
31
34
|
developer: string;
|
32
35
|
repo: string;
|
33
36
|
transactions: string[];
|
@@ -52,7 +55,7 @@ export declare class zkCloudWorkerClient {
|
|
52
55
|
* @returns { success: boolean, error?: string, jobId?: string }
|
53
56
|
* where jonId is the jobId of the job
|
54
57
|
*/
|
55
|
-
|
58
|
+
execute(data: {
|
56
59
|
developer: string;
|
57
60
|
repo: string;
|
58
61
|
task?: string;
|
@@ -137,4 +140,5 @@ export declare class zkCloudWorkerClient {
|
|
137
140
|
* */
|
138
141
|
private apiHub;
|
139
142
|
private isError;
|
143
|
+
private generateJobId;
|
140
144
|
}
|
package/lib/web/src/api/api.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { __awaiter } from "tslib";
|
2
2
|
import axios from "axios";
|
3
|
-
import { sleep } from "../mina";
|
3
|
+
import { sleep, makeString } from "../mina";
|
4
|
+
import { LocalCloud } from "../cloud/local";
|
4
5
|
import config from "../config";
|
5
6
|
const { ZKCLOUDWORKER_AUTH, ZKCLOUDWORKER_API } = config;
|
6
7
|
/**
|
@@ -13,9 +14,15 @@ export class zkCloudWorkerClient {
|
|
13
14
|
* Constructor for the API class
|
14
15
|
* @param jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
15
16
|
*/
|
16
|
-
constructor(jwt) {
|
17
|
+
constructor(jwt, zkcloudworker = undefined) {
|
18
|
+
this.localJobs = new Map();
|
17
19
|
this.jwt = jwt;
|
18
20
|
this.endpoint = ZKCLOUDWORKER_API;
|
21
|
+
if (jwt === "local") {
|
22
|
+
if (zkcloudworker === undefined)
|
23
|
+
throw new Error("worker is required for local mode");
|
24
|
+
this.localWorker = zkcloudworker;
|
25
|
+
}
|
19
26
|
}
|
20
27
|
/**
|
21
28
|
* Starts a new job for the proof calculation using serverless api call
|
@@ -33,9 +40,9 @@ export class zkCloudWorkerClient {
|
|
33
40
|
* The developers repo should provide a BackupPlugin with the name task
|
34
41
|
* that can be called with the given parameters
|
35
42
|
*/
|
36
|
-
|
43
|
+
recursiveProof(data) {
|
37
44
|
return __awaiter(this, void 0, void 0, function* () {
|
38
|
-
const result = yield this.apiHub("
|
45
|
+
const result = yield this.apiHub("recursiveProof", data);
|
39
46
|
if (result.data === "error")
|
40
47
|
return {
|
41
48
|
success: false,
|
@@ -61,9 +68,9 @@ export class zkCloudWorkerClient {
|
|
61
68
|
* @returns { success: boolean, error?: string, jobId?: string }
|
62
69
|
* where jonId is the jobId of the job
|
63
70
|
*/
|
64
|
-
|
71
|
+
execute(data) {
|
65
72
|
return __awaiter(this, void 0, void 0, function* () {
|
66
|
-
const result = yield this.apiHub("
|
73
|
+
const result = yield this.apiHub("execute", data);
|
67
74
|
if (result.data === "error")
|
68
75
|
return {
|
69
76
|
success: false,
|
@@ -118,6 +125,7 @@ export class zkCloudWorkerClient {
|
|
118
125
|
*/
|
119
126
|
deploy(data) {
|
120
127
|
return __awaiter(this, void 0, void 0, function* () {
|
128
|
+
// TODO: encrypt env.json
|
121
129
|
const result = yield this.apiHub("deploy", data);
|
122
130
|
if (result.data === "error")
|
123
131
|
return {
|
@@ -223,19 +231,75 @@ export class zkCloudWorkerClient {
|
|
223
231
|
) {
|
224
232
|
return __awaiter(this, void 0, void 0, function* () {
|
225
233
|
var _a;
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
234
|
+
if (this.jwt === "local") {
|
235
|
+
switch (command) {
|
236
|
+
case "recursiveProof": {
|
237
|
+
const jobId = this.generateJobId();
|
238
|
+
const cloud = new LocalCloud(Object.assign({ jobId }, data));
|
239
|
+
const worker = yield this.localWorker(cloud);
|
240
|
+
if (worker === undefined)
|
241
|
+
throw new Error("worker is undefined");
|
242
|
+
const proof = yield LocalCloud.sequencer({
|
243
|
+
worker,
|
244
|
+
data,
|
245
|
+
});
|
246
|
+
this.localJobs.set(jobId, proof);
|
247
|
+
return {
|
248
|
+
success: true,
|
249
|
+
data: jobId,
|
250
|
+
};
|
251
|
+
}
|
252
|
+
case "execute":
|
253
|
+
return {
|
254
|
+
success: true,
|
255
|
+
data: "local_execute",
|
256
|
+
};
|
257
|
+
case "jobResult":
|
258
|
+
const result = this.localJobs.get(data.jobId);
|
259
|
+
if (result === undefined) {
|
260
|
+
return {
|
261
|
+
success: false,
|
262
|
+
error: "local job not found",
|
263
|
+
};
|
264
|
+
}
|
265
|
+
else {
|
266
|
+
return {
|
267
|
+
success: true,
|
268
|
+
data: result,
|
269
|
+
};
|
270
|
+
}
|
271
|
+
case "deploy":
|
272
|
+
return {
|
273
|
+
success: true,
|
274
|
+
data: "local_deploy",
|
275
|
+
};
|
276
|
+
case "queryBilling":
|
277
|
+
return {
|
278
|
+
success: true,
|
279
|
+
data: "local_queryBilling",
|
280
|
+
};
|
281
|
+
default:
|
282
|
+
return {
|
283
|
+
success: false,
|
284
|
+
error: "local_error",
|
285
|
+
};
|
286
|
+
}
|
235
287
|
}
|
236
|
-
|
237
|
-
|
238
|
-
|
288
|
+
else {
|
289
|
+
const apiData = {
|
290
|
+
auth: ZKCLOUDWORKER_AUTH,
|
291
|
+
command: command,
|
292
|
+
jwtToken: this.jwt,
|
293
|
+
data: data,
|
294
|
+
};
|
295
|
+
try {
|
296
|
+
const response = yield axios.post(this.endpoint, apiData);
|
297
|
+
return { success: true, data: response.data };
|
298
|
+
}
|
299
|
+
catch (error) {
|
300
|
+
console.error("apiHub error:", (_a = error.message) !== null && _a !== void 0 ? _a : error);
|
301
|
+
return { success: false, error: error };
|
302
|
+
}
|
239
303
|
}
|
240
304
|
});
|
241
305
|
}
|
@@ -249,5 +313,8 @@ export class zkCloudWorkerClient {
|
|
249
313
|
return true;
|
250
314
|
return false;
|
251
315
|
}
|
316
|
+
generateJobId() {
|
317
|
+
return "local." + Date.now().toString() + "." + makeString(32);
|
318
|
+
}
|
252
319
|
}
|
253
320
|
//# sourceMappingURL=api.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;AAEzD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAM9B;;;OAGG;IACH,YACE,GAAW,EACX,gBAEgB,SAAS;QAXlB,cAAS,GAAwB,IAAI,GAAG,EAAkB,CAAC;QAalE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;QAClC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;YACpB,IAAI,aAAa,KAAK,SAAS;gBAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACU,cAAc,CAAC,IAQ3B;;YAKC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YACzD,I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AAE,CAAC,CAAC;IACjE,CAAC;CACF"}
|
@@ -1,5 +1,11 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { Cache, PrivateKey } from "o1js";
|
2
|
+
import { Cache, PrivateKey, PublicKey, SmartContract } from "o1js";
|
3
|
+
import { blockchain } from "../networks";
|
4
|
+
interface DeployedSmartContract {
|
5
|
+
address: PublicKey;
|
6
|
+
contract: SmartContract;
|
7
|
+
chain: blockchain;
|
8
|
+
}
|
3
9
|
export declare abstract class Cloud {
|
4
10
|
readonly jobId: string;
|
5
11
|
readonly stepId: string;
|
@@ -27,12 +33,14 @@ export declare abstract class Cloud {
|
|
27
33
|
abstract saveDataByKey(key: string, value: string): Promise<void>;
|
28
34
|
abstract saveFile(filename: string, value: Buffer): Promise<void>;
|
29
35
|
abstract loadFile(filename: string): Promise<Buffer | undefined>;
|
36
|
+
abstract loadEnvironment(password: string): Promise<void>;
|
30
37
|
}
|
31
38
|
export declare abstract class zkCloudWorker {
|
32
39
|
readonly cloud: Cloud;
|
33
40
|
constructor(cloud: Cloud);
|
34
|
-
abstract
|
41
|
+
abstract deployedContracts(): Promise<DeployedSmartContract[]>;
|
35
42
|
abstract create(transaction: string): Promise<string | undefined>;
|
36
43
|
abstract merge(proof1: string, proof2: string): Promise<string | undefined>;
|
37
44
|
abstract execute(): Promise<string | undefined>;
|
38
45
|
}
|
46
|
+
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"AAQA,MAAM,OAAgB,KAAK;IAWzB,YAAY,MAUX;QACC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,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;IAC3B,CAAC;CAUF;AAED,MAAM,OAAgB,aAAa;IAGjC,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAWF"}
|
@@ -1,14 +1,14 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { Cache, PrivateKey } from "o1js";
|
3
|
-
import { Cloud } from "./cloud";
|
3
|
+
import { Cloud, zkCloudWorker } from "./cloud";
|
4
4
|
export declare class LocalCloud extends Cloud {
|
5
5
|
data: Map<string, string>;
|
6
|
-
constructor(params
|
7
|
-
jobId
|
6
|
+
constructor(params: {
|
7
|
+
jobId: string;
|
8
8
|
stepId?: string;
|
9
9
|
cache?: Cache;
|
10
|
-
developer
|
11
|
-
repo
|
10
|
+
developer: string;
|
11
|
+
repo: string;
|
12
12
|
task?: string;
|
13
13
|
userId?: string;
|
14
14
|
args?: string;
|
@@ -20,4 +20,17 @@ export declare class LocalCloud extends Cloud {
|
|
20
20
|
saveDataByKey(key: string, value: string): Promise<void>;
|
21
21
|
saveFile(filename: string, value: Buffer): Promise<void>;
|
22
22
|
loadFile(filename: string): Promise<Buffer | undefined>;
|
23
|
+
loadEnvironment(password: string): Promise<void>;
|
24
|
+
static sequencer(params: {
|
25
|
+
worker: zkCloudWorker;
|
26
|
+
data: {
|
27
|
+
developer: string;
|
28
|
+
repo: string;
|
29
|
+
transactions: string[];
|
30
|
+
task?: string;
|
31
|
+
userId?: string;
|
32
|
+
args?: string;
|
33
|
+
metadata?: string;
|
34
|
+
};
|
35
|
+
}): Promise<string>;
|
23
36
|
}
|
@@ -2,18 +2,18 @@ import { __awaiter } from "tslib";
|
|
2
2
|
import { Cache } from "o1js";
|
3
3
|
import { Cloud } from "./cloud";
|
4
4
|
export class LocalCloud extends Cloud {
|
5
|
-
constructor(params
|
5
|
+
constructor(params) {
|
6
6
|
const { jobId, stepId, cache, developer, repo, task, userId, args, metadata, } = params;
|
7
7
|
super({
|
8
|
-
jobId: jobId
|
9
|
-
stepId: stepId
|
10
|
-
cache: cache
|
11
|
-
developer: developer
|
12
|
-
repo: repo
|
13
|
-
task: task
|
14
|
-
userId: userId
|
15
|
-
args: args
|
16
|
-
metadata: metadata
|
8
|
+
jobId: jobId,
|
9
|
+
stepId: stepId !== null && stepId !== void 0 ? stepId : "stepId",
|
10
|
+
cache: cache !== null && cache !== void 0 ? cache : Cache.FileSystem("./cache"),
|
11
|
+
developer: developer,
|
12
|
+
repo: repo,
|
13
|
+
task: task,
|
14
|
+
userId: userId,
|
15
|
+
args: args,
|
16
|
+
metadata: metadata,
|
17
17
|
});
|
18
18
|
this.data = new Map();
|
19
19
|
}
|
@@ -48,5 +48,31 @@ export class LocalCloud extends Cloud {
|
|
48
48
|
throw new Error("Method not implemented.");
|
49
49
|
});
|
50
50
|
}
|
51
|
+
loadEnvironment(password) {
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
53
|
+
throw new Error("Method not implemented.");
|
54
|
+
});
|
55
|
+
}
|
56
|
+
static sequencer(params) {
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
58
|
+
const { worker, data } = params;
|
59
|
+
const { developer, repo, transactions, task, userId, args, metadata } = data;
|
60
|
+
const proofs = [];
|
61
|
+
for (const transaction of transactions) {
|
62
|
+
const result = yield worker.create(transaction);
|
63
|
+
if (result === undefined)
|
64
|
+
throw new Error("Failed to create proof");
|
65
|
+
proofs.push(result);
|
66
|
+
}
|
67
|
+
let proof = proofs[0];
|
68
|
+
for (let i = 1; i < proofs.length; i++) {
|
69
|
+
const result = yield worker.merge(proof, proofs[i]);
|
70
|
+
if (result === undefined)
|
71
|
+
throw new Error("Failed to merge proofs");
|
72
|
+
proof = result;
|
73
|
+
}
|
74
|
+
return proof;
|
75
|
+
});
|
76
|
+
}
|
51
77
|
}
|
52
78
|
//# sourceMappingURL=local.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../src/cloud/local.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,KAAK,
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../src/cloud/local.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAE/C,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGnC,YAAY,MAUX;QACC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,GAAG,MAAM,CAAC;QACX,KAAK,CAAC;YACJ,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,QAAQ;YAC1B,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC;QAlCL,SAAI,GAAwB,IAAI,GAAG,EAAkB,CAAC;IAmCtD,CAAC;IACY,W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