[#720] pkg/innerring: Check Notary availability automatically

Do not read `without_notary` config value from env.
Make morph client constructor return client without
notary support. Enabling notary support should be done
with public `EnableNotarySupport` method separately.

Notary availability is deducted with client. Further,
if notary is presented on chain its support is
enabled at the corresponding client.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-07-23 17:37:56 +03:00 committed by Alex Vanin
parent 28aa0f521e
commit 896c749b92
4 changed files with 56 additions and 59 deletions

View file

@ -2,7 +2,6 @@ package client
import (
"context"
"fmt"
"time"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
@ -28,8 +27,6 @@ type cfg struct {
gas util.Uint160 // native gas script-hash
waitInterval time.Duration
notaryOpts []NotaryOption
}
const (
@ -47,6 +44,8 @@ func defaultConfig() *cfg {
}
// New creates, initializes and returns the Client instance.
// Notary support should be enabled with EnableNotarySupport client
// method separately.
//
// If private key is nil, it panics.
//
@ -105,12 +104,6 @@ func New(key *keys.PrivateKey, endpoint string, opts ...Option) (*Client, error)
waitInterval: cfg.waitInterval,
}
if len(cfg.notaryOpts) != 0 {
if err := c.enableNotarySupport(cfg.notaryOpts...); err != nil {
return nil, fmt.Errorf("can't enable notary support: %w", err)
}
}
return c, nil
}
@ -155,10 +148,3 @@ func WithLogger(logger *logger.Logger) Option {
}
}
}
// WithNotaryOptions enables notary support and sets notary options for the client.
func WithNotaryOptions(opts ...NotaryOption) Option {
return func(c *cfg) {
c.notaryOpts = opts
}
}