[#122] Return big.Int in balanceOf
function
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
e3c060b739
commit
03f52bca01
2 changed files with 10 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -14,7 +16,7 @@ type GetBalanceOfArgs struct {
|
|||
// GetBalanceOfValues groups the stack parameters
|
||||
// returned by "balance of" test invoke.
|
||||
type GetBalanceOfValues struct {
|
||||
amount int64 // wallet funds amount
|
||||
amount *big.Int // wallet funds amount
|
||||
}
|
||||
|
||||
// SetWallet sets the wallet script hash
|
||||
|
@ -24,7 +26,7 @@ func (g *GetBalanceOfArgs) SetWallet(v []byte) {
|
|||
}
|
||||
|
||||
// Amount returns the amount of funds.
|
||||
func (g *GetBalanceOfValues) Amount() int64 {
|
||||
func (g *GetBalanceOfValues) Amount() *big.Int {
|
||||
return g.amount
|
||||
}
|
||||
|
||||
|
@ -41,7 +43,7 @@ func (c *Client) BalanceOf(args GetBalanceOfArgs) (*GetBalanceOfValues, error) {
|
|||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.balanceOfMethod, ln)
|
||||
}
|
||||
|
||||
amount, err := client.IntFromStackItem(prms[0])
|
||||
amount, err := client.BigIntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get integer stack item from stack item (%s)", c.balanceOfMethod)
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
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) (int64, error) {
|
||||
func (w *Wrapper) BalanceOf(id *owner.ID) (*big.Int, error) {
|
||||
v, err := owner.ScriptHashBE(id)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
args := balance.GetBalanceOfArgs{}
|
||||
|
@ -18,7 +20,7 @@ func (w *Wrapper) BalanceOf(id *owner.ID) (int64, error) {
|
|||
|
||||
result, err := w.client.BalanceOf(args)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result.Amount(), nil
|
||||
|
|
Loading…
Reference in a new issue