mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 13:47:19 +00:00
cli: change StringFlag to AddressFlag
For passing address or hash AddressFlag is more suitable. Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
39559b90e2
commit
7b199af3b7
4 changed files with 7 additions and 15 deletions
|
@ -556,7 +556,7 @@ func TestContractManifestGroups(t *testing.T) {
|
||||||
"--nef", nefName, "--manifest", manifestName)
|
"--nef", nefName, "--manifest", manifestName)
|
||||||
})
|
})
|
||||||
t.Run("invalid sender", func(t *testing.T) {
|
t.Run("invalid sender", func(t *testing.T) {
|
||||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
e.RunWithErrorCheck(t, `invalid value "not-a-sender" for flag -sender: invalid base58 digit ('-')`, "neo-go", "contract", "manifest", "add-group",
|
||||||
"--wallet", testcli.TestWalletPath, "--address", testcli.TestWalletAccount,
|
"--wallet", testcli.TestWalletPath, "--address", testcli.TestWalletAccount,
|
||||||
"--sender", "not-a-sender", "--nef", nefName, "--manifest", manifestName)
|
"--sender", "not-a-sender", "--nef", nefName, "--manifest", manifestName)
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,11 +19,7 @@ func manifestAddGroup(ctx *cli.Context) error {
|
||||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sender, err := flags.ParseAddress(ctx.String("sender"))
|
sender := ctx.Generic("sender").(*flags.Address)
|
||||||
if err != nil {
|
|
||||||
return cli.Exit(fmt.Errorf("invalid sender: %w", err), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
nf, _, err := readNEFFile(ctx.String("nef"))
|
nf, _, err := readNEFFile(ctx.String("nef"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.Exit(fmt.Errorf("can't read NEF file: %w", err), 1)
|
return cli.Exit(fmt.Errorf("can't read NEF file: %w", err), 1)
|
||||||
|
@ -35,7 +31,7 @@ func manifestAddGroup(ctx *cli.Context) error {
|
||||||
return cli.Exit(fmt.Errorf("can't read contract manifest: %w", err), 1)
|
return cli.Exit(fmt.Errorf("can't read contract manifest: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
h := state.CreateContractHash(sender, nf.Checksum, m.Name)
|
h := state.CreateContractHash(sender.Uint160(), nf.Checksum, m.Name)
|
||||||
|
|
||||||
gAcc, w, err := options.GetAccFromContext(ctx)
|
gAcc, w, err := options.GetAccFromContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -117,12 +117,11 @@ func NewCommands() []*cli.Command {
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
manifestAddGroupFlags := append([]cli.Flag{
|
manifestAddGroupFlags := append([]cli.Flag{
|
||||||
&cli.StringFlag{
|
&flags.AddressFlag{
|
||||||
Name: "sender",
|
Name: "sender",
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Required: true,
|
Required: true,
|
||||||
Usage: "Deploy transaction sender",
|
Usage: "Deploy transaction sender",
|
||||||
Action: cmdargs.EnsureNotEmpty("sender"),
|
|
||||||
},
|
},
|
||||||
&flags.AddressFlag{
|
&flags.AddressFlag{
|
||||||
Name: addressFlagName, // use the same name for handler code unification.
|
Name: addressFlagName, // use the same name for handler code unification.
|
||||||
|
|
|
@ -79,7 +79,7 @@ var (
|
||||||
Name: gasFlagFullName,
|
Name: gasFlagFullName,
|
||||||
Usage: "GAS limit for this execution (integer number, satoshi).",
|
Usage: "GAS limit for this execution (integer number, satoshi).",
|
||||||
}
|
}
|
||||||
hashFlag = &cli.StringFlag{
|
hashFlag = &flags.AddressFlag{
|
||||||
Name: hashFlagFullName,
|
Name: hashFlagFullName,
|
||||||
Usage: "Smart-contract hash in LE form or address",
|
Usage: "Smart-contract hash in LE form or address",
|
||||||
}
|
}
|
||||||
|
@ -685,11 +685,8 @@ func getHashFlag(c *cli.Context) (util.Uint160, error) {
|
||||||
if !c.IsSet(hashFlagFullName) {
|
if !c.IsSet(hashFlagFullName) {
|
||||||
return util.Uint160{}, nil
|
return util.Uint160{}, nil
|
||||||
}
|
}
|
||||||
h, err := flags.ParseAddress(c.String(hashFlagFullName))
|
h := c.Generic(hashFlagFullName).(*flags.Address)
|
||||||
if err != nil {
|
return h.Uint160(), nil
|
||||||
return util.Uint160{}, fmt.Errorf("failed to parse contract hash: %w", err)
|
|
||||||
}
|
|
||||||
return h, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleLoadNEF(c *cli.Context) error {
|
func handleLoadNEF(c *cli.Context) error {
|
||||||
|
|
Loading…
Reference in a new issue