-
Notifications
You must be signed in to change notification settings - Fork 0
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
create_transaction_event Does Not Properly Parse Dictionary (Python) #5
Comments
hey @benefacto 🙂 appreciate the report. the function signature for create_transaction_event has actually changed in V2. specifically it accepts multiple arguments:
if you want to just pass in a dict, you can use TransactionEvent directly. but there is some processing done in create_transaction_event that would be missing. this may be fine for your tests, but just a heads up |
Thanks for clarifying the function signature, @haseebrabbani . To me, this signature violates the principle of least astonishment, since when passing in a dictionary including the If the goal is to maintain a high degree of flexibility for the arguments passed, it would be more intuitive to accept a single object with a number of optional properties. This approach would streamline the function call and reduce the potential for errors. Since the V1 version constructs the object directly from a dictionary, adding additional properties to a single parameter object could maintain backwards compatibility while ensuring that developers are making the necessary upgrades for V2. |
I encountered an issue with the
create_transaction_event
function in the Python SDK. It appears that this function does not properly parse this example dictionary and requires constructing theTransactionEvent
directly. This issue causes unexpected errors during test executions.Steps to Reproduce
Use the following example dictionary for creating a transaction event:
Expected Behavior
The
create_transaction_event
function should parse the example dictionary correctly and create aTransactionEvent
object without requiring additional manual steps.Actual Behavior
The function raises a
TypeError
indicating that theblock
andchain_id
arguments are missing, forcing the user to construct theTransactionEvent
directly.Workaround
Currently, I have to construct the
TransactionEvent
directly to avoid the error:Environment
forta_bot_sdk
0.2.3Additional Information
This issue was encountered while running test cases using
pytest
while migrating a Forta starter kit bot to V2. The error messages indicated that theblock
andchain_id
arguments were missing, even though they were included in the provided dictionary.The text was updated successfully, but these errors were encountered: