cli: use cosigners separator for VM CLI commands where appropriate
Needed for further VM CLI commands improvement, we'll add another positional args. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
a2449ae8ae
commit
ed2b59e077
2 changed files with 95 additions and 34 deletions
|
@ -151,7 +151,7 @@ Example:
|
|||
{
|
||||
Name: "loadnef",
|
||||
Usage: "Load a NEF-consistent script into the VM optionally attaching to it provided signers with scopes",
|
||||
UsageText: `loadnef [--historic <height>] [--gas <int>] <file> <manifest> [<signer-with-scope>, ...]`,
|
||||
UsageText: `loadnef [--historic <height>] [--gas <int>] <file> <manifest> [-- <signer-with-scope>, ...]`,
|
||||
Flags: []cli.Flag{historicFlag, gasFlag},
|
||||
Description: `<file> and <manifest> parameters are mandatory.
|
||||
|
||||
|
@ -164,7 +164,7 @@ Example:
|
|||
{
|
||||
Name: "loadbase64",
|
||||
Usage: "Load a base64-encoded script string into the VM optionally attaching to it provided signers with scopes",
|
||||
UsageText: `loadbase64 [--historic <height>] [--gas <int>] <string> [<signer-with-scope>, ...]`,
|
||||
UsageText: `loadbase64 [--historic <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`,
|
||||
Flags: []cli.Flag{historicFlag, gasFlag},
|
||||
Description: `<string> is mandatory parameter.
|
||||
|
||||
|
@ -177,7 +177,7 @@ Example:
|
|||
{
|
||||
Name: "loadhex",
|
||||
Usage: "Load a hex-encoded script string into the VM optionally attaching to it provided signers with scopes",
|
||||
UsageText: `loadhex [--historic <height>] [--gas <int>] <string> [<signer-with-scope>, ...]`,
|
||||
UsageText: `loadhex [--historic <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`,
|
||||
Flags: []cli.Flag{historicFlag, gasFlag},
|
||||
Description: `<string> is mandatory parameter.
|
||||
|
||||
|
@ -190,7 +190,7 @@ Example:
|
|||
{
|
||||
Name: "loadgo",
|
||||
Usage: "Compile and load a Go file with the manifest into the VM optionally attaching to it provided signers with scopes",
|
||||
UsageText: `loadgo [--historic <height>] [--gas <int>] <file> [<signer-with-scope>, ...]`,
|
||||
UsageText: `loadgo [--historic <height>] [--gas <int>] <file> [-- <signer-with-scope>, ...]`,
|
||||
Flags: []cli.Flag{historicFlag, gasFlag},
|
||||
Description: `<file> is mandatory parameter.
|
||||
|
||||
|
@ -220,7 +220,7 @@ Example:
|
|||
{
|
||||
Name: "loaddeployed",
|
||||
Usage: "Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes",
|
||||
UsageText: `loaddeployed [--historic <height>] [--gas <int>] <hash-or-address-or-id> [<signer-with-scope>, ...]`,
|
||||
UsageText: `loaddeployed [--historic <height>] [--gas <int>] <hash-or-address-or-id> [-- <signer-with-scope>, ...]`,
|
||||
Flags: []cli.Flag{historicFlag, gasFlag},
|
||||
Description: `Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes.
|
||||
If '--historic' flag specified, then the historic contract state (historic script and manifest) will be loaded.
|
||||
|
@ -688,7 +688,13 @@ func handleLoadNEF(c *cli.Context) error {
|
|||
}
|
||||
var signers []transaction.Signer
|
||||
if len(args) > 2 {
|
||||
signers, err = cmdargs.ParseSigners(c.Args()[2:])
|
||||
if args[2] != cmdargs.CosignersSeparator {
|
||||
return fmt.Errorf("%w: `%s` was expected as the third parameter, got %s", ErrInvalidParameter, cmdargs.CosignersSeparator, args[2])
|
||||
}
|
||||
if len(args) < 4 {
|
||||
return fmt.Errorf("%w: signers expected after `%s`, got none", ErrInvalidParameter, cmdargs.CosignersSeparator)
|
||||
}
|
||||
signers, err = cmdargs.ParseSigners(c.Args()[3:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
|
||||
}
|
||||
|
@ -715,7 +721,13 @@ func handleLoadBase64(c *cli.Context) error {
|
|||
}
|
||||
var signers []transaction.Signer
|
||||
if len(args) > 1 {
|
||||
signers, err = cmdargs.ParseSigners(args[1:])
|
||||
if args[1] != cmdargs.CosignersSeparator {
|
||||
return fmt.Errorf("%w: `%s` was expected as the second parameter, got %s", ErrInvalidParameter, cmdargs.CosignersSeparator, args[1])
|
||||
}
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf("%w: signers expected after `%s`, got none", ErrInvalidParameter, cmdargs.CosignersSeparator)
|
||||
}
|
||||
signers, err = cmdargs.ParseSigners(args[2:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
|
||||
}
|
||||
|
@ -749,7 +761,13 @@ func handleLoadHex(c *cli.Context) error {
|
|||
}
|
||||
var signers []transaction.Signer
|
||||
if len(args) > 1 {
|
||||
signers, err = cmdargs.ParseSigners(args[1:])
|
||||
if args[1] != cmdargs.CosignersSeparator {
|
||||
return fmt.Errorf("%w: `%s` was expected as the second parameter, got %s", ErrInvalidParameter, cmdargs.CosignersSeparator, args[1])
|
||||
}
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf("%w: signers expected after `%s`, got none", ErrInvalidParameter, cmdargs.CosignersSeparator)
|
||||
}
|
||||
signers, err = cmdargs.ParseSigners(args[2:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
|
||||
}
|
||||
|
@ -783,7 +801,13 @@ func handleLoadGo(c *cli.Context) error {
|
|||
}
|
||||
var signers []transaction.Signer
|
||||
if len(args) > 1 {
|
||||
signers, err = cmdargs.ParseSigners(args[1:])
|
||||
if args[1] != cmdargs.CosignersSeparator {
|
||||
return fmt.Errorf("%w: `%s` was expected as the second parameter, got %s", ErrInvalidParameter, cmdargs.CosignersSeparator, args[1])
|
||||
}
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf("%w: signers expected after `%s`, got none", ErrInvalidParameter, cmdargs.CosignersSeparator)
|
||||
}
|
||||
signers, err = cmdargs.ParseSigners(args[2:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
|
||||
}
|
||||
|
@ -849,7 +873,8 @@ func handleLoadDeployed(c *cli.Context) error {
|
|||
if !c.Args().Present() {
|
||||
return errors.New("contract hash, address or ID is mandatory argument")
|
||||
}
|
||||
hashOrID := c.Args().Get(0)
|
||||
args := c.Args()
|
||||
hashOrID := args[0]
|
||||
ic := getInteropContextFromContext(c.App)
|
||||
h, err := flags.ParseAddress(hashOrID)
|
||||
if err != nil {
|
||||
|
@ -868,8 +893,14 @@ func handleLoadDeployed(c *cli.Context) error {
|
|||
}
|
||||
|
||||
var signers []transaction.Signer
|
||||
if len(c.Args()) > 1 {
|
||||
signers, err = cmdargs.ParseSigners(c.Args()[1:])
|
||||
if len(args) > 1 {
|
||||
if args[1] != cmdargs.CosignersSeparator {
|
||||
return fmt.Errorf("%w: %s was expected as the second parameter, got %s", ErrInvalidParameter, cmdargs.CosignersSeparator, args[1])
|
||||
}
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf("%w: signers expected after `%s`, got none", ErrInvalidParameter, cmdargs.CosignersSeparator)
|
||||
}
|
||||
signers, err = cmdargs.ParseSigners(args[2:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue