PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

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/g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea/guardians

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
guardians
Namespace
g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea
Files
10 (gnomod.toml)
Exported functions
81
Module
gno.land/r/g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea/guardians
gno
0.9

Files (10)

  • gnomod.tomltoml
  • allowlist.gnogno
  • extensions.gnogno
  • guardians.gnogno
  • marketplace.gnogno
  • mint.gnogno
  • reserve.gnogno
  • reveal.gnogno
  • sale.gnogno
  • snapshot.gnogno
  • sale.gnogno
    1package guardians23import (4	"chain"5	"chain/banker"6	"chain/runtime/unsafe"7	"time"8

    Functions

    • Admin() string

    • AdminMint(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, quantity int)

    • AllowlistEnd() int64

    • AllowlistLeaf(owner string, allowance int, unitPrice int64) string

    • AllowlistMinted(owner string) int

    • AllowlistMintedSupply() int64

    • AllowlistPrice() int64

    • AllowlistReservedSupply() int64

    • AllowlistReserveReleased() bool

    • AllowlistReserveRemaining() int64

    • AllowlistRoot() string

    • AllowlistRootLocked() bool

    • AllowlistStart() int64

    • AllowlistUnclaimedSupply() int64

    • AllowlistWalletLimit() int

    • ApplyRevealBatch(startTokenID int64, quantity int)

    • 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}, to string, tokenID string)

    • AuthorizedMarketplace() string

    • BalanceOf(owner string) int64

    • CollectionID() string

    • ComputeRevealCommitment(secret string) string

    • ConfigureReveal(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}, provenance string, commitment string, baseURI string, deadline int64)

    • ConfigureSale(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}, allowlistStart int64, allowlistEnd int64, publicStart int64, publicEnd int64, allowlistPrice int64, publicPrice int64, allowlistLimit int, publicLimit int, treasury string)

    • DefaultRoyalty() (string, int64)

    • EnumerableSupply() int64

    • FinalBaseURI() string

    • FreezeMetadata(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})

    • GetApproved(tokenID string) string

    • IsApprovedForAll(owner string, operator string) bool

    • LaunchVersion() string

    • MarketplaceTransfer(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}, seller string, buyer string, tokenID string, grossPrice int64, nonce int64)

    • MaxSupply() int64

    • MetadataID(tokenID int64) int64

    • 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}, freeQuantity int, paidQuantity int, allowance int, unitPrice int64, proof string)

    • MintAllowlist(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}, quantity int, allowance int, unitPrice int64, proof string)

    • MintPublic(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}, quantity int)

    • Name() string

    • NextSaleTimestamp() int64

    • OwnerOf(tokenID string) string

    • ProvenanceRoot() string

    • PublicEnd() int64

    • PublicMintableSupply() int64

    • PublicMinted(owner string) int

    • PublicPrice() int64

    • PublicStart() int64

    • PublicWalletLimit() int

    • ReleaseAllowlistReserve(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})

    • Render(path string) string

    • Reveal(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}, secret string)

    • RevealCommitment() string

    • RevealDeadline() int64

    • RevealOverdue() bool

    • RevealProcessed() int64

    • RevealSeedHash() string

    • RevealState() string

    • RevealTarget() int64

    • RoyaltyInfo(tokenID string, salePrice int64) (string, int64)

    • RoyaltyMaxBps() int64

    • SaleConfigured() bool

    • SalePaused() bool

    • SalePhase() string

    • SalePhaseAt(unixTime int64) string

    • SaleSnapshot() string

    • SaleTreasury() string

    • SetAllowlistRoot(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}, root 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)

    • SetAuthorizedMarketplace(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}, marketplace string)

    • SetDefaultRoyalty(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}, receiver string, bps int64)

    • SetPublicEnd(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}, end int64)

    • SetSalePaused(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}, paused bool)

    • SetVeiledURI(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}, uri string)

    • Status() string

    • Symbol() string

    • TokenByIndex(index int64) string

    • TokenOfOwnerByIndex(owner string, index int64) string

    • TokenURI(tokenID string) 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, tokenID string)

    • VeiledURI() string

    • VerifyAllowlist(owner string, allowance int, unitPrice int64, proof string) bool

    • WalletSnapshot(owner string) 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.

    9 "gno.land/p/nt/avl/v0"
    10 "gno.land/p/nt/ufmt/v0"
    11)
    12
    13const (
    14 salePhaseClosed = "CLOSED"
    15 salePhaseAllowlist = "ALLOWLIST"
    16 salePhasePublic = "PUBLIC"
    17 salePhaseOpen = "OPEN"
    18 salePhaseSoldOut = "SOLD_OUT"
    19 saleDenom = "ugnot"
    20)
    21
    22type saleConfiguration struct {
    23 allowlistStart int64
    24 allowlistEnd int64
    25 publicStart int64
    26 publicEnd int64
    27 allowlistPrice int64
    28 publicPrice int64
    29 allowlistLimit int
    30 publicLimit int
    31 treasury address
    32}
    33
    34var (
    35 saleConfig saleConfiguration
    36 saleConfigured bool
    37 salePaused = true
    38 allowlistMintedByWallet avl.Tree
    39 publicMintedByWallet avl.Tree
    40)
    41
    42// ConfigureSale stores timestamps as Unix seconds and prices in ugnot.
    43// Configuration is only mutable while the sale is paused. An end timestamp
    44// of zero means no announced deadline, not an already-ended sale.
    45func ConfigureSale(
    46 cur realm,
    47 allowlistStart, allowlistEnd int64,
    48 publicStart, publicEnd int64,
    49 allowlistPrice, publicPrice int64,
    50 allowlistLimit, publicLimit int,
    51 treasury address,
    52) {
    53 assertAdmin(cur.Previous().Address())
    54 if !salePaused {
    55 panic("guardians: pause sale before configuration")
    56 }
    57 if !validSaleSchedule(allowlistStart, allowlistEnd, publicStart, publicEnd) {
    58 panic("guardians: invalid sale schedule")
    59 }
    60 if !validAllowlistPrice(allowlistPrice) || !validSalePrice(publicPrice) {
    61 panic("guardians: invalid sale price")
    62 }
    63 if !validWalletLimit(allowlistLimit) || !validWalletLimit(publicLimit) {
    64 panic("guardians: invalid wallet limit")
    65 }
    66 if !treasury.IsValid() {
    67 panic("guardians: invalid sale treasury")
    68 }
    69
    70 saleConfig = saleConfiguration{
    71 allowlistStart: allowlistStart,
    72 allowlistEnd: allowlistEnd,
    73 publicStart: publicStart,
    74 publicEnd: publicEnd,
    75 allowlistPrice: allowlistPrice,
    76 publicPrice: publicPrice,
    77 allowlistLimit: allowlistLimit,
    78 publicLimit: publicLimit,
    79 treasury: treasury,
    80 }
    81 saleConfigured = true
    82
    83 chain.Emit(
    84 "SaleConfigured",
    85 "allowlistStart", ufmt.Sprintf("%d", allowlistStart),
    86 "allowlistEnd", ufmt.Sprintf("%d", allowlistEnd),
    87 "publicStart", ufmt.Sprintf("%d", publicStart),
    88 "publicEnd", ufmt.Sprintf("%d", publicEnd),
    89 "treasury", treasury.String(),
    90 )
    91}
    92
    93func SetSalePaused(cur realm, paused bool) {
    94 assertAdmin(cur.Previous().Address())
    95 if !paused && !saleConfigured {
    96 panic("guardians: configure sale before unpausing")
    97 }
    98 if !paused && allowlistRoot == "" {
    99 panic("guardians: configure allowlist root before unpausing")
    100 }
    101 if !paused && revealState != revealStateCommitted {
    102 panic("guardians: commit reveal configuration before unpausing")
    103 }
    104 if !paused {
    105 allowlistRootLocked = true
    106 }
    107 salePaused = paused
    108 chain.Emit("SalePauseChanged", "paused", ufmt.Sprintf("%t", paused))
    109}
    110
    111func SalePhase() string { return salePhaseAt(time.Now().Unix()) }
    112
    113func SalePhaseAt(unixTime int64) string { return salePhaseAt(unixTime) }
    114
    115func salePhaseAt(unixTime int64) string {
    116 if token.TotalSupply() >= maxSupply {
    117 return salePhaseSoldOut
    118 }
    119 if salePaused || !saleConfigured {
    120 return salePhaseClosed
    121 }
    122 allowlistOpen := allowlistSaleOpenAt(unixTime)
    123 publicOpen := publicSaleOpenAt(unixTime)
    124 if allowlistOpen && publicOpen {
    125 return salePhaseOpen
    126 }
    127 if allowlistOpen {
    128 return salePhaseAllowlist
    129 }
    130 if publicOpen {
    131 return salePhasePublic
    132 }
    133 return salePhaseClosed
    134}
    135
    136func publicSaleOpenAt(unixTime int64) bool {
    137 return saleConfigured && !salePaused && unixTime >= saleConfig.publicStart &&
    138 (saleConfig.publicEnd == 0 || unixTime < saleConfig.publicEnd)
    139}
    140
    141func allowlistSaleOpenAt(unixTime int64) bool {
    142 return saleConfigured && !salePaused && unixTime >= saleConfig.allowlistStart &&
    143 (saleConfig.allowlistEnd == 0 || unixTime < saleConfig.allowlistEnd) &&
    144 (saleConfig.publicEnd == 0 || unixTime < saleConfig.publicEnd)
    145}
    146
    147// SetPublicEnd announces a deadline without pausing or changing price, wallet
    148// limits, roots, or counters. A completed sale cannot be reopened this way.
    149// Set end to the current block time to close immediately, or a future time
    150// to announce an end countdown. Zero is reserved for initial configuration.
    151func SetPublicEnd(cur realm, end int64) {
    152 assertAdmin(cur.Previous().Address())
    153 if !saleConfigured || revealState != revealStateCommitted {
    154 panic("guardians: sale is not configurable")
    155 }
    156 now := time.Now().Unix()
    157 if saleConfig.publicEnd > 0 && now >= saleConfig.publicEnd {
    158 panic("guardians: closed sale cannot be reopened")
    159 }
    160 if end < now || end <= saleConfig.publicStart {
    161 panic("guardians: invalid public end timestamp")
    162 }
    163 saleConfig.publicEnd = end
    164 chain.Emit("PublicEndConfigured", "publicEnd", ufmt.Sprintf("%d", end))
    165}
    166
    167func SalePaused() bool { return salePaused }
    168
    169func SaleConfigured() bool { return saleConfigured }
    170
    171func SaleTreasury() address { return saleConfig.treasury }
    172
    173func AllowlistStart() int64 { return saleConfig.allowlistStart }
    174
    175func AllowlistEnd() int64 { return saleConfig.allowlistEnd }
    176
    177func PublicStart() int64 { return saleConfig.publicStart }
    178
    179func PublicEnd() int64 { return saleConfig.publicEnd }
    180
    181func AllowlistPrice() int64 { return saleConfig.allowlistPrice }
    182
    183func PublicPrice() int64 { return saleConfig.publicPrice }
    184
    185func AllowlistWalletLimit() int { return saleConfig.allowlistLimit }
    186
    187func PublicWalletLimit() int { return saleConfig.publicLimit }
    188
    189func AllowlistMinted(owner address) int { return mintedCount(&allowlistMintedByWallet, owner) }
    190
    191func PublicMinted(owner address) int { return mintedCount(&publicMintedByWallet, owner) }
    192
    193func NextSaleTimestamp() int64 {
    194 now := time.Now().Unix()
    195 if !saleConfigured {
    196 return 0
    197 }
    198 next := int64(0)
    199 for _, timestamp := range []int64{saleConfig.allowlistStart, saleConfig.allowlistEnd, saleConfig.publicStart, saleConfig.publicEnd} {
    200 if timestamp > now && (next == 0 || timestamp < next) {
    201 next = timestamp
    202 }
    203 }
    204 return next
    205}
    206
    207// MintPublic accepts only direct Adena/EOA calls. This pairing is critical:
    208// OriginSend describes actual receipt by this realm only for a direct user call.
    209func MintPublic(cur realm, quantity int) {
    210 if !cur.Previous().IsUserCall() {
    211 panic("guardians: only direct user calls can mint")
    212 }
    213 if !publicSaleOpenAt(time.Now().Unix()) {
    214 panic("guardians: public sale is not active")
    215 }
    216
    217 caller := cur.Previous().Address()
    218 assertSaleMint(quantity, PublicMinted(caller), saleConfig.publicLimit)
    219 required := requiredPayment(saleConfig.publicPrice, quantity)
    220 sent := unsafe.OriginSend()
    221 assertExactPayment(sent, required)
    222
    223 mintTokens(caller, quantity)
    224 publicMintedByWallet.Set(caller.String(), PublicMinted(caller)+quantity)
    225 forwardPayment(cur, sent)
    226
    227 chain.Emit(
    228 "PublicMint",
    229 "minter", caller.String(),
    230 "quantity", ufmt.Sprintf("%d", quantity),
    231 "paid", ufmt.Sprintf("%d", required),
    232 )
    233}
    234
    235func assertSaleMint(quantity, alreadyMinted, walletLimit int) {
    236 assertMintQuantity(quantity)
    237 if alreadyMinted+quantity > walletLimit {
    238 panic("guardians: wallet mint limit exceeded")
    239 }
    240}
    241
    242func requiredPayment(unitPrice int64, quantity int) int64 {
    243 if unitPrice < 0 || !validMintQuantity(quantity) {
    244 panic("guardians: invalid payment calculation")
    245 }
    246 return unitPrice * int64(quantity)
    247}
    248
    249func assertExactPayment(sent chain.Coins, required int64) {
    250 if required == 0 {
    251 if len(sent) != 0 {
    252 panic("guardians: free mint must not include payment")
    253 }
    254 return
    255 }
    256 if !isExactPayment(sent, required) {
    257 panic(ufmt.Sprintf("guardians: exact payment required: %dugnot", required))
    258 }
    259}
    260
    261func isExactPayment(sent chain.Coins, required int64) bool {
    262 return len(sent) == 1 && sent[0].Denom == saleDenom && sent[0].Amount == required
    263}
    264
    265func forwardPayment(cur realm, sent chain.Coins) {
    266 if len(sent) == 0 {
    267 return
    268 }
    269 b := banker.NewBanker(banker.BankerTypeRealmSend, cur)
    270 b.SendCoins(cur.Address(), saleConfig.treasury, sent)
    271}
    272
    273func mintedCount(tree *avl.Tree, owner address) int {
    274 v := tree.Get(owner.String())
    275 if v == nil {
    276 return 0
    277 }
    278 return v.(int)
    279}
    280
    281func validSaleSchedule(allowlistStart, allowlistEnd, publicStart, publicEnd int64) bool {
    282 return allowlistStart > 0 &&
    283 publicStart >= allowlistStart &&
    284 (allowlistEnd == 0 || allowlistStart < allowlistEnd) &&
    285 (publicEnd == 0 || publicStart < publicEnd)
    286}
    287
    288func validSalePrice(price int64) bool {
    289 return price > 0 && price <= 9223372036854775807/int64(maxMintBatch)
    290}
    291
    292func validAllowlistPrice(price int64) bool {
    293 return price >= 0 && price <= 9223372036854775807/int64(maxMintBatch)
    294}
    295
    296func validWalletLimit(limit int) bool {
    297 return limit > 0 && int64(limit) <= maxSupply
    298}
    299