morph: Use (user.ID).ScriptHash() where possible #1537

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:fix-scripthash into master 2024-12-04 11:16:16 +00:00
2 changed files with 3 additions and 5 deletions
Showing only changes of commit 2d5d4093be - Show all commits

View file

@ -6,13 +6,12 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
) )
// BalanceOf receives the amount of funds in the client's account // BalanceOf receives the amount of funds in the client's account
// through the Balance contract call, and returns it. // through the Balance contract call, and returns it.
func (c *Client) BalanceOf(id user.ID) (*big.Int, error) { func (c *Client) BalanceOf(id user.ID) (*big.Int, error) {
h, err := address.StringToUint160(id.EncodeToString()) h, err := id.ScriptHash()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -6,7 +6,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
) )
// TransferPrm groups parameters of TransferX method. // TransferPrm groups parameters of TransferX method.
@ -25,12 +24,12 @@ type TransferPrm struct {
// //
// If TryNotary is provided, calls notary contract. // If TryNotary is provided, calls notary contract.
func (c *Client) TransferX(ctx context.Context, p TransferPrm) error { func (c *Client) TransferX(ctx context.Context, p TransferPrm) error {
from, err := address.StringToUint160(p.From.EncodeToString()) from, err := p.From.ScriptHash()
if err != nil { if err != nil {
return err return err
} }
to, err := address.StringToUint160(p.To.EncodeToString()) to, err := p.To.ScriptHash()
if err != nil { if err != nil {
return err return err
} }