Skip to content

Commit

Permalink
fix missing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Jul 4, 2024
1 parent 380d1c8 commit 7041fba
Show file tree
Hide file tree
Showing 31 changed files with 480 additions and 269 deletions.
35 changes: 6 additions & 29 deletions ignite/cmd/chain_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ func chainServe(cmd *cobra.Command, session *cliui.Session) error {
}

// check if custom config is defined
config, err := cmd.Flags().GetString(flagConfig)
if err != nil {
return err
}
config, _ := cmd.Flags().GetString(flagConfig)
if config != "" {
chainOption = append(chainOption, chain.ConfigFile(config))
}
Expand All @@ -156,47 +153,27 @@ func chainServe(cmd *cobra.Command, session *cliui.Session) error {
// serve the chain
var serveOptions []chain.ServeOption

forceUpdate, err := cmd.Flags().GetBool(flagForceReset)
if err != nil {
return err
}

forceUpdate, _ := cmd.Flags().GetBool(flagForceReset)
if forceUpdate {
serveOptions = append(serveOptions, chain.ServeForceReset())
}

resetOnce, err := cmd.Flags().GetBool(flagResetOnce)
if err != nil {
return err
}

resetOnce, _ := cmd.Flags().GetBool(flagResetOnce)
if resetOnce {
serveOptions = append(serveOptions, chain.ServeResetOnce())
}

quitOnFail, err := cmd.Flags().GetBool(flagQuitOnFail)
if err != nil {
return err
}

quitOnFail, _ := cmd.Flags().GetBool(flagQuitOnFail)
if quitOnFail {
serveOptions = append(serveOptions, chain.QuitOnFail())
}

generateClients, err := cmd.Flags().GetBool(flagGenerateClients)
if err != nil {
return err
}

generateClients, _ := cmd.Flags().GetBool(flagGenerateClients)
if generateClients {
serveOptions = append(serveOptions, chain.GenerateClients())
}

buildTags, err := cmd.Flags().GetStringSlice(flagBuildTags)
if err != nil {
return err
}

buildTags, _ := cmd.Flags().GetStringSlice(flagBuildTags)
if len(buildTags) > 0 {
serveOptions = append(serveOptions, chain.BuildTags(buildTags...))
}
Expand Down
5 changes: 1 addition & 4 deletions ignite/cmd/generate_composables.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ func generateComposablesHandler(cmd *cobra.Command, _ []string) error {
return err
}

output, err := cmd.Flags().GetString(flagOutput)
if err != nil {
return err
}
output, _ := cmd.Flags().GetString(flagOutput)

var opts []chain.GenerateTarget
if flagGetEnableProtoVendor(cmd) {
Expand Down
5 changes: 1 addition & 4 deletions ignite/cmd/generate_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ func generateHooksHandler(cmd *cobra.Command, _ []string) error {
return err
}

output, err := cmd.Flags().GetString(flagOutput)
if err != nil {
return err
}
output, _ := cmd.Flags().GetString(flagOutput)

var opts []chain.GenerateTarget
if flagGetEnableProtoVendor(cmd) {
Expand Down
11 changes: 2 additions & 9 deletions ignite/cmd/generate_typescript_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,8 @@ func generateTSClientHandler(cmd *cobra.Command, _ []string) error {
return err
}

output, err := cmd.Flags().GetString(flagOutput)
if err != nil {
return err
}

useCache, err := cmd.Flags().GetBool(flagUseCache)
if err != nil {
return err
}
output, _ := cmd.Flags().GetString(flagOutput)
useCache, _ := cmd.Flags().GetBool(flagUseCache)

var opts []chain.GenerateTarget
if flagGetEnableProtoVendor(cmd) {
Expand Down
7 changes: 6 additions & 1 deletion ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func scaffoldType(
return err
}

modificationsStr, err := sc.ApplyModifications()
sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -229,6 +229,11 @@ func scaffoldType(
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)
session.Printf("\n🎉 %s added. \n\n", typeName)

Expand Down
11 changes: 7 additions & 4 deletions ignite/cmd/scaffold_band.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/ignite/cli/v28/ignite/pkg/cliui"
"github.com/ignite/cli/v28/ignite/pkg/errors"
"github.com/ignite/cli/v28/ignite/pkg/placeholder"
"github.com/ignite/cli/v28/ignite/pkg/xgenny"
"github.com/ignite/cli/v28/ignite/services/scaffolder"
)

Expand Down Expand Up @@ -68,22 +67,26 @@ func createBandchainHandler(cmd *cobra.Command, args []string) error {
options = append(options, scaffolder.OracleWithSigner(signer)) //nolint: staticcheck
}

sc, err := scaffolder.New(appPath)
sc, err := scaffolder.New(cmd.Context(), appPath)
if err != nil {
return err
}

//nolint: staticcheck
sm, err := sc.AddOracle(cmd.Context(), cacheStorage, placeholder.New(), module, oracle, options...)
err = sc.AddOracle(cmd.Context(), cacheStorage, placeholder.New(), module, oracle, options...)
if err != nil {
return err
}

modificationsStr, err := xgenny.SourceModificationToString(sm)
modificationsStr, err := sc.ApplyModifications()
if err != nil {
return err
}

if err := sc.PostScaffold(cmd.Context(), cacheStorage, false); err != nil {
return err
}

session.Println(modificationsStr)
session.Printf(tplScaffoldBandSuccess, oracle, module)

Expand Down
18 changes: 13 additions & 5 deletions ignite/cmd/scaffold_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ about Cosmos SDK on https://docs.cosmos.network
c.Flags().StringP(flagPath, "p", "", "create a project in a specific path")
c.Flags().Bool(flagNoDefaultModule, false, "create a project without a default module")
c.Flags().StringSlice(flagParams, []string{}, "add default module parameters")
c.Flags().StringSlice(flagModuleConfigs, []string{}, "add module configs")
c.Flags().Bool(flagSkipGit, false, "skip Git repository initialization")
c.Flags().Bool(flagSkipProto, false, "skip proto generation")
c.Flags().Bool(flagMinimal, false, "create a minimal blockchain (with the minimum required Cosmos SDK modules)")
Expand All @@ -98,19 +99,25 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
defer session.End()

var (
name = args[0]
addressPrefix = getAddressPrefix(cmd)
appPath = flagGetPath(cmd)
name = args[0]
addressPrefix = getAddressPrefix(cmd)
appPath = flagGetPath(cmd)

noDefaultModule, _ = cmd.Flags().GetBool(flagNoDefaultModule)
skipGit, _ = cmd.Flags().GetBool(flagSkipGit)
minimal, _ = cmd.Flags().GetBool(flagMinimal)
isConsumer, _ = cmd.Flags().GetBool(flagIsConsumer)
params, _ = cmd.Flags().GetStringSlice(flagParams)
moduleConfigs, _ = cmd.Flags().GetStringSlice(flagModuleConfigs)
skipProto, _ = cmd.Flags().GetBool(flagSkipProto)
)

if noDefaultModule && len(params) > 0 {
return errors.New("params flag is only supported if the default module is enabled")
if noDefaultModule {
if len(params) > 0 {
return errors.New("params flag is only supported if the default module is enabled")
} else if len(moduleConfigs) > 0 {
return errors.New("module configs flag is only supported if the default module is enabled")
}
}

cacheStorage, err := newCache(cmd)
Expand All @@ -129,6 +136,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
minimal,
isConsumer,
params,
moduleConfigs,
)
if err != nil {
return err
Expand Down
7 changes: 6 additions & 1 deletion ignite/cmd/scaffold_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sc.ApplyModifications()
sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -75,6 +75,11 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)
session.Printf("\n🎉 New configs added to the module:\n\n- %s\n\n", strings.Join(configs, "\n- "))

Expand Down
7 changes: 6 additions & 1 deletion ignite/cmd/scaffold_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func messageHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sc.ApplyModifications()
sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -132,6 +132,11 @@ func messageHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)
session.Printf("\n🎉 Created a message `%[1]v`.\n\n", args[0])

Expand Down
35 changes: 16 additions & 19 deletions ignite/cmd/scaffold_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
flagDep = "dep"
flagIBC = "ibc"
flagParams = "params"
flagModuleConfigs = "module-configs"
flagIBCOrdering = "ordering"
flagRequireRegistration = "require-registration"
)
Expand Down Expand Up @@ -106,6 +107,7 @@ params.
c.Flags().String(flagIBCOrdering, "none", "channel ordering of the IBC module [none|ordered|unordered]")
c.Flags().Bool(flagRequireRegistration, false, "fail if module can't be registered")
c.Flags().StringSlice(flagParams, []string{}, "add module parameters")
c.Flags().StringSlice(flagModuleConfigs, []string{}, "add module configs")

return c
}
Expand All @@ -119,21 +121,12 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding))
defer session.End()

ibcModule, err := cmd.Flags().GetBool(flagIBC)
if err != nil {
return err
}

ibcOrdering, err := cmd.Flags().GetString(flagIBCOrdering)
if err != nil {
return err
}
requireRegistration, err := cmd.Flags().GetBool(flagRequireRegistration)
if err != nil {
return err
}
ibcModule, _ := cmd.Flags().GetBool(flagIBC)
ibcOrdering, _ := cmd.Flags().GetString(flagIBCOrdering)
requireRegistration, _ := cmd.Flags().GetBool(flagRequireRegistration)
params, _ := cmd.Flags().GetStringSlice(flagParams)

params, err := cmd.Flags().GetStringSlice(flagParams)
moduleConfigs, err := cmd.Flags().GetStringSlice(flagModuleConfigs)
if err != nil {
return err
}
Expand All @@ -145,6 +138,7 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {

options := []scaffolder.ModuleCreationOption{
scaffolder.WithParams(params),
scaffolder.WithModuleConfigs(moduleConfigs),
}

// Check if the module must be an IBC module
Expand All @@ -153,10 +147,7 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
}

// Get module dependencies
dependencies, err := cmd.Flags().GetStringSlice(flagDep)
if err != nil {
return err
}
dependencies, _ := cmd.Flags().GetStringSlice(flagDep)
if len(dependencies) > 0 {
var deps []modulecreate.Dependency

Expand Down Expand Up @@ -194,7 +185,8 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
return err
}
}
modificationsStr, err := sc.ApplyModifications()

sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -203,6 +195,11 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)

return session.Print(msg.String())
Expand Down
7 changes: 6 additions & 1 deletion ignite/cmd/scaffold_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func createPacketHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sc.ApplyModifications()
sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -95,6 +95,11 @@ func createPacketHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)
session.Printf("\n🎉 Created a packet `%[1]v`.\n\n", args[0])

Expand Down
7 changes: 6 additions & 1 deletion ignite/cmd/scaffold_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sc.ApplyModifications()
sm, err := sc.ApplyModifications()
if err != nil {
return err
}
Expand All @@ -77,6 +77,11 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error {
return err
}

modificationsStr, err := sm.String()
if err != nil {
return err
}

session.Println(modificationsStr)
session.Printf("\n🎉 New parameters added to the module:\n\n- %s\n\n", strings.Join(params, "\n- "))

Expand Down
Loading

0 comments on commit 7041fba

Please sign in to comment.