mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-21 11:51:03 +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)
|
||||
})
|
||||
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,
|
||||
"--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 {
|
||||
return err
|
||||
}
|
||||
sender, err := flags.ParseAddress(ctx.String("sender"))
|
||||
if err != nil {
|
||||
return cli.Exit(fmt.Errorf("invalid sender: %w", err), 1)
|
||||
}
|
||||
|
||||
sender := ctx.Generic("sender").(*flags.Address)
|
||||
nf, _, err := readNEFFile(ctx.String("nef"))
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
h := state.CreateContractHash(sender, nf.Checksum, m.Name)
|
||||
h := state.CreateContractHash(sender.Uint160(), nf.Checksum, m.Name)
|
||||
|
||||
gAcc, w, err := options.GetAccFromContext(ctx)
|
||||
if err != nil {
|
||||
|
|
|
@ -117,12 +117,11 @@ func NewCommands() []*cli.Command {
|
|||
},
|
||||
}...)
|
||||
manifestAddGroupFlags := append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
&flags.AddressFlag{
|
||||
Name: "sender",
|
||||
Aliases: []string{"s"},
|
||||
Required: true,
|
||||
Usage: "Deploy transaction sender",
|
||||
Action: cmdargs.EnsureNotEmpty("sender"),
|
||||
},
|
||||
&flags.AddressFlag{
|
||||
Name: addressFlagName, // use the same name for handler code unification.
|
||||
|
|
|
@ -79,7 +79,7 @@ var (
|
|||
Name: gasFlagFullName,
|
||||
Usage: "GAS limit for this execution (integer number, satoshi).",
|
||||
}
|
||||
hashFlag = &cli.StringFlag{
|
||||
hashFlag = &flags.AddressFlag{
|
||||
Name: hashFlagFullName,
|
||||
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) {
|
||||
return util.Uint160{}, nil
|
||||
}
|
||||
h, err := flags.ParseAddress(c.String(hashFlagFullName))
|
||||
if err != nil {
|
||||
return util.Uint160{}, fmt.Errorf("failed to parse contract hash: %w", err)
|
||||
}
|
||||
return h, nil
|
||||
h := c.Generic(hashFlagFullName).(*flags.Address)
|
||||
return h.Uint160(), nil
|
||||
}
|
||||
|
||||
func handleLoadNEF(c *cli.Context) error {
|
||||
|
|
Loading…
Reference in a new issue