From d942df86a828335f45b1d6c0c73098eda7483739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20Albi?= Date: Fri, 28 Oct 2022 16:12:38 +0200 Subject: [PATCH] feat: add support to change spinner text using event updates (#2944) * refactor: change `StartSpinner` option to receive an optional text * feat: add progress update support for events and session print loop This change allows to print event texts that will be removed when the spinner stops or when another event status update text is printed. * refactor: add `ProgressUpdate` to some of the events This is required so the event updates are cleared once another event update is received or when the spinner stops. * refactor: rename event progress options * feat: add `cliui.StartSpinnerWithText` option to session * test: add test for event update * chore: update changelog * chore: updated some network commands to use progress update * chore: review corrections Co-authored-by: Alex Johnson Co-authored-by: Lucas Bertrand * chore: update changelog Co-authored-by: Alex Johnson Co-authored-by: Lucas Bertrand --- changelog.md | 1 + ignite/cmd/chain_build.go | 5 +++- ignite/cmd/chain_serve.go | 5 +++- ignite/cmd/cmd.go | 3 +++ ignite/cmd/generate_dart.go | 4 +-- ignite/cmd/generate_go.go | 4 +-- ignite/cmd/generate_openapi.go | 4 +-- ignite/cmd/generate_typescript_client.go | 4 +-- ignite/cmd/generate_vuex.go | 4 +-- ignite/cmd/network_reward_release.go | 4 +-- ignite/cmd/node_query_bank_balances.go | 3 +-- ignite/cmd/node_query_tx.go | 4 +-- ignite/cmd/node_tx_bank_send.go | 2 +- ignite/cmd/relayer_configure.go | 2 +- ignite/cmd/relayer_connect.go | 2 +- ignite/cmd/scaffold.go | 6 ++--- ignite/cmd/scaffold_band.go | 4 +-- ignite/cmd/scaffold_chain.go | 4 +-- ignite/cmd/scaffold_message.go | 4 +-- ignite/cmd/scaffold_module.go | 4 +-- ignite/cmd/scaffold_mwasm.go | 4 +-- ignite/cmd/scaffold_package.go | 4 +-- ignite/cmd/scaffold_query.go | 4 +-- ignite/cmd/scaffold_vue.go | 4 +-- ignite/pkg/cliui/clispinner/clispinner.go | 17 ++++++++++-- ignite/pkg/cliui/cliui.go | 26 ++++++++++++++++--- ignite/pkg/events/bus_test.go | 8 +++--- ignite/pkg/events/events.go | 22 +++++++++++----- ignite/pkg/events/events_test.go | 18 ++++++++++--- ignite/services/chain/build.go | 5 ++-- ignite/services/chain/generate.go | 10 +++---- ignite/services/chain/init.go | 4 ++- ignite/services/chain/serve.go | 16 ++++++------ ignite/services/network/campaign.go | 14 +++++----- ignite/services/network/launch.go | 12 ++++----- ignite/services/network/networkchain/init.go | 14 +++++----- .../network/networkchain/networkchain.go | 12 ++++----- .../services/network/networkchain/prepare.go | 4 +-- .../services/network/networkchain/simulate.go | 8 +++--- ignite/services/network/profile.go | 12 ++++----- ignite/services/network/publish.go | 2 +- ignite/services/network/queries.go | 22 ++++++++-------- ignite/services/network/request.go | 26 +++++++++---------- ignite/services/network/reward.go | 10 +++---- 44 files changed, 191 insertions(+), 160 deletions(-) diff --git a/changelog.md b/changelog.md index 8b8125b8e3..19d10daacf 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ - [#2958](https://github.com/ignite/cli/pull/2958) Support absolute paths for client code generation config paths. - [#2993](https://github.com/ignite/cli/pull/2993) Hide `ignite scaffold band` command and deprecate functionality. - [#2991](https://github.com/ignite/cli/pull/2991) Hide `ignite scaffold flutter` command and remove functionality. +- [#2944](https://github.com/ignite/cli/pull/2944) Add a new event "update" status option to `pkg/cliui`. ## [`v0.25.1`](https://github.com/ignite/cli/releases/tag/v0.25.1) diff --git a/ignite/cmd/chain_build.go b/ignite/cmd/chain_build.go index 555d8c2896..fffddc57eb 100644 --- a/ignite/cmd/chain_build.go +++ b/ignite/cmd/chain_build.go @@ -101,7 +101,10 @@ func chainBuildHandler(cmd *cobra.Command, _ []string) error { releaseTargets, _ = cmd.Flags().GetStringSlice(flagReleaseTargets) releasePrefix, _ = cmd.Flags().GetString(flagReleasePrefix) output, _ = cmd.Flags().GetString(flagOutput) - session = cliui.New(cliui.WithVerbosity(getVerbosity(cmd)), cliui.StartSpinner()) + session = cliui.New( + cliui.WithVerbosity(getVerbosity(cmd)), + cliui.StartSpinner(), + ) ) defer session.End() diff --git a/ignite/cmd/chain_serve.go b/ignite/cmd/chain_serve.go index c1c76f14f0..c3134147c8 100644 --- a/ignite/cmd/chain_serve.go +++ b/ignite/cmd/chain_serve.go @@ -71,7 +71,10 @@ production, you may want to run "appd start" manually. } func chainServeHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.WithVerbosity(getVerbosity(cmd)), cliui.StartSpinner()) + session := cliui.New( + cliui.WithVerbosity(getVerbosity(cmd)), + cliui.StartSpinner(), + ) defer session.End() chainOption := []chain.Option{ diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index f24f30c3bf..0de9eebe74 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -37,6 +37,9 @@ const ( checkVersionTimeout = time.Millisecond * 600 cacheFileName = "ignite_cache.db" + + statusGenerating = "Generating..." + statusQuerying = "Querying..." ) // New creates a new root command for `Ignite CLI` with its sub commands. diff --git a/ignite/cmd/generate_dart.go b/ignite/cmd/generate_dart.go index 27f935d2f8..3f2e07d94d 100644 --- a/ignite/cmd/generate_dart.go +++ b/ignite/cmd/generate_dart.go @@ -22,11 +22,9 @@ func NewGenerateDart() *cobra.Command { } func generateDartHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) defer session.End() - session.StartSpinner("Generating...") - c, err := newChainWithHomeFlags( cmd, chain.EnableThirdPartyModuleCodegen(), diff --git a/ignite/cmd/generate_go.go b/ignite/cmd/generate_go.go index 28725500c0..097ca45b4f 100644 --- a/ignite/cmd/generate_go.go +++ b/ignite/cmd/generate_go.go @@ -22,11 +22,9 @@ func NewGenerateGo() *cobra.Command { } func generateGoHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) defer session.End() - session.StartSpinner("Generating...") - c, err := newChainWithHomeFlags( cmd, chain.WithOutputer(session), diff --git a/ignite/cmd/generate_openapi.go b/ignite/cmd/generate_openapi.go index 598e30c6b9..ecfa3e677e 100644 --- a/ignite/cmd/generate_openapi.go +++ b/ignite/cmd/generate_openapi.go @@ -22,11 +22,9 @@ func NewGenerateOpenAPI() *cobra.Command { } func generateOpenAPIHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) defer session.End() - session.StartSpinner("Generating...") - c, err := newChainWithHomeFlags( cmd, chain.WithOutputer(session), diff --git a/ignite/cmd/generate_typescript_client.go b/ignite/cmd/generate_typescript_client.go index 4e76d1e615..371beabecc 100644 --- a/ignite/cmd/generate_typescript_client.go +++ b/ignite/cmd/generate_typescript_client.go @@ -23,11 +23,9 @@ func NewGenerateTSClient() *cobra.Command { } func generateTSClientHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) defer session.End() - session.StartSpinner("Generating...") - c, err := newChainWithHomeFlags( cmd, chain.EnableThirdPartyModuleCodegen(), diff --git a/ignite/cmd/generate_vuex.go b/ignite/cmd/generate_vuex.go index d9f4077773..9804a90b18 100644 --- a/ignite/cmd/generate_vuex.go +++ b/ignite/cmd/generate_vuex.go @@ -23,11 +23,9 @@ func NewGenerateVuex() *cobra.Command { } func generateVuexHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) defer session.End() - session.StartSpinner("Generating...") - c, err := newChainWithHomeFlags( cmd, chain.EnableThirdPartyModuleCodegen(), diff --git a/ignite/cmd/network_reward_release.go b/ignite/cmd/network_reward_release.go index 036570519c..f555765631 100644 --- a/ignite/cmd/network_reward_release.go +++ b/ignite/cmd/network_reward_release.go @@ -63,11 +63,9 @@ func networkRewardRelease(cmd *cobra.Command, args []string) (err error) { err = handleRelayerAccountErr(err) }() - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText("Setting up chains...")) defer session.End() - session.StartSpinner("Setting up chains...") - launchID, err := network.ParseID(args[0]) if err != nil { return err diff --git a/ignite/cmd/node_query_bank_balances.go b/ignite/cmd/node_query_bank_balances.go index d016656ca6..6174ab9e52 100644 --- a/ignite/cmd/node_query_bank_balances.go +++ b/ignite/cmd/node_query_bank_balances.go @@ -42,9 +42,8 @@ func nodeQueryBankBalancesHandler(cmd *cobra.Command, args []string) error { return err } - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusQuerying)) defer session.End() - session.StartSpinner("Querying...") balances, err := client.BankBalances(cmd.Context(), address, pagination) if err != nil { diff --git a/ignite/cmd/node_query_tx.go b/ignite/cmd/node_query_tx.go index 673a69d855..e4d1d7d1f3 100644 --- a/ignite/cmd/node_query_tx.go +++ b/ignite/cmd/node_query_tx.go @@ -20,11 +20,9 @@ func NewNodeQueryTx() *cobra.Command { } func nodeQueryTxHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusQuerying)) defer session.End() - session.StartSpinner("Querying...") - bz, err := hex.DecodeString(args[0]) if err != nil { return err diff --git a/ignite/cmd/node_tx_bank_send.go b/ignite/cmd/node_tx_bank_send.go index 255493d5f1..dc19c0fc11 100644 --- a/ignite/cmd/node_tx_bank_send.go +++ b/ignite/cmd/node_tx_bank_send.go @@ -53,7 +53,7 @@ func nodeTxBankSendHandler(cmd *cobra.Command, args []string) error { return err } - session := cliui.New(cliui.StartSpinner()) + session := cliui.New() defer session.End() if generateOnly { diff --git a/ignite/cmd/relayer_configure.go b/ignite/cmd/relayer_configure.go index 5e63a67ad3..5a5ed105f0 100644 --- a/ignite/cmd/relayer_configure.go +++ b/ignite/cmd/relayer_configure.go @@ -95,7 +95,7 @@ func relayerConfigureHandler(cmd *cobra.Command, _ []string) (err error) { err = handleRelayerAccountErr(err) }() - session := cliui.New(cliui.StartSpinner()) + session := cliui.New() defer session.End() ca, err := cosmosaccount.New( diff --git a/ignite/cmd/relayer_connect.go b/ignite/cmd/relayer_connect.go index c6dbbc9fcb..e3e2ac6079 100644 --- a/ignite/cmd/relayer_connect.go +++ b/ignite/cmd/relayer_connect.go @@ -33,7 +33,7 @@ func relayerConnectHandler(cmd *cobra.Command, args []string) (err error) { err = handleRelayerAccountErr(err) }() - session := cliui.New(cliui.StartSpinner()) + session := cliui.New() defer session.End() ca, err := cosmosaccount.New( diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index f7ef4e3964..eb5d2e0b7b 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -20,6 +20,8 @@ const ( flagNoSimulation = "no-simulation" flagResponse = "response" flagDescription = "desc" + + statusScaffolding = "Scaffolding..." ) // NewScaffold returns a command that groups scaffolding related sub commands. @@ -135,11 +137,9 @@ func scaffoldType( } } - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - sc, err := newApp(appPath) if err != nil { return err diff --git a/ignite/cmd/scaffold_band.go b/ignite/cmd/scaffold_band.go index 57ad7802e3..df6e35e9e5 100644 --- a/ignite/cmd/scaffold_band.go +++ b/ignite/cmd/scaffold_band.go @@ -47,11 +47,9 @@ func createBandchainHandler(cmd *cobra.Command, args []string) error { signer = flagGetSigner(cmd) ) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - module, err := cmd.Flags().GetString(flagModule) if err != nil { return err diff --git a/ignite/cmd/scaffold_chain.go b/ignite/cmd/scaffold_chain.go index 776288939e..b86dcd4ad1 100644 --- a/ignite/cmd/scaffold_chain.go +++ b/ignite/cmd/scaffold_chain.go @@ -81,11 +81,9 @@ about Cosmos SDK on https://docs.cosmos.network } func scaffoldChainHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - var ( name = args[0] addressPrefix = getAddressPrefix(cmd) diff --git a/ignite/cmd/scaffold_message.go b/ignite/cmd/scaffold_message.go index 81845b6c00..446fb393ac 100644 --- a/ignite/cmd/scaffold_message.go +++ b/ignite/cmd/scaffold_message.go @@ -87,11 +87,9 @@ func messageHandler(cmd *cobra.Command, args []string) error { withoutSimulation = flagGetNoSimulation(cmd) ) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - cacheStorage, err := newCache(cmd) if err != nil { return err diff --git a/ignite/cmd/scaffold_module.go b/ignite/cmd/scaffold_module.go index e93cf11f70..3c298b06d6 100644 --- a/ignite/cmd/scaffold_module.go +++ b/ignite/cmd/scaffold_module.go @@ -119,11 +119,9 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { appPath = flagGetPath(cmd) ) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - ibcModule, err := cmd.Flags().GetBool(flagIBC) if err != nil { return err diff --git a/ignite/cmd/scaffold_mwasm.go b/ignite/cmd/scaffold_mwasm.go index ad9a649fed..323807bedf 100644 --- a/ignite/cmd/scaffold_mwasm.go +++ b/ignite/cmd/scaffold_mwasm.go @@ -24,11 +24,9 @@ func NewScaffoldWasm() *cobra.Command { func scaffoldWasmHandler(cmd *cobra.Command, args []string) error { appPath := flagGetPath(cmd) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - cacheStorage, err := newCache(cmd) if err != nil { return err diff --git a/ignite/cmd/scaffold_package.go b/ignite/cmd/scaffold_package.go index 18cdc2a9d7..d5c3c2d6b4 100644 --- a/ignite/cmd/scaffold_package.go +++ b/ignite/cmd/scaffold_package.go @@ -45,11 +45,9 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { appPath = flagGetPath(cmd) ) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - module, err := cmd.Flags().GetString(flagModule) if err != nil { return err diff --git a/ignite/cmd/scaffold_query.go b/ignite/cmd/scaffold_query.go index 4c863c1bfe..93fec423ff 100644 --- a/ignite/cmd/scaffold_query.go +++ b/ignite/cmd/scaffold_query.go @@ -38,11 +38,9 @@ func NewScaffoldQuery() *cobra.Command { func queryHandler(cmd *cobra.Command, args []string) error { appPath := flagGetPath(cmd) - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - // Get the module to add the type into module, err := cmd.Flags().GetString(flagModule) if err != nil { diff --git a/ignite/cmd/scaffold_vue.go b/ignite/cmd/scaffold_vue.go index 7d6715c178..7a2ce397e8 100644 --- a/ignite/cmd/scaffold_vue.go +++ b/ignite/cmd/scaffold_vue.go @@ -24,11 +24,9 @@ func NewScaffoldVue() *cobra.Command { } func scaffoldVueHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinner()) + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - session.StartSpinner("Scaffolding...") - path := flagGetPath(cmd) if err := scaffolder.Vue(path); err != nil { return err diff --git a/ignite/pkg/cliui/clispinner/clispinner.go b/ignite/pkg/cliui/clispinner/clispinner.go index 675f846fc4..1a5c628a41 100644 --- a/ignite/pkg/cliui/clispinner/clispinner.go +++ b/ignite/pkg/cliui/clispinner/clispinner.go @@ -25,16 +25,24 @@ type ( Options struct { writer io.Writer + text string } ) -// WithWriter configures an output for a spinner +// WithWriter configures an output for a spinner. func WithWriter(w io.Writer) Option { return func(options *Options) { options.writer = w } } +// WithText configures the spinner text. +func WithText(text string) Option { + return func(options *Options) { + options.text = text + } +} + // New creates a new spinner. func New(options ...Option) *Spinner { o := Options{} @@ -42,9 +50,14 @@ func New(options ...Option) *Spinner { apply(&o) } + text := o.text + if text == "" { + text = DefaultText + } + spOptions := []spinner.Option{ spinner.WithColor(spinnerColor), - spinner.WithSuffix(" " + DefaultText), + spinner.WithSuffix(" " + text), } if o.writer != nil { diff --git a/ignite/pkg/cliui/cliui.go b/ignite/pkg/cliui/cliui.go index 565f155df1..e72dd6a128 100644 --- a/ignite/pkg/cliui/cliui.go +++ b/ignite/pkg/cliui/cliui.go @@ -20,8 +20,10 @@ type sessionOptions struct { stdout io.WriteCloser stderr io.WriteCloser - startSpinner bool - verbosity uilog.Verbosity + spinnerStart bool + spinnerText string + + verbosity uilog.Verbosity } // Session controls command line interaction with users. @@ -67,7 +69,16 @@ func WithVerbosity(v uilog.Verbosity) Option { // StartSpinner forces spinner to be spinning right after creation. func StartSpinner() Option { return func(s *Session) { - s.options.startSpinner = true + s.options.spinnerStart = true + } +} + +// StartSpinnerWithText forces spinner to be spinning right after creation +// with a custom status text. +func StartSpinnerWithText(text string) Option { + return func(s *Session) { + s.options.spinnerStart = true + s.options.spinnerText = text } } @@ -98,8 +109,12 @@ func New(options ...Option) *Session { session.out = uilog.NewOutput(logOptions...) - if session.options.startSpinner { + if session.options.spinnerStart { session.spinner = clispinner.New(clispinner.WithWriter(session.out.Stdout())) + + if session.options.spinnerText != "" { + session.spinner.SetText(session.options.spinnerText) + } } // The main loop that prints the events uses a wait group to block @@ -233,10 +248,13 @@ func (s *Session) handleEvents() { switch e.ProgressIndication { case events.IndicationStart: s.StartSpinner(e.String()) + case events.IndicationUpdate: + s.spinner.SetText(e.String()) case events.IndicationFinish: s.StopSpinner() fmt.Fprintf(stdout, "%s\n", e) default: + // The text printed here won't be removed when the spinner stops resume := s.PauseSpinner() fmt.Fprintf(stdout, "%s\n", e) resume() diff --git a/ignite/pkg/events/bus_test.go b/ignite/pkg/events/bus_test.go index f8f00d2d9b..d16c0b40fb 100644 --- a/ignite/pkg/events/bus_test.go +++ b/ignite/pkg/events/bus_test.go @@ -24,7 +24,7 @@ func TestBusSend(t *testing.T) { { name: "with options", message: "test", - options: []events.Option{events.ProgressStarted()}, + options: []events.Option{events.ProgressStart()}, progress: events.IndicationStart, }, } @@ -82,7 +82,7 @@ func TestBusSendInfo(t *testing.T) { { name: "with options", message: "test", - options: []events.Option{events.ProgressStarted()}, + options: []events.Option{events.ProgressStart()}, progress: events.IndicationStart, }, } @@ -121,7 +121,7 @@ func TestBusSendError(t *testing.T) { { name: "with options", message: "test", - options: []events.Option{events.ProgressStarted()}, + options: []events.Option{events.ProgressStart()}, progress: events.IndicationStart, }, } @@ -170,7 +170,7 @@ func TestBusSendView(t *testing.T) { { name: "with options", message: "test", - options: []events.Option{events.ProgressStarted()}, + options: []events.Option{events.ProgressStart()}, progress: events.IndicationStart, }, } diff --git a/ignite/pkg/events/events.go b/ignite/pkg/events/events.go index 7becaa3c8f..60508b4638 100644 --- a/ignite/pkg/events/events.go +++ b/ignite/pkg/events/events.go @@ -10,6 +10,7 @@ type ProgressIndication uint8 const ( IndicationNone ProgressIndication = iota IndicationStart + IndicationUpdate IndicationFinish ) @@ -22,25 +23,32 @@ type ( Verbose bool } - // Option event options + // Option event options. Option func(*Event) ) -// ProgressStarted sets ProgressIndication as started -func ProgressStarted() Option { +// ProgressStart indicates that the event starts the progress indicator. +func ProgressStart() Option { return func(e *Event) { e.ProgressIndication = IndicationStart } } -// ProgressFinished sets ProgressIndication as finished -func ProgressFinished() Option { +// ProgressUpdate indicates that the event updates the current progress. +func ProgressUpdate() Option { + return func(e *Event) { + e.ProgressIndication = IndicationUpdate + } +} + +// ProgressFinish indicates that the event finish the current progress. +func ProgressFinish() Option { return func(e *Event) { e.ProgressIndication = IndicationFinish } } -// Verbose sets high verbosity for the Event +// Verbose sets high verbosity for the Event. func Verbose() Option { return func(e *Event) { e.Verbose = true @@ -75,5 +83,5 @@ func (e Event) String() string { // InProgress returns true when the event is in progress. func (e Event) InProgress() bool { - return e.ProgressIndication == IndicationStart + return e.ProgressIndication == IndicationStart || e.ProgressIndication == IndicationUpdate } diff --git a/ignite/pkg/events/events_test.go b/ignite/pkg/events/events_test.go index 4de80eaf6b..ad3cdee9c9 100644 --- a/ignite/pkg/events/events_test.go +++ b/ignite/pkg/events/events_test.go @@ -21,19 +21,29 @@ func TestNew(t *testing.T) { event: events.Event{}, }, { - name: "in progress event", + name: "event start", message: msg, inProgress: true, - options: []events.Option{events.ProgressStarted()}, + options: []events.Option{events.ProgressStart()}, event: events.Event{ ProgressIndication: events.IndicationStart, Message: msg, }, }, { - name: "finished event", + name: "event update", + message: msg, + inProgress: true, + options: []events.Option{events.ProgressUpdate()}, + event: events.Event{ + ProgressIndication: events.IndicationUpdate, + Message: msg, + }, + }, + { + name: "event finish", message: msg, - options: []events.Option{events.ProgressFinished()}, + options: []events.Option{events.ProgressFinish()}, event: events.Event{ ProgressIndication: events.IndicationFinish, Message: msg, diff --git a/ignite/services/chain/build.go b/ignite/services/chain/build.go index 731e694c64..df367e3bf8 100644 --- a/ignite/services/chain/build.go +++ b/ignite/services/chain/build.go @@ -17,6 +17,7 @@ import ( "github.com/ignite/cli/ignite/pkg/cmdrunner/exec" "github.com/ignite/cli/ignite/pkg/cmdrunner/step" "github.com/ignite/cli/ignite/pkg/dirchange" + "github.com/ignite/cli/ignite/pkg/events" "github.com/ignite/cli/ignite/pkg/goanalysis" "github.com/ignite/cli/ignite/pkg/gocmd" "github.com/ignite/cli/ignite/pkg/xstrings" @@ -204,7 +205,7 @@ func (c *Chain) preBuild(ctx context.Context, cacheStorage cache.Storage) (build gocmd.FlagLdflags, gocmd.Ldflags(ldFlags...), } - c.ev.Send("📦 Installing dependencies...") + c.ev.Send("Installing dependencies...", events.ProgressUpdate()) // We do mod tidy before checking for checksum changes, because go.mod gets modified often // and the mod verify command is the expensive one anyway @@ -232,7 +233,7 @@ func (c *Chain) preBuild(ctx context.Context, cacheStorage cache.Storage) (build } } - c.ev.Send("🛠 Building the blockchain...") + c.ev.Send("Building the blockchain...", events.ProgressUpdate()) return buildFlags, nil } diff --git a/ignite/services/chain/generate.go b/ignite/services/chain/generate.go index f4edcfbae8..365d868709 100644 --- a/ignite/services/chain/generate.go +++ b/ignite/services/chain/generate.go @@ -121,7 +121,7 @@ func (c *Chain) Generate( return err } - c.ev.Send("Building proto...", events.ProgressStarted()) + c.ev.Send("Building proto...", events.ProgressUpdate()) options := []cosmosgen.Option{ cosmosgen.IncludeDirs(conf.Build.Proto.ThirdPartyPaths), @@ -223,7 +223,7 @@ func (c *Chain) Generate( c.ev.Send( fmt.Sprintf("Typescript client path: %s", tsClientPath), events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } @@ -231,7 +231,7 @@ func (c *Chain) Generate( c.ev.Send( fmt.Sprintf("Vuex stores path: %s", vuexPath), events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } @@ -239,7 +239,7 @@ func (c *Chain) Generate( c.ev.Send( fmt.Sprintf("Dart path: %s", dartPath), events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } @@ -247,7 +247,7 @@ func (c *Chain) Generate( c.ev.Send( fmt.Sprintf("OpenAPI path: %s", openAPIPath), events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } } diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index b19869b8c2..04742e43a1 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -12,6 +12,7 @@ import ( chaincmdrunner "github.com/ignite/cli/ignite/pkg/chaincmd/runner" "github.com/ignite/cli/ignite/pkg/cliui/view/accountview" "github.com/ignite/cli/ignite/pkg/confile" + "github.com/ignite/cli/ignite/pkg/events" ) const ( @@ -91,6 +92,8 @@ func (c *Chain) InitAccounts(ctx context.Context, conf *chainconfig.Config) erro return err } + c.ev.Send("Initializing accounts...", events.ProgressUpdate()) + var accounts accountview.Accounts // add accounts from config into genesis @@ -123,7 +126,6 @@ func (c *Chain) InitAccounts(ctx context.Context, conf *chainconfig.Config) erro } } - c.ev.Send("🗂 Initialize accounts...") c.ev.SendView(accounts) _, err = c.IssueGentx(ctx, createValidatorFromConfig(conf)) diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index 6e4704ce97..2382401481 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -171,7 +171,7 @@ func (c *Chain) Serve(ctx context.Context, cacheStorage cache.Storage, options . if c.served { c.served = false - c.ev.Send("💿 Saving genesis state...") + c.ev.Send("Saving genesis state...", events.ProgressUpdate()) // If serve has been stopped, save the genesis state if err := c.saveChainState(context.TODO(), commands); err != nil { @@ -193,12 +193,12 @@ func (c *Chain) Serve(ctx context.Context, cacheStorage cache.Storage, options . // Change error message to add a link to the configuration docs err = fmt.Errorf("%w\nsee: https://github.com/ignite/cli#configure", err) - c.ev.SendView(errorview.NewError(err), events.ProgressFinished()) + c.ev.SendView(errorview.NewError(err), events.ProgressFinish()) case errors.As(err, &buildErr): if serveOptions.quitOnFail { return err } - c.ev.SendView(errorview.NewError(err), events.ProgressFinished()) + c.ev.SendView(errorview.NewError(err), events.ProgressFinish()) case errors.As(err, &startErr): // Parse returned error logs parsedErr := startErr.ParseStartError() @@ -311,7 +311,7 @@ func (c *Chain) serve(ctx context.Context, cacheStorage cache.Storage, forceRese if forceReset || configModified { // if forceReset is set, we consider the app as being not initialized - c.ev.Send("🔄 Resetting the app state...") + c.ev.Send("Resetting the app state...", events.ProgressUpdate()) isInit = false } } @@ -367,7 +367,7 @@ func (c *Chain) serve(ctx context.Context, cacheStorage cache.Storage, forceRese // init phase // nolint:gocritic if !isInit || (appModified && !exportGenesisExists) { - c.ev.Send("💿 Initializing the app...") + c.ev.Send("Initializing the app...", events.ProgressUpdate()) if err := c.Init(ctx, true); err != nil { return err @@ -375,7 +375,7 @@ func (c *Chain) serve(ctx context.Context, cacheStorage cache.Storage, forceRese } else if appModified { // if the chain is already initialized but the source has been modified // we reset the chain database and import the genesis state - c.ev.Send("💿 Existent genesis detected, restoring the database...") + c.ev.Send("Existent genesis detected, restoring the database...", events.ProgressUpdate()) if err := commands.UnsafeReset(ctx); err != nil { return err @@ -385,7 +385,7 @@ func (c *Chain) serve(ctx context.Context, cacheStorage cache.Storage, forceRese return err } } else { - c.ev.Send("▶ Restarting existing app...") + c.ev.Send("Restarting existing app...", events.ProgressUpdate()) } // save checksums @@ -459,7 +459,7 @@ func (c *Chain) start(ctx context.Context, config *chainconfig.Config) error { c.ev.Send( fmt.Sprintf("Tendermint node: %s", rpcAddr), events.Icon(icons.Earth), - events.ProgressFinished(), + events.ProgressFinish(), ) c.ev.Send( fmt.Sprintf("Blockchain API: %s", apiAddr), diff --git a/ignite/services/network/campaign.go b/ignite/services/network/campaign.go index 0cc9cf4463..e62df8f68f 100644 --- a/ignite/services/network/campaign.go +++ b/ignite/services/network/campaign.go @@ -47,7 +47,7 @@ func WithCampaignTotalSupply(totalSupply sdk.Coins) Prop { // Campaign fetches the campaign from Network func (n Network) Campaign(ctx context.Context, campaignID uint64) (networktypes.Campaign, error) { - n.ev.Send("Fetching campaign information", events.ProgressStarted()) + n.ev.Send("Fetching campaign information", events.ProgressStart()) res, err := n.campaignQuery.Campaign(ctx, &campaigntypes.QueryGetCampaignRequest{ CampaignID: campaignID, }) @@ -63,7 +63,7 @@ func (n Network) Campaign(ctx context.Context, campaignID uint64) (networktypes. func (n Network) Campaigns(ctx context.Context) ([]networktypes.Campaign, error) { var campaigns []networktypes.Campaign - n.ev.Send("Fetching campaigns information", events.ProgressStarted()) + n.ev.Send("Fetching campaigns information", events.ProgressStart()) res, err := n.campaignQuery.CampaignAll(ctx, &campaigntypes.QueryAllCampaignRequest{}) if err != nil { return campaigns, err @@ -79,7 +79,7 @@ func (n Network) Campaigns(ctx context.Context) ([]networktypes.Campaign, error) // CreateCampaign creates a campaign in Network func (n Network) CreateCampaign(ctx context.Context, name, metadata string, totalSupply sdk.Coins) (uint64, error) { - n.ev.Send(fmt.Sprintf("Creating campaign %s", name), events.ProgressStarted()) + n.ev.Send(fmt.Sprintf("Creating campaign %s", name), events.ProgressStart()) addr, err := n.account.Address(networktypes.SPN) if err != nil { return 0, err @@ -112,7 +112,7 @@ func (n Network) InitializeMainnet( sourceHash string, mainnetChainID string, ) (uint64, error) { - n.ev.Send("Initializing the mainnet campaign", events.ProgressStarted()) + n.ev.Send("Initializing the mainnet campaign", events.ProgressStart()) addr, err := n.account.Address(networktypes.SPN) if err != nil { return 0, err @@ -136,7 +136,7 @@ func (n Network) InitializeMainnet( return 0, err } - n.ev.Send(fmt.Sprintf("Campaign %d initialized on mainnet", campaignID), events.ProgressFinished()) + n.ev.Send(fmt.Sprintf("Campaign %d initialized on mainnet", campaignID), events.ProgressFinish()) return initMainnetRes.MainnetID, nil } @@ -153,7 +153,7 @@ func (n Network) UpdateCampaign( apply(&p) } - n.ev.Send(fmt.Sprintf("Updating the campaign %d", id), events.ProgressStarted()) + n.ev.Send(fmt.Sprintf("Updating the campaign %d", id), events.ProgressStart()) account, err := n.account.Address(networktypes.SPN) if err != nil { return err @@ -179,6 +179,6 @@ func (n Network) UpdateCampaign( if _, err := n.cosmos.BroadcastTx(ctx, n.account, msgs...); err != nil { return err } - n.ev.Send(fmt.Sprintf("Campaign %d updated", id), events.ProgressFinished()) + n.ev.Send(fmt.Sprintf("Campaign %d updated", id), events.ProgressFinish()) return nil } diff --git a/ignite/services/network/launch.go b/ignite/services/network/launch.go index ddf6573182..00814c574d 100644 --- a/ignite/services/network/launch.go +++ b/ignite/services/network/launch.go @@ -28,7 +28,7 @@ func (n Network) LaunchParams(ctx context.Context) (launchtypes.Params, error) { // TriggerLaunch launches a chain as a coordinator func (n Network) TriggerLaunch(ctx context.Context, launchID uint64, launchTime time.Time) error { - n.ev.Send(fmt.Sprintf("Launching chain %d", launchID), events.ProgressStarted()) + n.ev.Send(fmt.Sprintf("Launching chain %d", launchID), events.ProgressStart()) params, err := n.LaunchParams(ctx) if err != nil { return err @@ -57,7 +57,7 @@ func (n Network) TriggerLaunch(ctx context.Context, launchID uint64, launchTime } msg := launchtypes.NewMsgTriggerLaunch(address, launchID, launchTime) - n.ev.Send("Setting launch time", events.ProgressStarted()) + n.ev.Send("Setting launch time", events.ProgressUpdate()) res, err := n.cosmos.BroadcastTx(ctx, n.account, msg) if err != nil { return err @@ -70,14 +70,14 @@ func (n Network) TriggerLaunch(ctx context.Context, launchID uint64, launchTime n.ev.Send( fmt.Sprintf("Chain %d will be launched on %s", launchID, launchTime), - events.ProgressFinished(), + events.ProgressFinish(), ) return nil } // RevertLaunch reverts a launched chain as a coordinator func (n Network) RevertLaunch(ctx context.Context, launchID uint64, chain Chain) error { - n.ev.Send(fmt.Sprintf("Reverting launched chain %d", launchID), events.ProgressStarted()) + n.ev.Send(fmt.Sprintf("Reverting launched chain %d", launchID), events.ProgressStart()) address, err := n.account.Address(networktypes.SPN) if err != nil { @@ -92,9 +92,9 @@ func (n Network) RevertLaunch(ctx context.Context, launchID uint64, chain Chain) n.ev.Send( fmt.Sprintf("Chain %d launch was reverted", launchID), - events.ProgressFinished(), + events.ProgressFinish(), ) - n.ev.Send("Genesis time was reset", events.ProgressFinished()) + n.ev.Send("Genesis time was reset", events.ProgressFinish()) return nil } diff --git a/ignite/services/network/networkchain/init.go b/ignite/services/network/networkchain/init.go index 8fe201b23a..a9bd196023 100644 --- a/ignite/services/network/networkchain/init.go +++ b/ignite/services/network/networkchain/init.go @@ -29,13 +29,13 @@ func (c *Chain) Init(ctx context.Context, cacheStorage cache.Storage) error { return err } - c.ev.Send("Initializing the blockchain", events.ProgressStarted()) + c.ev.Send("Initializing the blockchain", events.ProgressStart()) if err = c.chain.Init(ctx, false); err != nil { return err } - c.ev.Send("Blockchain initialized", events.ProgressFinished()) + c.ev.Send("Blockchain initialized", events.ProgressFinish()) // initialize and verify the genesis if err = c.initGenesis(ctx); err != nil { @@ -49,7 +49,7 @@ func (c *Chain) Init(ctx context.Context, cacheStorage cache.Storage) error { // initGenesis creates the initial genesis of the genesis depending on the initial genesis type (default, url, ...) func (c *Chain) initGenesis(ctx context.Context) error { - c.ev.Send("Computing the Genesis", events.ProgressStarted()) + c.ev.Send("Computing the Genesis", events.ProgressStart()) genesisPath, err := c.chain.GenesisPath() if err != nil { @@ -64,7 +64,7 @@ func (c *Chain) initGenesis(ctx context.Context) error { // if the blockchain has a genesis URL, the initial genesis is fetched from the URL // otherwise, the default genesis is used, which requires no action since the default genesis is generated from the init command if c.genesisURL != "" { - c.ev.Send("Fetching custom Genesis from URL", events.ProgressStarted()) + c.ev.Send("Fetching custom Genesis from URL", events.ProgressUpdate()) genesis, err := cosmosgenesis.FromURL(ctx, c.genesisURL, genesisPath) if err != nil { return err @@ -73,10 +73,10 @@ func (c *Chain) initGenesis(ctx context.Context) error { if genesis.TarballPath() != "" { c.ev.Send( fmt.Sprintf("Extracted custom Genesis from tarball at %s", genesis.TarballPath()), - events.ProgressFinished(), + events.ProgressFinish(), ) } else { - c.ev.Send("Custom Genesis JSON from URL fetched", events.ProgressFinished()) + c.ev.Send("Custom Genesis JSON from URL fetched", events.ProgressFinish()) } hash, err := genesis.Hash() @@ -120,7 +120,7 @@ func (c *Chain) initGenesis(ctx context.Context) error { return err } - c.ev.Send("Genesis initialized", events.ProgressFinished()) + c.ev.Send("Genesis initialized", events.ProgressFinish()) return nil } diff --git a/ignite/services/network/networkchain/networkchain.go b/ignite/services/network/networkchain/networkchain.go index ce35fe53b6..47bfbbb58b 100644 --- a/ignite/services/network/networkchain/networkchain.go +++ b/ignite/services/network/networkchain/networkchain.go @@ -151,15 +151,15 @@ func New(ctx context.Context, ar cosmosaccount.Registry, source SourceOption, op apply(c) } - c.ev.Send("Fetching the source code", events.ProgressStarted()) + c.ev.Send("Fetching the source code", events.ProgressStart()) var err error if c.path, c.hash, err = fetchSource(ctx, c.url, c.ref, c.hash); err != nil { return nil, err } - c.ev.Send("Source code fetched", events.ProgressFinished()) - c.ev.Send("Setting up the blockchain", events.ProgressStarted()) + c.ev.Send("Source code fetched", events.ProgressFinish()) + c.ev.Send("Setting up the blockchain", events.ProgressStart()) chainOption := []chain.Option{ chain.ID(c.id), @@ -188,7 +188,7 @@ func New(ctx context.Context, ar cosmosaccount.Registry, source SourceOption, op } c.chain = chain - c.ev.Send("Blockchain set up", events.ProgressFinished()) + c.ev.Send("Blockchain set up", events.ProgressFinish()) return c, nil } @@ -322,14 +322,14 @@ func (c *Chain) Build(ctx context.Context, cacheStorage cache.Storage) (binaryNa } } - c.ev.Send("Building the chain's binary", events.ProgressStarted()) + c.ev.Send("Building the chain's binary", events.ProgressStart()) // build binary if binaryName, err = c.chain.Build(ctx, cacheStorage, "", true); err != nil { return "", err } - c.ev.Send("Chain's binary built", events.ProgressFinished()) + c.ev.Send("Chain's binary built", events.ProgressFinish()) // cache built binary for launch id if c.launchID != 0 { diff --git a/ignite/services/network/networkchain/prepare.go b/ignite/services/network/networkchain/prepare.go index f5325071b5..d59aa3b7de 100644 --- a/ignite/services/network/networkchain/prepare.go +++ b/ignite/services/network/networkchain/prepare.go @@ -95,7 +95,7 @@ func (c Chain) buildGenesis( lastBlockHeight, consumerUnbondingTime int64, ) error { - c.ev.Send("Building the genesis", events.ProgressStarted()) + c.ev.Send("Building the genesis", events.ProgressStart()) addressPrefix, err := c.detectPrefix(ctx) if err != nil { @@ -146,7 +146,7 @@ func (c Chain) buildGenesis( } } - c.ev.Send("Genesis built", events.ProgressFinished()) + c.ev.Send("Genesis built", events.ProgressFinish()) return nil } diff --git a/ignite/services/network/networkchain/simulate.go b/ignite/services/network/networkchain/simulate.go index c2f86caf35..ba97e10ccf 100644 --- a/ignite/services/network/networkchain/simulate.go +++ b/ignite/services/network/networkchain/simulate.go @@ -36,7 +36,7 @@ func (c Chain) SimulateRequests( gi networktypes.GenesisInformation, reqs []networktypes.Request, ) (err error) { - c.ev.Send("Verifying requests format", events.ProgressStarted()) + c.ev.Send("Verifying requests format", events.ProgressStart()) for _, req := range reqs { // static verification of the request if err := networktypes.VerifyRequest(req); err != nil { @@ -49,7 +49,7 @@ func (c Chain) SimulateRequests( return err } } - c.ev.Send("Requests format verified", events.ProgressFinished()) + c.ev.Send("Requests format verified", events.ProgressFinish()) // prepare the chain with the requests if err := c.Prepare( @@ -64,11 +64,11 @@ func (c Chain) SimulateRequests( return err } - c.ev.Send("Trying starting the network with the requests", events.ProgressStarted()) + c.ev.Send("Trying starting the network with the requests", events.ProgressStart()) if err := c.simulateChainStart(ctx); err != nil { return err } - c.ev.Send("The network can be started", events.ProgressFinished()) + c.ev.Send("The network can be started", events.ProgressFinish()) return nil } diff --git a/ignite/services/network/profile.go b/ignite/services/network/profile.go index a81f3deba4..350a6ca4f3 100644 --- a/ignite/services/network/profile.go +++ b/ignite/services/network/profile.go @@ -16,7 +16,7 @@ import ( // CoordinatorIDByAddress returns the CoordinatorByAddress from SPN func (n Network) CoordinatorIDByAddress(ctx context.Context, address string) (uint64, error) { - n.ev.Send("Fetching coordinator by address", events.ProgressStarted()) + n.ev.Send("Fetching coordinator by address", events.ProgressStart()) resCoordByAddr, err := n.profileQuery. CoordinatorByAddress(ctx, &profiletypes.QueryGetCoordinatorByAddressRequest{ @@ -35,7 +35,7 @@ func (n Network) CoordinatorIDByAddress(ctx context.Context, address string) (ui // SetCoordinatorDescription set the description of a coordindator // or creates the coordinator if it doesn't exist yet for the sender address func (n Network) SetCoordinatorDescription(ctx context.Context, description profiletypes.CoordinatorDescription) error { - n.ev.Send("Setting coordinator description", events.ProgressStarted()) + n.ev.Send("Setting coordinator description", events.ProgressStart()) addr, err := n.account.Address(networktypes.SPN) if err != nil { @@ -78,7 +78,7 @@ func (n Network) SetCoordinatorDescription(ctx context.Context, description prof // Coordinator returns the Coordinator by address from SPN func (n Network) Coordinator(ctx context.Context, address string) (networktypes.Coordinator, error) { - n.ev.Send("Fetching coordinator details", events.ProgressStarted()) + n.ev.Send("Fetching coordinator details", events.ProgressStart()) coordinatorID, err := n.CoordinatorIDByAddress(ctx, address) if err != nil { return networktypes.Coordinator{}, err @@ -99,7 +99,7 @@ func (n Network) Coordinator(ctx context.Context, address string) (networktypes. // SetValidatorDescription set a validator profile. func (n Network) SetValidatorDescription(ctx context.Context, validator profiletypes.Validator) error { - n.ev.Send("Setting validator description", events.ProgressStarted()) + n.ev.Send("Setting validator description", events.ProgressStart()) addr, err := n.account.Address(networktypes.SPN) if err != nil { @@ -126,7 +126,7 @@ func (n Network) SetValidatorDescription(ctx context.Context, validator profilet // Validator returns the Validator by address from SPN func (n Network) Validator(ctx context.Context, address string) (networktypes.Validator, error) { - n.ev.Send("Fetching validator description", events.ProgressStarted()) + n.ev.Send("Fetching validator description", events.ProgressStart()) res, err := n.profileQuery. Validator(ctx, &profiletypes.QueryGetValidatorRequest{ @@ -143,7 +143,7 @@ func (n Network) Validator(ctx context.Context, address string) (networktypes.Va // Balances returns the all balances by address from SPN func (n Network) Balances(ctx context.Context, address string) (sdk.Coins, error) { - n.ev.Send("Fetching address balances", events.ProgressStarted()) + n.ev.Send("Fetching address balances", events.ProgressStart()) res, err := banktypes.NewQueryClient(n.cosmos.Context()).AllBalances(ctx, &banktypes.QueryAllBalancesRequest{ Address: address, diff --git a/ignite/services/network/publish.go b/ignite/services/network/publish.go index f5970359de..5c88383f9e 100644 --- a/ignite/services/network/publish.go +++ b/ignite/services/network/publish.go @@ -142,7 +142,7 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption) } campaignID = o.campaignID - n.ev.Send("Publishing the network", events.ProgressStarted()) + n.ev.Send("Publishing the network", events.ProgressStart()) // a coordinator profile is necessary to publish a chain // if the user doesn't have an associated coordinator profile, we create one diff --git a/ignite/services/network/queries.go b/ignite/services/network/queries.go index cda2cd8474..19c396f769 100644 --- a/ignite/services/network/queries.go +++ b/ignite/services/network/queries.go @@ -24,7 +24,7 @@ var ErrObjectNotFound = errors.New("query object not found") // ChainLaunch fetches the chain launch from Network by launch id. func (n Network) ChainLaunch(ctx context.Context, id uint64) (networktypes.ChainLaunch, error) { - n.ev.Send("Fetching chain information", events.ProgressStarted()) + n.ev.Send("Fetching chain information", events.ProgressStart()) res, err := n.launchQuery. Chain(ctx, @@ -43,7 +43,7 @@ func (n Network) ChainLaunch(ctx context.Context, id uint64) (networktypes.Chain func (n Network) ChainLaunchesWithReward(ctx context.Context, pagination *query.PageRequest) ([]networktypes.ChainLaunch, error) { g, ctx := errgroup.WithContext(ctx) - n.ev.Send("Fetching chains information", events.ProgressStarted()) + n.ev.Send("Fetching chains information", events.ProgressStart()) res, err := n.launchQuery. ChainAll(ctx, &launchtypes.QueryAllChainRequest{ Pagination: pagination, @@ -52,7 +52,7 @@ func (n Network) ChainLaunchesWithReward(ctx context.Context, pagination *query. return nil, err } - n.ev.Send("Fetching reward information", events.ProgressStarted()) + n.ev.Send("Fetching reward information", events.ProgressUpdate()) var chainLaunches []networktypes.ChainLaunch var mu sync.Mutex @@ -104,7 +104,7 @@ func (n Network) GenesisInformation(ctx context.Context, launchID uint64) (gi ne // GenesisAccounts returns the list of approved genesis accounts for a launch from SPN func (n Network) GenesisAccounts(ctx context.Context, launchID uint64) (genAccs []networktypes.GenesisAccount, err error) { - n.ev.Send("Fetching genesis accounts", events.ProgressStarted()) + n.ev.Send("Fetching genesis accounts", events.ProgressStart()) res, err := n.launchQuery. GenesisAccountAll(ctx, &launchtypes.QueryAllGenesisAccountRequest{ @@ -124,7 +124,7 @@ func (n Network) GenesisAccounts(ctx context.Context, launchID uint64) (genAccs // VestingAccounts returns the list of approved genesis vesting accounts for a launch from SPN func (n Network) VestingAccounts(ctx context.Context, launchID uint64) (vestingAccs []networktypes.VestingAccount, err error) { - n.ev.Send("Fetching genesis vesting accounts", events.ProgressStarted()) + n.ev.Send("Fetching genesis vesting accounts", events.ProgressStart()) res, err := n.launchQuery. VestingAccountAll(ctx, &launchtypes.QueryAllVestingAccountRequest{ @@ -149,7 +149,7 @@ func (n Network) VestingAccounts(ctx context.Context, launchID uint64) (vestingA // GenesisValidators returns the list of approved genesis validators for a launch from SPN func (n Network) GenesisValidators(ctx context.Context, launchID uint64) (genVals []networktypes.GenesisValidator, err error) { - n.ev.Send("Fetching genesis validators", events.ProgressStarted()) + n.ev.Send("Fetching genesis validators", events.ProgressStart()) res, err := n.launchQuery. GenesisValidatorAll(ctx, &launchtypes.QueryAllGenesisValidatorRequest{ @@ -175,7 +175,7 @@ func (n Network) MainnetAccount( ) (acc networktypes.MainnetAccount, err error) { n.ev.Send( fmt.Sprintf("Fetching campaign %d mainnet account %s", campaignID, address), - events.ProgressStarted(), + events.ProgressStart(), ) res, err := n.campaignQuery. MainnetAccount(ctx, @@ -195,7 +195,7 @@ func (n Network) MainnetAccount( // MainnetAccounts returns the list of campaign mainnet accounts for a launch from SPN func (n Network) MainnetAccounts(ctx context.Context, campaignID uint64) (genAccs []networktypes.MainnetAccount, err error) { - n.ev.Send("Fetching campaign mainnet accounts", events.ProgressStarted()) + n.ev.Send("Fetching campaign mainnet accounts", events.ProgressStart()) res, err := n.campaignQuery. MainnetAccountAll(ctx, &campaigntypes.QueryAllMainnetAccountRequest{ @@ -214,7 +214,7 @@ func (n Network) MainnetAccounts(ctx context.Context, campaignID uint64) (genAcc } func (n Network) GenesisAccount(ctx context.Context, launchID uint64, address string) (networktypes.GenesisAccount, error) { - n.ev.Send("Fetching genesis accounts", events.ProgressStarted()) + n.ev.Send("Fetching genesis accounts", events.ProgressStart()) res, err := n.launchQuery.GenesisAccount(ctx, &launchtypes.QueryGetGenesisAccountRequest{ LaunchID: launchID, Address: address, @@ -228,7 +228,7 @@ func (n Network) GenesisAccount(ctx context.Context, launchID uint64, address st } func (n Network) VestingAccount(ctx context.Context, launchID uint64, address string) (networktypes.VestingAccount, error) { - n.ev.Send("Fetching vesting accounts", events.ProgressStarted()) + n.ev.Send("Fetching vesting accounts", events.ProgressStart()) res, err := n.launchQuery.VestingAccount(ctx, &launchtypes.QueryGetVestingAccountRequest{ LaunchID: launchID, Address: address, @@ -242,7 +242,7 @@ func (n Network) VestingAccount(ctx context.Context, launchID uint64, address st } func (n Network) GenesisValidator(ctx context.Context, launchID uint64, address string) (networktypes.GenesisValidator, error) { - n.ev.Send("Fetching genesis validator", events.ProgressStarted()) + n.ev.Send("Fetching genesis validator", events.ProgressStart()) res, err := n.launchQuery.GenesisValidator(ctx, &launchtypes.QueryGetGenesisValidatorRequest{ LaunchID: launchID, Address: address, diff --git a/ignite/services/network/request.go b/ignite/services/network/request.go index 36b954cf7d..88c3f1fe5a 100644 --- a/ignite/services/network/request.go +++ b/ignite/services/network/request.go @@ -78,7 +78,7 @@ func (n Network) RequestFromIDs(ctx context.Context, launchID uint64, requestIDs // SubmitRequest submits reviewals for proposals in batch for chain. func (n Network) SubmitRequest(ctx context.Context, launchID uint64, reviewal ...Reviewal) error { - n.ev.Send("Submitting requests...", events.ProgressStarted()) + n.ev.Send("Submitting requests...", events.ProgressStart()) addr, err := n.account.Address(networktypes.SPN) if err != nil { @@ -126,7 +126,7 @@ func (n Network) SendAccountRequest( ), ) - n.ev.Send("Broadcasting account transactions", events.ProgressStarted()) + n.ev.Send("Broadcasting account transactions", events.ProgressStart()) res, err := n.cosmos.BroadcastTx(ctx, n.account, msg) if err != nil { @@ -142,13 +142,13 @@ func (n Network) SendAccountRequest( n.ev.Send( "Account added to the network by the coordinator!", events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } else { n.ev.Send( fmt.Sprintf("Request %d to add account to the network has been submitted!", requestRes.RequestID), events.Icon(icons.Bullet), - events.ProgressFinished(), + events.ProgressFinish(), ) } return nil @@ -181,7 +181,7 @@ func (n Network) SendValidatorRequest( ), ) - n.ev.Send("Broadcasting validator transaction", events.ProgressStarted()) + n.ev.Send("Broadcasting validator transaction", events.ProgressStart()) res, err := n.cosmos.BroadcastTx(ctx, n.account, msg) if err != nil { @@ -194,11 +194,11 @@ func (n Network) SendValidatorRequest( } if requestRes.AutoApproved { - n.ev.Send("Validator added to the network by the coordinator!", events.ProgressFinished()) + n.ev.Send("Validator added to the network by the coordinator!", events.ProgressFinish()) } else { n.ev.Send( fmt.Sprintf("Request %d to join the network as a validator has been submitted!", requestRes.RequestID), - events.ProgressFinished(), + events.ProgressFinish(), ) } return nil @@ -223,7 +223,7 @@ func (n Network) SendValidatorRemoveRequest( ), ) - n.ev.Send("Broadcasting transaction", events.ProgressStarted()) + n.ev.Send("Broadcasting transaction", events.ProgressStart()) res, err := n.cosmos.BroadcastTx(ctx, n.account, msg) if err != nil { @@ -236,13 +236,13 @@ func (n Network) SendValidatorRemoveRequest( } if requestRes.AutoApproved { - n.ev.Send("Validator removed from network by the coordinator!", events.ProgressFinished()) + n.ev.Send("Validator removed from network by the coordinator!", events.ProgressFinish()) } else { n.ev.Send( fmt.Sprintf( "Request %d to remove validator from the network has been submitted!", requestRes.RequestID, ), - events.ProgressFinished(), + events.ProgressFinish(), ) } return nil @@ -267,7 +267,7 @@ func (n Network) SendAccountRemoveRequest( ), ) - n.ev.Send("Broadcasting transaction", events.ProgressStarted()) + n.ev.Send("Broadcasting transaction", events.ProgressStart()) res, err := n.cosmos.BroadcastTx(ctx, n.account, msg) if err != nil { @@ -280,13 +280,13 @@ func (n Network) SendAccountRemoveRequest( } if requestRes.AutoApproved { - n.ev.Send("Account removed from network by the coordinator!", events.ProgressFinished()) + n.ev.Send("Account removed from network by the coordinator!", events.ProgressFinish()) } else { n.ev.Send( fmt.Sprintf( "Request %d to remove account from the network has been submitted!", requestRes.RequestID, ), - events.ProgressFinished(), + events.ProgressFinish(), ) } return nil diff --git a/ignite/services/network/reward.go b/ignite/services/network/reward.go index df89facd69..d0784bc952 100644 --- a/ignite/services/network/reward.go +++ b/ignite/services/network/reward.go @@ -17,7 +17,7 @@ import ( func (n Network) SetReward(ctx context.Context, launchID uint64, lastRewardHeight int64, coins sdk.Coins) error { n.ev.Send( fmt.Sprintf("Setting reward %s to the chain %d at height %d", coins, launchID, lastRewardHeight), - events.ProgressStarted(), + events.ProgressStart(), ) addr, err := n.account.Address(networktypes.SPN) @@ -42,17 +42,17 @@ func (n Network) SetReward(ctx context.Context, launchID uint64, lastRewardHeigh } if setRewardRes.PreviousCoins.Empty() { - n.ev.Send("The reward pool was empty", events.Icon(icons.Info), events.ProgressFinished()) + n.ev.Send("The reward pool was empty", events.Icon(icons.Info), events.ProgressFinish()) } else { n.ev.Send( fmt.Sprintf("Previous reward pool %s at height %d is overwritten", coins, lastRewardHeight), events.Icon(icons.Info), - events.ProgressFinished(), + events.ProgressFinish(), ) } if setRewardRes.NewCoins.Empty() { - n.ev.Send("The reward pool is removed", events.ProgressFinished()) + n.ev.Send("The reward pool is removed", events.ProgressFinish()) } else { n.ev.Send( fmt.Sprintf( @@ -61,7 +61,7 @@ func (n Network) SetReward(ctx context.Context, launchID uint64, lastRewardHeigh lastRewardHeight, launchID, ), - events.ProgressFinished(), + events.ProgressFinish(), ) } return nil