Skip to content
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

Better CLI UX for governance #223

Open
oldremez opened this issue Apr 26, 2023 · 1 comment
Open

Better CLI UX for governance #223

oldremez opened this issue Apr 26, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@oldremez
Copy link
Contributor

oldremez commented Apr 26, 2023

Neutron DAO is based on CosmWasm contracts but still is the core part of Neutron chain. This means two things:

  1. There's no CLI support for governance operations.
  2. Regardless of being the part of neutrond binary, DAO contracts are a crucial part of Neutron, and having support for them in neutrond binary is a good thing.

The current process of making a proposal, voting for it, and executing it looks something like that:

neutrond tx wasm execute neutron1hulx7cgvpfcvg83wk5h96sedqgn72n026w6nl47uht554xhvj9nsgs8v0z '{
   "propose":{
      "msg":{
         "propose":{
            "title": "Proposal title",
            "description": "Proposal description",
            "msgs":[
               {
                   ...
                }
            ]
         }
      }
   }
}'

neutrond tx wasm execute neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh \
    '{"vote":{"proposal_id": 1, "vote":"yes"}}'

neutrond tx wasm execute neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh \
    '{"execute":{"proposal_id": 1}}'

The user here has to work with obscure addresses of specific contracts which should not be messed up, and also hast to manually craft the jsons for messages for any action. What would be great to have instead is something like that:

neutrond tx neutron-dao propose single-choice --title "Proposal title" --description  "Proposal description" --msgs '[
   {
       ...
    }
]'

neutrond tx neutron-dao vote single-choice 1 yes
neutrond tx neutron-dao execute single-choice 1

The same for queries, etc., etc.

It will require the following:

  1. The code that gets the set of Neutron contracts based on the admin module (the chain admin is Neutron DAO core, all the other contracts can be queried from the core; we already have the code that solves it in the tests (the getDaoContracts function))
  2. The interface code that will transform all human-readable commands to wasm messages to the corresponding contracts.
@oldremez oldremez added the good first issue Good for newcomers label Apr 26, 2023
@EskandarAtrakchi
Copy link

EskandarAtrakchi commented Jan 3, 2024

// This is only a try 
// neutron-dao module
func ProposeCommand(cliCtx context.CLIContext, title, description string, msgs []Msg) (sdk.TxResponse, error) {
    // Transform user-friendly inputs to wasm messages
    proposeMsg := NewMsgPropose(title, description, msgs)
    
    // Construct and broadcast the transaction
    return utils.BuildAndBroadcast(cliCtx, []sdk.Msg{proposeMsg})
}

// CLI command registration
var (
    CmdPropose = &cobra.Command{
        Use:   "propose",
        Short: "Propose a governance action",
        RunE: func(cmd *cobra.Command, args []string) error {
            title, _ := cmd.Flags().GetString("title")
            description, _ := cmd.Flags().GetString("description")
            msgs, _ := cmd.Flags().GetString("msgs")

            cliCtx := context.NewCLIContext().WithCodec(appCodec)
            response, err := neutronDao.ProposeCommand(cliCtx, title, description, msgs)
            // Handle response and error
        },
    }
)

// Add flags to the propose command
func init() {
    CmdPropose.Flags().String("title", "", "Proposal title")
    CmdPropose.Flags().String("description", "", "Proposal description")
    CmdPropose.Flags().String("msgs", "", "JSON array of messages")
    // Add other necessary flags here 
    // hmm... My code could be mess and wrong, but that what I came up with after taking a look at some of the files
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants