Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
445 changes: 17 additions & 428 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/helper/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class ZkWasmServiceHelper {
return __awaiter(this, void 0, void 0, function* () {
let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.PROVE, task, true);
if (this.endpoint.enable_logs) {
console.log("get addProvingTask response:", response.toString());
console.log("get addProvingTask response:", response);
}
return response;
});
Expand Down
2 changes: 1 addition & 1 deletion dist/cjs/helper/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export declare class ZkWasmUtil {
static ERC20Contract(contractAddress: string, signer: Signer): Contract;
static bytesToJSONString(data: Uint8Array): string;
static loadContextFileFromPath(filePath: string): Promise<ContextHexString>;
static loadContexFileAsBytes(filePath: string): Promise<Uint8Array>;
static loadContexFileAsBytes(filePath: string): Promise<[Buffer, string]>;
static browserLoadContextFileAsBytes(file: File): Promise<Uint8Array>;
static bytesToTempFile(data: Uint8Array): Promise<Buffer>;
static bytesToFile(data: Uint8Array): Promise<File>;
Expand Down
19 changes: 11 additions & 8 deletions dist/cjs/helper/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ class ZkWasmUtil {
message += params.description_url;
message += params.avator_url;
message += params.circuit_size;
// Additional params afterwards
if (params.initial_context) {
message += params.initial_context_md5;
}
message += params.prove_payment_src;
for (const chainId of params.auto_submit_network_ids) {
message += chainId;
}
// Additional params afterwards
if (params.initial_context) {
message += params.initial_context_md5;
}
return message;
}
static createProvingSignMessage(params) {
Expand Down Expand Up @@ -326,9 +326,11 @@ class ZkWasmUtil {
return __awaiter(this, void 0, void 0, function* () {
if (typeof window === "undefined") {
// We are in Node.js
const fs = require("fs");
//const fs = await import("fs").then((module) => module.promises);
return fs.readFile(filePath, "utf8");
const fs = yield Promise.resolve().then(() => __importStar(require("fs/promises")));
const file = yield fs.readFile(filePath, {
encoding: "utf-8",
});
return file;
}
else {
// Browser environment
Expand All @@ -343,7 +345,8 @@ class ZkWasmUtil {
const fileContents = yield this.loadContextFileFromPath(filePath);
let bytes = new TextEncoder().encode(fileContents);
this.validateContextBytes(bytes);
return bytes;
const md5 = this.convertToMd5(bytes);
return [Buffer.from(bytes), md5];
}
catch (err) {
throw err;
Expand Down
2 changes: 1 addition & 1 deletion dist/mjs/helper/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class ZkWasmServiceHelper {
async addProvingTask(task) {
let response = await this.sendRequestWithSignature("POST", TaskEndpoint.PROVE, task, true);
if (this.endpoint.enable_logs) {
console.log("get addProvingTask response:", response.toString());
console.log("get addProvingTask response:", response);
}
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/mjs/helper/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export declare class ZkWasmUtil {
static ERC20Contract(contractAddress: string, signer: Signer): Contract;
static bytesToJSONString(data: Uint8Array): string;
static loadContextFileFromPath(filePath: string): Promise<ContextHexString>;
static loadContexFileAsBytes(filePath: string): Promise<Uint8Array>;
static loadContexFileAsBytes(filePath: string): Promise<[Buffer, string]>;
static browserLoadContextFileAsBytes(file: File): Promise<Uint8Array>;
static bytesToTempFile(data: Uint8Array): Promise<Buffer>;
static bytesToFile(data: Uint8Array): Promise<File>;
Expand Down
19 changes: 11 additions & 8 deletions dist/mjs/helper/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ export class ZkWasmUtil {
message += params.description_url;
message += params.avator_url;
message += params.circuit_size;
// Additional params afterwards
if (params.initial_context) {
message += params.initial_context_md5;
}
message += params.prove_payment_src;
for (const chainId of params.auto_submit_network_ids) {
message += chainId;
}
// Additional params afterwards
if (params.initial_context) {
message += params.initial_context_md5;
}
return message;
}
static createProvingSignMessage(params) {
Expand Down Expand Up @@ -402,9 +402,11 @@ export class ZkWasmUtil {
static async loadContextFileFromPath(filePath) {
if (typeof window === "undefined") {
// We are in Node.js
const fs = require("fs");
//const fs = await import("fs").then((module) => module.promises);
return fs.readFile(filePath, "utf8");
const fs = await import("fs/promises");
const file = await fs.readFile(filePath, {
encoding: "utf-8",
});
return file;
}
else {
// Browser environment
Expand All @@ -417,7 +419,8 @@ export class ZkWasmUtil {
const fileContents = await this.loadContextFileFromPath(filePath);
let bytes = new TextEncoder().encode(fileContents);
this.validateContextBytes(bytes);
return bytes;
const md5 = this.convertToMd5(bytes);
return [Buffer.from(bytes), md5];
}
catch (err) {
throw err;
Expand Down
1 change: 1 addition & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions examples/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd node_modules/web3subscriber
npm run prepare
cd -
Loading