[#749] neofs-adm: Set signer for committee transactions

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-02-02 17:19:27 +03:00 committed by Alex Vanin
parent 8fa2b364a1
commit 1deea4e8c6
4 changed files with 61 additions and 29 deletions

View file

@ -4,8 +4,6 @@ import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
@ -31,19 +29,6 @@ func forceNewEpochCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("can't get netmap contract hash: %w", err)
}
signer := transaction.Signer{
Account: wCtx.CommitteeAcc.Contract.ScriptHash(),
Scopes: transaction.Global, // Scope is important, as we have nested call to container contract.
}
groupKey, err := nnsResolveKey(wCtx.Client, cs.Hash, groupKeyDomain)
if err != nil {
cmd.Println("Can't resolve neofs contract group key, using Global scope")
} else {
signer.Scopes = transaction.CustomGroups
signer.AllowedGroups = keys.PublicKeys{groupKey}
}
res, err := wCtx.Client.InvokeFunction(nmHash, "epoch", []smartcontract.Parameter{}, nil)
if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 {
return errors.New("can't fetch current epoch from the netmap contract")