forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
6a51086030
The notary is always enabled and this option does always work. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
45 lines
949 B
Go
45 lines
949 B
Go
package balance
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
|
)
|
|
|
|
// TransferPrm groups parameters of TransferX method.
|
|
type TransferPrm struct {
|
|
Amount int64
|
|
|
|
From, To user.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.
|
|
func (c *Client) TransferX(ctx context.Context, p TransferPrm) error {
|
|
from, err := p.From.ScriptHash()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
to, err := p.To.ScriptHash()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
prm := client.InvokePrm{}
|
|
prm.SetMethod(transferXMethod)
|
|
prm.SetArgs(from, to, p.Amount, p.Details)
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
|
|
|
_, err = c.client.Invoke(ctx, prm)
|
|
if err != nil {
|
|
return fmt.Errorf("could not invoke method (%s): %w", transferXMethod, err)
|
|
}
|
|
return nil
|
|
}
|