From b4d7cc5eb75347a245bf62f4e4b3229df0018aff Mon Sep 17 00:00:00 2001 From: PatrickAlphaC <54278053+PatrickAlphaC@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:15:21 -0400 Subject: [PATCH] moccasin --- .gitignore | 2 +- CONTRIBUTING.md | 8 +- README.md | 53 +++++++- ...s.rst => all_moccasin_toml_parameters.rst} | 6 +- docs/source/cli_commands.rst | 6 +- docs/source/common-errors.rst | 2 +- docs/source/conf.py | 8 +- docs/source/console.rst | 4 +- docs/source/dependencies.rst | 20 +-- docs/source/index.rst | 14 +-- ...ing-gaboon.rst => installing-moccasin.rst} | 36 +++--- .../{gaboon_toml.rst => moccasin_toml.rst} | 12 +- ...r_docs.py => moccasin_wrapper_for_docs.py} | 2 +- docs/source/networks.rst | 10 +- docs/source/project.rst | 10 +- docs/source/quickstart.rst | 22 ++-- docs/source/script.rst | 18 +-- docs/source/testing.rst | 6 +- docs/source/toctree.rst | 8 +- docs/source/wallet.rst | 14 +-- {gaboon => moccasin}/__init__.py | 2 +- {gaboon => moccasin}/__main__.py | 54 ++++---- .../_sys_path_and_config_setup.py | 22 ++-- {gaboon => moccasin}/boa_tools.py | 0 {gaboon => moccasin}/commands/__init__.py | 0 {gaboon => moccasin}/commands/compile.py | 29 +++-- {gaboon => moccasin}/commands/config_.py | 6 +- {gaboon => moccasin}/commands/console.py | 53 ++++---- {gaboon => moccasin}/commands/init.py | 8 +- {gaboon => moccasin}/commands/install.py | 8 +- {gaboon => moccasin}/commands/purge.py | 6 +- {gaboon => moccasin}/commands/run.py | 14 +-- {gaboon => moccasin}/commands/test.py | 4 +- {gaboon => moccasin}/commands/wallet.py | 33 ++--- {gaboon => moccasin}/config.py | 20 +-- {gaboon => moccasin}/constants/file_data.py | 16 +-- {gaboon => moccasin}/constants/vars.py | 12 +- {gaboon => moccasin}/logging.py | 0 .../moccasin_account.py | 14 +-- pyproject.toml | 12 +- requirements.txt | 8 +- tests/cli/test_cli_compile.py | 21 +--- tests/cli/test_cli_init.py | 16 +-- tests/cli/test_cli_install.py | 45 +++---- tests/cli/test_cli_run.py | 35 ++---- tests/cli/test_cli_test.py | 18 +-- tests/cli/test_cli_wallet.py | 13 +- tests/conftest.py | 14 +-- .../complex_project/.vscode/settings.json | 2 +- tests/data/complex_project/README.md | 2 +- .../{gaboon.toml => moccasin.toml} | 0 tests/data/complex_project/script/deploy.py | 4 +- .../script/get_usdc_balance.py | 4 +- .../complex_project/tests/test_fork_usdc.py | 2 +- tests/data/installation_project/.gitignore | 2 +- tests/data/installation_project/README.md | 10 +- .../{gaboon.toml => moccasin.toml} | 0 .../installation_project/script/deploy.py | 4 +- tests/data/zksync_project/.gitignore | 2 +- tests/data/zksync_project/README.md | 10 +- .../{gaboon.toml => moccasin.toml} | 4 +- tests/data/zksync_project/script/deploy.py | 4 +- tests/unit/test_unit_run.py | 2 +- tests/unit/test_unit_wallet.py | 7 +- uv.lock | 116 +++++++++--------- 65 files changed, 451 insertions(+), 468 deletions(-) rename docs/source/{all_gaboon_toml_parameters.rst => all_moccasin_toml_parameters.rst} (85%) rename docs/source/{installing-gaboon.rst => installing-moccasin.rst} (66%) rename docs/source/{gaboon_toml.rst => moccasin_toml.rst} (59%) rename docs/source/{gaboon_wrapper_for_docs.py => moccasin_wrapper_for_docs.py} (73%) rename {gaboon => moccasin}/__init__.py (83%) rename {gaboon => moccasin}/__main__.py (91%) rename {gaboon => moccasin}/_sys_path_and_config_setup.py (84%) rename {gaboon => moccasin}/boa_tools.py (100%) rename {gaboon => moccasin}/commands/__init__.py (100%) rename {gaboon => moccasin}/commands/compile.py (81%) rename {gaboon => moccasin}/commands/config_.py (84%) rename {gaboon => moccasin}/commands/console.py (72%) rename {gaboon => moccasin}/commands/init.py (93%) rename {gaboon => moccasin}/commands/install.py (97%) rename {gaboon => moccasin}/commands/purge.py (88%) rename {gaboon => moccasin}/commands/run.py (87%) rename {gaboon => moccasin}/commands/test.py (94%) rename {gaboon => moccasin}/commands/wallet.py (92%) rename {gaboon => moccasin}/config.py (94%) rename {gaboon => moccasin}/constants/file_data.py (93%) rename {gaboon => moccasin}/constants/vars.py (97%) rename {gaboon => moccasin}/logging.py (100%) rename gaboon/gaboon_account.py => moccasin/moccasin_account.py (92%) rename tests/data/complex_project/{gaboon.toml => moccasin.toml} (100%) rename tests/data/installation_project/{gaboon.toml => moccasin.toml} (100%) rename tests/data/zksync_project/{gaboon.toml => moccasin.toml} (73%) diff --git a/.gitignore b/.gitignore index f6ce423..135fd8a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ wheels/ .pytest_cache/ .ruff_cache/ -# Gaboon +# Moccasin built_docs/ anvil1 zkrich1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2153466..19634c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,8 +43,8 @@ Follow the steps to clone the repo for you to make changes to this project. 1. Clone the repo ```bash -git clone https://github.com/cyfrin/gaboon -cd gaboon +git clone https://github.com/cyfrin/moccasin +cd moccasin ``` 2. Sync dependencies @@ -88,7 +88,7 @@ However, if you run tests and scripts using the `uv` or `just` commands as we wi ## Running Tests -First, you'll need to make sure you have the `anvil1` keystore in your `~/.gaboon/keystores` folder. You can [find it here](./tests/data/keystores/anvil1). Please move it there. +First, you'll need to make sure you have the `anvil1` keystore in your `~/.moccasin/keystores` folder. You can [find it here](./tests/data/keystores/anvil1). Please move it there. Run the following: @@ -119,4 +119,4 @@ You can see in `justfile` a list of scripts one can run. To see them all you can # Thank you! -Thank you for wanting to participate in titanoboa and gaboon! \ No newline at end of file +Thank you for wanting to participate in titanoboa and moccasin! \ No newline at end of file diff --git a/README.md b/README.md index db89073..c4ac09c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,53 @@ >[!IMPORTANT] -> *This project has been moved to a new location. Check out https://github.com/cyfrin/moccasin* +> *This repo is a work in progress and is not ready for production use.* -This project has moved to: +# Moccasin -https://github.com/cyfrin/moccasin \ No newline at end of file +A fast, pythonic, Vyper smart contract testing and development framework. + +[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) + + + +Fast to install, test, and run python commands on your smart contracts. + +# Quickstart + +Head over to [the moccasin installation documentation](https://cyfrin.github.io/moccasin/installing-moccasin.html) to for other install methodologies and getting stated. + + +```bash +uv tool install moccasin +``` + +# Documentation + +The documentation roughly attempts to follow [Diátaxis](https://diataxis.fr/). + +# Speed Comparisons + +*The following comparisions were done taking the `user` result from running the bash `time` command followed by the appropriote command on an M3 MacOS* +*Compile command tested with a basic vyper counter contract on version 0.4.0 or 0.3.10 depending on compatibility* + + +| Command | Moccasin | Brownie | Hardhat | Foundry | Ape | +| ------- | -------- | ------- | ------- | ------- | ----- | +| help | 0.03s | 0.37s | 0.30s | 0.01s | 2.55s | +| init | 0.04s | 0.37s | xx | 0.20s | 5.08s | +| compile | 0.49s | 0.42s | xx | 0.17s | 2.00s | + + +# Acknowledgements + +- [brownie](https://github.com/eth-brownie/brownie) +- [vyper](https://github.com/vyperlang/vyper) +- [boa](https://github.com/vyperlang/titanoboa) + +## Background + +> Agkistrodon piscivorus is a species of venomous snake, a pit viper in the subfamily Crotalinae of the family Viperidae. The generic name is derived from the Greek words ἄγκιστρον agkistron "fish-hook, hook" and ὀδών odon "tooth", and the specific name comes from the Latin piscis 'fish' and voro '(I) eat greedily, devour'; thus, the scientific name translates to "hook-toothed fish-eater". Common names include cottonmouth, northern cottonmouth, water moccasin, swamp moccasin, black moccasin, and simply viper. \ No newline at end of file diff --git a/docs/source/all_gaboon_toml_parameters.rst b/docs/source/all_moccasin_toml_parameters.rst similarity index 85% rename from docs/source/all_gaboon_toml_parameters.rst rename to docs/source/all_moccasin_toml_parameters.rst index 133e50c..076a6e7 100644 --- a/docs/source/all_gaboon_toml_parameters.rst +++ b/docs/source/all_moccasin_toml_parameters.rst @@ -1,4 +1,4 @@ -All gaboon toml parameters +All moccasin toml parameters =========================== .. code-block:: toml @@ -22,10 +22,10 @@ All gaboon toml parameters is_zksync = false # This is the name of the account that will be unlocked when running on this network default_account_name = "anvil" - # If you don't provide a password or private key, gaboon will prompt you to unlock it + # If you don't provide a password or private key, moccasin will prompt you to unlock it # If you do, it will unlock it automatically # But be careful about storing passwords and private keys! NEVER store them in plain text - unsafe_password_file = "/home/user/.gaboon/password" # Replace with actual path + unsafe_password_file = "/home/user/.moccasin/password" # Replace with actual path [networks.sepolia.extra_data] my_key = "{$ETHERSCAN_API_KEY}" diff --git a/docs/source/cli_commands.rst b/docs/source/cli_commands.rst index 121ae10..841ed34 100644 --- a/docs/source/cli_commands.rst +++ b/docs/source/cli_commands.rst @@ -1,8 +1,8 @@ -gab +mox ### .. argparse:: - :module: gaboon_wrapper_for_docs + :module: moccasin_wrapper_for_docs :func: get_main_parser - :prog: gab + :prog: mox \ No newline at end of file diff --git a/docs/source/common-errors.rst b/docs/source/common-errors.rst index a81f507..5943e5d 100644 --- a/docs/source/common-errors.rst +++ b/docs/source/common-errors.rst @@ -4,4 +4,4 @@ Common Errors ValueError: .eoa not defined! ---------------------------------------------------------------------------- -This is the most common error you'll run into, and it means you'll need to add an account to your `gaboon.toml`. You can do this by following the :doc:`wallet ` guide. \ No newline at end of file +This is the most common error you'll run into, and it means you'll need to add an account to your `moccasin.toml`. You can do this by following the :doc:`wallet ` guide. \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 60fd971..b9958f5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,13 +6,13 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -import gaboon +import moccasin import os import sys sys.path.insert(0, os.path.abspath(".")) -project = "gaboon" +project = "moccasin" copyright = "2024, Patrick Collins, Charles Cooper" author = "Patrick Collins, Charles Cooper" @@ -48,11 +48,11 @@ html_context = { "source_type": "github", "source_user": "cyfrin", - "source_repo": "gaboon", + "source_repo": "moccasin", } # Options for sphinx_multiversion smv_remote_whitelist = r"^origin$" smv_branch_whitelist = r"^master$" # master is gross smv_tag_whitelist = r"^v\d+\.\d+.\d+$" -version = gaboon.version() +version = moccasin.version() diff --git a/docs/source/console.rst b/docs/source/console.rst index 7ff6b8c..f1326e9 100644 --- a/docs/source/console.rst +++ b/docs/source/console.rst @@ -1,10 +1,10 @@ Console ####### -You can enter a python shell with the `console` command. This will start a python shell with the `gaboon` module loaded, so you can interact with your contracts directly. +You can enter a python shell with the `console` command. This will start a python shell with the `moccasin` module loaded, so you can interact with your contracts directly. .. code-block:: bash - gab console + mox console Press `q` and hit `ENTER` to exit the console. \ No newline at end of file diff --git a/docs/source/dependencies.rst b/docs/source/dependencies.rst index 67ebf6c..605f11c 100644 --- a/docs/source/dependencies.rst +++ b/docs/source/dependencies.rst @@ -2,7 +2,7 @@ Dependencies ############ -Gaboon allows for working with either: +Moccasin allows for working with either: - :ref:`Installing from GitHub repositories ` @@ -18,18 +18,18 @@ To install a package from GitHub, you can run the following: .. code-block:: bash - gab install ORG/REPO[@VERSION] + mox install ORG/REPO[@VERSION] For example: .. code-block:: bash # Without a version - gab install pcaversaccio/snekmate + mox install pcaversaccio/snekmate # With a version - gab install pcaversaccio/snekmate@0.1.0 + mox install pcaversaccio/snekmate@0.1.0 -This will create an entry in your `gaboon.toml` file that looks like this: +This will create an entry in your `moccasin.toml` file that looks like this: .. code-block:: toml @@ -64,14 +64,14 @@ You can then use these packages in your vyper contracts, for example in an minia Installing pip/PyPI Dependencies ================================ -Gaboon let's you directly install and work with PyPI packages as you would any other python package. PyPi dependencies in gaboon are by default powered by the `uv `_ tool. In order to use this, you need to have the `uv` tool installed. However, you can change this setting to `pip` in your `gaboon.tom`. +Moccasin let's you directly install and work with PyPI packages as you would any other python package. PyPi dependencies in moccasin are by default powered by the `uv `_ tool. In order to use this, you need to have the `uv` tool installed. However, you can change this setting to `pip` in your `moccasin.tom`. .. code-block:: toml [project] installer = "pip" # change/add this setting -As of today, `gaboon` supports: +As of today, `moccasin` supports: - `pip` @@ -81,19 +81,19 @@ You can also directly install and work with PyPI packages as you would any other .. code-block:: bash - gab install PACKAGE + mox install PACKAGE For example: .. code-block:: bash - gab install snekmate + mox install snekmate .. note:: Snekmate is both a `pypi `_ and a GitHub package. -This will create an entry in your `gaboon.toml` file that looks like this: +This will create an entry in your `moccasin.toml` file that looks like this: .. code-block:: toml diff --git a/docs/source/index.rst b/docs/source/index.rst index ba2c3b2..9781708 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,13 +1,13 @@ .. image:: _static/docs-logo.png :width: 140px - :alt: Gaboon logo + :alt: Moccasin logo :align: center -Gaboon +Moccasin ###### -Gaboon is a fast, pythonic smart contract development framework heavily powered by `titanoboa `_. +Moccasin is a fast, pythonic smart contract development framework heavily powered by `titanoboa `_. .. note:: @@ -17,9 +17,9 @@ Gaboon is a fast, pythonic smart contract development framework heavily powered How to read the documentation ============================= -The gaboon documentation is written in a way that assumes you are on a MacOS or Linux-like system. If you are using windows, we recommend you watch the first `10 minutes of this WSL tutorial `_ and work with WSL. WSL stands for "Windows Subsystem for Linux" and it allows you to run a Linux commands on Windows machine. +The moccasin documentation is written in a way that assumes you are on a MacOS or Linux-like system. If you are using windows, we recommend you watch the first `10 minutes of this WSL tutorial `_ and work with WSL. WSL stands for "Windows Subsystem for Linux" and it allows you to run a Linux commands on Windows machine. -Why Gaboon? +Why Moccasin? =========== We think web3 needs the following: @@ -30,7 +30,7 @@ We think web3 needs the following: a. Running scripts to interact with contracts needs to be easy in a language that humans can understand. 3. And finally... it needs to be fast! -Then, we have some fun plans for AI, formal verification, fuzzing, and more in the future of gaboon, so stay tuned! +Then, we have some fun plans for AI, formal verification, fuzzing, and more in the future of moccasin, so stay tuned! -Head over to :doc:`installing gaboon ` to get started. \ No newline at end of file +Head over to :doc:`installing moccasin ` to get started. \ No newline at end of file diff --git a/docs/source/installing-gaboon.rst b/docs/source/installing-moccasin.rst similarity index 66% rename from docs/source/installing-gaboon.rst rename to docs/source/installing-moccasin.rst index 11551e0..80209f1 100644 --- a/docs/source/installing-gaboon.rst +++ b/docs/source/installing-moccasin.rst @@ -1,9 +1,9 @@ .. _install: -Installing Gaboon +Installing Moccasin ################# -There are a few things you'll need on your machine before you can install Gaboon. Please install the appropriate tools from the `Prerequisites`_ section. Once you have those, the recommended way to :ref:`install Gaboon is via uv `. +There are a few things you'll need on your machine before you can install Moccasin. Please install the appropriate tools from the `Prerequisites`_ section. Once you have those, the recommended way to :ref:`install Moccasin is via uv `. Prerequisites ============= @@ -15,7 +15,7 @@ Prerequisites Installation with uv -------------------- -For those unfamiliar, `uv `_ is a fast python package manager, and that helps us install gaboon into it's own isolated virtual environment, so we don't get any weird dependency conflicts with other python packages. It's similar to `pip` and `pipx` if you've used them before. It even comes with some `pip` compatibility, will tools like `uv pip install`. +For those unfamiliar, `uv `_ is a fast python package manager, and that helps us install moccasin into it's own isolated virtual environment, so we don't get any weird dependency conflicts with other python packages. It's similar to `pip` and `pipx` if you've used them before. It even comes with some `pip` compatibility, will tools like `uv pip install`. It's highly recommended you understand how `virtual environments `_ work as well. @@ -31,23 +31,23 @@ But you can head over to the `uv installation instructions `_ work. +And you will have `mox` in your virtual environment created from the `uv` tool. It's highly recommended you understand how `virtual environments `_ work. diff --git a/docs/source/gaboon_toml.rst b/docs/source/moccasin_toml.rst similarity index 59% rename from docs/source/gaboon_toml.rst rename to docs/source/moccasin_toml.rst index 3caa300..728c1d2 100644 --- a/docs/source/gaboon_toml.rst +++ b/docs/source/moccasin_toml.rst @@ -1,7 +1,7 @@ -gaboon.toml +moccasin.toml ############## -The `gaboon.toml` file created is our configuration file. In this file we can have: +The `moccasin.toml` file created is our configuration file. In this file we can have: - project and layout settings @@ -11,7 +11,7 @@ The `gaboon.toml` file created is our configuration file. In this file we can ha - extra data -A `gaboon.toml` file can look like this: +A `moccasin.toml` file can look like this: .. code-block:: toml @@ -26,13 +26,13 @@ A `gaboon.toml` file can look like this: my_key = "{$ETHERSCAN_API_KEY}" -You can learn more about each of the sections of the `gaboon.toml` file in their respective documentation. +You can learn more about each of the sections of the `moccasin.toml` file in their respective documentation. - `Project `_ - `Network `_ - `Dependencies `_ -You can also see a full example of a `gaboon.toml` in the :doc:`all gaboon toml parameters ` documentation. +You can also see a full example of a `moccasin.toml` in the :doc:`all moccasin toml parameters ` documentation. Extra Data ========== @@ -41,5 +41,5 @@ Extra data is a dictionary of data where you can put whatever you'd like. You ca .. code-block:: python - from gaboon import config + from moccasin import config print(config.get_config().extra_data["my_key"]) \ No newline at end of file diff --git a/docs/source/gaboon_wrapper_for_docs.py b/docs/source/moccasin_wrapper_for_docs.py similarity index 73% rename from docs/source/gaboon_wrapper_for_docs.py rename to docs/source/moccasin_wrapper_for_docs.py index 92f9312..0dbd0e2 100644 --- a/docs/source/gaboon_wrapper_for_docs.py +++ b/docs/source/moccasin_wrapper_for_docs.py @@ -1,4 +1,4 @@ -from gaboon.__main__ import generate_main_parser_and_sub_parsers +from moccasin.__main__ import generate_main_parser_and_sub_parsers import argparse diff --git a/docs/source/networks.rst b/docs/source/networks.rst index d76d689..419ea74 100644 --- a/docs/source/networks.rst +++ b/docs/source/networks.rst @@ -1,7 +1,7 @@ Networks ======== -Networks in `gaboon` are identified in your `gaboon.toml`. The complete list of options you can set for your network can be identified in the example here: +Networks in `moccasin` are identified in your `moccasin.toml`. The complete list of options you can set for your network can be identified in the example here: .. code-block:: toml @@ -11,7 +11,7 @@ Networks in `gaboon` are identified in your `gaboon.toml`. The complete list of is_fork = false is_zksync = false default_account_name = "anvil" - unsafe_password_file = "~/.gaboon/password" + unsafe_password_file = "~/.moccasin/password" extra_data = { "my_key" = "{$ETHERSCAN_API_KEY}" } Let's walk through what each of these options mean. @@ -26,12 +26,12 @@ Let's walk through what each of these options mean. You'll notice there is no `private-key`. We highly discourage having private keys in plain text. -When working with a network from the command line, for example to :doc:`run a script