forked from TrueCloudLab/frostfs-node
[#625] client/reputation: remove intermediate wrapper
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
97d18bc515
commit
767ee5c0cd
13 changed files with 145 additions and 375 deletions
|
@ -1,6 +1,10 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
|
@ -23,12 +27,57 @@ const (
|
|||
listByEpochMethod = "listByEpoch"
|
||||
)
|
||||
|
||||
// New creates, initializes and returns the Client instance.
|
||||
func New(c *client.StaticClient) *Client {
|
||||
return &Client{client: c}
|
||||
// NewFromMorph returns the wrapper instance from the raw morph client.
|
||||
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*Client, error) {
|
||||
o := defaultOpts()
|
||||
|
||||
for i := range opts {
|
||||
opts[i](o)
|
||||
}
|
||||
|
||||
sc, err := client.NewStatic(cli, contract, fee, ([]client.StaticClientOption)(*o)...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create static client of reputation contract: %w", err)
|
||||
}
|
||||
|
||||
return &Client{client: sc}, nil
|
||||
}
|
||||
|
||||
// Morph returns raw morph client.
|
||||
func (c Client) Morph() *client.Client {
|
||||
return c.client.Morph()
|
||||
}
|
||||
|
||||
// ContractAddress returns the address of the associated contract.
|
||||
func (c Client) ContractAddress() util.Uint160 {
|
||||
return c.client.ContractAddress()
|
||||
}
|
||||
|
||||
// Option allows to set an optional
|
||||
// parameter of ClientWrapper.
|
||||
type Option func(*opts)
|
||||
|
||||
type opts []client.StaticClientOption
|
||||
|
||||
func defaultOpts() *opts {
|
||||
return new(opts)
|
||||
}
|
||||
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,68 +5,58 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||
)
|
||||
|
||||
// GetArgs groups the arguments of "get reputation value" test invocation.
|
||||
type GetArgs struct {
|
||||
epoch uint64
|
||||
peerID []byte // object of reputation evaluation
|
||||
}
|
||||
type (
|
||||
// GetPrm groups the arguments of "get reputation value" test invocation.
|
||||
GetPrm struct {
|
||||
epoch uint64
|
||||
peerID reputation.PeerID
|
||||
}
|
||||
|
||||
// GetByIDArgs groups the arguments of "get reputation value by reputation id"
|
||||
// test invocation.
|
||||
type GetByIDArgs struct {
|
||||
id []byte // id of reputation value in reputation contract
|
||||
}
|
||||
|
||||
// GetResult groups the stack parameters returned by
|
||||
// "get" and "get by id" test invocations.
|
||||
type GetResult struct {
|
||||
reputations [][]byte
|
||||
}
|
||||
// GetByIDPrm groups the arguments of "get reputation value by
|
||||
// reputation id" test invocation.
|
||||
GetByIDPrm struct {
|
||||
id ID
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of expected reputation value.
|
||||
func (g *GetArgs) SetEpoch(v uint64) {
|
||||
func (g *GetPrm) SetEpoch(v uint64) {
|
||||
g.epoch = v
|
||||
}
|
||||
|
||||
// SetPeerID sets peer id of expected reputation value.
|
||||
func (g *GetArgs) SetPeerID(v []byte) {
|
||||
func (g *GetPrm) SetPeerID(v reputation.PeerID) {
|
||||
g.peerID = v
|
||||
}
|
||||
|
||||
// SetID sets id of expected reputation value in reputation contract.
|
||||
func (g *GetByIDArgs) SetID(v []byte) {
|
||||
func (g *GetByIDPrm) SetID(v ID) {
|
||||
g.id = v
|
||||
}
|
||||
|
||||
// Reputations returns slice of marshalled reputation values.
|
||||
func (g GetResult) Reputations() [][]byte {
|
||||
return g.reputations
|
||||
}
|
||||
|
||||
// Get invokes the call of "get reputation value" method of reputation contract.
|
||||
func (c *Client) Get(args GetArgs) (*GetResult, error) {
|
||||
func (c *Client) Get(p GetPrm) ([]reputation.GlobalTrust, error) {
|
||||
invokePrm := client.TestInvokePrm{}
|
||||
|
||||
invokePrm.SetMethod(getMethod)
|
||||
invokePrm.SetArgs(int64(args.epoch), args.peerID)
|
||||
invokePrm.SetArgs(int64(p.epoch), p.peerID.ToV2().GetPublicKey())
|
||||
|
||||
prms, err := c.client.TestInvoke(invokePrm)
|
||||
res, err := c.client.TestInvoke(invokePrm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getMethod, err)
|
||||
}
|
||||
|
||||
return parseReputations(prms, getMethod)
|
||||
return parseReputations(res, getMethod)
|
||||
}
|
||||
|
||||
// GetByID invokes the call of "get reputation value by reputation id" method
|
||||
// of reputation contract.
|
||||
func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
|
||||
func (c *Client) GetByID(p GetByIDPrm) ([]reputation.GlobalTrust, error) {
|
||||
invokePrm := client.TestInvokePrm{}
|
||||
|
||||
invokePrm.SetMethod(getByIDMethod)
|
||||
invokePrm.SetArgs(args.id)
|
||||
invokePrm.SetArgs([]byte(p.id))
|
||||
|
||||
prms, err := c.client.TestInvoke(invokePrm)
|
||||
if err != nil {
|
||||
|
@ -76,7 +66,24 @@ func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
|
|||
return parseReputations(prms, getByIDMethod)
|
||||
}
|
||||
|
||||
func parseReputations(items []stackitem.Item, method string) (*GetResult, error) {
|
||||
func parseGetResult(rawReputations [][]byte, method string) ([]reputation.GlobalTrust, error) {
|
||||
reputations := make([]reputation.GlobalTrust, 0, len(rawReputations))
|
||||
|
||||
for i := range rawReputations {
|
||||
r := reputation.GlobalTrust{}
|
||||
|
||||
err := r.Unmarshal(rawReputations[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't unmarshal global trust value (%s): %w", method, err)
|
||||
}
|
||||
|
||||
reputations = append(reputations, r)
|
||||
}
|
||||
|
||||
return reputations, nil
|
||||
}
|
||||
|
||||
func parseReputations(items []stackitem.Item, method string) ([]reputation.GlobalTrust, error) {
|
||||
if ln := len(items); ln != 1 {
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", method, ln)
|
||||
}
|
||||
|
@ -86,9 +93,7 @@ func parseReputations(items []stackitem.Item, method string) (*GetResult, error)
|
|||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res := &GetResult{
|
||||
reputations: make([][]byte, 0, len(items)),
|
||||
}
|
||||
res := make([][]byte, 0, len(items))
|
||||
|
||||
for i := range items {
|
||||
rawReputation, err := client.BytesFromStackItem(items[i])
|
||||
|
@ -96,8 +101,8 @@ func parseReputations(items []stackitem.Item, method string) (*GetResult, error)
|
|||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res.reputations = append(res.reputations, rawReputation)
|
||||
res = append(res, rawReputation)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return parseGetResult(res, method)
|
||||
}
|
||||
|
|
|
@ -6,35 +6,28 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
)
|
||||
|
||||
// ListByEpochArgs groups the arguments of
|
||||
// "list reputation ids by epoch" test invoke call.
|
||||
type ListByEpochArgs struct {
|
||||
epoch uint64
|
||||
}
|
||||
type (
|
||||
// ID is an ID of the reputation record in reputation contract.
|
||||
ID []byte
|
||||
|
||||
// ListByEpochResult groups the stack parameters
|
||||
// returned by "list reputation ids by epoch" test invoke.
|
||||
type ListByEpochResult struct {
|
||||
ids [][]byte
|
||||
}
|
||||
// ListByEpochArgs groups the arguments of
|
||||
// "list reputation ids by epoch" test invoke call.
|
||||
ListByEpochArgs struct {
|
||||
epoch uint64
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of expected reputation ids.
|
||||
func (l *ListByEpochArgs) SetEpoch(v uint64) {
|
||||
l.epoch = v
|
||||
}
|
||||
|
||||
// IDs returns slice of reputation id values.
|
||||
func (l ListByEpochResult) IDs() [][]byte {
|
||||
return l.ids
|
||||
}
|
||||
|
||||
// ListByEpoch invokes the call of "list reputation ids by epoch" method of
|
||||
// reputation contract.
|
||||
func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
|
||||
func (c *Client) ListByEpoch(p ListByEpochArgs) ([]ID, error) {
|
||||
invokePrm := client.TestInvokePrm{}
|
||||
|
||||
invokePrm.SetMethod(listByEpochMethod)
|
||||
invokePrm.SetArgs(int64(args.epoch))
|
||||
invokePrm.SetArgs(int64(p.epoch))
|
||||
|
||||
prms, err := c.client.TestInvoke(invokePrm)
|
||||
if err != nil {
|
||||
|
@ -48,18 +41,15 @@ func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
|
|||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", listByEpochMethod, err)
|
||||
}
|
||||
|
||||
res := &ListByEpochResult{
|
||||
ids: make([][]byte, 0, len(items)),
|
||||
}
|
||||
|
||||
result := make([]ID, 0, len(items))
|
||||
for i := range items {
|
||||
rawReputation, err := client.BytesFromStackItem(items[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", listByEpochMethod, err)
|
||||
}
|
||||
|
||||
res.ids = append(res.ids, rawReputation)
|
||||
result = append(result, rawReputation)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return result, nil
|
||||
}
|
||||
|
|
|
@ -4,39 +4,47 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||
)
|
||||
|
||||
// PutArgs groups the arguments of "put reputation value" invocation call.
|
||||
type PutArgs struct {
|
||||
epoch uint64
|
||||
peerID []byte
|
||||
value []byte
|
||||
}
|
||||
type (
|
||||
// PutPrm groups the arguments of "put reputation value" invocation call.
|
||||
PutPrm struct {
|
||||
epoch uint64
|
||||
peerID reputation.PeerID
|
||||
value reputation.GlobalTrust
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of reputation value.
|
||||
func (p *PutArgs) SetEpoch(v uint64) {
|
||||
func (p *PutPrm) SetEpoch(v uint64) {
|
||||
p.epoch = v
|
||||
}
|
||||
|
||||
// SetPeerID sets peer id of reputation value.
|
||||
func (p *PutArgs) SetPeerID(v []byte) {
|
||||
func (p *PutPrm) SetPeerID(v reputation.PeerID) {
|
||||
p.peerID = v
|
||||
}
|
||||
|
||||
// SetValue sets marshaled reputation value.
|
||||
func (p *PutArgs) SetValue(v []byte) {
|
||||
// SetValue sets reputation value.
|
||||
func (p *PutPrm) SetValue(v reputation.GlobalTrust) {
|
||||
p.value = v
|
||||
}
|
||||
|
||||
// Put invokes direct call of "put reputation value" method of reputation contract.
|
||||
func (c *Client) Put(args PutArgs) error {
|
||||
//
|
||||
// If TryNotary is provided, calls notary contract.
|
||||
func (c *Client) Put(p PutPrm) error {
|
||||
data, err := p.value.Marshal()
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't marshal global trust value: %w", err)
|
||||
}
|
||||
|
||||
prm := client.InvokePrm{}
|
||||
|
||||
prm.SetMethod(putMethod)
|
||||
prm.SetArgs(int64(args.epoch), args.peerID, args.value)
|
||||
|
||||
err := c.client.Invoke(prm)
|
||||
prm.SetArgs(int64(p.epoch), p.peerID.ToV2().GetPublicKey(), data)
|
||||
|
||||
err = c.client.Invoke(prm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", putMethod, err)
|
||||
}
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||
)
|
||||
|
||||
type (
|
||||
// GetArgs groups the arguments of "get reputation value" test invocation.
|
||||
GetArgs struct {
|
||||
epoch uint64
|
||||
peerID reputation.PeerID
|
||||
}
|
||||
|
||||
// GetByIDArgs groups the arguments of "get reputation value by
|
||||
// reputation id" test invocation.
|
||||
GetByIDArgs struct {
|
||||
id ReputationID
|
||||
}
|
||||
|
||||
// GetResult groups the result of "get reputation value" and
|
||||
// "get reputation value by reputation id" test invocations.
|
||||
GetResult struct {
|
||||
reputations []reputation.GlobalTrust
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of expected reputation value.
|
||||
func (g *GetArgs) SetEpoch(v uint64) {
|
||||
g.epoch = v
|
||||
}
|
||||
|
||||
// SetPeerID sets peer id of expected reputation value.
|
||||
func (g *GetArgs) SetPeerID(v reputation.PeerID) {
|
||||
g.peerID = v
|
||||
}
|
||||
|
||||
// SetID sets id of expected reputation value in reputation contract.
|
||||
func (g *GetByIDArgs) SetID(v ReputationID) {
|
||||
g.id = v
|
||||
}
|
||||
|
||||
// Reputations returns slice of reputation values.
|
||||
func (g GetResult) Reputations() []reputation.GlobalTrust {
|
||||
return g.reputations
|
||||
}
|
||||
|
||||
// Get invokes the call of "get reputation value" method of reputation contract.
|
||||
func (w *ClientWrapper) Get(v GetArgs) (*GetResult, error) {
|
||||
args := reputationClient.GetArgs{}
|
||||
args.SetEpoch(v.epoch)
|
||||
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
|
||||
|
||||
data, err := w.client.Get(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return parseGetResult(data)
|
||||
}
|
||||
|
||||
// GetByID invokes the call of "get reputation value by reputation id" method
|
||||
// of reputation contract.
|
||||
func (w *ClientWrapper) GetByID(v GetByIDArgs) (*GetResult, error) {
|
||||
args := reputationClient.GetByIDArgs{}
|
||||
args.SetID(v.id)
|
||||
|
||||
data, err := w.client.GetByID(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return parseGetResult(data)
|
||||
}
|
||||
|
||||
func parseGetResult(data *reputationClient.GetResult) (*GetResult, error) {
|
||||
rawReputations := data.Reputations()
|
||||
reputations := make([]reputation.GlobalTrust, 0, len(rawReputations))
|
||||
|
||||
for i := range rawReputations {
|
||||
r := reputation.GlobalTrust{}
|
||||
|
||||
err := r.Unmarshal(rawReputations[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't unmarshal global trust value: %w", err)
|
||||
}
|
||||
|
||||
reputations = append(reputations, r)
|
||||
}
|
||||
|
||||
return &GetResult{
|
||||
reputations: reputations,
|
||||
}, nil
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
)
|
||||
|
||||
type (
|
||||
// ReputationID is an ID of the reputation record in reputation contract.
|
||||
ReputationID []byte
|
||||
|
||||
// ListByEpochArgs groups the arguments of
|
||||
// "list reputation ids by epoch" test invoke call.
|
||||
ListByEpochArgs struct {
|
||||
epoch uint64
|
||||
}
|
||||
|
||||
// ListByEpochResult groups the result of "list reputation ids by epoch"
|
||||
// test invoke.
|
||||
ListByEpochResult struct {
|
||||
ids []ReputationID
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of expected reputation ids.
|
||||
func (l *ListByEpochArgs) SetEpoch(v uint64) {
|
||||
l.epoch = v
|
||||
}
|
||||
|
||||
// IDs returns slice of reputation id values.
|
||||
func (l ListByEpochResult) IDs() []ReputationID {
|
||||
return l.ids
|
||||
}
|
||||
|
||||
// ListByEpoch invokes the call of "list reputation ids by epoch" method of
|
||||
// reputation contract.
|
||||
func (w *ClientWrapper) ListByEpoch(v ListByEpochArgs) (*ListByEpochResult, error) {
|
||||
args := reputationClient.ListByEpochArgs{}
|
||||
args.SetEpoch(v.epoch)
|
||||
|
||||
data, err := w.client.ListByEpoch(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids := data.IDs()
|
||||
|
||||
result := make([]ReputationID, 0, len(ids))
|
||||
for i := range ids {
|
||||
result = append(result, ids[i])
|
||||
}
|
||||
|
||||
return &ListByEpochResult{
|
||||
ids: result,
|
||||
}, nil
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||
)
|
||||
|
||||
type (
|
||||
// PutArgs groups the arguments of "put reputation value" invocation call.
|
||||
PutArgs struct {
|
||||
epoch uint64
|
||||
peerID reputation.PeerID
|
||||
value reputation.GlobalTrust
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of reputation value.
|
||||
func (p *PutArgs) SetEpoch(v uint64) {
|
||||
p.epoch = v
|
||||
}
|
||||
|
||||
// SetPeerID sets peer id of reputation value.
|
||||
func (p *PutArgs) SetPeerID(v reputation.PeerID) {
|
||||
p.peerID = v
|
||||
}
|
||||
|
||||
// SetValue sets reputation value.
|
||||
func (p *PutArgs) SetValue(v reputation.GlobalTrust) {
|
||||
p.value = v
|
||||
}
|
||||
|
||||
// Put invokes direct call of "put reputation value" method of reputation contract.
|
||||
//
|
||||
// If TryNotary is provided, calls notary contract.
|
||||
func (w *ClientWrapper) Put(v PutArgs) error {
|
||||
args, err := preparePutArgs(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return w.client.Put(args)
|
||||
}
|
||||
|
||||
func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {
|
||||
args := reputationClient.PutArgs{}
|
||||
|
||||
data, err := v.value.Marshal()
|
||||
if err != nil {
|
||||
return args, fmt.Errorf("can't marshal global trust value: %w", err)
|
||||
}
|
||||
|
||||
args.SetEpoch(v.epoch)
|
||||
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
|
||||
args.SetValue(data)
|
||||
|
||||
return args, nil
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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 struct {
|
||||
internal.StaticClient
|
||||
|
||||
client *reputation.Client
|
||||
}
|
||||
|
||||
// Option allows to set an optional
|
||||
// parameter of ClientWrapper.
|
||||
type Option func(*opts)
|
||||
|
||||
type opts []client.StaticClientOption
|
||||
|
||||
func defaultOpts() *opts {
|
||||
return new(opts)
|
||||
}
|
||||
|
||||
// Morph returns raw morph client.
|
||||
func (w ClientWrapper) Morph() *client.Client {
|
||||
return w.client.Morph()
|
||||
}
|
||||
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewFromMorph returns the wrapper instance from the raw morph client.
|
||||
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*ClientWrapper, 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("could not create static client of reputation contract: %w", err)
|
||||
}
|
||||
|
||||
return &ClientWrapper{
|
||||
StaticClient: staticClient,
|
||||
client: reputation.New(staticClient),
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue