UNPKG

kuber-client

Version:

Javascript client library for kuber server

58 lines (57 loc) 4.07 kB
import { QueryAPIProvider, SubmitAPIProvider } from "libcardano-wallet"; import { CommonProtocolParameters, CommonTxObject } from "libcardano-wallet/utils/types"; import { HexString } from "libcardano/cardano/serialization"; import { TxInput, UTxO } from "libcardano/cardano/serialization/txinout"; import { Cip30, Cip30Provider } from "libcardano-wallet/cip30"; import { SignTxResult } from "libcardano-wallet/cip30/types"; export declare abstract class KuberProvider implements SubmitAPIProvider, QueryAPIProvider { abstract submitTx(tx: HexString): Promise<any>; abstract queryUTxOByAddress(addresss: string): Promise<UTxO[]>; abstract queryUTxOByTxIn(txIn: string): Promise<UTxO[]>; abstract queryProtocolParameters(): Promise<CommonProtocolParameters>; /** * Build a transaction with kuber. * The built transaction will already have exact min-fee, exact execution-units and extra change output if necessary. * The transaction will be ready to be signed and submitted. * **Note** It important to remember that the transaction returned by kuber api * and the transaction returned by kuber-client might be different due to reason mentioned here * <a href="https://github.com/Emurgo/cardano-serialization-lib/issues/429">cardano-serialization-lib/issues</a> * @param cip30Instance Browser cip30 provider instance obtained with enable() * @param buildRequest Object following Kuber's transaction builder JSON spec * @param autoAddCollateral Add collateral from provider. Kuber automatically picks collateral. * set this to true if you want to specify exact collateral utxo. * @returns A new rejected Promise. */ abstract buildTx(txBuilder: any, submit: boolean): Promise<CommonTxObject>; /** * Build a transaction with kuber. This function adds the available Utxos in the wallet to selection * @param cip30Instance Browser cip30 provider instance obtained with enable() * @param buildRequest Object following Kuber's transaction builder JSON spec * @param autoAddCollateral Add collateral from provider. Kuber automatically picks collateral. * set this to true if you want to specify exact collateral utxo. * minimumLovelace * @returns A new rejected Promise. */ buildWithWallet(cip30OrProvider: Cip30 | Cip30Provider, buildRequest: Record<string, any>, autoAddCollateral?: boolean, estimatedSpending?: number | bigint): Promise<CommonTxObject>; buildAndSignWithWallet(cip30OrProvider: Cip30 | Cip30Provider, buildRequest: Record<string, any>, autoAddCollateral?: boolean, estimatedSpending?: number | bigint): Promise<SignTxResult>; buildAndSubmitWithWallet(cip30OrProvider: Cip30 | Cip30Provider, buildRequest: Record<string, any>, autoAddCollateral?: boolean, estimatedSpending?: number | bigint): Promise<SignTxResult>; /** * Waits for a transaction output to vanish. * @param utxo The transaction ID or UTxO identifier. * @param pollIntervalMs The interval in milliseconds to poll for the UTxO. * @param timeoutMs The maximum time in milliseconds to wait. * @returns A promise that resolves with the total time spent waiting in milliseconds when the UTxO vanishes. */ waitForUtxoConsumption(txin: TxInput, timeoutMs?: number, logPoll?: boolean, pollIntervalMs?: number): Promise<number>; /** * Waits for a transaction to be confirmed by querying UTxO by TxIn. * Confirmation is determined by checking if the query returns more than one UTxO. * * @param txHash - The transaction hash (without the #0). * @param timeoutMs - Timeout in milliseconds. * @param pollIntervalMs - Polling interval in milliseconds (default: 3000ms). * @param logPoll - If true, logs the polling status. * @returns A Promise that resolves with the total time spent waiting in milliseconds if confirmed, or rejects on timeout. */ waitForTxConfirmation(txHash: string, timeoutMs?: number, logPoll?: boolean, pollIntervalMs?: number): Promise<number>; }