Skip to content

Commit

Permalink
docs: Add example of struct in a box (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel authored Jun 10, 2024
1 parent 23f9bd2 commit b0530c1
Show file tree
Hide file tree
Showing 20 changed files with 2,510 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/sizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
state_totals 38 27 11 27 0
stress_tests/BruteForceRotationSearch 238 175 63 175 0
string_ops 157 152 5 152 0
struct_in_box/Example 217 195 22 195 0
stubs/BigUInt 193 112 81 112 0
stubs/Bytes 924 256 668 256 0
stubs/String 624 141 483 141 0
Expand Down
44 changes: 44 additions & 0 deletions examples/struct_in_box/contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from algopy import ARC4Contract, Asset, arc4, op, subroutine


class UserStruct(arc4.Struct):
name: arc4.String
id: arc4.UInt64
asset: arc4.UInt64


class ExampleContract(ARC4Contract):

@subroutine
def read_from_box(self, user_id: arc4.UInt64) -> UserStruct:
box_data, exists = op.Box.get(user_id.bytes)
assert exists, "User with that id does not exist"
return UserStruct.from_bytes(box_data)

@subroutine
def write_to_box(self, user: UserStruct) -> None:
box_key = user.id.bytes
# Delete existing data, so we don't have to worry about resizing the box
op.Box.delete(box_key)

op.Box.put(box_key, user.bytes)

@subroutine
def box_exists(self, user_id: arc4.UInt64) -> bool:
_data, exists = op.Box.get(user_id.bytes)
return exists

@arc4.abimethod()
def add_user(self, user: UserStruct) -> None:
assert not self.box_exists(user.id), "User with id must not exist"
self.write_to_box(user)

@arc4.abimethod()
def attach_asset_to_user(self, user_id: arc4.UInt64, asset: Asset) -> None:
user = self.read_from_box(user_id)
user.asset = arc4.UInt64(asset.id)
self.write_to_box(user)

@arc4.abimethod()
def get_user(self, user_id: arc4.UInt64) -> UserStruct:
return self.read_from_box(user_id)
214 changes: 214 additions & 0 deletions examples/struct_in_box/out/ExampleContract.approval.mir

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions examples/struct_in_box/out/ExampleContract.approval.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
#pragma version 10

examples.struct_in_box.contract.ExampleContract.approval_program:
// struct_in_box/contract.py:10
// class ExampleContract(ARC4Contract):
txn NumAppArgs
bz main_bare_routing@7
method "add_user((string,uint64,uint64))void"
method "attach_asset_to_user(uint64,asset)void"
method "get_user(uint64)(string,uint64,uint64)"
txna ApplicationArgs 0
match main_add_user_route@2 main_attach_asset_to_user_route@3 main_get_user_route@4
err // reject transaction

main_add_user_route@2:
// struct_in_box/contract.py:31
// @arc4.abimethod()
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// struct_in_box/contract.py:10
// class ExampleContract(ARC4Contract):
txna ApplicationArgs 1
// struct_in_box/contract.py:31
// @arc4.abimethod()
callsub add_user
int 1
return

main_attach_asset_to_user_route@3:
// struct_in_box/contract.py:36
// @arc4.abimethod()
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// struct_in_box/contract.py:10
// class ExampleContract(ARC4Contract):
txna ApplicationArgs 1
txna ApplicationArgs 2
btoi
txnas Assets
// struct_in_box/contract.py:36
// @arc4.abimethod()
callsub attach_asset_to_user
int 1
return

main_get_user_route@4:
// struct_in_box/contract.py:42
// @arc4.abimethod()
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// struct_in_box/contract.py:10
// class ExampleContract(ARC4Contract):
txna ApplicationArgs 1
// struct_in_box/contract.py:42
// @arc4.abimethod()
callsub get_user
byte 0x151f7c75
swap
concat
log
int 1
return

main_bare_routing@7:
// struct_in_box/contract.py:10
// class ExampleContract(ARC4Contract):
txn OnCompletion
!
assert // reject transaction
txn ApplicationID
!
assert // is creating
int 1
return


// examples.struct_in_box.contract.ExampleContract.add_user(user: bytes) -> void:
add_user:
// struct_in_box/contract.py:31-32
// @arc4.abimethod()
// def add_user(self, user: UserStruct) -> None:
proto 1 0
// struct_in_box/contract.py:33
// assert not self.box_exists(user.id), "User with id must not exist"
frame_dig -1
extract 2 8 // on error: Index access is out of bounds
callsub box_exists
!
assert // User with id must not exist
// struct_in_box/contract.py:34
// self.write_to_box(user)
frame_dig -1
callsub write_to_box
frame_bury -1
retsub


// examples.struct_in_box.contract.ExampleContract.box_exists(user_id: bytes) -> uint64:
box_exists:
// struct_in_box/contract.py:26-27
// @subroutine
// def box_exists(self, user_id: arc4.UInt64) -> bool:
proto 1 1
// struct_in_box/contract.py:28
// _data, exists = op.Box.get(user_id.bytes)
frame_dig -1
box_get
bury 1
// struct_in_box/contract.py:29
// return exists
retsub


// examples.struct_in_box.contract.ExampleContract.write_to_box(user: bytes) -> bytes:
write_to_box:
// struct_in_box/contract.py:18-19
// @subroutine
// def write_to_box(self, user: UserStruct) -> None:
proto 1 1
// struct_in_box/contract.py:20
// box_key = user.id.bytes
frame_dig -1
extract 2 8 // on error: Index access is out of bounds
// struct_in_box/contract.py:21-22
// # Delete existing data, so we don't have to worry about resizing the box
// op.Box.delete(box_key)
dup
box_del
pop
// struct_in_box/contract.py:24
// op.Box.put(box_key, user.bytes)
frame_dig -1
box_put
frame_dig -1
retsub


// examples.struct_in_box.contract.ExampleContract.attach_asset_to_user(user_id: bytes, asset: uint64) -> void:
attach_asset_to_user:
// struct_in_box/contract.py:36-37
// @arc4.abimethod()
// def attach_asset_to_user(self, user_id: arc4.UInt64, asset: Asset) -> None:
proto 2 0
// struct_in_box/contract.py:38
// user = self.read_from_box(user_id)
frame_dig -2
callsub read_from_box
// struct_in_box/contract.py:39
// user.asset = arc4.UInt64(asset.id)
frame_dig -1
itob
replace2 10
// struct_in_box/contract.py:40
// self.write_to_box(user)
callsub write_to_box
pop
retsub


// examples.struct_in_box.contract.ExampleContract.read_from_box(user_id: bytes) -> bytes:
read_from_box:
// struct_in_box/contract.py:12-13
// @subroutine
// def read_from_box(self, user_id: arc4.UInt64) -> UserStruct:
proto 1 1
// struct_in_box/contract.py:14
// box_data, exists = op.Box.get(user_id.bytes)
frame_dig -1
box_get
// struct_in_box/contract.py:15
// assert exists, "User with that id does not exist"
assert // User with that id does not exist
// struct_in_box/contract.py:16
// return UserStruct.from_bytes(box_data)
retsub


// examples.struct_in_box.contract.ExampleContract.get_user(user_id: bytes) -> bytes:
get_user:
// struct_in_box/contract.py:42-43
// @arc4.abimethod()
// def get_user(self, user_id: arc4.UInt64) -> UserStruct:
proto 1 1
// struct_in_box/contract.py:44
// return self.read_from_box(user_id)
frame_dig -1
callsub read_from_box
retsub
130 changes: 130 additions & 0 deletions examples/struct_in_box/out/ExampleContract.arc32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"hints": {
"add_user((string,uint64,uint64))void": {
"call_config": {
"no_op": "CALL"
},
"structs": {
"user": {
"name": "UserStruct",
"elements": [
[
"name",
"string"
],
[
"id",
"uint64"
],
[
"asset",
"uint64"
]
]
}
}
},
"attach_asset_to_user(uint64,asset)void": {
"call_config": {
"no_op": "CALL"
}
},
"get_user(uint64)(string,uint64,uint64)": {
"call_config": {
"no_op": "CALL"
},
"structs": {
"output": {
"name": "UserStruct",
"elements": [
[
"name",
"string"
],
[
"id",
"uint64"
],
[
"asset",
"uint64"
]
]
}
}
}
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpleGFtcGxlcy5zdHJ1Y3RfaW5fYm94LmNvbnRyYWN0LkV4YW1wbGVDb250cmFjdC5hcHByb3ZhbF9wcm9ncmFtOgogICAgLy8gc3RydWN0X2luX2JveC9jb250cmFjdC5weToxMAogICAgLy8gY2xhc3MgRXhhbXBsZUNvbnRyYWN0KEFSQzRDb250cmFjdCk6CiAgICB0eG4gTnVtQXBwQXJncwogICAgYnogbWFpbl9iYXJlX3JvdXRpbmdANwogICAgbWV0aG9kICJhZGRfdXNlcigoc3RyaW5nLHVpbnQ2NCx1aW50NjQpKXZvaWQiCiAgICBtZXRob2QgImF0dGFjaF9hc3NldF90b191c2VyKHVpbnQ2NCxhc3NldCl2b2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JfaWQ6IGFyYzQuVUludDY0KSAtPiBVc2VyU3RydWN0OgogICAgcHJvdG8gMSAxCiAgICAvLyBzdHJ1Y3RfaW5fYm94L2NvbnRyYWN0LnB5OjQ0CiAgICAvLyByZXR1cm4gc2VsZi5yZWFkX2Zyb21fYm94KHVzZXJfaWQpCiAgICBmcmFtZV9kaWcgLTEKICAgIGNhbGxzdWIgcmVhZF9mcm9tX2JveAogICAgcmV0c3ViCg==",
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpleGFtcGxlcy5zdHJ1Y3RfaW5fYm94LmNvbnRyYWN0LkV4YW1wbGVDb250cmFjdC5jbGVhcl9zdGF0ZV9wcm9ncmFtOgogICAgLy8gc3RydWN0X2luX2JveC9jb250cmFjdC5weToxMAogICAgLy8gY2xhc3MgRXhhbXBsZUNvbnRyYWN0KEFSQzRDb250cmFjdCk6CiAgICBpbnQgMQogICAgcmV0dXJuCg=="
},
"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": "ExampleContract",
"methods": [
{
"name": "add_user",
"args": [
{
"type": "(string,uint64,uint64)",
"name": "user"
}
],
"returns": {
"type": "void"
}
},
{
"name": "attach_asset_to_user",
"args": [
{
"type": "uint64",
"name": "user_id"
},
{
"type": "asset",
"name": "asset"
}
],
"returns": {
"type": "void"
}
},
{
"name": "get_user",
"args": [
{
"type": "uint64",
"name": "user_id"
}
],
"returns": {
"type": "(string,uint64,uint64)"
}
}
],
"networks": {}
},
"bare_call_config": {
"no_op": "CREATE"
}
}
9 changes: 9 additions & 0 deletions examples/struct_in_box/out/ExampleContract.clear.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Op // Stack (out) Source code Source line

#pragma version 10

// examples.struct_in_box.contract.ExampleContract.clear_state_program() -> uint64:
main_block@0:
int 1 // 1 class ExampleContract(ARC4Contract): struct_in_box/contract.py:10
return // class ExampleContract(ARC4Contract): struct_in_box/contract.py:10

Loading

0 comments on commit b0530c1

Please sign in to comment.