grc721 source pure
1
1
var ErrInvalidTokenId, ErrInvalidAddress, ErrTokenIdNotHasApproved, ErrApprovalToCurrentOwner, ErrCallerIsNotOwner, ErrCallerNotApprovedForAll, ErrCannotTransferToSelf, ErrTransferFromIncorrectOwner, ErrTransferToNonGRC721Receiver, ErrCallerIsNotOwnerOrApproved, ErrTokenIdAlreadyExists, ErrInvalidRoyaltyPercentage, ErrInvalidRoyaltyPaymentAddress, ErrCannotCalculateRoyaltyAmount
1var (
2 ErrInvalidTokenId = errors.New("invalid token id")
3 ErrInvalidAddress = errors.New("invalid address")
4 ErrTokenIdNotHasApproved = errors.New("token id not approved for anyone")
5 ErrApprovalToCurrentOwner = errors.New("approval to current owner")
6 ErrCallerIsNotOwner = errors.New("caller is not token owner")
7 ErrCallerNotApprovedForAll = errors.New("caller is not approved for all")
8 ErrCannotTransferToSelf = errors.New("cannot send transfer to self")
9 ErrTransferFromIncorrectOwner = errors.New("transfer from incorrect owner")
10 ErrTransferToNonGRC721Receiver = errors.New("transfer to non GRC721Receiver implementer")
11 ErrCallerIsNotOwnerOrApproved = errors.New("caller is not token owner or approved")
12 ErrTokenIdAlreadyExists = errors.New("token id already exists")
13
14 // ERC721Royalty
15 ErrInvalidRoyaltyPercentage = errors.New("invalid royalty percentage")
16 ErrInvalidRoyaltyPaymentAddress = errors.New("invalid royalty paymentAddress")
17 ErrCannotCalculateRoyaltyAmount = errors.New("cannot calculate royalty amount")
18)1
func NewBasicNFT
Returns new basic NFT
4
type IGRC721Reader
interfaceIGRC721Reader is the read-only view of an NFT. Safe to receive across realm boundaries — has no rlm-typed methods, so a malicious impl can only lie about read results (data-integrity issue), not capture cur.
Writes are concrete methods on *basicNFT only — there is no IGRC721 writer interface. The owning realm should hold the concrete *basicNFT in an unexported package var and expose public rlm-validating wrappers like:
Example
1func TransferFrom(cur realm, from, to address, tid TokenID) error {
2 caller := cur.Previous().Address()
3 return nft.TransferFrom(caller, from, to, tid)
4}
This is the Reader/Writer split — stronger than the Authority-pattern because the writer interface doesn't exist at all, so no realm author can accidentally expose it. See `r/demo/foo721` for the canonical wrapper pattern.
type NFTGetter
funcNFTGetter returns a reader-only view of an NFT. Aggregators (such as tokenhub) register and dispatch NFTGetters; the reader-only return type means even a malicious aggregator can't be used to leak cur.
type TokenID
identtype TokenURI
ident6
- chain stdlib
- errors stdlib
- gno.land/p/nt/avl/v0 package
- gno.land/p/nt/ufmt/v0 package
- math/overflow stdlib
- strconv stdlib