refactor(types)!: removed txEncoder from global config (#18695)
This commit is contained in:
parent
e7f5c2ec8f
commit
e352f57b81
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user