mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
cli: allow to omit data
parameter for NEP17 transfers
There's a case when cosigners are specified and data is not.
This commit is contained in:
parent
3eefda7f1a
commit
8cfb72d5e9
2 changed files with 19 additions and 5 deletions
|
@ -76,12 +76,14 @@ func GetDataFromContext(ctx *cli.Context) (int, interface{}, *cli.ExitError) {
|
|||
if err != nil {
|
||||
return offset, nil, cli.NewExitError(fmt.Errorf("unable to parse 'data' parameter: %w", err), 1)
|
||||
}
|
||||
if len(params) != 1 {
|
||||
if len(params) > 1 {
|
||||
return offset, nil, cli.NewExitError("'data' should be represented as a single parameter", 1)
|
||||
}
|
||||
data, err = smartcontract.ExpandParameterToEmitable(params[0])
|
||||
if err != nil {
|
||||
return offset, nil, cli.NewExitError(fmt.Sprintf("failed to convert 'data' to emitable type: %s", err.Error()), 1)
|
||||
if len(params) != 0 {
|
||||
data, err = smartcontract.ExpandParameterToEmitable(params[0])
|
||||
if err != nil {
|
||||
return offset, nil, cli.NewExitError(fmt.Sprintf("failed to convert 'data' to emitable type: %s", err.Error()), 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
return offset, data, nil
|
||||
|
|
|
@ -134,9 +134,9 @@ func TestNEP17Transfer(t *testing.T) {
|
|||
require.Equal(t, big.NewInt(1), b)
|
||||
|
||||
hVerify := deployVerifyContract(t, e)
|
||||
const validatorDefault = "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo"
|
||||
|
||||
t.Run("default address", func(t *testing.T) {
|
||||
const validatorDefault = "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo"
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
|
@ -162,6 +162,18 @@ func TestNEP17Transfer(t *testing.T) {
|
|||
require.Equal(t, big.NewInt(41), b)
|
||||
})
|
||||
|
||||
t.Run("with signers", func(t *testing.T) {
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet,
|
||||
"--from", validatorAddr,
|
||||
"NEO:"+validatorDefault+":42",
|
||||
"GAS:"+validatorDefault+":7",
|
||||
"--", validatorAddr+":Global")
|
||||
e.checkTxPersisted(t)
|
||||
})
|
||||
|
||||
validTil := e.Chain.BlockHeight() + 100
|
||||
cmd := []string{
|
||||
"neo-go", "wallet", "nep17", "transfer",
|
||||
|
|
Loading…
Reference in a new issue