Merge pull request #8833 from kaola526/master

feat: msig cli: Check for existing signers in add-propose
This commit is contained in:
Łukasz Magiera 2022-07-07 13:56:44 +02:00 committed by GitHub
commit 1de56d5e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -878,6 +878,39 @@ var msigAddProposeCmd = &cli.Command{
from = defaddr
}
store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(api)))
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
act, err := api.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 := api.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())
}
}
proto, err := api.MsigAddPropose(ctx, msig, from, addr, cctx.Bool("increase-threshold"))
if err != nil {
return err