import { Address, SmartContractQuery, SmartContractQueryResponse, Token, Transaction, TransactionOnNetwork, TransactionStatus } from "../core"; import { AccountOnNetwork, AccountStorage, AccountStorageEntry } from "./accounts"; import { NetworkConfig } from "./networkConfig"; import { NetworkStatus } from "./networkStatus"; import { AwaitingOptions, TransactionCostResponse } from "./resources"; import { DefinitionOfFungibleTokenOnNetwork, DefinitionOfTokenCollectionOnNetwork } from "./tokenDefinitions"; import { TokenAmountOnNetwork } from "./tokens"; /** * An interface that defines the endpoints of an HTTP API Provider. */ export interface INetworkProvider { /** * Fetches the Network configuration. */ getNetworkConfig(): Promise; /** * Fetches the Network status. */ getNetworkStatus(): Promise; /** * Fetches the state of an account. */ getAccount(address: Address): Promise; /** * Fetches the storage (key-value pairs) of an account. */ getAccountStorage(address: Address): Promise; /** * Fetches a specific storage entry of an account. */ getAccountStorageEntry(address: Address, entryKey: string): Promise; /** * Waits until an account satisfies a given condition. * Can throw: * - ErrAwaitConditionNotReached */ awaitAccountOnCondition(address: Address, condition: (account: AccountOnNetwork) => boolean, options?: AwaitingOptions): Promise; /** * Broadcasts an already-signed transaction. */ sendTransaction(tx: Transaction): Promise; /** * Simulates the processing of an already-signed transaction. * */ simulateTransaction(tx: Transaction): Promise; /** * Estimates the cost of a transaction. * */ estimateTransactionCost(tx: Transaction): Promise; /** * Broadcasts a list of already-signed transactions. */ sendTransactions(txs: Transaction[]): Promise<[number, string[]]>; /** * Fetches the state of a transaction. */ getTransaction(txHash: string, withProcessStatus?: boolean): Promise; /** * Fetches the status of a transaction. */ getTransactionStatus(txHash: string): Promise; /** * Waits until the transaction is completely processed. * Can throw: * - ErrAwaitConditionNotReached */ awaitTransactionCompleted(transactionHash: string, options?: AwaitingOptions): Promise; /** * Waits until the transaction satisfies a given condition. * Can throw: * - ErrAwaitConditionNotReached */ awaitTransactionOnCondition(transactionHash: string, condition: (account: TransactionOnNetwork) => boolean, options?: AwaitingOptions): Promise; /** * Fetches the balance of an account, for a given token. */ getTokenOfAccount(address: Address, token: Token): Promise; /** * Fetches data about the fungible tokens held by an account. */ getFungibleTokensOfAccount(address: Address, pagination?: IPagination): Promise; /** * Fetches data about the non-fungible tokens held by account. */ getNonFungibleTokensOfAccount(address: Address, pagination?: IPagination): Promise; /** * Fetches the definition of a fungible token. */ getDefinitionOfFungibleToken(tokenIdentifier: string): Promise; /** * Fetches the definition of a SFT (including Meta ESDT) or NFT. */ getDefinitionOfTokenCollection(collection: string): Promise; /** * Queries a Smart Contract - runs a pure function defined by the contract and returns its results. */ queryContract(query: SmartContractQuery): Promise; /** * Performs a generic GET action against the provider (useful for new HTTP endpoints). */ doGetGeneric(resourceUrl: string): Promise; /** * Performs a generic POST action against the provider (useful for new HTTP endpoints). */ doPostGeneric(resourceUrl: string, payload: any): Promise; } export interface IPagination { from: number; size: number; }