Skip to content

Commit

Permalink
chore: use std.PrevRealm() in grc721 package (gnolang#992)
Browse files Browse the repository at this point in the history
update (missing part of) grc721 package implementation to use
`std.PrevRealm()` not `std.GetOrigCaller()`

## related
gnolang#667 implementation of `std.PrevRealm()`
gnolang#895 update grc20, 721 to use `std.PrevRealm()`

<details><summary>Checklists...</summary>

## Contributors Checklist

- [x] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](../.benchmarks/README.md).
</details>

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
2 people authored and gfanton committed Nov 9, 2023
1 parent e3a54fe commit 0265558
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/gno.land/p/demo/grc/grc721/basic_nft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *basicNFT) Approve(to std.Address, tid TokenID) error {
return ErrApprovalToCurrentOwner
}

caller := std.GetOrigCaller()
caller := std.PrevRealm().Addr()
if caller != owner && !s.IsApprovedForAll(owner, caller) {
return ErrCallerIsNotOwnerOrApproved
}
Expand Down Expand Up @@ -123,15 +123,15 @@ func (s *basicNFT) SetApprovalForAll(operator std.Address, approved bool) error
return ErrInvalidAddress
}

caller := std.GetOrigCaller()
caller := std.PrevRealm().Addr()
return s.setApprovalForAll(caller, operator, approved)
}

// Safely transfers `tokenId` token from `from` to `to`, checking that
// contract recipients are aware of the GRC721 protocol to prevent
// tokens from being forever locked.
func (s *basicNFT) SafeTransferFrom(from, to std.Address, tid TokenID) error {
caller := std.GetOrigCaller()
caller := std.PrevRealm().Addr()
if !s.isApprovedOrOwner(caller, tid) {
return ErrCallerIsNotOwnerOrApproved
}
Expand All @@ -150,7 +150,7 @@ func (s *basicNFT) SafeTransferFrom(from, to std.Address, tid TokenID) error {

// Transfers `tokenId` token from `from` to `to`.
func (s *basicNFT) TransferFrom(from, to std.Address, tid TokenID) error {
caller := std.GetOrigCaller()
caller := std.PrevRealm().Addr()
if !s.isApprovedOrOwner(caller, tid) {
return ErrCallerIsNotOwnerOrApproved
}
Expand Down

0 comments on commit 0265558

Please sign in to comment.