@ledgerhq/coin-stellar
Version:
Ledger Stellar Coin integration
86 lines • 3.73 kB
TypeScript
import type { Operation, Page } from '@ledgerhq/coin-module-framework/api/types';
import type { CacheRes } from '@ledgerhq/live-network/cache';
import { Horizon } from '@stellar/stellar-sdk';
import { type BalanceAsset, type NetworkInfo, type RawOperation, type Signer, NetworkCongestionLevel } from '../types';
/**
* Register logging and URL-fix interceptors on Horizon.AxiosClient.
* Must be called once after coinConfig is initialised (i.e. inside createApi).
*
* Logging is gated on coinConfig.enableNetworkLogs (driven by the ENABLE_NETWORK_LOGS env var).
* Horizon.AxiosClient uses feaxios internally, so we type the callbacks via the inferred
* InterceptorManager types rather than importing live-network's axios-typed interceptors.
*/
export declare function registerHorizonInterceptors(): void;
export declare function useConfigHostAndProtocol(url: string): string;
export declare function getAccountSpendableBalance(balance: BigNumber, account: Horizon.ServerApi.AccountRecord): Promise<BigNumber>;
export declare function fetchBaseFee(): Promise<{
baseFee: number;
recommendedFee: number;
networkCongestionLevel: NetworkCongestionLevel;
}>;
/**
* Get all account-related data
*
* @async
* @param {string} addr
*/
export declare function fetchAccount(addr: string): Promise<{
blockHeight: number;
balance: BigNumber;
spendableBalance: BigNumber;
assets: BalanceAsset[];
}>;
/**
* Fetch operations for a single account from indexer
*
* @param {string} accountId
* @param {string} addr
* @param {string} order - "desc" or "asc" order of returned records
* @param {string} cursor - point to start fetching records
* @param {number} maxOperations - maximum number of operations to return, stops fetching after reaching this threshold
*
* @return {Operation[]}
*/
export declare function fetchAllOperations(accountId: string, addr: string, order: 'asc' | 'desc', cursor?: string, maxOperations?: number): Promise<Operation[]>;
export declare function fetchOperations({ accountId, addr, minHeight, order, cursor, limit, }: {
accountId: string;
addr: string;
minHeight: number;
order: 'asc' | 'desc';
cursor: string | undefined;
limit?: number | undefined;
}): Promise<Page<Operation>>;
export declare function fetchAccountNetworkInfo(account: string): Promise<NetworkInfo>;
export declare function fetchSequence(address: string): Promise<BigNumber>;
export declare function fetchSigners(account: string): Promise<Signer[]>;
export declare function broadcastTransaction(signedTransaction: string): Promise<string>;
export declare function loadAccount(addr: string): Promise<Horizon.AccountResponse | null>;
export declare function getLastBlock(): Promise<{
height: number;
hash: string;
time: Date;
}>;
/**
* Loads a single ledger (closed block) by sequence number.
*
* Horizon `GET /ledgers/{sequence}` returns one ledger resource, not a page with `records`;
* do not read `records[0]` from this `.call()` result.
*
* @throws Error when the ledger does not exist (Horizon 404).
*/
export declare function fetchLedgerRecord(sequence: number): Promise<Horizon.ServerApi.LedgerRecord>;
/**
* Returns all operations included in `ledgerSequence`, ascending, including failed txs,
* with joined transaction payloads (same pattern as account operation listing).
*
* @throws Error when the ledger does not exist (Horizon 404).
*/
export declare function fetchAllLedgerOperations(ledgerSequence: number): Promise<RawOperation[]>;
export declare const getRecipientAccount: CacheRes<Array<{
recipient: string;
}>, {
id: string | null;
isMuxedAccount: boolean;
assetIds: string[];
} | null>;
//# sourceMappingURL=horizon.d.ts.map