Skip to content

Commit

Permalink
example for n0izn0iz
Browse files Browse the repository at this point in the history
  • Loading branch information
moul authored Jul 18, 2023
1 parent cee2bec commit ec7f2ce
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/gno.land/r/demo/dao_realm/dao_realm.gno
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,41 @@ func GetBinaryMembers() string {
}
return strings.Join(ss, ",")
}

func RegisterNewFeature(handle NewHandle) {
assertRealmIsInDAOPrefix() // if strings.HasPrefix(std.PrevRealm().PkgPath(), "dao_realm/")
assertIsWhitelistedCaller()
registry.Register(handle)
}

var whitelisted []std.Address // can be done with https://github.com/gnolang/gno/pull/880

func ToggleWhitelistedAddress(addr std.Address) {
assertIsAdminOrDAOApproved()
whitelisted = append(whitelisted, addr)
}




--------------
import "dao_realm"

func init() {
dao_realm.Register(handle) // works IF caller checks if std.PrevRealm().PkgPath() starts with the namespace
}

var registered bool

func RegisterSelf() { // this one works whenever someone calls it, except, you need to manually whitelist the contract address first
if registered { return }
dao_realm.Register(handle)
}

---


1. upload dao_realm
2. upload dao_feat2
3. call dao_realm.ToggleWhitelistedAddress(dao_feat2)
4. call dao_feat2.RegisterSelf()

0 comments on commit ec7f2ce

Please sign in to comment.