-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc CLI fixes #812
Misc CLI fixes #812
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #812 +/- ##
========================================
Coverage 65.18% 65.18%
========================================
Files 67 67
Lines 3539 3539
========================================
Hits 2307 2307
Misses 1045 1045
Partials 187 187 |
ae87ed2
to
a13a4d4
Compare
Ref #807 |
6155d45
to
4d4a7ee
Compare
Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff, few comments herein also we should include tests for NextSequence and AutoSequence
client/context/viper.go
Outdated
if err == nil { | ||
var doc tmtypes.GenesisDoc | ||
err = json.Unmarshal(bz, &doc) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad practice to nest if statements like this. I understand that we don't return an error in this function so you are nesting the operations but this suggests to me that this nest should be a seperate function which does return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updated.
client/context/viper.go
Outdated
|
||
// Automatically set sequence number | ||
func AutoSequence(ctx core.CoreContext) (core.CoreContext, error) { | ||
if !viper.IsSet(client.FlagSequence) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing with the nesting here, instead you could check the opposite and just return if it's true:
if viper.IsSet(client.FlagSequence) {
return ctx nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
client/context/viper.go
Outdated
} | ||
|
||
// Automatically set sequence number | ||
func AutoSequence(ctx core.CoreContext) (core.CoreContext, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name is slightly misleading because it's not always auto-sequencing it's only sequencing when there isn't a sequence number provided - but I get that you're trying to avoid dup code in all the command functions.. Maybe a more appropriate name would be SetSequence
or EnsureSequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to EnsureSequence
.
client/core/context.go
Outdated
@@ -48,3 +52,13 @@ func (c CoreContext) WithClient(client rpcclient.Client) CoreContext { | |||
c.Client = client | |||
return c | |||
} | |||
|
|||
func (c CoreContext) WithDecoder(decoder sdk.AccountDecoder) CoreContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment headers - what's dis stuff doing anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes it easier to change context parameters one-at-a-time (the IBC module uses these functions quite a bit, for example).
Comment headers added.
client/core/context.go
Outdated
return c | ||
} | ||
|
||
func (c CoreContext) WithAccountStore(accountStore string) CoreContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header added.
client/core/core.go
Outdated
@@ -137,6 +140,24 @@ func (ctx CoreContext) SignBuildBroadcast(name string, msg sdk.Msg, cdc *wire.Co | |||
return ctx.BroadcastTx(txBytes) | |||
} | |||
|
|||
func (c CoreContext) NextSequence(address []byte) (int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function header comments please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh.. not quite hehehe - I just pushed with a comment though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, too many windows open apparently. Thanks!
f2ae070
to
c7b680a
Compare
Also in favor of tests, but not sure how best to implement - we'll need an app with accounts to test sequence retrieval, doesn't make sense to import Basecoin in the All other comments addressed. |
Addressed, except tests (see comment).
cool - let's finalize the sequence testing as a part of this issue when we address #816 |
return "", err | ||
} | ||
genesisFile := cfg.GenesisFile() | ||
bz, err := ioutil.ReadFile(genesisFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (c CoreContext) WithChainID(chainID string) CoreContext { | ||
c.ChainID = chainID | ||
return c | ||
} | ||
|
||
// WithHeight - eturn a copy of the context with an updated height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
Address PR comments on #812
Ref #810