Skip to content

Commit

Permalink
feat: add external owned/minted/byId functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer committed Feb 13, 2024
1 parent 56dcfaf commit 8b09a2e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions contracts/GovNftSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def all(_account: address) -> DynArray[GovNft, MAX_RESULTS]:

return govnfts

@external
@view
def owned(_account: address) -> DynArray[GovNft, MAX_RESULTS]:
"""
@notice Returns all owned GovNFTs for the given account
@return Array of GovNft structs
"""
return self._owned(_account)

@internal
@view
def _owned(_account: address) -> DynArray[GovNft, MAX_RESULTS]:
Expand All @@ -104,6 +113,15 @@ def _owned(_account: address) -> DynArray[GovNft, MAX_RESULTS]:

return govnfts

@external
@view
def minted(_account: address) -> DynArray[GovNft, MAX_RESULTS]:
"""
@notice Returns all minted GovNFTs for the given account
@return Array of GovNft structs
"""
return self._minted(_account)

@internal
@view
def _minted(_account: address) -> DynArray[GovNft, MAX_RESULTS]:
Expand All @@ -126,6 +144,16 @@ def _minted(_account: address) -> DynArray[GovNft, MAX_RESULTS]:

return govnfts

@external
@view
def byId(_govnft_id: uint256) -> GovNft:
"""
@notice Returns GovNFT data based on ID
@param _govnft_id The GovNFT ID to look up
@return GovNft struct
"""
return self._byId(_govnft_id)

@internal
@view
def _byId(_govnft_id: uint256) -> GovNft:
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ The returned data/struct of type `GovNft` values represent:
The available methods are:

* `all(_account: address) -> GovNft[]` - returns a list of all `GovNft` structs owned or minted by the given account.
* `owned(_account: address) -> GovNft[]` - returns a list of all `GovNft` structs owned by the given account.
* `minted(_account: address) -> GovNft[]` - returns a list of all `GovNft` structs minted by the given account.
* `byId(_govnft_id: uint256) -> GovNft` - returns the `GovNft` based on the given ID.

## Development

Expand Down

0 comments on commit 8b09a2e

Please sign in to comment.