Browse Source

server: Update playsonify to 2.0.0

prometheus-integration
Alexis Hernandez 6 years ago
parent
commit
f4738baef7
  1. 3
      server/app/com/xsn/explorer/data/BalanceDataHandler.scala
  2. 3
      server/app/com/xsn/explorer/data/BlockDataHandler.scala
  3. 3
      server/app/com/xsn/explorer/data/TransactionDataHandler.scala
  4. 6
      server/app/com/xsn/explorer/data/anorm/BalancePostgresDataHandler.scala
  5. 6
      server/app/com/xsn/explorer/data/anorm/BlockPostgresDataHandler.scala
  6. 5
      server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala
  7. 7
      server/app/com/xsn/explorer/data/anorm/dao/BalancePostgresDAO.scala
  8. 7
      server/app/com/xsn/explorer/data/anorm/dao/BlockPostgresDAO.scala
  9. 7
      server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala
  10. 19
      server/app/com/xsn/explorer/data/anorm/interpreters/ColumnNameResolver.scala
  11. 23
      server/app/com/xsn/explorer/data/anorm/interpreters/FieldOrderingSQLInterpreter.scala
  12. 6
      server/app/com/xsn/explorer/data/async/BalanceFutureDataHandler.scala
  13. 10
      server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala
  14. 7
      server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala
  15. 6
      server/app/com/xsn/explorer/errors/addressErrors.scala
  16. 8
      server/app/com/xsn/explorer/errors/balanceErrors.scala
  17. 15
      server/app/com/xsn/explorer/errors/blockErrors.scala
  18. 6
      server/app/com/xsn/explorer/errors/ipAddressErrors.scala
  19. 4
      server/app/com/xsn/explorer/errors/ledgerErrors.scala
  20. 6
      server/app/com/xsn/explorer/errors/masternodeErrors.scala
  21. 14
      server/app/com/xsn/explorer/errors/orderingErrors.scala
  22. 4
      server/app/com/xsn/explorer/errors/postgresErrors.scala
  23. 22
      server/app/com/xsn/explorer/errors/transactionErrors.scala
  24. 16
      server/app/com/xsn/explorer/errors/xsnErrors.scala
  25. 3
      server/app/com/xsn/explorer/models/Address.scala
  26. 2
      server/app/com/xsn/explorer/models/fields/BalanceField.scala
  27. 2
      server/app/com/xsn/explorer/models/fields/BlockField.scala
  28. 2
      server/app/com/xsn/explorer/models/fields/TransactionField.scala
  29. 15
      server/app/com/xsn/explorer/models/package.scala
  30. 2
      server/app/com/xsn/explorer/parsers/BalanceOrderingParser.scala
  31. 2
      server/app/com/xsn/explorer/parsers/MasternodeOrderingParser.scala
  32. 2
      server/app/com/xsn/explorer/parsers/TransactionOrderingParser.scala
  33. 7
      server/app/com/xsn/explorer/play/MyHttpErrorHandler.scala
  34. 6
      server/app/com/xsn/explorer/services/BalanceService.scala
  35. 6
      server/app/com/xsn/explorer/services/MasternodeService.scala
  36. 5
      server/app/com/xsn/explorer/services/TransactionService.scala
  37. 16
      server/app/controllers/AddressesController.scala
  38. 12
      server/app/controllers/BalancesController.scala
  39. 18
      server/app/controllers/BlocksController.scala
  40. 14
      server/app/controllers/MasternodesController.scala
  41. 5
      server/app/controllers/StatisticsController.scala
  42. 14
      server/app/controllers/TransactionsController.scala
  43. 13
      server/app/controllers/common/Codecs.scala
  44. 4
      server/app/controllers/common/MyAuthenticatorService.scala
  45. 21
      server/app/controllers/common/MyJsonController.scala
  46. 4
      server/app/controllers/common/MyJsonControllerComponents.scala
  47. 11
      server/build.sbt
  48. 5
      server/test/com/xsn/explorer/data/BalancePostgresDataHandlerSpec.scala
  49. 5
      server/test/com/xsn/explorer/data/BlockPostgresDataHandlerSpec.scala
  50. 2
      server/test/com/xsn/explorer/data/LedgerPostgresDataHandlerSpec.scala
  51. 2
      server/test/com/xsn/explorer/data/StatisticsPostgresDataHandlerSpec.scala
  52. 5
      server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala
  53. 3
      server/test/com/xsn/explorer/helpers/BalanceDummyDataHandler.scala
  54. 3
      server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala
  55. 2
      server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala
  56. 5
      server/test/controllers/AddressesControllerSpec.scala
  57. 3
      server/test/controllers/BalancesControllerSpec.scala
  58. 5
      server/test/controllers/BlocksControllerSpec.scala
  59. 2
      server/test/controllers/MasternodesControllerSpec.scala
  60. 2
      server/test/controllers/TransactionsControllerSpec.scala

3
server/app/com/xsn/explorer/data/BalanceDataHandler.scala

@ -1,7 +1,8 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.models.fields.BalanceField
import com.xsn.explorer.models.{Address, Balance}

3
server/app/com/xsn/explorer/data/BlockDataHandler.scala

@ -1,7 +1,8 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.{Blockhash, Height}

3
server/app/com/xsn/explorer/data/TransactionDataHandler.scala

@ -1,7 +1,8 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField
import org.scalactic.Every

6
server/app/com/xsn/explorer/data/anorm/BalancePostgresDataHandler.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.data.anorm
import javax.inject.Inject
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.data.BalanceBlockingDataHandler
import com.xsn.explorer.data.anorm.dao.BalancePostgresDAO
import com.xsn.explorer.errors.BalanceUnknownError
import com.xsn.explorer.models.fields.BalanceField
import com.xsn.explorer.models.{Address, Balance}
import javax.inject.Inject
import org.scalactic.{Good, One, Or}
import play.api.db.Database

6
server/app/com/xsn/explorer/data/anorm/BlockPostgresDataHandler.scala

@ -1,15 +1,15 @@
package com.xsn.explorer.data.anorm
import javax.inject.Inject
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.data.BlockBlockingDataHandler
import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO
import com.xsn.explorer.errors._
import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject
import org.scalactic.{Good, One, Or}
import play.api.db.Database

5
server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala

@ -1,12 +1,13 @@
package com.xsn.explorer.data.anorm
import javax.inject.Inject
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.data.TransactionBlockingDataHandler
import com.xsn.explorer.data.anorm.dao.TransactionPostgresDAO
import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField
import javax.inject.Inject
import org.scalactic.{Every, Good}
import play.api.db.Database

7
server/app/com/xsn/explorer/data/anorm/dao/BalancePostgresDAO.scala

@ -1,14 +1,15 @@
package com.xsn.explorer.data.anorm.dao
import java.sql.Connection
import javax.inject.Inject
import anorm._
import com.alexitc.playsonify.models.{Count, FieldOrdering, PaginatedQuery}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{Count, PaginatedQuery}
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.parsers.BalanceParsers._
import com.xsn.explorer.models.fields.BalanceField
import com.xsn.explorer.models.{Address, Balance}
import javax.inject.Inject
import org.slf4j.LoggerFactory
class BalancePostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderingSQLInterpreter) {

7
server/app/com/xsn/explorer/data/anorm/dao/BlockPostgresDAO.scala

@ -1,15 +1,16 @@
package com.xsn.explorer.data.anorm.dao
import java.sql.Connection
import javax.inject.Inject
import anorm._
import com.alexitc.playsonify.models._
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition}
import com.alexitc.playsonify.models.pagination.{Count, Limit, Offset, PaginatedQuery}
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.parsers.BlockParsers._
import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject
class BlockPostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderingSQLInterpreter) {

7
server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala

@ -2,13 +2,14 @@ package com.xsn.explorer.data.anorm.dao
import java.sql.Connection
import javax.inject.Inject
import anorm._
import com.alexitc.playsonify.models.{Count, FieldOrdering, PaginatedQuery}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{Count, PaginatedQuery}
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.parsers.TransactionParsers._
import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField
import javax.inject.Inject
import org.scalactic.Every
class TransactionPostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderingSQLInterpreter) {

19
server/app/com/xsn/explorer/data/anorm/interpreters/ColumnNameResolver.scala

@ -1,19 +0,0 @@
package com.xsn.explorer.data.anorm.interpreters
import scala.annotation.implicitNotFound
@implicitNotFound(
"No column name resolver found for type ${A}. Try to implement an implicit ColumnNameResolver for this type."
)
trait ColumnNameResolver[A] {
/**
* Maps a field to the column name on the sql schema.
*/
def getColumnName(field: A): String
/**
* This is used to break ties while sorting by non-unique fields,
*/
def getUniqueColumnName: String
}

23
server/app/com/xsn/explorer/data/anorm/interpreters/FieldOrderingSQLInterpreter.scala

@ -1,23 +0,0 @@
package com.xsn.explorer.data.anorm.interpreters
import com.alexitc.playsonify.models.{FieldOrdering, OrderingCondition}
class FieldOrderingSQLInterpreter {
def toOrderByClause[A](fieldOrdering: FieldOrdering[A])(implicit columnNameResolver: ColumnNameResolver[A]) = {
val field = columnNameResolver.getColumnName(fieldOrdering.field)
val condition = getCondition(fieldOrdering.orderingCondition)
val uniqueField = columnNameResolver.getUniqueColumnName
if (field == uniqueField) {
s"ORDER BY $field $condition"
} else {
s"ORDER BY $field $condition, $uniqueField"
}
}
private def getCondition(ordering: OrderingCondition) = ordering match {
case OrderingCondition.AscendingOrder => "ASC"
case OrderingCondition.DescendingOrder => "DESC"
}
}

6
server/app/com/xsn/explorer/data/async/BalanceFutureDataHandler.scala

@ -1,13 +1,13 @@
package com.xsn.explorer.data.async
import javax.inject.Inject
import com.alexitc.playsonify.core.{FutureApplicationResult, FuturePaginatedResult}
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.xsn.explorer.data.{BalanceBlockingDataHandler, BalanceDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models.fields.BalanceField
import com.xsn.explorer.models.{Address, Balance}
import javax.inject.Inject
import scala.concurrent.Future

10
server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.data.async
import javax.inject.Inject
import com.alexitc.playsonify.core.FutureApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.core.{FutureApplicationResult, FuturePaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.xsn.explorer.data.{BlockBlockingDataHandler, BlockDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject
import scala.concurrent.Future
@ -25,7 +25,7 @@ class BlockFutureDataHandler @Inject() (
blockBlockingDataHandler.getBy(height)
}
override def getBy(paginatedQuery: PaginatedQuery, ordering: FieldOrdering[BlockField]): FutureApplicationResult[PaginatedResult[Block]] = Future {
override def getBy(paginatedQuery: PaginatedQuery, ordering: FieldOrdering[BlockField]): FuturePaginatedResult[Block] = Future {
blockBlockingDataHandler.getBy(paginatedQuery, ordering)
}

7
server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala

@ -1,12 +1,13 @@
package com.xsn.explorer.data.async
import javax.inject.Inject
import com.alexitc.playsonify.core.{FutureApplicationResult, FuturePaginatedResult}
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.xsn.explorer.data.{TransactionBlockingDataHandler, TransactionDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField
import javax.inject.Inject
import org.scalactic.Every
import scala.concurrent.Future
@ -31,7 +32,7 @@ class TransactionFutureDataHandler @Inject() (
override def getByBlockhash(
blockhash: Blockhash,
paginatedQuery: PaginatedQuery,
ordering: FieldOrdering[TransactionField]): FutureApplicationResult[PaginatedResult[TransactionWithValues]] = Future {
ordering: FieldOrdering[TransactionField]): FuturePaginatedResult[TransactionWithValues] = Future {
blockingDataHandler.getByBlockhash(blockhash, paginatedQuery, ordering)
}

6
server/app/com/xsn/explorer/errors/addressErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{FieldValidationError, InputValidationError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
sealed trait AddressError
case object AddressFormatError extends AddressError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.address.format")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.address.format")
val error = FieldValidationError("address", message)
List(error)
}

8
server/app/com/xsn/explorer/errors/balanceErrors.scala

@ -1,13 +1,15 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.models.{PublicError, ServerError}
import play.api.i18n.{Lang, MessagesApi}
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{ErrorId, PublicError, ServerError}
sealed trait BalanceError
case object BalanceUnknownError extends BalanceError with ServerError {
val id = ErrorId.create
override def cause: Option[Throwable] = None
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = List.empty
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = List.empty
}

15
server/app/com/xsn/explorer/errors/blockErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.models.{FieldValidationError, InputValidationError, PublicError, ServerError}
import play.api.i18n.{Lang, MessagesApi}
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models._
sealed trait BlockError
case object BlockhashFormatError extends BlockError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.block.format")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.block.format")
val error = FieldValidationError("blockhash", message)
List(error)
}
@ -16,14 +16,15 @@ case object BlockhashFormatError extends BlockError with InputValidationError {
case object BlockNotFoundError extends BlockError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.block.notFound")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.block.notFound")
val error = FieldValidationError("blockhash", message)
List(error)
}
}
case object BlockUnknownError extends BlockError with ServerError {
val id = ErrorId.create
override def cause: Option[Throwable] = None
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = List.empty
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = List.empty
}

6
server/app/com/xsn/explorer/errors/ipAddressErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{FieldValidationError, InputValidationError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
trait IPAddressError
case object IPAddressFormatError extends IPAddressError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.ipAddress.invalid")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.ipAddress.invalid")
val error = FieldValidationError("ip", message)
List(error)
}

4
server/app/com/xsn/explorer/errors/ledgerErrors.scala

@ -1,11 +1,11 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{ApplicationError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
trait LedgerError extends ApplicationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = List.empty
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = List.empty
}
case object PreviousBlockMissingError extends LedgerError

6
server/app/com/xsn/explorer/errors/masternodeErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{FieldValidationError, NotFoundError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
trait MasternodeError
case object MasternodeNotFoundError extends MasternodeError with NotFoundError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.masternode.notFound")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.masternode.notFound")
val error = FieldValidationError("ip", message)
List(error)
}

14
server/app/com/xsn/explorer/errors/orderingErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{FieldValidationError, InputValidationError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
sealed trait OrderingError
case object UnknownOrderingFieldError extends OrderingError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.ordering.unknownField")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.ordering.unknownField")
val error = FieldValidationError("orderBy", message)
List(error)
@ -17,8 +17,8 @@ case object UnknownOrderingFieldError extends OrderingError with InputValidation
case object InvalidOrderingConditionError extends OrderingError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.ordering.unknownCondition")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.ordering.unknownCondition")
val error = FieldValidationError("orderBy", message)
List(error)
@ -27,8 +27,8 @@ case object InvalidOrderingConditionError extends OrderingError with InputValida
case object InvalidOrderingError extends OrderingError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.ordering.invalid")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.ordering.invalid")
val error = FieldValidationError("orderBy", message)
List(error)

4
server/app/com/xsn/explorer/errors/postgresErrors.scala

@ -1,10 +1,12 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.models.ServerError
import com.alexitc.playsonify.models.{ErrorId, ServerError}
import org.postgresql.util.PSQLException
sealed trait PostgresError extends ServerError {
val id = ErrorId.create
def psqlException: PSQLException
override def cause: Option[Throwable] = Option(psqlException)

22
server/app/com/xsn/explorer/errors/transactionErrors.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models._
import play.api.i18n.{Lang, MessagesApi}
sealed trait TransactionError
case object TransactionFormatError extends TransactionError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.transaction.format")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.transaction.format")
val error = FieldValidationError("transactionId", message)
List(error)
}
@ -16,8 +16,8 @@ case object TransactionFormatError extends TransactionError with InputValidation
case object TransactionNotFoundError extends TransactionError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.transaction.notFound")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.transaction.notFound")
val error = FieldValidationError("transactionId", message)
List(error)
}
@ -25,15 +25,17 @@ case object TransactionNotFoundError extends TransactionError with InputValidati
case object TransactionUnknownError extends TransactionError with ServerError {
val id = ErrorId.create
override def cause: Option[Throwable] = None
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = List.empty
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = List.empty
}
case object InvalidRawTransactionError extends TransactionError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.rawTransaction.invalid")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.rawTransaction.invalid")
val error = FieldValidationError("hex", message)
List(error)
}
@ -41,8 +43,8 @@ case object InvalidRawTransactionError extends TransactionError with InputValida
case object RawTransactionAlreadyExistsError extends TransactionError with ConflictError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.rawTransaction.repeated")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("error.rawTransaction.repeated")
val error = FieldValidationError("hex", message)
List(error)
}

16
server/app/com/xsn/explorer/errors/xsnErrors.scala

@ -1,16 +1,18 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.models.{GenericPublicError, PublicError, ServerError}
import play.api.i18n.{Lang, MessagesApi}
import com.alexitc.playsonify.core.I18nService
import com.alexitc.playsonify.models.{ErrorId, GenericPublicError, PublicError, ServerError}
sealed trait XSNServerError extends ServerError {
val id = ErrorId.create
override def cause: Option[Throwable] = Option.empty
}
case class XSNMessageError(message: String) extends XSNServerError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val error = GenericPublicError(message)
List(error)
}
@ -18,16 +20,16 @@ case class XSNMessageError(message: String) extends XSNServerError {
case object XSNUnexpectedResponseError extends XSNServerError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("xsn.server.unexpectedError")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("xsn.server.unexpectedError")
val error = GenericPublicError(message)
List(error)
}
}
case object XSNWorkQueueDepthExceeded extends XSNServerError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("xsn.server.unexpectedError")
override def toPublicErrorList[L](i18nService: I18nService[L])(implicit lang: L): List[PublicError] = {
val message = i18nService.render("xsn.server.unexpectedError")
val error = GenericPublicError(message)
List(error)
}

3
server/app/com/xsn/explorer/models/Address.scala

@ -1,8 +1,7 @@
package com.xsn.explorer.models
import javax.xml.bind.DatatypeConverter
import com.alexitc.playsonify.models.WrappedString
import javax.xml.bind.DatatypeConverter
import play.api.libs.json._
import scala.util.Try

2
server/app/com/xsn/explorer/models/fields/BalanceField.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.models.fields
import com.xsn.explorer.data.anorm.interpreters.ColumnNameResolver
import com.alexitc.playsonify.sql.ColumnNameResolver
import enumeratum._
sealed abstract class BalanceField(override val entryName: String) extends EnumEntry

2
server/app/com/xsn/explorer/models/fields/BlockField.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.models.fields
import com.xsn.explorer.data.anorm.interpreters.ColumnNameResolver
import com.alexitc.playsonify.sql.ColumnNameResolver
import enumeratum.{Enum, EnumEntry}
sealed abstract class BlockField(override val entryName: String) extends EnumEntry

2
server/app/com/xsn/explorer/models/fields/TransactionField.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.models.fields
import com.xsn.explorer.data.anorm.interpreters.ColumnNameResolver
import com.alexitc.playsonify.sql.ColumnNameResolver
import enumeratum._
sealed abstract class TransactionField(override val entryName: String) extends EnumEntry

15
server/app/com/xsn/explorer/models/package.scala

@ -0,0 +1,15 @@
package com.xsn.explorer
import _root_.play.api.libs.json.{JsNumber, JsString, Writes}
import com.alexitc.playsonify.models.{WrappedInt, WrappedString}
package object models {
implicit val stringWrites: Writes[WrappedString] = Writes { obj =>
JsString(obj.string)
}
implicit val numberWrites: Writes[WrappedInt] = Writes { obj =>
JsNumber(obj.int)
}
}

2
server/app/com/xsn/explorer/parsers/BalanceOrderingParser.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.parsers
import com.alexitc.playsonify.models.OrderingCondition
import com.alexitc.playsonify.models.ordering.OrderingCondition
import com.alexitc.playsonify.parsers.FieldOrderingParser
import com.xsn.explorer.models.fields.BalanceField

2
server/app/com/xsn/explorer/parsers/MasternodeOrderingParser.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.parsers
import com.alexitc.playsonify.models.OrderingCondition
import com.alexitc.playsonify.models.ordering.OrderingCondition
import com.alexitc.playsonify.parsers.FieldOrderingParser
import com.xsn.explorer.models.fields.MasternodeField

2
server/app/com/xsn/explorer/parsers/TransactionOrderingParser.scala

@ -1,6 +1,6 @@
package com.xsn.explorer.parsers
import com.alexitc.playsonify.models.OrderingCondition
import com.alexitc.playsonify.models.ordering.OrderingCondition
import com.alexitc.playsonify.parsers.FieldOrderingParser
import com.xsn.explorer.models.fields.TransactionField

7
server/app/com/xsn/explorer/play/MyHttpErrorHandler.scala

@ -1,9 +1,8 @@
package com.xsn.explorer.play
import com.alexitc.playsonify.models.{ErrorId, InternalError, PublicError}
import com.alexitc.playsonify.play.PublicErrorRenderer
import javax.inject.Inject
import com.alexitc.playsonify.PublicErrorRenderer
import com.alexitc.playsonify.models.{ErrorId, PublicError}
import org.slf4j.LoggerFactory
import play.api.http.HttpErrorHandler
import play.api.libs.json.Json
@ -29,7 +28,7 @@ class MyHttpErrorHandler @Inject() (errorRenderer: PublicErrorRenderer) extends
def onServerError(request: RequestHeader, exception: Throwable) = {
val errorId = ErrorId.create
val error = errorRenderer.renderPrivateError(errorId)
val error = errorRenderer.renderPublicError(InternalError(errorId, "Internal error"))
val json = Json.obj(
"errors" -> Json.arr(error)
)

6
server/app/com/xsn/explorer/services/BalanceService.scala

@ -1,14 +1,14 @@
package com.xsn.explorer.services
import javax.inject.Inject
import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OrOps}
import com.alexitc.playsonify.core.FuturePaginatedResult
import com.alexitc.playsonify.models.{OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.alexitc.playsonify.validators.PaginatedQueryValidator
import com.xsn.explorer.data.async.BalanceFutureDataHandler
import com.xsn.explorer.models.Balance
import com.xsn.explorer.parsers.BalanceOrderingParser
import javax.inject.Inject
import scala.concurrent.ExecutionContext

6
server/app/com/xsn/explorer/services/MasternodeService.scala

@ -1,16 +1,16 @@
package com.xsn.explorer.services
import javax.inject.Inject
import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OrOps}
import com.alexitc.playsonify.core.{FutureApplicationResult, FuturePaginatedResult}
import com.alexitc.playsonify.models._
import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition, OrderingQuery}
import com.alexitc.playsonify.models.pagination.{Count, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.validators.PaginatedQueryValidator
import com.xsn.explorer.errors.IPAddressFormatError
import com.xsn.explorer.models.IPAddress
import com.xsn.explorer.models.fields.MasternodeField
import com.xsn.explorer.models.rpc.Masternode
import com.xsn.explorer.parsers.MasternodeOrderingParser
import javax.inject.Inject
import org.scalactic.{Bad, Good}
import scala.concurrent.ExecutionContext

5
server/app/com/xsn/explorer/services/TransactionService.scala

@ -1,15 +1,16 @@
package com.xsn.explorer.services
import javax.inject.Inject
import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureListOps, FutureOps, OrOps}
import com.alexitc.playsonify.core.{FutureApplicationResult, FuturePaginatedResult}
import com.alexitc.playsonify.models.{OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.alexitc.playsonify.validators.PaginatedQueryValidator
import com.xsn.explorer.data.async.TransactionFutureDataHandler
import com.xsn.explorer.errors._
import com.xsn.explorer.models._
import com.xsn.explorer.models.rpc.TransactionVIN
import com.xsn.explorer.parsers.TransactionOrderingParser
import javax.inject.Inject
import org.scalactic._
import play.api.libs.json.{JsObject, JsString, JsValue}

16
server/app/controllers/AddressesController.scala

@ -1,12 +1,12 @@
package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.{Limit, Offset, OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.{Limit, Offset, PaginatedQuery}
import com.xsn.explorer.models.Transaction
import com.xsn.explorer.services.{AddressService, TransactionService}
import com.xsn.explorer.util.Extensions.BigDecimalExt
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import controllers.common.{Codecs, MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
import play.api.libs.json._
class AddressesController @Inject() (
@ -15,11 +15,13 @@ class AddressesController @Inject() (
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def getBy(address: String) = publicNoInput { _ =>
import Codecs._
def getBy(address: String) = public { _ =>
addressService.getBy(address)
}
def getTransactions(address: String, offset: Int, limit: Int, ordering: String) = publicNoInput { _ =>
def getTransactions(address: String, offset: Int, limit: Int, ordering: String) = public { _ =>
val paginatedQuery = PaginatedQuery(Offset(offset), Limit(limit))
transactionService.getTransactions(address, paginatedQuery, OrderingQuery(ordering))
@ -40,7 +42,7 @@ class AddressesController @Inject() (
JsObject.apply(values)
}
def getUnspentOutputs(address: String) = publicNoInput { _ =>
def getUnspentOutputs(address: String) = public { _ =>
addressService.getUnspentOutputs(address)
}
}

12
server/app/controllers/BalancesController.scala

@ -1,17 +1,19 @@
package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.{Limit, Offset, OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.{Limit, Offset, PaginatedQuery}
import com.xsn.explorer.services.BalanceService
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import controllers.common.{Codecs, MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
class BalancesController @Inject() (
balanceService: BalanceService,
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def get(offset: Int, limit: Int, ordering: String) = publicNoInput { _ =>
import Codecs._
def get(offset: Int, limit: Int, ordering: String) = public { _ =>
val paginatedQuery = PaginatedQuery(Offset(offset), Limit(limit))
val orderingQuery = OrderingQuery(ordering)

18
server/app/controllers/BlocksController.scala

@ -1,11 +1,11 @@
package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.{Limit, Offset, OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.{Limit, Offset, PaginatedQuery}
import com.xsn.explorer.models.Height
import com.xsn.explorer.services.{BlockService, TransactionService}
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import controllers.common.{Codecs, MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
import scala.util.Try
@ -15,7 +15,9 @@ class BlocksController @Inject() (
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def getLatestBlocks() = publicNoInput { _ =>
import Codecs._
def getLatestBlocks() = public { _ =>
blockService.getLatestBlocks()
}
@ -24,21 +26,21 @@ class BlocksController @Inject() (
* is not a valid height, we assume it might be a blockhash and try to
* retrieve the block by blockhash.
*/
def getDetails(query: String) = publicNoInput { _ =>
def getDetails(query: String) = public { _ =>
Try(query.toInt)
.map(Height.apply)
.map(blockService.getDetails)
.getOrElse(blockService.getDetails(query))
}
def getRawBlock(query: String) = publicNoInput { _ =>
def getRawBlock(query: String) = public { _ =>
Try(query.toInt)
.map(Height.apply)
.map(blockService.getRawBlock)
.getOrElse(blockService.getRawBlock(query))
}
def getTransactions(blockhash: String, offset: Int, limit: Int, orderBy: String) = publicNoInput { _ =>
def getTransactions(blockhash: String, offset: Int, limit: Int, orderBy: String) = public { _ =>
val query = PaginatedQuery(Offset(offset), Limit(limit))
val ordering = OrderingQuery(orderBy)
transactionService.getByBlockhash(blockhash, query, ordering)

14
server/app/controllers/MasternodesController.scala

@ -1,24 +1,26 @@
package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.{Limit, Offset, OrderingQuery, PaginatedQuery}
import com.alexitc.playsonify.models.ordering.OrderingQuery
import com.alexitc.playsonify.models.pagination.{Limit, Offset, PaginatedQuery}
import com.xsn.explorer.services.MasternodeService
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import controllers.common.{Codecs, MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
class MasternodesController @Inject() (
masternodeService: MasternodeService,
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def get(offset: Int, limit: Int, ordering: String) = publicNoInput { _ =>
import Codecs._
def get(offset: Int, limit: Int, ordering: String) = public { _ =>
val paginatedQuery = PaginatedQuery(Offset(offset), Limit(limit))
val orderingQuery = OrderingQuery(ordering)
masternodeService.getMasternodes(paginatedQuery, orderingQuery)
}
def getBy(ipAddress: String) = publicNoInput { _ =>
def getBy(ipAddress: String) = public { _ =>
masternodeService.getMasternode(ipAddress)
}
}

5
server/app/controllers/StatisticsController.scala

@ -1,16 +1,15 @@
package controllers
import javax.inject.Inject
import com.xsn.explorer.services.StatisticsService
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
class StatisticsController @Inject() (
statisticsService: StatisticsService,
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def getStatus() = publicNoInput { _ =>
def getStatus() = public { _ =>
statisticsService.getStatistics()
}
}

14
server/app/controllers/TransactionsController.scala

@ -1,30 +1,30 @@
package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.PublicContextWithModel
import com.xsn.explorer.models.request.{GetLatestTransactionRequest, SendRawTransactionRequest}
import com.xsn.explorer.services.TransactionService
import controllers.common.{MyJsonController, MyJsonControllerComponents}
import javax.inject.Inject
class TransactionsController @Inject() (
transactionService: TransactionService,
cc: MyJsonControllerComponents)
extends MyJsonController(cc) {
def getTransaction(txid: String) = publicNoInput { _ =>
import Context._
def getTransaction(txid: String) = public { _ =>
transactionService.getTransactionDetails(txid)
}
def getRawTransaction(txid: String) = publicNoInput { _ =>
def getRawTransaction(txid: String) = public { _ =>
transactionService.getRawTransaction(txid)
}
def sendRawTransaction() = publicWithInput { ctx: PublicContextWithModel[SendRawTransactionRequest] =>
def sendRawTransaction() = publicInput { ctx: HasModel[SendRawTransactionRequest] =>
transactionService.sendRawTransaction(ctx.model.hex)
}
def getLatestByAddresses() = publicWithInput { ctx: PublicContextWithModel[GetLatestTransactionRequest] =>
def getLatestByAddresses() = publicInput { ctx: HasModel[GetLatestTransactionRequest] =>
transactionService.getLatestTransactionBy(ctx.model.addresses)
}
}

13
server/app/controllers/common/Codecs.scala

@ -1,10 +1,13 @@
package controllers.common
import com.alexitc.playsonify.models.pagination.PaginatedResult
import com.xsn.explorer.models._
import org.scalactic.Every
import play.api.libs.json._
object Codecs {
implicit def everyReads[T](implicit readsT: Reads[T]): Reads[Every[T]] = Reads[Every[T]] { json =>
json
.validate[List[T]]
@ -16,4 +19,14 @@ object Codecs {
}
}
}
implicit def paginatedResultWrites[T](implicit writesT: Writes[T]): Writes[PaginatedResult[T]] = OWrites[PaginatedResult[T]] { result =>
Json.obj(
"offset" -> result.offset,
"limit" -> result.limit,
"total" -> result.total,
"data" -> result.data
)
}
}

4
server/app/controllers/common/MyAuthenticatorService.scala

@ -1,7 +1,7 @@
package controllers.common
import com.alexitc.playsonify.AbstractAuthenticatorService
import com.alexitc.playsonify.core.FutureApplicationResult
import com.alexitc.playsonify.play.AbstractAuthenticatorService
import org.scalactic.Good
import play.api.libs.json.JsValue
import play.api.mvc.Request
@ -11,6 +11,6 @@ import scala.concurrent.Future
class MyAuthenticatorService extends AbstractAuthenticatorService[Nothing] {
override def authenticate(request: Request[JsValue]): FutureApplicationResult[Nothing] = {
Future.successful(Good(???))
Future.successful(Good(throw new RuntimeException("Not implemented")))
}
}

21
server/app/controllers/common/MyJsonController.scala

@ -1,25 +1,20 @@
package controllers.common
import com.alexitc.playsonify.AbstractJsonController
import com.alexitc.playsonify.models.{ErrorId, ServerError}
import com.alexitc.playsonify.models.ServerError
import com.alexitc.playsonify.play.AbstractJsonController
import org.slf4j.LoggerFactory
abstract class MyJsonController(cc: MyJsonControllerComponents) extends AbstractJsonController[Nothing](cc) {
protected val logger = LoggerFactory.getLogger(this.getClass)
override def onServerError(error: ServerError, errorId: ErrorId): Unit = {
val message = s"Unexpected server error, id = ${errorId.string}, error = $error"
override protected def onServerError(error: ServerError): Unit = {
error.cause match {
case Some(cause) =>
logger.error(s"Unexpected internal error, id = ${error.id.string}, error = $error", cause)
error
.cause
.orElse {
logger.warn(message)
None
}
.foreach { cause =>
// we'll log as error when there is an exception involved
logger.error(message, cause)
case None =>
logger.error(s"Unexpected internal error, id = ${error.id.string}, error = $error}")
}
}
}

4
server/app/controllers/common/MyJsonControllerComponents.scala

@ -1,8 +1,7 @@
package controllers.common
import com.alexitc.playsonify.play.{I18nPlayService, JsonControllerComponents, PublicErrorRenderer}
import javax.inject.Inject
import com.alexitc.playsonify.{JsonControllerComponents, PublicErrorRenderer}
import play.api.mvc.MessagesControllerComponents
import scala.concurrent.ExecutionContext
@ -11,5 +10,6 @@ class MyJsonControllerComponents @Inject() (
override val messagesControllerComponents: MessagesControllerComponents,
override val executionContext: ExecutionContext,
override val publicErrorRenderer: PublicErrorRenderer,
override val i18nService: I18nPlayService,
override val authenticatorService: MyAuthenticatorService)
extends JsonControllerComponents[Nothing]

11
server/build.sbt

@ -22,7 +22,7 @@ scalacOptions ++= Seq(
)
val playsonifyVersion = "1.2.0"
val playsonifyVersion = "2.0.0"
lazy val root = (project in file("."))
.enablePlugins(PlayScala)
@ -32,7 +32,13 @@ coverageExcludedPackages := "<empty>;Reverse.*;router\\.*"
libraryDependencies ++= Seq(guice, evolutions, jdbc, ws)
libraryDependencies += "com.alexitc" %% "playsonify" % playsonifyVersion
libraryDependencies ++= Seq(
"com.alexitc" %% "playsonify-core" % playsonifyVersion,
"com.alexitc" %% "playsonify-play" % playsonifyVersion,
"com.alexitc" %% "playsonify-sql" % playsonifyVersion,
"com.alexitc" %% "playsonify-play-test" % playsonifyVersion % Test
)
libraryDependencies += "com.google.inject" % "guice" % "4.1.0"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
libraryDependencies += "org.playframework.anorm" %% "anorm" % "2.6.1"
@ -48,7 +54,6 @@ libraryDependencies ++= Seq(
)
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.0" % Test
libraryDependencies += "com.alexitc" %% "playsonifytest" % playsonifyVersion % Test
libraryDependencies += "org.mockito" % "mockito-core" % "2.15.0" % Test
libraryDependencies ++= Seq(

5
server/test/com/xsn/explorer/data/BalancePostgresDataHandlerSpec.scala

@ -1,9 +1,10 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.models._
import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition}
import com.alexitc.playsonify.models.pagination.{Limit, Offset, PaginatedQuery}
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.BalancePostgresDataHandler
import com.xsn.explorer.data.anorm.dao.BalancePostgresDAO
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.helpers.DataHelper
import com.xsn.explorer.models.Balance

5
server/test/com/xsn/explorer/data/BlockPostgresDataHandlerSpec.scala

@ -1,9 +1,10 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.models._
import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition}
import com.alexitc.playsonify.models.pagination.{Count, Limit, Offset, PaginatedQuery}
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.BlockPostgresDataHandler
import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.BlockNotFoundError
import com.xsn.explorer.helpers.BlockLoader

2
server/test/com/xsn/explorer/data/LedgerPostgresDataHandlerSpec.scala

@ -1,8 +1,8 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.LedgerPostgresDataHandler
import com.xsn.explorer.data.anorm.dao.{BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.{PreviousBlockMissingError, RepeatedBlockHeightError}
import com.xsn.explorer.helpers.{BlockLoader, TransactionLoader}

2
server/test/com/xsn/explorer/data/StatisticsPostgresDataHandlerSpec.scala

@ -1,7 +1,7 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.dao.{BalancePostgresDAO, StatisticsPostgresDAO}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.{BalancePostgresDataHandler, StatisticsPostgresDataHandler}
import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.helpers.DataHelper

5
server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala

@ -1,8 +1,9 @@
package com.xsn.explorer.data
import com.alexitc.playsonify.models._
import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition}
import com.alexitc.playsonify.models.pagination._
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.dao.{BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.{BlockPostgresDataHandler, LedgerPostgresDataHandler, TransactionPostgresDataHandler}
import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.{BlockNotFoundError, TransactionNotFoundError}

3
server/test/com/xsn/explorer/helpers/BalanceDummyDataHandler.scala

@ -1,7 +1,8 @@
package com.xsn.explorer.helpers
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.data.BalanceBlockingDataHandler
import com.xsn.explorer.models.fields.BalanceField
import com.xsn.explorer.models.{Address, Balance}

3
server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala

@ -1,7 +1,8 @@
package com.xsn.explorer.helpers
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.data.TransactionBlockingDataHandler
import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField

2
server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala

@ -1,9 +1,9 @@
package com.xsn.explorer.services
import com.alexitc.playsonify.core.FutureApplicationResult
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.alexitc.playsonify.validators.PaginatedQueryValidator
import com.xsn.explorer.data.anorm.dao.{BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO}
import com.xsn.explorer.data.anorm.interpreters.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.{BlockPostgresDataHandler, LedgerPostgresDataHandler, TransactionPostgresDataHandler}
import com.xsn.explorer.data.async.{BlockFutureDataHandler, LedgerFutureDataHandler, TransactionFutureDataHandler}
import com.xsn.explorer.data.common.PostgresDataHandlerSpec

5
server/test/controllers/AddressesControllerSpec.scala

@ -1,8 +1,9 @@
package controllers
import com.alexitc.playsonify.PublicErrorRenderer
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.{Count, FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{Count, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.play.PublicErrorRenderer
import com.xsn.explorer.data.{BalanceBlockingDataHandler, TransactionBlockingDataHandler}
import com.xsn.explorer.helpers.{BalanceDummyDataHandler, DataHelper, TransactionDummyDataHandler}
import com.xsn.explorer.models._

3
server/test/controllers/BalancesControllerSpec.scala

@ -1,7 +1,8 @@
package controllers
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models._
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination._
import com.xsn.explorer.data.BalanceBlockingDataHandler
import com.xsn.explorer.helpers.DataHelper
import com.xsn.explorer.models.fields.BalanceField

5
server/test/controllers/BlocksControllerSpec.scala

@ -1,8 +1,9 @@
package controllers
import com.alexitc.playsonify.PublicErrorRenderer
import com.alexitc.playsonify.core.{ApplicationResult, FutureApplicationResult}
import com.alexitc.playsonify.models.{Count, FieldOrdering, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{Count, PaginatedQuery, PaginatedResult}
import com.alexitc.playsonify.play.PublicErrorRenderer
import com.xsn.explorer.data.TransactionBlockingDataHandler
import com.xsn.explorer.errors.{BlockNotFoundError, TransactionNotFoundError}
import com.xsn.explorer.helpers.{BlockLoader, DummyXSNService, TransactionDummyDataHandler, TransactionLoader}

2
server/test/controllers/MasternodesControllerSpec.scala

@ -1,7 +1,7 @@
package controllers
import com.alexitc.playsonify.PublicErrorRenderer
import com.alexitc.playsonify.core.FutureApplicationResult
import com.alexitc.playsonify.play.PublicErrorRenderer
import com.xsn.explorer.errors.MasternodeNotFoundError
import com.xsn.explorer.helpers.DummyXSNService
import com.xsn.explorer.models.rpc.Masternode

2
server/test/controllers/TransactionsControllerSpec.scala

@ -1,7 +1,7 @@
package controllers
import com.alexitc.playsonify.PublicErrorRenderer
import com.alexitc.playsonify.core.{ApplicationResult, FutureApplicationResult}
import com.alexitc.playsonify.play.PublicErrorRenderer
import com.xsn.explorer.data.TransactionBlockingDataHandler
import com.xsn.explorer.errors.TransactionNotFoundError
import com.xsn.explorer.helpers.{DataHelper, DummyXSNService, TransactionDummyDataHandler, TransactionLoader}

Loading…
Cancel
Save