From c675f160b575d9f80ffd086f31191de6224fd6fd Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Thu, 28 Dec 2023 23:04:05 +0100 Subject: [PATCH 1/3] refactor getting accounts for CLI commands --- cmd/deposit.go | 6 ------ cmd/upgrade.go | 6 ------ cmd/vote.go | 6 ------ utils/binary.go | 11 ++++++++++- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/cmd/deposit.go b/cmd/deposit.go index ee99d7a..1041cac 100644 --- a/cmd/deposit.go +++ b/cmd/deposit.go @@ -21,12 +21,6 @@ If no proposal ID is given by the user, the latest proposal is queried and depos return } - if err = bin.GetAccounts(); err != nil { - bin.Logger.Error().Msgf("error getting accounts: %v", err) - - return - } - proposalID, err := gov.Deposit(bin, args) if err != nil { bin.Logger.Error().Msgf("error depositing: %v", err) diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 3e944f6..a7bd9cf 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -24,12 +24,6 @@ voting for it using all keys of in the keyring and having it pass.`, return } - if err = bin.GetAccounts(); err != nil { - bin.Logger.Error().Msgf("error getting accounts: %v", err) - - return - } - targetVersion := args[0] if matched, _ := regexp.MatchString(`v\d+\.\d+\.\d(-rc\d+)?`, targetVersion); !matched { bin.Logger.Error().Msgf("invalid target version: %s; please use the format vX.Y.Z(-rc*).", targetVersion) diff --git a/cmd/vote.go b/cmd/vote.go index 1f1b6e1..a75680f 100644 --- a/cmd/vote.go +++ b/cmd/vote.go @@ -21,12 +21,6 @@ If no proposal ID is passed, the latest proposal on chain is queried and used.`, return } - if err = bin.GetAccounts(); err != nil { - bin.Logger.Error().Msgf("error getting accounts: %v", err) - - return - } - proposalID, err := gov.SubmitAllVotes(bin, args) if err != nil { bin.Logger.Error().Msgf("error submitting votes: %v", err) diff --git a/utils/binary.go b/utils/binary.go index a8f2dd8..052c413 100644 --- a/utils/binary.go +++ b/utils/binary.go @@ -67,7 +67,16 @@ func NewEvmosTestingBinary() (*Binary, error) { defaultEvmosdHome := path.Join(userHome, ".tmp-evmosd") - return NewBinary(defaultEvmosdHome, "evmosd", logger) + bin, err := NewBinary(defaultEvmosdHome, "evmosd", logger) + if err != nil { + return nil, err + } + + if err = bin.GetAccounts(); err != nil { + return nil, err + } + + return bin, nil } // GetCodec returns the codec to be used for the client. From 26621da514077ba414ce43d702e48e13de47060e Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Thu, 28 Dec 2023 23:08:19 +0100 Subject: [PATCH 2/3] adjust changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e9f4c..9eb10f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## Unreleased + +### Improvements + +- [#32](https://github.com/MalteHerrmann/evmos-utils/pull/32) Minor refactor in CLI commands. + ## [v0.4.0](https://github.com/MalteHerrmann/evmos-utils/releases/tag/v0.4.0) - 2023-12-18 ### Features @@ -74,4 +80,4 @@ Ref: https://keepachangelog.com/en/1.0.0/ - Gets current block height of local node (at `http://localhost:26657`) - Submit a software upgrade proposal to a running local Evmos node for the target version -- Vote on the software proposal \ No newline at end of file +- Vote on the software proposal From f113e04b3a94eda05bf02a0565b32f18c57aea6b Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Thu, 28 Dec 2023 23:10:52 +0100 Subject: [PATCH 3/3] minor adjustment --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb10f7..e58af30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements -- [#32](https://github.com/MalteHerrmann/evmos-utils/pull/32) Minor refactor in CLI commands. +- [#32](https://github.com/MalteHerrmann/evmos-utils/pull/32) Minor refactor in CLI commands ## [v0.4.0](https://github.com/MalteHerrmann/evmos-utils/releases/tag/v0.4.0) - 2023-12-18