You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.6 KiB
89 lines
2.6 KiB
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/woop-chain/go-sdk/pkg/governance"
|
|
"github.com/woop-chain/go-sdk/pkg/store"
|
|
"github.com/woop-chain/woop/accounts"
|
|
)
|
|
|
|
func init() {
|
|
cmdGovernance := &cobra.Command{
|
|
Use: "governance",
|
|
Short: "Interact with the Woop spaces on https://snapshot.org",
|
|
Long: `
|
|
Support interaction with the Woop governance space on Snapshot, especially for validators that do not want to import their account private key into either metamask or onewallet.
|
|
`,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cmd.Help()
|
|
return nil
|
|
},
|
|
}
|
|
|
|
cmdGovernance.AddCommand([]*cobra.Command{
|
|
commandVote(),
|
|
}...)
|
|
|
|
RootCmd.AddCommand(cmdGovernance)
|
|
}
|
|
|
|
func commandVote() (cmd *cobra.Command) {
|
|
var space string
|
|
var proposal string
|
|
var choice string
|
|
var key string
|
|
var proposalType string
|
|
// var privacy string
|
|
var app string
|
|
var reason string
|
|
|
|
cmd = &cobra.Command{
|
|
Use: "vote-proposal",
|
|
Short: "Vote on a proposal",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
keyStore := store.FromAccountName(key)
|
|
passphrase, err := getPassphrase()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(keyStore.Accounts()) <= 0 {
|
|
return fmt.Errorf("couldn't find address from the key")
|
|
}
|
|
|
|
account := accounts.Account{Address: keyStore.Accounts()[0].Address}
|
|
err = keyStore.Unlock(accounts.Account{Address: keyStore.Accounts()[0].Address}, passphrase)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return governance.DoVote(keyStore, account, governance.Vote{
|
|
Space: space,
|
|
Proposal: proposal,
|
|
ProposalType: proposalType,
|
|
Choice: choice,
|
|
// Privacy: privacy,
|
|
App: app,
|
|
From: account.Address.Hex(),
|
|
Reason: reason,
|
|
})
|
|
},
|
|
}
|
|
|
|
cmd.Flags().StringVar(&key, "key", "", "Account name. Must first use (wiki keys import-private-key) to import.")
|
|
cmd.Flags().StringVar(&space, "space", "woop-mainnet.eth", "Snapshot space")
|
|
cmd.Flags().StringVar(&proposal, "proposal", "", "Proposal hash")
|
|
cmd.Flags().StringVar(&proposalType, "proposal-type", "single-choice", "Proposal type like single-choice, approval, quadratic, etc.")
|
|
cmd.Flags().StringVar(&choice, "choice", "", "Vote choice either as integer, list of integers (e.x. when using ranked choice voting), or string")
|
|
// cmd.Flags().StringVar(&privacy, "privacy", "", "Vote privacy e.x. shutter")
|
|
cmd.Flags().StringVar(&app, "app", "snapshot", "Voting app")
|
|
cmd.Flags().StringVar(&reason, "reason", "", "Reason for your choice")
|
|
cmd.Flags().BoolVar(&userProvidesPassphrase, "passphrase", false, ppPrompt)
|
|
|
|
cmd.MarkFlagRequired("key")
|
|
cmd.MarkFlagRequired("proposal")
|
|
cmd.MarkFlagRequired("choice")
|
|
return
|
|
}
|
|
|