rpc/client: pass token as simple hash into TransferNEP5

It doesn't need full wallet.Token structure.
This commit is contained in:
Roman Khimov 2020-05-28 22:55:44 +03:00
parent ed0a3e4af5
commit 3b2644da4f
2 changed files with 3 additions and 3 deletions

View file

@ -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)
}

View file

@ -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()