From 9445ce5aa64d9c4fb22a8dd3914e4000015bb9af Mon Sep 17 00:00:00 2001 From: Ilya Smagin Date: Sat, 28 Apr 2018 18:05:25 +0300 Subject: [PATCH] Fix burn amount --- .../transaction/assets/BurnTransaction.scala | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/scala/scorex/transaction/assets/BurnTransaction.scala b/src/main/scala/scorex/transaction/assets/BurnTransaction.scala index 18e36d66c5c..71229f34340 100644 --- a/src/main/scala/scorex/transaction/assets/BurnTransaction.scala +++ b/src/main/scala/scorex/transaction/assets/BurnTransaction.scala @@ -1,6 +1,5 @@ package scorex.transaction.assets -import cats.implicits._ import com.google.common.primitives.{Bytes, Longs} import com.wavesplatform.state.ByteStr import monix.eval.Coeval @@ -8,7 +7,6 @@ import play.api.libs.json.{JsObject, Json} import scorex.account.PublicKeyAccount import scorex.crypto.signatures.Curve25519.KeyLength import scorex.transaction._ -import scorex.transaction.validation._ trait BurnTransaction extends ProvenTransaction { def version: Byte @@ -62,12 +60,10 @@ object BurnTransaction { (sender, assetId, quantity, fee, timestamp, quantityStart + 24) } - def validateBurnParams(amount: Long, fee: Long): Either[ValidationError, Unit] = { - (validateAmount(amount, "assets"), validateFee(fee)) - .mapN { case _ => () } - .fold( - _.head.asLeft[Unit], - _.asRight[ValidationError] - ) - } + def validateBurnParams(amount: Long, fee: Long): Either[ValidationError, Unit] = + if (amount < 0) { + Left(ValidationError.NegativeAmount(amount, "assets")) + } else if (fee <= 0) { + Left(ValidationError.InsufficientFee()) + } else Right(()) }