UNPKG

@zlattice/lattice-js

Version:

Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)

136 lines 5.37 kB
import { ProposalState } from "../common/constants.js"; import { ContractLifecycleProposal, DBlock, LatestBlock, ModifyChainConfigurationProposal, Proposal, Receipt, SubchainProposal, Transaction } from "../common/types/index.js"; import { AxiosRequestHeaders } from "axios"; interface JsonRpcError { code?: number; message?: string; } interface JsonRpcResponse<T> { id: number; jsonrpc: string; result?: T; error?: JsonRpcError; } interface JsonRpcBody { id: number; jsonrpc: string; method: string; params?: any[]; } declare class HttpProvider { baseUrl: string; constructor(baseUrl: string); post<T>(jsonRpcBody: JsonRpcBody, headers?: AxiosRequestHeaders | Record<string, string | string[]>): Promise<JsonRpcResponse<T>>; private rawPost; } interface HttpClient { httpProvider: HttpProvider; /** * Get the latest block info from chain * * @param chainId - The chain id * @param accountAddress - The account address * @returns The latest block info */ getLatestBlock(chainId: number, accountAddress: string): Promise<LatestBlock>; /** * Send a transaction to chain * * @param chainId - The chain id * @param transaction - The transaction * @returns The transaction hash */ sendTransaction(chainId: number, transaction: Transaction): Promise<string>; /** * Batch sends transactions to chain * * @param chainId - The chain id * @param transactions - The transactions * @returns The transaction hashes */ batchSendTransactions(chainId: number, transactions: Transaction[]): Promise<string[]>; /** * Get the transaction receipt from chain * * @param chainId - The chain id * @param hash - The transaction hash * @returns The transaction receipt */ getReceipt(chainId: number, hash: string): Promise<Receipt>; /** * Get the latest dblock from chain * * @param chainId - The chain id * @returns The latest dblock */ getLatestDBlock(chainId: number): Promise<DBlock>; /** * Pre-call contract * * @param chainId - The chain id * @param transaction - The unsigned transaction * @returns The receipt */ preCallContract(chainId: number, transaction: Transaction): Promise<Receipt>; /** * Get the contract lifecycle proposals * * @param chainId - The chain id * @param contractAddress - The contract address * @param state - The proposal state * @param startDate - The start date * @param endDate - The end date * @returns The contract lifecycle proposals */ getContractLifecycleProposals(chainId: number, contractAddress: string, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<ContractLifecycleProposal>[]>; /** * Get the modify chain configuration proposals * * @param chainId - The chain id * @param state - The proposal state * @param startDate - The start date * @param endDate - The end date * @returns The modify chain configuration proposals */ getModifyChainConfigurationProposals(chainId: number, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<ModifyChainConfigurationProposal>[]>; /** * Get the subchain proposals * * @param chainId - The chain id * @param state - The proposal state * @param startDate - The start date * @param endDate - The end date * @returns The subchain proposals */ getSubchainProposals(chainId: number, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<SubchainProposal>[]>; } declare class HttpClientImpl implements HttpClient { private provider; httpProvider: HttpProvider; constructor(provider: HttpProvider); /** * Handle json-rpc response. when the response is null, throw error * when the response internal error is not null, throw error * * @param response - The json-rpc response * @returns The result */ private handleJsonRpcResponse; getLatestBlock(chainId: number, accountAddress: string): Promise<LatestBlock>; /** * Send signed transaction to blockchain. * * @param transaction signed transaction * @return transaction hash */ sendTransaction(chainId: number, transaction: Transaction): Promise<string>; batchSendTransactions(chainId: number, transactions: Transaction[]): Promise<string[]>; getReceipt(chainId: number, hash: string): Promise<Receipt>; getLatestDBlock(chainId: number): Promise<DBlock>; preCallContract(chainId: number, transaction: Transaction): Promise<Receipt>; getContractLifecycleProposals(chainId: number, contractAddress: string, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<ContractLifecycleProposal>[]>; getModifyChainConfigurationProposals(chainId: number, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<ModifyChainConfigurationProposal>[]>; getSubchainProposals(chainId: number, state: ProposalState, startDate: Date, endDate: Date): Promise<Proposal<SubchainProposal>[]>; } export { type JsonRpcBody, type JsonRpcResponse, type JsonRpcError, HttpProvider, type HttpClient, HttpClientImpl }; //# sourceMappingURL=http_provider.d.ts.map