Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interpreter of a contract in Morley language.
Synopsis
- originateContract :: FilePath -> OriginationOperation -> ("verbose" :! Bool) -> IO Address
- runContract :: Maybe Timestamp -> Word64 -> Mutez -> FilePath -> UntypedValue -> UntypedContract -> TxData -> ("verbose" :! Bool) -> ("dryRun" :! Bool) -> IO ()
- transfer :: Maybe Timestamp -> Word64 -> FilePath -> Address -> TxData -> ("verbose" :! Bool) -> ("dryRun" :? Bool) -> IO ()
- parseContract :: Maybe FilePath -> Text -> Either ParserException (Contract ParsedOp)
- parseExpandContract :: Maybe FilePath -> Text -> Either ParserException UntypedContract
- readAndParseContract :: Maybe FilePath -> IO (Contract ParsedOp)
- prepareContract :: Maybe FilePath -> IO UntypedContract
- data ContractState = ContractState {
- csBalance :: !Mutez
- csStorage :: !UntypedValue
- csContract :: !UntypedContract
- data AddressState
- data TxData = TxData {
- tdSenderAddress :: !Address
- tdParameter :: !UntypedValue
- tdAmount :: !Mutez
- data InterpreterOp
- data InterpreterRes = InterpreterRes {}
- data InterpreterError
- interpreterPure :: Timestamp -> RemainingSteps -> GState -> [InterpreterOp] -> Either InterpreterError InterpreterRes
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
parseContract :: Maybe FilePath -> Text -> Either ParserException (Contract ParsedOp) Source #
Parse a contract from Text
.
parseExpandContract :: Maybe FilePath -> Text -> Either ParserException UntypedContract Source #
Parse a contract from Text
and expand macros.
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.
ContractState | |
|
Instances
data AddressState Source #
State of an arbitrary address.
ASSimple !Mutez | For contracts without code we store only its balance. |
ASContract !ContractState | For contracts with code we store more state represented by
|
Instances
Data associated with a particular transaction.
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.
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 # | |
Defined in Morley.Runtime showsPrec :: Int -> InterpreterOp -> ShowS # show :: InterpreterOp -> String # showList :: [InterpreterOp] -> ShowS # |
data InterpreterRes Source #
Result of a single execution of interpreter.
InterpreterRes | |
|
Instances
Show InterpreterRes Source # | |
Defined in Morley.Runtime showsPrec :: Int -> InterpreterRes -> ShowS # show :: InterpreterRes -> String # showList :: [InterpreterRes] -> ShowS # |
data InterpreterError Source #
Errors that can happen during contract interpreting.
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. |
Instances
Show InterpreterError Source # | |
Defined in Morley.Runtime showsPrec :: Int -> InterpreterError -> ShowS # show :: InterpreterError -> String # showList :: [InterpreterError] -> ShowS # | |
Exception InterpreterError Source # | |
Defined in Morley.Runtime | |
Buildable InterpreterError Source # | |
Defined in Morley.Runtime build :: InterpreterError -> Builder # |
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.