From fbe3f900ad66dad38b76de29f2c1a78b0abb16b5 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 28 Aug 2024 09:04:44 +0000 Subject: [PATCH 1/2] chore(types): deprecate acc address stringer (#21435) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Julián Toledano (cherry picked from commit 39b61a31022836617b59de96365b13ec4c23bde2) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ Makefile | 5 +---- types/address.go | 9 +++++++++ types/config.go | 17 +++++++++-------- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34986e690ae4..6e57c013d723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,19 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (client) [#21436](https://github.com/cosmos/cosmos-sdk/pull/21436) Use `address.Codec` from client.Context in `tx.Sign`. +<<<<<<< HEAD +======= +### Bug Fixes + +* (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0. + +### API Breaking Changes + +### Deprecated + +* (types) [#21435](https://github.com/cosmos/cosmos-sdk/pull/21435) The `String()` method on `AccAddress`, `ValAddress` and `ConsAddress` have been deprecated. This is done because those are still using the deprecated global `sdk.Config`. Use an `address.Codec` instead. + +>>>>>>> 39b61a310 (chore(types): deprecate acc address stringer (#21435)) ## [v0.52.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.52.0) - 2024-XX-XX Every module contains its own CHANGELOG.md. Please refer to the module you are interested in. diff --git a/Makefile b/Makefile index 2e760653bfc9..067b5d4f6103 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,7 @@ include scripts/build/build.mk .DEFAULT_GOAL := help -############################################################################### -### Tools & Dependencies ### -############################################################################### - +#? go.sum: Run go mod tidy and ensure dependencies have not been modified go.sum: go.mod echo "Ensure dependencies have not been modified ..." >&2 go mod verify diff --git a/types/address.go b/types/address.go index 8b19141e6569..afe35755487b 100644 --- a/types/address.go +++ b/types/address.go @@ -149,6 +149,7 @@ type Address interface { Marshal() ([]byte, error) MarshalJSON() ([]byte, error) Bytes() []byte + // Deprecated: Use an address.Codec to convert addresses from and to string/bytes. String() string Format(s fmt.State, verb rune) } @@ -179,6 +180,7 @@ func AccAddressFromHexUnsafe(address string) (addr AccAddress, err error) { } // MustAccAddressFromBech32 calls AccAddressFromBech32 and panics on error. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func MustAccAddressFromBech32(address string) AccAddress { addr, err := AccAddressFromBech32(address) if err != nil { @@ -189,6 +191,7 @@ func MustAccAddressFromBech32(address string) AccAddress { } // AccAddressFromBech32 creates an AccAddress from a Bech32 string. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func AccAddressFromBech32(address string) (addr AccAddress, err error) { bech32PrefixAccAddr := GetConfig().GetBech32AccountAddrPrefix() @@ -281,6 +284,7 @@ func (aa AccAddress) Bytes() []byte { } // String implements the Stringer interface. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func (aa AccAddress) String() string { if aa.Empty() { return "" @@ -328,6 +332,7 @@ func ValAddressFromHex(address string) (addr ValAddress, err error) { } // ValAddressFromBech32 creates a ValAddress from a Bech32 string. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func ValAddressFromBech32(address string) (addr ValAddress, err error) { bech32PrefixValAddr := GetConfig().GetBech32ValidatorAddrPrefix() @@ -336,6 +341,7 @@ func ValAddressFromBech32(address string) (addr ValAddress, err error) { } // MustValAddressFromBech32 calls ValAddressFromBech32 and panics on error. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func MustValAddressFromBech32(address string) ValAddress { addr, err := ValAddressFromBech32(address) if err != nil { @@ -432,6 +438,7 @@ func (va ValAddress) Bytes() []byte { } // String implements the Stringer interface. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func (va ValAddress) String() string { if va.Empty() { return "" @@ -480,6 +487,7 @@ func ConsAddressFromHex(address string) (addr ConsAddress, err error) { } // ConsAddressFromBech32 creates a ConsAddress from a Bech32 string. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func ConsAddressFromBech32(address string) (addr ConsAddress, err error) { bech32PrefixConsAddr := GetConfig().GetBech32ConsensusAddrPrefix() @@ -579,6 +587,7 @@ func (ca ConsAddress) Bytes() []byte { } // String implements the Stringer interface. +// Deprecated: Use an address.Codec to convert addresses from and to string/bytes. func (ca ConsAddress) String() string { if ca.Empty() { return "" diff --git a/types/config.go b/types/config.go index 7089ceaff74b..90008fb8512b 100644 --- a/types/config.go +++ b/types/config.go @@ -10,8 +10,16 @@ import ( // DefaultKeyringServiceName defines a default service name for the keyring. const DefaultKeyringServiceName = "cosmos" +func KeyringServiceName() string { + if len(version.Name) == 0 { + return DefaultKeyringServiceName + } + return version.Name +} + // Config is the structure that holds the SDK configuration parameters. -// This could be used to initialize certain configuration parameters for the SDK. +// Deprecated: The global SDK config is deprecated and users should prefer using an address codec. +// Users must still set the global config until the Stringer interface on `AccAddress`, `ValAddress`, and `ConsAddress` is removed. type Config struct { bech32AddressPrefix map[string]string mtx sync.RWMutex @@ -140,10 +148,3 @@ func (config *Config) GetBech32ValidatorPubPrefix() string { func (config *Config) GetBech32ConsensusPubPrefix() string { return config.bech32AddressPrefix["consensus_pub"] } - -func KeyringServiceName() string { - if len(version.Name) == 0 { - return DefaultKeyringServiceName - } - return version.Name -} From a6993f89c684313398ee39b852c0b81dad2f10c9 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 28 Aug 2024 12:25:28 +0200 Subject: [PATCH 2/2] cl --- CHANGELOG.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e57c013d723..9483268a60ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,19 +44,10 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (client) [#21436](https://github.com/cosmos/cosmos-sdk/pull/21436) Use `address.Codec` from client.Context in `tx.Sign`. -<<<<<<< HEAD -======= -### Bug Fixes - -* (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0. - -### API Breaking Changes - ### Deprecated * (types) [#21435](https://github.com/cosmos/cosmos-sdk/pull/21435) The `String()` method on `AccAddress`, `ValAddress` and `ConsAddress` have been deprecated. This is done because those are still using the deprecated global `sdk.Config`. Use an `address.Codec` instead. ->>>>>>> 39b61a310 (chore(types): deprecate acc address stringer (#21435)) ## [v0.52.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.52.0) - 2024-XX-XX Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.