From 3b2644da4f6b21bbe14fb5cf546205147b41d850 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 28 May 2020 22:55:44 +0300 Subject: [PATCH] rpc/client: pass token as simple hash into TransferNEP5 It doesn't need full wallet.Token structure. --- cli/wallet/nep5.go | 2 +- pkg/rpc/client/nep5.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/wallet/nep5.go b/cli/wallet/nep5.go index d0e3e0d1f..306fc5f4b 100644 --- a/cli/wallet/nep5.go +++ b/cli/wallet/nep5.go @@ -341,7 +341,7 @@ func transferNEP5(ctx *cli.Context) error { return cli.NewExitError(err, 1) } - hash, err := c.TransferNEP5(acc, to, token, amount, gas) + hash, err := c.TransferNEP5(acc, to, token.Hash, amount, gas) if err != nil { return cli.NewExitError(err, 1) } diff --git a/pkg/rpc/client/nep5.go b/pkg/rpc/client/nep5.go index 06302e8eb..063c4524b 100644 --- a/pkg/rpc/client/nep5.go +++ b/pkg/rpc/client/nep5.go @@ -97,7 +97,7 @@ func (c *Client) NEP5TokenInfo(tokenHash util.Uint160) (*wallet.Token, error) { // TransferNEP5 creates an invocation transaction that invokes 'transfer' method // on a given token to move specified amount of NEP5 assets (in FixedN format // using contract's number of decimals) to given account. -func (c *Client) TransferNEP5(acc *wallet.Account, to util.Uint160, token *wallet.Token, amount int64, gas util.Fixed8) (util.Uint256, error) { +func (c *Client) TransferNEP5(acc *wallet.Account, to util.Uint160, token util.Uint160, amount int64, gas util.Fixed8) (util.Uint256, error) { from, err := address.StringToUint160(acc.Address) if err != nil { return util.Uint256{}, fmt.Errorf("bad account address: %v", err) @@ -105,7 +105,7 @@ func (c *Client) TransferNEP5(acc *wallet.Account, to util.Uint160, token *walle // Note: we don't use invoke function here because it requires // 2 round trips instead of one. w := io.NewBufBinWriter() - emit.AppCallWithOperationAndArgs(w.BinWriter, token.Hash, "transfer", from, to, amount) + emit.AppCallWithOperationAndArgs(w.BinWriter, token, "transfer", from, to, amount) emit.Opcode(w.BinWriter, opcode.ASSERT) script := w.Bytes()