Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docs #98

Merged
merged 7 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 2 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "purescript-chanterelle",
"description": "A more functional truffle",
"license": "ISC",
"ignore": [
"**/.*",
"node_modules",
Expand Down
2 changes: 1 addition & 1 deletion chanterelle-bin.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./chanterelle')
require('./output/ChanterelleMain/index.js').main();
48 changes: 2 additions & 46 deletions docs/compiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,11 @@
Compiling
=========

Currently, Chanterelle does not have a dedicated command line tool for invoking its functionality. Instead, one writes
a brief PureScript program to invoke the various features of Chanterelle.

Generally, you'd want to have at least two subprojects, one for compiling and one for deploying/testing. This is because
the deployer and test suite will surely depend on PureScript bindings generated during the compilation phase, and thus
cannot be part of the same project. An example of this can be seen in `the Parking DAO example <https://github.com/f-o-a-m/parking-dao>`_.


Invoking the compiler
---------------------

A sample application to invoke the compiler is presented below. This is nearly identical to the Parking DAO compile script,
with the exception that this script also invokes the Genesis block generator. One may leave out the ``runGenesisGenerator`` bit
if this functionality is not required. One may want to store this script in a directory outside where their PureScript build system
(such as Pulp) would keep code. One such location is ``compile/Compile.purs`` (as opposed to say, ``src/compile/Compile.purs``).

.. code-block:: haskell

module CompileMain where

import Prelude
import Chanterelle (compileMain)
import Chanterelle.Genesis (runGenesisGenerator)
import Control.Monad.Eff (Effect)

main :: Eff Unit
main = do
compileMain
runGenesisGenerator "./base-genesis-block.json" "./injected-genesis-block.json"


We can then invoke this script as follows

.. code-block:: shell

pulp build --src-path compile -m CompileMain --to compile.js && \
node compile.js --log-level info; \
rm -f compile.js

chanterelle compile
chanterelle genesis --input ./base-genesis-block.json --output ./injected-genesis-block.json

This will compile and purescript-web3 codegen all the modules specified in ``chanterelle.json`` as well as generate a genesis block whose contents
are those of ``./base-genesis-block.json`` with injected libraries appended into ``allocs`` and written out to ``./injected-genesis-block.json``.

Note that we do not use ``pulp run`` as we then have no means to pass command line arguments to the compiler.

Compiler arguments
------------------

Currently the following command line arguments are supported for the compiler phase when ran with ``compileMain``:

- ``--log-level``: One of ``debug``, ``info``, ``warn``, or ``error``. Defaults to ``info``.
This option changes the level of logging to the console.
43 changes: 7 additions & 36 deletions docs/deployments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The type ``Constructor args`` is a type synonym:

.. code-block:: haskell

type Constructor args = forall eff. TransactionOptions NoPay -> HexString -> Record args -> Web3 HexString
type Constructor args = TransactionOptions NoPay -> HexString -> Record args -> Web3 HexString

In other words, ``Constructor args`` is the type a function taking in some ``TransactionOptions NoPay`` (constructors are not payable transactions), the deployment bytepurescriptcode, and a record of type ``Record args``. It will format the transaction and submit it via an ``eth_sendTransaction`` RPC call, returning the transaction hash as a ``HexString``.

Expand Down Expand Up @@ -120,9 +120,11 @@ Consider this example take from the parking-dao example project:

import ContractConfig (simpleStorageConfig, foamCSRConfig, parkingAuthorityConfig)

type DeployResults = (foamCSR :: Address, simpleStorage :: Address, parkingAuthority :: Address)
deploy :: DeployM Unit
deploy = void deployScript

deployScript :: forall eff. DeployM (Record DeployResults)
type DeployResults = (foamCSR :: Address, simpleStorage :: Address, parkingAuthority :: Address)
deployScript :: DeployM (Record DeployResults)
deployScript = do
deployCfg@(DeployConfig {primaryAccount}) <- ask
let bigGasLimit = unsafePartial fromJust $ parseBigNumber decimal "4712388"
Expand All @@ -144,39 +146,8 @@ Note that if we simply wanted to terminate the deployment script after the contr
Invocation
----------

Much like with the :ref:`compilation phase <compiling>`, the deployment phase is invoked with a minimal PureScript boilerplate.
This script, however, invokes the ``deployScript`` you defined previously, and may either reside with the rest of your source or more
methodically in a separate ``deploy/`` subproject. The latter is demonstrated below

.. code-block:: haskell

module DeployMain (main) where

import Prelude

import Chanterelle (deployMain)
import Control.Monad.Eff (Effect)
import MyDeployScript (deployScript) as MyDeployScript

main :: Eff Unit
main = deployMain MyDeployScript.deployScript

We can then invoke this script as follows:
depending on your setup you should make sure `MyDeployScript` module is built. in most cases you can access corresponding js file in `./output/MyDeployScript/index.js` which should be passed to `chanterelle deploy` command like this:

.. code-block:: shell

pulp build --src-path deploy -I src -m DeployMain --to deploy.js && \
node deploy.js --log-level info; \
rm -f deploy.js

One may note the similarities to the invocation of the compiler script, however the build has an additional ``-I src`` as your deploy script
will mostly likely depend on artifacts that are codegen'd into your main source root as well.


Deployer arguments
------------------

Currently the following command line arguments are supported for the deployment phase when ran with ``deployMain``:

- ``--log-level``: One of ``debug``, ``info``, ``warn``, or ``error``. Defaults to ``info``.
This option changes the level of logging to the console.
chanterelle deploy ./output/MyDeployScript/index.js
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Welcome to Chanterelle's documentation!
:maxdepth: 2
:caption: User Documentation

installation
chanterelle-json
modules
dependencies
Expand Down
14 changes: 14 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _installation:


=========
installing Chanterelle CLI
=========

you can install `master` of chanterelle CLI globally using npm:
.. code-block:: shell
npm install -g f-o-a-m/chanterelle

Or if you would like to install specific version like `v9.9.9 for example do:
.. code-block:: shell
npm install -g f-o-a-m/chanterelle#v9.9.9
Loading