UNPKG

@ledgerhq/coin-stellar

Version:
50 lines 1.77 kB
import { fetchOperations } from "../network"; export async function listOperations(address, { limit, cursor, order, minHeight }) { // Fake accountId const accountId = ""; const [operations, nextCursor] = await fetchOperations({ accountId, addr: address, minHeight, order: order, limit, cursor: cursor, }); return [operations.map(op => convertToCoreOperation(op)), nextCursor]; } const convertToCoreOperation = (operation) => { return { id: `${operation.hash}-${operation.extra.index}`, asset: operation.extra?.assetCode && operation.extra?.assetIssuer ? { type: "token", assetReference: operation.extra.assetCode, assetOwner: operation.extra.assetIssuer, } : { type: "native" }, tx: { hash: operation.hash, block: { hash: operation.blockHash, time: operation.extra.blockTime, height: operation.blockHeight, }, fees: BigInt(operation.fee.toString()), date: operation.date, failed: operation.hasFailed ?? false, }, details: { sequence: operation.transactionSequenceNumber?.toString(), ledgerOpType: operation.extra.ledgerOpType, assetAmount: operation.extra.assetAmount ? operation.extra.assetAmount : operation.value.toString(), memo: operation.extra.memo, }, type: operation.type, value: BigInt(operation.value.toString()), senders: operation.senders, recipients: operation.recipients, }; }; //# sourceMappingURL=listOperations.js.map