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

gnomod.toml

module = "gno.land/p/nym-moultest123/ownable/v0"
gno = "0.9"

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

ownable.gno

// Package ownable proposes an abstraction around the ownership which provides
// various kind of owners and some composition options.
package ownable

import "chain/runtime"

type Owner interface {
	Addr() address
	Kind() Kind
	owner()
}

type Kind int

type UserOwner struct {
	addr address
}

type RealmOwner struct {
	realm runtime.Realm
}

type MembstoreOwner struct {
	// membstore.Membstore
}

type DAOOwner struct {
	// dao.DAO
}

func And(a Owner, b ...Owner) Owner { panic("not implemented") }
func Or(a Owner, b ...Owner) Owner  { panic("not implemented") }

ownable_test.gno

package ownable

import (
	"testing"

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

// This package is an API sketch recovered from an unmerged upstream proposal:
// it declares the Owner abstraction and its four owner kinds, but And/Or are
// `panic("not implemented")`. The tests pin that surface so that implementing
// one is a deliberate, visible change rather than a silent behaviour shift.

func TestCompositionHelpersAreNotImplemented(cur realm, t *testing.T) {
	uassert.PanicsWithMessage(t, cur, "not implemented", func() { And(nil) })
	uassert.PanicsWithMessage(t, cur, "not implemented", func() { Or(nil) })
}

// TestOwnerKindsAreDeclared is a compile-time check that the concrete owner
// types still exist with their documented shape.
func TestOwnerKindsAreDeclared(t *testing.T) {
	var (
		_ UserOwner
		_ RealmOwner
		_ MembstoreOwner
		_ DAOOwner
		_ Kind
	)
	uassert.True(t, true, "owner kinds are declared")
}

// TestKindIsAnInt pins Kind's underlying type: it is compared and likely
// persisted numerically, so a change of base type is breaking.
func TestKindIsAnInt(t *testing.T) {
	var k Kind
	uassert.Equal(t, 0, int(k), "zero Kind is 0")
}