import { HealthV2, GetAbiSnapshot, GetVoters, GetCreatedAccounts, GetDeltas, GetTableState, GetCreator, GetActions, GetKeyAccounts, GetTokens, GetTransaction, GetLinks, GetProposals } from "./types/api"; import 'isomorphic-fetch'; import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'; /** * JsonRpc * * @param {string} endpoint hyperion endpoint * @example * * const endpoint = "https://br.eosrio.io" * const rpc = new JsonRpc(endpoint, { fetch }) */ export declare class JsonRpc { endpoint: string; timeout: number; constructor(endpoint: string, args?: { timeout?: number; }); /** * post * * POST `body` to `endpoint + path`. * Throws detailed error information in `RpcError` when available. * * @private */ post(path: string, body: any): Promise; /** * get * * GET `params` to `endpoint + path`. * Throws detailed error information in `RpcError` when available. * * @private */ get(path: string, params: any): Promise; /** * [GET /v2/state/alive](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_alive) * * simple server healthcheck * * @returns {Promise} alive * @example * * const response = await rpc.alive(); * console.log(response); * // => {"status": "OK"} */ alive(): Promise; /** * [GET /v2/history/get_abi_snapshot](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_abi_snapshot) * * fetch contract abi at specific block * * @param {string} contract contract account * @param {number} number target block * @returns {Promise} abi snapshot * @example * * const response = await rpc.get_abi_snapshot("eosio", 200); * console.log(response.version); * // => "eosio::abi/1.0" * * for (const table of response.tables) { * console.log(table); * // => { name: 'producers', index_type: 'i64', key_names: [ 'owner' ], key_types: [ 'uint64' ], type: 'producer_info' } * } */ get_abi_snapshot(contract: string, block: number): Promise; /** * [GET /v2/state/get_voters](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_get_voters) * * get voters * * @param {object} [options={}] Optional parameters * @param {string} [options.producer] filter by voted producer (comma separated) * @param {boolean} [options.proxy] true or false * @param {number} [options.skip] skip [n] actions (pagination) * @param {number} [options.limit] limit of [n] actions per page * @returns {Promise} voters * @example * * const response = await rpc.get_voters({ producer: "eoscafeblock", limit: 100 }); * console.log(response.voters); * // => "[{ * // "account": "guzdkmrtgage", * // "weight": 78434695236505280, * // "last_vote": 64804768 * // }]" */ get_voters(options: any): Promise; /** * [GET /v2/state/get_links](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_links) * * get voters * * @param {string} [account] account to get links for * @returns {Promise} links * @example * * const response = await rpc.get_links("eoscafeblock"); * console.log(response.links); * // => "[{ * "block_num":26088072, * "timestamp":"2019-11-22T23:17:42.000", * "account":"eosriobrazil", * "permission":"claim2", * "code":"eosio", * "action":"voteproducer" * }]" */ get_links(account: string): Promise; /** * [GET /v2/state/get_proposals](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_get_proposals) * * get proposals * * @param {string} [account] account to get proposals for * @param {object} [options={}] Optional parameters * @param {string} [options.proposer] filter by proposer * @param {string} [options.proposal] filter by proposal name * @param {string} [options.account] filter by either requested or provided account * @param {string} [options.requested] filter by requested account * @param {string} [options.provided] filter by provided account * @param {string} [options.track] total results to track (count) [number or true] * @param {number} [options.skip] skip [n] actions (pagination) * @param {number} [options.limit] limit of [n] actions per page * @returns {Promise} proposals */ get_proposals(options: { proposer?: string; proposal?: string; account?: string; requested?: string; provided?: string; executed?: boolean; skip?: number; limit?: number; }): Promise; /** * [GET /v2/history/get_actions](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_actions) * * get actions based on notified account * * @param {string} account notified account * @param {object} [options={}] Optional parameters * @param {string} [options.filter] code::name filter * @param {number} [options.skip] skip [n] actions (pagination) * @param {number} [options.limit] limit of [n] actions per page * @param {string} [options.sort] sort direction * @param {string} [options.after] filter after specified date (ISO8601) * @param {string} [options.before] filter before specified date (ISO8601) * @param {string} [options.transfer_to] transfer filter to * @param {string} [options.transfer_from] transfer filter from * @param {string} [options.transfer_symbol] transfer filter symbol * @param {string} [options.act_name] act name * @param {string} [options.act_account] act account * @returns {Promise} get actions * @example * * const response = await rpc.get_actions("eoscafeblock", { * filter: "eosio.token:*", * skip: 100, * limit: 100, * }); * * for (const action of response.actions) { * console.log(action); * // => { act: { account: 'eosio.token', name: 'transfer', ... } } * } */ get_actions(account: string, options?: { filter?: string; skip?: number; limit?: number; sort?: string; after?: string; before?: string; ["transfer.to"]?: string; ["transfer.from"]?: string; ["transfer.symbol"]?: string; ["act.name"]?: string; ["act.account"]?: string; block_num?: number; }): Promise>; /** * [GET /v2/history/get_created_accounts](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_created_accounts) * * get created accounts * * @param {string} account created account * @returns {Promise} get creator * @example * * const response = await rpc.get_created_accounts("eosnationftw"); * console.log(response); * // => {"accounts": [{"name":"eosnationdsp","trx_id":"728d4a4da36a98d9048080461dacaf975ad083e8158ef84edea60cc755ab2c1a","timestamp":"2019-02-28T22:36:45.000"}, ... ]} */ get_created_accounts(account: string): Promise; /** * [GET /v2/history/get_creator](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_creator) * * get creator * * @param {string} account created account * @returns {Promise} get creator * @example * * const response = await rpc.get_creator("eosnationftw"); * console.log(response); * // => { account: 'eosnationftw', creator: 'gyztcmrvgqge', timestamp: '2018-06-10T13:06:43.500', ... } */ get_creator(account: string): Promise; /** * [GET /v2/history/get_deltas](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_deltas) * * get deltas * * @param {string} code contract account * @param {string} scope table scope * @param {string} table table name * @param {string} payer payer account * @returns {Promise} get deltas * @example * * const response = await rpc.get_deltas("eosio.token", "eosnationftw", "accounts", "eosnationftw"); * console.log(response); * // => { "query_time": 19, "total": { "value": 486, "relation": "eq" }, "deltas": [ ... ] } */ get_deltas(code?: string, scope?: string, table?: string, payer?: string, options?: any): Promise>; /** * [GET /v2/history/get_table_state](https://eos.hyperion.eosrio.io/v2/docs/static/index.html#/history/get_v2_history_get_table_state * * get table state * * @param {string} code contract account * @param {string} table table name * @param {string} block_num target block * @param {string} after_key last key for pagination * @returns {Promise} get table state * @example * * const response = await rpc.get_table_state("eosio.token", "stat", "1000", ""); * console.log(response); * // => { "query_time": 19, "code": "eosio.token", "table": "stat", "block_num": 1000, "next_key": "........ehbo5-5459781",, "results": [ ... ] } */ get_table_state(code: string, table: string, block_num?: number, after_key?: string): Promise>; /** * [GET/v2/state/get_key_accounts](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_get_key_accounts) * * get account by public key * * @param {string} public_key Contract account targeted by the action. * @returns {Promise} key accounts * @example * * const response = await rpc.get_key_accounts("EOS5Mto3Km6BCVxowb6LkkFaT9oaUwLVgswgcxvY4Qgc4rhHry4Tv"); * console.log(response.account_names); * // => [ 'eoscafeblock' ] */ get_key_accounts(public_key: string): Promise; /** * [GET /v2/state/get_tokens](https://eos.hyperion.eosrio.io/v2/docs/index.html#/state/get_v2_state_get_tokens) * * get tokens * * @param {string} account account * @returns {Promise} get tokens * @example * * const response = await rpc.get_tokens("eosnationftw"); * for (const token of response.tokens) { * console.log(token); * // => { symbol: 'ZOS', precision: 4, amount: 140, contract: 'zosdiscounts' } * } */ get_tokens(account: string): Promise; /** * [GET /v2/history/get_transaction](https://eos.hyperion.eosrio.io/v2/docs/index.html#/history/get_v2_history_get_transaction) * * get all actions belonging to the same transaction * * @param {string} id transaction id * @returns {Promise} transaction * @example * * const response = await rpc.get_transaction("42dacd5722001b734be46a2140917e06cd21d42425f927f506c07b4388b07f62"); * for (const action of response.actions) { * console.log(action); * // => { act: { account: 'eosio', name: 'buyrambytes', ... }} * } */ get_transaction(id: string): Promise>; }