PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/gnoswap/gnft

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
gnft
Namespace
gnoswap
Files
8 (README)(gnomod.toml)
Exported functions
17
Module
gno.land/r/gnoswap/gnft
gno
0.9

Files (8)

  • README.mdmarkdown
  • gnomod.tomltoml
  • assert.gnogno
  • doc.gnogno
  • errors.gnogno
  • gnft.gnogno
  • svg_generator.gnogno
  • utils.gnogno
  • utils.gnogno
    1package gnft23import (4	"errors"5	"math/rand"6	"time"78

    Functions

    • Approve(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, approved string, tid string) interface {Error func() string}

    • BalanceOf(owner string) (int64, interface {Error func() string})

    • Burn(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, tid string)

    • Exists(tid string) bool

    • GetApproved(tid string) (string, interface {Error func() string})

    • IsApprovedForAll(owner string, operator string) bool

    • Mint(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, to string, tid string) string

    • MustOwnerOf(tid string) string

    • Name() string

    • OwnerOf(tid string) (string, interface {Error func() string})

    • Render(path string) string

    • SetApprovalForAll(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, operator string, approved bool) interface {Error func() string}

    • SetTokenURI(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, tid string, tURI string) (bool, interface {Error func() string})

    • Symbol() string

    • TokenURI(tid string) (string, interface {Error func() string})

    • TotalSupply() int64

    • TransferFrom(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, from string, to string, tid string) interface {Error func() string}

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    "gno.land/p/nt/grc721/v0"
    9 "gno.land/p/nt/ufmt/v0"
    10)
    11
    12// generateRandInstance generates a new random instance.
    13func generateRandInstance() *rand.Rand {
    14 now := time.Now()
    15 seed1 := now.Unix() + TotalSupply()
    16 seed2 := now.UnixNano() + TotalSupply()
    17 pcg := rand.NewPCG(uint64(seed1), uint64(seed2))
    18 return rand.New(pcg)
    19}
    20
    21// checkErr panics if an error occurs.
    22func checkErr(err error) {
    23 if err != nil {
    24 panic(err.Error())
    25 }
    26}
    27
    28// checkTransferErr wraps transfer errors with more specific context.
    29func checkTransferErr(err error, caller, from, to address, tid grc721.TokenID) {
    30 if err == nil {
    31 return
    32 }
    33
    34 // Check if token exists
    35 owner, ownerErr := token.OwnerOf(tid)
    36 if ownerErr != nil {
    37 panic(ownerErr)
    38 }
    39
    40 switch err {
    41 case grc721.ErrCallerIsNotOwnerOrApproved:
    42 // Check if caller is the owner
    43 if caller == owner {
    44 panic(makeErrorWithDetails(grc721.ErrTransferFromIncorrectOwner.Error(), ufmt.Sprintf("owner mismatch - from: %s, actual owner: %s, token: %s", from, owner, string(tid))))
    45 }
    46
    47 // Check if caller is approved for this specific token
    48 approved, _ := token.GetApproved(tid)
    49 if approved != caller {
    50 // Check if caller is approved for all tokens
    51 if !token.IsApprovedForAll(owner, caller) {
    52 panic(makeErrorWithDetails(grc721.ErrCallerIsNotOwnerOrApproved.Error(), ufmt.Sprintf("caller %s is not owner %s or approved for token %s", caller, owner, string(tid))))
    53 }
    54 }
    55
    56 case grc721.ErrInvalidAddress:
    57 panic(makeErrorWithDetails(grc721.ErrInvalidAddress.Error(), ufmt.Sprintf("to address (%s)", to)))
    58
    59 case grc721.ErrTransferFromIncorrectOwner:
    60 panic(makeErrorWithDetails(grc721.ErrTransferFromIncorrectOwner.Error(), ufmt.Sprintf("from %s is not the owner %s of token %s", from, owner, string(tid))))
    61
    62 case grc721.ErrInvalidTokenId:
    63 panic(makeErrorWithDetails(grc721.ErrInvalidTokenId.Error(), ufmt.Sprintf("token %s", string(tid))))
    64
    65 default:
    66 panic(err.Error())
    67 }
    68}
    69
    70// checkApproveErr wraps approve errors with more specific context.
    71func checkApproveErr(err error, caller, approved address, tid grc721.TokenID) {
    72 if err == nil {
    73 return
    74 }
    75
    76 switch {
    77 case errors.Is(err, grc721.ErrInvalidTokenId):
    78 panic(makeErrorWithDetails(errTokenNotExists, ufmt.Sprintf("token %s", string(tid))))
    79
    80 case errors.Is(err, grc721.ErrCallerIsNotOwnerOrApproved):
    81 owner, ownerErr := token.OwnerOf(tid)
    82 checkErr(ownerErr)
    83 panic(makeErrorWithDetails(errNotOwnerOrApproved, ufmt.Sprintf("caller %s cannot approve for token %s owned by %s", caller, string(tid), owner)))
    84
    85 case errors.Is(err, grc721.ErrApprovalToCurrentOwner):
    86 panic(makeErrorWithDetails(errTransferToSelf, ufmt.Sprintf("cannot approve to current owner %s for token %s", approved, string(tid))))
    87
    88 default:
    89 panic(err.Error())
    90 }
    91}
    92