Skip to content

Commit

Permalink
server: Wrap the light wallet transactions response in a data field
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Dec 29, 2018
1 parent 2db4f9f commit 36e0551
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions server/app/com/xsn/explorer/models/WrappedResult.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.xsn.explorer.models

import play.api.libs.json.{Json, Writes}

case class WrappedResult[+T](data: T)

object WrappedResult {

implicit def writes[T](implicit writesT: Writes[T]): Writes[WrappedResult[T]] = Json.writes[WrappedResult[T]]
}
4 changes: 2 additions & 2 deletions server/app/com/xsn/explorer/services/TransactionService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class TransactionService @Inject() (
result.toFuture
}

def getLightWalletTransactions(addressString: String, limit: Limit, lastSeenTxidString: Option[String]): FutureApplicationResult[List[LightWalletTransaction]] = {
def getLightWalletTransactions(addressString: String, limit: Limit, lastSeenTxidString: Option[String]): FutureApplicationResult[WrappedResult[List[LightWalletTransaction]]] = {
def buildData(address: Address, txValues: Transaction) = {
val result = for {
plain <- xsnService.getTransaction(txValues.id).toFutureOr
Expand Down Expand Up @@ -195,7 +195,7 @@ class TransactionService @Inject() (

transactions <- transactionFutureDataHandler.getLatestBy(address, limit, lastSeenTxid).toFutureOr
data <- transactions.map { transaction => buildData(address, transaction) }.toFutureOr
} yield data
} yield WrappedResult(data)

result.toFuture
}
Expand Down

0 comments on commit 36e0551

Please sign in to comment.