github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/r/x/manfred_upgrade_patterns/upgrade_b/v2/v2.gno (about) 1 package upgradeb 2 3 import ( 4 "std" 5 6 v1 "gno.land/r/x/manfred_upgrade_patterns/upgrade_b/v1" 7 ) 8 9 const admin = "blahblah" 10 11 var ( 12 counter int 13 nextVersion string 14 ) 15 16 func Inc(nb int) { 17 if nextVersion != "" { 18 panic("contract is locked, please use the new version at r/" + nextVersion) 19 } 20 counter += nb 21 } 22 23 func Get() int { 24 return v1.Get() + counter 25 } 26 27 func SetNextVersion(addr string) { 28 // assert CallTx call. 29 std.AssertOriginCall() 30 // assert admin. 31 caller := std.GetCallerAt(2) 32 if caller != std.GetOrigCaller() { 33 panic("should not happen") // because std.AssertOrigCall(). 34 } 35 if caller != admin { 36 panic("unauthorized") 37 } 38 nextVersion = addr 39 }