From e013477bc9500e34657178e1466f52ed18224e0b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 24 Jul 2020 16:34:46 +0300 Subject: [PATCH] rpc,cli: support multitransfer transactions Allow to transfer single asset to multiple recepients in a single transaction. It is currently a separate command in CLI and can be merged in future. --- cli/wallet/nep5.go | 110 ++++++++++++++++++++++++++++++++++++----- pkg/rpc/client/nep5.go | 38 ++++++++++++-- 2 files changed, 131 insertions(+), 17 deletions(-) diff --git a/cli/wallet/nep5.go b/cli/wallet/nep5.go index da9f9c3c2..67c3d0c11 100644 --- a/cli/wallet/nep5.go +++ b/cli/wallet/nep5.go @@ -25,17 +25,25 @@ var ( gasToken = wallet.NewToken(client.GasContractHash, "GAS", "gas", 8) ) +var ( + tokenFlag = cli.StringFlag{ + Name: "token", + Usage: "Token to use", + } + gasFlag = flags.Fixed8Flag{ + Name: "gas", + Usage: "Amount of GAS to attach to a tx", + } +) + func newNEP5Commands() []cli.Command { balanceFlags := []cli.Flag{ walletPathFlag, + tokenFlag, cli.StringFlag{ Name: "addr", Usage: "Address to use", }, - cli.StringFlag{ - Name: "token", - Usage: "Token to use", - }, } balanceFlags = append(balanceFlags, options.RPC...) importFlags := []cli.Flag{ @@ -51,20 +59,22 @@ func newNEP5Commands() []cli.Command { outFlag, fromAddrFlag, toAddrFlag, - cli.StringFlag{ - Name: "token", - Usage: "Token to use", - }, + tokenFlag, + gasFlag, cli.StringFlag{ Name: "amount", Usage: "Amount of asset to send", }, - flags.Fixed8Flag{ - Name: "gas", - Usage: "Amount of GAS to attach to a tx", - }, } transferFlags = append(transferFlags, options.RPC...) + multiTransferFlags := []cli.Flag{ + walletPathFlag, + outFlag, + fromAddrFlag, + tokenFlag, + gasFlag, + } + multiTransferFlags = append(multiTransferFlags, options.RPC...) return []cli.Command{ { Name: "balance", @@ -114,6 +124,14 @@ func newNEP5Commands() []cli.Command { Action: transferNEP5, Flags: transferFlags, }, + { + Name: "multitransfer", + Usage: "transfer NEP5 tokens to multiple recepients", + UsageText: `multitransfer --wallet --rpc-endpoint --timeout