From a8ee8baf5a3bb2213a358b11cb5f4bc4c09c6e82 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Sun, 3 Nov 2024 17:39:48 -0500 Subject: [PATCH] Added InitChain to code-gen --- src/dev_tools/goMaker/types/templates.go | 2 ++ src/dev_tools/goMaker/types/types_structure.go | 4 ++++ src/dev_tools/goMaker/types/utils.go | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dev_tools/goMaker/types/templates.go b/src/dev_tools/goMaker/types/templates.go index 16583056f4..8f8464f527 100644 --- a/src/dev_tools/goMaker/types/templates.go +++ b/src/dev_tools/goMaker/types/templates.go @@ -41,6 +41,7 @@ func getFuncMap() template.FuncMap { firstLower := func(s string) string { return FirstLower(s) } firstUpper := func(s string) string { return FirstUpper(s) } toLowerPlural := func(s string) string { return Lower(Plural(s)) } + or := func(a, b bool) bool { return a || b } return template.FuncMap{ "toSingular": toSingular, "toProper": toProper, @@ -50,5 +51,6 @@ func getFuncMap() template.FuncMap { "toLower": toLower, "firstLower": firstLower, "firstUpper": firstUpper, + "or": or, } } diff --git a/src/dev_tools/goMaker/types/types_structure.go b/src/dev_tools/goMaker/types/types_structure.go index 84632326fb..125b829e5e 100644 --- a/src/dev_tools/goMaker/types/types_structure.go +++ b/src/dev_tools/goMaker/types/types_structure.go @@ -291,6 +291,10 @@ func (s *Structure) NeedsChain() bool { return !strings.Contains(s.Attributes, "noChain") } +func (s *Structure) InitChain() bool { + return !s.NeedsChain() && strings.Contains(s.Attributes, "initChain") +} + func (s *Structure) NeedsFetch() bool { return !strings.Contains(s.Attributes, "noFetch") } diff --git a/src/dev_tools/goMaker/types/utils.go b/src/dev_tools/goMaker/types/utils.go index 55cdedb43e..1647646759 100644 --- a/src/dev_tools/goMaker/types/utils.go +++ b/src/dev_tools/goMaker/types/utils.go @@ -186,9 +186,10 @@ func FirstLower(s string) string { func Plural(s string) string { if strings.HasSuffix(s, "s") { return s - } - if strings.HasSuffix(s, "x") { + } else if strings.HasSuffix(s, "x") { return s + "es" + } else if strings.HasSuffix(s, "y") { + return s + "ies" } return s + "s" }