Skip to content

Commit 7df0996

Browse files
committed
per comments
1 parent 4aa69c6 commit 7df0996

File tree

6 files changed

+50
-60
lines changed

6 files changed

+50
-60
lines changed

pyteal/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ from pyteal.config import (
2929

3030
__all__ = [
3131
"ABIReturnSubroutine",
32-
"ASTBuilder",
3332
"AccountParam",
3433
"Add",
3534
"Addr",

pyteal/ast/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140
from pyteal.ast.ecdsa import EcdsaCurve, EcdsaVerify, EcdsaDecompress, EcdsaRecover
141141
from pyteal.ast.router import (
142142
Router,
143-
ASTBuilder,
144143
CallConfig,
145144
MethodConfig,
146145
OnCompleteAction,
@@ -288,7 +287,6 @@
288287
"Break",
289288
"Continue",
290289
"Router",
291-
"ASTBuilder",
292290
"CallConfig",
293291
"MethodConfig",
294292
"OnCompleteAction",

pyteal/ast/int.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,5 @@ def __str__(self):
6464
def type_of(self):
6565
return TealType.uint64
6666

67-
def __hash__(self) -> int:
68-
return hash(str(self))
69-
7067

7168
EnumInt.__module__ = "pyteal"

pyteal/ast/router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def method(
537537
func: Callable = None,
538538
/,
539539
*,
540-
overriding_name: str = None,
540+
name: str = None,
541541
no_op: CallConfig = CallConfig.CALL,
542542
opt_in: CallConfig = CallConfig.NEVER,
543543
close_out: CallConfig = CallConfig.NEVER,
@@ -555,7 +555,7 @@ def wrap(_func):
555555
update_application=update_application,
556556
delete_application=delete_application,
557557
)
558-
self.add_method_handler(wrapped_subroutine, overriding_name, call_configs)
558+
self.add_method_handler(wrapped_subroutine, name, call_configs)
559559

560560
if not func:
561561
return wrap

pyteal/ast/router_test.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import pyteal as pt
2+
from pyteal.ast.router import ASTBuilder
3+
24
import itertools
35
import pytest
46

57
# import random
68
import typing
79
import algosdk.abi as sdk_abi
810

11+
912
options = pt.CompileOptions(version=5)
1013

1114

@@ -188,7 +191,7 @@ def power_set(no_dup_list: list, length_override: int = None):
188191

189192
def full_perm_gen(non_dup_list: list, perm_length: int):
190193
if perm_length < 0:
191-
raise
194+
raise pt.TealInputError("input permutation length must be non-negative")
192195
elif perm_length == 0:
193196
yield []
194197
return
@@ -413,7 +416,7 @@ def test_wrap_handler_bare_call():
413416
pt.Log(pt.Bytes("message")),
414417
]
415418
for bare_call in BARE_CALL_CASES:
416-
wrapped: pt.Expr = pt.ASTBuilder.wrap_handler(False, bare_call)
419+
wrapped: pt.Expr = ASTBuilder.wrap_handler(False, bare_call)
417420
match bare_call:
418421
case pt.Expr():
419422
if bare_call.has_return():
@@ -453,24 +456,24 @@ def test_wrap_handler_bare_call():
453456
]
454457
for error_case, error_msg in ERROR_CASES:
455458
with pytest.raises(pt.TealInputError) as bug:
456-
pt.ASTBuilder.wrap_handler(False, error_case)
459+
ASTBuilder.wrap_handler(False, error_case)
457460
assert error_msg in str(bug)
458461

459462

460463
def test_wrap_handler_method_call():
461464
with pytest.raises(pt.TealInputError) as bug:
462-
pt.ASTBuilder.wrap_handler(True, not_registrable)
465+
ASTBuilder.wrap_handler(True, not_registrable)
463466
assert "method call ABIReturnSubroutine is not routable" in str(bug)
464467

465468
with pytest.raises(pt.TealInputError) as bug:
466-
pt.ASTBuilder.wrap_handler(True, safe_clear_state_delete)
469+
ASTBuilder.wrap_handler(True, safe_clear_state_delete)
467470
assert "method call should be only registering ABIReturnSubroutine" in str(bug)
468471

469472
ONLY_ABI_SUBROUTINE_CASES = list(
470473
filter(lambda x: isinstance(x, pt.ABIReturnSubroutine), GOOD_SUBROUTINE_CASES)
471474
)
472475
for abi_subroutine in ONLY_ABI_SUBROUTINE_CASES:
473-
wrapped: pt.Expr = pt.ASTBuilder.wrap_handler(True, abi_subroutine)
476+
wrapped: pt.Expr = ASTBuilder.wrap_handler(True, abi_subroutine)
474477
assembled_wrapped: pt.TealBlock = assemble_helper(wrapped)
475478

476479
args: list[pt.abi.BaseType] = [
@@ -539,8 +542,4 @@ def test_contract_json_obj():
539542
method_list.append(sdk_abi.Method.from_signature(subroutine.method_signature()))
540543
sdk_contract = sdk_abi.Contract(contract_name, method_list)
541544
contract = router.contract_construct()
542-
assert sdk_contract.desc == contract.desc
543-
assert sdk_contract.name == contract.name
544-
assert sdk_contract.networks == contract.networks
545-
for method in sdk_contract.methods:
546-
assert method in contract.methods
545+
assert contract == sdk_contract

pyteal/compiler/compiler_test.py

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,44 +2274,42 @@ def all_laid_to_args(
22742274

22752275
router.add_method_handler(all_laid_to_args)
22762276

2277-
actual_ap_compiled, actual_csp_compiled, _ = router.compile_program(
2278-
version=6, assembleConstants=True
2279-
)
2277+
actual_ap_compiled, actual_csp_compiled, _ = router.compile_program(version=6)
2278+
print(actual_ap_compiled)
2279+
print(actual_csp_compiled)
22802280

22812281
expected_ap = """#pragma version 6
2282-
intcblock 0 1
2283-
bytecblock 0x151f7c75
22842282
txna ApplicationArgs 0
2285-
pushbytes 0xfe6bdf69 // "add(uint64,uint64)uint64"
2283+
method "add(uint64,uint64)uint64"
22862284
==
22872285
bnz main_l12
22882286
txna ApplicationArgs 0
2289-
pushbytes 0x78b488b7 // "sub(uint64,uint64)uint64"
2287+
method "sub(uint64,uint64)uint64"
22902288
==
22912289
bnz main_l11
22922290
txna ApplicationArgs 0
2293-
pushbytes 0xe2f188c5 // "mul(uint64,uint64)uint64"
2291+
method "mul(uint64,uint64)uint64"
22942292
==
22952293
bnz main_l10
22962294
txna ApplicationArgs 0
2297-
pushbytes 0x16e80f08 // "div(uint64,uint64)uint64"
2295+
method "div(uint64,uint64)uint64"
22982296
==
22992297
bnz main_l9
23002298
txna ApplicationArgs 0
2301-
pushbytes 0x4dfc58ae // "mod(uint64,uint64)uint64"
2299+
method "mod(uint64,uint64)uint64"
23022300
==
23032301
bnz main_l8
23042302
txna ApplicationArgs 0
2305-
pushbytes 0x487ce2fd // "all_laid_to_args(uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64)uint64"
2303+
method "all_laid_to_args(uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64)uint64"
23062304
==
23072305
bnz main_l7
23082306
err
23092307
main_l7:
23102308
txn OnCompletion
2311-
intc_0 // NoOp
2309+
int NoOp
23122310
==
23132311
txn ApplicationID
2314-
intc_0 // 0
2312+
int 0
23152313
!=
23162314
&&
23172315
assert
@@ -2360,11 +2358,11 @@ def all_laid_to_args(
23602358
txna ApplicationArgs 15
23612359
store 44
23622360
load 44
2363-
intc_0 // 0
2361+
int 0
23642362
extract_uint64
23652363
store 45
23662364
load 44
2367-
pushint 8 // 8
2365+
int 8
23682366
extract_uint64
23692367
store 46
23702368
load 30
@@ -2385,19 +2383,19 @@ def all_laid_to_args(
23852383
load 46
23862384
callsub alllaidtoargs_5
23872385
store 47
2388-
bytec_0 // 0x151f7c75
2386+
byte 0x151f7c75
23892387
load 47
23902388
itob
23912389
concat
23922390
log
2393-
intc_1 // 1
2391+
int 1
23942392
return
23952393
main_l8:
23962394
txn OnCompletion
2397-
intc_0 // NoOp
2395+
int NoOp
23982396
==
23992397
txn ApplicationID
2400-
intc_0 // 0
2398+
int 0
24012399
!=
24022400
&&
24032401
assert
@@ -2411,19 +2409,19 @@ def all_laid_to_args(
24112409
load 25
24122410
callsub mod_4
24132411
store 26
2414-
bytec_0 // 0x151f7c75
2412+
byte 0x151f7c75
24152413
load 26
24162414
itob
24172415
concat
24182416
log
2419-
intc_1 // 1
2417+
int 1
24202418
return
24212419
main_l9:
24222420
txn OnCompletion
2423-
intc_0 // NoOp
2421+
int NoOp
24242422
==
24252423
txn ApplicationID
2426-
intc_0 // 0
2424+
int 0
24272425
!=
24282426
&&
24292427
assert
@@ -2437,19 +2435,19 @@ def all_laid_to_args(
24372435
load 19
24382436
callsub div_3
24392437
store 20
2440-
bytec_0 // 0x151f7c75
2438+
byte 0x151f7c75
24412439
load 20
24422440
itob
24432441
concat
24442442
log
2445-
intc_1 // 1
2443+
int 1
24462444
return
24472445
main_l10:
24482446
txn OnCompletion
2449-
intc_0 // NoOp
2447+
int NoOp
24502448
==
24512449
txn ApplicationID
2452-
intc_0 // 0
2450+
int 0
24532451
!=
24542452
&&
24552453
assert
@@ -2463,19 +2461,19 @@ def all_laid_to_args(
24632461
load 13
24642462
callsub mul_2
24652463
store 14
2466-
bytec_0 // 0x151f7c75
2464+
byte 0x151f7c75
24672465
load 14
24682466
itob
24692467
concat
24702468
log
2471-
intc_1 // 1
2469+
int 1
24722470
return
24732471
main_l11:
24742472
txn OnCompletion
2475-
intc_0 // NoOp
2473+
int NoOp
24762474
==
24772475
txn ApplicationID
2478-
intc_0 // 0
2476+
int 0
24792477
!=
24802478
&&
24812479
assert
@@ -2489,19 +2487,19 @@ def all_laid_to_args(
24892487
load 7
24902488
callsub sub_1
24912489
store 8
2492-
bytec_0 // 0x151f7c75
2490+
byte 0x151f7c75
24932491
load 8
24942492
itob
24952493
concat
24962494
log
2497-
intc_1 // 1
2495+
int 1
24982496
return
24992497
main_l12:
25002498
txn OnCompletion
2501-
intc_0 // NoOp
2499+
int NoOp
25022500
==
25032501
txn ApplicationID
2504-
intc_0 // 0
2502+
int 0
25052503
!=
25062504
&&
25072505
assert
@@ -2515,12 +2513,12 @@ def all_laid_to_args(
25152513
load 1
25162514
callsub add_0
25172515
store 2
2518-
bytec_0 // 0x151f7c75
2516+
byte 0x151f7c75
25192517
load 2
25202518
itob
25212519
concat
25222520
log
2523-
intc_1 // 1
2521+
int 1
25242522
return
25252523
25262524
// add
@@ -2633,17 +2631,16 @@ def all_laid_to_args(
26332631
assert expected_ap == actual_ap_compiled
26342632

26352633
expected_csp = """#pragma version 6
2636-
intcblock 0
26372634
txn NumAppArgs
2638-
intc_0 // 0
2635+
int 0
26392636
==
26402637
bnz main_l2
26412638
err
26422639
main_l2:
26432640
txn ApplicationID
2644-
intc_0 // 0
2641+
int 0
26452642
!=
26462643
assert
2647-
pushint 1 // 1
2644+
int 1
26482645
return""".strip()
26492646
assert expected_csp == actual_csp_compiled

0 commit comments

Comments
 (0)