morley 0.1.0.4 → 0.1.0.5
raw patch · 4 files changed
+67/−9 lines, 4 filesdep +transformers-compat
Dependencies added: transformers-compat
Files
- README.md +30/−4
- app/Main.hs +30/−3
- morley.cabal +3/−1
- src/Morley/Runtime/GState.hs +4/−1
README.md view
@@ -28,10 +28,36 @@ ## IV: Testing EDSL -Testing EDSL makes it possible to write tests in Haskell.-It supports both integrational and unit tests.-Tests of both types can use static data or arbitrary data.-There is [a document](/docs/testingEDSL.md) with a detailed description of EDSL and a tutorial about its usage.+Coming soon, see TM-77.++## Running and building++Morley executable provides following functionality:+- `parse` contract and return its representation in haskell types.+- `typecheck` contract.+- `run` contract. Given contract is being originated first and then transaction is being sent to it+- `originate` contract.+- `transfer` tokens to given address.+- `print` produce `.tz` contract that can be parsed by the OCaml referenced client from `.mtz` or `.tz` contract.++You can get more info about this command by running `morley <command> --help`++There are two ways to get morley executable:+- [Docker](https://docs.docker.com/) based (preferable). Get [script](/scripts/morley.sh)+ (e. g. using `curl https://gitlab.com/camlcase-dev/morley/raw/master/scripts/morley.sh > morley.sh`)+ and run it `./morley.sh <args>`. This script will pull docker image that contains latest version of morley executable from master branch and run it with given arguments.+ Usage example:+ `./morley.sh` to see help message+ `./morley.sh run --contract add1.tz --storage 1 --parameter 1 --amount 1`+- [Stack](https://docs.haskellstack.org/en/stable/README/) based. Clone this git repository and run `stack build` command,+ after that you can do `stack exec -- morley <args>` to run morley executable built from source code.+ Usage example:+ `stack exec -- morley --help` to see help message+ `stack exec -- morley originate --contract contracts/add1.tz --storage 1 --verbose`++For more information about morley commands check out following docs:+- [interpreter doc](/docs/morleyInterpreter.md)+- [typechecker doc](/docs/morleyTypechecker.md) ## Issue Tracker
app/Main.hs view
@@ -7,9 +7,10 @@ import Fmt (pretty) import Named ((!)) import Options.Applicative- (auto, command, eitherReader, execParser, fullDesc, header, help, helper, info, infoOption, long,- maybeReader, metavar, option, progDesc, readerError, short, showDefault, showDefaultWith,+ (auto, command, eitherReader, execParser, footerDoc, fullDesc, header, help, helper, info, infoOption,+ long, maybeReader, metavar, option, progDesc, readerError, short, showDefault, showDefaultWith, strOption, subparser, switch, value)+import Options.Applicative.Help.Pretty (Doc, linebreak) import qualified Options.Applicative as Opt import Paths_morley (version) import Text.Pretty.Simple (pPrint)@@ -159,7 +160,7 @@ <*> dbPathOption <*> keyHashOption (Just genesisKeyHash) "manager" "Contract's manager" <*> optional- (keyHashOption Nothing "manager" "Contract's optional delegate")+ (keyHashOption Nothing "delegate" "Contract's optional delegate") <*> switch (long "spendable" <> help "Whether the contract is spendable") <*> switch (long "delegatable" <>@@ -282,6 +283,7 @@ [ fullDesc , progDesc "Morley: Haskell implementation of Michelson typechecker and interpreter" , header "Morley tools"+ , footerDoc $ usageDoc ] versionOption = infoOption ("morley-" <> showVersion version)@@ -321,3 +323,28 @@ transfer toNow toMaxSteps toDBPath toDestination toTxData ! #verbose toVerbose ! #dryRun toDryRun++usageDoc :: Maybe Doc+usageDoc = Just $ mconcat+ [ "You can use help for specific COMMAND", linebreak+ , "EXAMPLE:", linebreak+ , " morley run --help", linebreak+ , linebreak+ , "Documentation for morley tools can be found at the following links:", linebreak+ , " https://gitlab.com/camlcase-dev/morley/blob/master/README.md", linebreak+ , " https://gitlab.com/camlcase-dev/morley/tree/master/docs", linebreak+ , linebreak+ , "Sample contracts for running can be found at the following link:", linebreak+ , " https://gitlab.com/camlcase-dev/morley/tree/master/contracts", linebreak+ , linebreak+ , "USAGE EXAMPLE:", linebreak+ , " morley parse --contract add1.tz", linebreak+ , linebreak+ , " This command will parse contract stored in add1.tz", linebreak+ , " and return its representation in haskell types", linebreak+ , linebreak+ , " morley originate --contract add1.tz --storage 1 --verbose", linebreak+ , linebreak+ , " This command will originate contract with code stored in add1.tz", linebreak+ , " with initial storage value set to 1 and return info about", linebreak+ , " originated contract: its balance, storage and contract code"]
morley.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: morley-version: 0.1.0.4+version: 0.1.0.5 synopsis: Developer tools for the Michelson Language description: A library to make writing smart contracts in Michelson — the smart contract@@ -96,6 +96,8 @@ , text , time , timerep+ -- Otherwise Hackage fails+ , transformers-compat == 0.6.2 , parser-combinators >= 1.0.0 , directory , singletons
src/Morley/Runtime/GState.hs view
@@ -125,7 +125,10 @@ readGState fp = (LBS.readFile fp >>= parseFile) `catch` onExc where parseFile :: LByteString -> IO GState- parseFile = either (throwM . GStateParseError) pure . Aeson.eitherDecode'+ parseFile lByteString =+ if length lByteString == 0+ then pure initGState+ else (either (throwM . GStateParseError) pure . Aeson.eitherDecode') lByteString onExc :: IOError -> IO GState onExc exc | isDoesNotExistError exc = pure initGState