From 0a8a80ac456b97a50137f3747e83511441430380 Mon Sep 17 00:00:00 2001 From: Oscar Downing Date: Thu, 18 Apr 2024 11:33:30 +0530 Subject: [PATCH] ZKWAS-253: changes for pressure test script (#64) --- dist/cjs/helper/endpoint.d.ts | 3 +- dist/cjs/helper/endpoint.js | 19 ++++++--- dist/cjs/helper/task.d.ts | 2 +- dist/cjs/helper/task.js | 78 +++++++++++++++++++++++++---------- dist/mjs/helper/endpoint.d.ts | 3 +- dist/mjs/helper/endpoint.js | 20 ++++++--- dist/mjs/helper/task.d.ts | 2 +- dist/mjs/helper/task.js | 78 +++++++++++++++++++++++++---------- src/helper/endpoint.ts | 19 ++++++--- src/helper/task.ts | 78 +++++++++++++++++++++++++---------- 10 files changed, 220 insertions(+), 82 deletions(-) diff --git a/dist/cjs/helper/endpoint.d.ts b/dist/cjs/helper/endpoint.d.ts index 73cb765..abe6476 100644 --- a/dist/cjs/helper/endpoint.d.ts +++ b/dist/cjs/helper/endpoint.d.ts @@ -3,7 +3,8 @@ export declare class ZkWasmServiceEndpoint { endpoint: string; username: string; useraddress: string; - constructor(endpoint: string, username: string, useraddress: string); + enable_logs: boolean; + constructor(endpoint: string, username: string, useraddress: string, enable_logs?: boolean); prepareRequest(method: "GET" | "POST", url: string, body: JSON | FormData | null, headers?: { [key: string]: string; }): Promise; diff --git a/dist/cjs/helper/endpoint.js b/dist/cjs/helper/endpoint.js index 8bb9b79..968718b 100644 --- a/dist/cjs/helper/endpoint.js +++ b/dist/cjs/helper/endpoint.js @@ -15,21 +15,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.ZkWasmServiceEndpoint = void 0; const axios_1 = __importDefault(require("axios")); class ZkWasmServiceEndpoint { - constructor(endpoint, username, useraddress) { + constructor(endpoint, username, useraddress, enable_logs = true) { this.endpoint = endpoint; this.username = username; this.useraddress = useraddress; + this.enable_logs = enable_logs; } prepareRequest(method, url, body, headers) { return __awaiter(this, void 0, void 0, function* () { if (method === "GET") { - console.log(this.endpoint + url); + if (this.enable_logs) { + console.log(this.endpoint + url); + } try { let response = yield axios_1.default.get(this.endpoint + url, body ? { params: body, headers: Object.assign({}, headers) } : {}); return response.data; } catch (e) { - console.error(e); + if (this.enable_logs) { + console.error(e); + } return { success: false, error: e.response ? { @@ -50,7 +55,9 @@ class ZkWasmServiceEndpoint { return response.data; } catch (e) { - console.log(e); + if (this.enable_logs) { + console.log(e); + } return { success: false, error: e.response ? { @@ -68,7 +75,9 @@ class ZkWasmServiceEndpoint { getJSONResponse(json) { return __awaiter(this, void 0, void 0, function* () { if (json["success"] !== true) { - console.error(json); + if (this.enable_logs) { + console.error(json); + } throw new Error(json["error"].message); } return json["result"]; diff --git a/dist/cjs/helper/task.d.ts b/dist/cjs/helper/task.d.ts index 154b19b..7cd2388 100644 --- a/dist/cjs/helper/task.d.ts +++ b/dist/cjs/helper/task.d.ts @@ -2,7 +2,7 @@ import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, W import { ZkWasmServiceEndpoint } from "./endpoint.js"; export declare class ZkWasmServiceHelper { endpoint: ZkWasmServiceEndpoint; - constructor(endpoint: string, username: string, useraddress: string); + constructor(endpoint: string, username: string, useraddress: string, enable_logs?: boolean); queryImage(md5: string): Promise; queryImageBinary(md5: string): Promise; queryUser(user_query: UserQueryParams): Promise; diff --git a/dist/cjs/helper/task.js b/dist/cjs/helper/task.js index 087618d..3e45e89 100644 --- a/dist/cjs/helper/task.js +++ b/dist/cjs/helper/task.js @@ -29,15 +29,17 @@ const util_js_1 = require("./util.js"); const endpoint_js_1 = require("./endpoint.js"); const ethers_1 = require("ethers"); class ZkWasmServiceHelper { - constructor(endpoint, username, useraddress) { - this.endpoint = new endpoint_js_1.ZkWasmServiceEndpoint(endpoint, username, useraddress); + constructor(endpoint, username, useraddress, enable_logs = true) { + this.endpoint = new endpoint_js_1.ZkWasmServiceEndpoint(endpoint, username, useraddress, enable_logs); } queryImage(md5) { return __awaiter(this, void 0, void 0, function* () { let req = JSON.parse("{}"); req["md5"] = md5; const images = yield this.endpoint.invokeRequest("GET", "/image", req); - console.log("get queryImage response."); + if (this.endpoint.enable_logs) { + console.log("get queryImage response."); + } return images[0]; }); } @@ -46,7 +48,9 @@ class ZkWasmServiceHelper { let req = JSON.parse("{}"); req["md5"] = md5; const image = yield this.endpoint.invokeRequest("GET", "/imagebinary", req); - console.log("get queryImageBinary response."); + if (this.endpoint.enable_logs) { + console.log("get queryImageBinary response."); + } return image; }); } @@ -55,7 +59,9 @@ class ZkWasmServiceHelper { let req = JSON.parse("{}"); req["user_address"] = user_query.user_address; const user = yield this.endpoint.invokeRequest("GET", "/user", req); - console.log("get queryUser response."); + if (this.endpoint.enable_logs) { + console.log("get queryUser response."); + } return user; }); } @@ -64,7 +70,9 @@ class ZkWasmServiceHelper { let req = JSON.parse("{}"); req["user_address"] = user_query.user_address; const user = yield this.endpoint.invokeRequest("GET", "/user_subscription", req); - console.log("get queryUserSubscription response."); + if (this.endpoint.enable_logs) { + console.log("get queryUserSubscription response."); + } return user; }); } @@ -73,7 +81,9 @@ class ZkWasmServiceHelper { let req = JSON.parse("{}"); req["user_address"] = history_query.user_address; const txs = yield this.endpoint.invokeRequest("GET", "/transactions", req); - console.log("get queryTxHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryTxHistory response."); + } return txs; }); } @@ -82,14 +92,18 @@ class ZkWasmServiceHelper { let req = JSON.parse("{}"); req["user_address"] = history_query.user_address; const txs = yield this.endpoint.invokeRequest("GET", "/deposits", req); - console.log("get queryDepositHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryDepositHistory response."); + } return txs; }); } queryConfig() { return __awaiter(this, void 0, void 0, function* () { const config = yield this.endpoint.invokeRequest("GET", "/config", JSON.parse("{}")); - console.log("get queryConfig response."); + if (this.endpoint.enable_logs) { + console.log("get queryConfig response."); + } return config; }); } @@ -98,7 +112,9 @@ class ZkWasmServiceHelper { let headers = { "Content-Type": "application/json" }; let queryJson = JSON.parse("{}"); let st = yield this.endpoint.invokeRequest("GET", `/statistics`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return { totalImages: st.total_images, totalProofs: st.total_proofs, @@ -142,66 +158,86 @@ class ZkWasmServiceHelper { if (query[key] != "" && query[key] != null) queryJson[key] = query[key]; }); - console.log("params:", query); - console.log("json", queryJson); + if (this.endpoint.enable_logs) { + console.log("params:", query); + console.log("json", queryJson); + } let tasks = yield this.endpoint.invokeRequest("GET", `/tasks`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return tasks; }); } queryLogs(query) { return __awaiter(this, void 0, void 0, function* () { let logs = yield this.sendRequestWithSignature("GET", TaskEndpoint.LOGS, query); - console.log("loading logs!"); + if (this.endpoint.enable_logs) { + console.log("loading logs!"); + } return logs; }); } addPayment(payRequest) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.endpoint.invokeRequest("POST", TaskEndpoint.PAY, JSON.parse(JSON.stringify(payRequest))); - console.log("get addPayment response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addPayment response:", response.toString()); + } return response; }); } addSubscription(subscription) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.endpoint.invokeRequest("POST", TaskEndpoint.SUBSCRIBE, JSON.parse(JSON.stringify(subscription))); - console.log("get addSubscription response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addSubscription response:", response.toString()); + } return response; }); } addNewWasmImage(task) { return __awaiter(this, void 0, void 0, function* () { let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.SETUP, task, true); - console.log("get addNewWasmImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addNewWasmImage response:", response.toString()); + } return response; }); } addProvingTask(task) { return __awaiter(this, void 0, void 0, function* () { let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.PROVE, task, true); - console.log("get addProvingTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addProvingTask response:", response.toString()); + } return response; }); } addDeployTask(task) { return __awaiter(this, void 0, void 0, function* () { let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.DEPLOY, task); - console.log("get addDeployTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addDeployTask response:", response.toString()); + } return response; }); } addResetTask(task) { return __awaiter(this, void 0, void 0, function* () { let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.RESET, task, true); - console.log("get addResetTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addResetTask response:", response.toString()); + } return response; }); } modifyImage(data) { return __awaiter(this, void 0, void 0, function* () { let response = yield this.sendRequestWithSignature("POST", TaskEndpoint.MODIFY, data); - console.log("get modifyImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get modifyImage response:", response.toString()); + } return response; }); } diff --git a/dist/mjs/helper/endpoint.d.ts b/dist/mjs/helper/endpoint.d.ts index 73cb765..abe6476 100644 --- a/dist/mjs/helper/endpoint.d.ts +++ b/dist/mjs/helper/endpoint.d.ts @@ -3,7 +3,8 @@ export declare class ZkWasmServiceEndpoint { endpoint: string; username: string; useraddress: string; - constructor(endpoint: string, username: string, useraddress: string); + enable_logs: boolean; + constructor(endpoint: string, username: string, useraddress: string, enable_logs?: boolean); prepareRequest(method: "GET" | "POST", url: string, body: JSON | FormData | null, headers?: { [key: string]: string; }): Promise; diff --git a/dist/mjs/helper/endpoint.js b/dist/mjs/helper/endpoint.js index 974ab3f..4f4b05f 100644 --- a/dist/mjs/helper/endpoint.js +++ b/dist/mjs/helper/endpoint.js @@ -3,20 +3,26 @@ export class ZkWasmServiceEndpoint { endpoint; username; useraddress; - constructor(endpoint, username, useraddress) { + enable_logs; + constructor(endpoint, username, useraddress, enable_logs = true) { this.endpoint = endpoint; this.username = username; this.useraddress = useraddress; + this.enable_logs = enable_logs; } async prepareRequest(method, url, body, headers) { if (method === "GET") { - console.log(this.endpoint + url); + if (this.enable_logs) { + console.log(this.endpoint + url); + } try { let response = await axios.get(this.endpoint + url, body ? { params: body, headers: { ...headers } } : {}); return response.data; } catch (e) { - console.error(e); + if (this.enable_logs) { + console.error(e); + } return { success: false, error: e.response ? { @@ -39,7 +45,9 @@ export class ZkWasmServiceEndpoint { return response.data; } catch (e) { - console.log(e); + if (this.enable_logs) { + console.log(e); + } return { success: false, error: e.response ? { @@ -55,7 +63,9 @@ export class ZkWasmServiceEndpoint { } async getJSONResponse(json) { if (json["success"] !== true) { - console.error(json); + if (this.enable_logs) { + console.error(json); + } throw new Error(json["error"].message); } return json["result"]; diff --git a/dist/mjs/helper/task.d.ts b/dist/mjs/helper/task.d.ts index 154b19b..7cd2388 100644 --- a/dist/mjs/helper/task.d.ts +++ b/dist/mjs/helper/task.d.ts @@ -2,7 +2,7 @@ import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, W import { ZkWasmServiceEndpoint } from "./endpoint.js"; export declare class ZkWasmServiceHelper { endpoint: ZkWasmServiceEndpoint; - constructor(endpoint: string, username: string, useraddress: string); + constructor(endpoint: string, username: string, useraddress: string, enable_logs?: boolean); queryImage(md5: string): Promise; queryImageBinary(md5: string): Promise; queryUser(user_query: UserQueryParams): Promise; diff --git a/dist/mjs/helper/task.js b/dist/mjs/helper/task.js index f263db6..9de7844 100644 --- a/dist/mjs/helper/task.js +++ b/dist/mjs/helper/task.js @@ -4,61 +4,77 @@ import { ZkWasmServiceEndpoint } from "./endpoint.js"; import { ethers } from "ethers"; export class ZkWasmServiceHelper { endpoint; - constructor(endpoint, username, useraddress) { - this.endpoint = new ZkWasmServiceEndpoint(endpoint, username, useraddress); + constructor(endpoint, username, useraddress, enable_logs = true) { + this.endpoint = new ZkWasmServiceEndpoint(endpoint, username, useraddress, enable_logs); } async queryImage(md5) { let req = JSON.parse("{}"); req["md5"] = md5; const images = await this.endpoint.invokeRequest("GET", "/image", req); - console.log("get queryImage response."); + if (this.endpoint.enable_logs) { + console.log("get queryImage response."); + } return images[0]; } async queryImageBinary(md5) { let req = JSON.parse("{}"); req["md5"] = md5; const image = await this.endpoint.invokeRequest("GET", "/imagebinary", req); - console.log("get queryImageBinary response."); + if (this.endpoint.enable_logs) { + console.log("get queryImageBinary response."); + } return image; } async queryUser(user_query) { let req = JSON.parse("{}"); req["user_address"] = user_query.user_address; const user = await this.endpoint.invokeRequest("GET", "/user", req); - console.log("get queryUser response."); + if (this.endpoint.enable_logs) { + console.log("get queryUser response."); + } return user; } async queryUserSubscription(user_query) { let req = JSON.parse("{}"); req["user_address"] = user_query.user_address; const user = await this.endpoint.invokeRequest("GET", "/user_subscription", req); - console.log("get queryUserSubscription response."); + if (this.endpoint.enable_logs) { + console.log("get queryUserSubscription response."); + } return user; } async queryTxHistory(history_query) { let req = JSON.parse("{}"); req["user_address"] = history_query.user_address; const txs = await this.endpoint.invokeRequest("GET", "/transactions", req); - console.log("get queryTxHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryTxHistory response."); + } return txs; } async queryDepositHistory(history_query) { let req = JSON.parse("{}"); req["user_address"] = history_query.user_address; const txs = await this.endpoint.invokeRequest("GET", "/deposits", req); - console.log("get queryDepositHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryDepositHistory response."); + } return txs; } async queryConfig() { const config = await this.endpoint.invokeRequest("GET", "/config", JSON.parse("{}")); - console.log("get queryConfig response."); + if (this.endpoint.enable_logs) { + console.log("get queryConfig response."); + } return config; } async loadStatistics() { let headers = { "Content-Type": "application/json" }; let queryJson = JSON.parse("{}"); let st = await this.endpoint.invokeRequest("GET", `/statistics`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return { totalImages: st.total_images, totalProofs: st.total_proofs, @@ -100,50 +116,70 @@ export class ZkWasmServiceHelper { if (query[key] != "" && query[key] != null) queryJson[key] = query[key]; }); - console.log("params:", query); - console.log("json", queryJson); + if (this.endpoint.enable_logs) { + console.log("params:", query); + console.log("json", queryJson); + } let tasks = await this.endpoint.invokeRequest("GET", `/tasks`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return tasks; } async queryLogs(query) { let logs = await this.sendRequestWithSignature("GET", TaskEndpoint.LOGS, query); - console.log("loading logs!"); + if (this.endpoint.enable_logs) { + console.log("loading logs!"); + } return logs; } async addPayment(payRequest) { const response = await this.endpoint.invokeRequest("POST", TaskEndpoint.PAY, JSON.parse(JSON.stringify(payRequest))); - console.log("get addPayment response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addPayment response:", response.toString()); + } return response; } async addSubscription(subscription) { const response = await this.endpoint.invokeRequest("POST", TaskEndpoint.SUBSCRIBE, JSON.parse(JSON.stringify(subscription))); - console.log("get addSubscription response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addSubscription response:", response.toString()); + } return response; } async addNewWasmImage(task) { let response = await this.sendRequestWithSignature("POST", TaskEndpoint.SETUP, task, true); - console.log("get addNewWasmImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addNewWasmImage response:", response.toString()); + } return response; } async addProvingTask(task) { let response = await this.sendRequestWithSignature("POST", TaskEndpoint.PROVE, task, true); - console.log("get addProvingTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addProvingTask response:", response.toString()); + } return response; } async addDeployTask(task) { let response = await this.sendRequestWithSignature("POST", TaskEndpoint.DEPLOY, task); - console.log("get addDeployTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addDeployTask response:", response.toString()); + } return response; } async addResetTask(task) { let response = await this.sendRequestWithSignature("POST", TaskEndpoint.RESET, task, true); - console.log("get addResetTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addResetTask response:", response.toString()); + } return response; } async modifyImage(data) { let response = await this.sendRequestWithSignature("POST", TaskEndpoint.MODIFY, data); - console.log("get modifyImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get modifyImage response:", response.toString()); + } return response; } async sendRequestWithSignature(method, path, task, isFormData = false) { diff --git a/src/helper/endpoint.ts b/src/helper/endpoint.ts index 0639973..24f0b11 100644 --- a/src/helper/endpoint.ts +++ b/src/helper/endpoint.ts @@ -5,7 +5,8 @@ export class ZkWasmServiceEndpoint { constructor( public endpoint: string, public username: string, - public useraddress: string + public useraddress: string, + public enable_logs: boolean = true, ) { } async prepareRequest( method: "GET" | "POST", @@ -16,7 +17,9 @@ export class ZkWasmServiceEndpoint { } ) { if (method === "GET") { - console.log(this.endpoint + url); + if (this.enable_logs) { + console.log(this.endpoint + url); + } try { let response = await axios.get( this.endpoint + url, @@ -25,7 +28,9 @@ export class ZkWasmServiceEndpoint { ); return response.data; } catch (e: any) { - console.error(e); + if (this.enable_logs) { + console.error(e); + } return { success: false, error: e.response ? { @@ -50,7 +55,9 @@ export class ZkWasmServiceEndpoint { ); return response.data; } catch (e: any) { - console.log(e); + if (this.enable_logs) { + console.log(e); + } return { success: false, error: e.response ? { @@ -68,7 +75,9 @@ export class ZkWasmServiceEndpoint { async getJSONResponse(json: any) { if (json["success"] !== true) { - console.error(json); + if (this.enable_logs) { + console.error(json); + } throw new Error(json["error"].message); } return json["result"]; diff --git a/src/helper/task.ts b/src/helper/task.ts index a537929..1aab10e 100644 --- a/src/helper/task.ts +++ b/src/helper/task.ts @@ -30,8 +30,8 @@ import { ethers } from "ethers"; export class ZkWasmServiceHelper { endpoint: ZkWasmServiceEndpoint; - constructor(endpoint: string, username: string, useraddress: string) { - this.endpoint = new ZkWasmServiceEndpoint(endpoint, username, useraddress); + constructor(endpoint: string, username: string, useraddress: string, enable_logs : boolean = true) { + this.endpoint = new ZkWasmServiceEndpoint(endpoint, username, useraddress, enable_logs); } async queryImage(md5: string): Promise { @@ -39,7 +39,9 @@ export class ZkWasmServiceHelper { req["md5"] = md5; const images = await this.endpoint.invokeRequest("GET", "/image", req); - console.log("get queryImage response."); + if (this.endpoint.enable_logs) { + console.log("get queryImage response."); + } return images[0]!; } @@ -48,7 +50,9 @@ export class ZkWasmServiceHelper { req["md5"] = md5; const image = await this.endpoint.invokeRequest("GET", "/imagebinary", req); - console.log("get queryImageBinary response."); + if (this.endpoint.enable_logs) { + console.log("get queryImageBinary response."); + } return image!; } @@ -57,7 +61,9 @@ export class ZkWasmServiceHelper { req["user_address"] = user_query.user_address; const user = await this.endpoint.invokeRequest("GET", "/user", req); - console.log("get queryUser response."); + if (this.endpoint.enable_logs) { + console.log("get queryUser response."); + } return user; } @@ -72,7 +78,9 @@ export class ZkWasmServiceHelper { "/user_subscription", req ); - console.log("get queryUserSubscription response."); + if (this.endpoint.enable_logs) { + console.log("get queryUserSubscription response."); + } return user; } @@ -83,7 +91,9 @@ export class ZkWasmServiceHelper { req["user_address"] = history_query.user_address; const txs = await this.endpoint.invokeRequest("GET", "/transactions", req); - console.log("get queryTxHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryTxHistory response."); + } return txs; } @@ -94,7 +104,9 @@ export class ZkWasmServiceHelper { req["user_address"] = history_query.user_address; const txs = await this.endpoint.invokeRequest("GET", "/deposits", req); - console.log("get queryDepositHistory response."); + if (this.endpoint.enable_logs) { + console.log("get queryDepositHistory response."); + } return txs; } @@ -104,7 +116,9 @@ export class ZkWasmServiceHelper { "/config", JSON.parse("{}") ); - console.log("get queryConfig response."); + if (this.endpoint.enable_logs) { + console.log("get queryConfig response."); + } return config; } @@ -113,7 +127,9 @@ export class ZkWasmServiceHelper { let queryJson = JSON.parse("{}"); let st = await this.endpoint.invokeRequest("GET", `/statistics`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return { totalImages: st.total_images, @@ -162,11 +178,15 @@ export class ZkWasmServiceHelper { if (query[key] != "" && query[key] != null) queryJson[key] = query[key]; }); - console.log("params:", query); - console.log("json", queryJson); + if (this.endpoint.enable_logs) { + console.log("params:", query); + console.log("json", queryJson); + } let tasks = await this.endpoint.invokeRequest("GET", `/tasks`, queryJson); - console.log("loading task board!"); + if (this.endpoint.enable_logs) { + console.log("loading task board!"); + } return tasks; } @@ -176,7 +196,9 @@ export class ZkWasmServiceHelper { TaskEndpoint.LOGS, query ); - console.log("loading logs!"); + if (this.endpoint.enable_logs) { + console.log("loading logs!"); + } return logs; } @@ -186,7 +208,9 @@ export class ZkWasmServiceHelper { TaskEndpoint.PAY, JSON.parse(JSON.stringify(payRequest)) ); - console.log("get addPayment response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addPayment response:", response.toString()); + } return response; } @@ -196,7 +220,9 @@ export class ZkWasmServiceHelper { TaskEndpoint.SUBSCRIBE, JSON.parse(JSON.stringify(subscription)) ); - console.log("get addSubscription response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addSubscription response:", response.toString()); + } return response; } @@ -208,7 +234,9 @@ export class ZkWasmServiceHelper { true ); - console.log("get addNewWasmImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addNewWasmImage response:", response.toString()); + } return response; } @@ -219,7 +247,9 @@ export class ZkWasmServiceHelper { task, true ); - console.log("get addProvingTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addProvingTask response:", response.toString()); + } return response; } @@ -229,7 +259,9 @@ export class ZkWasmServiceHelper { TaskEndpoint.DEPLOY, task ); - console.log("get addDeployTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addDeployTask response:", response.toString()); + } return response; } @@ -241,7 +273,9 @@ export class ZkWasmServiceHelper { true ); - console.log("get addResetTask response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get addResetTask response:", response.toString()); + } return response; } @@ -252,7 +286,9 @@ export class ZkWasmServiceHelper { data ); - console.log("get modifyImage response:", response.toString()); + if (this.endpoint.enable_logs) { + console.log("get modifyImage response:", response.toString()); + } return response; }