-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow stateTotals to be specified statically in contract options
- Loading branch information
1 parent
56725d2
commit 52ebc65
Showing
29 changed files
with
4,554 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
tests/approvals/out/state-totals/BaseWithState.approval.teal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#pragma version 10 | ||
|
||
tests/approvals/state-totals.algo.ts::BaseWithState.approvalProgram: | ||
intcblock 0 1 | ||
txn ApplicationID | ||
bnz main_after_if_else@2 | ||
callsub constructor | ||
|
||
main_after_if_else@2: | ||
callsub __puya_arc4_router__ | ||
return | ||
|
||
|
||
// tests/approvals/state-totals.algo.ts::BaseWithState.constructor() -> void: | ||
constructor: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
proto 0 0 | ||
// tests/approvals/state-totals.algo.ts:5 | ||
// oneGlobal = GlobalState({ initialValue: Uint64(1) }) | ||
pushbytes "oneGlobal" | ||
intc_1 // 1 | ||
app_global_put | ||
retsub | ||
|
||
|
||
// tests/approvals/state-totals.algo.ts::BaseWithState.__puya_arc4_router__() -> uint64: | ||
__puya_arc4_router__: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
proto 0 1 | ||
txn NumAppArgs | ||
intc_0 // 0 | ||
!= | ||
bz __puya_arc4_router___bare_routing@2 | ||
b __puya_arc4_router___after_if_else@6 | ||
|
||
__puya_arc4_router___bare_routing@2: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
txn OnCompletion | ||
intc_0 // 0 | ||
swap | ||
match __puya_arc4_router_____algots__.defaultCreate@3 | ||
b __puya_arc4_router___switch_case_default@4 | ||
|
||
__puya_arc4_router_____algots__.defaultCreate@3: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
txn ApplicationID | ||
intc_0 // 0 | ||
== | ||
assert // can only call when creating | ||
callsub __algots__.defaultCreate | ||
intc_1 // 1 | ||
retsub | ||
|
||
__puya_arc4_router___switch_case_default@4: | ||
|
||
__puya_arc4_router___after_if_else@6: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
intc_0 // 0 | ||
retsub | ||
|
||
|
||
// tests/approvals/state-totals.algo.ts::BaseWithState.__algots__.defaultCreate() -> void: | ||
__algots__.defaultCreate: | ||
// tests/approvals/state-totals.algo.ts:4 | ||
// export class BaseWithState extends Contract { | ||
proto 0 0 | ||
retsub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"hints": {}, | ||
"source": { | ||
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6OkJhc2VXaXRoU3RhdGUuYXBwcm92YWxQcm9ncmFtOgogICAgaW50Y2Jsb2NrIDAgMQogICAgdHhuIEFwcGxpY2F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4dGVuZHMgQ29udHJhY3QgewogICAgaW50Y18wIC8vIDAKICAgIHJldHN1YgoKCi8vIHRlc3RzL2FwcHJvdmFscy9zdGF0ZS10b3RhbHMuYWxnby50czo6QmFzZVdpdGhTdGF0ZS5fX2FsZ290c19fLmRlZmF1bHRDcmVhdGUoKSAtPiB2b2lkOgpfX2FsZ290c19fLmRlZmF1bHRDcmVhdGU6CiAgICAvLyB0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6NAogICAgLy8gZXhwb3J0IGNsYXNzIEJhc2VXaXRoU3RhdGUgZXh0ZW5kcyBDb250cmFjdCB7CiAgICBwcm90byAwIDAKICAgIHJldHN1Ygo=", | ||
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6OkJhc2VXaXRoU3RhdGUuY2xlYXJTdGF0ZVByb2dyYW06CiAgICBwdXNoaW50IDEgLy8gMQogICAgcmV0dXJuCg==" | ||
}, | ||
"state": { | ||
"global": { | ||
"num_byte_slices": 0, | ||
"num_uints": 2 | ||
}, | ||
"local": { | ||
"num_byte_slices": 0, | ||
"num_uints": 0 | ||
} | ||
}, | ||
"schema": { | ||
"global": { | ||
"declared": { | ||
"oneGlobal": { | ||
"type": "uint64", | ||
"key": "oneGlobal" | ||
}, | ||
"twoGlobal": { | ||
"type": "uint64", | ||
"key": "twoGlobal" | ||
} | ||
}, | ||
"reserved": {} | ||
}, | ||
"local": { | ||
"declared": {}, | ||
"reserved": {} | ||
} | ||
}, | ||
"contract": { | ||
"name": "BaseWithState", | ||
"methods": [], | ||
"networks": {} | ||
}, | ||
"bare_call_config": { | ||
"no_op": "CREATE" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"name": "BaseWithState", | ||
"structs": {}, | ||
"methods": [], | ||
"arcs": [ | ||
22, | ||
28 | ||
], | ||
"networks": {}, | ||
"state": { | ||
"schema": { | ||
"global": { | ||
"ints": 2, | ||
"bytes": 0 | ||
}, | ||
"local": { | ||
"ints": 0, | ||
"bytes": 0 | ||
} | ||
}, | ||
"keys": { | ||
"global": { | ||
"oneGlobal": { | ||
"keyType": "AVMString", | ||
"valueType": "AVMUint64", | ||
"key": "b25lR2xvYmFs" | ||
}, | ||
"twoGlobal": { | ||
"keyType": "AVMString", | ||
"valueType": "AVMUint64", | ||
"key": "dHdvR2xvYmFs" | ||
} | ||
}, | ||
"local": {}, | ||
"box": {} | ||
}, | ||
"maps": { | ||
"global": {}, | ||
"local": {}, | ||
"box": {} | ||
} | ||
}, | ||
"bareActions": { | ||
"create": [ | ||
"NoOp" | ||
], | ||
"call": [] | ||
}, | ||
"sourceInfo": { | ||
"approval": { | ||
"sourceInfo": [ | ||
{ | ||
"pc": [ | ||
62 | ||
], | ||
"errorMessage": "can only call when creating" | ||
} | ||
], | ||
"pcOffsetMethod": "none" | ||
}, | ||
"clear": { | ||
"sourceInfo": [], | ||
"pcOffsetMethod": "none" | ||
} | ||
}, | ||
"source": { | ||
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6OkJhc2VXaXRoU3RhdGUuYXBwcm92YWxQcm9ncmFtOgogICAgaW50Y2Jsb2NrIDAgMQogICAgdHhuIEFwcGxpY2F0aW9uSUQKICAgIGJueiBtYWluX2FmdGVyX2lmX2Vsc2VAMgogICAgY2FsbHN1YiBjb25zdHJ1Y3RvcgoKbWFpbl9hZnRlcl9pZl9lbHNlQDI6CiAgICBjYWxsc3ViIF9fcHV5YV9hcmM0X3JvdXRlcl9fCiAgICByZXR1cm4KCgovLyB0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28ud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ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6NAogICAgLy8gZXhwb3J0IGNsYXNzIEJhc2VXaXRoU3RhdGUgZXh0ZW5kcyBDb250cmFjdCB7CiAgICBwcm90byAwIDAKICAgIHJldHN1Ygo=", | ||
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvc3RhdGUtdG90YWxzLmFsZ28udHM6OkJhc2VXaXRoU3RhdGUuY2xlYXJTdGF0ZVByb2dyYW06CiAgICBwdXNoaW50IDEgLy8gMQogICAgcmV0dXJuCg==" | ||
}, | ||
"events": [], | ||
"templateVariables": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma version 10 | ||
|
||
tests/approvals/state-totals.algo.ts::BaseWithState.clearStateProgram: | ||
pushint 1 // 1 | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
contract tests/approvals/state-totals.algo.ts::BaseWithState: | ||
program approval: | ||
subroutine @algorandfoundation/algorand-typescript/arc4/index.d.ts::Contract.approvalProgram() -> bool: | ||
block@0: // L1 | ||
let reinterpret_bool%0#0: bool = (txn ApplicationID) | ||
goto reinterpret_bool%0#0 ? block@2 : block@1 | ||
block@1: // if_body_L1 | ||
tests/approvals/state-totals.algo.ts::BaseWithState.constructor() | ||
goto block@2 | ||
block@2: // after_if_else_L1 | ||
let tmp%0#0: bool = tests/approvals/state-totals.algo.ts::BaseWithState.__puya_arc4_router__() | ||
return tmp%0#0 | ||
|
||
subroutine tests/approvals/state-totals.algo.ts::BaseWithState.constructor() -> void: | ||
block@0: // L4 | ||
(app_global_put "oneGlobal" 1u) | ||
return | ||
|
||
subroutine tests/approvals/state-totals.algo.ts::BaseWithState.__puya_arc4_router__() -> bool: | ||
block@0: // L4 | ||
let tmp%0#0: uint64 = (txn NumAppArgs) | ||
let tmp%1#0: bool = (!= tmp%0#0 0u) | ||
goto tmp%1#0 ? block@1 : block@2 | ||
block@1: // abi_routing_L4 | ||
goto block@6 | ||
block@2: // bare_routing_L4 | ||
let tmp%2#0: uint64 = (txn OnCompletion) | ||
switch tmp%2#0 {0u => block@3, * => block@4} | ||
block@3: // __algots__.defaultCreate_L4 | ||
let tmp%3#0: uint64 = (txn ApplicationID) | ||
let tmp%4#0: bool = (== tmp%3#0 0u) | ||
(assert tmp%4#0) // can only call when creating | ||
tests/approvals/state-totals.algo.ts::BaseWithState.__algots__.defaultCreate() | ||
return 1u | ||
block@4: // switch_case_default_L4 | ||
goto block@5 | ||
block@5: // switch_case_next_L4 | ||
goto block@6 | ||
block@6: // after_if_else_L4 | ||
return 0u | ||
|
||
subroutine tests/approvals/state-totals.algo.ts::BaseWithState.__algots__.defaultCreate() -> void: | ||
block@0: // L4 | ||
return | ||
|
||
program clear-state: | ||
subroutine @algorandfoundation/algorand-typescript/base-contract.d.ts::BaseContract.clearStateProgram() -> bool: | ||
block@0: // L1 | ||
return 1u |
Oops, something went wrong.