Skip to content

Commit

Permalink
Decoding: Fix roundtrip encode/decode tests for transactions (algoran…
Browse files Browse the repository at this point in the history
  • Loading branch information
algochoi authored Nov 9, 2022
1 parent ad918b8 commit fd9391c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit fd9391c

Please sign in to comment.