import BigNumber from "bignumber.js"; import Wallet from "./Wallet"; import SignedTransaction from "./SignedTransaction"; import * as Validator from "./data/Validator"; import * as Util from "./data/Util"; import Amount from "./data/Amount"; import * as Converter from "./data/Converter"; import HttpProvider from "./transport/http/HttpProvider"; import * as Hexadecimal from "./data/Hexadecimal"; import HttpCall from "./transport/http/client/HttpCall"; import Block from "./data/Formatter/Block"; import ScoreApiList from "./data/Formatter/ScoreApiList"; import Transaction from "./data/Formatter/Transaction"; import TransactionResult from "./data/Formatter/TransactionResult"; import { IcxTransaction, MessageTransaction } from "./builder"; import { DepositTransaction, DeployTransaction } from "./builder"; import { Call, CallTransaction } from "./builder"; import { Hash } from "./types/hash"; import BTPNetworkInfo from "./data/Formatter/BTPNetworkInfo"; import BTPNetworkTypeInfo from "./data/Formatter/BTPNetworkTypeInfo"; import BTPSourceInformation from "./data/Formatter/BTPSourceInformation"; import Monitor from "./transport/monitor/Monitor"; import BlockNotification from "./data/Formatter/BlockNotification"; import EventNotification from "./data/Formatter/EventNotification"; import BTPNotification from "./data/Formatter/BTPNotification"; import BlockMonitorSpec from "./transport/monitor/BlockMonitorSpec"; import EventMonitorSpec from "./transport/monitor/EventMonitorSpec"; import BTPMonitorSpec from "./transport/monitor/BTPMonitorSpec"; import ScoreStatus from "./data/Formatter/ScoreStatus"; import NetworkInfo from "./data/Formatter/NetworkInfo"; /** * Class which provides APIs of ICON network. */ export default class IconService { static IconAmount: typeof Amount; static IconBuilder: { CallBuilder: typeof import("./builder").CallBuilder; IcxTransactionBuilder: typeof import("./builder").IcxTransactionBuilder; CallTransactionBuilder: typeof import("./builder").CallTransactionBuilder; DeployTransactionBuilder: typeof import("./builder").DeployTransactionBuilder; MessageTransactionBuilder: typeof import("./builder").MessageTransactionBuilder; DepositTransactionBuilder: typeof import("./builder").DepositTransactionBuilder; }; static IconConverter: typeof Converter; static IconWallet: typeof Wallet; static IconUtil: typeof Util; static SignedTransaction: typeof SignedTransaction; static HttpProvider: typeof HttpProvider; static IconHexadecimal: typeof Hexadecimal; static IconValidator: typeof Validator; private provider; /** * Creates an instance of IconService. * @param {HttpProvider} provider - The HttpProvider instance. */ constructor(provider: HttpProvider); /** * Get the total number of issued coins. * @param {Hash} [height] - block Height. * @return {HttpCall} The HttpCall instance for icx_getTotalSupply JSON-RPC API request. */ getTotalSupply(height?: Hash): HttpCall; /** * Get the balance of the address. * @param {string} address - The EOA or SCORE address. * @param {Hash} [height] - block Height. * @return {HttpCall} The HttpCall instance for icx_getBalance JSON-RPC API request. */ getBalance(address: string, height?: Hash): HttpCall; /** * @description Get the block information. * @param {BigNumber} value The value of block number * @return {object} The HttpCall instance for icx_getBlockByHeight JSON-RPC API request. */ getBlockByHeight(value: BigNumber): HttpCall; /** * @description Get the block information. * @param {string} value The value of block hash * @return {object} The HttpCall instance for icx_getBlockByHash JSON-RPC API request. */ getBlockByHash(value: string): HttpCall; /** * @description Get the last block information. * @return {object} The HttpCall instance for icx_getLastBlock JSON-RPC API request. */ getLastBlock(): HttpCall; /** * @description Get the SCORE API list. * @param {string} address SCORE address * @param {Hash} [height] block Height * @return {array} The HttpCall instance for icx_getScoreApi JSON-RPC API request. */ getScoreApi(address: string, height?: Hash): HttpCall; /** * @description Get the SCORE status * @param {string} address SCORE address * @param {Hash} [height] block Height * @return {object} The HttpCall instance for icx_getScoreStatus JSON-RPC API request. */ getScoreStatus(address: string, height?: Hash): HttpCall; /** * Get the transaction information. * @param {string} hash - The transaction hash. * @return {HttpCall} The HttpCall instance for icx_getTransactionByHash JSON-RPC API request. */ getTransaction(hash: string): HttpCall; /** * Get the result of transaction by transaction hash. * @param {string} hash - The transaction hash. * @return {HttpCall} The HttpCall instance for icx_getTransactionResult JSON-RPC API request. */ getTransactionResult(hash: string): HttpCall; /** * Send a transaction that changes the states of address. * @param {SignedTransaction} signedTransaction - Parameters including signature. * @return {HttpCall} The HttpCall instance for icx_sendTransaction JSON-RPC API request. */ sendTransaction(signedTransaction: SignedTransaction): HttpCall; /** * Returns an estimated step of how much step is necessary to allow the transaction to complete. * @param {SignedTransaction} transaction - Parameters * @return {HttpCall} The HttpCall instance for debug_estimateStep JSON-RPC API request. */ estimateStep(transaction: IcxTransaction | MessageTransaction | DepositTransaction | DeployTransaction | CallTransaction): HttpCall; /** * Calls a SCORE API just for reading. * @param {Call} call - The call instance exported by CallBuilder * @return {HttpCall} The HttpCall instance for icx_call JSON-RPC API request. */ call(call: Call): HttpCall; /** * sends a transaction like `icx_sendTransaction`, then it will wait for the result of it for specified time. If the timeout isn't set by user, it uses `defaultWaitTimeout` of icon node. * @param {SignedTransaction} signedTransaction - Parameters including signature. * @return {HttpCall} The HttpCall instance for icx_sendTransactionAndWait JSON-RPC API request. */ sendTransactionAndWait(signedTransaction: SignedTransaction): HttpCall; /** * It will wait for the result of the transaction for specified time. * If the timeout isn't set by user, it uses `defaultWaitTimeout` of icon node. * @param {string} hash - The transaction hash. * @return {HttpCall} The HttpCall instance for icx_waitTransactionResult JSON-RPC API request. */ waitTransactionResult(hash: string): HttpCall; /** * Get data by hash. It can be used to retrieve data based on the hash algorithm (SHA3-256). Following data can be retrieved by a hash. * BlockHeader with the hash of the block * Validators with BlockHeader.NextValidatorsHash * Votes with BlockHeader.VotesHash * etc… * @param {string} hash - The hash value of the data to retrieve * @return {HttpCall} The HttpCall instance for icx_getDataByHash JSON-RPC API request. */ getDataByHash(hash: string): HttpCall; /** * Get block header for specified height. * @param {BigNumber | string} height - The height of the block. * @return {HttpCall} The HttpCall instance for icx_getBlockHeaderByHeight JSON-RPC API request. */ getBlockHeaderByHeight(height: string | BigNumber): HttpCall; /** * Get votes for the block specified by height. * @param {BigNumber} height - The height of the block. * @return {HttpCall} The HttpCall instance for icx_getVotesByHeight JSON-RPC API request. */ getVotesByHeight(height: string | BigNumber): HttpCall; /** * Get proof for the receipt * @param {string} hash - The hash value of the block including the result * @param {string} index - Index of the receipt in the block * @return {HttpCall} The HttpCall instance for icx_getProofForResult JSON-RPC API request. */ getProofForResult(hash: string, index: string | BigNumber): HttpCall; /** * Get proof for the receipt and the events in it * @param {string} hash - The hash value of the block including the result * @param index - Index of the receipt in the block * @param events - List of indexes of the events in the receipt * @return {HttpCall} The HttpCall instance for icx_getProofForEvents JSON-RPC API request. */ getProofForEvents(hash: string, index: string | BigNumber, events: Array): HttpCall; /** * Get BTP network information. * @param id - network id * @param height - Main block height * @return {HttpCall} The HttpCall instance for btp_getNetworkInfo JSON-RPC API request. */ getBTPNetworkInfo(id: string | BigNumber, height?: string | BigNumber): HttpCall; /** * Get BTP network type information. * @param id - Network type id * @param height - Main block height * @return {HttpCall} The HttpCall instance for btp_getNetworkTypeInfo JSON-RPC API request. */ getBTPNetworkTypeInfo(id: string | BigNumber, height?: string | BigNumber): HttpCall; /** * Get BTP messages * @param networkID - BTP network ID * @param height - Main block height * @return {HttpCall} The HttpCall instance for btp_getMessages JSON-RPC API request. */ getBTPMessages(networkID: string | BigNumber, height: string | BigNumber): HttpCall>; /** * Get BTP block header * @param networkID - Network id * @param height - Main block height * @return {HttpCall} The HttpCall instance for btp_getHeader JSON-RPC API request. */ getBTPHeader(networkID: string | BigNumber, height: string | BigNumber): HttpCall; /** * Get BTP block proof * @param networkID - Network id * @param height - Main block height * @return {HttpCall} The HttpCall instance for btp_getProof JSON-RPC API request. */ getBTPProof(networkID: string | BigNumber, height: string | BigNumber): HttpCall; /** * Get source network information * @return {HttpCall} The HttpCall instance for btp_getSourceInformation JSON-RPC API request. */ getBTPSourceInformation(): HttpCall; /*** * Get basic network Information. */ getNetworkInfo(): HttpCall; /** * Get the transaction trace. * @param {string} hash - The transaction hash. * @return {HttpCall} The HttpCall instance for debug_getTrace JSON-RPC API request. */ getTrace(hash: string): HttpCall; /*** * Get monitor for block. * @param monitorSpec * @param ondata - Callback to be called when Monitor successfully got messages * @param onerror - Callback to be called when a network error or os error occurs * @return {Monitor} The Monitor instance for `block` websocket API */ monitorBlock(monitorSpec: BlockMonitorSpec, ondata: (notification: BlockNotification) => void, onerror: (error: any) => void): Monitor; /*** * Get monitor for event * @param monitorSpec * @param ondata - Callback to be called when Monitor successfully got messages * @param onerror - Callback to be called when a network error or os error occurs * @param onprogress - Callback to be called when the block is processed * @return {Monitor} The Monitor instance for `event` websocket API */ monitorEvent(monitorSpec: EventMonitorSpec, ondata: (notification: EventNotification) => void, onerror: (error: any) => void, onprogress?: (height: BigNumber) => void): Monitor; /*** * Get monitor for btp * @param monitorSpec * @param ondata - Callback to be called when Monitor successfully got messages * @param onerror - Callback to be called when a network error or os error occurs * @param onprogress - Callback to be called when the block is processed * @return {Monitor} The Monitor instance for `btp` websocket API */ monitorBTP(monitorSpec: BTPMonitorSpec, ondata: (notification: BTPNotification) => void, onerror: (error: any) => void, onprogress?: (height: BigNumber) => void): Monitor; }