-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for emitting ARC-28 events
- Loading branch information
1 parent
7d3d534
commit aa4a651
Showing
30 changed files
with
1,441 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from puyapy import ARC4Contract, arc4 | ||
|
||
|
||
class Swapped(arc4.Struct): | ||
a: arc4.UInt64 | ||
b: arc4.UInt64 | ||
|
||
|
||
class EventEmitter(ARC4Contract): | ||
@arc4.abimethod | ||
def emit_swapped(self, a: arc4.UInt64, b: arc4.UInt64) -> None: | ||
arc4.emit(Swapped(b, a)) | ||
arc4.emit("Swapped(uint64,uint64)", b, a) | ||
arc4.emit("Swapped", b, a) |
Large diffs are not rendered by default.
Oops, something went wrong.
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,67 @@ | ||
#pragma version 10 | ||
|
||
contract.EventEmitter.approval_program: | ||
// arc-28/contract.py:9 | ||
// class EventEmitter(ARC4Contract): | ||
txn NumAppArgs | ||
bz main_bare_routing@5 | ||
method "emit_swapped(uint64,uint64)void" | ||
txna ApplicationArgs 0 | ||
match main_emit_swapped_route@2 | ||
err // reject transaction | ||
|
||
main_emit_swapped_route@2: | ||
// arc-28/contract.py:10 | ||
// @arc4.abimethod | ||
txn OnCompletion | ||
! | ||
assert // OnCompletion is NoOp | ||
txn ApplicationID | ||
assert // is not creating | ||
// arc-28/contract.py:9 | ||
// class EventEmitter(ARC4Contract): | ||
txna ApplicationArgs 1 | ||
txna ApplicationArgs 2 | ||
// arc-28/contract.py:10 | ||
// @arc4.abimethod | ||
callsub emit_swapped | ||
int 1 | ||
return | ||
|
||
main_bare_routing@5: | ||
// arc-28/contract.py:9 | ||
// class EventEmitter(ARC4Contract): | ||
txn OnCompletion | ||
! | ||
assert // reject transaction | ||
txn ApplicationID | ||
! | ||
assert // is creating | ||
int 1 | ||
return | ||
|
||
|
||
// contract.EventEmitter.emit_swapped(a: bytes, b: bytes) -> void: | ||
emit_swapped: | ||
// arc-28/contract.py:10-11 | ||
// @arc4.abimethod | ||
// def emit_swapped(self, a: arc4.UInt64, b: arc4.UInt64) -> None: | ||
proto 2 0 | ||
// arc-28/contract.py:12 | ||
// arc4.emit(Swapped(b, a)) | ||
frame_dig -1 | ||
frame_dig -2 | ||
concat | ||
method "Swapped(uint64,uint64)" | ||
swap | ||
concat | ||
dup | ||
log | ||
// arc-28/contract.py:13 | ||
// arc4.emit("Swapped(uint64,uint64)", b, a) | ||
dup | ||
log | ||
// arc-28/contract.py:14 | ||
// arc4.emit("Swapped", b, a) | ||
log | ||
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,58 @@ | ||
{ | ||
"hints": { | ||
"emit_swapped(uint64,uint64)void": { | ||
"call_config": { | ||
"no_op": "CALL" | ||
} | ||
} | ||
}, | ||
"source": { | ||
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpjb250cmFjdC5FdmVudEVtaXR0ZXIuYXBwcm92YWxfcHJvZ3JhbToKICAgIC8vIGFyYy0yOC9jb250cmFjdC5weTo5CiAgICAvLyBjbGFzcyBFdmVudEVtaXR0ZXIoQVJDNENvbnRyYWN0KToKICAgIHR4biBOdW1BcHBBcmdzCiAgICBieiBtYWluX2JhcmVfcm91dGluZ0A1CiAgICBtZXRob2QgImVtaXRfc3dhcHBlZCh1aW50NjQsdWludDY0KXZvaWQiCiAgICB0eG5hIEFwcGxpY2F0aW9uQXJnc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BAYXJjNC5hYmltZXRob2QKICAgIC8vIGRlZiBlbWl0X3N3YXBwZWQoc2VsZiwgYTogYXJjNC5VSW50NjQsIGI6IGFyYzQuVUludDY0KSAtPiBOb25lOgogICAgcHJvdG8gMiAwCiAgICAvLyBhcmMtMjgvY29udHJhY3QucHk6MTIKICAgIC8vIGFyYzQuZW1pdChTd2FwcGVkKGIsIGEpKQogICAgZnJhbWVfZGlnIC0xCiAgICBmcmFtZV9kaWcgLTIKICAgIGNvbmNhdAogICAgbWV0aG9kICJTd2FwcGVkKHVpbnQ2NCx1aW50NjQpIgogICAgc3dhcAogICAgY29uY2F0CiAgICBkdXAKICAgIGxvZwogICAgLy8gYXJjLTI4L2NvbnRyYWN0LnB5OjEzCiAgICAvLyBhcmM0LmVtaXQoIlN3YXBwZWQodWludDY0LHVpbnQ2NCkiLCBiLCBhKQogICAgZHVwCiAgICBsb2cKICAgIC8vIGFyYy0yOC9jb250cmFjdC5weToxNAogICAgLy8gYXJjNC5lbWl0KCJTd2FwcGVkIiwgYiwgYSkKICAgIGxvZwogICAgcmV0c3ViCg==", | ||
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpjb250cmFjdC5FdmVudEVtaXR0ZXIuY2xlYXJfc3RhdGVfcHJvZ3JhbToKICAgIC8vIGFyYy0yOC9jb250cmFjdC5weTo5CiAgICAvLyBjbGFzcyBFdmVudEVtaXR0ZXIoQVJDNENvbnRyYWN0KToKICAgIGludCAxCiAgICByZXR1cm4K" | ||
}, | ||
"state": { | ||
"global": { | ||
"num_byte_slices": 0, | ||
"num_uints": 0 | ||
}, | ||
"local": { | ||
"num_byte_slices": 0, | ||
"num_uints": 0 | ||
} | ||
}, | ||
"schema": { | ||
"global": { | ||
"declared": {}, | ||
"reserved": {} | ||
}, | ||
"local": { | ||
"declared": {}, | ||
"reserved": {} | ||
} | ||
}, | ||
"contract": { | ||
"name": "EventEmitter", | ||
"methods": [ | ||
{ | ||
"name": "emit_swapped", | ||
"args": [ | ||
{ | ||
"type": "uint64", | ||
"name": "a" | ||
}, | ||
{ | ||
"type": "uint64", | ||
"name": "b" | ||
} | ||
], | ||
"returns": { | ||
"type": "void" | ||
} | ||
} | ||
], | ||
"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,9 @@ | ||
// Op // Stack (out) Source code Source line | ||
|
||
#pragma version 10 | ||
|
||
// contract.EventEmitter.clear_state_program() -> uint64: | ||
main_block@0: | ||
int 1 // 1 class EventEmitter(ARC4Contract): arc-28/contract.py:9 | ||
return // class EventEmitter(ARC4Contract): arc-28/contract.py:9 | ||
|
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,7 @@ | ||
#pragma version 10 | ||
|
||
contract.EventEmitter.clear_state_program: | ||
// arc-28/contract.py:9 | ||
// class EventEmitter(ARC4Contract): | ||
int 1 | ||
return |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
# This file is auto-generated, do not modify | ||
# flake8: noqa | ||
# fmt: off | ||
import typing | ||
|
||
import puyapy | ||
|
||
|
||
class EventEmitter(puyapy.arc4.ARC4Client, typing.Protocol): | ||
@puyapy.arc4.abimethod | ||
def emit_swapped( | ||
self, | ||
a: puyapy.arc4.UInt64, | ||
b: puyapy.arc4.UInt64, | ||
) -> None: ... |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.