-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix typo * SC-727 REPL imports * Improve and test error message for lets restriction
- Loading branch information
Showing
6 changed files
with
123 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 35 additions & 32 deletions
67
lang/shared/src/main/scala/com/wavesplatform/lang/v1/repl/node/ErrorMessageEnvironment.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,46 @@ | ||
package com.wavesplatform.lang.v1.repl.node | ||
|
||
import com.wavesplatform.common.state.ByteStr | ||
import com.wavesplatform.lang.ValidationError | ||
import com.wavesplatform.lang.script.Script | ||
import com.wavesplatform.lang.v1.compiler.Terms.EVALUATED | ||
import com.wavesplatform.lang.v1.traits.Environment.InputEntity | ||
import com.wavesplatform.lang.v1.traits.domain.{BlockInfo, Recipient, ScriptAssetInfo, Tx} | ||
import com.wavesplatform.lang.v1.traits.domain.Recipient.Address | ||
import com.wavesplatform.lang.v1.traits.domain.{BlockInfo, Recipient, ScriptAssetInfo, Tx} | ||
import com.wavesplatform.lang.v1.traits.{DataType, Environment} | ||
import com.wavesplatform.lang.v1.compiler.Terms.EVALUATED | ||
import com.wavesplatform.lang.ValidationError | ||
import com.wavesplatform.lang.script.Script | ||
import monix.eval.Coeval | ||
|
||
import scala.concurrent.Future | ||
|
||
object ErrorMessageEnvironment extends Environment[Future] { | ||
lazy val unavailable = throw new BlockchainUnavailableException() | ||
override def chainId: Byte = 0 | ||
override def height: Future[Long] = unavailable | ||
override def inputEntity: InputEntity = unavailable | ||
override def tthis: Environment.Tthis = unavailable | ||
override def transactionById(id: Array[Byte]): Future[Option[Tx]] = unavailable | ||
override def transferTransactionById(id: Array[Byte]): Future[Option[Tx.Transfer]] = unavailable | ||
override def transactionHeightById(id: Array[Byte]): Future[Option[Long]] = unavailable | ||
override def assetInfoById(d: Array[Byte]): Future[Option[ScriptAssetInfo]] = unavailable | ||
override def lastBlockOpt(): Future[Option[BlockInfo]] = unavailable | ||
override def blockInfoByHeight(height: Int): Future[Option[BlockInfo]] = unavailable | ||
override def data(addressOrAlias: Recipient, key: String, dataType: DataType): Future[Option[Any]] = unavailable | ||
override def hasData(addressOrAlias: Recipient): Future[Boolean] = unavailable | ||
override def resolveAlias(name: String): Future[Either[String, Recipient.Address]] = unavailable | ||
override def accountBalanceOf(addressOrAlias: Recipient, assetId: Option[Array[Byte]]): Future[Either[String, Long]] = unavailable | ||
override def accountWavesBalanceOf(addressOrAlias: Recipient): Future[Either[String, Environment.BalanceDetails]] = unavailable | ||
override def multiPaymentAllowed: Boolean = unavailable | ||
override def txId: ByteStr = unavailable | ||
override def transferTransactionFromProto(b: Array[Byte]): Future[Option[Tx.Transfer]] = unavailable | ||
override def addressFromString(address: String): Either[String, Recipient.Address] = unavailable | ||
override def accountScript(addressOrAlias: Recipient): Future[Option[Script]] = unavailable | ||
override def callScript(dApp: Address, func: String, args: List[EVALUATED], payments: Seq[(Option[Array[Byte]], Long)], availableComplexity: Int): Coeval[Future[(Either[ValidationError, EVALUATED], Int)]] = unavailable | ||
case class ErrorMessageEnvironment[F[_]](message: String) extends Environment[F] { | ||
lazy val unavailable = throw new BlockchainUnavailableException(message) | ||
override def chainId: Byte = 0 | ||
override def height: F[Long] = unavailable | ||
override def inputEntity: InputEntity = unavailable | ||
override def tthis: Environment.Tthis = unavailable | ||
override def transactionById(id: Array[Byte]): F[Option[Tx]] = unavailable | ||
override def transferTransactionById(id: Array[Byte]): F[Option[Tx.Transfer]] = unavailable | ||
override def transactionHeightById(id: Array[Byte]): F[Option[Long]] = unavailable | ||
override def assetInfoById(d: Array[Byte]): F[Option[ScriptAssetInfo]] = unavailable | ||
override def lastBlockOpt(): F[Option[BlockInfo]] = unavailable | ||
override def blockInfoByHeight(height: Int): F[Option[BlockInfo]] = unavailable | ||
override def data(addressOrAlias: Recipient, key: String, dataType: DataType): F[Option[Any]] = unavailable | ||
override def hasData(addressOrAlias: Recipient): F[Boolean] = unavailable | ||
override def resolveAlias(name: String): F[Either[String, Recipient.Address]] = unavailable | ||
override def accountBalanceOf(addressOrAlias: Recipient, assetId: Option[Array[Byte]]): F[Either[String, Long]] = unavailable | ||
override def accountWavesBalanceOf(addressOrAlias: Recipient): F[Either[String, Environment.BalanceDetails]] = unavailable | ||
override def multiPaymentAllowed: Boolean = unavailable | ||
override def txId: ByteStr = unavailable | ||
override def transferTransactionFromProto(b: Array[Byte]): F[Option[Tx.Transfer]] = unavailable | ||
override def addressFromString(address: String): Either[String, Recipient.Address] = unavailable | ||
override def accountScript(addressOrAlias: Recipient): F[Option[Script]] = unavailable | ||
override def callScript( | ||
dApp: Address, | ||
func: String, | ||
args: List[EVALUATED], | ||
payments: Seq[(Option[Array[Byte]], Long)], | ||
availableComplexity: Int | ||
): Coeval[F[(Either[ValidationError, EVALUATED], Int)]] = unavailable | ||
} | ||
|
||
class BlockchainUnavailableException extends RuntimeException { | ||
override def toString: String = "Blockchain state is unavailable from REPL" | ||
case class BlockchainUnavailableException(message: String) extends RuntimeException { | ||
override def toString: String = message | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters