All checks were successful
DCO action / DCO (pull_request) Successful in 35s
Vulncheck / Vulncheck (pull_request) Successful in 51s
Build / Build Components (pull_request) Successful in 1m21s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m25s
Tests and linters / Run gofumpt (pull_request) Successful in 1m46s
Tests and linters / Staticcheck (pull_request) Successful in 1m59s
Tests and linters / Tests (pull_request) Successful in 2m3s
Tests and linters / Lint (pull_request) Successful in 3m3s
Tests and linters / gopls check (pull_request) Successful in 3m15s
Tests and linters / Tests with -race (pull_request) Successful in 3m54s
`user.ID.ScriptHash()` does not return an error anymore. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
38 lines
863 B
Go
38 lines
863 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 := p.From.ScriptHash()
|
|
to := p.To.ScriptHash()
|
|
|
|
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("invoke method (%s): %w", transferXMethod, err)
|
|
}
|
|
return nil
|
|
}
|