PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidators

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/demo/profile

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
profile
Namespace
demo
Files
4 (gnomod.toml)
Exported functions
7
Module
gno.land/r/demo/profile
gno
0.9

Files (4)

  • gnomod.tomltoml
  • profile.gnogno
  • render.gnogno
  • profile_test.gnogno
profile_test.gnogno
1package profile23import (4	"testing"56	"gno.land/p/nt/testutils/v0"7	"gno.land/p/nt/uassert/v0"8)910// Global addresses for test users11var (12	alice   = testutils.TestAddress("alice")13	bob     = testutils.TestAddress("bob")14	charlie = testutils.TestAddress("charlie")15	dave    = testutils.TestAddress("dave")16	eve     = testutils.TestAddress("eve")17	frank   = testutils.TestAddress("frank")18	user1   = testutils.TestAddress("user1")19	user2   = testutils.TestAddress("user2")20)2122func TestStringFields(cur realm, t *testing.T) {23	testing.SetRealm(testing.NewUserRealm(alice))2425	// Get before setting26	name := GetStringField(alice, DisplayName, "anon")27	uassert.Equal(t, "anon", name)2829	// Set new key30	updated := SetStringField(cross(cur), DisplayName, "Alice foo")31	uassert.Equal(t, updated, false)32	updated = SetStringField(cross(cur), Homepage, "https://example.com")33	uassert.Equal(t, updated, false)3435	// Update the key36	updated = SetStringField(cross(cur), DisplayName, "Alice foo")37	uassert.Equal(t, updated, true)3839	// Get after setting40	name = GetStringField(alice, DisplayName, "anon")41	homepage := GetStringField(alice, Homepage, "")42	bio := GetStringField(alice, Bio, "42")4344	uassert.Equal(t, "Alice foo", name)45	uassert.Equal(t, "https://example.com", homepage)46	uassert.Equal(t, "42", bio)47}4849func TestIntFields(cur realm, t *testing.T) {50	testing.SetRealm(testing.NewUserRealm(bob))5152	// Get before setting53	age := GetIntField(bob, Age, 25)54	uassert.Equal(t, 25, age)5556	// Set new key57	updated := SetIntField(cross(cur), Age, 30)58	uassert.Equal(t, updated, false)5960	// Update the key61	updated = SetIntField(cross(cur), Age, 30)62	uassert.Equal(t, updated, true)6364	// Get after setting65	age = GetIntField(bob, Age, 25)66	uassert.Equal(t, 30, age)67}6869func TestBoolFields(cur realm, t *testing.T) {70	testing.SetRealm(testing.NewUserRealm(charlie))7172	// Get before setting73	hiring := GetBoolField(charlie, AvailableForHiring, false)74	uassert.Equal(t, false, hiring)7576	// Set77	updated := SetBoolField(cross(cur), AvailableForHiring, true)78	uassert.Equal(t, updated, false)7980	// Update the key81	updated = SetBoolField(cross(cur), AvailableForHiring, true)82	uassert.Equal(t, updated, true)8384	// Get after setting85	hiring = GetBoolField(charlie, AvailableForHiring, false)86	uassert.Equal(t, true, hiring)87}8889func TestMultipleProfiles(cur realm, t *testing.T) {90	// Set profile for user191	testing.SetRealm(testing.NewUserRealm(user1))92	updated := SetStringField(cross(cur), DisplayName, "User One")93	uassert.Equal(t, updated, false)9495	// Set profile for user296	testing.SetRealm(testing.NewUserRealm(user2))97	updated = SetStringField(cross(cur), DisplayName, "User Two")98	uassert.Equal(t, updated, false)99100	// Get profiles101	testing.SetRealm(testing.NewUserRealm(user1)) // Switch back to user1102	name1 := GetStringField(user1, DisplayName, "anon")103	testing.SetRealm(testing.NewUserRealm(user2)) // Switch back to user2104	name2 := GetStringField(user2, DisplayName, "anon")105106	uassert.Equal(t, "User One", name1)107	uassert.Equal(t, "User Two", name2)108}109110func TestArbitraryStringField(cur realm, t *testing.T) {111	testing.SetRealm(testing.NewUserRealm(user1))112113	// Set arbitrary string field114	updated := SetStringField(cross(cur), "MyEmail", "my@email.com")115	uassert.Equal(t, updated, false)116117	val := GetStringField(user1, "MyEmail", "")118	uassert.Equal(t, val, "my@email.com")119}120121func TestArbitraryIntField(cur realm, t *testing.T) {122	testing.SetRealm(testing.NewUserRealm(user1))123124	// Set arbitrary int field125	updated := SetIntField(cross(cur), "MyIncome", 100_000)126	uassert.Equal(t, updated, false)127128	val := GetIntField(user1, "MyIncome", 0)129	uassert.Equal(t, val, 100_000)130}131132func TestArbitraryBoolField(cur realm, t *testing.T) {133	testing.SetRealm(testing.NewUserRealm(user1))134135	// Set arbitrary bool field136	updated := SetBoolField(cross(cur), "IsWinner", true)137	uassert.Equal(t, updated, false)138139	val := GetBoolField(user1, "IsWinner", false)140	uassert.Equal(t, val, true)141}142

Functions

  • GetBoolField(addr string, field string, def bool) bool

  • GetIntField(addr string, field string, def int) int

  • GetStringField(addr string, field string, def string) string

  • Render(path string) string

  • SetBoolField(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}, field string, value bool) bool

  • SetIntField(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}, field string, value int) bool

  • SetStringField(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}, field string, value string) bool

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.