Skip to content

Commit

Permalink
Use asset/app IDs when accessing ABI reference args (#701)
Browse files Browse the repository at this point in the history
* Use creatable indexes when accessing ABI args

* changelog
  • Loading branch information
jasonpaulos authored Apr 18, 2023
1 parent 34b5fe4 commit ca97ccb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

## Changed

* Stop using slot indexes for assets and apps when accessing properties of ABI reference type arguments. ([#701](https://github.com/algorand/pyteal/pull/701))

# v0.24.0

## Added
Expand Down
8 changes: 4 additions & 4 deletions pyteal/ast/abi/reference_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def asset_holding(self, asset: "Expr | Asset") -> AssetHoldingObject:
must evaluate to uint64).
"""
if isinstance(asset, Asset):
asset_ref = asset.referenced_index()
asset_ref = asset.asset_id()
else:
asset_ref = asset
return AssetHoldingObject(asset_ref, self.referenced_index())
Expand Down Expand Up @@ -172,11 +172,11 @@ def holding(self, account: Expr | Account) -> AssetHoldingObject:
account_ref = account.referenced_index()
else:
account_ref = account
return AssetHoldingObject(self.referenced_index(), account_ref)
return AssetHoldingObject(self.asset_id(), account_ref)

def params(self) -> AssetParamObject:
"""Get information about the asset's parameters."""
return AssetParamObject(self.referenced_index())
return AssetParamObject(self.asset_id())


Asset.__module__ = "pyteal.abi"
Expand Down Expand Up @@ -209,7 +209,7 @@ def application_id(self) -> Expr:

def params(self) -> AppParamObject:
"""Get information about the application's parameters."""
return AppParamObject(self.referenced_index())
return AppParamObject(self.application_id())


Application.__module__ = "pyteal.abi"
Expand Down
8 changes: 4 additions & 4 deletions pyteal/ast/abi/reference_type_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_Account_params():
def test_Account_asset_holding():
value = abi.Account()

assets = ((pt.Int(6), pt.Int(6)), (a := abi.Asset(), a.referenced_index()))
assets = ((pt.Int(6), pt.Int(6)), (a := abi.Asset(), a.asset_id()))

for asset, expected_asset in assets:
holding = value.asset_holding(asset)
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_Asset_holding():

assert type(holding) is pt.AssetHoldingObject

expected_asset = value.referenced_index()
expected_asset = value.asset_id()
actual_asset = holding._asset

actual_account = holding._account
Expand All @@ -253,7 +253,7 @@ def test_Asset_params():

assert type(params) is pt.AssetParamObject

expected = value.referenced_index()
expected = value.asset_id()
actual = params._asset

with pt.TealComponent.Context.ignoreExprEquality():
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_Application_params():

assert type(params) is pt.AppParamObject

expected = value.referenced_index()
expected = value.application_id()
actual = params._app

with pt.TealComponent.Context.ignoreExprEquality():
Expand Down

0 comments on commit ca97ccb

Please sign in to comment.