Safe Haskell | None |
---|---|
Language | Haskell2010 |
Executor and typechecker of a contract in Morley language.
Synopsis
- originateContract :: FilePath -> OriginationOperation -> ("verbose" :! Bool) -> IO Address
- runContract :: Maybe Timestamp -> Word64 -> Mutez -> FilePath -> Value -> Contract -> 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 Contract
- readAndParseContract :: Maybe FilePath -> IO (Contract' ParsedOp)
- prepareContract :: Maybe FilePath -> IO Contract
- typeCheckWithDb :: FilePath -> Contract -> IO (Either TCError SomeContract)
- data ContractState = ContractState {}
- data AddressState
- data TxData = TxData {}
- data ExecutorOp
- data ExecutorRes = ExecutorRes {}
- data ExecutorError' a
- = EEUnknownContract !a
- | EEInterpreterFailed !a !InterpretError
- | EEAlreadyOriginated !a !ContractState
- | EEUnknownSender !a
- | EEUnknownManager !a
- | EENotEnoughFunds !a !Mutez
- | EEZeroTransaction !a
- | EEFailedToApplyUpdates !GStateUpdateError
- | EEIllTypedContract !TCError
- | EEIllTypedStorage !TCError
- | EEIllTypedParameter !TCError
- | EEUnknownEntrypoint EpName
- type ExecutorError = ExecutorError' Address
- executorPure :: Timestamp -> RemainingSteps -> GState -> [ExecutorOp] -> Either ExecutorError ExecutorRes
- erInterpretResults :: Lens' ExecutorRes [(Address, InterpretResult)]
- erUpdates :: Lens' ExecutorRes [GStateUpdate]
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 -> Value -> Contract -> 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 Contract Source #
Parse a contract from Text
and expand macros.
prepareContract :: Maybe FilePath -> IO Contract Source #
Read a contract using readAndParseContract
, expand and
flatten. The contract is not type checked.
typeCheckWithDb :: FilePath -> Contract -> IO (Either TCError SomeContract) Source #
Re-exports
data ContractState Source #
State of a contract with code.
ContractState | |
|
Instances
Show ContractState Source # | |
Defined in Michelson.Runtime.GState showsPrec :: Int -> ContractState -> ShowS # show :: ContractState -> String # showList :: [ContractState] -> ShowS # | |
ToJSON ContractState Source # | |
Defined in Michelson.Runtime.GState toJSON :: ContractState -> Value # toEncoding :: ContractState -> Encoding # toJSONList :: [ContractState] -> Value # toEncodingList :: [ContractState] -> Encoding # | |
FromJSON ContractState Source # | |
Defined in Michelson.Runtime.GState parseJSON :: Value -> Parser ContractState # parseJSONList :: Value -> Parser [ContractState] # | |
Buildable ContractState Source # | |
Defined in Michelson.Runtime.GState build :: ContractState -> Builder # |
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 ExecutorOp 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 ExecutorOp Source # | |
Defined in Michelson.Runtime showsPrec :: Int -> ExecutorOp -> ShowS # show :: ExecutorOp -> String # showList :: [ExecutorOp] -> ShowS # |
data ExecutorRes Source #
Result of a single execution of interpreter.
ExecutorRes | |
|
Instances
Show ExecutorRes Source # | |
Defined in Michelson.Runtime showsPrec :: Int -> ExecutorRes -> ShowS # show :: ExecutorRes -> String # showList :: [ExecutorRes] -> ShowS # | |
Semigroup ExecutorRes Source # | |
Defined in Michelson.Runtime (<>) :: ExecutorRes -> ExecutorRes -> ExecutorRes # sconcat :: NonEmpty ExecutorRes -> ExecutorRes # stimes :: Integral b => b -> ExecutorRes -> ExecutorRes # |
data ExecutorError' a Source #
Errors that can happen during contract interpreting.
Type parameter a
determines how contracts will be represented
in these errors, e.g. Address
EEUnknownContract !a | The interpreted contract hasn't been originated. |
EEInterpreterFailed !a !InterpretError | Interpretation of Michelson contract failed. |
EEAlreadyOriginated !a !ContractState | A contract is already originated. |
EEUnknownSender !a | Sender address is unknown. |
EEUnknownManager !a | Manager address is unknown. |
EENotEnoughFunds !a !Mutez | Sender doesn't have enough funds. |
EEZeroTransaction !a | Sending 0tz towards an address. |
EEFailedToApplyUpdates !GStateUpdateError | Failed to apply updates to GState. |
EEIllTypedContract !TCError | A contract is ill-typed. |
EEIllTypedStorage !TCError | Contract storage is ill-typed. |
EEIllTypedParameter !TCError | Contract parameter is ill-typed. |
EEUnknownEntrypoint EpName | Specified entrypoint to run is not found. |
Instances
Show a => Show (ExecutorError' a) Source # | |
Defined in Michelson.Runtime showsPrec :: Int -> ExecutorError' a -> ShowS # show :: ExecutorError' a -> String # showList :: [ExecutorError' a] -> ShowS # | |
(Typeable a, Show a, Buildable a) => Exception (ExecutorError' a) Source # | |
Defined in Michelson.Runtime toException :: ExecutorError' a -> SomeException # fromException :: SomeException -> Maybe (ExecutorError' a) # displayException :: ExecutorError' a -> String # | |
Buildable a => Buildable (ExecutorError' a) Source # | |
Defined in Michelson.Runtime build :: ExecutorError' a -> Builder # |
type ExecutorError = ExecutorError' Address Source #
executorPure :: Timestamp -> RemainingSteps -> GState -> [ExecutorOp] -> Either ExecutorError ExecutorRes Source #
Implementation of executor outside IO
. It reads operations,
executes them one by one and updates state accordingly.
Each operation from the passed list is fully executed before
the next one is considered.