Safe Haskell | None |
---|---|
Language | Haskell2010 |
Michelson.Interpret
Contents
Description
Module, containing function to interpret Michelson instructions against given context and input stack.
Synopsis
- data ContractEnv = ContractEnv {}
- data InterpreterState = InterpreterState {}
- 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
- MichelsonAmbigousEpRef :: EpName -> EpAddress -> MichelsonFailed
- newtype RemainingSteps = RemainingSteps Word64
- data SomeItStack where
- SomeItStack :: ExtInstr inp -> Rec Value inp -> SomeItStack
- newtype MorleyLogs = MorleyLogs {
- unMorleyLogs :: [Text]
- noMorleyLogs :: MorleyLogs
- interpret :: ContractCode 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)
- type ContractReturn st = (Either MichelsonFailed ([Operation], Value st), InterpreterState)
- mkInitStack :: Value param -> Value st -> Rec Value (ContractInp param st)
- fromFinalStack :: Rec Value (ContractOut st) -> ([Operation], Value st)
- newtype InterpretError = InterpretError (MichelsonFailed, MorleyLogs)
- data InterpretResult where
- InterpretResult :: StorageScope st => {..} -> InterpretResult
- type EvalM m = (MonadReader ContractEnv m, MonadState InterpreterState m, MonadError MichelsonFailed m)
- type InstrRunner m = forall inp out. Instr inp out -> Rec Value inp -> m (Rec Value 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.
Constructors
ContractEnv | |
Fields
|
data InterpreterState Source #
Constructors
InterpreterState | |
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.
Constructors
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 | |
MichelsonAmbigousEpRef :: EpName -> EpAddress -> MichelsonFailed |
Instances
Eq MichelsonFailed Source # | |
Defined in Michelson.Interpret Methods (==) :: MichelsonFailed -> MichelsonFailed -> Bool # (/=) :: MichelsonFailed -> MichelsonFailed -> Bool # | |
Show MichelsonFailed Source # | |
Defined in Michelson.Interpret Methods showsPrec :: Int -> MichelsonFailed -> ShowS # show :: MichelsonFailed -> String # showList :: [MichelsonFailed] -> ShowS # | |
NFData MichelsonFailed Source # | |
Defined in Michelson.Interpret Methods rnf :: MichelsonFailed -> () # | |
Buildable MichelsonFailed Source # | |
Defined in Michelson.Interpret Methods build :: MichelsonFailed -> Builder # |
newtype RemainingSteps Source #
Constructors
RemainingSteps Word64 |
Instances
data SomeItStack where Source #
Constructors
SomeItStack :: ExtInstr inp -> Rec Value inp -> SomeItStack |
newtype MorleyLogs Source #
Morley logs for interpreter state.
Constructors
MorleyLogs | |
Fields
|
Instances
Eq MorleyLogs Source # | |
Defined in Michelson.Interpret | |
Show MorleyLogs Source # | |
Defined in Michelson.Interpret Methods showsPrec :: Int -> MorleyLogs -> ShowS # show :: MorleyLogs -> String # showList :: [MorleyLogs] -> ShowS # | |
Generic MorleyLogs Source # | |
Defined in Michelson.Interpret Associated Types type Rep MorleyLogs :: Type -> Type # | |
NFData MorleyLogs Source # | |
Defined in Michelson.Interpret Methods rnf :: MorleyLogs -> () # | |
Default MorleyLogs Source # | |
Defined in Michelson.Interpret Methods def :: MorleyLogs # | |
Buildable MorleyLogs Source # | |
Defined in Michelson.Interpret Methods build :: MorleyLogs -> Builder # | |
type Rep MorleyLogs Source # | |
Defined in Michelson.Interpret type Rep MorleyLogs = D1 ('MetaData "MorleyLogs" "Michelson.Interpret" "morley-1.7.0-inplace" 'True) (C1 ('MetaCons "MorleyLogs" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMorleyLogs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]))) |
interpret :: ContractCode 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.
type ContractReturn st = (Either MichelsonFailed ([Operation], Value st), InterpreterState) Source #
mkInitStack :: Value param -> Value st -> Rec Value (ContractInp param st) Source #
fromFinalStack :: Rec Value (ContractOut st) -> ([Operation], Value st) Source #
newtype InterpretError Source #
Constructors
InterpretError (MichelsonFailed, MorleyLogs) |
Instances
Show InterpretError Source # | |
Defined in Michelson.Interpret Methods showsPrec :: Int -> InterpretError -> ShowS # show :: InterpretError -> String # showList :: [InterpretError] -> ShowS # | |
Generic InterpretError Source # | |
Defined in Michelson.Interpret Associated Types type Rep InterpretError :: Type -> Type # Methods from :: InterpretError -> Rep InterpretError x # to :: Rep InterpretError x -> InterpretError # | |
Buildable InterpretError Source # | |
Defined in Michelson.Interpret Methods build :: InterpretError -> Builder # | |
type Rep InterpretError Source # | |
Defined in Michelson.Interpret type Rep InterpretError = D1 ('MetaData "InterpretError" "Michelson.Interpret" "morley-1.7.0-inplace" 'True) (C1 ('MetaCons "InterpretError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MichelsonFailed, MorleyLogs)))) |
data InterpretResult where Source #
Constructors
InterpretResult | |
Fields
|
Instances
Show InterpretResult Source # | |
Defined in Michelson.Interpret Methods showsPrec :: Int -> InterpretResult -> ShowS # show :: InterpretResult -> String # showList :: [InterpretResult] -> ShowS # |
type EvalM m = (MonadReader ContractEnv m, MonadState InterpreterState m, MonadError MichelsonFailed m) Source #
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.