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

Decoding: Fix roundtrip encode/decode tests for transactions #398

Merged
merged 4 commits into from
Nov 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion algosdk/box_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ def __init__(self, app_index: int, name: bytes):

@staticmethod
def translate_box_reference(
ref: Tuple[int, Union[bytes, bytearray, str, int]],
ref: Union[
Tuple[int, Union[bytes, bytearray, str, int]], "BoxReference"
],
foreign_apps: List[int],
this_app_id: int,
) -> "BoxReference":
# Do not need to translate the references if they are already BoxReference type.
if isinstance(ref, BoxReference):
return ref

# Try checking reference id and name type.
ref_id, ref_name = ref[0], encoding.encode_as_bytes(ref[1])
if not isinstance(ref_id, int):
Expand Down
8 changes: 4 additions & 4 deletions algosdk/future/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,8 +1519,8 @@ def dictify(self):
@staticmethod
def undictify(d):
return StateSchema(
num_uints=d["nui"] if "nui" in d else None,
num_byte_slices=d["nbs"] if "nbs" in d else None,
num_uints=d["nui"] if "nui" in d else 0,
num_byte_slices=d["nbs"] if "nbs" in d else 0,
)

def __eq__(self, other):
Expand Down Expand Up @@ -1628,13 +1628,13 @@ def __init__(
self, sender, sp, note, lease, constants.appcall_txn, rekey_to
)
self.index = self.creatable_index(index)
self.on_complete = on_complete
self.on_complete = on_complete if on_complete else 0
self.local_schema = self.state_schema(local_schema)
self.global_schema = self.state_schema(global_schema)
self.approval_program = self.teal_bytes(approval_program)
self.clear_program = self.teal_bytes(clear_program)
self.app_args = self.bytes_list(app_args)
self.accounts = accounts
self.accounts = accounts if accounts else None
self.foreign_apps = self.int_list(foreign_apps)
self.foreign_assets = self.int_list(foreign_assets)
self.extra_pages = extra_pages
Expand Down