-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add cli to update default quoting params of vaults #2721
Conversation
WalkthroughA new CLI command is introduced in the vault module to update default quoting parameters. The command, defined as Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant CLI as Vault CLI
participant CMD as CmdUpdateDefaultQuotingParams
participant MSG as MsgUpdateDefaultQuotingParams
participant NET as Network
U->>CLI: Execute update-default-quoting-params command\n(with authority and JSON)
CLI->>CMD: Call CmdUpdateDefaultQuotingParams
CMD->>CMD: Parse authority and JSON input
CMD->>MSG: Create MsgUpdateDefaultQuotingParams
CMD->>NET: Broadcast message
NET-->>U: Return confirmation response
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (9)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
protocol/x/vault/client/cli/tx.go (1)
302-303
: Enhance command documentation.The command's usage and description should include:
- Description of the authority parameter
- Example of the expected JSON format for quoting parameters
Update the command documentation:
- Use: "update-default-quoting-params [authority] [quoting_params_json]", - Short: "Broadcast message UpdateDefaultQuotingParams", + Use: "update-default-quoting-params [authority] [quoting_params_json]", + Short: "Update the default quoting parameters for vaults", + Long: `Update the default quoting parameters for vaults. + +Arguments: + [authority] The address of the authority allowed to update parameters + [quoting_params_json] JSON string of quoting parameters. Example: + { + "max_quote_amount": "1000000", + "min_quote_amount": "100", + "price_adjustment": "0.01" + }`,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
protocol/x/vault/client/cli/tx.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: test-sim-multi-seed-short
- GitHub Check: test-sim-import-export
- GitHub Check: test-sim-after-import
- GitHub Check: liveness-test
- GitHub Check: unit-end-to-end-and-integration
- GitHub Check: container-tests
- GitHub Check: test-race
- GitHub Check: test-coverage-upload
- GitHub Check: Summary
🔇 Additional comments (1)
protocol/x/vault/client/cli/tx.go (1)
34-34
: LGTM!The new command is properly integrated into the command list, following the established pattern.
protocol/x/vault/client/cli/tx.go
Outdated
func CmdUpdateDefaultQuotingParams() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "update-default-quoting-params [authority] [quoting_params_json]", | ||
Short: "Broadcast message UpdateDefaultQuotingParams", | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Parse quoting params. | ||
var quotingParams types.QuotingParams | ||
if err := json.Unmarshal([]byte(args[1]), "ingParams); err != nil { | ||
return fmt.Errorf("invalid quoting params JSON: %w", err) | ||
} | ||
|
||
// Create MsgUpdateDefaultQuotingParams. | ||
msg := &types.MsgUpdateDefaultQuotingParams{ | ||
Authority: args[0], | ||
DefaultQuotingParams: quotingParams, | ||
} | ||
|
||
// Broadcast or generate the transaction. | ||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
// Add the necessary flags. | ||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
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.
Add validation for QuotingParams.
The command should validate the parsed QuotingParams before creating the message, similar to how CmdSetVaultParams
validates its parameters on line 134.
Add validation after parsing:
if err := json.Unmarshal([]byte(args[1]), "ingParams); err != nil {
return fmt.Errorf("invalid quoting params JSON: %w", err)
}
+
+ // Validate quoting params
+ if err := quotingParams.Validate(); err != nil {
+ return err
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
func CmdUpdateDefaultQuotingParams() *cobra.Command { | |
cmd := &cobra.Command{ | |
Use: "update-default-quoting-params [authority] [quoting_params_json]", | |
Short: "Broadcast message UpdateDefaultQuotingParams", | |
Args: cobra.ExactArgs(2), | |
RunE: func(cmd *cobra.Command, args []string) (err error) { | |
clientCtx, err := client.GetClientTxContext(cmd) | |
if err != nil { | |
return err | |
} | |
// Parse quoting params. | |
var quotingParams types.QuotingParams | |
if err := json.Unmarshal([]byte(args[1]), "ingParams); err != nil { | |
return fmt.Errorf("invalid quoting params JSON: %w", err) | |
} | |
// Create MsgUpdateDefaultQuotingParams. | |
msg := &types.MsgUpdateDefaultQuotingParams{ | |
Authority: args[0], | |
DefaultQuotingParams: quotingParams, | |
} | |
// Broadcast or generate the transaction. | |
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | |
}, | |
} | |
// Add the necessary flags. | |
flags.AddTxFlagsToCmd(cmd) | |
return cmd | |
} | |
func CmdUpdateDefaultQuotingParams() *cobra.Command { | |
cmd := &cobra.Command{ | |
Use: "update-default-quoting-params [authority] [quoting_params_json]", | |
Short: "Broadcast message UpdateDefaultQuotingParams", | |
Args: cobra.ExactArgs(2), | |
RunE: func(cmd *cobra.Command, args []string) (err error) { | |
clientCtx, err := client.GetClientTxContext(cmd) | |
if err != nil { | |
return err | |
} | |
// Parse quoting params. | |
var quotingParams types.QuotingParams | |
if err := json.Unmarshal([]byte(args[1]), "ingParams); err != nil { | |
return fmt.Errorf("invalid quoting params JSON: %w", err) | |
} | |
// Validate quoting params | |
if err := quotingParams.Validate(); err != nil { | |
return err | |
} | |
// Create MsgUpdateDefaultQuotingParams. | |
msg := &types.MsgUpdateDefaultQuotingParams{ | |
Authority: args[0], | |
DefaultQuotingParams: quotingParams, | |
} | |
// Broadcast or generate the transaction. | |
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | |
}, | |
} | |
// Add the necessary flags. | |
flags.AddTxFlagsToCmd(cmd) | |
return cmd | |
} |
dcc9b5f
to
605daef
Compare
Changelist
[Describe or list the changes made in this PR]
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit