Skip to content

Commit

Permalink
refactor(types)!: removed txEncoder from global config (#18695)
Browse files Browse the repository at this point in the history
  • Loading branch information
bizk authored Dec 15, 2023
1 parent e7f5c2e commit e352f57
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (crypto/keys) [#18026](https://github.com/cosmos/cosmos-sdk/pull/18026) Made public key generation constant time on `secp256k1`
* (crypto | x/auth) [#14372](https://github.com/cosmos/cosmos-sdk/pull/18194) Key checks on signatures antehandle.
* (staking) [#18506](https://github.com/cosmos/cosmos-sdk/pull/18506) Detect the length of the ed25519 pubkey in CreateValidator to prevent panic.
* (types) [#18372](https://github.com/cosmos/cosmos-sdk/pull/18372) Removed global configuration for coin type and purpose. Setters and getters should be removed and access directly to defined types.

### Bug Fixes

Expand Down Expand Up @@ -180,6 +179,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/slashing) [#18115](https://github.com/cosmos/cosmos-sdk/pull/18115) `NewValidatorSigningInfo` takes strings instead of `sdk.AccAddress`
* (types) [#18268](https://github.com/cosmos/cosmos-sdk/pull/18268) Remove global setting of basedenom. Use the staking module parameter instead
* (x/auth) [#18351](https://github.com/cosmos/cosmos-sdk/pull/18351) Auth module was moved to its own go.mod `cosmossdk.io/x/auth`
* (types) [#18372](https://github.com/cosmos/cosmos-sdk/pull/18372) Removed global configuration for coin type and purpose. Setters and getters should be removed and access directly to defined types.
* (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder.

### CLI Breaking Changes

Expand Down
20 changes: 0 additions & 20 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ const DefaultKeyringServiceName = "cosmos"
type Config struct {
fullFundraiserPath string
bech32AddressPrefix map[string]string
txEncoder TxEncoder
addressVerifier func([]byte) error
mtx sync.RWMutex

// SLIP-44 related
purpose uint32
coinType uint32

sealed bool
sealedch chan struct{}
}
Expand All @@ -46,10 +41,6 @@ func NewConfig() *Config {
"consensus_pub": Bech32PrefixConsPub,
},
fullFundraiserPath: FullFundraiserPath,

purpose: Purpose,
coinType: CoinType,
txEncoder: nil,
}
}

Expand Down Expand Up @@ -106,12 +97,6 @@ func (config *Config) SetBech32PrefixForConsensusNode(addressPrefix, pubKeyPrefi
config.bech32AddressPrefix["consensus_pub"] = pubKeyPrefix
}

// SetTxEncoder builds the Config with TxEncoder used to marshal StdTx to bytes
func (config *Config) SetTxEncoder(encoder TxEncoder) {
config.assertNotSealed()
config.txEncoder = encoder
}

// SetAddressVerifier builds the Config with the provided function for verifying that addresses
// have the correct format
func (config *Config) SetAddressVerifier(addressVerifier func([]byte) error) {
Expand Down Expand Up @@ -174,11 +159,6 @@ func (config *Config) GetBech32ConsensusPubPrefix() string {
return config.bech32AddressPrefix["consensus_pub"]
}

// GetTxEncoder return function to encode transactions
func (config *Config) GetTxEncoder() TxEncoder {
return config.txEncoder
}

// GetAddressVerifier returns the function to verify that addresses have the correct format
func (config *Config) GetAddressVerifier() func([]byte) error {
return config.addressVerifier
Expand Down
14 changes: 0 additions & 14 deletions types/config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package types_test

import (
"errors"
"testing"

"github.com/stretchr/testify/suite"
Expand All @@ -17,19 +16,6 @@ func TestConfigTestSuite(t *testing.T) {
suite.Run(t, new(configTestSuite))
}

func (s *configTestSuite) TestConfig_SetTxEncoder() {
mockErr := errors.New("test")
config := sdk.NewConfig()
s.Require().Nil(config.GetTxEncoder())
encFunc := sdk.TxEncoder(func(tx sdk.Tx) ([]byte, error) { return nil, nil })
config.SetTxEncoder(encFunc)
_, err := config.GetTxEncoder()(sdk.Tx(nil))
s.Require().Error(mockErr, err)

config.Seal()
s.Require().Panics(func() { config.SetTxEncoder(encFunc) })
}

func (s *configTestSuite) TestConfig_SetFullFundraiserPath() {
config := sdk.NewConfig()
config.SetFullFundraiserPath("test/path")
Expand Down

0 comments on commit e352f57

Please sign in to comment.