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
3 changes: 2 additions & 1 deletion dist/cjs/helper/task.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, WithSignature, UserQueryParams, PaymentParams, TxHistoryQueryParams, LogQuery, ResetImageParams, PaginationResult, Task, Image, TransactionInfo, AppConfig, OmitSignature, ModifyImageParams, SubscriptionRequest, ERC20DepositInfo, User, Subscription, PaginatedQuery, Round1BatchProofQuery, Round2BatchProofQuery, Round2BatchProof, Round1BatchProof, FinalBatchProofQuery, FinalBatchProof } from "../interface/interface.js";
import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, WithSignature, UserQueryParams, PaymentParams, TxHistoryQueryParams, LogQuery, ResetImageParams, PaginationResult, Task, Image, TransactionInfo, AppConfig, OmitSignature, ModifyImageParams, SubscriptionRequest, ERC20DepositInfo, User, Subscription, PaginatedQuery, Round1BatchProofQuery, Round2BatchProofQuery, Round2BatchProof, Round1BatchProof, FinalBatchProofQuery, FinalBatchProof, ConciseTask } from "../interface/interface.js";
import { ZkWasmServiceEndpoint } from "./endpoint.js";
export declare class ZkWasmServiceHelper {
endpoint: ZkWasmServiceEndpoint;
Expand All @@ -12,6 +12,7 @@ export declare class ZkWasmServiceHelper {
queryConfig(): Promise<AppConfig>;
loadStatistics(): Promise<Statistics>;
loadTasks(query: QueryParams): Promise<PaginationResult<Task[]>>;
loadTaskList(query: QueryParams): Promise<PaginationResult<ConciseTask[]>>;
queryRound1BatchProofs(query: PaginatedQuery<Round1BatchProofQuery>): Promise<PaginationResult<Round1BatchProof[]>>;
queryRound2BatchProofs(query: PaginatedQuery<Round2BatchProofQuery>): Promise<PaginationResult<Round2BatchProof[]>>;
queryFinalBatchProofs(query: PaginatedQuery<FinalBatchProofQuery>): Promise<PaginationResult<FinalBatchProof[]>>;
Expand Down
46 changes: 46 additions & 0 deletions dist/cjs/helper/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,52 @@ class ZkWasmServiceHelper {
return tasks;
});
}
loadTaskList(query) {
return __awaiter(this, void 0, void 0, function* () {
let headers = { "Content-Type": "application/json" };
let queryJson = JSON.parse("{}");
// Validate query params
if (query.start != null && query.start < 0) {
throw new Error("start must be positive");
}
if (query.total != null && query.total <= 0) {
throw new Error("total must be positive");
}
if (query.id != null && query.id != "") {
// Validate it is a hex string (mongodb objectid)
if (!util_js_1.ZkWasmUtil.isHexString(query.id)) {
throw new Error("id must be a hex string or ");
}
}
if (query.user_address != null && query.user_address != "") {
// Validate it is a hex string (ethereum address)
if (!ethers_1.ethers.isAddress(query.user_address)) {
throw new Error("user_address must be a valid ethereum address");
}
}
if (query.md5 != null && query.md5 != "") {
// Validate it is a hex string (md5)
if (!util_js_1.ZkWasmUtil.isHexString(query.md5)) {
throw new Error("md5 must be a hex string");
}
}
//build query JSON
let objKeys = Object.keys(query);
objKeys.forEach((key) => {
if (query[key] != "" && query[key] != null)
queryJson[key] = query[key];
});
if (this.endpoint.enable_logs) {
console.log("params:", query);
console.log("json", queryJson);
}
let tasks = yield this.endpoint.invokeRequest("GET", `/tasklist`, queryJson);
if (this.endpoint.enable_logs) {
console.log("loading task board!");
}
return tasks;
});
}
queryRound1BatchProofs(query) {
return __awaiter(this, void 0, void 0, function* () {
let proofData = yield this.endpoint.invokeRequest("GET", TaskEndpoint.ROUND_1_BATCH, JSON.parse(JSON.stringify(query)));
Expand Down
4 changes: 2 additions & 2 deletions dist/cjs/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Task, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, WithSignature, User, UserQueryParams, PaymentParams, SubscriptionParams, Subscription, SubscriptionType, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, TaskStatus, TaskType, AppConfig, PaginationResult, ResetImageParams, LogQuery, ModifyImageParams, ChainDetails, InputContextType, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofStatus, Round2BatchProofStatus, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, AutoSubmitStatus, VerifyBatchProofParams, FinalProofStatus, AutoSubmitBatchMetadata, ProofSubmitMode, ProvePaymentSrc } from "./interface/interface.js";
import { Task, ConciseTask, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, WithSignature, User, UserQueryParams, PaymentParams, SubscriptionParams, Subscription, SubscriptionType, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, TaskStatus, TaskType, AppConfig, PaginationResult, ResetImageParams, LogQuery, ModifyImageParams, ChainDetails, InputContextType, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofStatus, Round2BatchProofStatus, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, AutoSubmitStatus, VerifyBatchProofParams, FinalProofStatus, AutoSubmitBatchMetadata, ProofSubmitMode, ProvePaymentSrc } from "./interface/interface.js";
import { ZkWasmUtil } from "./helper/util.js";
import { ZkWasmServiceEndpoint } from "./helper/endpoint.js";
import { ZkWasmServiceHelper } from "./helper/task.js";
export { ZkWasmServiceEndpoint, ZkWasmServiceHelper, ZkWasmUtil, InputContextType, AutoSubmitStatus, Round1BatchProofStatus, Round2BatchProofStatus, FinalProofStatus, ProofSubmitMode, ProvePaymentSrc, };
export type { Task, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, TaskStatus, TaskType, WithSignature, User, UserQueryParams, Subscription, SubscriptionType, PaymentParams, SubscriptionParams, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, ResetImageParams, AppConfig, PaginationResult, LogQuery, ModifyImageParams, ChainDetails, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, VerifyBatchProofParams, AutoSubmitBatchMetadata, };
export type { Task, ConciseTask, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, TaskStatus, TaskType, WithSignature, User, UserQueryParams, Subscription, SubscriptionType, PaymentParams, SubscriptionParams, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, ResetImageParams, AppConfig, PaginationResult, LogQuery, ModifyImageParams, ChainDetails, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, VerifyBatchProofParams, AutoSubmitBatchMetadata, };
12 changes: 12 additions & 0 deletions dist/cjs/interface/interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export interface Task {
batch_proof_data?: BatchProofData;
auto_submit_status?: AutoSubmitStatus;
}
export interface ConciseTask {
_id: any;
user_address: string;
md5: string;
task_type: string;
status: TaskStatus;
submit_time: string;
process_started?: string;
process_finished?: string;
proof_submit_mode?: ProofSubmitMode;
auto_submit_status?: AutoSubmitStatus;
}
export interface AutoSubmitBatchMetadata {
chain_id: number;
id: string;
Expand Down
3 changes: 2 additions & 1 deletion dist/mjs/helper/task.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, WithSignature, UserQueryParams, PaymentParams, TxHistoryQueryParams, LogQuery, ResetImageParams, PaginationResult, Task, Image, TransactionInfo, AppConfig, OmitSignature, ModifyImageParams, SubscriptionRequest, ERC20DepositInfo, User, Subscription, PaginatedQuery, Round1BatchProofQuery, Round2BatchProofQuery, Round2BatchProof, Round1BatchProof, FinalBatchProofQuery, FinalBatchProof } from "../interface/interface.js";
import { QueryParams, ProvingParams, DeployParams, Statistics, AddImageParams, WithSignature, UserQueryParams, PaymentParams, TxHistoryQueryParams, LogQuery, ResetImageParams, PaginationResult, Task, Image, TransactionInfo, AppConfig, OmitSignature, ModifyImageParams, SubscriptionRequest, ERC20DepositInfo, User, Subscription, PaginatedQuery, Round1BatchProofQuery, Round2BatchProofQuery, Round2BatchProof, Round1BatchProof, FinalBatchProofQuery, FinalBatchProof, ConciseTask } from "../interface/interface.js";
import { ZkWasmServiceEndpoint } from "./endpoint.js";
export declare class ZkWasmServiceHelper {
endpoint: ZkWasmServiceEndpoint;
Expand All @@ -12,6 +12,7 @@ export declare class ZkWasmServiceHelper {
queryConfig(): Promise<AppConfig>;
loadStatistics(): Promise<Statistics>;
loadTasks(query: QueryParams): Promise<PaginationResult<Task[]>>;
loadTaskList(query: QueryParams): Promise<PaginationResult<ConciseTask[]>>;
queryRound1BatchProofs(query: PaginatedQuery<Round1BatchProofQuery>): Promise<PaginationResult<Round1BatchProof[]>>;
queryRound2BatchProofs(query: PaginatedQuery<Round2BatchProofQuery>): Promise<PaginationResult<Round2BatchProof[]>>;
queryFinalBatchProofs(query: PaginatedQuery<FinalBatchProofQuery>): Promise<PaginationResult<FinalBatchProof[]>>;
Expand Down
44 changes: 44 additions & 0 deletions dist/mjs/helper/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,50 @@ export class ZkWasmServiceHelper {
}
return tasks;
}
async loadTaskList(query) {
let headers = { "Content-Type": "application/json" };
let queryJson = JSON.parse("{}");
// Validate query params
if (query.start != null && query.start < 0) {
throw new Error("start must be positive");
}
if (query.total != null && query.total <= 0) {
throw new Error("total must be positive");
}
if (query.id != null && query.id != "") {
// Validate it is a hex string (mongodb objectid)
if (!ZkWasmUtil.isHexString(query.id)) {
throw new Error("id must be a hex string or ");
}
}
if (query.user_address != null && query.user_address != "") {
// Validate it is a hex string (ethereum address)
if (!ethers.isAddress(query.user_address)) {
throw new Error("user_address must be a valid ethereum address");
}
}
if (query.md5 != null && query.md5 != "") {
// Validate it is a hex string (md5)
if (!ZkWasmUtil.isHexString(query.md5)) {
throw new Error("md5 must be a hex string");
}
}
//build query JSON
let objKeys = Object.keys(query);
objKeys.forEach((key) => {
if (query[key] != "" && query[key] != null)
queryJson[key] = query[key];
});
if (this.endpoint.enable_logs) {
console.log("params:", query);
console.log("json", queryJson);
}
let tasks = await this.endpoint.invokeRequest("GET", `/tasklist`, queryJson);
if (this.endpoint.enable_logs) {
console.log("loading task board!");
}
return tasks;
}
async queryRound1BatchProofs(query) {
let proofData = await this.endpoint.invokeRequest("GET", TaskEndpoint.ROUND_1_BATCH, JSON.parse(JSON.stringify(query)));
if (this.endpoint.enable_logs) {
Expand Down
4 changes: 2 additions & 2 deletions dist/mjs/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Task, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, WithSignature, User, UserQueryParams, PaymentParams, SubscriptionParams, Subscription, SubscriptionType, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, TaskStatus, TaskType, AppConfig, PaginationResult, ResetImageParams, LogQuery, ModifyImageParams, ChainDetails, InputContextType, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofStatus, Round2BatchProofStatus, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, AutoSubmitStatus, VerifyBatchProofParams, FinalProofStatus, AutoSubmitBatchMetadata, ProofSubmitMode, ProvePaymentSrc } from "./interface/interface.js";
import { Task, ConciseTask, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, WithSignature, User, UserQueryParams, PaymentParams, SubscriptionParams, Subscription, SubscriptionType, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, TaskStatus, TaskType, AppConfig, PaginationResult, ResetImageParams, LogQuery, ModifyImageParams, ChainDetails, InputContextType, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofStatus, Round2BatchProofStatus, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, AutoSubmitStatus, VerifyBatchProofParams, FinalProofStatus, AutoSubmitBatchMetadata, ProofSubmitMode, ProvePaymentSrc } from "./interface/interface.js";
import { ZkWasmUtil } from "./helper/util.js";
import { ZkWasmServiceEndpoint } from "./helper/endpoint.js";
import { ZkWasmServiceHelper } from "./helper/task.js";
export { ZkWasmServiceEndpoint, ZkWasmServiceHelper, ZkWasmUtil, InputContextType, AutoSubmitStatus, Round1BatchProofStatus, Round2BatchProofStatus, FinalProofStatus, ProofSubmitMode, ProvePaymentSrc, };
export type { Task, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, TaskStatus, TaskType, WithSignature, User, UserQueryParams, Subscription, SubscriptionType, PaymentParams, SubscriptionParams, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, ResetImageParams, AppConfig, PaginationResult, LogQuery, ModifyImageParams, ChainDetails, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, VerifyBatchProofParams, AutoSubmitBatchMetadata, };
export type { Task, ConciseTask, ProvingParams, DeployParams, QueryParams, VerifyProofParams, VerifyData, StatusState, DeploymentInfo, Image, Statistics, AddImageParams, TaskStatus, TaskType, WithSignature, User, UserQueryParams, Subscription, SubscriptionType, PaymentParams, SubscriptionParams, SubscriptionRequest, TxHistoryQueryParams, TransactionInfo, ResetImageParams, AppConfig, PaginationResult, LogQuery, ModifyImageParams, ChainDetails, ContextHexString, WithCustomInputContextType, WithInitialContext, WithNonCustomInputContextType, WithResetContext, WithoutInitialContext, WithoutInputContextType, WithoutResetContext, Round1BatchProof, Round2BatchProof, FinalBatchProof, Round1BatchProofQuery, Round2BatchProofQuery, FinalBatchProofQuery, PaginatedQuery, PaginationQuery, VerifyBatchProofParams, AutoSubmitBatchMetadata, };
12 changes: 12 additions & 0 deletions dist/mjs/interface/interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export interface Task {
batch_proof_data?: BatchProofData;
auto_submit_status?: AutoSubmitStatus;
}
export interface ConciseTask {
_id: any;
user_address: string;
md5: string;
task_type: string;
status: TaskStatus;
submit_time: string;
process_started?: string;
process_finished?: string;
proof_submit_mode?: ProofSubmitMode;
auto_submit_status?: AutoSubmitStatus;
}
export interface AutoSubmitBatchMetadata {
chain_id: number;
id: string;
Expand Down
58 changes: 58 additions & 0 deletions src/helper/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
Round1BatchProof,
FinalBatchProofQuery,
FinalBatchProof,
ConciseTask,
} from "../interface/interface.js";
import { ZkWasmServiceEndpoint } from "./endpoint.js";
import { ethers } from "ethers";
Expand Down Expand Up @@ -207,6 +208,63 @@ export class ZkWasmServiceHelper {
return tasks;
}

async loadTaskList(
query: QueryParams
): Promise<PaginationResult<ConciseTask[]>> {
let headers = { "Content-Type": "application/json" };
let queryJson = JSON.parse("{}");

// Validate query params
if (query.start != null && query.start < 0) {
throw new Error("start must be positive");
}
if (query.total != null && query.total <= 0) {
throw new Error("total must be positive");
}

if (query.id != null && query.id != "") {
// Validate it is a hex string (mongodb objectid)
if (!ZkWasmUtil.isHexString(query.id)) {
throw new Error("id must be a hex string or ");
}
}

if (query.user_address != null && query.user_address != "") {
// Validate it is a hex string (ethereum address)
if (!ethers.isAddress(query.user_address)) {
throw new Error("user_address must be a valid ethereum address");
}
}

if (query.md5 != null && query.md5 != "") {
// Validate it is a hex string (md5)
if (!ZkWasmUtil.isHexString(query.md5)) {
throw new Error("md5 must be a hex string");
}
}

//build query JSON
let objKeys = Object.keys(query) as Array<keyof QueryParams>;
objKeys.forEach((key) => {
if (query[key] != "" && query[key] != null) queryJson[key] = query[key];
});

if (this.endpoint.enable_logs) {
console.log("params:", query);
console.log("json", queryJson);
}

let tasks = await this.endpoint.invokeRequest(
"GET",
`/tasklist`,
queryJson
);
if (this.endpoint.enable_logs) {
console.log("loading task board!");
}
return tasks;
}

async queryRound1BatchProofs(
query: PaginatedQuery<Round1BatchProofQuery>
): Promise<PaginationResult<Round1BatchProof[]>> {
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Task,
ConciseTask,
ProvingParams,
DeployParams,
QueryParams,
Expand Down Expand Up @@ -74,6 +75,7 @@ export {

export type {
Task,
ConciseTask,
ProvingParams,
DeployParams,
QueryParams,
Expand Down
13 changes: 13 additions & 0 deletions src/interface/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ export interface Task {
auto_submit_status?: AutoSubmitStatus;
}

export interface ConciseTask {
_id: any;
user_address: string;
md5: string;
task_type: string;
status: TaskStatus;
submit_time: string;
process_started?: string;
process_finished?: string;
proof_submit_mode?: ProofSubmitMode;
auto_submit_status?: AutoSubmitStatus;
}

export interface AutoSubmitBatchMetadata {
chain_id: number;
id: string;
Expand Down