[#627] morph: Inherit internal.StaticClient interface in all wrappers

There is a need to provide contract address getter from all contract client
wrappers.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-15 13:48:00 +03:00 committed by Alex Vanin
parent 1860f5040c
commit d6c0307431
14 changed files with 79 additions and 30 deletions

View file

@ -53,7 +53,7 @@ func (w *ClientWrapper) Get(v GetArgs) (*GetResult, error) {
args.SetEpoch(v.epoch)
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
data, err := (*reputationClient.Client)(w).Get(args)
data, err := w.client.Get(args)
if err != nil {
return nil, err
}
@ -67,7 +67,7 @@ func (w *ClientWrapper) GetByID(v GetByIDArgs) (*GetResult, error) {
args := reputationClient.GetByIDArgs{}
args.SetID(v.id)
data, err := (*reputationClient.Client)(w).GetByID(args)
data, err := w.client.GetByID(args)
if err != nil {
return nil, err
}

View file

@ -37,7 +37,7 @@ func (w *ClientWrapper) ListByEpoch(v ListByEpochArgs) (*ListByEpochResult, erro
args := reputationClient.ListByEpochArgs{}
args.SetEpoch(v.epoch)
data, err := (*reputationClient.Client)(w).ListByEpoch(args)
data, err := w.client.ListByEpoch(args)
if err != nil {
return nil, err
}

View file

@ -40,7 +40,7 @@ func (w *ClientWrapper) Put(v PutArgs) error {
return err
}
return (*reputationClient.Client)(w).Put(args)
return w.client.Put(args)
}
func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {

View file

@ -6,12 +6,17 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/internal"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
)
// ClientWrapper is a wrapper over reputation contract
// client which implements storage of reputation values.
type ClientWrapper reputation.Client
type ClientWrapper struct {
internal.StaticClient
client *reputation.Client
}
// Option allows to set an optional
// parameter of ClientWrapper.
@ -25,7 +30,7 @@ func defaultOpts() *opts {
// Morph returns raw morph client.
func (w ClientWrapper) Morph() *client.Client {
return (reputation.Client)(w).Morph()
return w.client.Morph()
}
// TryNotary returns option to enable
@ -65,5 +70,8 @@ func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8,
return nil, fmt.Errorf("could not create reputation contract client: %w", err)
}
return (*ClientWrapper)(enhancedRepurationClient), nil
return &ClientWrapper{
StaticClient: staticClient,
client: enhancedRepurationClient,
}, nil
}