Skip to content

Commit

Permalink
neofs-adm:Add check for alphabet and contract wallets creation
Browse files Browse the repository at this point in the history
The only command that can create alphabet wallets is init.
The only commands that can create contract wallet are init and update-contracts.

Closes #2134.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
  • Loading branch information
AliceInHunterland committed Aug 16, 2023
1 parent 66bc5b2 commit 1f1c14f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect
- Storage node no longer ignores unhealthy shards on startup (#2464)
- Processing of status errors returned by API client from NeoFS SDK RC-9 (#2465)
- `neofs-lens write-cache list` command duplication (#2505)
- `neofs-adm` create wallets only with `init` and `update-contracts` commands (#2134)

### Removed
- Deprecated `morph.rpc_endpoint` SN and `morph.endpoint.client` IR config sections (#2400)
Expand Down
3 changes: 3 additions & 0 deletions cmd/neofs-adm/internal/modules/morph/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func generateAlphabetCreds(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
if cmd.Name() != "init" {
return errors.New("can't generate alphabet wallets for non-init command")
}
if size == 0 {
return errors.New("size must be > 0")
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/neofs-adm/internal/modules/morph/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ func openContractWallet(v *viper.Viper, cmd *cobra.Command, walletDir string) (*
if !os.IsNotExist(err) {
return nil, fmt.Errorf("can't open wallet: %w", err)
}

cmd.Printf("Contract group wallet is missing, initialize at %s\n", p)
return initializeContractWallet(v, walletDir)
if cmd.Name() == "init" || cmd.Name() == "update-contracts" {
cmd.Printf("Contract group wallet is missing, initialize at %s\n", p)
return initializeContractWallet(v, walletDir)
} else {

Check warning on line 62 in cmd/neofs-adm/internal/modules/morph/group.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
return nil, fmt.Errorf("contract group wallet is missing")
}
}

password, err := config.GetPassword(v, contractWalletPasswordKey)
Expand Down

0 comments on commit 1f1c14f

Please sign in to comment.