frostfs-node/pkg/morph/client/balance/wrapper/balanceOf.go
Alex Vanin 03f52bca01 [#122] Return big.Int in balanceOf function
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-29 10:14:59 +03:00

27 lines
571 B
Go

package wrapper
import (
"math/big"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
)
// BalanceOf receives the amount of funds in the client's account
// through the Balance contract call, and returns it.
func (w *Wrapper) BalanceOf(id *owner.ID) (*big.Int, error) {
v, err := owner.ScriptHashBE(id)
if err != nil {
return nil, err
}
args := balance.GetBalanceOfArgs{}
args.SetWallet(v)
result, err := w.client.BalanceOf(args)
if err != nil {
return nil, err
}
return result.Amount(), nil
}