Skip to content

Commit

Permalink
chore: Check for existing signers in add-propose (#5320)
Browse files Browse the repository at this point in the history
* chore: Check for existing signers in add-propose

* chore: fix lint
  • Loading branch information
simlecode committed Oct 21, 2022
1 parent 9e9f428 commit 11e6578
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cmd/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,40 @@ var msigAddProposeCmd = &cmds.Command{
if err != nil {
return err
}

store := adt.WrapStore(ctx, cbor.NewCborStore(sbchain.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))

head, err := env.(*node.Env).ChainAPI.ChainHead(ctx)
if err != nil {
return err
}

act, err := env.(*node.Env).ChainAPI.StateGetActor(ctx, msig, head.Key())
if err != nil {
return err
}

mstate, err := multisig.Load(store, act)
if err != nil {
return err
}

signers, err := mstate.Signers()
if err != nil {
return err
}

addrID, err := env.(*node.Env).ChainAPI.StateLookupID(ctx, addr, types.EmptyTSK)
if err != nil {
return err
}

for _, s := range signers {
if s == addrID {
return fmt.Errorf("%s is already a signer", addr.String())
}
}

msgCid, err := env.(*node.Env).MultiSigAPI.MsigAddPropose(ctx, msig, from, addr, reqBoolOption(req, "increase-threshold"))
if err != nil {
return err
Expand Down

0 comments on commit 11e6578

Please # to comment.