morley-0.2.0.1: Developer tools for the Michelson Language

Safe HaskellNone
LanguageHaskell2010

Morley.Runtime

Contents

Description

Interpreter of a contract in Morley language.

Synopsis

High level interface for end user

originateContract :: FilePath -> OriginationOperation -> ("verbose" :! Bool) -> IO Address Source #

Originate a contract. Returns the address of the originated contract.

runContract :: Maybe Timestamp -> Word64 -> Mutez -> FilePath -> UntypedValue -> UntypedContract -> TxData -> ("verbose" :! Bool) -> ("dryRun" :! Bool) -> IO () Source #

Run a contract. The contract is originated first (if it's not already) and then we pretend that we send a transaction to it.

transfer :: Maybe Timestamp -> Word64 -> FilePath -> Address -> TxData -> ("verbose" :! Bool) -> ("dryRun" :? Bool) -> IO () Source #

Send a transaction to given address with given parameters.

Other helpers

parseExpandContract :: Maybe FilePath -> Text -> Either ParserException UntypedContract Source #

Parse a contract from Text and expand macros.

readAndParseContract :: Maybe FilePath -> IO (Contract ParsedOp) Source #

Read and parse a contract from give path or stdin (if the argument is Nothing). The contract is not expanded.

prepareContract :: Maybe FilePath -> IO UntypedContract Source #

Read a contract using readAndParseContract, expand and flatten. The contract is not type checked.

Re-exports

data ContractState Source #

State of a contract with code.

Constructors

ContractState 

Fields

Instances
Eq ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

Show ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

Generic ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

Associated Types

type Rep ContractState :: Type -> Type #

ToJSON ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

FromJSON ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

Buildable ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

type Rep ContractState Source # 
Instance details

Defined in Morley.Runtime.GState

type Rep ContractState = D1 (MetaData "ContractState" "Morley.Runtime.GState" "morley-0.2.0.1-FliIoxX7mVfHuhHSaQftJN" False) (C1 (MetaCons "ContractState" PrefixI True) (S1 (MetaSel (Just "csBalance") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Mutez) :*: (S1 (MetaSel (Just "csStorage") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 UntypedValue) :*: S1 (MetaSel (Just "csContract") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 UntypedContract))))

data AddressState Source #

State of an arbitrary address.

Constructors

ASSimple !Mutez

For contracts without code we store only its balance.

ASContract !ContractState

For contracts with code we store more state represented by ContractState.

Instances
Eq AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

Show AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

Generic AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

Associated Types

type Rep AddressState :: Type -> Type #

ToJSON AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

FromJSON AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

Buildable AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

type Rep AddressState Source # 
Instance details

Defined in Morley.Runtime.GState

type Rep AddressState = D1 (MetaData "AddressState" "Morley.Runtime.GState" "morley-0.2.0.1-FliIoxX7mVfHuhHSaQftJN" False) (C1 (MetaCons "ASSimple" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Mutez)) :+: C1 (MetaCons "ASContract" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ContractState)))

data TxData Source #

Data associated with a particular transaction.

Instances
Show ExpandedUExtInstr => Show TxData Source # 
Instance details

Defined in Morley.Runtime.TxData

For testing

data InterpreterOp Source #

Operations executed by interpreter. In our model one Michelson's operation (operation type in Michelson) corresponds to 0 or 1 interpreter operation.

Note: Address is not part of TxData, because TxData is supposed to be provided by the user, while Address can be computed by our code.

Constructors

OriginateOp !OriginationOperation

Originate a contract.

TransferOp Address TxData

Send a transaction to given address which is assumed to be the address of an originated contract.

Instances
Show InterpreterOp Source # 
Instance details

Defined in Morley.Runtime

data InterpreterRes Source #

Result of a single execution of interpreter.

Constructors

InterpreterRes 

Fields

Instances
Show InterpreterRes Source # 
Instance details

Defined in Morley.Runtime

data InterpreterError Source #

Errors that can happen during contract interpreting.

Constructors

IEUnknownContract !Address

The interpreted contract hasn't been originated.

IEInterpreterFailed !Address !(InterpretUntypedError MorleyLogs)

Interpretation of Michelson contract failed.

IEAlreadyOriginated !Address !ContractState

A contract is already originated.

IEUnknownSender !Address

Sender address is unknown.

IEUnknownManager !Address

Manager address is unknown.

IENotEnoughFunds !Address !Mutez

Sender doesn't have enough funds.

IEFailedToApplyUpdates !GStateUpdateError

Failed to apply updates to GState.

IEIllTypedContract !TCError

A contract is ill-typed.

interpreterPure :: Timestamp -> RemainingSteps -> GState -> [InterpreterOp] -> Either InterpreterError InterpreterRes Source #

Implementation of interpreter outside IO. It reads operations, interprets them one by one and updates state accordingly.