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