-
Notifications
You must be signed in to change notification settings - Fork 465
Auto-gen Python Exchange wrapper #1919
Auto-gen Python Exchange wrapper #1919
Conversation
8943621
to
9dbabb2
Compare
ba02cf4
to
ca52224
Compare
ca52224
to
10e9523
Compare
This branch is currently in a good checkpoint state. The Exchange contract is being generated and run through the tests and doctest examples with every build, and are clean in CircleCI (except for the However, generated wrappers are currently not yet doing any JSON schema validation, nor any signature validation. There may also be other specially crafted logic in there too, which would need to be ported over, but at this time all of the examples/tests are using this generated wrapper and passing. These omissions are reflected in the checklist in the PR description. The generated Exchange wrapper, as of this point in time, can be seen here: https://gist.github.com/feuGeneA/de3754c87d3732e8a2e2e69e53da78de The pre-existing, manually-written Exchange wrapper, can be seen in the commit that deleted it. For the reviewer's convenience, here is a diff of the two: https://www.diffchecker.com/7tEnPG7v . Sadly, there is a lot of change in the diff.
🤷♂️ a re-run didn't fix it... |
packages/abi-gen/test-cli/expected-output/python/abi_gen_dummy.py
Outdated
Show resolved
Hide resolved
packages/abi-gen/test-cli/expected-output/python/abi_gen_dummy.py
Outdated
Show resolved
Hide resolved
e14fab8
to
5071f26
Compare
This leaves space for user-defined additions to the same module, such as for custom types, as shown herein.
For abi-gen command-line test output, for generated Python contract wrappers as output by abi-gen, for generated Python contract wrappers as reformatted and included in the Python package area, and for the "build" output folder in each Python package, which includes the generated documentation.
5e524cf
to
6833c91
Compare
@fabioberger @xianny @PirosB3 this PR is pretty big, but not as big as it looks. It says I added 2,300 new lines of code, but a lot of that is generated: expected outputs for those new abi-gen CLI tests, pre-compiled contract artifacts for abi-gen test fixtures, etc. And there are 30 commits, but many of them are very small. There are maybe 2 or 3 commits that are pretty big and hairy, and maybe 3 or 4 medium sized ones, and the rest are small to tiny. |
33af363
to
7a0d5a8
Compare
Co-Authored-By: Fabio B <[email protected]>
Co-Authored-By: Fabio B <[email protected]>
Added a method to the "dummy" test fixture contract that isn't pure. All of the other prior method cases were pure.
4634f4a
to
c01f76f
Compare
Looking great @feuGeneA! 🎉 |
Specifically, wrapper methods wrapping contract methods that modify contract state and return no return value. There was no test case for this. Now there is.
a5ec3f9
to
e2d932f
Compare
Fixes #1888 .
Description
Include
Exchange
in the list of ABI's thatpackages/python-contract-wrapper
is currently generating wrappers for, and changepython-packages/contract_wrappers
to pull in that code (overwriting the existing, manually-written wrapper) before linting and testing itself. Existing tests/examples should all pass with minimal changes (ideally none).Testing instructions
Since the end result is generated code, reviewing that code (and the docs generated from it) is the first step in testing.
I found some CircleCI configuration to persist "Build Artifacts," which accurately describes our generated code. With this, you can go to a build job's "Artifacts" tab (here's a link to the "Artifacts" tab on a recent run of
test-python
), and drill down through the repo tree to find persisted artifacts.I'm using this to persist generated Python wrappers, generated test output from
abi-gen
's command-line tests, and documentation generated from the Python code. Here are the links to the artifacts from the latest CircleCI run:contract_wrappers.py
generated documentation (includes docs for the Exchange wrapper class)If you want to actually run the generation process yourself:
Types of changes
Checklist:
exchange_wrapper.py
to justexchange.py
.bytes
parameter methods as requiring a UTF-8 encoding.TypedDict
s for structs that are only used as the return value for non-const methods, since there's no generated reference to such aTypedDict
, because those return values aren't accessible since a non-const method can only return a transaction hash.abi-gen/diff.sh
. Also, move thatdiff.sh
intotest-cli
, since that's the only place it's ever used, and remove the parameters, since it's always called with the same arguments, and also rename it torun_diff_test.sh
.abi-gen/test-cli/fixtures/contracts/AbiGenDummy.sol
, renameEvent
toAnEvent
..gitignore
JSON schema files in python package area, and also generated wrappers in python area.development
in order to fix test-publish failure.Add signature validation.Decided not to do this; see comment below.view_only=True
(to do aneth_call
instead of aneth_sendTransaction
) the method should return the value returned by the method, not return a transaction hash.get_*_event()
methods. Currently they're all justTuple[AttributeDict]
.str
ings (not justbytes
).