-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix(client/v2/autocli): add CoinDec flag #22817
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3077806
fix: autocli parse decCoins
JulianToledano 59eb5eb
update: parseCoin
JulianToledano a57b40d
fix
JulianToledano 46e7d5c
changelog
JulianToledano d7a87db
Merge branch 'main' into julian/autocli-coin-test
tac0turtle 82f090f
updates
julienrbrt 98d1aef
bump schema (to fix build)
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package flag | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"strings" | ||
|
||
"google.golang.org/protobuf/reflect/protoreflect" | ||
|
||
basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" | ||
"cosmossdk.io/client/v2/internal/coins" | ||
) | ||
|
||
type decCoinType struct{} | ||
|
||
type decCoinValue struct { | ||
value *basev1beta1.DecCoin | ||
} | ||
|
||
func (c decCoinType) NewValue(*context.Context, *Builder) Value { | ||
return &decCoinValue{} | ||
} | ||
|
||
func (c decCoinType) DefaultValue() string { | ||
return "zero" | ||
} | ||
|
||
func (c *decCoinValue) Get(protoreflect.Value) (protoreflect.Value, error) { | ||
if c.value == nil { | ||
return protoreflect.Value{}, nil | ||
} | ||
return protoreflect.ValueOfMessage(c.value.ProtoReflect()), nil | ||
} | ||
JulianToledano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
func (c *decCoinValue) String() string { | ||
if c.value == nil { | ||
return "" | ||
} | ||
|
||
return c.value.String() | ||
} | ||
|
||
func (c *decCoinValue) Set(stringValue string) error { | ||
if strings.Contains(stringValue, ",") { | ||
return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") | ||
} | ||
|
||
coin, err := coins.ParseDecCoin(stringValue) | ||
if err != nil { | ||
return err | ||
} | ||
c.value = coin | ||
return nil | ||
} | ||
|
||
func (c *decCoinValue) Type() string { | ||
return "cosmos.base.v1beta1.DecCoin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Move changelog entry to Features section
The addition of DecCoin support in autocli flag builder is a new feature rather than a bug fix. Consider moving this entry to the "Features" section:
📝 Committable suggestion