Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Feb 27, 2025
1 parent 305f67a commit 489fc0b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 31 deletions.
7 changes: 3 additions & 4 deletions cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
Expand Down Expand Up @@ -425,13 +424,13 @@ func convertSubnetToL1(
doStrongInputsCheck bool,
) ([]*txs.ConvertSubnetToL1Validator, bool, bool, error) {
if subnetID == ids.Empty {
return nil, false, false, clierrors.ErrNoSubnetID
return nil, false, false, constants.ErrNoSubnetID
}
if blockchainID == ids.Empty {
return nil, false, false, clierrors.ErrNoBlockchainID
return nil, false, false, constants.ErrNoBlockchainID
}
if !common.IsHexAddress(validatorManagerAddressStr) {
return nil, false, false, clierrors.ErrInvalidValidatorManagerAddress
return nil, false, false, constants.ErrInvalidValidatorManagerAddress
}
avaGoBootstrapValidators, err := ConvertToAvalancheGoSubnetValidator(bootstrapValidators)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/blockchaincmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/ava-labs/avalanche-cli/pkg/application"
"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
"github.com/ava-labs/avalanche-cli/pkg/models"
Expand Down Expand Up @@ -86,7 +86,7 @@ func UpdateKeychainWithSubnetControlKeys(
}
subnetID := sc.Networks[network.Name()].SubnetID
if subnetID == ids.Empty {
return clierrors.ErrNoSubnetID
return constants.ErrNoSubnetID
}
_, controlKeys, _, err := txutils.GetOwners(network, subnetID)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/blockchaincmd/remove_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
Expand Down Expand Up @@ -118,7 +117,7 @@ func removeValidator(_ *cobra.Command, args []string) error {
scNetwork := sc.Networks[network.Name()]
subnetID := scNetwork.SubnetID
if subnetID == ids.Empty {
return clierrors.ErrNoSubnetID
return constants.ErrNoSubnetID
}

var nodeID ids.NodeID
Expand Down
4 changes: 2 additions & 2 deletions cmd/nodecmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/ava-labs/avalanche-cli/cmd/blockchaincmd"
"github.com/ava-labs/avalanche-cli/pkg/ansible"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/node"
"github.com/ava-labs/avalanche-cli/pkg/ssh"
Expand Down Expand Up @@ -72,7 +72,7 @@ func statusNode(_ *cobra.Command, args []string) error {
}
blockchainID = sc.Networks[clusterConf.Network.Name()].BlockchainID
if blockchainID == ids.Empty {
return clierrors.ErrNoBlockchainID
return constants.ErrNoBlockchainID
}
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/nodecmd/validate_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

blockchaincmd "github.com/ava-labs/avalanche-cli/cmd/blockchaincmd"
"github.com/ava-labs/avalanche-cli/pkg/ansible"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
Expand Down Expand Up @@ -256,7 +255,7 @@ func validateSubnet(_ *cobra.Command, args []string) error {
if !avoidSubnetValidationChecks {
blockchainID = sc.Networks[network.Name()].BlockchainID
if blockchainID == ids.Empty {
return clierrors.ErrNoBlockchainID
return constants.ErrNoBlockchainID
}
}
nodeErrors := map[string]error{}
Expand Down
7 changes: 3 additions & 4 deletions cmd/nodecmd/wiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ava-labs/avalanche-cli/cmd/blockchaincmd"
"github.com/ava-labs/avalanche-cli/cmd/interchaincmd/messengercmd"
"github.com/ava-labs/avalanche-cli/pkg/ansible"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
awsAPI "github.com/ava-labs/avalanche-cli/pkg/cloud/aws"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
Expand Down Expand Up @@ -309,7 +308,7 @@ func wiz(cmd *cobra.Command, args []string) error {
}
subnetID := sc.Networks[network.Name()].SubnetID
if subnetID == ids.Empty {
return clierrors.ErrNoSubnetID
return constants.ErrNoSubnetID
}

ux.Logger.PrintToUser("")
Expand Down Expand Up @@ -367,7 +366,7 @@ func wiz(cmd *cobra.Command, args []string) error {
}
blockchainID := sc.Networks[network.Name()].BlockchainID
if blockchainID == ids.Empty {
return clierrors.ErrNoBlockchainID
return constants.ErrNoBlockchainID
}
// update logging
if addMonitoring {
Expand Down Expand Up @@ -504,7 +503,7 @@ func updateProposerVMs(
ux.Logger.PrintToUser("Updating proposerVM on %s", deployedSubnetName)
blockchainID := deployedSubnetSc.Networks[network.Name()].BlockchainID
if blockchainID == ids.Empty {
return clierrors.ErrNoBlockchainID
return constants.ErrNoBlockchainID
}
if err := interchain.SetProposerVM(app, network, blockchainID.String(), deployedSubnetSc.TeleporterKey); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/transactioncmd/transaction_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/ava-labs/avalanche-cli/cmd/blockchaincmd"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/subnet"
Expand Down Expand Up @@ -83,7 +83,7 @@ func commitTx(_ *cobra.Command, args []string) error {
}
subnetID = sc.Networks[network.Name()].SubnetID
if subnetID == ids.Empty {
return clierrors.ErrNoSubnetID
return constants.ErrNoSubnetID
}
}
} else if isCreateChainTx {
Expand Down
4 changes: 2 additions & 2 deletions cmd/transactioncmd/transaction_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"fmt"

"github.com/ava-labs/avalanche-cli/cmd/blockchaincmd"
"github.com/ava-labs/avalanche-cli/pkg/clierrors"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/prompts"
Expand Down Expand Up @@ -123,7 +123,7 @@ func signTx(_ *cobra.Command, args []string) error {
}
subnetID = sc.Networks[network.Name()].SubnetID
if subnetID == ids.Empty {
return clierrors.ErrNoSubnetID
return constants.ErrNoSubnetID
}
}
}
Expand Down
11 changes: 0 additions & 11 deletions pkg/clierrors/clierrors.go

This file was deleted.

11 changes: 11 additions & 0 deletions pkg/constants/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package constants

import "errors"

var (
ErrNoBlockchainID = errors.New("\n\nNo blockchainID found. To resolve this:\n- Use 'avalanche blockchain deploy' to deploy the blockchain and generate a blockchainID.\n- Or use 'avalanche blockchain import' to import an existing configuration.\n")

Check failure on line 8 in pkg/constants/errors.go

View workflow job for this annotation

GitHub Actions / Lint

ST1005: error strings should not end with punctuation or newlines (stylecheck)
ErrNoSubnetID = errors.New("\n\nNo subnetID found. To resolve this:\n- Use 'avalanche blockchain deploy' to create the subnet and generate a subnetID.\n- Or use 'avalanche blockchain import' to import an existing configuration.\n")
ErrInvalidValidatorManagerAddress = errors.New("invalid validator manager address")
)

0 comments on commit 489fc0b

Please sign in to comment.