Search Apps Documentation Source Content File Folder Download Copy Actions Download

test_basic_nft.gno

1.18 Kb ยท 66 lines
 1package mynft6
 2
 3import (
 4	"strconv"
 5	"chain/runtime"
 6
 7	"gno.land/p/demo/tokens/grc721"
 8	"gno.land/r/pierre115/nftregistry5"
 9)
10
11type NFTCollection interface {
12	grc721.IGRC721
13	Mint(to address, tid grc721.TokenID) error
14	Getter() grc721.NFTGetter
15}
16
17var (
18	nft         NFTCollection
19	nextTokenId = 1
20)
21
22func init() {
23	nft = grc721.NewBasicNFT("Test NFT Collection 6", "TEST6")
24}
25
26// Register registers this collection on the NFT registry
27func Register(_ realm) {
28	nftregistry5.RegisterCollection(
29		"Test NFT Collection 6",
30		"TEST6",
31		"art",
32		"My awesome NFT collection",
33		"https://example.com",
34		false,
35		nft.Getter(),
36	)
37}
38
39func MintNFT(_ realm) int {
40	caller := runtime.PreviousRealm().Address()
41	tokenId := grc721.TokenID(strconv.Itoa(nextTokenId))
42
43	err := nft.Mint(caller, tokenId)
44	if err != nil {
45		panic(err.Error())
46	}
47
48	nextTokenId++
49	return nextTokenId - 1
50}
51
52func SetApprovalForAll(_ realm, operator address, approved bool) {
53	err := nft.SetApprovalForAll(operator, approved)
54	if err != nil {
55		panic(err.Error())
56	}
57}
58
59func Getter() grc721.NFTGetter {
60	return nft.Getter()
61}
62
63func Render(path string) string {
64	output := "# My test collection\n\n"
65	output += "## test 6\n\n"
66	return output
67}