diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index ed0bad0c1..b935faddb 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -828,7 +828,7 @@ func contractDeploy(ctx *cli.Context) error { return cli.NewExitError(fmt.Errorf("failed to restore manifest file: %w", err), 1) } - data, extErr := GetDataFromContext(ctx) + _, data, extErr := GetDataFromContext(ctx) if extErr != nil { return extErr } @@ -889,23 +889,28 @@ func contractDeploy(ctx *cli.Context) error { } // GetDataFromContext returns data parameter from context args. -func GetDataFromContext(ctx *cli.Context) (interface{}, *cli.ExitError) { - var data interface{} +func GetDataFromContext(ctx *cli.Context) (int, interface{}, *cli.ExitError) { + var ( + data interface{} + offset int + params []smartcontract.Parameter + err error + ) args := ctx.Args() if args.Present() { - _, params, err := ParseParams(args, true) + offset, params, err = ParseParams(args, true) if err != nil { - return nil, cli.NewExitError(fmt.Errorf("unable to parse 'data' parameter: %w", err), 1) + return offset, nil, cli.NewExitError(fmt.Errorf("unable to parse 'data' parameter: %w", err), 1) } if len(params) != 1 { - return nil, cli.NewExitError("'data' should be represented as a single parameter", 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 nil, cli.NewExitError(fmt.Sprintf("failed to convert 'data' to emitable type: %s", err.Error()), 1) + return offset, nil, cli.NewExitError(fmt.Sprintf("failed to convert 'data' to emitable type: %s", err.Error()), 1) } } - return data, nil + return offset, data, nil } // ParseContractConfig reads contract configuration file (.yaml) and returns unmarshalled ProjectConfig. diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 70817a15b..802e28ace 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -461,7 +461,7 @@ func transferNEP17(ctx *cli.Context) error { return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1) } - data, extErr := smartcontractcli.GetDataFromContext(ctx) + _, data, extErr := smartcontractcli.GetDataFromContext(ctx) if extErr != nil { return extErr }