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

Add propose remove #4311

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chain/actors/builtin/multisig/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type MessageBuilder interface {

// this type is the same between v0 and v2
type ProposalHashData = multisig2.ProposalHashData
type ProposeReturn = multisig2.ProposeReturn

func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := multisig2.TxnIDParams{ID: multisig2.TxnID(id)}
Expand Down
79 changes: 79 additions & 0 deletions cli/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var multisigCmd = &cli.Command{
msigCreateCmd,
msigInspectCmd,
msigProposeCmd,
msigRemoveProposeCmd,
msigApproveCmd,
msigAddProposeCmd,
msigAddApproveCmd,
Expand Down Expand Up @@ -504,6 +505,84 @@ var msigApproveCmd = &cli.Command{
},
}

var msigRemoveProposeCmd = &cli.Command{
Name: "propose-remove",
Usage: "Propose to remove a signer",
ArgsUsage: "[multisigAddress signer]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "decrease-threshold",
Usage: "whether the number of required signers should be decreased",
},
&cli.StringFlag{
Name: "from",
Usage: "account to send the propose message from",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address"))
}

api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)

msig, err := address.NewFromString(cctx.Args().Get(0))
if err != nil {
return err
}

addr, err := address.NewFromString(cctx.Args().Get(1))
if err != nil {
return err
}

var from address.Address
if cctx.IsSet("from") {
f, err := address.NewFromString(cctx.String("from"))
if err != nil {
return err
}
from = f
} else {
defaddr, err := api.WalletDefaultAddress(ctx)
if err != nil {
return err
}
from = defaddr
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to add a check at this stage that the from we're gonna use is a valid signer...This isn't specific to this PR, though, we can just crack an issue for it for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to do, for sure.

msgCid, err := api.MsigRemoveSigner(ctx, msig, from, addr, cctx.Bool("decrease-threshold"))
if err != nil {
return err
}

fmt.Println("sent remove proposal in message: ", msgCid)

wait, err := api.StateWaitMsg(ctx, msgCid, build.MessageConfidence)
if err != nil {
return err
}

if wait.Receipt.ExitCode != 0 {
return fmt.Errorf("add proposal returned exit %d", wait.Receipt.ExitCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"add proposal" is wrong

}

var ret multisig.ProposeReturn
err = ret.UnmarshalCBOR(bytes.NewReader(wait.Receipt.Return))
if err != nil {
return xerrors.Errorf("decoding proposal return: %w", err)
}
fmt.Printf("TxnID: %d", ret.TxnID)

return nil
},
}

var msigAddProposeCmd = &cli.Command{
Name: "add-propose",
Usage: "Propose to add a signer",
Expand Down