Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Module, containing function to interpret Michelson instructions against given context and input stack.
Synopsis
- data ContractEnv = ContractEnv {
- ceNow :: Timestamp
- ceMaxSteps :: RemainingSteps
- ceBalance :: Mutez
- ceContracts :: Map ContractAddress ContractState
- ceSelf :: ContractAddress
- ceSource :: L1Address
- ceSender :: L1Address
- ceAmount :: Mutez
- ceVotingPowers :: VotingPowers
- ceChainId :: ChainId
- ceOperationHash :: Maybe OperationHash
- ceLevel :: Natural
- ceErrorSrcPos :: ErrorSrcPos
- ceMinBlockTime :: Natural
- data InterpreterState = InterpreterState {}
- data MichelsonFailed ext where
- MichelsonFailedWith :: (SingI t, ConstantScope t) => Value t -> MichelsonFailed ext
- MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed ext
- MichelsonGasExhaustion :: MichelsonFailed ext
- MichelsonFailedTestAssert :: Text -> MichelsonFailed ext
- MichelsonUnsupported :: Text -> MichelsonFailed ext
- MichelsonExt :: ext -> MichelsonFailed ext
- data MichelsonFailureWithStack ext = MichelsonFailureWithStack {}
- newtype RemainingSteps = RemainingSteps Word64
- data SomeItStack where
- SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack
- newtype MorleyLogs = MorleyLogs {
- unMorleyLogs :: [Text]
- buildMorleyLogs :: MorleyLogsBuilder -> MorleyLogs
- newtype MorleyLogsBuilder = MorleyLogsBuilder (Endo [Text])
- interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> GlobalCounter -> BigMapCounter -> ContractEnv -> ContractReturn st
- interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec Value out)
- interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec StkEl out)
- type ContractReturn st = (Either (MichelsonFailureWithStack Void) ([Operation], Value st), (InterpreterState, MorleyLogs))
- mkInitStack :: Value param -> Value st -> Rec StkEl (ContractInp param st)
- fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st)
- newtype InterpretError ext = InterpretError (MichelsonFailureWithStack ext, MorleyLogs)
- data InterpretResult where
- InterpretResult :: StorageScope st => {..} -> InterpretResult
- type EvalM m = EvalM' Void m
- class Monad m => InterpreterStateMonad m where
- getInterpreterState :: m InterpreterState
- putInterpreterState :: InterpreterState -> m ()
- stateInterpreterState :: (InterpreterState -> (a, InterpreterState)) -> m a
- modifyInterpreterState :: (InterpreterState -> InterpreterState) -> m ()
- newtype StkEl t = StkEl {}
- type InstrRunner m = forall inp out. Instr inp out -> Rec StkEl inp -> m (Rec StkEl out)
- runInstr :: EvalM m => InstrRunner m
- runInstrNoGas :: EvalM m => InstrRunner m
- runUnpack :: forall t. UnpackedValScope t => ByteString -> Either UnpackError (Value t)
- initInterpreterState :: GlobalCounter -> BigMapCounter -> ContractEnv -> InterpreterState
- handleContractReturn :: StorageScope st => ContractReturn st -> Either (InterpretError Void) InterpretResult
- runInstrImpl :: forall ext m. EvalM' ext m => InstrRunner m -> InstrRunner m
- assignBigMapIds :: MonadState BigMapCounter m => Bool -> Value t -> m (Value t)
- _MorleyLogs :: Iso' MorleyLogs [Text]
Documentation
data ContractEnv Source #
Environment for contract execution.
ContractEnv | |
|
data InterpreterState Source #
Instances
data MichelsonFailed ext where Source #
Errors that can be thrown by the interpreter. The ext
type variable
allow the downstreams consumer to add additional exceptions.
MichelsonFailedWith | |
| |
MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed ext | |
MichelsonGasExhaustion :: MichelsonFailed ext | |
MichelsonFailedTestAssert :: Text -> MichelsonFailed ext | |
MichelsonUnsupported :: Text -> MichelsonFailed ext | |
MichelsonExt :: ext -> MichelsonFailed ext |
Instances
Show ext => Show (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret showsPrec :: Int -> MichelsonFailed ext -> ShowS # show :: MichelsonFailed ext -> String # showList :: [MichelsonFailed ext] -> ShowS # | |
NFData ext => NFData (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret rnf :: MichelsonFailed ext -> () # | |
Buildable ext => Buildable (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret build :: MichelsonFailed ext -> Builder # | |
Eq ext => Eq (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret (==) :: MichelsonFailed ext -> MichelsonFailed ext -> Bool # (/=) :: MichelsonFailed ext -> MichelsonFailed ext -> Bool # |
data MichelsonFailureWithStack ext Source #
Carries a MichelsonFailed
ext
error and the ErrorSrcPos
at which it was raised
Instances
newtype RemainingSteps Source #
Instances
data SomeItStack where Source #
SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack |
newtype MorleyLogs Source #
Morley logs appearing as interpreter result.
MorleyLogs | |
|
Instances
newtype MorleyLogsBuilder Source #
Morley logs accumulator, for incremental building.
Instances
interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> GlobalCounter -> BigMapCounter -> ContractEnv -> ContractReturn st Source #
interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec Value out) Source #
Interpret an instruction in vacuum, putting no extra constraints on its execution.
Mostly for testing purposes.
interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec StkEl out) Source #
Interpret an instruction in vacuum, putting no extra constraints on its execution while preserving its annotations.
Mostly for testing purposes.
type ContractReturn st = (Either (MichelsonFailureWithStack Void) ([Operation], Value st), (InterpreterState, MorleyLogs)) Source #
mkInitStack :: Value param -> Value st -> Rec StkEl (ContractInp param st) Source #
fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st) Source #
newtype InterpretError ext Source #
Instances
Generic (InterpretError ext) Source # | |
Defined in Morley.Michelson.Interpret type Rep (InterpretError ext) :: Type -> Type # from :: InterpretError ext -> Rep (InterpretError ext) x # to :: Rep (InterpretError ext) x -> InterpretError ext # | |
Show ext => Show (InterpretError ext) Source # | |
Defined in Morley.Michelson.Interpret showsPrec :: Int -> InterpretError ext -> ShowS # show :: InterpretError ext -> String # showList :: [InterpretError ext] -> ShowS # | |
Buildable ext => Buildable (InterpretError ext) Source # | |
Defined in Morley.Michelson.Interpret build :: InterpretError ext -> Builder # | |
type Rep (InterpretError ext) Source # | |
Defined in Morley.Michelson.Interpret type Rep (InterpretError ext) = D1 ('MetaData "InterpretError" "Morley.Michelson.Interpret" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "InterpretError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MichelsonFailureWithStack ext, MorleyLogs)))) |
data InterpretResult where Source #
InterpretResult | |
|
Instances
Show InterpretResult Source # | |
Defined in Morley.Michelson.Interpret showsPrec :: Int -> InterpretResult -> ShowS # show :: InterpretResult -> String # showList :: [InterpretResult] -> ShowS # |
class Monad m => InterpreterStateMonad m where Source #
Nothing
getInterpreterState :: m InterpreterState Source #
putInterpreterState :: InterpreterState -> m () Source #
stateInterpreterState :: (InterpreterState -> (a, InterpreterState)) -> m a Source #
modifyInterpreterState :: (InterpreterState -> InterpreterState) -> m () Source #
Instances
Instances
runInstr :: EvalM m => InstrRunner m Source #
Function to change amount of remaining steps stored in State monad.
runInstrNoGas :: EvalM m => InstrRunner m Source #
runUnpack :: forall t. UnpackedValScope t => ByteString -> Either UnpackError (Value t) Source #
Unpacks given raw data into a typed value.
Internals
handleContractReturn :: StorageScope st => ContractReturn st -> Either (InterpretError Void) InterpretResult Source #
runInstrImpl :: forall ext m. EvalM' ext m => InstrRunner m -> InstrRunner m Source #
Function to interpret Michelson instruction(s) against given stack.
The ext
type variable specifies additional exceptions that can be thrown from the inner
runner function (via MichelsonExt
). In Morley, it's set to Void
, but downstream consumers
may use other type here.
:: MonadState BigMapCounter m | |
=> Bool | If true, assign a new ID even if the bigmap already has one. Otherwise, assign IDs only to bigmaps that don't have one yet. |
-> Value t | |
-> m (Value t) |
All big_maps stored in a chain have a globally unique ID.
We use this function to assign a new ID whenever a big_map is created.
Prisms
_MorleyLogs :: Iso' MorleyLogs [Text] Source #