UNPKG

@archwayhq/arch3-core

Version:

Core library to interact with Archway Network

88 lines (87 loc) 4.26 kB
import { Pubkey } from '@cosmjs/amino'; import { EncodeObject } from '@cosmjs/proto-signing'; import { CometClient } from '@cosmjs/tendermint-rpc'; import { SimulateResponse } from 'cosmjs-types/cosmos/tx/v1beta1/service'; import { BlockTracking, ContractMetadata, ContractPremium, EstimateTxFees, OutstandingRewards, RewardsPool, RewardsRecord } from './types'; /** * Interface for querying the Archway modules. */ export interface IArchwayQueryClient { /** * Queries the rewards tracking data for the current block height. * * @returns The current block rewards tracking information. */ getBlockRewardsTracking(): Promise<BlockTracking>; /** * Queries a contract metadata for information on the rewards destination. * * @param contractAddress - Contract address to query the metadata for. * @returns The contract metadata. */ getContractMetadata(contractAddress: string): Promise<ContractMetadata | undefined>; /** * Queries the premium fee for a contract. * * @param contractAddress - Contract address to query the premium for. * @returns The contract premium data. */ getContractPremium(contractAddress: string): Promise<ContractPremium>; /** * Queries the transaction fees estimation for a given gas limit. * Optionally takes in contract address to include the flat fees in the estimate. * * @param gasLimit - Gas limit to estimate the fees for. * @param contractAddress - Contract address to include the flat fees in the estimate. * @returns The estimated transaction fees for the lastest block. */ getEstimateTxFees(gasLimit?: number, contractAddress?: string): Promise<EstimateTxFees>; /** * Queries the unclaimed rewards available for a given address. * * @param rewardsAddress - address set in a contract's metadata to receive rewards * @returns The outstanding rewards for the given address. */ getOutstandingRewards(rewardsAddress: string): Promise<OutstandingRewards>; /** * Queries the pool with undistributed rewards and the treasury pool funds. * * @returns The rewards pool information. */ getRewardsPool(): Promise<RewardsPool>; /** * Queries all available rewards stored for a given address set in a contract's metadata. * * @param rewardsAddress - Address set in a contract's metadata to receive rewards. * @returns All rewards records for the given address. * * @see {@link IArchwayQueryClient.getContractMetadata} */ getAllRewardsRecords(rewardsAddress: string): Promise<readonly RewardsRecord[]>; /** * Simulates the transaction. * It uses `payer` and `granter` arguments during the simulation, * to support Archway-specific `cw-fees` mechanics and include gas * the `SudoMsg::CwGrant` message consumes into the estimation. * * @param messages - The messages to include in the transaction for simulating the gas wanted. * The messages types should be registered in the {@link SigningArchwayClient.registry} * when the client is instantiated. * @param memo - Optional memo to add to the transaction. * @param signer - Public key of the account to be used as the signer in the gas simulation. * The signer must be able to sign with this address. * @param sequence - Number of transactions sent from the signer. * @param granter - The granter address that is used for paying with feegrants. * @param payer - The fee payer address. The payer must have signed the transaction. * @returns A {@link SimulateResponse}. */ simulateTx(messages: readonly EncodeObject[], memo: string | undefined, signer: Pubkey, sequence: number, granter?: string, payer?: string): Promise<SimulateResponse>; } /** * Created a facade for querying archway modules using the * {@link QueryClient} extended with the {@link RewardsExtension}. * * @param cometClient - A CometBFT client for a given endpoint. * @returns A new {@link IArchwayQueryClient} implementation. */ export declare function createArchwayQueryClient(cometClient: CometClient | undefined): IArchwayQueryClient;