[#971] *: Add optional parameters to balance morph client calls

Adapt all balance wrapper calls to new
structures.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-15 01:07:39 +03:00 committed by Alex Vanin
parent 644baf4985
commit ed4810a020

View file

@ -2,6 +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"
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"
) )
@ -19,11 +20,14 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
return return
} }
prm := balancewrp.MintPrm{}
prm.SetTo(deposit.To())
prm.SetAmount(np.converter.ToBalancePrecision(deposit.Amount()))
prm.SetID(deposit.ID())
// send transferX to balance contract // send transferX to balance contract
err := np.balanceClient.Mint( err := np.balanceClient.Mint(prm)
deposit.To(),
np.converter.ToBalancePrecision(deposit.Amount()),
deposit.ID())
if err != nil { if err != nil {
np.log.Error("can't transfer assets to balance contract", zap.Error(err)) np.log.Error("can't transfer assets to balance contract", zap.Error(err))
} }
@ -91,12 +95,15 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
curEpoch := np.epochState.EpochCounter() curEpoch := np.epochState.EpochCounter()
err = np.balanceClient.Lock( prm := balancewrp.LockPrm{}
withdraw.ID(),
withdraw.User(), prm.SetID(withdraw.ID())
lock, prm.SetUser(withdraw.User())
np.converter.ToBalancePrecision(withdraw.Amount()), prm.SetLock(lock)
int64(curEpoch+lockAccountLifetime)) prm.SetAmount(np.converter.ToBalancePrecision(withdraw.Amount()))
prm.SetDueEpoch(int64(curEpoch + lockAccountLifetime))
err = np.balanceClient.Lock(prm)
if err != nil { if err != nil {
np.log.Error("can't lock assets for withdraw", zap.Error(err)) np.log.Error("can't lock assets for withdraw", zap.Error(err))
} }
@ -110,10 +117,13 @@ func (np *Processor) processCheque(cheque *neofsEvent.Cheque) {
return return
} }
err := np.balanceClient.Burn( prm := balancewrp.BurnPrm{}
cheque.LockAccount(),
np.converter.ToBalancePrecision(cheque.Amount()), prm.SetTo(cheque.LockAccount())
cheque.ID()) prm.SetAmount(np.converter.ToBalancePrecision(cheque.Amount()))
prm.SetID(cheque.ID())
err := np.balanceClient.Burn(prm)
if err != nil { if err != nil {
np.log.Error("can't transfer assets to fed contract", zap.Error(err)) np.log.Error("can't transfer assets to fed contract", zap.Error(err))
} }