Playground
gnomod.toml
module = "gno.land/r/moul/x/upgrade/wrap/v0" gno = "0.9" [addpkg] creator = "g1manfred47kzduec920z88wfr64ylksmdcedlf5" height = 410016 max_deposit = "5000000ugnot"
render_example_test.gno
package wrap
// ExampleRender pins the render of a freshly deployed v0.
func ExampleRender() {
print(Render(""))
// Output:
// wrap/v0: 0
}
wrap.gno
// Package wrap is version 0 of the "wrapping versions" upgrade pattern
// (pattern A of the exploration; see ../README.md).
//
// Nothing here knows that a successor exists. v0 keeps its own counter and
// stays writable forever: callers pinned to this path keep working, and keep
// diverging from whatever the newer version reports.
package wrap
import "gno.land/p/nt/ufmt/v0"
var counter int
// Inc adds n to this version's own counter.
func Inc(cur realm, n int) {
counter += n
}
// Get returns this version's counter. Non-crossing on purpose: a successor
// reads it without entering this realm as a writer.
func Get() int {
return counter
}
func Render(_ string) string {
return ufmt.Sprintf("wrap/v0: %d\n", counter)
}