app.gno
0.73 Kb · 27 lines
1package core
2
3import (
4 "gno.land/p/aib/ibc/app"
5 "gno.land/p/aib/ibc/host"
6 "gno.land/p/nt/ufmt/v0"
7)
8
9// RegisterApp registers an IBCApp, the portID is determined using the package
10// path of the caller, hence it must an other realm.
11func RegisterApp(cur realm, portID string, app app.IBCApp) {
12 caller := cur.Previous()
13 if caller.IsUser() {
14 panic("RegisterApp can only be called from an other realm")
15 }
16 if err := host.PortIdentifierValidator(portID); err != nil {
17 panic(ufmt.Errorf("invalid portID: %v", err))
18 }
19 if _, ok := store.routes[portID]; ok {
20 panic(ufmt.Errorf("portID %s has already been registered", portID))
21 }
22 store.routes[portID] = ibcApp{
23 IBCApp: app,
24 pkgPath: caller.PkgPath(),
25 address: caller.Address(),
26 }
27}