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/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/x/upgrade/store/logic/v0"
gno = "0.9"

[addpkg]
  creator = "g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv"
  height = 914348
  max_deposit = "5000000ugnot"

logic.gno

// Package logic is version 0 of the logic realm of the "state realm + swappable
// logic" upgrade pattern (pattern C of the exploration; see ../../README.md).
//
// It owns no state at all. Everything it writes lands in the root data realm,
// which is what makes replacing this realm cheap: there is nothing here to
// migrate.
package logic

import (
	root "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/x/upgrade/store/root/v0"

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

// Step is this version's business rule: one call, one unit.
const Step = 1

// Inc applies this version's rule to the shared counter.
func Inc(cur realm) int {
	return root.Inc(cross(cur), Step)
}

// Get reads the shared counter. Same number every version sees.
func Get() int {
	return root.Get()
}

func Render(_ string) string {
	return ufmt.Sprintf("store/logic/v0: counter=%d step=%d\n", Get(), Step)
}

render_example_test.gno

package logic

// ExampleRender pins the render of the logic realm against an untouched store.
func ExampleRender() {
	print(Render(""))
	// Output:
	// store/logic/v0: counter=0 step=1
}