mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-26 19:43:48 +00:00
cli: use AddressFlag for import-deployed
This commit is contained in:
parent
87f950a719
commit
92c6708fa0
2 changed files with 11 additions and 7 deletions
|
@ -197,9 +197,9 @@ func NewCommands() []cli.Command {
|
|||
Flags: append([]cli.Flag{
|
||||
walletPathFlag,
|
||||
wifFlag,
|
||||
cli.StringFlag{
|
||||
flags.AddressFlag{
|
||||
Name: "contract, c",
|
||||
Usage: "Contract hash",
|
||||
Usage: "Contract hash or address",
|
||||
},
|
||||
}, options.RPC...),
|
||||
},
|
||||
|
@ -421,10 +421,9 @@ func importDeployed(ctx *cli.Context) error {
|
|||
|
||||
defer wall.Close()
|
||||
|
||||
rawHash := ctx.String("contract")
|
||||
h, err := flags.ParseAddress(rawHash)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("invalid contract hash: %w", err), 1)
|
||||
rawHash := ctx.Generic("contract").(*flags.Address)
|
||||
if !rawHash.IsSet {
|
||||
return cli.NewExitError("contract hash was not provided", 1)
|
||||
}
|
||||
|
||||
acc, err := newAccountFromWIF(ctx.App.Writer, ctx.String("wif"))
|
||||
|
@ -440,7 +439,7 @@ func importDeployed(ctx *cli.Context) error {
|
|||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
|
||||
cs, err := c.GetContractStateByHash(h)
|
||||
cs, err := c.GetContractStateByHash(rawHash.Uint160())
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("can't fetch contract info: %w", err), 1)
|
||||
}
|
||||
|
|
|
@ -267,6 +267,11 @@ func TestImportDeployed(t *testing.T) {
|
|||
priv, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
// missing contract sh
|
||||
e.RunWithError(t, "neo-go", "wallet", "import-deployed",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath, "--wif", priv.WIF())
|
||||
|
||||
e.In.WriteString("acc\rpass\rpass\r")
|
||||
e.Run(t, "neo-go", "wallet", "import-deployed",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
|
|
Loading…
Reference in a new issue