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