// SPDX-FileCopyrightText: © 2026 LEDGER SAS // SPDX-License-Identifier: Apache-2.0 import type { StellarContext } from '../config' import type { ListOperationsOptions, Operation, Page, } from '@ledgerhq/coin-module-framework/api/types' import { fetchOperations } from '../network' export async function listOperations( context: StellarContext, address: string, { limit, cursor, order, minHeight }: ListOperationsOptions ): Promise> { const config = await context.config() // Fake accountId const accountId = '' const { items: operations, next: nextCursor } = await fetchOperations(config, { accountId, addr: address, minHeight, order: order || 'desc', limit, cursor: cursor, }) const mappedOperations = operations.map((op) => convertToLegacyOperation(op)) return { items: mappedOperations, next: nextCursor } } function convertToLegacyOperation(operation: Operation): Operation { const details = operation.details return { id: `${operation.tx.hash}-${details?.index ?? ''}`, asset: operation.asset, tx: operation.tx, details: { sequence: details?.sequence, ledgerOpType: details?.ledgerOpType, assetAmount: details?.assetAmount ?? operation.value.toString(), memo: details?.memo, }, type: operation.type, value: operation.value, senders: operation.senders, recipients: operation.recipients, } }