zkcloudworker 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ts/src/api/api.d.ts +7 -3
- package/lib/ts/src/api/api.js +79 -13
- package/lib/ts/src/cloud/cloud.d.ts +8 -2
- package/lib/ts/src/cloud/local.d.ts +17 -5
- package/lib/ts/src/cloud/local.js +29 -10
- package/lib/ts/src/index.d.ts +7 -7
- package/lib/ts/src/index.js +21 -30
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/api/api.d.ts +7 -3
- package/lib/web/src/api/api.js +80 -14
- package/lib/web/src/api/api.js.map +1 -1
- package/lib/web/src/cloud/cloud.d.ts +8 -2
- package/lib/web/src/cloud/cloud.js.map +1 -1
- package/lib/web/src/cloud/local.d.ts +17 -5
- package/lib/web/src/cloud/local.js +31 -10
- package/lib/web/src/cloud/local.js.map +1 -1
- package/lib/web/src/index.d.ts +7 -7
- package/lib/web/src/index.js +7 -7
- package/lib/web/src/index.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
|
@@ -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
|
@@ -224,19 +231,75 @@ export class zkCloudWorkerClient {
|
|
224
231
|
) {
|
225
232
|
return __awaiter(this, void 0, void 0, function* () {
|
226
233
|
var _a;
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
+
}
|
236
287
|
}
|
237
|
-
|
238
|
-
|
239
|
-
|
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
|
+
}
|
240
303
|
}
|
241
304
|
});
|
242
305
|
}
|
@@ -250,5 +313,8 @@ export class zkCloudWorkerClient {
|
|
250
313
|
return true;
|
251
314
|
return false;
|
252
315
|
}
|
316
|
+
generateJobId() {
|
317
|
+
return "local." + Date.now().toString() + "." + makeString(32);
|
318
|
+
}
|
253
319
|
}
|
254
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,C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O,aAAa;QACnB,OAAO,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,UAAU,CAAC,EAAE,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
|
+
export 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;
|
@@ -32,7 +38,7 @@ export declare abstract class Cloud {
|
|
32
38
|
export declare abstract class zkCloudWorker {
|
33
39
|
readonly cloud: Cloud;
|
34
40
|
constructor(cloud: Cloud);
|
35
|
-
abstract
|
41
|
+
abstract deployedContracts(): Promise<DeployedSmartContract[]>;
|
36
42
|
abstract create(transaction: string): Promise<string | undefined>;
|
37
43
|
abstract merge(proof1: string, proof2: string): Promise<string | undefined>;
|
38
44
|
abstract execute(): Promise<string | undefined>;
|
@@ -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;
|
@@ -21,4 +21,16 @@ export declare class LocalCloud extends Cloud {
|
|
21
21
|
saveFile(filename: string, value: Buffer): Promise<void>;
|
22
22
|
loadFile(filename: string): Promise<Buffer | undefined>;
|
23
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>;
|
24
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
|
}
|
@@ -53,5 +53,26 @@ export class LocalCloud extends Cloud {
|
|
53
53
|
throw new Error("Method not implemented.");
|
54
54
|
});
|
55
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
|
+
}
|
56
77
|
}
|
57
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,WAAW;;YACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;KAAA;IACY,GAAG,CAAC,GAAW;;YAC1B,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;KAAA;IAEY,YAAY,CAAC,GAAW;;YACnC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI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,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpD,IAAI,MAAM,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBACpE,KAAK,GAAG,MAAM,CAAC;YACjB,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;CACF"}
|
package/lib/web/src/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
1
|
+
export * from "./api/api";
|
2
|
+
export * from "./cloud/cloud";
|
3
|
+
export * from "./cloud/local";
|
4
|
+
export * from "./mina";
|
5
|
+
export * from "./fee";
|
6
|
+
export * from "./networks";
|
7
|
+
export * from "./api/client-api";
|
package/lib/web/src/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
1
|
+
export * from "./api/api";
|
2
|
+
export * from "./cloud/cloud";
|
3
|
+
export * from "./cloud/local";
|
4
|
+
export * from "./mina";
|
5
|
+
export * from "./fee";
|
6
|
+
export * from "./networks";
|
7
|
+
export * from "./api/client-api";
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/web/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|