Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
fergalwalsh committed Feb 29, 2024
1 parent 001b9c2 commit 860ede5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 43 deletions.
80 changes: 38 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,62 +73,58 @@ A VS Code extension for syntax highlighting of Tealish & TEAL is available [here
## Starter Template

```python
#pragma version 7
#pragma version 8

if Txn.ApplicationID == 0:
# Create app
# Handle Create App
exit(1)
end

switch Txn.OnCompletion:
NoOp: main
OptIn: opt_in
CloseOut: close_out
UpdateApplication: update_app
DeleteApplication: delete_app
router:
method_a
method_b
method_c
update_app
delete_app
end

block opt_in:
# Disallow Opt In
exit(0)
@public(OnCompletion=UpdateApplication)
func update_app():
# Handle Update App
# Example: Only allow the Creator to update the app (useful during development)
assert(Txn.Sender == Global.CreatorAddress)
# OR Disallow Update App by removing this function
return
end

block close_out:
# Disallow Closing Out
exit(0)
@public(OnCompletion=DeleteApplication)
func delete_app():
# Handle Delete App
# Example: Only allow the Creator to update the app (useful during development)
assert(Txn.Sender == Global.CreatorAddress)
# OR Disallow Delete App by removing this function
return
end

block update_app:
# Only allow the Creator to update the app
exit(Txn.Sender == Global.CreatorAddress)
@public()
func method_a(user_address: bytes[32], amount: int):
# Handle method_a
# some statements here
return
end

block delete_app:
# Only allow the Creator to delete the app
exit(Txn.Sender == Global.CreatorAddress)
@public()
func method_b():
# Handle method_b
# some statements here
return
end

block main:
switch Txn.ApplicationArgs[0]:
"method_a": method_a
"method_b": method_b
"method_c": method_c
end

block method_a:
# some statements here
exit(1)
end

block method_b:
# some statements here
exit(1)
end

block method_c:
# some statements here
exit(1)
end
@public()
func method_c():
# Handle method_c
# some statements here
return
end
```

Expand All @@ -141,7 +137,7 @@ Readability is achieved by the following:
- Semantic names for scratch slots (variables)
- Aliases for values on stack
- Named constants
- High level language concepts (if/elif/else, loops, switches)
- High level language concepts (if/elif/else, loops, switches, structs, functions, function router)
- A simple style convention

Safety Features:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages = ["tealish"]

[project]
name = "tealish"
version = "0.0.2"
version = "0.0.3"
authors = [
{ name="Tinyman", email="[email protected]" },
]
Expand Down

0 comments on commit 860ede5

Please sign in to comment.