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{
|
Flags: append([]cli.Flag{
|
||||||
walletPathFlag,
|
walletPathFlag,
|
||||||
wifFlag,
|
wifFlag,
|
||||||
cli.StringFlag{
|
flags.AddressFlag{
|
||||||
Name: "contract, c",
|
Name: "contract, c",
|
||||||
Usage: "Contract hash",
|
Usage: "Contract hash or address",
|
||||||
},
|
},
|
||||||
}, options.RPC...),
|
}, options.RPC...),
|
||||||
},
|
},
|
||||||
|
@ -421,10 +421,9 @@ func importDeployed(ctx *cli.Context) error {
|
||||||
|
|
||||||
defer wall.Close()
|
defer wall.Close()
|
||||||
|
|
||||||
rawHash := ctx.String("contract")
|
rawHash := ctx.Generic("contract").(*flags.Address)
|
||||||
h, err := flags.ParseAddress(rawHash)
|
if !rawHash.IsSet {
|
||||||
if err != nil {
|
return cli.NewExitError("contract hash was not provided", 1)
|
||||||
return cli.NewExitError(fmt.Errorf("invalid contract hash: %w", err), 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
acc, err := newAccountFromWIF(ctx.App.Writer, ctx.String("wif"))
|
acc, err := newAccountFromWIF(ctx.App.Writer, ctx.String("wif"))
|
||||||
|
@ -440,7 +439,7 @@ func importDeployed(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
cs, err := c.GetContractStateByHash(h)
|
cs, err := c.GetContractStateByHash(rawHash.Uint160())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't fetch contract info: %w", err), 1)
|
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()
|
priv, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
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.In.WriteString("acc\rpass\rpass\r")
|
||||||
e.Run(t, "neo-go", "wallet", "import-deployed",
|
e.Run(t, "neo-go", "wallet", "import-deployed",
|
||||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||||
|
|
Loading…
Reference in a new issue