-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #535 from algorandfoundation/feat/non_class_functions
feat: allow calling non-class functions
- Loading branch information
Showing
10 changed files
with
1,061 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#pragma version 10 | ||
|
||
// This TEAL was generated by TEALScript v0.101.0 | ||
// https://github.com/algorandfoundation/TEALScript | ||
|
||
// This contract is compliant with and/or implements the following ARCs: [ ARC4 ] | ||
|
||
// The following ten lines of TEAL handle initial program flow | ||
// This pattern is used to make it easy for anyone to parse the start of the program and determine if a specific action is allowed | ||
// Here, action refers to the OnComplete in combination with whether the app is being created or called | ||
// Every possible action for this contract is represented in the switch statement | ||
// If the action is not implemented in the contract, its respective branch will be "*NOT_IMPLEMENTED" which just contains "err" | ||
txn ApplicationID | ||
! | ||
int 6 | ||
* | ||
txn OnCompletion | ||
+ | ||
switch *call_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *create_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED | ||
|
||
*NOT_IMPLEMENTED: | ||
// The requested action is not implemented in this contract. Are you using the correct OnComplete? Did you set your app ID? | ||
err | ||
|
||
// callNonClassFunction(uint64,uint64)uint64 | ||
*abi_route_callNonClassFunction: | ||
// The ABI return prefix | ||
byte 0x151f7c75 | ||
|
||
// b: uint64 | ||
txna ApplicationArgs 2 | ||
btoi | ||
|
||
// a: uint64 | ||
txna ApplicationArgs 1 | ||
btoi | ||
|
||
// execute callNonClassFunction(uint64,uint64)uint64 | ||
callsub callNonClassFunction | ||
itob | ||
concat | ||
log | ||
int 1 | ||
return | ||
|
||
// callNonClassFunction(a: uint64, b: uint64): uint64 | ||
callNonClassFunction: | ||
proto 2 1 | ||
|
||
// tests/contracts/functions.algo.ts:10 | ||
// return nonClassFunction(a, b); | ||
frame_dig -2 // b: uint64 | ||
frame_dig -1 // a: uint64 | ||
callsub nonClassFunction | ||
retsub | ||
|
||
// callExternalFunction(uint64,uint64)uint64 | ||
*abi_route_callExternalFunction: | ||
// The ABI return prefix | ||
byte 0x151f7c75 | ||
|
||
// b: uint64 | ||
txna ApplicationArgs 2 | ||
btoi | ||
|
||
// a: uint64 | ||
txna ApplicationArgs 1 | ||
btoi | ||
|
||
// execute callExternalFunction(uint64,uint64)uint64 | ||
callsub callExternalFunction | ||
itob | ||
concat | ||
log | ||
int 1 | ||
return | ||
|
||
// callExternalFunction(a: uint64, b: uint64): uint64 | ||
callExternalFunction: | ||
proto 2 1 | ||
|
||
// tests/contracts/functions.algo.ts:14 | ||
// return externalFunction(a, b); | ||
frame_dig -2 // b: uint64 | ||
frame_dig -1 // a: uint64 | ||
callsub externalFunction | ||
retsub | ||
|
||
*abi_route_createApplication: | ||
int 1 | ||
return | ||
|
||
*create_NoOp: | ||
method "createApplication()void" | ||
txna ApplicationArgs 0 | ||
match *abi_route_createApplication | ||
|
||
// this contract does not implement the given ABI method for create NoOp | ||
err | ||
|
||
*call_NoOp: | ||
method "callNonClassFunction(uint64,uint64)uint64" | ||
method "callExternalFunction(uint64,uint64)uint64" | ||
txna ApplicationArgs 0 | ||
match *abi_route_callNonClassFunction *abi_route_callExternalFunction | ||
|
||
// this contract does not implement the given ABI method for call NoOp | ||
err | ||
|
||
// externalFunction(a: uint64, b: uint64): uint64 | ||
externalFunction: | ||
proto 2 1 | ||
|
||
// tests/contracts/functions-external.algo.ts:2 | ||
// return a + b; | ||
frame_dig -1 // a: uint64 | ||
frame_dig -2 // b: uint64 | ||
+ | ||
retsub | ||
|
||
// nonClassFunction(a: uint64, b: uint64): uint64 | ||
nonClassFunction: | ||
proto 2 1 | ||
|
||
// tests/contracts/functions.algo.ts:5 | ||
// return a + b; | ||
frame_dig -1 // a: uint64 | ||
frame_dig -2 // b: uint64 | ||
+ | ||
retsub |
Oops, something went wrong.