From be4df989e5151b0031f64c09f26f9c49325fa199 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 17 Feb 2023 22:27:29 +0300 Subject: [PATCH] [#239] morph/client: Deduplicate signers in Client a bit One signer in the cfg is enough. Signed-off-by: Roman Khimov Signed-off-by: Evgenii Stratonikov --- pkg/morph/client/client.go | 2 -- pkg/morph/client/constructor.go | 1 - pkg/morph/client/nns.go | 6 ++++-- pkg/morph/client/notary.go | 12 ++++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index b93c5f75ff..5e98211c40 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -57,8 +57,6 @@ type Client struct { acc *wallet.Account // neo account accAddr util.Uint160 // account's address - signer *transaction.Signer - notary *notaryInfo cfg cfg diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 9ed2750293..c4ec701714 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -105,7 +105,6 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er logger: cfg.logger, acc: acc, accAddr: accAddr, - signer: cfg.signer, cfg: *cfg, switchLock: &sync.RWMutex{}, notifications: make(chan rpcclient.Notification), diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index c3b900ddb5..e61cb8e150 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -208,8 +208,10 @@ func (c *Client) SetGroupSignerScope() error { return err } - c.signer.Scopes = transaction.CustomGroups | transaction.CalledByEntry - c.signer.AllowedGroups = []*keys.PublicKey{pub} + c.cfg.signer = &transaction.Signer{ + Scopes: transaction.CustomGroups | transaction.CalledByEntry, + AllowedGroups: []*keys.PublicKey{pub}, + } return nil } diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 96dca03195..069c357820 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -596,18 +596,18 @@ func (c *Client) notaryCosigners(invokedByAlpha bool, ir []*keys.PublicKey, comm s = append(s, transaction.Signer{ Account: hash.Hash160(multisigScript), - Scopes: c.signer.Scopes, - AllowedContracts: c.signer.AllowedContracts, - AllowedGroups: c.signer.AllowedGroups, + Scopes: c.cfg.signer.Scopes, + AllowedContracts: c.cfg.signer.AllowedContracts, + AllowedGroups: c.cfg.signer.AllowedGroups, }) if !invokedByAlpha { // then we have invoker signature s = append(s, transaction.Signer{ Account: hash.Hash160(c.acc.GetVerificationScript()), - Scopes: c.signer.Scopes, - AllowedContracts: c.signer.AllowedContracts, - AllowedGroups: c.signer.AllowedGroups, + Scopes: c.cfg.signer.Scopes, + AllowedContracts: c.cfg.signer.AllowedContracts, + AllowedGroups: c.cfg.signer.AllowedGroups, }) }