Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

types.gno

1.26 Kb · 53 lines
 1// Package royalty is a stackable GRC721 extension implementing EIP-2981 in basis
 2// points. Writes are issuer-only so a holder cannot zero out a royalty on a
 3// token they just received.
 4package royalty
 5
 6import (
 7	"errors"
 8
 9	"gno.land/p/nt/avl/v0"
10	"gno.land/p/nt/grc721/v0"
11)
12
13// FeeDenominator is the EIP-2981 basis-point denominator: bps/10000, 10000 == 100%.
14const FeeDenominator = 10000
15
16const RoyaltyUpdateEvent = "RoyaltyUpdate"
17
18var (
19	ErrInvalidReceiver  = errors.New("invalid royalty receiver")
20	ErrInvalidBps       = errors.New("royalty bps out of range")
21	ErrTokenNotMinted   = errors.New("token is not minted")
22	ErrMaxBpsRange      = errors.New("maxBps out of range (0..10000)")
23	ErrInvalidSalePrice = errors.New("invalid sale price (negative or would overflow)")
24)
25
26var zeroAddress = address("")
27
28// RoyaltyInfo is a royalty policy: send Bps/10000 of a sale to Receiver.
29type RoyaltyInfo struct {
30	Receiver address
31	Bps      int64
32}
33
34type storage struct {
35	maxBps     int64
36	hasDefault bool
37	def        RoyaltyInfo
38	perToken   avl.Tree // grc721.TokenID -> RoyaltyInfo
39}
40
41type Royalty struct {
42	core *grc721.Token
43	st   *storage
44}
45
46type Ledger struct {
47	core *grc721.Token
48	st   *storage
49}
50
51var _ grc721.Extension = (*Ledger)(nil)
52
53var _ grc721.ExtensionView = (*Royalty)(nil)