diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 2ea5bf716..f1cb00829 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -476,7 +476,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error return nil, err } - server.netmapClient, err = nmWrapper.NewFromMorph(server.morphClient, server.contracts.netmap, fee, client.TryNotary(), client.AsAlphabet()) + server.netmapClient, err = nmWrapper.NewFromMorph(server.morphClient, server.contracts.netmap, fee, nmWrapper.TryNotary(), nmWrapper.AsAlphabet()) if err != nil { return nil, err } diff --git a/pkg/morph/client/netmap/wrapper/wrapper.go b/pkg/morph/client/netmap/wrapper/wrapper.go index a05c92476..133258096 100644 --- a/pkg/morph/client/netmap/wrapper/wrapper.go +++ b/pkg/morph/client/netmap/wrapper/wrapper.go @@ -22,9 +22,25 @@ type Wrapper struct { client *netmap.Client } +// Option allows to set an optional +// parameter of Wrapper. +type Option func(*opts) + +type opts []client.StaticClientOption + +func defaultOpts() *opts { + return new(opts) +} + // NewFromMorph returns the wrapper instance from the raw morph client. -func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...client.StaticClientOption) (*Wrapper, error) { - staticClient, err := client.NewStatic(cli, contract, fee, opts...) +func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*Wrapper, error) { + o := defaultOpts() + + for i := range opts { + opts[i](o) + } + + staticClient, err := client.NewStatic(cli, contract, fee, ([]client.StaticClientOption)(*o)...) if err != nil { return nil, fmt.Errorf("can't create netmap static client: %w", err) } @@ -36,3 +52,22 @@ func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, return &Wrapper{client: enhancedNetmapClient}, nil } + +// TryNotary returns option to enable +// notary invocation tries. +func TryNotary() Option { + return func(o *opts) { + *o = append(*o, client.TryNotary()) + } +} + +// AsAlphabet returns option to sign main TX +// of notary requests with client's private +// key. +// +// Considered to be used by IR nodes only. +func AsAlphabet() Option { + return func(o *opts) { + *o = append(*o, client.AsAlphabet()) + } +}