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 Address AddressState
- ceSelf :: Address
- ceSource :: Address
- ceSender :: Address
- ceAmount :: Mutez
- ceVotingPowers :: VotingPowers
- ceChainId :: ChainId
- ceOperationHash :: Maybe OperationHash
- ceLevel :: Natural
- ceErrorSrcPos :: ErrorSrcPos
- ceMinBlockTime :: Natural
- data InterpreterState = InterpreterState {}
- data MichelsonFailed where
- MichelsonFailedWith :: (SingI t, ConstantScope t) => Value t -> MichelsonFailed
- MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed
- MichelsonGasExhaustion :: MichelsonFailed
- MichelsonFailedTestAssert :: Text -> MichelsonFailed
- MichelsonUnsupported :: Text -> MichelsonFailed
- data MichelsonFailureWithStack = 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 (Rec Value out)
- interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either MichelsonFailureWithStack (Rec StkEl out)
- type ContractReturn st = (Either MichelsonFailureWithStack ([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 = InterpretError (MichelsonFailureWithStack, MorleyLogs)
- data InterpretResult where
- InterpretResult :: StorageScope st => {..} -> InterpretResult
- type EvalM m = (MonadReader ContractEnv m, InterpreterStateMonad m, MonadWriter MorleyLogsBuilder m, MonadError MichelsonFailureWithStack 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 InterpretResult
- runInstrImpl :: forall m. EvalM 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 where Source #
Represents [FAILED]
state of a Michelson program. Contains
value that was on top of the stack when FAILWITH
was called.
MichelsonFailedWith :: (SingI t, ConstantScope t) => Value t -> MichelsonFailed | |
MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed | |
MichelsonGasExhaustion :: MichelsonFailed | |
MichelsonFailedTestAssert :: Text -> MichelsonFailed | |
MichelsonUnsupported :: Text -> MichelsonFailed |
Instances
Show MichelsonFailed Source # | |
Defined in Morley.Michelson.Interpret showsPrec :: Int -> MichelsonFailed -> ShowS # show :: MichelsonFailed -> String # showList :: [MichelsonFailed] -> ShowS # | |
NFData MichelsonFailed Source # | |
Defined in Morley.Michelson.Interpret rnf :: MichelsonFailed -> () # | |
Buildable MichelsonFailed Source # | |
Defined in Morley.Michelson.Interpret build :: MichelsonFailed -> Builder # | |
Eq MichelsonFailed Source # | |
Defined in Morley.Michelson.Interpret (==) :: MichelsonFailed -> MichelsonFailed -> Bool # (/=) :: MichelsonFailed -> MichelsonFailed -> Bool # |
data MichelsonFailureWithStack Source #
Carries a MichelsonFailed
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 (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 (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 ([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 Source #
Instances
Generic InterpretError Source # | |
Defined in Morley.Michelson.Interpret type Rep InterpretError :: Type -> Type # from :: InterpretError -> Rep InterpretError x # to :: Rep InterpretError x -> InterpretError # | |
Show InterpretError Source # | |
Defined in Morley.Michelson.Interpret showsPrec :: Int -> InterpretError -> ShowS # show :: InterpretError -> String # showList :: [InterpretError] -> ShowS # | |
Buildable InterpretError Source # | |
Defined in Morley.Michelson.Interpret build :: InterpretError -> Builder # | |
type Rep InterpretError Source # | |
Defined in Morley.Michelson.Interpret type Rep InterpretError = D1 ('MetaData "InterpretError" "Morley.Michelson.Interpret" "morley-1.17.0-inplace" 'True) (C1 ('MetaCons "InterpretError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MichelsonFailureWithStack, 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 # |
type EvalM m = (MonadReader ContractEnv m, InterpreterStateMonad m, MonadWriter MorleyLogsBuilder m, MonadError MichelsonFailureWithStack 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
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 :: forall m. EvalM m => InstrRunner m -> InstrRunner m Source #
Function to interpret Michelson instruction(s) against given stack.
:: 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 #