From 42c1e8b0e3eac0ed911d6bf675b928a15e6b2244 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Fri, 25 Feb 2022 10:27:51 +0300 Subject: [PATCH] cli/smartcontract: allow to use 0x-prefixed hashes in generate Signed-off-by: Evgeniy Stratonikov --- cli/smartcontract/generate.go | 3 ++- cli/smartcontract/generate_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/smartcontract/generate.go b/cli/smartcontract/generate.go index c3e627866..7c9d3e493 100644 --- a/cli/smartcontract/generate.go +++ b/cli/smartcontract/generate.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "strings" "github.com/nspcc-dev/neo-go/pkg/smartcontract/binding" "github.com/nspcc-dev/neo-go/pkg/util" @@ -58,7 +59,7 @@ func contractGenerateWrapper(ctx *cli.Context) error { cfg.Manifest = m - h, err := util.Uint160DecodeStringLE(ctx.String("hash")) + h, err := util.Uint160DecodeStringLE(strings.TrimPrefix(ctx.String("hash"), "0x")) if err != nil { return cli.NewExitError(fmt.Errorf("invalid contract hash: %w", err), 1) } diff --git a/cli/smartcontract/generate_test.go b/cli/smartcontract/generate_test.go index 83d455209..28e04c624 100644 --- a/cli/smartcontract/generate_test.go +++ b/cli/smartcontract/generate_test.go @@ -256,7 +256,7 @@ func TestGenerateValidPackageName(t *testing.T) { require.NoError(t, app.Run([]string{"", "generate-wrapper", "--manifest", manifestFile, "--out", outFile, - "--hash", h.StringLE(), + "--hash", "0x" + h.StringLE(), })) data, err := ioutil.ReadFile(outFile)