mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
cli/smartcontract: allow to use 0x-prefixed hashes in generate
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
870fd024c9
commit
42c1e8b0e3
2 changed files with 3 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -58,7 +59,7 @@ func contractGenerateWrapper(ctx *cli.Context) error {
|
||||||
|
|
||||||
cfg.Manifest = m
|
cfg.Manifest = m
|
||||||
|
|
||||||
h, err := util.Uint160DecodeStringLE(ctx.String("hash"))
|
h, err := util.Uint160DecodeStringLE(strings.TrimPrefix(ctx.String("hash"), "0x"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("invalid contract hash: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("invalid contract hash: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ func TestGenerateValidPackageName(t *testing.T) {
|
||||||
require.NoError(t, app.Run([]string{"", "generate-wrapper",
|
require.NoError(t, app.Run([]string{"", "generate-wrapper",
|
||||||
"--manifest", manifestFile,
|
"--manifest", manifestFile,
|
||||||
"--out", outFile,
|
"--out", outFile,
|
||||||
"--hash", h.StringLE(),
|
"--hash", "0x" + h.StringLE(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(outFile)
|
data, err := ioutil.ReadFile(outFile)
|
||||||
|
|
Loading…
Reference in a new issue