[#239] morph/client: Deduplicate signers in Client a bit

One signer in the cfg is enough.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Roman Khimov 2023-02-17 22:27:29 +03:00 committed by fyrchik
parent 96b38f7e86
commit be4df989e5
4 changed files with 10 additions and 11 deletions

View file

@ -57,8 +57,6 @@ type Client struct {
acc *wallet.Account // neo account acc *wallet.Account // neo account
accAddr util.Uint160 // account's address accAddr util.Uint160 // account's address
signer *transaction.Signer
notary *notaryInfo notary *notaryInfo
cfg cfg cfg cfg

View file

@ -105,7 +105,6 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er
logger: cfg.logger, logger: cfg.logger,
acc: acc, acc: acc,
accAddr: accAddr, accAddr: accAddr,
signer: cfg.signer,
cfg: *cfg, cfg: *cfg,
switchLock: &sync.RWMutex{}, switchLock: &sync.RWMutex{},
notifications: make(chan rpcclient.Notification), notifications: make(chan rpcclient.Notification),

View file

@ -208,8 +208,10 @@ func (c *Client) SetGroupSignerScope() error {
return err return err
} }
c.signer.Scopes = transaction.CustomGroups | transaction.CalledByEntry c.cfg.signer = &transaction.Signer{
c.signer.AllowedGroups = []*keys.PublicKey{pub} Scopes: transaction.CustomGroups | transaction.CalledByEntry,
AllowedGroups: []*keys.PublicKey{pub},
}
return nil return nil
} }

View file

@ -596,18 +596,18 @@ func (c *Client) notaryCosigners(invokedByAlpha bool, ir []*keys.PublicKey, comm
s = append(s, transaction.Signer{ s = append(s, transaction.Signer{
Account: hash.Hash160(multisigScript), Account: hash.Hash160(multisigScript),
Scopes: c.signer.Scopes, Scopes: c.cfg.signer.Scopes,
AllowedContracts: c.signer.AllowedContracts, AllowedContracts: c.cfg.signer.AllowedContracts,
AllowedGroups: c.signer.AllowedGroups, AllowedGroups: c.cfg.signer.AllowedGroups,
}) })
if !invokedByAlpha { if !invokedByAlpha {
// then we have invoker signature // then we have invoker signature
s = append(s, transaction.Signer{ s = append(s, transaction.Signer{
Account: hash.Hash160(c.acc.GetVerificationScript()), Account: hash.Hash160(c.acc.GetVerificationScript()),
Scopes: c.signer.Scopes, Scopes: c.cfg.signer.Scopes,
AllowedContracts: c.signer.AllowedContracts, AllowedContracts: c.cfg.signer.AllowedContracts,
AllowedGroups: c.signer.AllowedGroups, AllowedGroups: c.cfg.signer.AllowedGroups,
}) })
} }