Skip to content

Commit

Permalink
move some util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Dec 23, 2024
1 parent a3451d8 commit a21336a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
31 changes: 1 addition & 30 deletions gov/governance/execute2.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"gno.land/p/demo/avl"
"gno.land/p/demo/ufmt"
"gno.land/r/gnoswap/v1/common"
cp "gno.land/r/gnoswap/v1/community_pool"
"gno.land/r/gnoswap/v1/consts"
cp "gno.land/r/gnoswap/v1/community_pool"
en "gno.land/r/gnoswap/v1/emission"
pl "gno.land/r/gnoswap/v1/pool"
)
Expand Down Expand Up @@ -268,32 +268,3 @@ func validateExecutionWindow(now, windowStart, windowEnd uint64) error {

return nil
}

///////////////////// UTILS /////////////////////

func parseInt(s string) int {
num, err := strconv.ParseInt(s, 10, 64)
if err != nil {
panic(ufmt.Sprintf("invalid int value: %s", s))
}
return int(num)
}

func parseUint64(s string) uint64 {
num, err := strconv.ParseUint(s, 10, 64)
if err != nil {
panic(ufmt.Sprintf("invalid uint64 value: %s", s))
}
return num
}

func parseBool(s string) bool {
switch s {
case "true":
return true
case "false":
return false
default:
panic(ufmt.Sprintf("invalid bool value: %s", s))
}
}
27 changes: 27 additions & 0 deletions gov/governance/util.gno → gov/governance/utils.gno
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,30 @@ func getPrev() (string, string) {
prev := std.PrevRealm()
return prev.Addr().String(), prev.PkgPath()
}

func parseInt(s string) int {
num, err := strconv.ParseInt(s, 10, 64)
if err != nil {
panic(ufmt.Sprintf("invalid int value: %s", s))
}
return int(num)
}

func parseUint64(s string) uint64 {
num, err := strconv.ParseUint(s, 10, 64)
if err != nil {
panic(ufmt.Sprintf("invalid uint64 value: %s", s))
}
return num
}

func parseBool(s string) bool {
switch s {
case "true":
return true
case "false":
return false
default:
panic(ufmt.Sprintf("invalid bool value: %s", s))
}
}

0 comments on commit a21336a

Please sign in to comment.