From 88529bbfa74e0327599403dcc54190168dab1f02 Mon Sep 17 00:00:00 2001 From: oskin1 Date: Tue, 9 Oct 2018 08:26:39 +0300 Subject: [PATCH] Duplicated checks removed. --- .../scala/org/ergoplatform/api/WalletApiRoute.scala | 1 + .../ergoplatform/local/TransactionGenerator.scala | 1 + .../nodeView/wallet/ErgoWalletReader.scala | 1 + .../nodeView/wallet/requests/AssetIssueRequest.scala | 12 ++++++++++++ .../wallet/{ => requests}/PaymentRequest.scala | 5 +++-- .../nodeView/ErgoNodeViewHolderSpec.scala | 8 ++------ 6 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 src/main/scala/org/ergoplatform/nodeView/wallet/requests/AssetIssueRequest.scala rename src/main/scala/org/ergoplatform/nodeView/wallet/{ => requests}/PaymentRequest.scala (89%) diff --git a/src/main/scala/org/ergoplatform/api/WalletApiRoute.scala b/src/main/scala/org/ergoplatform/api/WalletApiRoute.scala index 8ca4febce2..c53e2afa74 100644 --- a/src/main/scala/org/ergoplatform/api/WalletApiRoute.scala +++ b/src/main/scala/org/ergoplatform/api/WalletApiRoute.scala @@ -7,6 +7,7 @@ import io.circe.Encoder import org.ergoplatform.modifiers.mempool.ErgoTransaction import org.ergoplatform.nodeView.ErgoReadersHolder.{GetReaders, Readers} import org.ergoplatform.nodeView.wallet._ +import org.ergoplatform.nodeView.wallet.requests.{PaymentRequest, PaymentRequestDecoder} import org.ergoplatform.settings.ErgoSettings import scorex.core.NodeViewHolder.ReceivableMessages.LocallyGeneratedTransaction import scorex.core.api.http.ApiError.BadRequest diff --git a/src/main/scala/org/ergoplatform/local/TransactionGenerator.scala b/src/main/scala/org/ergoplatform/local/TransactionGenerator.scala index f293a6d8a0..84a9100783 100644 --- a/src/main/scala/org/ergoplatform/local/TransactionGenerator.scala +++ b/src/main/scala/org/ergoplatform/local/TransactionGenerator.scala @@ -8,6 +8,7 @@ import org.ergoplatform.nodeView.history.ErgoHistory import org.ergoplatform.nodeView.mempool.ErgoMemPool import org.ergoplatform.nodeView.state.UtxoState import org.ergoplatform.nodeView.wallet._ +import org.ergoplatform.nodeView.wallet.requests.PaymentRequest import org.ergoplatform.settings.ErgoSettings import scorex.core.NodeViewHolder.ReceivableMessages.{GetDataFromCurrentView, LocallyGeneratedTransaction} import scorex.core.network.NodeViewSynchronizer.ReceivableMessages.{SemanticallySuccessfulModifier, SuccessfulTransaction} diff --git a/src/main/scala/org/ergoplatform/nodeView/wallet/ErgoWalletReader.scala b/src/main/scala/org/ergoplatform/nodeView/wallet/ErgoWalletReader.scala index 69b57386f7..6477651b0b 100644 --- a/src/main/scala/org/ergoplatform/nodeView/wallet/ErgoWalletReader.scala +++ b/src/main/scala/org/ergoplatform/nodeView/wallet/ErgoWalletReader.scala @@ -7,6 +7,7 @@ import akka.pattern.ask import akka.util.Timeout import org.ergoplatform.modifiers.mempool.ErgoTransaction import org.ergoplatform.nodeView.wallet.ErgoWalletActor.{GenerateTransaction, ReadPublicKeys, ReadRandomPublicKey, ReadTrackedAddresses} +import org.ergoplatform.nodeView.wallet.requests.PaymentRequest import scorex.core.transaction.wallet.VaultReader import scala.concurrent.Future diff --git a/src/main/scala/org/ergoplatform/nodeView/wallet/requests/AssetIssueRequest.scala b/src/main/scala/org/ergoplatform/nodeView/wallet/requests/AssetIssueRequest.scala new file mode 100644 index 0000000000..1e83be32ea --- /dev/null +++ b/src/main/scala/org/ergoplatform/nodeView/wallet/requests/AssetIssueRequest.scala @@ -0,0 +1,12 @@ +package org.ergoplatform.nodeView.wallet.requests + +import org.ergoplatform.ErgoBoxCandidate +import org.ergoplatform.nodeView.wallet.ErgoAddress + +case class AssetIssueRequest(address: ErgoAddress, + amount: Long, + name: String, + decimals: Int) { + + def toBoxCandidate: ErgoBoxCandidate = ??? +} diff --git a/src/main/scala/org/ergoplatform/nodeView/wallet/PaymentRequest.scala b/src/main/scala/org/ergoplatform/nodeView/wallet/requests/PaymentRequest.scala similarity index 89% rename from src/main/scala/org/ergoplatform/nodeView/wallet/PaymentRequest.scala rename to src/main/scala/org/ergoplatform/nodeView/wallet/requests/PaymentRequest.scala index b62eb6727f..45ba2d01c6 100644 --- a/src/main/scala/org/ergoplatform/nodeView/wallet/PaymentRequest.scala +++ b/src/main/scala/org/ergoplatform/nodeView/wallet/requests/PaymentRequest.scala @@ -1,9 +1,10 @@ -package org.ergoplatform.nodeView.wallet +package org.ergoplatform.nodeView.wallet.requests import io.circe.syntax._ import io.circe.{Decoder, Encoder, HCursor, Json} import org.ergoplatform.ErgoBox.NonMandatoryRegisterId import org.ergoplatform.modifiers.mempool.ErgoTransaction._ +import org.ergoplatform.nodeView.wallet.{ErgoAddress, ErgoAddressEncoder} import org.ergoplatform.settings.ErgoSettings import org.ergoplatform.{ErgoBox, ErgoBoxCandidate} import sigmastate.SType @@ -23,7 +24,7 @@ case class PaymentRequest(address: ErgoAddress, class PaymentRequestEncoder(settings: ErgoSettings) extends Encoder[PaymentRequest] { - implicit val addressEncoder = new ErgoAddressEncoder(settings).encoder + implicit val addressEncoder: Encoder[ErgoAddress] = new ErgoAddressEncoder(settings).encoder def apply(request: PaymentRequest): Json = { Json.obj( diff --git a/src/test/scala/org/ergoplatform/nodeView/ErgoNodeViewHolderSpec.scala b/src/test/scala/org/ergoplatform/nodeView/ErgoNodeViewHolderSpec.scala index b3b617822f..7fd458a011 100644 --- a/src/test/scala/org/ergoplatform/nodeView/ErgoNodeViewHolderSpec.scala +++ b/src/test/scala/org/ergoplatform/nodeView/ErgoNodeViewHolderSpec.scala @@ -113,9 +113,7 @@ class ErgoNodeViewHolderSpec extends ErgoPropertyTest with NodeViewTestOps with applyBlock(block) shouldBe 'success getBestHeaderOpt shouldBe Some(block.header) - if (verifyTransactions) { - getRootHash shouldBe Algos.encode(wusAfterBlock.rootHash) - } + getRootHash shouldBe Algos.encode(wusAfterBlock.rootHash) getBestHeaderOpt shouldBe Some(block.header) val brokenBlock = genInvalidFullBlock(block.header, wusAfterBlock) @@ -160,9 +158,7 @@ class ErgoNodeViewHolderSpec extends ErgoPropertyTest with NodeViewTestOps with applyBlock(block) shouldBe 'success getBestHeaderOpt shouldBe Some(block.header) - if (verifyTransactions) { - getRootHash shouldBe Algos.encode(wusAfterBlock.rootHash) - } + getRootHash shouldBe Algos.encode(wusAfterBlock.rootHash) getBestHeaderOpt shouldBe Some(block.header) val brokenBlock = genBlockWithInvalidExtension(block.header, wusAfterBlock)