wowok
Version:
Wowok Blockchain TypeScript API
627 lines (626 loc) • 18.5 kB
TypeScript
import type { ENTRYPOINT } from "../../client/network.js";
import type { ObjectOwner } from "../../jsonRpc/types/index.js";
import type { CacheExpireType } from "../local/cache.js";
import type { GuardNode, GuardTableItem } from "../call/guard.js";
import type { AccountOrMark_Address } from "../local/index.js";
import type { RecordsInEntity, VoteInRegistrar } from "../call/entity.js";
import type { BalanceType, Recipient, SupportedValue, ValueTypeInput } from "../common.js";
import { WitnessType, ObjectType } from "../common.js";
import type { PermissionIndexType } from "../call/permission.js";
export { ObjectType };
export declare const MAX_OBJECTS_PER_QUERY = 50;
export declare const WitnessSourceType: (type: WitnessType) => ObjectType;
export declare const WitnessTargetType: (type: WitnessType) => ObjectType;
export interface ObjectTypeDefinition {
name: ObjectType;
moveValue: number;
moveName: string;
}
export declare const OBJECT_TYPE_DEFINITIONS: Record<ObjectType, ObjectTypeDefinition>;
export declare const objectTypeToNumber: Record<ObjectType, number>;
export declare const numberToObjectType: Record<number, ObjectType>;
export declare function getObjectTypeFromNumber(value: number): ObjectType | undefined;
export declare function getNumberFromObjectType(objectType: ObjectType): number | undefined;
export declare function getObjectTypeDefinition(objectType: ObjectType): ObjectTypeDefinition | undefined;
export declare function getObjectTypeDefinitionFromNumber(value: number): ObjectTypeDefinition | undefined;
export declare function getObjectTypeFromMoveName(moveName: string): ObjectType | undefined;
export declare function getMoveNameFromObjectType(objectType: ObjectType): string | undefined;
export declare function getMoveNameFromNumber(value: number): string | undefined;
export declare function getNumberFromMoveName(moveName: string): number | undefined;
export declare function getObjectTypesFromNumbers(values: number[]): (ObjectType | undefined)[];
export declare function getNumbersFromObjectTypes(objectTypes: ObjectType[]): (number | undefined)[];
export interface ObjectBase {
object: string;
type?: ObjectType;
type_raw?: string;
owner?: ObjectOwner | null;
version?: string;
previousTransaction?: string;
cache_expire?: CacheExpireType;
query_name?: string;
content_raw?: any;
}
export interface Im {
at: string;
status: string;
join_time: number;
description: string;
}
export interface ObjectContact extends ObjectBase {
description: string;
permission: string;
location: string;
ims: Im[];
}
export interface ObjectEntityRegistrar extends ObjectBase {
entity_count: number;
}
export interface ObjectEntityLinker extends ObjectBase {
entity_count: number;
}
export interface ObjectResource extends ObjectBase {
entity_count: number;
}
export interface ObjectEntity extends ObjectBase {
entity_count: number;
}
export interface TableItem_EntityLinker extends ObjectBase {
address: string;
pos: number;
count: number;
votes: VoteInRegistrar[];
}
export interface TableItem_EntityRegistrar extends ObjectBase {
address: string;
description: string;
time: number;
referrer: string | null;
mark_object: string | null;
records: RecordsInEntity[];
}
export interface TableItem_AddressMark extends ObjectBase {
entity: string;
name: string;
tags: string[];
}
export interface ServiceGuard {
guard: string;
service_identifier?: number | null;
}
export interface ObjectDemand extends ObjectBase {
description: string;
location: string;
rewards: string[];
guards: ServiceGuard[];
presenters_count: number;
um: string | null;
permission: string;
}
export interface ObjectMachine extends ObjectBase {
description: string;
node_count: number;
consensus_repositories: string[];
bPaused: boolean;
bPublished: boolean;
um: string | null;
permission: string;
}
export interface ServiceSale {
name: string;
price: BalanceType;
stock: BalanceType;
suspension: boolean;
wip: string;
wip_hash: string;
}
export interface PurchasedItem {
name: string;
price: BalanceType;
quantity: BalanceType;
wip_hash: string;
}
export interface ObjectOrder extends ObjectBase {
items: PurchasedItem[];
discount: string | null;
progress: string | null;
machine: string | null;
amount: BalanceType;
builder: string;
service: string;
dispute: string[];
agent: string[];
allocation: string | null;
claimed_by: string | null;
required_info: string | null;
time: string | number;
}
export interface NamedOperator {
name: string;
operators: string[];
}
export interface ProgressSession {
next_node: string;
forwards: ProgressSessionHolder[];
weights: number;
threshold: number;
}
export interface ProgressSessionHolder {
forward: string;
who: string | null;
retained_submission: GuardSubmission[];
msg: string;
accomplished: boolean;
time: number;
}
export interface ObjectProgress extends ObjectBase {
machine: string;
context_repositories: string[];
current: string;
task: string | null;
namedOperator: NamedOperator[];
session: ProgressSession[];
history_count: number;
current_time: number;
}
export declare enum AmountType {
GuardU64Identifier = 0,
Fixed = 1
}
export type Amount = {
type: AmountType.GuardU64Identifier;
value: number;
} | {
type: AmountType.Fixed;
value: BalanceType;
};
export interface RewardGuard {
guard: string;
recipient: Recipient;
amount: Amount;
expiration_time?: number;
store_from_id?: number | null;
}
export interface ObjectReward extends ObjectBase {
description: string;
guards: RewardGuard[];
balance: BalanceType;
guard_not_added_expiration_time: string | number | null;
record_count: number;
um: string | null;
permission: string;
}
export interface ObjectService extends ObjectBase {
description: string;
location: string;
sales: ServiceSale[];
repositories: string[];
buy_guard: string | null;
machine: string | null;
bPublished: boolean;
bPaused: boolean;
customer_required: string[];
arbitrations: string[];
compensation_fund: BalanceType;
paused_time: number | null;
compensation_lock_duration: string | number | bigint;
order_allocators: Allocators | null;
rewards: string[];
um: string | null;
permission: string;
}
export interface ArbVoted {
voter: string;
agrees: number[];
weight: number;
time: number;
}
export interface ArbProposition {
name: string;
votes: number;
}
export interface ArbIndemnity {
amount: BalanceType;
time: number;
}
export declare enum ArbStatus {
Principal_confirming = 0,
Arbitrator_confirming = 1,
Voting = 2,
Arbitrated = 3,
Objectionable = 4,
Finished = 5,
Withdrawn = 6
}
export interface ObjectArb extends ObjectBase {
description: string;
arbitration: string;
order: string;
voted: ArbVoted[];
proposition: ArbProposition[];
fee: BalanceType;
feedback: string;
indemnity?: ArbIndemnity | null;
voting_deadline?: number | string | bigint;
objection: string;
status: ArbStatus;
compensation_time: number | null;
time: number;
}
export declare enum DiscountType {
RATES = 0,
FIXED = 1
}
export interface ObjectDiscount extends ObjectBase {
name: string;
discount_type: DiscountType;
benchmark: BalanceType | null;
off: BalanceType;
time_start: string | number;
time_end: string | number;
service: string;
transferable: boolean;
}
export interface AmountFromDepositGuard {
guard: string;
identifier?: number | null;
store_from_id?: number | null;
}
export interface AmountFromWithdrawGuard {
guard: string;
identifier: number;
store_from_id?: number | null;
}
export interface ObjectProof extends ObjectBase {
description: string;
proof: string;
server_pubkey: string;
server_signature: string;
proof_type: number;
item_count: number | null;
about_address: string | null;
signer: string;
time: number;
}
export interface ObjectTreasury extends ObjectBase {
description: string;
balance: BalanceType;
history_count: number;
external_deposit_guard: AmountFromDepositGuard[];
external_withdraw_guard: AmountFromWithdrawGuard[];
inflow: BalanceType;
outflow: BalanceType;
um: string | null;
permission: string;
}
export declare enum TreasuryOp {
Withdraw = 0,
Deposit = 1,
Receive = 2
}
export interface TreasuryRecord {
op: TreasuryOp;
signer: string;
external_guard: string | null;
amount: BalanceType;
time: number | string | bigint;
store_from_id?: string | null;
}
export interface WReceivedObject extends ObjectBase {
balance: BalanceType;
payment: string;
}
export interface PolicyWriteGuard {
guard: string;
id_from_submission?: number;
data_from_submission?: number;
}
export declare enum IdFrom {
None = 0,
Clock = 1,
Signer = 2
}
export type IdFromInput = IdFrom | string;
export declare const parseIdFrom: (input: IdFromInput) => IdFrom;
export declare const idFromToString: (type: IdFrom) => string;
export declare const isValidIdFromInput: (input: unknown) => input is IdFromInput;
export interface PolicyRule {
name: string;
description: string;
write_guard: PolicyWriteGuard[];
quote_guard?: string | null;
id_from: IdFromInput;
value_type: ValueTypeInput;
}
export interface TableItem_RepositoryData extends ObjectBase {
entity: string;
name: string;
value: Uint8Array;
data: {
value_type: ValueTypeInput;
value: SupportedValue;
};
}
export interface TableItem_RewardRecord extends ObjectBase {
recipient: string;
guard: string;
total: BalanceType;
record: {
amount: BalanceType;
time: number;
store_from_id?: string | null;
}[];
}
export interface ObjectRepository extends ObjectBase {
description: string;
policies: PolicyRule[];
data_count: number;
rewards: string[];
um: string | null;
permission: string;
}
export interface ObjectPersonal extends ObjectBase {
address: string;
like: number;
dislike: number;
info: RecordsInEntity[];
description: string;
referrer: string | null;
mark_object: string | null;
details: VoteInRegistrar[];
active_tx: string | null;
passive_tx: string | null;
time: number;
}
export interface ObjectPermission extends ObjectBase {
builder: string;
admin: string[];
description: string;
entity_count: number;
perm_remark: {
index: PermissionIndexType;
remark: string;
}[];
um: string | null;
}
export interface ObjectGuard extends ObjectBase {
description: string;
table: GuardTableItem[];
input: Uint8Array;
root: GuardNode;
rep_quote: Map<string, string[]>;
relies: string[];
relies_logic_and: boolean;
rep: boolean;
}
export declare enum AllocationMode {
Amount = 0,
Rate = 1,
Surplus = 2
}
export interface AllocationSharing {
who: Recipient;
sharing: BalanceType;
mode: AllocationMode;
}
export interface Allocator {
guard: string;
sharing: AllocationSharing[];
fix?: BalanceType;
max?: BalanceType | null;
}
export interface Allocators {
description: string;
threshold: BalanceType;
allocators: Allocator[];
}
export interface PaymentInfo {
for_object?: string | null;
for_guard?: string | null;
remark: string;
index: number | bigint | string;
}
export interface ObjectPayment extends ObjectBase {
record: {
recipient: Recipient;
amount: BalanceType;
}[];
amount: BalanceType;
time: string;
from_object?: string | null;
signer: string;
info: PaymentInfo;
}
export interface ObjectAllocation extends ObjectBase {
description: string;
allocators: Allocator[];
balance: BalanceType;
payment_info?: PaymentInfo;
payment: string[];
}
export type VoteWeight = {
GuardIdentifier: number;
} | {
FixedValue: number;
};
export interface VotingGuard {
guard: string;
vote_weight: VoteWeight;
}
export interface ObjectArbitration extends ObjectBase {
description: string;
location: string;
voting_guard: VotingGuard[];
usage_guard?: string | null;
fee: BalanceType;
balance: BalanceType;
bPaused: boolean;
um: string | null;
permission: string;
}
export interface GuardSubmission {
identifier: number;
value_type: ValueTypeInput;
value: SupportedValue;
}
export interface GuardInPassport {
guard: string;
result: boolean;
impack: boolean;
relies: string[];
relies_logic_and: boolean;
submission: GuardSubmission;
}
export interface ObjectPassport extends ObjectBase {
info: GuardInPassport[];
result: boolean;
tx_hash: string;
impack_guard: string[];
time: number;
signer: string;
has_verified: boolean;
}
export interface TableItem_PermissionPerm extends ObjectBase {
address: string;
perm: number[];
}
export interface TableItem_DemandPresenter extends ObjectBase {
address: string;
recommend: string;
service: string | null;
update_time: number;
acceptance_score: number | null;
feedback: string;
feedback_time: number;
}
export interface MachineForwardGuard {
guard: string;
retained_submission?: number[];
}
export interface MachineForward {
name: string;
namedOperator?: string;
permissionIndex?: number;
weight: number;
guard?: MachineForwardGuard;
}
export interface MachineNodePair {
prev_node: string;
threshold: number;
forwards: MachineForward[];
}
export interface MachineNode {
name: string;
pairs: MachineNodePair[];
}
export interface TableItem_MachineNode extends ObjectBase {
name: string;
value: MachineNodePair[];
}
export interface TableItem_ProgressHistory extends ObjectBase {
index: number;
node: string;
next_node: string;
session: ProgressSession[];
time: number;
}
export interface TableItem_TreasuryHistory extends ObjectBase {
payment: string;
op: TreasuryOp;
signer: string;
external_guard: string | null;
amount: BalanceType;
time: number;
store_from_id?: string | null;
}
export interface ObjectsQuery {
objects: string[];
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface ObjectsAnswer {
objects?: ObjectBase[];
}
export interface PersonalQuery {
account?: string;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface TableQuery {
parent: string;
cursor?: string | null | undefined;
limit?: number | null | undefined;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface TableAnswer {
items: TableAnswerItem[];
nextCursor: string | null;
hasNextPage: boolean;
cache_expire?: CacheExpireType;
}
export interface TableItemQuery {
parent: string;
key: {
type: string;
value: unknown;
};
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface TableAnswerItem {
key: {
type: string;
value: unknown;
};
type: string;
object: string;
version: string;
}
export declare const query_objects_json: (json: string) => Promise<string>;
export declare const query_table_json: (json: string) => Promise<string>;
export declare const query_objects: (query: ObjectsQuery) => Promise<ObjectsAnswer>;
export declare const query_personal: (query: PersonalQuery) => Promise<ObjectPersonal | undefined>;
export declare const query_table: (query: TableQuery) => Promise<TableAnswer | undefined>;
export declare const query_tableItem: (query: TableItemQuery) => Promise<ObjectBase | undefined>;
export interface QueryTableItem_byAddress {
parent: string | ObjectPermission | ObjectDemand | ObjectEntityRegistrar | ObjectResource | ObjectReward | ObjectTreasury | ObjectEntityLinker;
address: AccountOrMark_Address | string;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface QueryTableItem_byU64 {
parent: string | ObjectProgress;
u64: number | string | bigint;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface QueryTableItem_byString {
parent: string | ObjectMachine;
key: string;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface QueryTableItem_byNameAddress {
parent: string | ObjectMachine;
name: string;
entity: AccountOrMark_Address | bigint | number;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export interface QueryTableItem_Entity {
address: AccountOrMark_Address | string;
no_cache?: boolean;
network?: ENTRYPOINT;
}
export declare const queryTableItem_RepositoryData: (query: QueryTableItem_byNameAddress) => Promise<TableItem_RepositoryData | undefined>;
export declare const queryTableItem_PermissionPerm: (query: QueryTableItem_byAddress) => Promise<TableItem_PermissionPerm | undefined>;
export declare const queryTableItem_EntityRegistrar: (query: QueryTableItem_Entity) => Promise<TableItem_EntityRegistrar | undefined>;
export declare const queryTableItem_EntityLinker: (query: QueryTableItem_Entity) => Promise<TableItem_EntityLinker | undefined>;
export declare const queryTableItem_RewardRecord: (query: QueryTableItem_byAddress) => Promise<TableItem_RewardRecord | undefined>;
export declare const queryTableItem_DemandPresenter: (query: QueryTableItem_byAddress) => Promise<TableItem_DemandPresenter | undefined>;
export declare const queryTableItem_TreasuryHistory: (query: QueryTableItem_byAddress) => Promise<TableItem_TreasuryHistory | undefined>;
export declare const queryTableItem_MachineNode: (query: QueryTableItem_byString) => Promise<TableItem_MachineNode | undefined>;
export declare const queryTableItem_AddressMark: (query: QueryTableItem_byAddress) => Promise<TableItem_AddressMark | undefined>;
export declare const queryTableItem_ProgressHistory: (query: QueryTableItem_byU64) => Promise<TableItem_ProgressHistory | undefined>;
export declare function raw2type(type_raw: string | undefined): ObjectType | undefined;
export declare function data2object(data?: any): ObjectBase;