UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

345 lines (344 loc) 14.3 kB
import type { Transaction, TransactionArgument, TransactionObjectArgument, TransactionResult } from "../transactions/index.js"; import type { ENTRYPOINT } from "../client/network.js"; import type { AccountOrMark_Address, ManyAccountOrMark_Address } from "./local/index.js"; export type AddressResult = TransactionResult | TransactionObjectArgument; export type ObjectResult = TransactionResult | string | TransactionObjectArgument; export type PermissionAddress = AddressResult; export type PermissionObject = ObjectResult; export type RepositoryAddress = AddressResult; export type RepositoryObject = ObjectResult; export type GuardAddress = AddressResult; export type GuardObject = ObjectResult; export type MachineAddress = AddressResult; export type MachineObject = ObjectResult; export type ContactAddress = AddressResult; export type ContactObject = ObjectResult; export type PassportObject = TransactionResult; export type DemandAddress = AddressResult; export type DemandObject = ObjectResult; export type ServiceObject = ObjectResult; export type ServiceAddress = AddressResult; export type ArbitrationObject = ObjectResult; export type ArbitrationAddress = AddressResult; export type ArbObject = ObjectResult; export type ArbAddress = AddressResult; export type ProgressObject = ObjectResult; export type ProgressAddress = AddressResult; export type TreasuryObject = ObjectResult; export type TreasuryAddress = AddressResult; export type OrderObject = ObjectResult; export type OrderAddress = AddressResult; export type DiscountObject = ObjectResult; export type CoinObject = TransactionObjectArgument; export type ResourceObject = ObjectResult; export type ResourceAddress = AddressResult; export type PaymentObject = ObjectResult; export type PaymentAddress = AddressResult; export type AllocationObject = TransactionObjectArgument; export type AllocationAddress = AddressResult; export type RewardObject = ObjectResult; export type RewardAddress = AddressResult; export type ReceivedObject = ObjectResult; export type ProofAddress = AddressResult; export type CoinWrapperObject = TransactionResult; export type PaymentInfoObject = TransactionObjectArgument; export type TxObject = ObjectResult | PassportObject | CoinWrapperObject; export type TxAddress = string | TransactionResult | TransactionObjectArgument; export type TxString = string | TransactionArgument; export type TxNumber = number | TransactionArgument | bigint | string; export type TxAddressVec = Array<string> | TransactionResult; export type TxNumberVec = Array<number | bigint | string> | TransactionResult; export declare enum ValueType { Bool = 0, Address = 1, String = 2, U8 = 3, U16 = 4, U32 = 5, U64 = 6, U128 = 7, U256 = 8, VecBool = 9, VecAddress = 10, VecString = 11, VecU8 = 12, VecU16 = 13, VecU32 = 14, VecU64 = 15, VecU128 = 16, VecU256 = 17, VecVecU8 = 18, Value = 19 } export interface ValueContainer<T extends ValueType = ValueType> { valueType: T; value: ValueTypeToType[T]; } export declare const createValueContainer: <T extends ValueType>(valueType: T, value: ValueTypeToType[T]) => ValueContainer<T>; export type ValueTypeToType = { [ValueType.Bool]: boolean; [ValueType.Address]: AccountOrMark_Address | string; [ValueType.String]: string; [ValueType.U8]: number; [ValueType.U16]: number; [ValueType.U32]: number; [ValueType.U64]: bigint | number; [ValueType.U128]: bigint; [ValueType.U256]: bigint; [ValueType.VecBool]: boolean[]; [ValueType.VecAddress]: ManyAccountOrMark_Address | string[]; [ValueType.VecString]: string[]; [ValueType.VecU8]: number[] | Uint8Array; [ValueType.VecU16]: number[]; [ValueType.VecU32]: number[]; [ValueType.VecU64]: (bigint | number)[]; [ValueType.VecU128]: bigint[]; [ValueType.VecU256]: bigint[]; [ValueType.VecVecU8]: (number[] | Uint8Array)[]; [ValueType.Value]: ValueContainer; }; export type SupportedValue = ValueTypeToType[keyof ValueTypeToType]; export type ValueTypeInput = ValueType | string; export declare const parseValueType: (input: ValueTypeInput) => ValueType; export declare const valueTypeToString: (type: ValueType) => string; export declare const isValidValueTypeInput: (input: unknown) => input is ValueTypeInput; export declare enum OperatorType { TypeQuery = 40, TypeNumberAdd = 200, TypeNumberSubtract = 201, TypeNumberMultiply = 202, TypeNumberDivide = 203, TypeNumberMod = 204, TypeNumberAddress = 205, TypeNumberString = 206, TypeAddressNumber = 207, TypeStringNumber = 208, TypeSafeU8 = 220, TypeSafeU16 = 221, TypeSafeU32 = 222, TypeSafeU64 = 223, TypeSafeU128 = 224, TypeSafeU256 = 225, TypeStringLength = 61, TypeStringIndexof = 62, TypeStringNocaseIndexof = 63, TypeStringContains = 64, TypeStringNocaseContains = 65, TypeStringNocaseEqual = 66, TypedValueType = 70, TypedValueVecLength = 71, TypedValueVecContains_Bool = 72, TypedValueVecContains_Address = 73, TypedValueVecContains_String = 74, TypedValueVecContains_StringNoCase = 75, TypedValueVecContains_Number = 76, TypedValueVecContains_U8 = 82, TypedValueVecContains_U16 = 83, TypedValueVecContains_U32 = 84, TypedValueVecContains_U64 = 85, TypedValueVecContains_U128 = 86, TypedValueVecContains_U256 = 87, TypedValueVecIndexOf_Bool = 77, TypedValueVecIndexOf_Address = 78, TypedValueVecIndexOf_String = 79, TypedValueVecIndexOf_StringNoCase = 80, TypedValueVecIndexOf_Number = 81, TypeLogicEqual = 90, TypeLogicAsU256Greater = 91, TypeLogicAsU256GreaterEqual = 92, TypeLogicAsU256Lesser = 93, TypeLogicAsU256LesserEqual = 94, TypeLogicAsU256Equal = 95, TypeLogicAnd = 96, TypeLogicOr = 97, TypeLogicNot = 98 } export declare enum WitnessType { TypeOrderProgress = 100, TypeOrderMachine = 101, TypeOrderService = 102, TypeProgressMachine = 103, TypeArbOrder = 104, TypeArbArbitration = 105, TypeArbProgress = 106, TypeArbMachine = 107, TypeArbService = 108 } export declare const isWitnessType: (type: number | WitnessType | undefined | null) => type is WitnessType; export declare enum ContextType { TypeSigner = 45, TypeClock = 46, TypeGuard = 47, TypeConstant = 48 } export declare enum Modules { Machine = "machine", Progress = "progress", Repository = "repository", Permission = "permission", Passport = "passport", Guard = "guard", Demand = "demand", Order = "order", Service = "service", Resource = "resource", Entity = "entity", Wowok = "wowok", Treasury = "treasury", Payment = "payment", Arbitration = "arbitration", Arb = "arb", Allocation = "allocation" } export declare const PackageAddress = "0x2"; export declare const GasTokenType = "0x2::wow::WOW"; export declare const GasCoinType = "0x2::coin::Coin<0x2::wow::WOW>"; export declare const RegistrarAddress = "0xaaa"; export declare const EntityAddress = "0xaab"; export declare const MAX_ENV_PERMISSION_GUARD_COUNT = 4; export declare const isGasTokenType: (token_type: string) => boolean; export declare const isValidValueType: (valueType: number) => boolean; export declare const isThisPackage: (type: string) => boolean; export declare const isValidArray: <T>(arr: T[], validator: (item: T) => boolean) => boolean; export declare const isValidU8: (value: number | bigint | string) => boolean; export declare const isValidU16: (value: number | bigint | string) => boolean; export declare const isValidU64: (value: number | bigint | string) => boolean; export declare const isValidU128: (value: number | bigint | string) => boolean; export declare const isValidU256: (value: number | bigint | string) => boolean; export declare const isValidU32: (value: number | bigint | string) => boolean; export declare const IsBcsStringLength: (str: string, max_len: number) => boolean; export declare const MAX_DESCRIPTION_LENGTH = 4000; export declare const MAX_NAME_LENGTH = 64; export declare const MAX_LONG_NAME_LENGTH = 256; export declare const MAX_GUARD_TABLE_ITEM_LENGTH = 256; export declare const MAX_INPUT_SIZE = 1024; export declare const MAX_TABLE_SIZE = 40000; export declare const MAX_DEPENDED_COUNT = 4; export declare const MAX_MULTI_OPERANDS = 8; export declare const isValidDescription: (description: string) => boolean; export declare const isValidName: (name: string) => boolean; export declare const isValidLongName: (name: string) => boolean; export declare const isValidHttpUrl: (url: string) => boolean; export declare const isValueTypeNumber: (valueType: ValueType | number) => boolean; export declare const toTxObject: (tx: Transaction, arg: TxObject) => TransactionObjectArgument; export declare const toTxString: (tx: Transaction, arg: TxString) => TransactionArgument; export declare const toTxU8: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxU16: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxU32: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxU128: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxU256: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxU64: (tx: Transaction, arg: TxNumber) => TransactionArgument; export declare const toTxAddress: (tx: Transaction, arg: TxAddress) => TransactionArgument; export declare const toTxAddressVec: (tx: Transaction, arg: TxAddressVec, max_len: number) => TransactionArgument; export declare const toTxU16Vec: (tx: Transaction, arg: TxNumberVec, max_len: number) => TransactionArgument; export declare const object_name_from_type: (type_repr: string | null | undefined) => string | undefined; export interface ObjectModuleAndName { module: string; name: string; } export declare const object_module_and_name_from_type: (type_repr: string | null | undefined) => ObjectModuleAndName | undefined; export interface NamedObject { name?: string; tags?: string[]; replaceExistName?: boolean; onChain?: boolean; } export interface NamedObjectWithDescription extends NamedObject { description?: string; } export interface NamedObjectWithPermission extends NamedObject { permission?: DescriptionObject; } export interface TypeNamedObjectWithPermission extends NamedObjectWithPermission { type_parameter: string; } export interface TypeNamedObject extends NamedObject { type_parameter: string; } export type TypedPermissionObject = string | TypeNamedObjectWithPermission; export type TypedDescriptionObject = string | TypeNamedObject; export type WithPermissionObject = string | NamedObjectWithPermission; export type NormalObject = string | NamedObject; export type DescriptionObject = string | NamedObjectWithDescription; export type WObject = TypedPermissionObject | TypedDescriptionObject | PermissionObject | NormalObject | DescriptionObject; export declare const GetObjectExisted: (object?: WObject) => Promise<string | undefined>; export declare const GetObjectDescription: (object?: WObject) => string | undefined; export declare const GetObject: (object?: WObject) => NamedObjectWithPermission | TypeNamedObjectWithPermission | NamedObjectWithDescription | TypeNamedObject | undefined; export declare const MAX_PERMISSION_GUARD_COUNT = 4; export interface CallEnv { network?: ENTRYPOINT; account?: string | null; permission_guard?: string[]; no_cache?: boolean; referrer?: string | null; } export declare const CoinWrapPrefix = "0x2::payment::CoinWrapper"; export type BalanceType = number | bigint | string; export declare const IsValidBalance: (balance: BalanceType) => boolean; export declare const IsValidEndpoint: (endpoint?: string | null | undefined) => boolean; export declare const IsValidArgType: (arg_type: string | null | undefined) => boolean; export type CoinParam = { coin: CoinObject | string; } | { balance: BalanceType; }; export declare enum RecipientType { GuardIdentifier = 0, Entity = 1, Signer = 2 } export type Recipient = { GuardIdentifier: number; } | { Entity: AccountOrMark_Address; } | { Signer: null; }; export type ObjectWithType = { object: string; type: string; }; export declare function serviceFn(name: string): string; export declare function demandFn(name: string): string; export declare function machineFn(name: string): string; export declare function contactFn(name: string): string; export declare function treasuryFn(name: string): string; export declare function arbitrationFn(name: string): string; export declare function repositoryFn(name: string): string; export declare function rewardFn(name: string): string; export declare enum ObjectType { Permission = "Permission", Repository = "Repository", Arb = "Arb", Arbitration = "Arbitration", Service = "Service", Machine = "Machine", Order = "Order", Progress = "Progress", Payment = "Payment", Treasury = "Treasury", Guard = "Guard", Demand = "Demand", Passport = "Passport", Allocation = "Allocation", Resource = "Resource", Reward = "Reward", Discount = "Discount", EntityRegistrar = "EntityRegistrar", EntityLinker = "EntityLinker", Proof = "Proof", Contact = "Contact", WReceivedObject = "WReceivedObject", TableItem_ProgressHistory = "TableItem_ProgressHistory", TableItem_PermissionPerm = "TableItem_PermissionPerm", TableItem_DemandPresenter = "TableItem_DemandPresenter", TableItem_MachineNode = "TableItem_MachineNode", TableItem_TreasuryHistory = "TableItem_TreasuryHistory", TableItem_RepositoryData = "TableItem_RepositoryData", TableItem_RewardRecord = "TableItem_RewardRecord", TableItem_EntityLinker = "TableItem_EntityLinker", TableItem_AddressMark = "TableItem_AddressMark", TableItem_EntityRegistrar = "TableItem_EntityRegistrar" } export declare const ENTITY_LINKER_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000aaa"; export declare const ENTITY_REGISTRAR_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000aab";