Skip to content Search Apps Documentation Source Content 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.

impl.gno

1.28 Kb · 38 lines
 1// Package impl is version 1 of the implementation realm of the
 2// "self-registering implementation" upgrade pattern (pattern E; see
 3// ../../README.md).
 4//
 5// Identical wiring to v0, different behaviour. Deploying it takes the facade
 6// over on the spot, with no transaction from anybody.
 7package impl
 8
 9import (
10	facade "gno.land/r/nym-moultest123/x/upgrade/selfreg/facade/v0"
11)
12
13type greeter struct{}
14
15func (greeter) Greet(name string) string { return "HELLO, " + name + "!" }
16func (greeter) Version() string          { return "impl/v1" }
17
18// Instance exposes the singleton so a test (or a rollback) can re-register it
19// without redeploying.
20func Instance() facade.Impl { return greeter{} }
21
22func init(cur realm) {
23	facade.Register(cross(cur), Instance())
24}
25
26// Register re-registers this implementation with the facade. init does it once
27// at deploy; exposing it as a transaction is what makes a rollback to an
28// already-deployed version a single call.
29func Register(cur realm) {
30	facade.Register(cross(cur), Instance())
31}
32
33// Seal asks the facade to end its upgradeability, forever. It only succeeds
34// while this implementation is the live one: the facade reads the caller off
35// the crossing frame, so this cannot be used to seal somebody else's tenure.
36func Seal(cur realm) {
37	facade.Seal(cross(cur))
38}