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

Rename pyteal/ast/abi method parameters to follow PEP 8 conventions #468

Merged
merged 1 commit into from
Jul 22, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyteal/ast/abi/bool.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def decode(
start_index = Int(0)
return self.decode_bit(encoded, start_index * Int(NUM_BITS_IN_BYTE))

def decode_bit(self, encoded, bitIndex: Expr) -> Expr:
return self.stored_value.store(GetBit(encoded, bitIndex))
def decode_bit(self, encoded, bit_index: Expr) -> Expr:
return self.stored_value.store(GetBit(encoded, bit_index))

def encode(self) -> Expr:
return SetBit(Bytes(b"\x00"), Int(0), self.get())
Expand Down
34 changes: 17 additions & 17 deletions pyteal/ast/abi/uint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def uint_storage_type(size: int) -> TealType:
return TealType.bytes


def uint_set(size: int, uintVar: ScratchVar, value: Union[int, Expr, "Uint"]) -> Expr:
def uint_set(size: int, uint_var: ScratchVar, value: Union[int, Expr, "Uint"]) -> Expr:
if size > 64:
raise NotImplementedError(
"Uint operations have not yet been implemented for bit sizes larger than 64"
Expand All @@ -49,17 +49,17 @@ def uint_set(size: int, uintVar: ScratchVar, value: Union[int, Expr, "Uint"]) ->
checked = True

if checked or size == 64:
return uintVar.store(cast(Expr, value))
return uint_var.store(cast(Expr, value))

return Seq(
uintVar.store(cast(Expr, value)),
Assert(uintVar.load() < Int(2**size)),
uint_var.store(cast(Expr, value)),
Assert(uint_var.load() < Int(2**size)),
)


def uint_decode(
size: int,
uintVar: ScratchVar,
uint_var: ScratchVar,
encoded: Expr,
start_index: Optional[Expr],
end_index: Optional[Expr],
Expand All @@ -73,41 +73,41 @@ def uint_decode(
if size == 64:
if start_index is None:
if end_index is None and length is None:
return uintVar.store(Btoi(encoded))
return uint_var.store(Btoi(encoded))
start_index = Int(0)
return uintVar.store(ExtractUint64(encoded, start_index))
return uint_var.store(ExtractUint64(encoded, start_index))

if start_index is None:
start_index = Int(0)

if size == 8:
return uintVar.store(GetByte(encoded, start_index))
return uint_var.store(GetByte(encoded, start_index))
if size == 16:
return uintVar.store(ExtractUint16(encoded, start_index))
return uint_var.store(ExtractUint16(encoded, start_index))
if size == 32:
return uintVar.store(ExtractUint32(encoded, start_index))
return uint_var.store(ExtractUint32(encoded, start_index))

raise ValueError("Unsupported uint size: {}".format(size))


def uint_encode(size: int, uintVar: Expr | ScratchVar) -> Expr:
def uint_encode(size: int, uint_var: Expr | ScratchVar) -> Expr:

if isinstance(uintVar, ScratchVar):
uintVar = uintVar.load()
if isinstance(uint_var, ScratchVar):
uint_var = uint_var.load()

if size > 64:
raise NotImplementedError(
"Uint operations have not yet been implemented for bit sizes larger than 64"
)

if size == 8:
return SetByte(Bytes(b"\x00"), Int(0), uintVar)
return SetByte(Bytes(b"\x00"), Int(0), uint_var)
if size == 16:
return Suffix(Itob(uintVar), Int(6))
return Suffix(Itob(uint_var), Int(6))
if size == 32:
return Suffix(Itob(uintVar), Int(4))
return Suffix(Itob(uint_var), Int(4))
if size == 64:
return Itob(uintVar)
return Itob(uint_var)

raise ValueError("Unsupported uint size: {}".format(size))

Expand Down