From e352f57b81e522f11cf446ef21b6a4ff92ad0914 Mon Sep 17 00:00:00 2001 From: Carlos Santiago Yanzon <27785807+bizk@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:57:40 -0300 Subject: [PATCH] refactor(types)!: removed txEncoder from global config (#18695) --- CHANGELOG.md | 3 ++- types/config.go | 20 -------------------- types/config_test.go | 14 -------------- 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba16c7f1286f..5274e00ff7be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/types/config.go b/types/config.go index 8ff1ad5eb87f..09a1ce69f5b6 100644 --- a/types/config.go +++ b/types/config.go @@ -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{} } @@ -46,10 +41,6 @@ func NewConfig() *Config { "consensus_pub": Bech32PrefixConsPub, }, fullFundraiserPath: FullFundraiserPath, - - purpose: Purpose, - coinType: CoinType, - txEncoder: nil, } } @@ -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) { @@ -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 diff --git a/types/config_test.go b/types/config_test.go index da9383ef3a3f..51579f0b2f3a 100644 --- a/types/config_test.go +++ b/types/config_test.go @@ -1,7 +1,6 @@ package types_test import ( - "errors" "testing" "github.com/stretchr/testify/suite" @@ -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")