Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

Playground

bbb.gno

// Package bbb is a throwaway GRC20 with an open faucet, used to exercise the
// pair instances in this repo. It has no value and no owner controls.
package bbb

import (
	"gno.land/p/nt/grc20/v0"
	"gno.land/r/nt/grc20reg/v0"
)

var (
	Token         *grc20.Token
	privateLedger *grc20.PrivateLedger
	userTeller    grc20.Teller
)

// Key is this token's grc20reg key, the string an instance realm is
// configured with.
const Key = "gno.land/r/nym-moultest123/x/pairs/bbb/v0.BBB"

func init(cur realm) {
	Token, privateLedger = grc20.NewToken("Test Beta", "BBB", 6, 1, cur)
	userTeller = privateLedger.CallerTeller()
	grc20reg.Register(cross(cur), Token, "")
}

// Faucet mints a fixed amount to the caller. Unrestricted on purpose.
func Faucet(cur realm) {
	if err := privateLedger.Mint(cur.Previous().Address(), 1_000_000_000); err != nil {
		panic(err)
	}
}

func TotalSupply() int64                      { return userTeller.TotalSupply() }
func BalanceOf(owner address) int64           { return userTeller.BalanceOf(owner) }
func Allowance(owner, spender address) int64  { return userTeller.Allowance(owner, spender) }

func Transfer(cur realm, to address, amount int64) {
	if err := userTeller.Transfer(0, cur, to, amount); err != nil {
		panic(err)
	}
}

func Approve(cur realm, spender address, amount int64) {
	if err := userTeller.Approve(0, cur, spender, amount); err != nil {
		panic(err)
	}
}

func Render(string) string {
	return "# BBB\n\nThrowaway test token for the pair instances. `Faucet` mints 1000 BBB to you.\n"
}

bbb_test.gno

package bbb

import (
	"strings"
	"testing"

	"gno.land/p/nt/testutils/v0"
	"gno.land/p/nt/uassert/v0"
)

func TestFaucetAndRender(cur realm, t *testing.T) {
	user := testutils.TestAddress("bbb-user")
	testing.SetRealm(testing.NewUserRealm(user))
	Faucet(cross(cur))
	uassert.Equal(t, int64(1_000_000_000), BalanceOf(user))

	uassert.True(t, strings.Contains(Render(""), "# BBB"))
	uassert.Equal(t, "gno.land/r/nym-moultest123/x/pairs/bbb/v0.BBB", Key)
}

gnomod.toml

module = "gno.land/r/nym-moultest123/x/pairs/bbb/v0"
gno = "0.9"

[addpkg]
  creator = "g1ml9grtwnpzqn3hre5ve5vjdlmv2srrmpmc0dsv"
  height = 186407
  max_deposit = "5000000ugnot"