forked from TrueCloudLab/frostfs-node
[#326] morph/balance: Provide interface to "transferX" method's invocations
Implement TransferX method on Balance contract client. Implement TransferX method on Balance client's wrapper that encapsulates it's TransferX call. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f7a9e43165
commit
20ad0ae82a
3 changed files with 110 additions and 0 deletions
53
pkg/morph/client/balance/transfer.go
Normal file
53
pkg/morph/client/balance/transfer.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// TransferXArgs groups the arguments
|
||||
// of "transferX" invocation call.
|
||||
type TransferXArgs struct {
|
||||
amount int64 // amount in GASe-12
|
||||
|
||||
sender []byte // sender's wallet script hash
|
||||
|
||||
recipient []byte // recipient's wallet script hash
|
||||
|
||||
details []byte // transfer details
|
||||
}
|
||||
|
||||
// SetAmount sets amount of funds to transfer
|
||||
// in GASe-12.
|
||||
func (t *TransferXArgs) SetAmount(v int64) {
|
||||
t.amount = v
|
||||
}
|
||||
|
||||
// SetSender sets wallet script hash
|
||||
// of the sender of funds in a binary format.
|
||||
func (t *TransferXArgs) SetSender(v []byte) {
|
||||
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 invokes the call of "transferX" method
|
||||
// of NeoFS Balance contract.
|
||||
func (c *Client) TransferX(args TransferXArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.transferXMethod,
|
||||
args.sender,
|
||||
args.recipient,
|
||||
args.amount,
|
||||
args.details,
|
||||
), "could not invoke method (%s)", c.transferXMethod)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue