2021-01-26 10:21:16 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2021-01-26 10:21:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2021-02-25 16:49:05 +00:00
|
|
|
// TransferX directly invokes the call of "transferX" method
|
2021-01-26 10:21:16 +00:00
|
|
|
// of NeoFS Balance contract.
|
|
|
|
func (c *Client) TransferX(args TransferXArgs) error {
|
2021-06-02 16:29:19 +00:00
|
|
|
err := c.client.Invoke(
|
2021-01-26 10:21:16 +00:00
|
|
|
c.transferXMethod,
|
|
|
|
args.sender,
|
|
|
|
args.recipient,
|
|
|
|
args.amount,
|
|
|
|
args.details,
|
2021-05-18 08:12:51 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", c.transferXMethod, err)
|
|
|
|
}
|
2021-06-02 16:29:19 +00:00
|
|
|
|
2021-05-18 08:12:51 +00:00
|
|
|
return nil
|
2021-01-26 10:21:16 +00:00
|
|
|
}
|