Browse Source

server: Wrap the light wallet transactions response in a data field

prometheus-integration
Alexis Hernandez 6 years ago
parent
commit
36e05516fb
  1. 10
      server/app/com/xsn/explorer/models/WrappedResult.scala
  2. 4
      server/app/com/xsn/explorer/services/TransactionService.scala

10
server/app/com/xsn/explorer/models/WrappedResult.scala

@ -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
server/app/com/xsn/explorer/services/TransactionService.scala

@ -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
@ -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
}

Loading…
Cancel
Save