[#749] morph/client: set group signer scope

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-29 15:42:48 +03:00 committed by Alex Vanin
parent fa947b85a6
commit e21d054fe2
4 changed files with 31 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import (
"strconv"
nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns"
"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/rpc/client"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
@ -175,8 +176,27 @@ func exists(c *client.Client, nnsHash util.Uint160, domain string) (bool, error)
return !available, nil
}
// ContractGroupKey returns public key designating NeoFS contract group.
func (c *Client) ContractGroupKey() (*keys.PublicKey, error) {
// SetGroupSignerScope makes the default signer scope include all NeoFS contracts.
// Should be called for side-chain client only.
func (c *Client) SetGroupSignerScope() error {
if c.multiClient != nil {
return c.multiClient.iterateClients(func(c *Client) error {
return wrapNeoFSError(c.SetGroupSignerScope())
})
}
pub, err := c.contractGroupKey()
if err != nil {
return err
}
c.signer.Scopes = transaction.CustomGroups
c.signer.AllowedGroups = []*keys.PublicKey{pub}
return nil
}
// contractGroupKey returns public key designating NeoFS contract group.
func (c *Client) contractGroupKey() (*keys.PublicKey, error) {
if c.groupKey != nil {
return c.groupKey, nil
}