[#496] innerring/invoke: move wrapper structs to separate packages

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-21 13:39:01 +03:00 committed by Alex Vanin
parent ca0e3211be
commit b52751e992
9 changed files with 104 additions and 116 deletions

View file

@ -1,6 +1,11 @@
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/reputation"
)
@ -12,3 +17,18 @@ type ClientWrapper reputation.Client
func WrapClient(c *reputation.Client) *ClientWrapper {
return (*ClientWrapper)(c)
}
// NewFromMorph returns the wrapper instance from the raw morph client.
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8) (*ClientWrapper, error) {
staticClient, err := client.NewStatic(cli, contract, fee)
if err != nil {
return nil, fmt.Errorf("could not create static client of reputation contract: %w", err)
}
enhancedRepurationClient, err := reputation.New(staticClient)
if err != nil {
return nil, fmt.Errorf("could not create reputation contract client: %w", err)
}
return WrapClient(enhancedRepurationClient), nil
}