diff --git a/cmd/blockchaincmd/convert.go b/cmd/blockchaincmd/convert.go index ad71e8b02..085af091e 100644 --- a/cmd/blockchaincmd/convert.go +++ b/cmd/blockchaincmd/convert.go @@ -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" @@ -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 { diff --git a/cmd/blockchaincmd/helpers.go b/cmd/blockchaincmd/helpers.go index 6fe30bf31..81c3c7ba2 100644 --- a/cmd/blockchaincmd/helpers.go +++ b/cmd/blockchaincmd/helpers.go @@ -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" @@ -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 { diff --git a/cmd/blockchaincmd/remove_validator.go b/cmd/blockchaincmd/remove_validator.go index 376140a8e..941c24873 100644 --- a/cmd/blockchaincmd/remove_validator.go +++ b/cmd/blockchaincmd/remove_validator.go @@ -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" @@ -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 diff --git a/cmd/nodecmd/status.go b/cmd/nodecmd/status.go index 9e360195f..cabcff4f9 100644 --- a/cmd/nodecmd/status.go +++ b/cmd/nodecmd/status.go @@ -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" @@ -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 } } diff --git a/cmd/nodecmd/validate_subnet.go b/cmd/nodecmd/validate_subnet.go index 6ae65ce9a..f006709ef 100644 --- a/cmd/nodecmd/validate_subnet.go +++ b/cmd/nodecmd/validate_subnet.go @@ -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" @@ -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{} diff --git a/cmd/nodecmd/wiz.go b/cmd/nodecmd/wiz.go index 8cf09803a..a01761c3a 100644 --- a/cmd/nodecmd/wiz.go +++ b/cmd/nodecmd/wiz.go @@ -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" @@ -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("") @@ -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 { @@ -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 diff --git a/cmd/transactioncmd/transaction_commit.go b/cmd/transactioncmd/transaction_commit.go index 72e78203a..61f385c4e 100644 --- a/cmd/transactioncmd/transaction_commit.go +++ b/cmd/transactioncmd/transaction_commit.go @@ -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" @@ -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 { diff --git a/cmd/transactioncmd/transaction_sign.go b/cmd/transactioncmd/transaction_sign.go index 4b3539049..eeea80e68 100644 --- a/cmd/transactioncmd/transaction_sign.go +++ b/cmd/transactioncmd/transaction_sign.go @@ -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" @@ -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 } } } diff --git a/pkg/clierrors/clierrors.go b/pkg/clierrors/clierrors.go deleted file mode 100644 index aad090161..000000000 --- a/pkg/clierrors/clierrors.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2022, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. -package clierrors - -import "errors" - -var ( - ErrNoBlockchainID = errors.New("failed to find the blockchain ID for this subnet, has it been deployed/created on this network?\nyou can use 'avalanche blockchain import' if having partial information on a deployed subnet") - ErrNoSubnetID = errors.New("failed to find the subnet ID for this subnet, has it been deployed/created on this network?\nyou can use 'avalanche blockchain import' if having partial information on a deployed subnet") - ErrInvalidValidatorManagerAddress = errors.New("invalid validator manager address") -) diff --git a/pkg/constants/errors.go b/pkg/constants/errors.go new file mode 100644 index 000000000..85a750a1e --- /dev/null +++ b/pkg/constants/errors.go @@ -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") + 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") +)