wowok
Version:
Wowok Blockchain TypeScript API
84 lines (83 loc) • 3.64 kB
TypeScript
export declare enum WErrors {
AccountNotFound = "account not found",
AddressNotFound = "address not found",
IsValidDescription = "invalid description",
IsValidName = "invalid name",
IsValidName_AllowEmpty = "invalid name",
IsValidEndpoint = "invalid endpoint",
IsValidAddress = "invalid address",
IsValidArgType = "invalid argument type",
IsValidTokenType = "invalid token type",
IsValidUint = "invalid uint",
IsValidInt = "invalid int",
IsValidU8 = "invalid u8",
IsValidU16 = "invalid u16",
IsValidU32 = "invalid u32",
IsValidU64 = "invalid u64",
IsValidU128 = "invalid u128",
IsValidU256 = "invalid u256",
IsValidRate = "invalid rate[0-10000]",
IsValidArray = "invalid array",
IsValidObjects = "invalid objects",
AllInvalid = "one valid at least",
InvalidParam = "invalid parameter",
IsValidPermissionIndex = "invalid permission index",
IsValidKey = "invalid key",
Fail = "fail",
IsValidIdentifier = "identifier invalid",
IsValidHttpUrl = "invalid url",
IsValidBizPermissionIndex = "invalid biz-permission id[1000 - 65535]",
BcsTypeInvalid = "invalid bcs type",
IsValidServiceItemName = "invalid service item name",
IsValidCoinType = "not the coin type",
IsValidGuardIdentifier = "guard identifier invalid",
NoPermission = "no permission",
IsValidValue = "invalid value",
IsValidValueType = "invalid value type",
IsValidLocation = "invalid location",
NetworkInvalid = "protocol network not specified",
WitnessTypeInvalid = "witness type invalid",
AddressCountExceeded = "address count exceeded",
NumberCountExceeded = "number count exceeded",
NewGuardCheckFailed = "new guard check failed",
GuardTableItemLengthExceeded = "guard table item length exceeded",
AccountPersistentStorageNotSet = "account persistent storage not set",
AccountPersistentStorageNotFound = "account persistent storage not found",
AccountNameExist = "account name exist",
ConfigPersistentStorageNotSet = "config persistent storage not set",
TokenNotFoundLocally = "token not found",
LocalMarkNameExist = "local mark name exist",
MaxObjectsPerQuery = "max objects per query",
ResourceTagCountExceeded = "resource tag count exceeded",
ParseObjectContentFailed = "parse object content failed"
}
export declare class WException extends Error {
readonly code: WErrors;
readonly details?: any;
constructor(error: WErrors, details?: any);
getErrorMessage(): string;
getErrorCode(): WErrors;
getDetails(): any;
}
export declare const W_ERROR: (error: WErrors, details?: any) => never;
export type WResult<T> = {
success: true;
data: T;
} | {
success: false;
error: WException;
};
export declare const W_SUCCESS: <T>(data: T) => WResult<T>;
export declare const W_FAILURE: (error: WErrors, details?: any) => WResult<any>;
export declare function WValidate<T extends (...args: any[]) => any>(fn: T): T;
export declare const W_SAFE: <T>(fn: () => T, error?: WErrors, details?: any) => WResult<T>;
export declare const W_ENSURE: (condition: boolean, error: WErrors, details?: any) => void;
export declare const W_VALIDATE_PARAM: (param: any, validator: (value: any) => boolean, error: WErrors, details?: any) => void;
export interface MoveModuleError {
module: string;
code: number;
description: string;
}
export declare const MoveErrors: MoveModuleError[];
export declare function getMoveErrorDescription(module: string, code: number): string | null;
export declare function enrichMoveError(errorMessage: string): string;