forked from TrueCloudLab/frostfs-node
[#625] client/balance: remove intermediate wrapper
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
c7a8c762e0
commit
6f50fefbea
17 changed files with 239 additions and 524 deletions
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
accountingGRPC "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
|
accountingGRPC "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
accountingTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/accounting/grpc"
|
accountingTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/accounting/grpc"
|
||||||
accountingService "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
|
accountingService "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
|
||||||
accounting "github.com/nspcc-dev/neofs-node/pkg/services/accounting/morph"
|
accounting "github.com/nspcc-dev/neofs-node/pkg/services/accounting/morph"
|
||||||
|
@ -13,7 +13,7 @@ func initAccountingService(c *cfg) {
|
||||||
initMorphComponents(c)
|
initMorphComponents(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceMorphWrapper, err := wrapper.NewFromMorph(c.cfgMorph.client, c.cfgAccounting.scriptHash, 0)
|
balanceMorphWrapper, err := balance.NewFromMorph(c.cfgMorph.client, c.cfgAccounting.scriptHash, 0)
|
||||||
fatalOnErr(err)
|
fatalOnErr(err)
|
||||||
|
|
||||||
server := accountingTransportGRPC.New(
|
server := accountingTransportGRPC.New(
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/metrics"
|
"github.com/nspcc-dev/neofs-node/pkg/metrics"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
||||||
balanceWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
cntWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
cntWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
neofsWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs/wrapper"
|
neofsWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs/wrapper"
|
||||||
neofsidWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
neofsidWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
||||||
|
@ -76,7 +76,7 @@ type (
|
||||||
precision precision.Fixed8Converter
|
precision precision.Fixed8Converter
|
||||||
auditClient *auditWrapper.ClientWrapper
|
auditClient *auditWrapper.ClientWrapper
|
||||||
healthStatus atomic.Value
|
healthStatus atomic.Value
|
||||||
balanceClient *balanceWrapper.Wrapper
|
balanceClient *balanceClient.Client
|
||||||
netmapClient *nmWrapper.Wrapper
|
netmapClient *nmWrapper.Wrapper
|
||||||
persistate *state.PersistentStorage
|
persistate *state.PersistentStorage
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
server.balanceClient, err = balanceWrapper.NewFromMorph(server.morphClient, server.contracts.balance, fee, balanceWrapper.TryNotary(), balanceWrapper.AsAlphabet())
|
server.balanceClient, err = balanceClient.NewFromMorph(server.morphClient, server.contracts.balance, fee, balanceClient.TryNotary(), balanceClient.AsAlphabet())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package neofs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
balancewrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,7 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
prm := balancewrp.MintPrm{}
|
prm := balance.MintPrm{}
|
||||||
|
|
||||||
prm.SetTo(deposit.To())
|
prm.SetTo(deposit.To())
|
||||||
prm.SetAmount(np.converter.ToBalancePrecision(deposit.Amount()))
|
prm.SetAmount(np.converter.ToBalancePrecision(deposit.Amount()))
|
||||||
|
@ -95,7 +95,7 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
|
||||||
|
|
||||||
curEpoch := np.epochState.EpochCounter()
|
curEpoch := np.epochState.EpochCounter()
|
||||||
|
|
||||||
prm := balancewrp.LockPrm{}
|
prm := balance.LockPrm{}
|
||||||
|
|
||||||
prm.SetID(withdraw.ID())
|
prm.SetID(withdraw.ID())
|
||||||
prm.SetUser(withdraw.User())
|
prm.SetUser(withdraw.User())
|
||||||
|
@ -117,7 +117,7 @@ func (np *Processor) processCheque(cheque *neofsEvent.Cheque) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
prm := balancewrp.BurnPrm{}
|
prm := balance.BurnPrm{}
|
||||||
|
|
||||||
prm.SetTo(cheque.LockAccount())
|
prm.SetTo(cheque.LockAccount())
|
||||||
prm.SetAmount(np.converter.ToBalancePrecision(cheque.Amount()))
|
prm.SetAmount(np.converter.ToBalancePrecision(cheque.Amount()))
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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"
|
||||||
balanceWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
neofsid "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
neofsid "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
||||||
nmWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
nmWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -39,7 +39,7 @@ type (
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
pool *ants.Pool
|
pool *ants.Pool
|
||||||
neofsContract util.Uint160
|
neofsContract util.Uint160
|
||||||
balanceClient *balanceWrapper.Wrapper
|
balanceClient *balance.Client
|
||||||
netmapClient *nmWrapper.Wrapper
|
netmapClient *nmWrapper.Wrapper
|
||||||
morphClient *client.Client
|
morphClient *client.Client
|
||||||
epochState EpochState
|
epochState EpochState
|
||||||
|
@ -60,7 +60,7 @@ type (
|
||||||
PoolSize int
|
PoolSize int
|
||||||
NeoFSContract util.Uint160
|
NeoFSContract util.Uint160
|
||||||
NeoFSIDClient *neofsid.ClientWrapper
|
NeoFSIDClient *neofsid.ClientWrapper
|
||||||
BalanceClient *balanceWrapper.Wrapper
|
BalanceClient *balance.Client
|
||||||
NetmapClient *nmWrapper.Wrapper
|
NetmapClient *nmWrapper.Wrapper
|
||||||
MorphClient *client.Client
|
MorphClient *client.Client
|
||||||
EpochState EpochState
|
EpochState EpochState
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/basic"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/basic"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/common"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/common"
|
||||||
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
||||||
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
||||||
|
@ -46,7 +46,7 @@ type settlementDeps struct {
|
||||||
|
|
||||||
clientCache *ClientCache
|
clientCache *ClientCache
|
||||||
|
|
||||||
balanceClient *balanceClient.Wrapper
|
balanceClient *balanceClient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type auditSettlementDeps struct {
|
type auditSettlementDeps struct {
|
||||||
|
|
|
@ -4,39 +4,22 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetBalanceOfArgs groups the arguments
|
// BalanceOf receives the amount of funds in the client's account
|
||||||
// of "balance of" test invoke call.
|
// through the Balance contract call, and returns it.
|
||||||
type GetBalanceOfArgs struct {
|
func (c *Client) BalanceOf(id *owner.ID) (*big.Int, error) {
|
||||||
wallet []byte // wallet script hash
|
h, err := address.StringToUint160(id.String())
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetBalanceOfValues groups the stack parameters
|
|
||||||
// returned by "balance of" test invoke.
|
|
||||||
type GetBalanceOfValues struct {
|
|
||||||
amount *big.Int // wallet funds amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetWallet sets the wallet script hash
|
|
||||||
// in a binary format.
|
|
||||||
func (g *GetBalanceOfArgs) SetWallet(v []byte) {
|
|
||||||
g.wallet = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Amount returns the amount of funds.
|
|
||||||
func (g *GetBalanceOfValues) Amount() *big.Int {
|
|
||||||
return g.amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// BalanceOf performs the test invoke of "balance of"
|
|
||||||
// method of NeoFS Balance contract.
|
|
||||||
func (c *Client) BalanceOf(args GetBalanceOfArgs) (*GetBalanceOfValues, error) {
|
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
|
|
||||||
invokePrm.SetMethod(balanceOfMethod)
|
invokePrm.SetMethod(balanceOfMethod)
|
||||||
invokePrm.SetArgs(args.wallet)
|
invokePrm.SetArgs(h.BytesBE())
|
||||||
|
|
||||||
prms, err := c.client.TestInvoke(invokePrm)
|
prms, err := c.client.TestInvoke(invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,8 +32,5 @@ func (c *Client) BalanceOf(args GetBalanceOfArgs) (*GetBalanceOfValues, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", balanceOfMethod, err)
|
return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", balanceOfMethod, err)
|
||||||
}
|
}
|
||||||
|
return amount, nil
|
||||||
return &GetBalanceOfValues{
|
|
||||||
amount: amount,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
40
pkg/morph/client/balance/burn.go
Normal file
40
pkg/morph/client/balance/burn.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package balance
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BurnPrm groups parameters of Burn operation.
|
||||||
|
type BurnPrm struct {
|
||||||
|
to util.Uint160
|
||||||
|
amount int64
|
||||||
|
id []byte
|
||||||
|
|
||||||
|
client.InvokePrmOptional
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTo sets receiver.
|
||||||
|
func (b *BurnPrm) SetTo(to util.Uint160) {
|
||||||
|
b.to = to
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAmount sets amount.
|
||||||
|
func (b *BurnPrm) SetAmount(amount int64) {
|
||||||
|
b.amount = amount
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets ID
|
||||||
|
func (b *BurnPrm) SetID(id []byte) {
|
||||||
|
b.id = id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Burn destroys funds from the account.
|
||||||
|
func (c *Client) Burn(p BurnPrm) error {
|
||||||
|
prm := client.InvokePrm{}
|
||||||
|
prm.SetMethod(burnMethod)
|
||||||
|
prm.SetArgs(p.to.BytesBE(), p.amount, p.id)
|
||||||
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||||
|
|
||||||
|
return c.client.Invoke(prm)
|
||||||
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package balance
|
package balance
|
||||||
|
|
||||||
import (
|
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,7 +29,49 @@ const (
|
||||||
decimalsMethod = "decimals"
|
decimalsMethod = "decimals"
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates, initializes and returns the Client instance.
|
// NewFromMorph returns the wrapper instance from the raw morph client.
|
||||||
func New(c *client.StaticClient) *Client {
|
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*Client, error) {
|
||||||
return &Client{client: c}
|
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 Balance contract: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Client{
|
||||||
|
client: staticClient,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Option allows to set an optional
|
||||||
|
// parameter of Wrapper.
|
||||||
|
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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,42 +6,22 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DecimalsArgs groups the arguments
|
// Decimals decimal precision of currency transactions
|
||||||
// of decimals test invoke call.
|
// through the Balance contract call, and returns it.
|
||||||
type DecimalsArgs struct {
|
func (c *Client) Decimals() (uint32, error) {
|
||||||
}
|
|
||||||
|
|
||||||
// DecimalsValues groups the stack parameters
|
|
||||||
// returned by decimals test invoke.
|
|
||||||
type DecimalsValues struct {
|
|
||||||
decimals int64 // decimals value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decimals returns the decimals value.
|
|
||||||
func (d *DecimalsValues) Decimals() int64 {
|
|
||||||
return d.decimals
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decimals performs the test invoke of decimals
|
|
||||||
// method of NeoFS Balance contract.
|
|
||||||
func (c *Client) Decimals(args DecimalsArgs) (*DecimalsValues, error) {
|
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
|
|
||||||
invokePrm.SetMethod(decimalsMethod)
|
invokePrm.SetMethod(decimalsMethod)
|
||||||
|
|
||||||
prms, err := c.client.TestInvoke(invokePrm)
|
prms, err := c.client.TestInvoke(invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", decimalsMethod, err)
|
return 0, fmt.Errorf("could not perform test invocation (%s): %w", decimalsMethod, err)
|
||||||
} else if ln := len(prms); ln != 1 {
|
} else if ln := len(prms); ln != 1 {
|
||||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", decimalsMethod, ln)
|
return 0, fmt.Errorf("unexpected stack item count (%s): %d", decimalsMethod, ln)
|
||||||
}
|
}
|
||||||
|
|
||||||
decimals, err := client.IntFromStackItem(prms[0])
|
decimals, err := client.IntFromStackItem(prms[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", decimalsMethod, err)
|
return 0, fmt.Errorf("could not get integer stack item from stack item (%s): %w", decimalsMethod, err)
|
||||||
}
|
}
|
||||||
|
return uint32(decimals), nil
|
||||||
return &DecimalsValues{
|
|
||||||
decimals: decimals,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
52
pkg/morph/client/balance/lock.go
Normal file
52
pkg/morph/client/balance/lock.go
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package balance
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LockPrm groups parameters of Lock operation.
|
||||||
|
type LockPrm struct {
|
||||||
|
id []byte
|
||||||
|
user util.Uint160
|
||||||
|
lock util.Uint160
|
||||||
|
amount int64
|
||||||
|
dueEpoch int64
|
||||||
|
|
||||||
|
client.InvokePrmOptional
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets ID.
|
||||||
|
func (l *LockPrm) SetID(id []byte) {
|
||||||
|
l.id = id
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser set user.
|
||||||
|
func (l *LockPrm) SetUser(user util.Uint160) {
|
||||||
|
l.user = user
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLock sets lock.
|
||||||
|
func (l *LockPrm) SetLock(lock util.Uint160) {
|
||||||
|
l.lock = lock
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAmount sets amount.
|
||||||
|
func (l *LockPrm) SetAmount(amount int64) {
|
||||||
|
l.amount = amount
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDueEpoch sets end of the lock.
|
||||||
|
func (l *LockPrm) SetDueEpoch(dueEpoch int64) {
|
||||||
|
l.dueEpoch = dueEpoch
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock locks fund on the user account.
|
||||||
|
func (c *Client) Lock(p LockPrm) error {
|
||||||
|
prm := client.InvokePrm{}
|
||||||
|
prm.SetMethod(lockMethod)
|
||||||
|
prm.SetArgs(p.id, p.user.BytesBE(), p.lock.BytesBE(), p.amount, p.dueEpoch)
|
||||||
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||||
|
|
||||||
|
return c.client.Invoke(prm)
|
||||||
|
}
|
40
pkg/morph/client/balance/mint.go
Normal file
40
pkg/morph/client/balance/mint.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package balance
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MintPrm groups parameters of Mint operation.
|
||||||
|
type MintPrm struct {
|
||||||
|
to util.Uint160
|
||||||
|
amount int64
|
||||||
|
id []byte
|
||||||
|
|
||||||
|
client.InvokePrmOptional
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTo sets receiver of the transfer.
|
||||||
|
func (m *MintPrm) SetTo(to util.Uint160) {
|
||||||
|
m.to = to
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAmount sets amount of the transfer.
|
||||||
|
func (m *MintPrm) SetAmount(amount int64) {
|
||||||
|
m.amount = amount
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets ID.
|
||||||
|
func (m *MintPrm) SetID(id []byte) {
|
||||||
|
m.id = id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mint sends funds to the account.
|
||||||
|
func (c *Client) Mint(p MintPrm) error {
|
||||||
|
prm := client.InvokePrm{}
|
||||||
|
prm.SetMethod(mintMethod)
|
||||||
|
prm.SetArgs(p.to.BytesBE(), p.amount, p.id)
|
||||||
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||||
|
|
||||||
|
return c.client.Invoke(prm)
|
||||||
|
}
|
|
@ -3,177 +3,45 @@ package balance
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransferXArgs groups the arguments
|
// TransferPrm groups parameters of TransferX method.
|
||||||
// of "transferX" invocation call.
|
type TransferPrm struct {
|
||||||
type TransferXArgs struct {
|
Amount int64
|
||||||
amount int64 // amount in GASe-12
|
|
||||||
|
|
||||||
sender []byte // sender's wallet script hash
|
From, To *owner.ID
|
||||||
|
|
||||||
recipient []byte // recipient's wallet script hash
|
Details []byte
|
||||||
|
|
||||||
details []byte // transfer details
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
client.InvokePrmOptional
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAmount sets amount of funds to transfer
|
// TransferX transfers p.Amount of GASe-12 from p.From to p.To
|
||||||
// in GASe-12.
|
// with details p.Details through direct smart contract call.
|
||||||
func (t *TransferXArgs) SetAmount(v int64) {
|
//
|
||||||
t.amount = v
|
// If TryNotary is provided, calls notary contract.
|
||||||
}
|
func (c *Client) TransferX(p TransferPrm) error {
|
||||||
|
from, err := address.StringToUint160(p.From.String())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// SetSender sets wallet script hash
|
to, err := address.StringToUint160(p.To.String())
|
||||||
// of the sender of funds in a binary format.
|
if err != nil {
|
||||||
func (t *TransferXArgs) SetSender(v []byte) {
|
return err
|
||||||
t.sender = v
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// SetRecipient sets wallet script hash
|
|
||||||
// of the recipient of funds in a binary format.
|
|
||||||
func (t *TransferXArgs) SetRecipient(v []byte) {
|
|
||||||
t.recipient = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDetails sets details of the money transaction
|
|
||||||
// in a binary format.
|
|
||||||
func (t *TransferXArgs) SetDetails(v []byte) {
|
|
||||||
t.details = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransferX directly invokes the call of "transferX" method
|
|
||||||
// of NeoFS Balance contract.
|
|
||||||
func (c *Client) TransferX(args TransferXArgs) error {
|
|
||||||
prm := client.InvokePrm{}
|
prm := client.InvokePrm{}
|
||||||
|
|
||||||
prm.SetMethod(transferXMethod)
|
prm.SetMethod(transferXMethod)
|
||||||
prm.SetArgs(args.sender, args.recipient, args.amount, args.details)
|
prm.SetArgs(from.BytesBE(), to.BytesBE(), p.Amount, p.Details)
|
||||||
prm.InvokePrmOptional = args.InvokePrmOptional
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||||
|
|
||||||
err := c.client.Invoke(prm)
|
err = c.client.Invoke(prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not invoke method (%s): %w", transferXMethod, err)
|
return fmt.Errorf("could not invoke method (%s): %w", transferXMethod, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MintPrm groups parameters of Mint operation.
|
|
||||||
type MintPrm struct {
|
|
||||||
to []byte
|
|
||||||
amount int64
|
|
||||||
id []byte
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets receiver of the transfer.
|
|
||||||
func (m *MintPrm) SetTo(to []byte) {
|
|
||||||
m.to = to
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount of the transfer.
|
|
||||||
func (m *MintPrm) SetAmount(amount int64) {
|
|
||||||
m.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID.
|
|
||||||
func (m *MintPrm) SetID(id []byte) {
|
|
||||||
m.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mint invokes `mint` method of the balance contract.
|
|
||||||
func (c *Client) Mint(args MintPrm) error {
|
|
||||||
prm := client.InvokePrm{}
|
|
||||||
|
|
||||||
prm.SetMethod(mintMethod)
|
|
||||||
prm.SetArgs(args.to, args.amount, args.id)
|
|
||||||
prm.InvokePrmOptional = args.InvokePrmOptional
|
|
||||||
|
|
||||||
return c.client.Invoke(prm)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BurnPrm groups parameters of Burn operation.
|
|
||||||
type BurnPrm struct {
|
|
||||||
to []byte
|
|
||||||
amount int64
|
|
||||||
id []byte
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets receiver.
|
|
||||||
func (b *BurnPrm) SetTo(to []byte) {
|
|
||||||
b.to = to
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount.
|
|
||||||
func (b *BurnPrm) SetAmount(amount int64) {
|
|
||||||
b.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID.
|
|
||||||
func (b *BurnPrm) SetID(id []byte) {
|
|
||||||
b.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Burn invokes `burn` method of the balance contract.
|
|
||||||
func (c *Client) Burn(args BurnPrm) error {
|
|
||||||
prm := client.InvokePrm{}
|
|
||||||
|
|
||||||
prm.SetMethod(burnMethod)
|
|
||||||
prm.SetArgs(args.to, args.amount, args.id)
|
|
||||||
prm.InvokePrmOptional = args.InvokePrmOptional
|
|
||||||
|
|
||||||
return c.client.Invoke(prm)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LockPrm groups parameters of Lock operation.
|
|
||||||
type LockPrm struct {
|
|
||||||
id []byte
|
|
||||||
user []byte
|
|
||||||
lock []byte
|
|
||||||
amount int64
|
|
||||||
dueEpoch int64
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID.
|
|
||||||
func (l *LockPrm) SetID(id []byte) {
|
|
||||||
l.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUser set user.
|
|
||||||
func (l *LockPrm) SetUser(user []byte) {
|
|
||||||
l.user = user
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLock sets lock.
|
|
||||||
func (l *LockPrm) SetLock(lock []byte) {
|
|
||||||
l.lock = lock
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount.
|
|
||||||
func (l *LockPrm) SetAmount(amount int64) {
|
|
||||||
l.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDueEpoch sets end of the lock.
|
|
||||||
func (l *LockPrm) SetDueEpoch(dueEpoch int64) {
|
|
||||||
l.dueEpoch = dueEpoch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock invokes `lock` method of the balance contract.
|
|
||||||
func (c *Client) Lock(args LockPrm) error {
|
|
||||||
prm := client.InvokePrm{}
|
|
||||||
|
|
||||||
prm.SetMethod(lockMethod)
|
|
||||||
prm.SetArgs(args.id, args.user, args.lock, args.amount, args.dueEpoch)
|
|
||||||
prm.InvokePrmOptional = args.InvokePrmOptional
|
|
||||||
|
|
||||||
return c.client.Invoke(prm)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package wrapper
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BalanceOf receives the amount of funds in the client's account
|
|
||||||
// through the Balance contract call, and returns it.
|
|
||||||
func (w *Wrapper) BalanceOf(id *owner.ID) (*big.Int, error) {
|
|
||||||
h, err := address.StringToUint160(id.String())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
args := balance.GetBalanceOfArgs{}
|
|
||||||
args.SetWallet(h.BytesBE())
|
|
||||||
|
|
||||||
result, err := w.client.BalanceOf(args)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.Amount(), nil
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package wrapper
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decimals decimal precision of currency transactions
|
|
||||||
// through the Balance contract call, and returns it.
|
|
||||||
func (w *Wrapper) Decimals() (uint32, error) {
|
|
||||||
// prepare invocation arguments
|
|
||||||
args := balance.DecimalsArgs{}
|
|
||||||
|
|
||||||
// invoke smart contract call
|
|
||||||
values, err := w.client.Decimals(args)
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("could not invoke smart contract: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return uint32(values.Decimals()), nil
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
package wrapper
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
||||||
"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/balance"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TransferPrm groups parameters of TransferX method.
|
|
||||||
type TransferPrm struct {
|
|
||||||
Amount int64
|
|
||||||
|
|
||||||
From, To *owner.ID
|
|
||||||
|
|
||||||
Details []byte
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransferX transfers p.Amount of GASe-12 from p.From to p.To
|
|
||||||
// with details p.Details through direct smart contract call.
|
|
||||||
//
|
|
||||||
// If TryNotary is provided, calls notary contract.
|
|
||||||
func (w *Wrapper) TransferX(p TransferPrm) error {
|
|
||||||
from, err := address.StringToUint160(p.From.String())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
to, err := address.StringToUint160(p.To.String())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare invocation arguments
|
|
||||||
args := balance.TransferXArgs{}
|
|
||||||
args.SetSender(from.BytesBE())
|
|
||||||
args.SetRecipient(to.BytesBE())
|
|
||||||
args.SetAmount(p.Amount)
|
|
||||||
args.SetDetails(p.Details)
|
|
||||||
args.InvokePrmOptional = p.InvokePrmOptional
|
|
||||||
|
|
||||||
return w.client.TransferX(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MintPrm groups parameters of Mint operation.
|
|
||||||
type MintPrm struct {
|
|
||||||
to util.Uint160
|
|
||||||
amount int64
|
|
||||||
id []byte
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets receiver of the transfer.
|
|
||||||
func (m *MintPrm) SetTo(to util.Uint160) {
|
|
||||||
m.to = to
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount of the transfer.
|
|
||||||
func (m *MintPrm) SetAmount(amount int64) {
|
|
||||||
m.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID.
|
|
||||||
func (m *MintPrm) SetID(id []byte) {
|
|
||||||
m.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mint sends funds to the account.
|
|
||||||
func (w *Wrapper) Mint(prm MintPrm) error {
|
|
||||||
args := balance.MintPrm{}
|
|
||||||
|
|
||||||
args.SetTo(prm.to.BytesBE())
|
|
||||||
args.SetAmount(prm.amount)
|
|
||||||
args.SetID(prm.id)
|
|
||||||
args.InvokePrmOptional = prm.InvokePrmOptional
|
|
||||||
|
|
||||||
return w.client.Mint(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BurnPrm groups parameters of Burn operation.
|
|
||||||
type BurnPrm struct {
|
|
||||||
to util.Uint160
|
|
||||||
amount int64
|
|
||||||
id []byte
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets receiver.
|
|
||||||
func (b *BurnPrm) SetTo(to util.Uint160) {
|
|
||||||
b.to = to
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount.
|
|
||||||
func (b *BurnPrm) SetAmount(amount int64) {
|
|
||||||
b.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID
|
|
||||||
func (b *BurnPrm) SetID(id []byte) {
|
|
||||||
b.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Burn destroys funds from the account.
|
|
||||||
func (w *Wrapper) Burn(prm BurnPrm) error {
|
|
||||||
args := balance.BurnPrm{}
|
|
||||||
|
|
||||||
args.SetTo(prm.to.BytesBE())
|
|
||||||
args.SetAmount(prm.amount)
|
|
||||||
args.SetID(prm.id)
|
|
||||||
args.InvokePrmOptional = prm.InvokePrmOptional
|
|
||||||
|
|
||||||
return w.client.Burn(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LockPrm groups parameters of Lock operation.
|
|
||||||
type LockPrm struct {
|
|
||||||
id []byte
|
|
||||||
user util.Uint160
|
|
||||||
lock util.Uint160
|
|
||||||
amount int64
|
|
||||||
dueEpoch int64
|
|
||||||
|
|
||||||
client.InvokePrmOptional
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets ID.
|
|
||||||
func (l *LockPrm) SetID(id []byte) {
|
|
||||||
l.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUser set user.
|
|
||||||
func (l *LockPrm) SetUser(user util.Uint160) {
|
|
||||||
l.user = user
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLock sets lock.
|
|
||||||
func (l *LockPrm) SetLock(lock util.Uint160) {
|
|
||||||
l.lock = lock
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAmount sets amount.
|
|
||||||
func (l *LockPrm) SetAmount(amount int64) {
|
|
||||||
l.amount = amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDueEpoch sets end of the lock.
|
|
||||||
func (l *LockPrm) SetDueEpoch(dueEpoch int64) {
|
|
||||||
l.dueEpoch = dueEpoch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock locks fund on the user account.
|
|
||||||
func (w *Wrapper) Lock(prm LockPrm) error {
|
|
||||||
args := balance.LockPrm{}
|
|
||||||
|
|
||||||
args.SetID(prm.id)
|
|
||||||
args.SetUser(prm.user.BytesBE())
|
|
||||||
args.SetLock(prm.lock.BytesBE())
|
|
||||||
args.SetAmount(prm.amount)
|
|
||||||
args.SetDueEpoch(prm.dueEpoch)
|
|
||||||
args.InvokePrmOptional = prm.InvokePrmOptional
|
|
||||||
|
|
||||||
return w.client.Lock(args)
|
|
||||||
}
|
|
|
@ -1,74 +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/balance"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/internal"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Wrapper is a wrapper over balance contract
|
|
||||||
// client which implements:
|
|
||||||
// * tool for obtaining the amount of funds in the client's account;
|
|
||||||
// * tool for obtaining decimal precision of currency transactions.
|
|
||||||
//
|
|
||||||
// Working wrapper must be created via constructor New.
|
|
||||||
// Using the Wrapper that has been created with new(Wrapper)
|
|
||||||
// expression (or just declaring a Wrapper variable) is unsafe
|
|
||||||
// and can lead to panic.
|
|
||||||
type Wrapper struct {
|
|
||||||
internal.StaticClient
|
|
||||||
|
|
||||||
client *balance.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Option allows to set an optional
|
|
||||||
// parameter of Wrapper.
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewFromMorph returns the wrapper instance from the raw morph client.
|
|
||||||
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("could not create static client of Balance contract: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Wrapper{
|
|
||||||
StaticClient: staticClient,
|
|
||||||
client: balance.New(staticClient),
|
|
||||||
}, nil
|
|
||||||
}
|
|
|
@ -4,16 +4,16 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||||
accountingSvc "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
|
accountingSvc "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
)
|
)
|
||||||
|
|
||||||
type morphExecutor struct {
|
type morphExecutor struct {
|
||||||
client *wrapper.Wrapper
|
client *balance.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExecutor(client *wrapper.Wrapper) accountingSvc.ServiceExecutor {
|
func NewExecutor(client *balance.Client) accountingSvc.ServiceExecutor {
|
||||||
return &morphExecutor{
|
return &morphExecutor{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue