import { PopulatedTransaction } from '../models' ; import { mapToRosettaTransaction } from './data-mapper' ; export interface SearchTransactionsMapperParameters { transactions : PopulatedTransaction [ ] ; poolDeposit : number ; offset : number ; limit : number ; totalCount : number ; } export const mapToSearchTransactionsResponse = ( parameters ) : Components . Schemas . SearchTransactionsResponse => { const { transactions , poolDeposit , totalCount , offset , limit } = parameters ; const blockTransactions = transactions . map ( tx => ( { block_identifier : { index : tx . blockNo , hash : tx . blockHash } , transaction : mapToRosettaTransaction ( tx , poolDeposit ) } ) ) ; const nextOffset = offset + limit ; const toReturn = { transactions : blockTransactions , total_count : totalCount } ; if ( nextOffset < totalCount ) { toReturn . next_offset = nextOffset ; } return toReturn ; } ;