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

Fixed set payload from list #76

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion multiversx_sdk/abi/struct_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def set_payload(self, value: Any):

native_list, ok = convert_native_value_to_list(value, raise_on_failure=False)
if ok:
set_fields_from_list(self.fields, native_list[1:])
set_fields_from_list(self.fields, native_list)
return

raise ValueError("cannot set payload for struct (should be either a dictionary or a list)")
Expand Down
5 changes: 5 additions & 0 deletions multiversx_sdk/abi/struct_value_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_set_payload_and_get_payload():
Field("b", BigUIntValue())
])

# From list
value.set_payload([39, 40])
assert value.fields == [Field("a", U32Value(39)), Field("b", BigUIntValue(40))]
assert value.get_payload() == SimpleNamespace(a=39, b=40)

# From SimpleNamespace
value.set_payload(SimpleNamespace(a=41, b=42))
assert value.fields == [Field("a", U32Value(41)), Field("b", BigUIntValue(42))]
Expand Down
Loading