[#1294] neofs-adm: Use Global scope where needed

Provide explicit argument to `sendCommitteeTx` signifying whether a tx
should try to use group signer.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-04-05 17:21:11 +03:00 committed by fyrchik
parent 7d670129c9
commit 82fda42316
9 changed files with 22 additions and 19 deletions

View file

@ -250,8 +250,8 @@ func (c *initializeContext) nnsContractState() (*state.Contract, error) {
return cs, nil
}
func (c *initializeContext) getSigner() transaction.Signer {
if c.groupKey != nil {
func (c *initializeContext) getSigner(tryGroup bool) transaction.Signer {
if tryGroup && c.groupKey != nil {
return transaction.Signer{
Scopes: transaction.CustomGroups,
AllowedGroups: keys.PublicKeys{c.groupKey},
@ -263,6 +263,10 @@ func (c *initializeContext) getSigner() transaction.Signer {
Scopes: transaction.Global, // Scope is important, as we have nested call to container contract.
}
if !tryGroup {
return signer
}
nnsCs, err := c.nnsContractState()
if err != nil {
return signer
@ -325,9 +329,12 @@ loop:
return retErr
}
func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64) error {
// sendCommitteeTx creates transaction from script and sends it to RPC.
// If sysFee is -1, it is calculated automatically. If tryGroup is false,
// global scope is used for the signer (useful when working with native contracts).
func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGroup bool) error {
tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []client.SignerAccount{{
Signer: c.getSigner(),
Signer: c.getSigner(tryGroup),
Account: c.CommitteeAcc,
}})
if err != nil {