2020-07-24 13:54:03 +00:00
|
|
|
package wrapper
|
|
|
|
|
2020-09-01 14:33:26 +00:00
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
|
|
|
)
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// BalanceOf receives the amount of funds in the client's account
|
|
|
|
// through the Balance contract call, and returns it.
|
2020-09-01 14:33:26 +00:00
|
|
|
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
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|