Skip to content

Commit 6df2567

Browse files
authored
chore: refreshing todos (#11)
[skip ci]
1 parent 8c12bab commit 6df2567

File tree

17 files changed

+34
-36
lines changed

17 files changed

+34
-36
lines changed

src/algopy_testing/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from algopy_testing.primitives import BigUInt, Bytes, String, UInt64
2525
from algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState
2626

27+
# TODO: clean up and ensure only algopy_testing namespace specific user facing abstractions
28+
# are exposed Only keep the _value_generators, ledger_context, txn_context,
29+
# context, and arc4_prexif from utils (make utils private)
2730
__all__ = [
2831
"ARC4Contract",
2932
"ARC4ValueGenerator",

src/algopy_testing/_context_helpers/ledger_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self) -> None:
1919
self.account_data = defaultdict[str, AccountContextData](get_empty_account)
2020
self.application_data: dict[int, ApplicationContextData] = {}
2121
self.asset_data: dict[int, AssetFields] = {}
22-
# TODO: move boxes onto application data
22+
# TODO: 1.0 move boxes onto application data
2323
self.boxes: dict[bytes, bytes] = {}
2424
self.blocks: dict[int, dict[str, int]] = {}
2525
self.global_fields: GlobalFields = get_default_global_fields()
@@ -85,6 +85,7 @@ def update_application(
8585

8686
self.application_data[app_id].fields.update(application_fields)
8787

88+
# TODO: 1.0 add app ids, access the boxes from application data
8889
def get_box(self, name: algopy.Bytes | bytes) -> bytes:
8990
name_bytes = name if isinstance(name, bytes) else name.value
9091
return self.boxes.get(name_bytes, b"")

src/algopy_testing/_value_generators/avm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def asset(
117117
if asset_id and asset_id in lazy_context.ledger.asset_data:
118118
raise ValueError("Asset with such ID already exists in testing context!")
119119

120-
# TODO: ensure passed fields are valid names and types
120+
# TODO: 1.0 ensure passed fields are valid names and types
121121
new_asset = algopy.Asset(asset_id or next(lazy_context.ledger.asset_id))
122122
default_asset_fields = {
123123
"total": lazy_context.any.uint64(),

src/algopy_testing/_value_generators/txn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def transaction(
123123
return self._new_gtxn(gtxn.Transaction, **fields)
124124

125125
def _new_gtxn(self, txn_type: type[_TGlobalTxn], **fields: object) -> _TGlobalTxn:
126-
# TODO: check reference types are known?
127126
fields.setdefault("type", txn_type.type_enum)
128127
fields.setdefault("sender", lazy_context.value.default_sender)
129128

src/algopy_testing/arc4.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ def __init__(
277277
bytes_value = int_to_bytes(value, self.type_info.max_bytes_len)
278278
self._value = as_bytes(bytes_value)
279279

280-
# ~~~ https://docs.python.org/3/reference/datamodel.html#basic-customization ~~~
281-
# TODO: mypy suggests due to Liskov below should be other: object
282-
# need to consider ramifications here, ignoring it for now
283280
def __eq__( # type: ignore[override]
284281
self,
285282
other: UIntN[_TBitSize] | BigUIntN[_TBitSize] | algopy.UInt64 | algopy.BigUInt | int,
@@ -1031,7 +1028,7 @@ def _tuple_type_from_struct(struct: type[Struct]) -> type[Tuple]: # type: ignor
10311028
class Struct(metaclass=_StructMeta):
10321029
"""Base class for ARC4 Struct types."""
10331030

1034-
type_info: typing.ClassVar[_TypeInfo] # TODO: this could clash with user values
1031+
type_info: typing.ClassVar[_TypeInfo] # TODO: 1.0 this could clash with user values
10351032

10361033
def __init_subclass__(cls) -> None:
10371034
dataclasses.dataclass(cls)

src/algopy_testing/context.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(
3232
) -> None:
3333
import algopy
3434

35-
# TODO: remove direct reads of data mappings outside of context_storage
3635
self._default_sender = algopy.Account(
3736
default_sender or algosdk.account.generate_account()[1]
3837
)

src/algopy_testing/decorators/arc4.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_arc4_metadata(fn: object) -> MethodMetadata:
6464
def get_ordered_args(
6565
_fn: Callable[..., typing.Any], app_args: list[typing.Any], kwargs: dict[str, typing.Any]
6666
) -> list[typing.Any]:
67-
# TODO: order kwargs correctly based on fn signature
67+
# TODO: 1.0 order kwargs correctly based on fn signature
6868
return [*app_args, *kwargs.values()]
6969

7070

@@ -140,8 +140,6 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
140140
app_id = contract.__app_id__
141141

142142
context = lazy_context.value
143-
# TODO: does contract need to be active here?
144-
# TODO: handle custom txn groups
145143
ordered_args = get_ordered_args(fn, app_args, kwargs)
146144
assert metadata.arc4_signature is not None, "expected abimethod"
147145
txns = create_abimethod_txns(
@@ -152,7 +150,7 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
152150
with context.txn._maybe_implicit_txn_group(txns):
153151
check_routing_conditions(app_id, metadata)
154152
result = fn(*args, **kwargs)
155-
# TODO: add result along with ARC4 log prefix to application logs?
153+
# TODO: 1.0 add result along with ARC4 log prefix to application logs?
156154
return result
157155

158156
return wrapper
@@ -202,7 +200,6 @@ def create_baremethod_txns(app_id: int) -> list[algopy.gtxn.TransactionBase]:
202200
contract_app = lazy_context.ledger.get_application(app_id)
203201
txn_fields.setdefault("app_id", contract_app)
204202

205-
# TODO: fill out other fields where possible (see abimethod)
206203
txn_fields.setdefault(
207204
"approval_program_pages", [algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)]
208205
)
@@ -253,7 +250,7 @@ def _extract_arrays_from_args(
253250
case _ as maybe_native:
254251
app_args.append(algopy_testing.arc4.native_value_to_arc4(maybe_native).bytes)
255252
if len(app_args) > 16:
256-
# TODO: pack extra args into an ARC4 tuple
253+
# TODO:1.0 pack extra args into an ARC4 tuple
257254
raise NotImplementedError
258255
return _TxnArrays(
259256
txns=txns,
@@ -374,7 +371,6 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
374371
assert isinstance(contract, algopy_testing.ARC4Contract), "expected ARC4 contract"
375372
assert fn is not None, "expected function"
376373

377-
# TODO: handle custom txn groups
378374
txns = create_baremethod_txns(contract.__app_id__)
379375

380376
with lazy_context.txn._maybe_implicit_txn_group(txns):

src/algopy_testing/models/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ApplicationContextData:
4242
)
4343
is_creating: bool = False
4444
contract: Contract | None = None
45+
# TODO: 1.0 add getter to ledger context, get_global_state, get_local_state, get_box
4546

4647
def get_global_state(self, key: algopy.Bytes | bytes) -> StateValueType:
4748
return self.global_state[as_bytes(key)]
@@ -99,7 +100,7 @@ def fields(self) -> ApplicationFields:
99100
def __getattr__(self, name: str) -> typing.Any:
100101
if name in inspect.get_annotations(ApplicationFields):
101102
value = self.fields.get(name)
102-
# TODO: ensure reasonable default values are present (like account does)
103+
# TODO: 1.0 ensure reasonable default values are present (like account does)
103104
if value is None:
104105
raise ValueError(
105106
f"The Application value '{name}' has not been defined on the test context. "

src/algopy_testing/models/contract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __call__(cls, *args: typing.Any, **kwargs: dict[str, typing.Any]) -> object:
4848
fields = lazy_context.get_txn_op_fields()
4949
fields["app_id"] = app_ref
5050

51-
# TODO: provide app_id during instantiation without requiring a txn
51+
# TODO: 1.0 provide app_id during instantiation without requiring a txn
5252
txn = context.any.txn.application_call(**fields)
5353
with context.txn.create_group([txn]):
5454
instance = super().__call__(*args, **kwargs)
@@ -91,7 +91,7 @@ def __init_subclass__(
9191
) = None,
9292
state_totals: StateTotals | None = None,
9393
):
94-
# TODO: check storing these on cls does not interfere with instances
94+
# TODO: 1.0 add test : check storing these on cls does not interfere with instances
9595
# by having a contract with _name, _scratch_slots and _state_totals attributes
9696
cls._name = name or cls.__name__
9797
cls._scratch_slots = scratch_slots
@@ -113,7 +113,7 @@ def set_active_contract(
113113
*args: typing.Any, **kwargs: dict[str, typing.Any]
114114
) -> typing.Any:
115115
context = lazy_context.value
116-
# TODO: this should populate the app txn as much as possible like abimethod does
116+
# TODO: 1.0 should populate the app txn as much as possible like abimethod does
117117
app = context.ledger.get_application(_get_self_or_active_app_id(self))
118118
txns = [context.any.txn.application_call(app_id=app)]
119119
with context.txn._maybe_implicit_txn_group(txns):
@@ -207,7 +207,7 @@ def _get_state_totals(contract: Contract, cls_state_totals: StateTotals) -> _Sta
207207
else:
208208
local_bytes += 1
209209

210-
# TODO: add tests for state overrides
210+
# TODO: 1.0 add tests for state overrides
211211
# apply any cls specific overrides
212212
if cls_state_totals.global_uints is not None:
213213
global_uints = cls_state_totals.global_uints

src/algopy_testing/models/txn_fields.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class ApplicationCallFields(TransactionBaseFields, total=False):
7676
accounts: Sequence[algopy.Account]
7777
assets: Sequence[algopy.Asset]
7878
apps: Sequence[algopy.Application]
79-
# TODO: when storing these pages values, combine into one bytes and then
80-
# "chop" into 4096 length pieces
79+
# TODO: 1.0 when storing these pages values, combine into one bytes and then
80+
# "chop" into 4096 length pieces. Covered in ITxns, ensure Txns use the same method
8181
approval_program: Sequence[algopy.Bytes]
8282
clear_state_program: Sequence[algopy.Bytes]
8383

@@ -104,7 +104,6 @@ class TransactionFields( # type: ignore[misc]
104104
type: algopy.TransactionType
105105

106106

107-
# TODO: can this easily be derived from annotations?
108107
_FIELD_TYPES = {
109108
"sender": Account,
110109
"rekey_to": Account,
@@ -201,7 +200,7 @@ def sender(self) -> algopy.Account:
201200
return self.fields["sender"] # type: ignore[return-value]
202201

203202
@property
204-
def txn_id(self) -> algopy.Bytes: # TODO: txn_id or tx_id
203+
def txn_id(self) -> algopy.Bytes:
205204
return self.fields["txn_id"] # type: ignore[return-value]
206205

207206
@property

0 commit comments

Comments
 (0)