-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat(fw): Implement ModelGenerator
, implement Transactions
and Withdrawals
#435
base: main
Are you sure you want to change the base?
Conversation
Super nice! |
b8ec99e
to
4ec7d20
Compare
Transactions
and Withdrawals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice, I checked to see if we could use these in other tests but couldn't find anything!
I wondered if we could do something similar for pre/post accounts, or even blocks but I don't think the value is weighted.
We should add tests for withdrawals tests/test_withdrawals.py
and add a section to the documentation for this.
When I update: #61 - I will use Transactions
- so I can mention these in the documentation too
Yes please 👍 we definitely need some examples in the docs for this. I think the |
This PR is affected by the pydantic changes, so potentially needs to be reworked. Converting into draft until rework is done. |
8cfbece
to
bb90231
Compare
Rebased on top of #486, which was surprisingly easy, but now it requires that PR to be merged first. |
Transactions
and Withdrawals
ModelGenerator
, implement Transactions
and Withdrawals
bb90231
to
cfb4407
Compare
a41a283
to
da07dd9
Compare
🗒️ Description
Adds a
ModelGenerator
class which can be used to implement generators of pydantic models, such asTransaction
andWithdrawal
.ModelGenerator
is used as:and generates a new class that takes the same arguments for instantiation, but also takes an
Iterable
in each field.When an
Iterable
is provided, a generator is instantiated that produces one instance of the model per element.ModelGenerator
automatically detects which fields of the model are already supposed to be lists (iterables), and accepts a new field with an_iter
suffix and treats each as an iterator to generate the lists.E.g. In the
Transaction
class, the fieldaccess_list
is already supposed to be a list, so theModelGenerator
accepts a new field calledaccess_list_iter
where the user can specify the iterable for this field that generates theaccess_list
field for each generated transaction.This PR implements
Transactions
andWithdrawals
, and modifies usages in many tests as examples.🔗 Related Issues
None
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.