11import typing
22
3- from algopy import Bytes , FixedBytes , arc4
3+ from algopy import Application , Bytes , FixedBytes , arc4
44
55FixedBytes11 = FixedBytes [typing .Literal [11 ]]
66
77
88class FixedBytesABI (arc4 .ARC4Contract ):
9- @arc4 .abimethod ()
10- def test_itxn_validate_caller_bytes (self , val : Bytes ) -> None :
11- app = arc4 .arc4_create (CheckABIApp ).created_app
12-
9+ @arc4 .abimethod (resource_encoding = "index" )
10+ def test_itxn_validate_caller_bytes (self , checker : Application , val : Bytes ) -> None :
1311 # this be validated in the caller as it will attempt to encode val to FixedBytes11
1412 arc4 .abi_call (
1513 CheckABIApp .manual_validate ,
1614 val ,
17- app_id = app ,
15+ app_id = checker ,
1816 )
1917
20- arc4 .abi_call (CheckABIApp .delete , app_id = app )
21-
22- @arc4 .abimethod ()
23- def test_itxn_validate_callee_manual (self , val : Bytes ) -> None :
24- app = arc4 .arc4_create (CheckABIApp ).created_app
25-
18+ @arc4 .abimethod (resource_encoding = "index" )
19+ def test_itxn_validate_callee_manual (self , checker : Application , val : Bytes ) -> None :
2620 fb = FixedBytes11 .from_bytes (val )
2721 # this will be validated in the callee method as types match
2822 arc4 .abi_call (
2923 CheckABIApp .manual_validate ,
3024 fb ,
31- app_id = app ,
25+ app_id = checker ,
3226 )
3327
34- arc4 .abi_call (CheckABIApp .delete , app_id = app )
35-
36- @arc4 .abimethod ()
37- def test_itxn_validate_callee_router (self , val : Bytes ) -> None :
38- app = arc4 .arc4_create (CheckABIApp ).created_app
39-
28+ @arc4 .abimethod (resource_encoding = "index" )
29+ def test_itxn_validate_callee_router (self , checker : Application , val : Bytes ) -> None :
4030 fb = FixedBytes11 .from_bytes (val )
4131 # this will be validated in the callee router as types match
4232 arc4 .abi_call (
4333 CheckABIApp .router_validate ,
4434 fb ,
45- app_id = app ,
35+ app_id = checker ,
4636 )
4737
48- arc4 .abi_call (CheckABIApp .delete , app_id = app )
38+ @arc4 .abimethod (resource_encoding = "index" )
39+ def test_static_to_dynamic_encoding (self , checker : Application ) -> None :
40+ fb = FixedBytes11 (b"hello world" )
41+ arc4 .abi_call (
42+ CheckABIApp .i_am_a_dynamic_personality ,
43+ fb ,
44+ app_id = checker ,
45+ )
4946
5047
5148class CheckABIApp (arc4 .ARC4Contract ):
@@ -57,6 +54,6 @@ def manual_validate(self, value: FixedBytes11) -> None:
5754 def router_validate (self , value : FixedBytes11 ) -> None :
5855 assert value .bytes .length == 11 , "callee method check failed"
5956
60- @arc4 .abimethod ( allow_actions = [ "DeleteApplication" ])
61- def delete (self ) -> None :
62- pass
57+ @arc4 .abimethod
58+ def i_am_a_dynamic_personality (self , value : arc4 . DynamicBytes ) -> None :
59+ assert value . native == b"hello world"
0 commit comments