import { Chan } from '@lesomnus/channel'; type Uint64 = number; type DVMString = string; type Hash = string; type SCCode = string; type Address = string; type DataType = "S" | "U" | "H"; type Stringkeys = { [key: string]: number | string; }; type Entity = "wallet" | "daemon"; type Config = { address?: string; port?: number; debug?: boolean; timeout?: { AUTH_TIMEOUT?: number; METHOD_TIMEOUT?: number; BLOCK_TIMEOUT?: number; }; secure?: boolean; }; declare enum ConnectionState { Initializing = "initializing", WaitingAuth = "waitingAuth", Accepted = "accepted", Refused = "refused", Closed = "closed" } type AppInfo = { id: string; name: string; description: string; url?: string; }; type EventType = "new_topoheight" | "new_entry" | "new_balance"; type JSONRPCRequest = { method: "POST"; headers: { "Content-Type": "application/json"; }; body: JSONRPCRequestBody>; }; type JSONRPCRequestBody> = { jsonrpc: "2.0"; id: string | number; method: M; params: Params; }; type Method = E extends "daemon" ? "DERO.Echo" | "DERO.Ping" | "DERO.GetInfo" | "DERO.GetBlock" | "DERO.GetBlockHeaderByTopoHeight" | "DERO.GetBlockHeaderByHash" | "DERO.GetTxPool" | "DERO.GetRandomAddress" | "DERO.GetTransaction" | "DERO.SendRawTransaction" | "DERO.GetHeight" | "DERO.GetBlockCount" | "DERO.GetLastBlockHeader" | "DERO.GetBlockTemplate" | "DERO.GetEncryptedBalance" | "DERO.GetSC" | "DERO.GetGasEstimate" | "DERO.NameToAddress" : "Echo" | "GetAddress" | "GetBalance" | "GetHeight" | "GetTransferbyTXID" | "GetTransfers" | "GetTrackedAssets" | "MakeIntegratedAddress" | "SplitIntegratedAddress" | "QueryKey" | "transfer" | "scinvoke" | "Subscribe"; type Params> = M extends "DERO.Echo" ? Echo : M extends "DERO.Ping" ? undefined : M extends "DERO.GetInfo" ? undefined : M extends "DERO.GetBlock" ? DEROGetBlock : M extends "DERO.GetBlockHeaderByTopoHeight" ? DEROGetBlockHeaderByTopoHeight : M extends "DERO.GetBlockHeaderByHash" ? DEROGetBlockHeaderByHash : M extends "DERO.GetTxPool" ? undefined : M extends "DERO.GetRandomAddress" ? DEROGetRandomAddress : M extends "DERO.GetTransaction" ? DEROGetTransaction : M extends "DERO.SendRawTransaction" ? DEROSendRawTransaction : M extends "DERO.GetHeight" ? undefined : M extends "DERO.GetBlockCount" ? undefined : M extends "DERO.GetLastBlockHeader" ? undefined : M extends "DERO.GetBlockTemplate" ? DEROGetBlockTemplate : M extends "DERO.GetEncryptedBalance" ? DEROGetEncryptedBalance : M extends "DERO.GetSC" ? DEROGetSC : M extends "DERO.GetGasEstimate" ? DEROGetGasEstimate : M extends "DERO.NameToAddress" ? DERONameToAddress : M extends "GetAddress" ? undefined : M extends "GetBalance" ? GetBalance : M extends "GetHeight" ? undefined : M extends "GetTrackedAssets" ? GetTrackedAssets : M extends "GetTransferbyTXID" ? GetTransferbyTXID : M extends "GetTransfers" ? GetTransfers : M extends "MakeIntegratedAddress" ? MakeIntegratedAddress : M extends "SplitIntegratedAddress" ? SplitIntegratedAddress : M extends "QueryKey" ? QueryKey : M extends "transfer" ? Transfer : M extends "scinvoke" ? SCInvoke : M extends "Subscribe" ? { event: EventType; } : Echo; type Echo = DVMString[]; type WalletTransfer = { amount?: Uint64; burn?: Uint64; destination?: string; scid?: Hash; payload_rpc?: Arguments; }; type ArgumentType = Uint64 | DVMString | Hash; type Argument = { name: DVMString; datatype: AT extends Uint64 ? "U" : AT extends Hash | DVMString ? "H" | "S" : unknown; value: AT; }; type Arguments = Argument[]; type DEROGetBlock = { hash?: Hash; height?: Uint64; }; type DEROGetBlockHeaderByTopoHeight = { topoheight: Uint64; }; type DEROGetBlockHeaderByHash = { hash: Hash; }; type DEROGetRandomAddress = { scid?: Hash; }; type DEROGetTransaction = { txs_hashes: Hash[]; decode_as_json?: Uint64; }; type DEROSendRawTransaction = { tx_as_hex: DVMString; }; type DEROGetBlockTemplate = { wallet_address: DVMString; block?: boolean; miner?: DVMString; }; type DEROGetEncryptedBalance = { address: DVMString; topoheight: Uint64; scid?: Hash; treehash?: Hash; }; type DEROGetSC = { scid: Hash; code?: boolean; variables?: boolean; topoheight?: Uint64; keysuint64?: Uint64[]; keysstring?: DVMString[]; keysbytes?: Int8Array[]; }; declare function gasEstimateSCArgs(scid: Hash, entrypoint: string, args: { name: string; value: DVMString | Uint64; }[]): Argument[]; declare function scinvokeSCArgs(entrypoint: string, args: { name: string; value: DVMString | Uint64; }[]): Argument[]; type DEROGetGasEstimate = { transfers?: WalletTransfer[]; sc?: SCCode; sc_rpc?: Argument[]; signer?: Address; }; type DERONameToAddress = { name: DVMString; topoheight: Uint64; }; type GetBalance = { scid?: Hash; }; type GetTrackedAssets = { only_positive_balances: boolean; skip_balance_check: boolean; }; type GetTransferbyTXID = { hash?: Hash; txid?: Hash; }; type GetTransfers = { scid?: Hash; coinbase?: boolean; in?: boolean; out?: boolean; min_height?: Uint64; max_height?: Uint64; sender?: DVMString; receiver?: DVMString; dstport?: Uint64; srcport?: Uint64; }; type MakeIntegratedAddress = { address?: DVMString; payload_rpc?: Argument; }; type SplitIntegratedAddress = { integrated_address: DVMString; }; type QueryKey = { key_type: "mnemonic"; }; type Transfer = { transfers?: WalletTransfer[]; sc?: SCCode; sc_rpc?: Arguments; ringsize?: Uint64; scid?: Hash; fees?: Uint64; signer?: Address; }; type SCInvoke = { scid: Hash; sc_rpc: Arguments; sc_dero_deposit?: Uint64; sc_token_deposit?: Uint64; ringsize?: Uint64; }; type Result = "error" | "result"; type ErrorResponse = { message: string; code: number; }; type ResultResponse> = M extends "DEROEcho" | "Echo" ? string[] : M extends "DERO.Ping" ? "Pong " : M extends "DERO.GetInfo" ? DEROGetInfoResult : M extends "DERO.GetBlock" ? DEROGetBlockResult : M extends "DERO.GetBlockHeaderByTopoHeight" | "DERO.GetBlockHeaderByHash" ? DEROGetBlockHeaderResult : M extends "DERO.GetTxPool" ? DEROGetTxPoolResult : M extends "DERO.GetRandomAddress" ? { address: string[]; status: "OK"; } : M extends "DERO.GetTransaction" ? DEROGetTransactionResult : M extends "DERO.GetHeight" ? DEROGetHeightResult : M extends "DERO.GetBlockCount" ? DEROGetBlockCountResult : M extends "DERO.GetLastBlockHeader" ? DEROGetBlockResult : M extends "DERO.GetSC" ? DEROGetSCResult : M extends "DERO.GetGasEstimate" ? DEROGetGasEstimateResult : M extends "DERO.GetBlockTemplate" ? DEROGetBlockTemplateResult : M extends "DERO.GetEncryptedBalance" ? DEROGetEncryptedBalanceResult : M extends "DERO.NameToAddress" ? DERONameToAddressResult : M extends "GetAddress" ? { address: string; } : M extends "GetBalance" ? GetBalanceResult : M extends "GetHeight" ? { height: Uint64; } : M extends "GetTransfers" ? GetTransfersResult : M extends "GetTrackedAssets" ? GetTrackedAssetsResult : M extends "QueryKey" ? { key: string; } : M extends "Subscribe" ? boolean : M extends "transfer" | "scinvoke" ? { txid: string; } : M extends "GetTransferbyTXID" ? GetTransferByTXIDResult : unknown; type Response, R extends Result> = { jsonrpc: "2.0"; id: string; } & (R extends "error" ? { error: ErrorResponse; } : { result: ResultResponse; }); type AuthResponse = { accepted: boolean; message: string; }; type EventResponse = { jsonrpc: "2.0"; id: string; result: { event: EventType; value: any; }; }; type Network = "Simulator" | "Testnet" | "Mainnet"; type Status = { status: "OK"; }; type DEROGetInfoResult = { alt_blocks_count: Uint64; difficulty: Uint64; grey_peerlist_size: number; height: Uint64; stableheight: Uint64; topoheight: Uint64; treehash: Hash; averageblocktime50: number; incoming_connections_count: number; outgoing_connections_count: number; target: number; target_height: Uint64; testnet: boolean; network: Network; top_block_hash: Hash; tx_count: number; tx_pool_size: number; dynamic_fee_per_kb: number; total_supply: number; median_block_size: number; white_peerlist_size: number; version: string; connected_miners: number; miniblocks_in_memory: number; blocks_count: number; miniblocks_accepted_count: number; miniblocks_rejected_count: number; mining_velocity: number; uptime: number; hashrate_1hr: number; hashrate_1d: number; hashrate_7d: number; } & Status; type DEROGetBlockResult = { blob: string; json: string; block_header: { depth: number; difficulty: string; hash: Hash; height: Uint64; topoheight: Uint64; major_version: number; minor_version: number; nonce: number; orphan_status: boolean; syncblock: boolean; sideblock: boolean; txcount: number; miners: null | unknown; reward: number; tips: null | unknown; timestamp: number; }; } & Status; type DEROGetBlockHeaderResult = { block_header: { depth: Uint64; difficulty: string; hash: Hash; height: Uint64; topoheight: Uint64; major_version: number; minor_version: number; nonce: number; orphan_status: boolean; syncblock: boolean; sideblock: boolean; txcount: number; miners: null | unknown; reward: Uint64; tips: null | unknown; timestamp: number; }; } & Status; type DEROGetTxPoolResult = {} & Status; type DEROGetTransactionResult = { txs_as_hex: null; txs: null; } & Status; type DEROGetHeightResult = { height: Uint64; stableheight: Uint64; topoheight: Uint64; } & Status; type DEROGetBlockCountResult = { count: Uint64; } & Status; type DERONameToAddressResult = { name: string; address: string; } & Status; type GetBalanceResult = { balance: Uint64; unlocked_balance: Uint64; }; type Entry = { height: Uint64; topoheight: Uint64; blockhash: Hash; minerreward: number; tpos: number; pos: number; coinbase: boolean; incoming: boolean; txid: Hash; destination: string; amount: Uint64; fees: Uint64; proof: string; status: number; time: string; ewdata: string; data: string; payloadtype: number; payload: string; payload_rpc: { name: string; datatype: "S" | "U"; value: DVMString | Uint64; }[]; sender: string; dstport: number; srcport: number; }; type Topoheight = Uint64; type Balance = Uint64; type GetTransfersResult = { entries: Entry[]; }; type GetTrackedAssetsResult = { balances: { [asset: Hash]: Uint64; }; }; type GetTransferByTXIDResult = { entry: Entry; scid: Hash; }; type DEROGetSCResult = { valuesuint64: DVMString[]; valuesstring: DVMString[]; valuesbytes: DVMString[]; stringkeys: { C: SCCode; [k: string]: DVMString | Uint64; }; uint64keys: { [k: Uint64]: DVMString | Uint64; }; balances: { [scid: Hash]: Uint64; }; balance: Uint64; code: DVMString; } & Status; type DEROGetGasEstimateResult = { gascompute: Uint64; gasstorage: Uint64; } & Status; type DEROGetBlockTemplateResult = { jobid: string; blocktemplate_blob: string; blockhashing_blob: string; difficulty: string; difficultyuint64: Uint64; height: Uint64; prev_hash: Hash; epochmilli: number; blocks: Uint64; miniblocks: Uint64; rejected: Uint64; lasterror: string; } & Status; type DEROGetEncryptedBalanceResult = { scid: Hash; data: string; registration: Uint64; bits: number; height: Uint64; topoheight: Uint64; blockhash: Hash; treehash: Hash; dheight: Uint64; dtopoheight: Uint64; dtreehash: Hash; } & Status; declare enum ConnectionType { XSWD = "xswd", Fallback = "fallback" } declare class Api { connection: { [ct in ConnectionType]: WebSocket | null; }; state: { [ct in ConnectionType]: ConnectionState; }; buffer: string; appInfo: AppInfo; config: { [k in ConnectionType]: k extends ConnectionType.XSWD ? Config : Config | null; }; response: Chan, Result>>; subscriptions: { events: { [et in EventType]: { enabled: boolean; waiting: Chan[]; callback?: (eventValue?: any) => void; }; }; }; private nextId; get mode(): ConnectionType; constructor(appInfo: AppInfo, config?: Config, fallback_config?: Config | null); initialize(): Promise; initializeFallback(): Promise; initializeXSWD(): Promise; _initializeWebsocket(connectionType: ConnectionType): Promise; _handleFragmentedData(message: MessageEvent): AuthResponse | EventResponse | Response, "error"> | Response, "result"> | null; _setupHandlers(connectionType: ConnectionType, resolve: (value: void | PromiseLike) => void, reject: (reason?: any) => void): Promise; onclose(connectionType: ConnectionType, ev: CloseEvent): void; closeXSWD(): Promise; closeFallback(): Promise; close(): Promise; Send>(//! previously sendSync entity: E, method: M, body: Omit, "id">): Promise | Response>; subscribe({ event, callback, }: { event: EventType; callback?: (value: any) => void; }): Promise; waitFor(event: ET, predicate?: (eventValue: EV) => boolean): Promise; private authorize; wallet: { _api: Api; Echo(params: Echo): Promise | Response<"wallet", "Echo", "result">>; GetAddress(): Promise | Response<"wallet", "GetAddress", "result">>; GetBalance(params?: GetBalance): Promise | Response<"wallet", "GetBalance", "result">>; GetHeight(): Promise | Response<"wallet", "GetHeight", "result">>; GetTransferbyTXID(params: GetTransferbyTXID): Promise | Response<"wallet", "GetTransferbyTXID", "result">>; GetTransfers(params?: GetTransfers): Promise | Response<"wallet", "GetTransfers", "result">>; GetTrackedAssets(params: GetTrackedAssets): Promise | Response<"wallet", "GetTrackedAssets", "result">>; MakeIntegratedAddress(params: MakeIntegratedAddress): Promise | Response<"wallet", "MakeIntegratedAddress", "result">>; SplitIntegratedAddress(params: SplitIntegratedAddress): Promise | Response<"wallet", "SplitIntegratedAddress", "result">>; QueryKey(params: QueryKey): Promise | Response<"wallet", "QueryKey", "result">>; transfer(params: Transfer): Promise | Response<"wallet", "transfer", "result">>; scinvoke(params: SCInvoke): Promise>; }; node: { _api: Api; Echo(params: Echo): Promise | Response<"daemon", "DERO.Echo", "result">>; Ping(): Promise | Response<"daemon", "DERO.Ping", "result">>; GetInfo(): Promise | Response<"daemon", "DERO.GetInfo", "result">>; GetBlock(params: DEROGetBlock): Promise | Response<"daemon", "DERO.GetBlock", "result">>; GetBlockHeaderByTopoHeight(params: DEROGetBlockHeaderByTopoHeight): Promise | Response<"daemon", "DERO.GetBlockHeaderByTopoHeight", "result">>; GetBlockHeaderByHash(params: DEROGetBlockHeaderByHash): Promise | Response<"daemon", "DERO.GetBlockHeaderByHash", "result">>; GetTxPool(): Promise | Response<"daemon", "DERO.GetTxPool", "result">>; GetRandomAddress(params?: DEROGetRandomAddress): Promise | Response<"daemon", "DERO.GetRandomAddress", "result">>; GetTransaction(params: DEROGetTransaction): Promise | Response<"daemon", "DERO.GetTransaction", "result">>; GetHeight(): Promise | Response<"daemon", "DERO.GetHeight", "result">>; GetBlockCount(): Promise | Response<"daemon", "DERO.GetBlockCount", "result">>; GetLastBlockHeader(): Promise | Response<"daemon", "DERO.GetLastBlockHeader", "result">>; GetBlockTemplate(params: DEROGetBlockTemplate): Promise | Response<"daemon", "DERO.GetBlockTemplate", "result">>; GetEncryptedBalance(params: DEROGetEncryptedBalance): Promise | Response<"daemon", "DERO.GetEncryptedBalance", "result">>; GetSC(params: DEROGetSC, waitAfterNewBlock?: true): Promise | Response<"daemon", "DERO.GetSC", "result">>; GetGasEstimate(params: DEROGetGasEstimate): Promise | Response<"daemon", "DERO.GetGasEstimate", "result">>; NameToAddress(params: DERONameToAddress): Promise | Response<"daemon", "DERO.NameToAddress", "result">>; }; } declare function generateAppId(appName: string): string; declare function sleep(timems: number): Promise; declare function to, R extends Result = Result>(response: Response): [ErrorResponse | undefined, ResultResponse | undefined]; export { Address, Api, AppInfo, AuthResponse, Balance, Config, ConnectionState, DEROGetBlock, DEROGetBlockHeaderByHash, DEROGetBlockHeaderByTopoHeight, DEROGetBlockTemplate, DEROGetEncryptedBalance, DEROGetGasEstimate, DEROGetRandomAddress, DEROGetSC, DEROGetTransaction, DERONameToAddress, DEROSendRawTransaction, DVMString, DataType, Echo, Entity, Entry, ErrorResponse, EventResponse, EventType, GetBalance, GetTrackedAssets, GetTransferbyTXID, GetTransfers, Hash, JSONRPCRequest, JSONRPCRequestBody, MakeIntegratedAddress, Method, Params, QueryKey, Response, Result, ResultResponse, SCCode, SCInvoke, SplitIntegratedAddress, Stringkeys, Topoheight, Transfer, Uint64, WalletTransfer, gasEstimateSCArgs, generateAppId, scinvokeSCArgs, sleep, to };