Skip to content

Commit

Permalink
fix linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
CiottiGiorgio committed Nov 5, 2024
1 parent 2b3ff14 commit 0c4c588
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pyright: reportMissingModuleSource=false
import typing as t

from algopy import ARC4Contract, GlobalState, UInt64, arc4, urange, String, Bytes
from algopy import ARC4Contract, GlobalState, String, UInt64, arc4, urange
from algopy.arc4 import abimethod


Expand Down Expand Up @@ -38,7 +38,9 @@ def arc4_uint_n(
return arc4.UInt64(total)

@abimethod()
def arc4_biguint_n(self, a: arc4.UInt128, b: arc4.UInt256, c: arc4.UInt512) -> arc4.UInt512:
def arc4_biguint_n(
self, a: arc4.UInt128, b: arc4.UInt256, c: arc4.UInt512
) -> arc4.UInt512:
"""
Integers with larger bit size are supported up to 512 bits.
Ultimately, they are all represented with native BigUInt.
Expand All @@ -60,7 +62,7 @@ def arc4_byte(self, a: arc4.Byte) -> arc4.Byte:

@abimethod()
def arc4_address_properties(self, address: arc4.Address) -> UInt64:
underlying_bytes = (
underlying_bytes = ( # noqa: F841
address.bytes
) # This will return the underlying bytes of the address.

Expand All @@ -69,7 +71,7 @@ def arc4_address_properties(self, address: arc4.Address) -> UInt64:
) # This will return the account type of the given address.

bal = account.balance # returns the balance of the account
total_asset = (
total_asset = ( # noqa: F841
account.total_assets
) # returns the total assets held in the account

Expand Down Expand Up @@ -140,7 +142,9 @@ def arc4_dynamic_array(self, name: arc4.String) -> arc4.String:
"""
dynamic_string_array = arc4.DynamicArray[arc4.String](arc4.String("Hello"))

extension = arc4.DynamicArray[arc4.String](arc4.String(" world"), arc4.String(", "))
extension = arc4.DynamicArray[arc4.String](
arc4.String(" world"), arc4.String(", ")
)
dynamic_string_array.extend(extension)

dynamic_string_array.append(name)
Expand Down Expand Up @@ -214,7 +218,12 @@ def return_todo(self, task: arc4.String) -> Todo:
class Arc4Tuple(ARC4Contract):

@abimethod()
def arc4_tuple(self, a: arc4.Tuple[arc4.UInt8, arc4.String, arc4.UInt64, arc4.DynamicArray[arc4.UInt32]]) -> arc4.String:
def arc4_tuple(
self,
a: arc4.Tuple[
arc4.UInt8, arc4.String, arc4.UInt64, arc4.DynamicArray[arc4.UInt32]
],
) -> arc4.String:
"""An arc4.Tuple is a heterogeneous collection of arc4 types."""

total = a[0].native + a[2].native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ def deploy(
on_schema_break=algokit_utils.OnSchemaBreak.AppendApp,
on_update=algokit_utils.OnUpdate.AppendApp,
)
name = "world"
response = app_client.hello(name=name)
logger.info(
f"Called hello on {app_spec.contract.name} ({app_client.app_id}) "
f"with name={name}, received: {response.return_value}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from algokit_utils.config import config
from algosdk.v2client.algod import AlgodClient

from smart_contracts.artifacts.arc4_types.arc4_dynamic_array_client import Arc4DynamicArrayClient, SimulateOptions
from smart_contracts.artifacts.arc4_types.arc4_dynamic_array_client import (
Arc4DynamicArrayClient,
SimulateOptions,
)
from smart_contracts.artifacts.arc4_types.arc4_static_array_client import (
Arc4StaticArrayClient,
)
Expand Down Expand Up @@ -283,16 +286,24 @@ def test_arc4_static_array(arc4_statc_array_app_client: Arc4StaticArrayClient) -
arc4_statc_array_app_client.arc4_static_array()


def test_arc4_dynamic_array(arc4_dynamic_array_app_client: Arc4DynamicArrayClient) -> None:
def test_arc4_dynamic_array(
arc4_dynamic_array_app_client: Arc4DynamicArrayClient,
) -> None:
"""Test the arc4_dynamic_array method"""

# Call the arc4_static_array method with simulate to avoid opcode budget constraints.
result = arc4_dynamic_array_app_client.compose().arc4_dynamic_array(name="John").simulate(SimulateOptions(extra_opcode_budget=700))
result = (
arc4_dynamic_array_app_client.compose()
.arc4_dynamic_array(name="John")
.simulate(SimulateOptions(extra_opcode_budget=700))
)

assert result.abi_results[0].return_value == "Hello world, John"


def test_arc4_dynamic_bytes(arc4_dynamic_array_app_client: Arc4DynamicArrayClient) -> None:
def test_arc4_dynamic_bytes(
arc4_dynamic_array_app_client: Arc4DynamicArrayClient,
) -> None:
"""Test the arc4_dynamic_bytes method"""

# Call the arc4_static_array method.
Expand Down Expand Up @@ -341,6 +352,8 @@ def test_arc4_tuple(
) -> None:
"""Test the arc4_tuple method"""

result = arc4_tuple_app_client.arc4_tuple(a=(4, "This is a good string.", 100, [1, 2, 3]))
result = arc4_tuple_app_client.arc4_tuple(
a=(4, "This is a good string.", 100, [1, 2, 3])
)

assert result.return_value == "This is a good string."

0 comments on commit 0c4c588

Please sign in to comment.