From b7f91b7ce44761ab85ff786dbb41d7340e7afcad Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sat, 16 Feb 2019 23:41:10 -0700 Subject: [PATCH] server: Move the Transaction model to the persisted package --- server/app/com/xsn/explorer/data/LedgerDataHandler.scala | 3 +-- .../app/com/xsn/explorer/data/TransactionDataHandler.scala | 1 + .../xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala | 4 ++-- .../data/anorm/TransactionPostgresDataHandler.scala | 1 + .../anorm/dao/AddressTransactionDetailsPostgresDAO.scala | 3 ++- .../data/anorm/dao/TransactionInputPostgresDAO.scala | 3 ++- .../data/anorm/dao/TransactionOutputPostgresDAO.scala | 3 ++- .../explorer/data/anorm/dao/TransactionPostgresDAO.scala | 1 + .../explorer/data/anorm/parsers/TransactionParsers.scala | 1 + .../xsn/explorer/data/async/LedgerFutureDataHandler.scala | 4 +--- .../explorer/data/async/TransactionFutureDataHandler.scala | 1 + .../xsn/explorer/models/{ => persisted}/Transaction.scala | 4 +++- server/app/com/xsn/explorer/services/AddressService.scala | 6 +++--- .../xsn/explorer/services/LedgerSynchronizerService.scala | 4 ++-- .../com/xsn/explorer/services/TransactionRPCService.scala | 3 ++- server/app/controllers/AddressesController.scala | 2 +- .../explorer/data/TransactionPostgresDataHandlerSpec.scala | 1 + server/test/com/xsn/explorer/helpers/DataGenerator.scala | 3 ++- server/test/com/xsn/explorer/helpers/LedgerHelper.scala | 1 + .../xsn/explorer/helpers/TransactionDummyDataHandler.scala | 1 + server/test/controllers/AddressesControllerSpec.scala | 1 + 21 files changed, 32 insertions(+), 19 deletions(-) rename server/app/com/xsn/explorer/models/{ => persisted}/Transaction.scala (93%) diff --git a/server/app/com/xsn/explorer/data/LedgerDataHandler.scala b/server/app/com/xsn/explorer/data/LedgerDataHandler.scala index fa793da..2d4cb19 100644 --- a/server/app/com/xsn/explorer/data/LedgerDataHandler.scala +++ b/server/app/com/xsn/explorer/data/LedgerDataHandler.scala @@ -1,8 +1,7 @@ package com.xsn.explorer.data import com.alexitc.playsonify.core.ApplicationResult -import com.xsn.explorer.models.Transaction -import com.xsn.explorer.models.persisted.Block +import com.xsn.explorer.models.persisted.{Block, Transaction} import scala.language.higherKinds diff --git a/server/app/com/xsn/explorer/data/TransactionDataHandler.scala b/server/app/com/xsn/explorer/data/TransactionDataHandler.scala index e7ab350..2e83871 100644 --- a/server/app/com/xsn/explorer/data/TransactionDataHandler.scala +++ b/server/app/com/xsn/explorer/data/TransactionDataHandler.scala @@ -5,6 +5,7 @@ import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition} import com.alexitc.playsonify.models.pagination.{Limit, PaginatedQuery, PaginatedResult} import com.xsn.explorer.models._ import com.xsn.explorer.models.fields.TransactionField +import com.xsn.explorer.models.persisted.Transaction import scala.language.higherKinds diff --git a/server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala b/server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala index 3549565..fdd6c3c 100644 --- a/server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala +++ b/server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala @@ -7,8 +7,8 @@ import com.alexitc.playsonify.models.ApplicationError import com.xsn.explorer.data.LedgerBlockingDataHandler import com.xsn.explorer.data.anorm.dao.{AggregatedAmountPostgresDAO, BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO} import com.xsn.explorer.errors.{PostgresForeignKeyViolationError, PreviousBlockMissingError, RepeatedBlockHeightError} -import com.xsn.explorer.models.persisted.Block -import com.xsn.explorer.models.{Address, Balance, Transaction} +import com.xsn.explorer.models.persisted.{Block, Transaction} +import com.xsn.explorer.models.{Address, Balance} import com.xsn.explorer.util.Extensions.ListOptionExt import javax.inject.Inject import org.scalactic.Good diff --git a/server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala b/server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala index 92ad73e..059c0ec 100644 --- a/server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala +++ b/server/app/com/xsn/explorer/data/anorm/TransactionPostgresDataHandler.scala @@ -7,6 +7,7 @@ import com.xsn.explorer.data.TransactionBlockingDataHandler import com.xsn.explorer.data.anorm.dao.{TransactionOutputPostgresDAO, TransactionPostgresDAO} import com.xsn.explorer.models._ import com.xsn.explorer.models.fields.TransactionField +import com.xsn.explorer.models.persisted.Transaction import javax.inject.Inject import org.scalactic.Good import play.api.db.Database diff --git a/server/app/com/xsn/explorer/data/anorm/dao/AddressTransactionDetailsPostgresDAO.scala b/server/app/com/xsn/explorer/data/anorm/dao/AddressTransactionDetailsPostgresDAO.scala index 756a094..bf78076 100644 --- a/server/app/com/xsn/explorer/data/anorm/dao/AddressTransactionDetailsPostgresDAO.scala +++ b/server/app/com/xsn/explorer/data/anorm/dao/AddressTransactionDetailsPostgresDAO.scala @@ -4,7 +4,8 @@ import java.sql.Connection import anorm._ import com.xsn.explorer.data.anorm.parsers.TransactionParsers._ -import com.xsn.explorer.models.{AddressTransactionDetails, Transaction, TransactionId} +import com.xsn.explorer.models.persisted.Transaction +import com.xsn.explorer.models.{AddressTransactionDetails, TransactionId} class AddressTransactionDetailsPostgresDAO { diff --git a/server/app/com/xsn/explorer/data/anorm/dao/TransactionInputPostgresDAO.scala b/server/app/com/xsn/explorer/data/anorm/dao/TransactionInputPostgresDAO.scala index 43eee5c..e9e30cf 100644 --- a/server/app/com/xsn/explorer/data/anorm/dao/TransactionInputPostgresDAO.scala +++ b/server/app/com/xsn/explorer/data/anorm/dao/TransactionInputPostgresDAO.scala @@ -4,7 +4,8 @@ import java.sql.Connection import anorm._ import com.xsn.explorer.data.anorm.parsers.TransactionParsers._ -import com.xsn.explorer.models.{Address, Transaction, TransactionId} +import com.xsn.explorer.models._ +import com.xsn.explorer.models.persisted.Transaction import org.slf4j.LoggerFactory class TransactionInputPostgresDAO { diff --git a/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala b/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala index de56773..3fbbfb3 100644 --- a/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala +++ b/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala @@ -4,7 +4,8 @@ import java.sql.Connection import anorm._ import com.xsn.explorer.data.anorm.parsers.TransactionParsers._ -import com.xsn.explorer.models.{Address, Transaction, TransactionId} +import com.xsn.explorer.models._ +import com.xsn.explorer.models.persisted.Transaction import org.slf4j.LoggerFactory class TransactionOutputPostgresDAO { diff --git a/server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala b/server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala index 8da9604..c97c715 100644 --- a/server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala +++ b/server/app/com/xsn/explorer/data/anorm/dao/TransactionPostgresDAO.scala @@ -9,6 +9,7 @@ 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 com.xsn.explorer.models.persisted.Transaction import javax.inject.Inject import org.slf4j.LoggerFactory diff --git a/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala b/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala index ee5438a..51a9a0d 100644 --- a/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala +++ b/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala @@ -3,6 +3,7 @@ package com.xsn.explorer.data.anorm.parsers import anorm.SqlParser.{get, str} import anorm.~ import com.xsn.explorer.models._ +import com.xsn.explorer.models.persisted.Transaction object TransactionParsers { diff --git a/server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala b/server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala index 4a6b6e7..c580f4a 100644 --- a/server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala +++ b/server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala @@ -1,12 +1,10 @@ package com.xsn.explorer.data.async import javax.inject.Inject - import com.alexitc.playsonify.core.FutureApplicationResult import com.xsn.explorer.data.{LedgerBlockingDataHandler, LedgerDataHandler} import com.xsn.explorer.executors.DatabaseExecutionContext -import com.xsn.explorer.models.Transaction -import com.xsn.explorer.models.persisted.Block +import com.xsn.explorer.models.persisted.{Block, Transaction} import scala.concurrent.Future diff --git a/server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala b/server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala index a3cbdbc..a2e73ca 100644 --- a/server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala +++ b/server/app/com/xsn/explorer/data/async/TransactionFutureDataHandler.scala @@ -7,6 +7,7 @@ import com.xsn.explorer.data.{TransactionBlockingDataHandler, TransactionDataHan import com.xsn.explorer.executors.DatabaseExecutionContext import com.xsn.explorer.models._ import com.xsn.explorer.models.fields.TransactionField +import com.xsn.explorer.models.persisted.Transaction import javax.inject.Inject import scala.concurrent.Future diff --git a/server/app/com/xsn/explorer/models/Transaction.scala b/server/app/com/xsn/explorer/models/persisted/Transaction.scala similarity index 93% rename from server/app/com/xsn/explorer/models/Transaction.scala rename to server/app/com/xsn/explorer/models/persisted/Transaction.scala index 7d1d515..53ac4a9 100644 --- a/server/app/com/xsn/explorer/models/Transaction.scala +++ b/server/app/com/xsn/explorer/models/persisted/Transaction.scala @@ -1,4 +1,6 @@ -package com.xsn.explorer.models +package com.xsn.explorer.models.persisted + +import com.xsn.explorer.models.{Address, Blockhash, HexString, Size, TransactionId, rpc} case class Transaction( id: TransactionId, diff --git a/server/app/com/xsn/explorer/services/AddressService.scala b/server/app/com/xsn/explorer/services/AddressService.scala index 83bf624..5258798 100644 --- a/server/app/com/xsn/explorer/services/AddressService.scala +++ b/server/app/com/xsn/explorer/services/AddressService.scala @@ -1,12 +1,12 @@ package com.xsn.explorer.services -import javax.inject.Inject - import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OrOps} import com.alexitc.playsonify.core.{ApplicationResult, FutureApplicationResult} import com.xsn.explorer.data.async.{BalanceFutureDataHandler, TransactionFutureDataHandler} import com.xsn.explorer.errors.AddressFormatError -import com.xsn.explorer.models.{Address, Balance, Transaction} +import com.xsn.explorer.models.persisted.Transaction +import com.xsn.explorer.models.{Address, Balance} +import javax.inject.Inject import org.scalactic.{One, Or} import scala.concurrent.ExecutionContext diff --git a/server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala b/server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala index 02c1349..6d1a54b 100644 --- a/server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala +++ b/server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala @@ -4,9 +4,9 @@ import com.alexitc.playsonify.core.FutureApplicationResult import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OptionOps} import com.xsn.explorer.data.async.{BlockFutureDataHandler, LedgerFutureDataHandler} import com.xsn.explorer.errors.BlockNotFoundError -import com.xsn.explorer.models.persisted.Block +import com.xsn.explorer.models.persisted.{Block, Transaction} import com.xsn.explorer.models.transformers._ -import com.xsn.explorer.models.{Blockhash, Height, Transaction} +import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.util.Extensions.FutureOrExt import javax.inject.Inject import org.scalactic.Good diff --git a/server/app/com/xsn/explorer/services/TransactionRPCService.scala b/server/app/com/xsn/explorer/services/TransactionRPCService.scala index ec943a4..d17f99a 100644 --- a/server/app/com/xsn/explorer/services/TransactionRPCService.scala +++ b/server/app/com/xsn/explorer/services/TransactionRPCService.scala @@ -3,8 +3,9 @@ package com.xsn.explorer.services import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureListOps, FutureOps, OrOps} import com.alexitc.playsonify.core.{FutureApplicationResult, FutureOr} import com.xsn.explorer.errors.{InvalidRawTransactionError, TransactionFormatError, TransactionNotFoundError, XSNWorkQueueDepthExceeded} +import com.xsn.explorer.models.persisted.Transaction import com.xsn.explorer.models.rpc.TransactionVIN -import com.xsn.explorer.models.{HexString, Transaction, TransactionDetails, TransactionId, TransactionValue} +import com.xsn.explorer.models.{HexString, TransactionDetails, TransactionId, TransactionValue} import com.xsn.explorer.util.Extensions.FutureOrExt import javax.inject.Inject import org.scalactic.{Bad, Good, One, Or} diff --git a/server/app/controllers/AddressesController.scala b/server/app/controllers/AddressesController.scala index a10f7f2..bb8ead7 100644 --- a/server/app/controllers/AddressesController.scala +++ b/server/app/controllers/AddressesController.scala @@ -2,7 +2,7 @@ package controllers 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.models.persisted.Transaction import com.xsn.explorer.services.{AddressService, TransactionService} import com.xsn.explorer.util.Extensions.BigDecimalExt import controllers.common.{Codecs, MyJsonController, MyJsonControllerComponents} diff --git a/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala b/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala index 36bf5ef..e3d1947 100644 --- a/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala +++ b/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala @@ -10,6 +10,7 @@ import com.xsn.explorer.helpers.DataHelper._ import com.xsn.explorer.helpers.{DataGenerator, LedgerHelper, TransactionLoader} import com.xsn.explorer.models._ import com.xsn.explorer.models.fields.TransactionField +import com.xsn.explorer.models.persisted.Transaction import com.xsn.explorer.models.rpc.Block import org.scalactic.{Good, One, Or} import org.scalatest.BeforeAndAfter diff --git a/server/test/com/xsn/explorer/helpers/DataGenerator.scala b/server/test/com/xsn/explorer/helpers/DataGenerator.scala index 92ee14a..658f8de 100644 --- a/server/test/com/xsn/explorer/helpers/DataGenerator.scala +++ b/server/test/com/xsn/explorer/helpers/DataGenerator.scala @@ -1,7 +1,8 @@ package com.xsn.explorer.helpers +import com.xsn.explorer.models.persisted.Transaction import com.xsn.explorer.models.rpc.Block -import com.xsn.explorer.models.{Address, Blockhash, Confirmations, Height, HexString, Size, Transaction, TransactionId} +import com.xsn.explorer.models.{Address, Blockhash, Confirmations, Height, HexString, Size, TransactionId} trait DataGenerator { diff --git a/server/test/com/xsn/explorer/helpers/LedgerHelper.scala b/server/test/com/xsn/explorer/helpers/LedgerHelper.scala index a1bda21..2fd2b99 100644 --- a/server/test/com/xsn/explorer/helpers/LedgerHelper.scala +++ b/server/test/com/xsn/explorer/helpers/LedgerHelper.scala @@ -1,6 +1,7 @@ package com.xsn.explorer.helpers import com.xsn.explorer.models._ +import com.xsn.explorer.models.persisted.Transaction object LedgerHelper { diff --git a/server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala b/server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala index 2e108f4..d1aebc8 100644 --- a/server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala +++ b/server/test/com/xsn/explorer/helpers/TransactionDummyDataHandler.scala @@ -7,6 +7,7 @@ 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 +import com.xsn.explorer.models.persisted.Transaction class TransactionDummyDataHandler extends TransactionBlockingDataHandler { diff --git a/server/test/controllers/AddressesControllerSpec.scala b/server/test/controllers/AddressesControllerSpec.scala index 9ae027f..6a6751c 100644 --- a/server/test/controllers/AddressesControllerSpec.scala +++ b/server/test/controllers/AddressesControllerSpec.scala @@ -8,6 +8,7 @@ import com.xsn.explorer.data.{BalanceBlockingDataHandler, TransactionBlockingDat import com.xsn.explorer.helpers.{BalanceDummyDataHandler, DataHelper, TransactionDummyDataHandler} import com.xsn.explorer.models._ import com.xsn.explorer.models.fields.TransactionField +import com.xsn.explorer.models.persisted.Transaction import com.xsn.explorer.util.Extensions.BigDecimalExt import controllers.common.MyAPISpec import org.scalactic.Good