PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

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/gov/dao/treasury/v0

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
v0
Namespace
gov / dao / treasury
Files
2 (gnomod.toml)
Exported functions
8
Module
gno.land/r/gov/dao/treasury/v0
gno
0.9

Files (2)

  • gnomod.tomltoml
  • treasury.gnogno
treasury.gnogno
1package treasury23import (4	"chain/banker"56	"gno.land/p/nt/grc20/v0"7	t "gno.land/p/nt/treasury/v0"89	"gno.land/r/gov/dao"10	"gno.land/r/nt/grc20reg/v0"11)1213var (14	treasury  *t.Treasury15	tokenKeys = []string{16		// TODO: Add the default GRC20 tokens we want to support here.17	}18)1920func init(cur realm) {21	// Define a token lister for the GRC20Banker.22	// For now, GovDAO uses a static list of tokens.23	grc20Lister := func() map[string]*grc20.Token {24		// Get the GRC20 tokens from the registry.25		tokens := map[string]*grc20.Token{}26		for _, key := range tokenKeys {27			// Get the token by its key.28			token := grc20reg.Get(key)29			if token != nil {30				tokens[key] = token31			}32		}3334		return tokens35	}3637	// Init the treasury bankers.38	coinsBanker, err := t.NewCoinsBankerWithOwner(cur.Address(), banker.NewBanker(banker.BankerTypeRealmSend, cur))39	if err != nil {40		panic("failed to create CoinsBanker: " + err.Error())41	}42	grc20Banker, err := t.NewGRC20BankerWithOwner(cur.Address(), grc20Lister)43	if err != nil {44		panic("failed to create GRC20Banker: " + err.Error())45	}46	bankers := []t.Banker{47		coinsBanker,48		grc20Banker,49	}5051	// Create the treasury instance with the bankers. cur.PkgPath() is52	// captured for render-link construction (See full history → /r/gov/dao/treasury/v0:.../history).53	treasury, err = t.New(bankers, cur.PkgPath())54	if err != nil {55		panic("failed to create treasury: " + err.Error())56	}57}5859// SetTokenKeys sets the GRC20 token registry keys that the treasury will use.60func SetTokenKeys(cur realm, keys []string) {61	// Crossing function, so cur is a live minted cur and this is redundant62	// today; kept to match the documented rule that caller identity is63	// derived from cur.Previous() only under an IsCurrent() guard.64	if !cur.IsCurrent() {65		panic("realm value is not the caller's live cur")66	}67	caller := cur.Previous().PkgPath()6869	// Check if the caller realm is allowed to set token keys.70	if !dao.InAllowedDAOs(caller) {71		panic("this Realm is not allowed to send payment: " + caller)72	}7374	// Copied, not aliased: the grc20Lister closure re-reads tokenKeys on every75	// Balances() and every GRC20 payment, so storing the caller's array as76	// given would leave it a permanent write handle on this realm's token set.77	tokenKeys = make([]string, len(keys))78	copy(tokenKeys, keys)79}8081// Send sends a payment using the treasury instance.82func Send(cur realm, payment t.Payment) {83	// See SetTokenKeys: redundant under the crossing-function guarantee, kept84	// for conformance with the IsCurrent()-before-Previous() rule.85	if !cur.IsCurrent() {86		panic("realm value is not the caller's live cur")87	}88	caller := cur.Previous().PkgPath()8990	// Check if the caller realm is allowed to send payments.91	if !dao.InAllowedDAOs(caller) {92		panic("this Realm is not allowed to send payment: " + caller)93	}9495	// Send the payment using the treasury instance. cur is this realm's96	// captured cur — passes IsCurrent inside Banker.Send and matches the97	// banker's owner (this realm's address) registered at init.98	if err := treasury.Send(0, cur, payment); err != nil {99		panic(err)100	}101}102103// History returns the payment history sent by the banker with the given ID.104// Payments are paginated, with the most recent payments first.105func History(bankerID string, pageNumber int, pageSize int) []t.Payment {106	history, err := treasury.History(bankerID, pageNumber, pageSize)107	if err != nil {108		panic("failed to get history: " + err.Error())109	}110111	return history112}113114// Balances returns the balances of the banker with the given ID.115func Balances(bankerID string) []t.Balance {116	balances, err := treasury.Balances(bankerID)117	if err != nil {118		panic("failed to get balances: " + err.Error())119	}120121	return balances122}123124// Address returns the address of the banker with the given ID.125func Address(bankerID string) string {126	addr, err := treasury.Address(bankerID)127	if err != nil {128		panic("failed to get address: " + err.Error())129	}130131	return addr132}133134// HasBanker checks if a banker with the given ID is registered.135func HasBanker(bankerID string) bool {136	return treasury.HasBanker(bankerID)137}138139// ListBankerIDs returns a list of all registered banker IDs.140func ListBankerIDs() []string {141	return treasury.ListBankerIDs()142}143144func Render(path string) string {145	return treasury.Render(path)146}147

Functions

  • Address(bankerID string) string

  • Balances(bankerID string) []gno.land/p/nt/treasury/v0.Balance

  • HasBanker(bankerID string) bool

  • History(bankerID string, pageNumber int, pageSize int) []gno.land/p/nt/treasury/v0.Payment

  • ListBankerIDs() []string

  • Render(path string) string

  • Send(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}, payment interface {BankerID func() string; String func() string})

  • SetTokenKeys(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}, keys []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.