UNPKG

@roochnetwork/rooch-sdk

Version:
132 lines (131 loc) 7.07 kB
import { Signer } from '../crypto/index.js'; import { CreateSessionArgs, Session } from '../session/index.js'; import { BitcoinAddress, BitcoinNetowkType, RoochAddress } from '../address/index.js'; import { address, Bytes, u64 } from '../types/index.js'; import { RoochTransport } from './transportInterface.js'; import { CallFunctionArgs, TypeArgs, Transaction } from '../transactions/index.js'; import { AnnotatedFunctionResultView, BalanceInfoView, ExecuteTransactionResponseView, GetBalanceParams, GetStatesParams, ListStatesParams, PaginatedStateKVViews, PaginationArguments, PaginationResult, SessionInfoView, ObjectStateView, QueryUTXOsParams, PaginatedUTXOStateViews, PaginatedInscriptionStateViews, QueryInscriptionsParams, GetBalancesParams, PaginatedBalanceInfoViews, QueryObjectStatesParams, PaginatedIndexerObjectStateViews, QueryTransactionsParams, PaginatedTransactionWithInfoViews, PaginatedEventViews, GetEventsByEventHandleParams, QueryEventsParams, PaginatedIndexerEventViews, ModuleABIView, GetModuleABIParams, BroadcastTXParams, GetObjectStatesParams, GetFieldStatesParams, ListFieldStatesParams, GetTransactionsByHashParams, TransactionWithInfoView, GetTransactionsByOrderParams, RepairIndexerParams, SyncStatesParams, PaginatedStateChangeSetWithTxOrderViews, DryRunRawTransactionParams, DryRunTransactionResponseView, EventFilterView, TransactionFilterView, IndexerEventView } from './types/index.js'; /** * Configuration options for the RoochClient * You must provide either a `url` or a `transport` */ export type RoochClientOptions = NetworkOrTransport; type NetworkOrTransport = { url: string; transport?: never; } | { transport: RoochTransport; url?: never; }; declare const ROOCH_CLIENT_BRAND: unique symbol; export declare function isRoochClient(client: unknown): client is RoochClient; export interface SubscriptionEventParams { filter?: EventFilterView; onError?: (error: Error) => void; signal?: AbortSignal; } export interface SubscriptionTransactionParams { filter?: TransactionFilterView; onError?: (error: Error) => void; signal?: AbortSignal; } export type Unsubscribe = () => Promise<boolean>; export declare class RoochClient { protected chainID: bigint | undefined; protected transport: RoochTransport; get [ROOCH_CLIENT_BRAND](): boolean; getTransport(): RoochTransport; /** * Establish a connection to a rooch RPC endpoint * * @param options configuration options for the API Client */ constructor(options: RoochClientOptions); getRpcApiVersion(): Promise<string | undefined>; getChainId(): Promise<u64>; executeViewFunction(input: CallFunctionArgs): Promise<AnnotatedFunctionResultView>; dryrun(input: DryRunRawTransactionParams): Promise<DryRunTransactionResponseView>; signAndExecuteTransaction({ transaction, signer, option, }: { transaction: Transaction | Bytes; signer: Signer; option?: { withOutput: boolean; }; }): Promise<ExecuteTransactionResponseView>; repairIndexer(input: RepairIndexerParams): Promise<void>; syncStates(input: SyncStatesParams): Promise<PaginatedStateChangeSetWithTxOrderViews>; getStates(input: GetStatesParams): Promise<ObjectStateView[]>; listStates(input: ListStatesParams): Promise<PaginatedStateKVViews>; getModuleAbi(input: GetModuleABIParams): Promise<ModuleABIView>; getEvents(input: GetEventsByEventHandleParams): Promise<PaginatedEventViews>; queryEvents(input: QueryEventsParams): Promise<PaginatedIndexerEventViews>; queryInscriptions(input: QueryInscriptionsParams): Promise<PaginatedInscriptionStateViews>; queryUTXO(input: QueryUTXOsParams): Promise<PaginatedUTXOStateViews>; broadcastBitcoinTX(input: BroadcastTXParams): Promise<string>; getObjectStates(input: GetObjectStatesParams): Promise<ObjectStateView[]>; getFieldStates(input: GetFieldStatesParams): Promise<ObjectStateView[]>; listFieldStates(input: ListFieldStatesParams): Promise<PaginatedStateKVViews>; queryObjectStates(input: QueryObjectStatesParams): Promise<PaginatedIndexerObjectStateViews>; getTransactionsByHash(input: GetTransactionsByHashParams): Promise<TransactionWithInfoView>; getTransactionsByOrder(input: GetTransactionsByOrderParams): Promise<PaginatedTransactionWithInfoViews>; queryTransactions(input: QueryTransactionsParams): Promise<PaginatedTransactionWithInfoViews>; getSequenceNumber(address: string): Promise<u64>; /** * Get the total coin balance for one coin type, owned by the address owner. */ getBalance(input: GetBalanceParams): Promise<BalanceInfoView>; getBalances(input: GetBalancesParams): Promise<PaginatedBalanceInfoViews>; transfer(input: { signer: Signer; recipient: address; amount: number | bigint; coinType: TypeArgs; }): Promise<ExecuteTransactionResponseView>; transferObject(input: { signer: Signer; recipient: address; objectId: string; objectType: TypeArgs; }): Promise<ExecuteTransactionResponseView>; resolveBTCAddress(input: { roochAddress: string | RoochAddress; network: BitcoinNetowkType; }): Promise<BitcoinAddress | undefined>; createSession({ sessionArgs, signer }: { sessionArgs: CreateSessionArgs; signer: Signer; }): Promise<Session>; removeSession({ authKey, signer }: { authKey: string; signer: Signer; }): Promise<boolean>; sessionIsExpired({ address, authKey, }: { address: address; authKey: string; }): Promise<boolean>; getAllModules({ package_address, limit, cursor, }: { package_address: address; } & PaginationArguments<string>): Promise<Map<string, string>>; getSessionKeys({ address, limit, cursor, }: { address: address; } & PaginationArguments<string>): Promise<PaginationResult<string, SessionInfoView>>; subscribeEventWithSSE(input: SubscriptionEventParams & { /** function to run when we receive a notification of a new event matching the filter */ onMessage: (event: IndexerEventView) => void; }): Promise<() => Promise<boolean>>; subscribeTransactionWithSSE(input: SubscriptionEventParams & { /** function to run when we receive a notification of a new event matching the filter */ onMessage: (event: IndexerEventView) => void; }): Promise<() => Promise<boolean>>; subscribeEvent(input: SubscriptionEventParams & { /** function to run when we receive a notification of a new event matching the filter */ onMessage: (event: IndexerEventView) => void; }): Promise<() => Promise<boolean>>; subscribeTransaction(input: SubscriptionTransactionParams & { /** function to run when we receive a notification of a new event matching the filter */ onMessage: (message: TransactionWithInfoView) => void; }): Promise<() => Promise<boolean>>; events(): void; destroy(): void; } export {};