Enabling mypy by incorporating #16 and making other similar changes to new code. This makes it possible for downstream dependencies that incorporate graviton to be mypy-compliant as well.
Allow handling of Transaction Params in Logic Sig and App Dry-Runs
Previously, graviton was using the old Python SDK DryRunHelper which hard-coded the transaction information associated with a dry run. This made it impossible to write logic sigs that vallidated the transaction information in their program. This PR fixes this situation. In fact, the image below was only possible to create thanks to this new addition.
Jupyter Notebooks
Introducing notebooks/quadratic_factoring_game.ipynb which shows how to leverage graviton for creating graphs in jupyter such as below. The notebook also runs during integration testing.
Summary of Important Changes
.github/workflows/build.yml + Makefile:
allow testing and running jupyter notebooks
add mypy to lint
graviton/:
README.md - move the top-level tutorial here
abi_strategy.py - includes ABIStrategy which lets you generate random ABI instances as well as running mutate_for_dryrun() which emulates the logic in the roundtrip teal programs and allows for verification that abi decoding/manipulation/encoding all work as expected
blackbox.py:
pass mypy
allow specifying transaction params into dry-runs
handle ABI types
dryrun.py:
pass mypy
deprecated_dry_run.py: new module that contains functionality mostly used by the now deprecated DryRunTestCaseMixin
deprecated_dryrun_mixin.py: where the now deprecated DryRunTestCaseMixin is defined
dryrun.py:
refactor to keep only the most useful portions of the original helper
make mypy pass
allow specifying transaction parameters
pprint() now returns a string, in addition to printing
invariant.py: make mypy pass
models.py: new module that contains lightweight models such as the App and LSig dataclasses
py.typed - needed for mypy
mypy.ini: needed by mypy
notebooks: new directory for Jupyter notebooks. It contains:
IMAGES.md: a static file that shows examples of 3D graphs of dry-runs
notebooks_test.ipynb: explains how to test notebooks with pytest and includes an intentionally erroring cell with a modification of the notebook's configuration to allow it to be run in CI without failing
quadratic_factoring_game.ipynb: Notebook that demonstrates logic sig factoring game
setup.py: new Jupyter notebooks requirements, and declaration for receiving projects that this package is typed
tests
integration/
abi_test.py: adding the roundtrip test that iterates over teal files in tests/teal/roundtrip and based on the filename encodes a random ABI instance and runs the roundtrip teal program on it via dry-run. In particular includes "round trips" test preparer that:
generates random abi-type arguments
run a dry-run program against them that decode and then manipulate using a self-invertible function f and return (x, f(x), f(f(x)))
algod_test.py: separate out the test that algod is alive and well into a seperate integration test, for easier debugging
blackbox_test.py: small refactoring, mostly for mypy
dryrun_mixin_docs_test.py: refactoring mostly due to deprecations
lsig_test.py: test that was described during an April Demo and which
teal/ directory - many teal programs created via PyTEAL which are used for dry-run tests
roundtrip/ - roundtrip teal programs used by abi_test.py
mypy
Enabling
mypy
by incorporating #16 and making other similar changes to new code. This makes it possible for downstream dependencies that incorporate graviton to be mypy-compliant as well.Allow handling of Transaction Params in Logic Sig and App Dry-Runs
Previously, graviton was using the old Python SDK
DryRunHelper
which hard-coded the transaction information associated with a dry run. This made it impossible to write logic sigs that vallidated the transaction information in their program. This PR fixes this situation. In fact, the image below was only possible to create thanks to this new addition.Jupyter Notebooks
Introducing
notebooks/quadratic_factoring_game.ipynb
which shows how to leverage graviton for creating graphs in jupyter such as below. The notebook also runs during integration testing.Summary of Important Changes
.github/workflows/build.yml
+Makefile
:mypy
tolint
graviton/
:README.md
- move the top-level tutorial hereabi_strategy.py
- includesABIStrategy
which lets you generate random ABI instances as well as runningmutate_for_dryrun()
which emulates the logic in theroundtrip
teal programs and allows for verification that abi decoding/manipulation/encoding all work as expectedblackbox.py
:mypy
dryrun.py
:mypy
deprecated_dry_run.py
: new module that contains functionality mostly used by the now deprecatedDryRunTestCaseMixin
deprecated_dryrun_mixin.py
: where the now deprecatedDryRunTestCaseMixin
is defineddryrun.py
:mypy
passpprint()
now returns a string, in addition to printinginvariant.py
: makemypy
passmodels.py
: new module that contains lightweight models such as theApp
andLSig
dataclassespy.typed
- needed formypy
mypy.ini
: needed by mypynotebooks
: new directory for Jupyter notebooks. It contains:IMAGES.md
: a static file that shows examples of 3D graphs of dry-runsnotebooks_test.ipynb
: explains how to test notebooks withpytest
and includes an intentionally erroring cell with a modification of the notebook's configuration to allow it to be run in CI without failingquadratic_factoring_game.ipynb
: Notebook that demonstrates logic sig factoring gamesetup.py
: new Jupyter notebooks requirements, and declaration for receiving projects that this package is typedtests
integration/
abi_test.py
: adding the roundtrip test that iterates over teal files intests/teal/roundtrip
and based on the filename encodes a random ABI instance and runs the roundtrip teal program on it via dry-run. In particular includes "round trips" test preparer that:f
and return(x, f(x), f(f(x)))
algod_test.py
: separate out the test thatalgod
is alive and well into a seperate integration test, for easier debuggingblackbox_test.py
: small refactoring, mostly formypy
dryrun_mixin_docs_test.py
: refactoring mostly due to deprecationslsig_test.py
: test that was described during an April Demo and whichteal/
directory - many teal programs created via PyTEAL which are used for dry-run testsroundtrip/
- roundtrip teal programs used byabi_test.py