Skip to content
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

Allow creating and using Structs defined in contract ABI #1953

Open
fubuloubu opened this issue Mar 8, 2024 · 1 comment
Open

Allow creating and using Structs defined in contract ABI #1953

fubuloubu opened this issue Mar 8, 2024 · 1 comment
Labels
category: feature New feature or request

Comments

@fubuloubu
Copy link
Member

Overview

Some contracts define custom structs. It would be helpful to be able to use those definitions directly

Specification

s = contract.MyStruct(a1, a2, ...)  # Initialize a struct

assert contract.myStruct() == contract.MyStruct(a1, a2)  # comparisons for Assertions

s.encode(packed=True)  # encode a struct to bytes (unpacked by default)
s = contract.MyStruct.decode(data_bytes, packed=True)  # decode a struct from some bytes

Dependencies

This feature is already available on abi encoding and decoding for methods, so it's a matter of exposing it more formally as something you can use directly from the contracts ABI

@fubuloubu fubuloubu added the category: feature New feature or request label Mar 8, 2024
Copy link

linear bot commented Mar 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant