Search Apps Documentation Source Content File Folder Download Copy Actions Download

meta.gno

1.75 Kb · 61 lines
 1package gnogle_nft2
 2
 3import (
 4	"chain"
 5	"strconv"
 6
 7	"gno.land/p/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/grc721"
 8)
 9
10// Burn permanently destroys a token the caller owns.
11func Burn(cur realm, collID, tokenID string) {
12	assertUserCall(cur)
13	coll := mustGetCollection(collID)
14	caller := cur.Previous().Address()
15	tid := grc721.TokenID(tokenID)
16	owner, err := coll.nft.OwnerOf(tid)
17	if err != nil {
18		panic(err)
19	}
20	if owner != caller {
21		panic("only the token owner can burn it")
22	}
23	if err := coll.nft.Burn(tid); err != nil {
24		panic(err)
25	}
26	coll.burned++
27	chain.Emit("Burn", "collection", collID, "tokenId", tokenID, "by", caller.String())
28}
29
30// SealCollection caps supply at the current minted count (burns the unminted
31// remainder). Creator-only, irreversible.
32func SealCollection(cur realm, collID string) {
33	assertUserCall(cur)
34	coll := mustGetCollection(collID)
35	if cur.Previous().Address() != coll.creator {
36		panic("only the collection creator can seal it")
37	}
38	coll.maxSupply = coll.minted
39	coll.sealed = true
40	chain.Emit("CollectionSealed", "collection", collID, "supply", strconv.FormatInt(coll.minted, 10))
41}
42
43// SetBaseURI updates a collection's metadata base URI (e.g. after pinning to
44// IPFS). Creator-only.
45func SetBaseURI(cur realm, collID, uri string) {
46	assertUserCall(cur)
47	coll := mustGetCollection(collID)
48	if cur.Previous().Address() != coll.creator {
49		panic("only the collection creator can set the base URI")
50	}
51	coll.baseURI = uri
52	chain.Emit("SetBaseURI", "collection", collID)
53}
54
55// SetVerified toggles a collection's verified badge. Admin-only.
56func SetVerified(cur realm, collID string, v bool) {
57	assertAdmin(cur)
58	coll := mustGetCollection(collID)
59	coll.verified = v
60	chain.Emit("SetVerified", "collection", collID, "verified", strconv.FormatBool(v))
61}