UNPKG

@ledgerhq/live-common

Version:
43 lines 2.63 kB
import { Account, Operation } from "@ledgerhq/types-live"; import { Balance, Operation as CoreOperation, TransactionIntent } from "@ledgerhq/coin-framework/api/types"; import { CryptoCurrency } from "@ledgerhq/types-cryptoassets"; import { GenericTransaction } from "./types"; export declare function findCryptoCurrencyByNetwork(network: string): CryptoCurrency | undefined; export declare function extractBalance(balances: Balance[], type: string): Balance; export declare function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOperation): Operation; /** * Converts a transaction object into a `TransactionIntent` object, which is used to represent * the intent of a transaction in a standardized format. * * @template MemoType - The type of memo supported by the transaction, defaults to `MemoNotSupported`. * * @param account - The account initiating the transaction. Contains details such as the sender's address. * @param transaction - The transaction object containing details about the operation to be performed. * - `assetOwner` (optional): The issuer of the asset, if applicable. * - `assetReference` (optional): The code of the asset, if applicable. * - `mode` (optional): The mode of the transaction, e.g., "changetrust" or "send". * - `fees` (optional): The fees associated with the transaction. * - `memoType` (optional): The type of memo to attach to the transaction. * - `memoValue` (optional): The value of the memo to attach to the transaction. * @param computeIntentType - An optional function to compute the intent type that supersedes the default implementation if present * * @returns A `TransactionIntent` object containing the standardized representation of the transaction. * - Includes details such as type, sender, recipient, amount, fees, asset, and an optional memo. * - If `assetReference` and `assetOwner` are provided, the asset is represented as a token. * - If `memoType` and `memoValue` are provided, a memo is included; otherwise, a default memo of type "NO_MEMO" is added. * * @throws An error if the transaction mode is unsupported. */ export declare function transactionToIntent(account: Account, transaction: GenericTransaction, computeIntentType?: (transaction: GenericTransaction) => string): TransactionIntent & { memo?: { type: string; value?: string; }; } & { data?: { type: string; value?: unknown; }; }; export declare const buildOptimisticOperation: (account: Account, transaction: GenericTransaction, sequenceNumber?: number) => Operation; //# sourceMappingURL=utils.d.ts.map