Skip to content

Commit 8024d37

Browse files
authored
refactor: refinements to support client generator v3 (#130)
* chore: initial methods for typed client generator * fix: fixing arc2 note generation in AppDeployer * fix: changing CompiledTeal compiled to str from bytes; patching _build_source_map * refactor: adding usage of collections.abc.Sequence for args params * refactor: expose algorand client protocol; expand to cover latest interface * refactor: patch compile_teal_template behaviour around deployment_metadata * refactor: using generics for abi_return type in AppFactoryCreateMethodCallResult * refactor: making deploy arg types in app factory rely on generic (for redefinition in client generator) * refactor: further leveraging generics to match ts behaviour, the abi_return type turns into ABIValue * fix: proper use of type vars for client manager typed class getters * refactor: make all bare properties on app client send/createTxn/params optional * refactor: add error handler for simulate responses * fix: proper handling of default args from hints * fix: proper handling of getting abi args with default values (when no args given) * fix: typo in generics inheritance * refactor: ensure send calls from AppClient for methods parse output to arc56 values * fix: skip snake case conversion for struct field in arc56 * fix: group id generation for log during send atc * fix: exposing AppMethodCallTransactionArgument for typed client * fix: fixing params creation in factory * fix: safer global state decoding * refactor: parametrize indent in to_json methods of arc classes * fix: typo in get_map decoding * fix: box key decoding * refactor: contravariant typevars for typed factory protocol plus a fix for box decoding
1 parent b3dec7f commit 8024d37

21 files changed

+839
-381
lines changed

poetry.lock

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/algokit_utils/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from algokit_utils.applications.app_manager import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME
1515
from algokit_utils.errors.logic_error import LogicError
1616
from algokit_utils.clients.algorand_client import AlgorandClient
17+
from algokit_utils.protocols import AlgorandClientProtocol
1718

1819
# Common managers/clients that are frequently used entry points
1920
from algokit_utils.accounts.account_manager import AccountManager
@@ -138,6 +139,7 @@
138139
"AlgorandClient",
139140
"DELETABLE_TEMPLATE_NAME",
140141
"UPDATABLE_TEMPLATE_NAME",
142+
"AlgorandClientProtocol",
141143
# Common managers/clients
142144
"AccountManager",
143145
"AppClient",

src/algokit_utils/_debugging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _build_avm_sourcemap(
169169
source_map = compiled_teal.source_map.__dict__
170170
teal_content = compiled_teal.teal
171171
elif isinstance(compiled_teal, CompiledTeal):
172-
program_hash = base64.b64encode(checksum(compiled_teal.compiled)).decode()
172+
program_hash = base64.b64encode(checksum(compiled_teal.compiled_base64_to_bytes)).decode()
173173
source_map = compiled_teal.source_map.__dict__ if compiled_teal.source_map else {}
174174
teal_content = compiled_teal.teal
175175
else:

src/algokit_utils/applications/abi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ABIStruct: TypeAlias = dict[str, list[dict[str, "ABIValue"]]]
1616
Arc56ReturnValueType: TypeAlias = ABIValue | ABIStruct | None
1717

18+
1819
ABIType: TypeAlias = algosdk.abi.ABIType
1920
ABIArgumentType: TypeAlias = algosdk.abi.ABIType | algosdk.abi.ABITransactionType | algosdk.abi.ABIReferenceType
2021

@@ -56,13 +57,13 @@ def is_success(self) -> bool:
5657

5758
def get_arc56_value(
5859
self, method: Arc56Method | AlgorandABIMethod, structs: dict[str, list[StructField]]
59-
) -> ABIValue | ABIStruct | None:
60+
) -> Arc56ReturnValueType:
6061
return get_arc56_value(self, method, structs)
6162

6263

6364
def get_arc56_value(
6465
abi_return: ABIReturn, method: Arc56Method | AlgorandABIMethod, structs: dict[str, list[StructField]]
65-
) -> ABIValue | ABIStruct | None:
66+
) -> Arc56ReturnValueType:
6667
if isinstance(method, AlgorandABIMethod):
6768
type_str = method.returns.type
6869
struct = None # AlgorandABIMethod doesn't have struct info

0 commit comments

Comments
 (0)