Skip to content

Commit

Permalink
feat: add asset and application reference types to op module (#124)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
op module now uses `Asset` and `Application` types in ops involving those types
Asset.asset_id is now Aseet.id
Application.application_id is now Application.id
  • Loading branch information
daniel-makerx authored Mar 12, 2024
1 parent 9d93fee commit 47741ab
Show file tree
Hide file tree
Showing 61 changed files with 589 additions and 470 deletions.
4 changes: 2 additions & 2 deletions examples/amm/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def bootstrap(
assert seed.receiver == Global.current_application_address, "receiver not app address"

assert seed.amount >= 300_000, "amount minimum not met" # 0.3 Algos
assert a_asset.asset_id < b_asset.asset_id, "asset a must be less than asset b"
assert a_asset.id < b_asset.id, "asset a must be less than asset b"
self.asset_a = a_asset
self.asset_b = b_asset
self.pool_token = self._create_pool_token()

self._do_opt_in(self.asset_a)
self._do_opt_in(self.asset_b)
return arc4.UInt64(self.pool_token.asset_id)
return arc4.UInt64(self.pool_token.id)

@arc4.abimethod(
default_args={
Expand Down
22 changes: 11 additions & 11 deletions examples/amm/out/ConstantProductAMM.approval.mir

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/amm/out/ConstantProductAMM.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bootstrap:
>=
assert // amount minimum not met
// amm/contract.py:74
// assert a_asset.asset_id < b_asset.asset_id, "asset a must be less than asset b"
// assert a_asset.id < b_asset.id, "asset a must be less than asset b"
frame_dig -2
frame_dig -1
<
Expand Down Expand Up @@ -338,7 +338,7 @@ bootstrap:
assert // check asset_b exists
callsub _do_opt_in
// amm/contract.py:81
// return arc4.UInt64(self.pool_token.asset_id)
// return arc4.UInt64(self.pool_token.id)
int 0
byte "pool_token"
app_global_get_ex
Expand Down
2 changes: 1 addition & 1 deletion examples/amm/out/ConstantProductAMM.arc32.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/amm/out_unoptimized/ConstantProductAMM.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ bootstrap:
>=
assert // amount minimum not met
// amm/contract.py:74
// assert a_asset.asset_id < b_asset.asset_id, "asset a must be less than asset b"
// assert a_asset.id < b_asset.id, "asset a must be less than asset b"
frame_dig -2
frame_dig -1
<
Expand Down Expand Up @@ -378,7 +378,7 @@ bootstrap:
assert // check asset_b exists
callsub _do_opt_in
// amm/contract.py:81
// return arc4.UInt64(self.pool_token.asset_id)
// return arc4.UInt64(self.pool_token.id)
int 0
byte "pool_token"
app_global_get_ex
Expand Down
2 changes: 1 addition & 1 deletion examples/auction/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def opt_into_asset(self, asset: Asset) -> None:
# Only allow app creator to opt the app account into a ASA
assert Txn.sender == Global.creator_address, "Only creator can opt in to ASA"
# Verify a ASA hasn't already been opted into
assert self.asa.asset_id == 0, "ASA already opted in"
assert self.asa.id == 0, "ASA already opted in"
# Save ASA ID in global state
self.asa = asset

Expand Down
10 changes: 5 additions & 5 deletions examples/auction/out/Auction.approval.mir
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ opt_into_asset_block@0:
// virtual: store asa_value%3#0 to l-stack (no copy) (𝕡) asset#0 | asa_value%3#0,asa_exists%4#0 y a ASA hasn't already been opted into\nassert self.asa auction/contract.py:29-30
// virtual: load asa_exists%4#0 from l-stack (no copy) (𝕡) asset#0 | asa_value%3#0,asa_exists%4#0 y a ASA hasn't already been opted into\nassert self.asa auction/contract.py:29-30
assert // check asa exists // (𝕡) asset#0 | asa_value%3#0 y a ASA hasn't already been opted into\nassert self.asa auction/contract.py:29-30
// virtual: load asa_value%3#0 from l-stack (no copy) (𝕡) asset#0 | asa_value%3#0 y a ASA hasn't already been opted into\nassert self.asa.asset_id == 0 auction/contract.py:29-30
! // (𝕡) asset#0 | {!} y a ASA hasn't already been opted into\nassert self.asa.asset_id == 0 auction/contract.py:29-30
// virtual: store tmp%5#0 to l-stack (no copy) (𝕡) asset#0 | tmp%5#0 y a ASA hasn't already been opted into\nassert self.asa.asset_id == 0 auction/contract.py:29-30
// virtual: load tmp%5#0 from l-stack (no copy) (𝕡) asset#0 | tmp%5#0 # Verify a ASA hasn't already been opted into\nassert self.asa.asset_id == 0, "ASA already opted in" auction/contract.py:29-30
assert // ASA already opted in // (𝕡) asset#0 | # Verify a ASA hasn't already been opted into\nassert self.asa.asset_id == 0, "ASA already opted in" auction/contract.py:29-30
// virtual: load asa_value%3#0 from l-stack (no copy) (𝕡) asset#0 | asa_value%3#0 y a ASA hasn't already been opted into\nassert self.asa.id == 0 auction/contract.py:29-30
! // (𝕡) asset#0 | {!} y a ASA hasn't already been opted into\nassert self.asa.id == 0 auction/contract.py:29-30
// virtual: store tmp%5#0 to l-stack (no copy) (𝕡) asset#0 | tmp%5#0 y a ASA hasn't already been opted into\nassert self.asa.id == 0 auction/contract.py:29-30
// virtual: load tmp%5#0 from l-stack (no copy) (𝕡) asset#0 | tmp%5#0 # Verify a ASA hasn't already been opted into\nassert self.asa.id == 0, "ASA already opted in" auction/contract.py:29-30
assert // ASA already opted in // (𝕡) asset#0 | # Verify a ASA hasn't already been opted into\nassert self.asa.id == 0, "ASA already opted in" auction/contract.py:29-30
byte "asa" // (𝕡) asset#0 | "asa" # Save ASA ID in global state\nself.asa auction/contract.py:31-32
frame_dig -1 // load asset#0 from parameters (𝕡) asset#0 | "asa",asset#0 # Save ASA ID in global state\nself.asa = asset auction/contract.py:31-32
app_global_put // (𝕡) asset#0 | # Save ASA ID in global state\nself.asa = asset auction/contract.py:31-32
Expand Down
2 changes: 1 addition & 1 deletion examples/auction/out/Auction.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ opt_into_asset:
assert // Only creator can opt in to ASA
// auction/contract.py:29-30
// # Verify a ASA hasn't already been opted into
// assert self.asa.asset_id == 0, "ASA already opted in"
// assert self.asa.id == 0, "ASA already opted in"
int 0
byte "asa"
app_global_get_ex
Expand Down
2 changes: 1 addition & 1 deletion examples/auction/out/Auction.arc32.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/auction/out_unoptimized/Auction.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ opt_into_asset:
assert // Only creator can opt in to ASA
// auction/contract.py:29-30
// # Verify a ASA hasn't already been opted into
// assert self.asa.asset_id == 0, "ASA already opted in"
// assert self.asa.id == 0, "ASA already opted in"
int 0
byte "asa"
app_global_get_ex
Expand Down
2 changes: 1 addition & 1 deletion examples/local_state/out/local_state_contract.awst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/local_state/out/local_state_with_offsets.awst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/sizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ arc4_types/Arc4StructsType 296 237 237
arc4_types/Arc4TuplesType 799 146 146
asset/Reference 259 252 252
auction/Auction 564 523 523
augmented_assignment/Augmented 159 158 158
augmented_assignment/Augmented 157 156 156
avm_types_in_abi/Test 226 173 173
biguint_binary_ops/BiguintBinaryOps 280 216 216
boolean_binary_ops/BooleanBinaryOps 308 302 302
Expand Down
2 changes: 1 addition & 1 deletion examples/voting/out/VotingRoundApp.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ close_after_for@15:
// note=note,
// )
// .submit()
// .created_asset.asset_id
// .created_asset.id
// )
app_global_put
retsub
Expand Down
2 changes: 1 addition & 1 deletion examples/voting/out/VotingRoundApp.arc32.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ close_after_for@15:
// note=note,
// )
// .submit()
// .created_asset.asset_id
// .created_asset.id
// )
swap
app_global_put
Expand Down
2 changes: 1 addition & 1 deletion examples/voting/voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def close(self) -> None:
note=note,
)
.submit()
.created_asset.asset_id
.created_asset.id
)

@arc4.abimethod(readonly=True)
Expand Down
Loading

0 comments on commit 47741ab

Please sign in to comment.