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/p/nt/treasury/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
nt / treasury
Files
14 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/nt/treasury/v0
gno
0.9

Files (14)

  • README.mdmarkdown
  • gnomod.tomltoml
  • banker_coins.gnogno
  • banker_grc20.gnogno
  • doc.gnogno
  • render.gnogno
  • treasury.gnogno
  • types.gnogno
  • banker_canonical_filetest.gnogno
  • banker_coins_filetest.gnogno
  • banker_coins_payment_canonical_filetest.gnogno
  • banker_coins_payment_copy_filetest.gnogno
  • banker_grc20_filetest.gnogno
  • treasury_filetest.gnogno
  • banker_coins_filetest.gnogno
    1// PKGPATH: gno.land/r/treasury/main23package main45import (6	"chain"7	"chain/banker"8	"testing"910	"gno.land/p/nt/treasury/v0"11)1213func main(cur realm) {14	// Define addresses for the sender (owner) and destination.15	ownerAddr := chain.PackageAddress("gno.land/r/treasury/main")16	destAddr := chain.PackageAddress("gno.land/r/dest/main")1718	// Create a CoinsBanker.19	banker_ := banker.NewBanker(banker.BankerTypeRealmSend, cur)20	cbanker, err := treasury.NewCoinsBankerWithOwner(ownerAddr, banker_)21	if err != nil {22		panic("failed to create CoinsBanker: " + err.Error())23	}2425	println("CoinsBanker ID:", cbanker.ID())26	println("CoinsBanker Address:", cbanker.Address())2728	// Check if the CoinsBanker address matches the owner address.29	if cbanker.Address() != ownerAddr.String() {30		panic("CoinsBanker address does not match current realm address")31	}3233	println("CoinsBanker Balances count:", len(cbanker.Balances()))3435	// Issue some coins to the owner address.36	testing.IssueCoins(ownerAddr, chain.NewCoins(chain.NewCoin("ugnot", 42)))3738	println("CoinsBanker Balances count:", len(cbanker.Balances()))39	println("Ugnot balance:", cbanker.Balances()[0].Amount)4041	// Send a valid payment.42	validPayment := treasury.NewCoinsPayment(43		chain.NewCoins(chain.NewCoin("ugnot", 10)),44		destAddr,45	)46	err = cbanker.Send(0, cur, validPayment)47	println("Valid payment error:", err)48	if err != nil {49		panic("failed to send valid payment: " + err.Error())50	}5152	println("Ugnot balance:", cbanker.Balances()[0].Amount)5354	// Send a payment with an invalid type.55	invalidPaymentType := treasury.NewGRC20Payment("", 0, destAddr)56	err = cbanker.Send(0, cur, invalidPaymentType)57	println("Invalid payment type error:", err)58	if err == nil {59		panic("expected error for invalid payment type, but got none")60	}6162	// Issue another coin to the owner address to test the Balances method.63	testing.IssueCoins(ownerAddr, chain.NewCoins(chain.NewCoin("anothercoin", 1337)))6465	println("CoinsBanker Balances count:", len(cbanker.Balances()))66}6768// Output:69// CoinsBanker ID: Coins70// CoinsBanker Address: g1ynsdz5zaxhn9gnqtr6t40m5k4fueeutq7xy22471// CoinsBanker Balances count: 072// CoinsBanker Balances count: 173// Ugnot balance: 4274// Valid payment error: undefined75// Ugnot balance: 3276// Invalid payment type error: invalid payment type77// CoinsBanker Balances count: 278

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.