@ledgerhq/coin-tezos
Version:
133 lines • 7.49 kB
TypeScript
import type { TezosCoinConfig } from '../config';
import type { APIAccount, APIBlock, APIDelegationType, APIOperation, APIOriginationType, APIRevealType, APIStakingType, APITokenTransfer, APITransactionType, APIUnstakeRequest, AccountsGetOperationsOptions, TokenTransfersGetOptions, APITokenBalance } from './types';
/**
* Builds the TzKT explorer client bound to the given coin config (ADR-019). The caller resolves the
* config from its {@link Context} and passes it in, rather than the client reading a module-level
* singleton.
*/
export declare function createTzktApi(config: TezosCoinConfig): {
getBlockCount(): Promise<number>;
getLastBlock(): Promise<{
hash: string;
level: number;
date: Date;
}>;
getAccountByAddress(address: string): Promise<APIAccount>;
/**
* Returns the total `actualAmount` (mutez) summed over the account's `finalizable`
* unstake requests — the portion of `unstakedBalance` whose unlock cycle has been
* reached and that can be reclaimed via `finalize_unstake`. The complementary
* `unstakedBalance - finalizable` portion is still in the deactivation delay window.
*
* TzKT's account endpoint does not expose this split, so we sum from
* `/v1/staking/unstake_requests`. https://api.tzkt.io/#operation/Staking_GetUnstakeRequests
*
* `limit=1000` covers any realistic number of concurrent finalizable requests for
* a single staker — we do not paginate.
*/
getUnstakeRequestsFinalizable(address: string): Promise<bigint>;
/**
* Pending + finalizable unstake requests, by id ascending. Uses `status.ne=finalized` because
* TzKT ignores `status.in=pending,finalizable` on this endpoint and returns finalized requests.
* https://api.tzkt.io/#operation/Staking_GetUnstakeRequests
*/
getUnstakeRequests(address: string): Promise<APIUnstakeRequest[]>;
getAccountOperations(address: string, query: AccountsGetOperationsOptions): Promise<APIOperation[]>;
getBlockByLevel(level: number): Promise<APIBlock>;
/**
* Resolves block hashes for the given levels in a single request.
* Uses `/v1/blocks?level.in=...&select.values=level,hash`, which TzKT honours
* (unlike `/v1/blocks/{level}?select=...`, where `select` is ignored). Used
* for cheap backfill of `block.hash` on operations whose level is known but
* whose response omits the block field (e.g. `/accounts/{addr}/operations`
* for staking ops). Levels that don't resolve are absent from the result map.
*/
getBlockHashesByLevels(levels: readonly number[]): Promise<Map<number, string>>;
/**
* Fetches a single page of `transaction` operations at the given block level.
* Internal — used by `fetchBlockTransactions` which handles pagination.
* https://api.tzkt.io/#operation/Operations_GetTransactions
*/
getBlockTransactionsPage(level: number, cursor?: number): Promise<APITransactionType[]>;
/**
* Fetches a list of `transaction` operations after the given level.
* https://api.tzkt.io/#operation/Operations_GetTransactions
*/
getOperationsTransactions(level: number, cursor?: number, apiQueryParams?: Record<string, unknown>): Promise<(APITransactionType & {
block: string;
hash: string;
})[]>;
/**
* Fetches a list of `originations` operations after the given level.
* https://api.tzkt.io/#operation/Operations_GetOriginations
*/
getOperationsOrigination(level: number, cursor?: number, apiQueryParams?: Record<string, unknown>): Promise<(APITransactionType & {
block: string;
hash: string;
})[]>;
/**
* Fetches a single page of FA token transfers at the given block level.
* Internal — used by `fetchBlockTokenTransfers` which handles pagination.
* https://api.tzkt.io/#operation/Tokens_GetTokenTransfers
*/
getBlockTokenTransfersPage(level: number, cursor?: number): Promise<APITokenTransfer[]>;
/**
* Fetches the latest FA token transfers since the given level.
* https://api.tzkt.io/#operation/Tokens_GetTokenTransfers
*/
getTokenTransfers(apiQueryParams?: Record<string, unknown>): Promise<APITokenTransfer[]>;
/**
* Fetches a single page of `origination` operations at the given block level.
* Internal — used by `fetchBlockOriginations` which handles pagination.
* https://api.tzkt.io/#operation/Operations_GetOriginations
*/
getBlockOriginationsPage(level: number, cursor?: number): Promise<APIOriginationType[]>;
/**
* Fetches a single page of `reveal` operations at the given block level.
* Internal — used by `fetchBlockReveals` which handles pagination.
* https://api.tzkt.io/#operation/Operations_GetReveals
*/
getBlockRevealsPage(level: number, cursor?: number): Promise<APIRevealType[]>;
/**
* Fetches a single page of `delegation` operations at the given block level.
* Internal — used by `fetchBlockDelegations` which handles pagination.
* https://api.tzkt.io/#operation/Operations_GetDelegations
*/
getBlockDelegationsPage(level: number, cursor?: number): Promise<APIDelegationType[]>;
/**
* Fetches a single page of `staking` operations at the given block level.
* Internal — used by `fetchBlockStaking` which handles pagination.
* https://api.tzkt.io/#operation/Operations_GetStaking
*/
getBlockStakingPage(level: number, cursor?: number): Promise<APIStakingType[]>;
/**
* Fetches FA2 token transfers for a given account.
* Translates `query.sort` to TzKT's `sort.asc=id` / `sort.desc=id`.
* The lower-level `getTokenTransfers` helper is a generic pass-through and does not pin the sort.
* https://api.tzkt.io/#operation/Tokens_GetTokenTransfers
*/
getAccountTokenTransfers(address: string, query: TokenTransfersGetOptions): Promise<(APITokenTransfer & {
hash: string;
block: string;
})[]>;
/**
* Fetches FA2 token balances for a given account.
* When `tokenFilter` is omitted, all FA2 token balances are returned.
* Pass `tokenFilter` to query a specific FA2 contract + token id (e.g. send-max for FA2).
* https://api.tzkt.io/#operation/Tokens_GetTokenBalances
*/
getTokensBalances(address: string, tokenFilter?: {
contractAddress: string;
tokenId: number;
}): Promise<APITokenBalance[]>;
};
/** The TzKT explorer client bound to a coin config, as returned by {@link createTzktApi}. */
export type TzktApi = ReturnType<typeof createTzktApi>;
export declare const fetchAllTransactions: (config: TezosCoinConfig, address: string, lastId?: number) => Promise<APIOperation[]>;
export declare const fetchBlockTransactions: (config: TezosCoinConfig, level: number) => Promise<APITransactionType[]>;
export declare const fetchBlockTokenTransfers: (config: TezosCoinConfig, level: number) => Promise<APITokenTransfer[]>;
export declare const fetchBlockDelegations: (config: TezosCoinConfig, level: number) => Promise<APIDelegationType[]>;
export declare const fetchBlockStaking: (config: TezosCoinConfig, level: number) => Promise<APIStakingType[]>;
export declare const fetchBlockOriginations: (config: TezosCoinConfig, level: number) => Promise<APIOriginationType[]>;
export declare const fetchBlockReveals: (config: TezosCoinConfig, level: number) => Promise<APIRevealType[]>;
//# sourceMappingURL=tzkt.d.ts.map