From 292798e4002933613b4bdbeb7af6c46889626877 Mon Sep 17 00:00:00 2001 From: bizk Date: Mon, 11 Dec 2023 16:34:34 -0300 Subject: [PATCH 1/4] removed global txEncoder --- types/config.go | 17 ++--------------- types/config_test.go | 14 -------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/types/config.go b/types/config.go index 8ff1ad5eb87..831385df17f 100644 --- a/types/config.go +++ b/types/config.go @@ -15,7 +15,6 @@ const DefaultKeyringServiceName = "cosmos" type Config struct { fullFundraiserPath string bech32AddressPrefix map[string]string - txEncoder TxEncoder addressVerifier func([]byte) error mtx sync.RWMutex @@ -47,9 +46,8 @@ func NewConfig() *Config { }, fullFundraiserPath: FullFundraiserPath, - purpose: Purpose, - coinType: CoinType, - txEncoder: nil, + purpose: Purpose, + coinType: CoinType, } } @@ -106,12 +104,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 +166,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 da9383ef3a3..51579f0b2f3 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") From f10a2ecc021af9657f0abf39dca8026c74edf357 Mon Sep 17 00:00:00 2001 From: bizk Date: Mon, 11 Dec 2023 16:40:14 -0300 Subject: [PATCH 2/4] updated changelog --- CHANGELOG.md | 1 + types/config.go | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74e5144336..be45119d6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (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. +* (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder. ### Bug Fixes diff --git a/types/config.go b/types/config.go index 831385df17f..cfc1af1763a 100644 --- a/types/config.go +++ b/types/config.go @@ -45,9 +45,6 @@ func NewConfig() *Config { "consensus_pub": Bech32PrefixConsPub, }, fullFundraiserPath: FullFundraiserPath, - - purpose: Purpose, - coinType: CoinType, } } From bcbcb98c47cd4bb9d2273ee064f2add6cbf0cf94 Mon Sep 17 00:00:00 2001 From: bizk Date: Mon, 11 Dec 2023 16:57:35 -0300 Subject: [PATCH 3/4] removed unused types and fix linted --- types/config.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/types/config.go b/types/config.go index cfc1af1763a..09a1ce69f5b 100644 --- a/types/config.go +++ b/types/config.go @@ -18,10 +18,6 @@ type Config struct { addressVerifier func([]byte) error mtx sync.RWMutex - // SLIP-44 related - purpose uint32 - coinType uint32 - sealed bool sealedch chan struct{} } From 7149c27af48a97d0b3098d0dbe53a853bc364a72 Mon Sep 17 00:00:00 2001 From: bizk Date: Fri, 15 Dec 2023 16:48:03 -0300 Subject: [PATCH 4/4] updated changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff5fb9320a0..5274e00ff7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,8 +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. -* (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder. ### Bug Fixes @@ -181,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