/** * @module API */ import { AbiProvider, AuthorityProvider, BinaryAbi, CachedAbi, SignatureProvider } from './eosjs-api-interfaces'; import { JsonRpc } from './eosjs-jsonrpc'; import { Abi, PushTransactionArgs, SendTransaction2Args } from "./eosjs-rpc-interfaces"; import * as ser from './eosjs-serialize'; export declare class Api { /** Issues RPC calls */ rpc: JsonRpc; /** Get subset of `availableKeys` needed to meet authorities in a `transaction` */ authorityProvider: AuthorityProvider; /** Supplies ABIs in raw form (binary) */ abiProvider: AbiProvider; /** Signs transactions */ signatureProvider: SignatureProvider; /** Identifies chain */ chainId: string; textEncoder: TextEncoder; textDecoder: TextDecoder; /** Converts abi files between binary and structured form (`abi.abi.json`) */ abiTypes: Map; /** Converts transactions between binary and structured form (`transaction.abi.json`) */ transactionTypes: Map; /** Holds information needed to serialize contract actions */ contracts: Map; /** Fetched abis */ cachedAbis: Map; /** Matched get_info server version string * Deferred call to get_info will populate * Needed for new 3.1+ endpoints to check support * */ private server_version_string?; /** * @param args * * `rpc`: Issues RPC calls * * `authorityProvider`: Get public keys needed to meet authorities in a transaction * * `abiProvider`: Supplies ABIs in raw form (binary) * * `signatureProvider`: Signs transactions * * `chainId`: Identifies chain * * `textEncoder`: `TextEncoder` instance to use. Pass in `null` if running in a browser * * `textDecoder`: `TextDecoder` instance to use. Pass in `null` if running in a browser */ constructor(args: { rpc: JsonRpc; authorityProvider?: AuthorityProvider; abiProvider?: AbiProvider; signatureProvider: SignatureProvider; chainId?: string; textEncoder?: TextEncoder; textDecoder?: TextDecoder; }); /** Decodes an abi as Uint8Array into json. */ rawAbiToJson(rawAbi: Uint8Array): Abi; /** Get abi in both binary and structured forms. Fetch when needed. */ getCachedAbi(accountName: string, reload?: boolean): Promise; /** Get abi in structured form. Fetch when needed. */ getAbi(accountName: string, reload?: boolean): Promise; /** Get abis needed by a transaction */ getTransactionAbis(transaction: any, reload?: boolean): Promise; /** Get data needed to serialize actions in a contract */ getContract(accountName: string, reload?: boolean): Promise; /** Convert `value` to binary form. `type` must be a built-in abi type or in `transaction.abi.json`. */ serialize(buffer: ser.SerialBuffer, type: string, value: any): void; /** Convert data in `buffer` to structured form. `type` must be a built-in abi type or in `transaction.abi.json`. */ deserialize(buffer: ser.SerialBuffer, type: string): any; /** Convert a transaction to binary */ serializeTransaction(transaction: any): Uint8Array; /** Serialize context-free data */ serializeContextFreeData(contextFreeData: Uint8Array[]): Uint8Array; /** Convert a transaction from binary. Leaves actions in hex. */ deserializeTransaction(transaction: Uint8Array): any; /** Convert actions to hex */ serializeActions(actions: ser.Action[]): Promise; /** Convert actions from hex */ deserializeActions(actions: ser.Action[]): Promise; /** Convert a transaction from binary. Also deserializes actions. */ deserializeTransactionWithActions(transaction: Uint8Array | string): Promise; /** * Create and optionally broadcast a transaction. * * Named Parameters: * * `broadcast`: broadcast this transaction? * * `sign`: sign this transaction? * * `useOldRPC`: use old RPC push_transaction, rather than new RPC send_transaction? * * `useOldSendRPC`: use old RPC /v1/chain/send_transaction, rather than new RPC /v1/chain/send_transaction2? * * `readOnly`: read only, nothing modified * * `returnFailureTrace`: return partial traces on failed transactions? * * `retryTrxNumBlocks`: request node to retry transaction until in a block of given height, blocking call? * * `retryIrreversible`: request node to retry transaction until it is irreversible or expires, blocking call? * * If both `blocksBehind` and `expireSeconds` are present, * then fetch the block which is `blocksBehind` behind head block, * use it as a reference for TAPoS, and expire the transaction `expireSeconds` after that block's time. * * `searchBlocksAhead`: only for testing, on single producer nodes, there is only one irreversible block, * and without the need for consensus irreversible blocks don't live long. * This option makes corrections to look at the latest block to build Tapos * @returns node response if `broadcast`, `{signatures, serializedTransaction}` if `!broadcast` */ transact(transaction: any, { broadcast, sign, blocksBehind, searchBlocksAhead, expireSeconds, useOldRPC, useOldSendRPC, readOnly, returnFailureTrace, retryTrxNumBlocks, retryIrreversible, }?: { broadcast?: boolean; sign?: boolean; blocksBehind?: number; searchBlocksAhead?: number; expireSeconds?: number; useOldRPC?: boolean; useOldSendRPC?: boolean; readOnly?: boolean; returnFailureTrace?: boolean; retryTrxNumBlocks?: number; retryIrreversible?: boolean; }): Promise; /** Broadcast a signed transaction using push_transaction RPC */ pushSignedTransaction({ signatures, serializedTransaction, serializedContextFreeData, }: PushTransactionArgs): Promise; /** Broadcast a signed transaction using send_transaction RPC */ sendSignedTransaction({ signatures, serializedTransaction, serializedContextFreeData, }: PushTransactionArgs): Promise; /** Broadcast a signed transaction using send_transaction2 RPC*/ sendSignedTransaction2({ return_failure_trace, retry_trx, retry_trx_num_blocks, transaction: { signatures, serializedTransaction, serializedContextFreeData }, }: SendTransaction2Args): Promise; sendReadonlyTransaction({ signatures, serializedTransaction, serializedContextFreeData, }: PushTransactionArgs): Promise; private hasRequiredTaposFields; }