UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

351 lines (350 loc) 9.24 kB
import type { Transaction } from "../../transactions/index.js"; import { ObjectType } from "../common.js"; import type { GuardObject, GuardAddress, ObjectResult, SupportedValue, WitnessType, NamedObject, CallEnv, PassportObject, ValueTypeInput } from "../common.js"; import type { CallResult } from "./base.js"; import { CallBase } from "./base.js"; import type { SubmissionCall } from "./passport.js"; import type { ENTRYPOINT } from "../../client/network.js"; export declare function guardFn(name: string): string; export type GuardNode = { type: "identifier"; identifier: number; } | { type: "query"; query: string | number; object: { identifier: number; convert_witness?: WitnessType; }; parameters: GuardNode[]; } | { type: "logic_as_u256_greater_or_equal"; nodes: GuardNode[]; } | { type: "logic_as_u256_lesser_or_equal"; nodes: GuardNode[]; } | { type: "logic_as_u256_greater"; nodes: GuardNode[]; } | { type: "logic_as_u256_lesser"; nodes: GuardNode[]; } | { type: "logic_as_u256_equal"; nodes: GuardNode[]; } | { type: "logic_equal"; nodes: GuardNode[]; } | { type: "logic_not"; node: GuardNode; } | { type: "logic_and"; nodes: GuardNode[]; } | { type: "logic_or"; nodes: GuardNode[]; } | { type: "logic_string_contains"; nodes: GuardNode[]; } | { type: "logic_string_nocase_contains"; nodes: GuardNode[]; } | { type: "logic_string_nocase_equal"; nodes: GuardNode[]; } | { type: "calc_number_add"; nodes: GuardNode[]; } | { type: "calc_number_multiply"; nodes: GuardNode[]; } | { type: "calc_number_subtract"; nodes: GuardNode[]; } | { type: "calc_number_divide"; nodes: GuardNode[]; } | { type: "calc_number_mod"; nodes: GuardNode[]; } | { type: "calc_string_length"; node: GuardNode; } | { type: "calc_string_nocase_contains"; nodes: GuardNode[]; } | { type: "calc_string_nocase_equal"; nodes: GuardNode[]; } | { type: "calc_string_contains"; nodes: GuardNode[]; } | { type: "calc_string_indexof"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "calc_string_nocase_indexof"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "convert_number_address"; node: GuardNode; } | { type: "convert_address_number"; node: GuardNode; } | { type: "convert_number_string"; node: GuardNode; } | { type: "convert_string_number"; node: GuardNode; } | { type: "convert_safe_u8"; node: GuardNode; } | { type: "convert_safe_u16"; node: GuardNode; } | { type: "convert_safe_u32"; node: GuardNode; } | { type: "convert_safe_u64"; node: GuardNode; } | { type: "convert_safe_u128"; node: GuardNode; } | { type: "convert_safe_u256"; node: GuardNode; } | { type: "value_type"; node: GuardNode; } | { type: "vec_length"; node: GuardNode; } | { type: "vec_contains_bool"; nodes: GuardNode[]; } | { type: "vec_contains_address"; nodes: GuardNode[]; } | { type: "vec_contains_string"; nodes: GuardNode[]; } | { type: "vec_contains_string_nocase"; nodes: GuardNode[]; } | { type: "vec_contains_number"; nodes: GuardNode[]; } | { type: "vec_indexof_bool"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "vec_indexof_address"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "vec_indexof_string"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "vec_indexof_string_nocase"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "vec_indexof_number"; nodeLeft: GuardNode; nodeRight: GuardNode; order: "forward" | "backward"; } | { type: "context"; context: "Clock" | "Guard" | "Signer"; } | { type: "query_reward_record_find"; object: { identifier: number; }; find: "first" | "last"; recipient: GuardNode; where: { guard?: string; timeMin?: string; timeMax?: string; amountMin?: string; amountMax?: string; storeFromId?: "exists" | "not_exists" | { eq: string; }; }; conditionsIdentifier?: number; } | { type: "query_reward_record_count"; object: { identifier: number; }; recipient: GuardNode; where: { guard?: string; timeMin?: string; timeMax?: string; amountMin?: string; amountMax?: string; storeFromId?: "exists" | "not_exists" | { eq: string; }; }; conditionsIdentifier?: number; } | { type: "query_reward_record_exists"; object: { identifier: number; }; recipient: GuardNode; where: { guard?: string; timeMin?: string; timeMax?: string; amountMin?: string; amountMax?: string; storeFromId?: "exists" | "not_exists" | { eq: string; }; }; conditionsIdentifier?: number; } | { type: "query_progress_history_find"; object: { identifier: number; }; where: { node?: string; nextNode?: string; timeMin?: string; timeMax?: string; indexMin?: string; indexMax?: string; }; find: "first" | "last"; conditionsIdentifier?: number; } | { type: "query_progress_history_session_find"; object: { identifier: number; }; historyIdx: GuardNode; where: { nextNode?: string; }; find: "first" | "last"; } | { type: "query_progress_history_session_forward_find"; object: { identifier: number; }; historyIdx: GuardNode; sessionIdx: GuardNode; where: { who?: string; operation?: string; accomplished?: boolean; timeMin?: string; timeMax?: string; }; find: "first" | "last"; } | { type: "query_progress_history_session_count"; object: { identifier: number; }; historyIdx: GuardNode; } | { type: "query_progress_history_session_forward_count"; object: { identifier: number; }; historyIdx: GuardNode; sessionIdx: GuardNode; } | { type: "query_progress_history_session_forward_retained_submission_count"; object: { identifier: number; }; historyIdx: GuardNode; sessionIdx: GuardNode; forwardIdx: GuardNode; }; export interface CallGuard_Data { namedNew?: NamedObject; description?: string; table: GuardTableItemBase[]; root: GuardNode; rely?: { guards: string[]; logic_or?: boolean; }; } export declare class CallGuard extends CallBase { data: CallGuard_Data; constructor(data: CallGuard_Data); call(env: CallEnv): Promise<CallResult>; operate(env: CallEnv, tx: Transaction, _passport?: PassportObject, _submission?: GuardSubmissionToFill[]): Promise<void>; } export interface GuardTableItemBase { identifier: number; b_submission: boolean; value_type: ValueTypeInput; value: SupportedValue | undefined; name: string; } export interface GuardTableItem extends GuardTableItemBase { object_type?: ObjectType; } export interface GuardSubmissionToFill { guard: string; submission: GuardTableItem[]; } export declare const newGuard: (tx: Transaction, description: string, table: GuardTableItem[], root: GuardNode) => Promise<ObjectResult>; export declare function create(tx: Transaction, guard: GuardObject): GuardAddress; export declare function reliesAdd(tx: Transaction, guard: GuardObject, rely_guards: string[]): void; export declare function reliesRemove(tx: Transaction, guard: GuardObject, rely_guards: string[]): void; export declare function reliesClear(tx: Transaction, guard: GuardObject): void; export declare function reliesLogic(tx: Transaction, guard: GuardObject, logic_and: boolean): void; export declare const guard2file: (guard: string, file_path: string, format?: "json" | "markdown", network?: ENTRYPOINT) => Promise<void>; export declare const generateNodeComments: (node: GuardNode, comments?: Array<{ type: string; description: string; }>) => Array<{ type: string; description: string; }>; export declare const gen_passport: (env: CallEnv, guard: string, info?: SubmissionCall) => Promise<CallResult>; export interface GuardParseError { message: string; path: string; line?: number; column?: number; } export interface GuardParseResult { success: boolean; data?: Partial<CallGuard_Data> & { root: GuardNode; }; errors: GuardParseError[]; } export declare function parseGuardFromMarkdown(content: string): GuardParseResult; export declare function parseGuardFile(content: string, format?: "json" | "markdown"): GuardParseResult; export declare function validateGuardNode(node: unknown): { success: boolean; errors: GuardParseError[]; }; export declare function formatGuardParseErrors(errors: GuardParseError[]): string;