Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module, containing function to interpret Michelson instructions against given context and input stack.
Synopsis
- data ContractEnv = ContractEnv {}
- data InterpreterState = InterpreterState {}
- isMorleyLogsL :: Lens' InterpreterState MorleyLogs
- data MichelsonFailed where
- MichelsonFailedWith :: KnownT t => Value t -> MichelsonFailed
- MichelsonArithError :: (Typeable n, Typeable m, Typeable instr) => ArithError (Value' instr n) (Value' instr m) -> MichelsonFailed
- MichelsonGasExhaustion :: MichelsonFailed
- MichelsonFailedTestAssert :: Text -> MichelsonFailed
- newtype RemainingSteps = RemainingSteps Word64
- data SomeItStack where
- SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack
- newtype MorleyLogs = MorleyLogs [Text]
- noMorleyLogs :: MorleyLogs
- pickMorleyLogs :: MorleyLogs -> [Text]
- interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> ContractEnv -> ContractReturn st
- interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either MichelsonFailed (Rec Value out)
- interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either MichelsonFailed (Rec StkEl out)
- type ContractReturn st = (Either MichelsonFailed ([Operation], Value st), InterpreterState)
- mkInitStack :: Value param -> ParamNotes param -> Value st -> Notes st -> Rec StkEl (ContractInp param st)
- fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st)
- newtype InterpretError = InterpretError (MichelsonFailed, MorleyLogs)
- data InterpretResult where
- InterpretResult :: StorageScope st => {..} -> InterpretResult
- type EvalM m = (MonadReader ContractEnv m, InterpreterStateMonad m, MonadError MichelsonFailed m)
- class Monad m => InterpreterStateMonad m where
- getInterpreterState :: m InterpreterState
- putInterpreterState :: InterpreterState -> m ()
- stateInterpreterState :: (InterpreterState -> (a, InterpreterState)) -> m a
- modifyInterpreterState :: (InterpreterState -> InterpreterState) -> m ()
- data 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 :: ContractEnv -> InterpreterState
- handleContractReturn :: StorageScope st => ContractReturn st -> Either InterpretError InterpretResult
- runInstrImpl :: EvalM m => InstrRunner m -> InstrRunner m
Documentation
data ContractEnv Source #
Environment for contract execution.
ContractEnv | |
|
Instances
data InterpreterState Source #
Instances
data MichelsonFailed where Source #
Represents [FAILED]
state of a Michelson program. Contains
value that was on top of the stack when FAILWITH
was called.
MichelsonFailedWith :: KnownT t => Value t -> MichelsonFailed | |
MichelsonArithError :: (Typeable n, Typeable m, Typeable instr) => ArithError (Value' instr n) (Value' instr m) -> MichelsonFailed | |
MichelsonGasExhaustion :: MichelsonFailed | |
MichelsonFailedTestAssert :: Text -> MichelsonFailed |
Instances
newtype RemainingSteps Source #
Instances
data SomeItStack where Source #
SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack |
newtype MorleyLogs Source #
Morley logs for interpreter state that are stored in reverse order.
Instances
pickMorleyLogs :: MorleyLogs -> [Text] Source #
interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> ContractEnv -> ContractReturn st Source #
interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either MichelsonFailed (Rec Value out) Source #
Interpret an instruction in vacuum, putting no extra contraints on its execution.
Mostly for testing purposes.
interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either MichelsonFailed (Rec StkEl out) Source #
Interpret an instruction in vacuum, putting no extra contraints on its execution while preserving its annotations.
Mostly for testing purposes.
type ContractReturn st = (Either MichelsonFailed ([Operation], Value st), InterpreterState) Source #
mkInitStack :: Value param -> ParamNotes param -> Value st -> Notes st -> Rec StkEl (ContractInp param st) Source #
fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st) Source #
newtype InterpretError Source #
Instances
Show InterpretError Source # | |
Defined in Michelson.Interpret showsPrec :: Int -> InterpretError -> ShowS # show :: InterpretError -> String # showList :: [InterpretError] -> ShowS # | |
Generic InterpretError Source # | |
Defined in Michelson.Interpret type Rep InterpretError :: Type -> Type # from :: InterpretError -> Rep InterpretError x # to :: Rep InterpretError x -> InterpretError # | |
Buildable InterpretError Source # | |
Defined in Michelson.Interpret build :: InterpretError -> Builder # | |
type Rep InterpretError Source # | |
Defined in Michelson.Interpret type Rep InterpretError = D1 ('MetaData "InterpretError" "Michelson.Interpret" "morley-1.12.0-inplace" 'True) (C1 ('MetaCons "InterpretError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MichelsonFailed, MorleyLogs)))) |
data InterpretResult where Source #
InterpretResult | |
|
Instances
Show InterpretResult Source # | |
Defined in Michelson.Interpret showsPrec :: Int -> InterpretResult -> ShowS # show :: InterpretResult -> String # showList :: [InterpretResult] -> ShowS # |
type EvalM m = (MonadReader ContractEnv m, InterpreterStateMonad m, MonadError MichelsonFailed m) Source #
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
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 InterpretResult Source #
runInstrImpl :: EvalM m => InstrRunner m -> InstrRunner m Source #
Function to interpret Michelson instruction(s) against given stack.