diff --git a/node/src/main/scala/com/wavesplatform/api/http/TransactionJsonSerializer.scala b/node/src/main/scala/com/wavesplatform/api/http/TransactionJsonSerializer.scala index 073d5d2c817..78d58883dd3 100644 --- a/node/src/main/scala/com/wavesplatform/api/http/TransactionJsonSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/api/http/TransactionJsonSerializer.scala @@ -283,7 +283,7 @@ final case class TransactionJsonSerializer(blockchain: Blockchain, commonApi: Co tx.assetFee._1.maybeBase58Repr.foreach(gen.writeStringField("feeAssetId", _)) gen.writeNumberField("timestamp", tx.timestamp, numbersAsString) gen.writeNumberField("version", tx.version, numbersAsString) - if (tx.asInstanceOf[PBSince].isProtobufVersion) gen.writeNumberField("chainId", tx.chainId, numbersAsString) + if (PBSince.affects(tx)) gen.writeNumberField("chainId", tx.chainId, numbersAsString) gen.writeStringField("sender", tx.sender.toAddress(tx.chainId).toString) gen.writeStringField("senderPublicKey", tx.sender.toString) gen.writeArrayField("proofs")(gen => tx.proofs.proofs.foreach(p => gen.writeString(p.toString))) @@ -312,7 +312,7 @@ final case class TransactionJsonSerializer(blockchain: Blockchain, commonApi: Co tx.assetFee._1.maybeBase58Repr.foreach(gen.writeStringField("feeAssetId", _)) gen.writeNumberField("timestamp", tx.timestamp, numbersAsString) gen.writeNumberField("version", tx.version, numbersAsString) - if (tx.isProtobufVersion) gen.writeNumberField("chainId", tx.chainId, numbersAsString) + if (PBSince.affects(tx)) gen.writeNumberField("chainId", tx.chainId, numbersAsString) gen.writeStringField("bytes", EthEncoding.toHexString(tx.bytes())) gen.writeStringField("sender", tx.senderAddress().toString) gen.writeStringField("senderPublicKey", tx.signerPublicKey().toString) diff --git a/node/src/main/scala/com/wavesplatform/database/package.scala b/node/src/main/scala/com/wavesplatform/database/package.scala index 9ca8e410bc7..fe3fe467f79 100644 --- a/node/src/main/scala/com/wavesplatform/database/package.scala +++ b/node/src/main/scala/com/wavesplatform/database/package.scala @@ -1,8 +1,5 @@ package com.wavesplatform -import java.nio.ByteBuffer -import java.util -import java.util.Map as JMap import com.google.common.base.Charsets.UTF_8 import com.google.common.collect.{Interners, Maps} import com.google.common.io.ByteStreams.{newDataInput, newDataOutput} @@ -28,15 +25,7 @@ import com.wavesplatform.state.StateHash.SectionId import com.wavesplatform.state.reader.LeaseDetails import com.wavesplatform.transaction.Asset.IssuedAsset import com.wavesplatform.transaction.lease.LeaseTransaction -import com.wavesplatform.transaction.{ - EthereumTransaction, - GenesisTransaction, - PBSince, - PaymentTransaction, - Transaction, - TransactionParsers, - TxValidationError -} +import com.wavesplatform.transaction.{EthereumTransaction, GenesisTransaction, PBSince, PaymentTransaction, Transaction, TransactionParsers, TxValidationError, VersionedTransaction} import com.wavesplatform.utils.* import monix.eval.Task import monix.reactive.Observable @@ -44,6 +33,9 @@ import org.rocksdb.* import sun.nio.ch.Util import supertagged.TaggedType +import java.nio.ByteBuffer +import java.util +import java.util.Map as JMap import scala.annotation.tailrec import scala.collection.mutable.ArrayBuffer import scala.collection.{View, mutable} @@ -645,11 +637,11 @@ package object database { def writeTransaction(v: (TxMeta, Transaction)): Array[Byte] = { val (m, tx) = v val ptx = tx match { - case lps: PBSince if !lps.isProtobufVersion => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) - case _: GenesisTransaction => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) - case _: PaymentTransaction => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) - case et: EthereumTransaction => TD.EthereumTransaction(ByteString.copyFrom(et.bytes())) - case _ => TD.WavesTransaction(PBTransactions.protobuf(tx)) + case lps: PBSince with VersionedTransaction if !PBSince.affects(lps) => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) + case _: GenesisTransaction => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) + case _: PaymentTransaction => TD.LegacyBytes(ByteString.copyFrom(tx.bytes())) + case et: EthereumTransaction => TD.EthereumTransaction(ByteString.copyFrom(et.bytes())) + case _ => TD.WavesTransaction(PBTransactions.protobuf(tx)) } pb.TransactionData(ptx, m.status.protobuf, m.spentComplexity).toByteArray } diff --git a/node/src/main/scala/com/wavesplatform/state/diffs/CommonValidation.scala b/node/src/main/scala/com/wavesplatform/state/diffs/CommonValidation.scala index 86a363846f8..de0c5673d07 100644 --- a/node/src/main/scala/com/wavesplatform/state/diffs/CommonValidation.scala +++ b/node/src/main/scala/com/wavesplatform/state/diffs/CommonValidation.scala @@ -185,7 +185,7 @@ object CommonValidation { case v: VersionedTransaction if !versionIsCorrect(v) && blockchain.isFeatureActivated(LightNode) => Left(UnsupportedTypeAndVersion(v.tpe.id.toByte, v.version)) - case p: PBSince if p.isProtobufVersion => + case p: PBSince with VersionedTransaction if PBSince.affects(p) => activationBarrier(BlockchainFeatures.BlockV5) case v: VersionedTransaction if !versionIsCorrect(v) => diff --git a/node/src/main/scala/com/wavesplatform/state/diffs/FeeValidation.scala b/node/src/main/scala/com/wavesplatform/state/diffs/FeeValidation.scala index 95fcbaea82d..3c52774e02b 100644 --- a/node/src/main/scala/com/wavesplatform/state/diffs/FeeValidation.scala +++ b/node/src/main/scala/com/wavesplatform/state/diffs/FeeValidation.scala @@ -82,7 +82,7 @@ object FeeValidation { case tx: DataTransaction => val payloadLength = if (blockchain.isFeatureActivated(BlockchainFeatures.RideV6)) DataTxValidator.realUserPayloadSize(tx.data) - else if (tx.isProtobufVersion) tx.protoDataPayload.length + else if (PBSince.affects(tx)) tx.protoDataPayload.length else if (blockchain.isFeatureActivated(BlockchainFeatures.SmartAccounts)) tx.bodyBytes().length else tx.bytes().length diff --git a/node/src/main/scala/com/wavesplatform/state/diffs/invoke/InvokeDiffsCommon.scala b/node/src/main/scala/com/wavesplatform/state/diffs/invoke/InvokeDiffsCommon.scala index c8cba5acea9..2451077adcf 100644 --- a/node/src/main/scala/com/wavesplatform/state/diffs/invoke/InvokeDiffsCommon.scala +++ b/node/src/main/scala/com/wavesplatform/state/diffs/invoke/InvokeDiffsCommon.scala @@ -367,7 +367,7 @@ object InvokeDiffsCommon { tx.enableEmptyKeys || dataEntries.forall(_.key.nonEmpty), (), { val versionInfo = tx.root match { - case s: PBSince => s" in tx version >= ${s.protobufVersion}" + case s: PBSince => s" in tx version >= ${PBSince.version(s)}" case _ => "" } s"Empty keys aren't allowed$versionInfo" diff --git a/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala b/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala index 86f93a8fed6..4cb83f2c0d7 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala @@ -1,20 +1,19 @@ package com.wavesplatform.transaction -import com.wavesplatform.transaction.PBSince.* +sealed trait PBSince -import scala.annotation.nowarn +object PBSince { + trait V1 extends PBSince + trait V2 extends PBSince + trait V3 extends PBSince -sealed trait PBSince { self: Transaction & VersionedTransaction => - lazy val protobufVersion: TxVersion = this match { - case _: V1 => TxVersion.V1 - case _: V2 => TxVersion.V2: @nowarn // scalac: unreachable code - case _: V3 => TxVersion.V3 - } - final def isProtobufVersion: Boolean = self.version >= protobufVersion -} + def version(tx: PBSince): TxVersion = + tx match { + case _: V1 => TxVersion.V1 + case _: V2 => TxVersion.V2 + case _: V3 => TxVersion.V3 + } -object PBSince { - trait V1 extends PBSince { self: Transaction & VersionedTransaction => } - trait V2 extends PBSince { self: Transaction & VersionedTransaction => } - trait V3 extends PBSince { self: Transaction & VersionedTransaction => } + def affects(tx: PBSince & VersionedTransaction): Boolean = + tx.version >= version(tx) } diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/BaseTxJson.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/BaseTxJson.scala index ff6ff28cbf0..f8a390787f0 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/BaseTxJson.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/BaseTxJson.scala @@ -15,12 +15,12 @@ object BaseTxJson { case v: VersionedTransaction => Json.obj("version" -> v.version) case _ => Json.obj() }) ++ (tx match { - case pbs: PBSince if pbs.isProtobufVersion => Json.obj("chainId" -> tx.chainId) - case _ => Json.obj() + case pbs: PBSince with VersionedTransaction if PBSince.affects(pbs) => Json.obj("chainId" -> tx.chainId) + case _ => Json.obj() }) ++ (tx match { case p: ProvenTransaction => Json.obj( - "sender" -> p.sender.toAddress(p.chainId), + "sender" -> p.sender.toAddress(p.chainId), "senderPublicKey" -> p.sender, "proofs" -> JsArray(p.proofs.proofs.map(p => JsString(p.toString))) ) ++ (tx match { diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/DataTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/DataTxSerializer.scala index f90ac9726cf..4b0102931fd 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/DataTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/DataTxSerializer.scala @@ -5,10 +5,10 @@ import java.nio.charset.StandardCharsets.UTF_8 import com.google.common.primitives.{Bytes, Longs, Shorts} import com.wavesplatform.common.state.ByteStr import com.wavesplatform.account.AddressScheme -import com.wavesplatform.serialization._ +import com.wavesplatform.serialization.* import com.wavesplatform.state.DataEntry.Type import com.wavesplatform.state.{BinaryDataEntry, BooleanDataEntry, DataEntry, IntegerDataEntry, StringDataEntry} -import com.wavesplatform.transaction.{DataTransaction, TxPositiveAmount, TxVersion} +import com.wavesplatform.transaction.{DataTransaction, PBSince, TxPositiveAmount, TxVersion} import com.wavesplatform.utils.StringBytes import play.api.libs.json.{JsObject, Json} @@ -51,7 +51,7 @@ object DataTxSerializer { } def toBytes(tx: DataTransaction): Array[Byte] = - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(Array(0: Byte), this.bodyBytes(tx), tx.proofs.bytes()) def parseBytes(bytes: Array[Byte]): Try[DataTransaction] = Try { diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/InvokeScriptTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/InvokeScriptTxSerializer.scala index 1e20830e51f..38f7bc1e8df 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/InvokeScriptTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/InvokeScriptTxSerializer.scala @@ -1,7 +1,6 @@ package com.wavesplatform.transaction.serialization.impl import java.nio.ByteBuffer - import com.google.common.primitives.{Bytes, Longs} import com.wavesplatform.common.state.ByteStr import com.wavesplatform.common.utils.* @@ -11,7 +10,7 @@ import com.wavesplatform.lang.v1.serialization.SerdeV1 import com.wavesplatform.serialization.* import com.wavesplatform.transaction.smart.InvokeScriptTransaction import com.wavesplatform.transaction.smart.InvokeScriptTransaction.Payment -import com.wavesplatform.transaction.{Asset, TxPositiveAmount, TxVersion} +import com.wavesplatform.transaction.{Asset, PBSince, TxPositiveAmount, TxVersion} import play.api.libs.json.{JsArray, JsObject, JsString, Json} import scala.util.Try @@ -69,7 +68,7 @@ object InvokeScriptTxSerializer { } def toBytes(tx: InvokeScriptTransaction): Array[Byte] = - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(Array(0: Byte), this.bodyBytes(tx), tx.proofs.bytes()) def parseBytes(bytes: Array[Byte]): Try[InvokeScriptTransaction] = Try { diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/MassTransferTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/MassTransferTxSerializer.scala index 1371a98429e..a0e64fc68a1 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/MassTransferTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/MassTransferTxSerializer.scala @@ -4,8 +4,8 @@ import java.nio.ByteBuffer import com.google.common.primitives.{Bytes, Longs, Shorts} import com.wavesplatform.account.AddressScheme import com.wavesplatform.common.state.ByteStr -import com.wavesplatform.serialization._ -import com.wavesplatform.transaction.{TxNonNegativeAmount, TxPositiveAmount, TxVersion} +import com.wavesplatform.serialization.* +import com.wavesplatform.transaction.{PBSince, TxNonNegativeAmount, TxPositiveAmount, TxVersion} import com.wavesplatform.transaction.transfer.MassTransferTransaction import com.wavesplatform.transaction.transfer.MassTransferTransaction.{ParsedTransfer, Transfer} import com.wavesplatform.utils.byteStrFormat @@ -51,7 +51,7 @@ object MassTransferTxSerializer { } def toBytes(tx: MassTransferTransaction): Array[Byte] = - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(this.bodyBytes(tx), tx.proofs.bytes()) // No zero mark def parseBytes(bytes: Array[Byte]): Try[MassTransferTransaction] = Try { diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetAssetScriptTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetAssetScriptTxSerializer.scala index 2d9b2680262..5122a1c8b6e 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetAssetScriptTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetAssetScriptTxSerializer.scala @@ -4,7 +4,7 @@ import java.nio.ByteBuffer import com.google.common.primitives.{Bytes, Longs} import com.wavesplatform.account.AddressScheme import com.wavesplatform.serialization.{ByteBufferOps, Deser} -import com.wavesplatform.transaction.{TxPositiveAmount, TxVersion} +import com.wavesplatform.transaction.{PBSince, TxPositiveAmount, TxVersion} import com.wavesplatform.transaction.assets.SetAssetScriptTransaction import play.api.libs.json.{JsObject, Json} @@ -38,7 +38,7 @@ object SetAssetScriptTxSerializer { } def toBytes(tx: SetAssetScriptTransaction): Array[Byte] = - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(Array(0: Byte), this.bodyBytes(tx), tx.proofs.bytes()) def parseBytes(bytes: Array[Byte]): Try[SetAssetScriptTransaction] = Try { diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetScriptTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetScriptTxSerializer.scala index 3475e0867c2..77e406ab37b 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetScriptTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SetScriptTxSerializer.scala @@ -4,7 +4,7 @@ import java.nio.ByteBuffer import com.google.common.primitives.{Bytes, Longs} import com.wavesplatform.account.AddressScheme import com.wavesplatform.serialization.{ByteBufferOps, Deser} -import com.wavesplatform.transaction.{TxPositiveAmount, TxVersion} +import com.wavesplatform.transaction.{PBSince, TxPositiveAmount, TxVersion} import com.wavesplatform.transaction.smart.SetScriptTransaction import play.api.libs.json.{JsObject, Json} @@ -36,7 +36,7 @@ object SetScriptTxSerializer { } def toBytes(tx: SetScriptTransaction): Array[Byte] = { - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(Array(0: Byte), this.bodyBytes(tx), tx.proofs.bytes()) } diff --git a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SponsorFeeTxSerializer.scala b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SponsorFeeTxSerializer.scala index 6501d793459..6a6db4be5e7 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SponsorFeeTxSerializer.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/serialization/impl/SponsorFeeTxSerializer.scala @@ -4,7 +4,7 @@ import java.nio.ByteBuffer import com.google.common.primitives.{Bytes, Longs} import com.wavesplatform.account.AddressScheme import com.wavesplatform.serialization.ByteBufferOps -import com.wavesplatform.transaction.{TxPositiveAmount, TxVersion} +import com.wavesplatform.transaction.{PBSince, TxPositiveAmount, TxVersion} import com.wavesplatform.transaction.assets.SponsorFeeTransaction import play.api.libs.json.{JsObject, Json} @@ -38,7 +38,7 @@ object SponsorFeeTxSerializer { } def toBytes(tx: SponsorFeeTransaction): Array[Byte] = { - if (tx.isProtobufVersion) PBTransactionSerializer.bytes(tx) + if (PBSince.affects(tx)) PBTransactionSerializer.bytes(tx) else Bytes.concat(Array(0: Byte, tx.tpe.id.toByte, tx.version), this.bodyBytes(tx), tx.proofs.bytes()) // [typeId, version] appears twice } diff --git a/node/src/main/scala/com/wavesplatform/transaction/validation/impl/ExchangeTxValidator.scala b/node/src/main/scala/com/wavesplatform/transaction/validation/impl/ExchangeTxValidator.scala index 51bf02b5622..ffd8a212b67 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/validation/impl/ExchangeTxValidator.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/validation/impl/ExchangeTxValidator.scala @@ -3,19 +3,19 @@ package com.wavesplatform.transaction.validation.impl import cats.data.ValidatedNel import com.wavesplatform.lang.ValidationError import com.wavesplatform.transaction.TxValidationError.{GenericError, OrderValidationError} -import com.wavesplatform.transaction.TxVersion import com.wavesplatform.transaction.assets.exchange.{ExchangeTransaction, Order, OrderType} import com.wavesplatform.transaction.validation.TxValidator +import com.wavesplatform.transaction.{PBSince, TxVersion} object ExchangeTxValidator extends TxValidator[ExchangeTransaction] { override def validate(tx: ExchangeTransaction): ValidatedNel[ValidationError, ExchangeTransaction] = { - import tx._ + import tx.* V.seq(tx)( V.cond(sellMatcherFee <= Order.MaxAmount, GenericError("sellMatcherFee too large")), V.cond(buyMatcherFee <= Order.MaxAmount, GenericError("buyMatcherFee too large")), V.cond(fee.value <= Order.MaxAmount, GenericError("fee too large")), - V.cond(isProtobufVersion || order1.orderType == OrderType.BUY, GenericError("order1 should have OrderType.BUY")), + V.cond(PBSince.affects(tx) || order1.orderType == OrderType.BUY, GenericError("order1 should have OrderType.BUY")), V.cond(buyOrder.orderType == OrderType.BUY, GenericError("buyOrder should has OrderType.BUY")), V.cond(sellOrder.orderType == OrderType.SELL, GenericError("sellOrder should has OrderType.SELL")), V.cond(buyOrder.matcherPublicKey == sellOrder.matcherPublicKey, GenericError("buyOrder.matcher should be the same as sellOrder.matcher")), diff --git a/node/src/main/scala/com/wavesplatform/transaction/validation/impl/InvokeScriptTxValidator.scala b/node/src/main/scala/com/wavesplatform/transaction/validation/impl/InvokeScriptTxValidator.scala index 0621ca97acb..333a5916bc2 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/validation/impl/InvokeScriptTxValidator.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/validation/impl/InvokeScriptTxValidator.scala @@ -2,15 +2,16 @@ package com.wavesplatform.transaction.validation.impl import cats.data.NonEmptyList import cats.data.Validated.{Invalid, Valid} -import cats.syntax.either._ +import cats.syntax.either.* import com.wavesplatform.lang.v1.compiler.Terms.FUNCTION_CALL import com.wavesplatform.lang.v1.{ContractLimits, FunctionHeader} import com.wavesplatform.protobuf.transaction.PBTransactions +import com.wavesplatform.transaction.PBSince import com.wavesplatform.transaction.TxValidationError.{GenericError, NonPositiveAmount} import com.wavesplatform.transaction.smart.InvokeScriptTransaction import com.wavesplatform.transaction.smart.InvokeScriptTransaction.Payment import com.wavesplatform.transaction.validation.{TxValidator, ValidatedNV, ValidatedV} -import com.wavesplatform.utils._ +import com.wavesplatform.utils.* import scala.util.Try @@ -27,7 +28,7 @@ object InvokeScriptTxValidator extends TxValidator[InvokeScriptTransaction] { def checkLength: Either[GenericError, Unit] = { val length = - if (tx.isProtobufVersion) + if (PBSince.affects(tx)) PBTransactions.toPBInvokeScriptData(tx.dApp, tx.funcCallOpt, tx.payments).toByteArray.length else tx.bytes().length diff --git a/node/src/test/scala/com/wavesplatform/http/ProtoVersionTransactionsSpec.scala b/node/src/test/scala/com/wavesplatform/http/ProtoVersionTransactionsSpec.scala index 667863482bf..e82802d734f 100644 --- a/node/src/test/scala/com/wavesplatform/http/ProtoVersionTransactionsSpec.scala +++ b/node/src/test/scala/com/wavesplatform/http/ProtoVersionTransactionsSpec.scala @@ -158,9 +158,9 @@ class ProtoVersionTransactionsSpec (reissueTx.json() \ "chainId").asOpt[Byte].value shouldBe reissueTx.chainId (burnTx.json() \ "chainId").asOpt[Byte].value shouldBe burnTx.chainId - issueTx.isProtobufVersion shouldBe true - reissueTx.isProtobufVersion shouldBe true - burnTx.isProtobufVersion shouldBe true + PBSince.affects(issueTx) shouldBe true + PBSince.affects(reissueTx) shouldBe true + PBSince.affects(burnTx) shouldBe true } "DataTransaction" in { @@ -183,7 +183,7 @@ class ProtoVersionTransactionsSpec (dataTx.json() \ "chainId").asOpt[Byte].value shouldBe dataTx.chainId - dataTx.isProtobufVersion shouldBe true + PBSince.affects(dataTx) shouldBe true } "ExchangeTransaction" in { @@ -210,7 +210,7 @@ class ProtoVersionTransactionsSpec (exchangeTx.json() \ "chainId").asOpt[Byte].value shouldBe exchangeTx.chainId - exchangeTx.isProtobufVersion shouldBe true + PBSince.affects(exchangeTx) shouldBe true } "InvokeScriptTransaction" in { @@ -247,7 +247,7 @@ class ProtoVersionTransactionsSpec (invokeScriptTx.json() \ "chainId").asOpt[Byte].value shouldBe invokeScriptTx.chainId - invokeScriptTx.isProtobufVersion shouldBe true + PBSince.affects(invokeScriptTx) shouldBe true } "LeaseTransaction/LeaseCancelTransaction" in { @@ -287,8 +287,8 @@ class ProtoVersionTransactionsSpec (leaseTx.json() \ "chainId").asOpt[Byte].value shouldBe leaseTx.chainId (leaseCancelTx.json() \ "chainId").asOpt[Byte].value shouldBe leaseCancelTx.chainId - leaseTx.isProtobufVersion shouldBe true - leaseCancelTx.isProtobufVersion shouldBe true + PBSince.affects(leaseTx) shouldBe true + PBSince.affects(leaseCancelTx) shouldBe true } "TransferTransaction" in { @@ -316,7 +316,7 @@ class ProtoVersionTransactionsSpec (transferTx.json() \ "chainId").asOpt[Byte].value shouldBe transferTx.chainId - transferTx.isProtobufVersion shouldBe true + PBSince.affects(transferTx) shouldBe true } "MassTransferTransaction" in { @@ -344,7 +344,7 @@ class ProtoVersionTransactionsSpec (massTransferTx.json() \ "chainId").asOpt[Byte].value shouldBe massTransferTx.chainId - massTransferTx.isProtobufVersion shouldBe true + PBSince.affects(massTransferTx) shouldBe true } "SetScriptTransaction" in { @@ -389,7 +389,7 @@ class ProtoVersionTransactionsSpec decode(base64Str) shouldBe setAssetScriptTx - setAssetScriptTx.isProtobufVersion shouldBe true + PBSince.affects(setAssetScriptTx) shouldBe true } "SponsorshipTransaction" in { @@ -414,7 +414,7 @@ class ProtoVersionTransactionsSpec (sponsorshipTx.json() \ "chainId").asOpt[Byte].value shouldBe sponsorshipTx.chainId - sponsorshipTx.isProtobufVersion shouldBe true + PBSince.affects(sponsorshipTx) shouldBe true } "UpdateAssetInfoTransaction" in { diff --git a/node/src/test/scala/com/wavesplatform/transaction/MassTransferTransactionSpecification.scala b/node/src/test/scala/com/wavesplatform/transaction/MassTransferTransactionSpecification.scala index 8f7c783895f..5b49db93917 100644 --- a/node/src/test/scala/com/wavesplatform/transaction/MassTransferTransactionSpecification.scala +++ b/node/src/test/scala/com/wavesplatform/transaction/MassTransferTransactionSpecification.scala @@ -67,7 +67,7 @@ class MassTransferTransactionSpecification extends PropSpec { ) val bytes = tx.bytes() val recovered = { - if (tx.isProtobufVersion) PBTransactionSerializer.parseBytes(bytes) + if (PBSince.affects(tx)) PBTransactionSerializer.parseBytes(bytes) else MassTransferTransaction.parseBytes(bytes) }.get recovered shouldEqual tx @@ -125,7 +125,7 @@ class MassTransferTransactionSpecification extends PropSpec { proofs = Proofs(proofs), chainId = chainId ) - if (!tx.isProtobufVersion && tx.chainId == AddressScheme.current.chainId) { + if (!PBSince.affects(tx) && tx.chainId == AddressScheme.current.chainId) { val recovered = TransactionParsers.parseBytes(tx.bytes()).get recovered.bytes() shouldEqual tx.bytes() }