UNPKG

@jagad/icsi

Version:

Internet Computer Subaccount Indexer Library - TypeScript SDK for ICP multi-token subaccount management, transaction tracking, and automated sweeping with webhook support

118 lines (117 loc) 6.73 kB
import { HttpAgent } from '@dfinity/agent'; import { TokenType, Result_7, Result_9 } from './userVault.did'; /** * Calls the list_transactions function on a canister to fetch transactions. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @param {bigint} [upToIndex] - The number of blocks for the transactions to fetch. * @returns {Promise<Result_9>} - The list of transactions wrapped in a Result. */ export declare function getUserVaultTransactions(agent: HttpAgent, userVaultCanisterId: string, upToIndex?: bigint): Promise<Result_9>; /** * Calls the get_interval function on a canister to get the interval. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<bigint>} - The interval value. * @throws {Error} - Throws if the call returns an error. */ export declare function getUserVaultInterval(agent: HttpAgent, userVaultCanisterId: string): Promise<bigint>; /** * Calls the get_transactions_count function on a canister to get the transaction count. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<number>} - The transaction count. * @throws {Error} - Throws if the call returns an error. */ export declare function getTransactionsCount(agent: HttpAgent, userVaultCanisterId: string): Promise<number>; /** * Calls the get_nonce function on a canister to get the nonce value. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<number>} - The nonce value. * @throws {Error} - Throws if the call returns an error. */ export declare function getNonce(agent: HttpAgent, userVaultCanisterId: string): Promise<number>; /** * Calls the get_subaccount_count function on a canister to get the subaccount count. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<number>} - The subaccount count. * @throws {Error} - Throws if the call returns an error. */ export declare function getSubaccountCount(agent: HttpAgent, userVaultCanisterId: string): Promise<number>; /** * Calls the get_subaccountid function on a canister to get the subaccount ID by index. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @param {number} index - The index of the subaccount. * @param {TokenType} tokenType - The token type for the subaccount. * @returns {Promise<string>} - The subaccount ID. * @throws {Error} - Throws if the call returns an error. */ export declare function getSubaccountId(agent: HttpAgent, userVaultCanisterId: string, index: number, tokenType: TokenType): Promise<string>; /** * Retrieves the webhook URL set for the user's vault. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<string>} - A promise that resolves to the webhook URL. * @throws {Error} - Throws if the call returns an error. */ export declare function getWebhookUrl(agent: HttpAgent, userVaultCanisterId: string): Promise<string>; /** * Gets the principal of the user vault canister. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<string>} - A promise that resolves to the canister principal. * @throws {Error} - Throws if the call returns an error. */ export declare function getCanisterPrincipal(agent: HttpAgent, userVaultCanisterId: string): Promise<string>; /** * Gets the ICRC-1 account representation for a subaccount. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @param {number} index - The index of the subaccount. * @returns {Promise<string>} - A promise that resolves to the ICRC-1 account. * @throws {Error} - Throws if the call returns an error. */ export declare function getIcrcAccount(agent: HttpAgent, userVaultCanisterId: string, index: number): Promise<string>; /** * Gets the network the user vault is running on (Mainnet or Local). * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<"Mainnet" | "Local">} - A promise that resolves to the network. * @throws {Error} - Throws if the call returns an error. */ export declare function getNetwork(agent: HttpAgent, userVaultCanisterId: string): Promise<'Mainnet' | 'Local'>; /** * Gets the next block to be processed by the user vault. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<bigint>} - A promise that resolves to the next block. * @throws {Error} - Throws if the call returns an error. */ export declare function getNextBlock(agent: HttpAgent, userVaultCanisterId: string): Promise<bigint>; /** * Gets the oldest block processed by the user vault. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<bigint | undefined>} - A promise that resolves to the oldest block or undefined. * @throws {Error} - Throws if the call returns an error. */ export declare function getOldestBlock(agent: HttpAgent, userVaultCanisterId: string): Promise<bigint | undefined>; /** * Gets the token types registered with the user vault. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @returns {Promise<Result_7>} - The registered tokens wrapped in a Result. */ export declare function getRegisteredTokens(agent: HttpAgent, userVaultCanisterId: string): Promise<Result_7>; /** * Gets the token type for a specific transaction. * @param {HttpAgent} agent - The HTTP agent used for the call. * @param {string} userVaultCanisterId - The canister ID of the user vault. * @param {string} txHash - The transaction hash. * @returns {Promise<TokenType>} - A promise that resolves to the token type. * @throws {Error} - Throws if the call returns an error. */ export declare function getTransactionTokenType(agent: HttpAgent, userVaultCanisterId: string, txHash: string): Promise<TokenType>;