Skip to content

Commit

Permalink
update config err
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Aug 30, 2024
1 parent 5fa1e88 commit 856d4f2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/gno.land/r/leon/config/config.gno
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package leon
package config

import (
"errors"
Expand All @@ -24,7 +24,7 @@ func Backup() std.Address {

func SetAddress(a std.Address) error {
if !a.IsValid() {
return errors.New("invalid address")
return errors.New("config: invalid address")
}

if err := checkAuthorized(); err != nil {
Expand All @@ -37,7 +37,7 @@ func SetAddress(a std.Address) error {

func SetBackup(a std.Address) error {
if !a.IsValid() {
return errors.New("invalid address")
return errors.New("config: invalid address")
}

if err := checkAuthorized(); err != nil {
Expand All @@ -56,3 +56,10 @@ func checkAuthorized() error {

return nil
}

func AssertAuthorized() {
caller := std.PrevRealm().Addr()
if caller != main || caller != backup {
panic("config: unauthorized")
}
}

0 comments on commit 856d4f2

Please sign in to comment.