UNPKG

@signumjs/core

Version:

Principal package with functions and models for building Signum Network applications.

85 lines (84 loc) 3.75 kB
/** * Copyright (c) 2019 Burst Apps Team * Modified (c) 2023 Signum Network */ import { ChainServiceSettings } from './chainServiceSettings'; /** * The send arguments for {@link ChainService.send} * * @category args */ export interface SendArgs { /** * Setting this option to `true`, skips the additional security check, i.e. the verification of the * unsigned transaction bytes, which detects tampered node responses. By default, the option is `false`. * Usually, you won't use this option, but can be useful when a method cannot be verified, * because the verification is not implemented yet. * */ skipAdditionalSecurityCheck?: boolean; [key: string]: any; } /** * Generic Chain Service class. * * This class can be used to call the chain api directly, in case a function is * not supported yet by SignumJS. Usually, you won't need to do it. * * * * */ export declare class ChainService { /** * Creates Service instance * @param settings The settings for the service */ constructor(settings: ChainServiceSettings); settings: ChainServiceSettings; private readonly _relPath; private static throwAsHttpError; /** * Mounts an API conformant endpoint of format `<host>?requestType=getBlock&height=123` * * @see https://docs.signum.network/signum/node-http-api * * @param {string} method The method name for `requestType` * @param {any} data A JSON object which will be mapped to url params * @return {string} The mounted url (without host) */ toApiEndpoint(method: string, data?: object): string; /** * Requests a query to the configured chain node * @param {string} method The method according https://europe.signum.network/api-doc/ * @param {any} args A JSON object which will be mapped to url params * @param {any} options The optional request configuration for the passed Http client * (default is [AxiosRequestConfig](https://axios-http.com/docs/req_config) ) * @return {Promise<T>} The response data of success * @throws HttpError in case of failure */ query<T>(method: string, args?: any, options?: any): Promise<T>; /** * Send data to chain node * @param {string} method The method according https://europe.signum.network/api-doc/. * Note that there are only a few POST methods * @param {SendArgs} args A JSON object which will be mapped to url params * @param {any} body An object with key value pairs to submit as post body * @param {any} options The optional request configuration for the passed Http client * (default is [AxiosRequestConfig](https://axios-http.com/docs/req_config) ) * @return {Promise<T>} The response data of success * @throws HttpError in case of failure */ send<T>(method: string, args?: SendArgs, body?: object, options?: any): Promise<T>; private faultTolerantRequest; /** * Selects the fastest responding host from the configured reliable node hosts. * @param reconfigure An optional flag to set automatic reconfiguration. Default is `false` * Attention: Reconfiguration works only, if you use the default http client. Otherwise, you need to reconfigure manually! * @param checkMethod The optional API method to be called. This applies only for GET methods. Default is `getBlockchainStatus` * @param timeout The optional amount of time in milliseconds to check. Default is 10_000 * @returns Promise resolving to the selected host * @throws Error if no reliable hosts are configured or if all hosts fail */ selectBestHost(reconfigure?: boolean, timeout?: number, checkMethod?: string): Promise<string>; }