[#1618] pkg: Refactor user.ID.ScriptHash()
usage
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
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>
This commit is contained in:
parent
713f4b144c
commit
ae851b3922
6 changed files with 17 additions and 39 deletions
|
@ -11,10 +11,7 @@ import (
|
|||
// BalanceOf receives the amount of funds in the client's account
|
||||
// through the Balance contract call, and returns it.
|
||||
func (c *Client) BalanceOf(id user.ID) (*big.Int, error) {
|
||||
h, err := id.ScriptHash()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
h := id.ScriptHash()
|
||||
|
||||
invokePrm := client.TestInvokePrm{}
|
||||
invokePrm.SetMethod(balanceOfMethod)
|
||||
|
|
|
@ -22,22 +22,15 @@ type TransferPrm struct {
|
|||
// 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
|
||||
}
|
||||
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)
|
||||
_, err := c.client.Invoke(ctx, prm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invoke method (%s): %w", transferXMethod, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue