config.gno
2.11 Kb · 73 lines
1package memba_collections
2
3import (
4 "chain"
5)
6
7// phase constants
8const (
9 PhaseDraft = 0
10 PhaseAllowlist = 1
11 PhasePublic = 2
12 PhaseClosed = 3
13)
14
15// SetMintPhase sets the sale phase and (for the allowlist phase) the Merkle
16// root. Admin only. Emits MintPhaseSet with the root for off-chain indexers.
17func SetMintPhase(cur realm, id string, phase int, allowlistRoot string) {
18 c := mustGet(id)
19 assertCollectionAdmin(c)
20 if phase < PhaseDraft || phase > PhaseClosed {
21 panic("invalid phase")
22 }
23 c.phase = phase
24 c.allowlistRoot = allowlistRoot
25 chain.Emit("MintPhaseSet",
26 "collectionID", id,
27 "phase", itoa(int64(phase)),
28 "allowlistRoot", allowlistRoot,
29 "block", itoa(chainHeight()),
30 )
31}
32
33// SetMintConfig sets the full mint configuration. Admin only. payDenom must be
34// native ("" / "ugnot") or a currently-allowed denom. mintPrice (when > 0)
35// must be in [MinMintPrice, MaxPriceUgnot]. maxSupply cannot be set below the
36// number already minted. Emits MintConfigChanged carrying every cap (E-2).
37func SetMintConfig(cur realm, id string, mintPrice int64, payDenom string, maxSupply, maxPerWallet, mintStartBlock, mintCooldownBlocks int64) {
38 c := mustGet(id)
39 assertCollectionAdmin(c)
40
41 if !isNativeDenom(payDenom) {
42 if _, ok := allowedDenoms.Get(payDenom); !ok {
43 panic("denom not allowed: " + payDenom)
44 }
45 }
46 if mintPrice != 0 && (mintPrice < MinMintPrice || mintPrice > MaxPriceUgnot) {
47 panic("mint price out of range")
48 }
49 if maxSupply != 0 && maxSupply < c.nextAutoTokenID {
50 panic("maxSupply below minted count")
51 }
52 if maxPerWallet < 0 || mintStartBlock < 0 || mintCooldownBlocks < 0 {
53 panic("negative config value")
54 }
55
56 c.mintPrice = mintPrice
57 c.payDenom = payDenom
58 c.maxSupply = maxSupply
59 c.maxPerWallet = maxPerWallet
60 c.mintStartBlock = mintStartBlock
61 c.mintCooldownBlocks = mintCooldownBlocks
62
63 chain.Emit("MintConfigChanged",
64 "collectionID", id,
65 "mintPrice", itoa(mintPrice),
66 "payDenom", payDenom,
67 "maxSupply", itoa(maxSupply),
68 "maxPerWallet", itoa(maxPerWallet),
69 "mintStartBlock", itoa(mintStartBlock),
70 "mintCooldownBlocks", itoa(mintCooldownBlocks),
71 "block", itoa(chainHeight()),
72 )
73}