Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename constants to constant #321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugin/evm/export_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/constant"

Check failure on line 19 in plugin/evm/export_tx.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests Race Detection v (ubuntu-20.04)

no required module provides package github.com/ava-labs/avalanchego/utils/constant; to add it:

Check failure on line 19 in plugin/evm/export_tx.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests v (macos-11.0)

no required module provides package github.com/ava-labs/avalanchego/utils/constant; to add it:

Check failure on line 19 in plugin/evm/export_tx.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests v (ubuntu-20.04)

no required module provides package github.com/ava-labs/avalanchego/utils/constant; to add it:
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/math"
"github.com/ava-labs/avalanchego/utils/set"
Expand Down Expand Up @@ -108,7 +108,7 @@
return err
}
assetID := out.AssetID()
if assetID != ctx.AVAXAssetID && utx.DestinationChain == constants.PlatformChainID {
if assetID != ctx.AVAXAssetID && utx.DestinationChain == constant.PlatformChainID {
return errWrongChainID
}
if rules.IsBanff && assetID != ctx.AVAXAssetID {
Expand Down
13 changes: 7 additions & 6 deletions plugin/evm/export_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
"github.com/ava-labs/avalanchego/chains/atomic"
"github.com/ava-labs/avalanchego/ids"
engCommon "github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/constant"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/coreth/params"
"github.com/ethereum/go-ethereum/common"

"github.com/ava-labs/coreth/params"
)

// createExportTxOptions adds funds to shared memory, imports them, and returns a list of export transactions
Expand Down Expand Up @@ -544,7 +545,7 @@ func TestExportTxSemanticVerify(t *testing.T) {
name: "P-chain before AP5",
tx: func() *Tx {
validExportTx := *validAVAXExportTx
validExportTx.DestinationChain = constants.PlatformChainID
validExportTx.DestinationChain = constant.PlatformChainID
return &Tx{UnsignedAtomicTx: &validExportTx}
}(),
signers: [][]*secp256k1.PrivateKey{
Expand All @@ -558,7 +559,7 @@ func TestExportTxSemanticVerify(t *testing.T) {
name: "P-chain after AP5",
tx: func() *Tx {
validExportTx := *validAVAXExportTx
validExportTx.DestinationChain = constants.PlatformChainID
validExportTx.DestinationChain = constant.PlatformChainID
return &Tx{UnsignedAtomicTx: &validExportTx}
}(),
signers: [][]*secp256k1.PrivateKey{
Expand Down Expand Up @@ -586,7 +587,7 @@ func TestExportTxSemanticVerify(t *testing.T) {
name: "P-chain multi-coin before AP5",
tx: func() *Tx {
validExportTx := *validExportTx
validExportTx.DestinationChain = constants.PlatformChainID
validExportTx.DestinationChain = constant.PlatformChainID
return &Tx{UnsignedAtomicTx: &validExportTx}
}(),
signers: [][]*secp256k1.PrivateKey{
Expand All @@ -602,7 +603,7 @@ func TestExportTxSemanticVerify(t *testing.T) {
name: "P-chain multi-coin after AP5",
tx: func() *Tx {
validExportTx := *validExportTx
validExportTx.DestinationChain = constants.PlatformChainID
validExportTx.DestinationChain = constant.PlatformChainID
return &Tx{UnsignedAtomicTx: &validExportTx}
}(),
signers: [][]*secp256k1.PrivateKey{
Expand Down
9 changes: 5 additions & 4 deletions plugin/evm/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ package evm
import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/constant"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)

// ParseServiceAddress get address ID from address string, being it either localized (using address manager,
Expand Down Expand Up @@ -50,7 +51,7 @@ func (vm *VM) FormatAddress(chainID ids.ID, addr ids.ShortID) (string, error) {
if err != nil {
return "", err
}
hrp := constants.GetHRP(vm.ctx.NetworkID)
hrp := constant.GetHRP(vm.ctx.NetworkID)
return address.Format(chainIDAlias, hrp, addr.Bytes())
}

Expand Down
9 changes: 5 additions & 4 deletions plugin/evm/import_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"math/big"
"testing"

"github.com/ava-labs/coreth/params"
"github.com/ethereum/go-ethereum/common"

"github.com/ava-labs/coreth/params"

"github.com/ava-labs/avalanchego/chains/atomic"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/constant"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/components/avax"
Expand Down Expand Up @@ -167,7 +168,7 @@ func TestImportTxVerify(t *testing.T) {
"P-chain source before AP5": {
generate: func(t *testing.T) UnsignedAtomicTx {
tx := *importTx
tx.SourceChain = constants.PlatformChainID
tx.SourceChain = constant.PlatformChainID
return &tx
},
ctx: ctx,
Expand All @@ -177,7 +178,7 @@ func TestImportTxVerify(t *testing.T) {
"P-chain source after AP5": {
generate: func(t *testing.T) UnsignedAtomicTx {
tx := *importTx
tx.SourceChain = constants.PlatformChainID
tx.SourceChain = constant.PlatformChainID
return &tx
},
ctx: ctx,
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

avalanchegoMetrics "github.com/ava-labs/avalanchego/api/metrics"
"github.com/ava-labs/avalanchego/utils/constant"

"github.com/ava-labs/coreth/consensus/dummy"
corethConstants "github.com/ava-labs/coreth/constants"
Expand Down Expand Up @@ -71,7 +72,6 @@ import (
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
Expand Down Expand Up @@ -1288,7 +1288,7 @@ func (vm *VM) ParseAddress(addrStr string) (ids.ID, ids.ShortID, error) {
return ids.ID{}, ids.ShortID{}, err
}

expectedHRP := constants.GetHRP(vm.ctx.NetworkID)
expectedHRP := constant.GetHRP(vm.ctx.NetworkID)
if hrp != expectedHRP {
return ids.ID{}, ids.ShortID{}, fmt.Errorf("expected hrp %q but got %q",
expectedHRP, hrp)
Expand Down
7 changes: 3 additions & 4 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils/cb58"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/utils/hashing"
Expand Down Expand Up @@ -159,9 +158,9 @@
ctx.ValidatorState = &validators.TestState{
GetSubnetIDF: func(_ context.Context, chainID ids.ID) (ids.ID, error) {
subnetID, ok := map[ids.ID]ids.ID{
constants.PlatformChainID: constants.PrimaryNetworkID,
testXChainID: constants.PrimaryNetworkID,
testCChainID: constants.PrimaryNetworkID,
constant.PlatformChainID: constant.PrimaryNetworkID,

Check failure on line 161 in plugin/evm/vm_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: constant (typecheck)
testXChainID: constant.PrimaryNetworkID,

Check failure on line 162 in plugin/evm/vm_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: constant (typecheck)
testCChainID: constant.PrimaryNetworkID,

Check failure on line 163 in plugin/evm/vm_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: constant (typecheck)
}[chainID]
if !ok {
return ids.Empty, errors.New("unknown chain")
Expand Down
Loading