frostfs-node/pkg/morph/client/balance/wrapper/balanceOf.go
Alex Vanin 80f10dab7b [#16] Fix balanceOf wrapper for api request
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:35 +03:00

25 lines
551 B
Go

package wrapper
import (
"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) (int64, error) {
v, err := owner.ScriptHashBE(id)
if err != nil {
return 0, err
}
args := balance.GetBalanceOfArgs{}
args.SetWallet(v)
result, err := w.client.BalanceOf(args)
if err != nil {
return 0, err
}
return result.Amount(), nil
}