diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef61b16206..78228b58813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * [#23470](/~https://github.com/cosmos/cosmos-sdk/pull/23470) Converge to use of one single sign mode type and signer data: * Use api's signmode throughout the SDK to align with `cosmossdk.io/tx`. This allows developer not to juggle between sign mode types * Deprecate `authsigning.SignerData` in favor of txsigning.SignerData and replace its usage - * Move helpers to go from one sign mode enum to another to `types/signing` instead of `x/auth/signing` (less dependency on `x`) + * Remove `APISignModeToInternal` from `x/auth` as no conversion is necessary by the user anymore * (all) [#23445](/~https://github.com/cosmos/cosmos-sdk/pull/23445) Remove `v2` code from codebase. * (codec) [#22988](/~https://github.com/cosmos/cosmos-sdk/pull/22988) Improve edge case handling for recursion limits. * (proto) [#23437](/~https://github.com/cosmos/cosmos-sdk/pull/23437) Deprecate `Block` field from `GetBlockByHeightResponse` and return empty comet block for `GetBlockByHeight`. diff --git a/client/tx/aux_builder.go b/client/tx/aux_builder.go index 35ba3a88008..2345be22eeb 100644 --- a/client/tx/aux_builder.go +++ b/client/tx/aux_builder.go @@ -136,7 +136,7 @@ func (b *AuxTxBuilder) SetSignMode(mode apisigning.SignMode) error { apisigning.SignMode_SIGN_MODE_DIRECT_AUX, apisigning.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) } - b.auxSignerData.Mode, _ = signing.APISignModeToInternal(mode) + b.auxSignerData.Mode = signing.SignMode(mode) return nil } diff --git a/client/tx/aux_builder_test.go b/client/tx/aux_builder_test.go index 67e04bc8987..f8eb8953191 100644 --- a/client/tx/aux_builder_test.go +++ b/client/tx/aux_builder_test.go @@ -18,7 +18,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" typestx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" ) const ( @@ -249,7 +248,6 @@ func checkCorrectData(t *testing.T, cdc codec.Codec, auxSignerData typestx.AuxSi require.Equal(t, chainID, auxSignerData.SignDoc.ChainId) require.Equal(t, msgAny, body.GetMessages()[0]) require.Equal(t, pkAny, auxSignerData.SignDoc.PublicKey) - m, _ := signing.InternalSignModeToAPI(auxSignerData.Mode) - require.Equal(t, signMode, m) + require.Equal(t, signMode, apisigning.SignMode(auxSignerData.Mode)) require.Equal(t, rawSig, auxSignerData.Sig) } diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index a35f040c627..85f028f9ea0 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -36,7 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v2.10.0-beta.2](/~https://github.com/cosmos/cosmos-sdk/releases/tag/client/v2/v2.10.0-beta.2) - 2025-01-22 + * [#23325](/~https://github.com/cosmos/cosmos-sdk/pull/23325) Remove `NewAppOptionsFromConfig` that isn't needed in normal wiring. +* [#23470](/~https://github.com/cosmos/cosmos-sdk/pull/23470) Accept sign mode from `cosmossdk.io/api`. ## [v2.10.0-beta.1](/~https://github.com/cosmos/cosmos-sdk/releases/tag/client/v2/v2.10.0-beta.1) - 2024-12-18 diff --git a/client/v2/go.mod b/client/v2/go.mod index 7147489b69b..45f8608c763 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -174,4 +174,4 @@ require ( pgregory.net/rapid v1.1.0 // indirect ) -replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122113551-ad692c97166e +replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122120205-bc49a8e7fd2f diff --git a/client/v2/go.sum b/client/v2/go.sum index 38d49b2735c..6274fb4960a 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -133,8 +133,8 @@ github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNC github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122113551-ad692c97166e h1:uD+6+X9yIfcBH13hJZjPqiTnZAuskWWUlLtIrbTQ7K4= -github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122113551-ad692c97166e/go.mod h1:NBaGSpGuOFFDx7V/FVmbPqm1n0Xu3ihzqCbqj+8PxVs= +github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122120205-bc49a8e7fd2f h1:la+6zEjMn3+/gG+uHyJYyqkJ6HUAgP1NcoKH21rvBUE= +github.com/cosmos/cosmos-sdk v0.52.0-rc.1.0.20250122120205-bc49a8e7fd2f/go.mod h1:NBaGSpGuOFFDx7V/FVmbPqm1n0Xu3ihzqCbqj+8PxVs= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 90d00fc48ba..ddb470b2151 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -3,6 +3,8 @@ package tx import ( gogoprotoany "github.com/cosmos/gogoproto/types/any" + apisigning "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -50,12 +52,10 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { return signing.SignatureV2{}, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (cryptotypes.PubKey)(nil), pk) } - signMode, _ := signing.InternalSignModeToAPI(a.Mode) - return signing.SignatureV2{ PubKey: pk, Data: &signing.SingleSignatureData{ - SignMode: signMode, + SignMode: apisigning.SignMode(a.Mode), Signature: a.Sig, }, Sequence: a.SignDoc.Sequence, diff --git a/types/tx/direct_aux_test.go b/types/tx/direct_aux_test.go index 62427c576ba..421da8e18df 100644 --- a/types/tx/direct_aux_test.go +++ b/types/tx/direct_aux_test.go @@ -5,6 +5,8 @@ import ( "github.com/stretchr/testify/require" + apisigning "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -76,8 +78,7 @@ func TestAuxSignerData(t *testing.T) { require.NoError(t, err) sigV2, err := tc.sd.GetSignatureV2() require.NoError(t, err) - m, _ := signing.InternalSignModeToAPI(tc.sd.Mode) - require.Equal(t, m, sigV2.Data.(*signing.SingleSignatureData).SignMode) + require.Equal(t, apisigning.SignMode(tc.sd.Mode), sigV2.Data.(*signing.SingleSignatureData).SignMode) require.Equal(t, tc.sd.Sig, sigV2.Data.(*signing.SingleSignatureData).Signature) require.Equal(t, tc.sd.SignDoc.Sequence, sigV2.Sequence) require.True(t, tc.sd.SignDoc.PublicKey.GetCachedValue().(cryptotypes.PubKey).Equals(sigV2.PubKey)) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index ada0a81076e..938d63c36d4 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -5,6 +5,8 @@ import ( gogoprotoany "github.com/cosmos/gogoproto/types/any" + signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) @@ -32,11 +34,10 @@ type SignatureV2 struct { func SignatureDataToProto(data SignatureData) *SignatureDescriptor_Data { switch data := data.(type) { case *SingleSignatureData: - signMode, _ := APISignModeToInternal(data.SignMode) return &SignatureDescriptor_Data{ Sum: &SignatureDescriptor_Data_Single_{ Single: &SignatureDescriptor_Data_Single{ - Mode: signMode, + Mode: SignMode(data.SignMode), Signature: data.Signature, }, }, @@ -67,9 +68,8 @@ func SignatureDataToProto(data SignatureData) *SignatureDescriptor_Data { func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { switch descData := descData.Sum.(type) { case *SignatureDescriptor_Data_Single_: - signMode, _ := InternalSignModeToAPI(descData.Single.Mode) return &SingleSignatureData{ - SignMode: signMode, + SignMode: signingv1beta1.SignMode(descData.Single.Mode), Signature: descData.Single.Signature, } case *SignatureDescriptor_Data_Multi_: diff --git a/types/tx/signing/types.go b/types/tx/signing/types.go deleted file mode 100644 index 9785c3667d3..00000000000 --- a/types/tx/signing/types.go +++ /dev/null @@ -1,39 +0,0 @@ -package signing - -import ( - "fmt" - - signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" -) - -// APISignModeToInternal converts a protobuf SignMode to a SignMode. -func APISignModeToInternal(mode signingv1beta1.SignMode) (SignMode, error) { - switch mode { - case signingv1beta1.SignMode_SIGN_MODE_DIRECT: - return SignMode_SIGN_MODE_DIRECT, nil - case signingv1beta1.SignMode_SIGN_MODE_LEGACY_AMINO_JSON: - return SignMode_SIGN_MODE_LEGACY_AMINO_JSON, nil - case signingv1beta1.SignMode_SIGN_MODE_TEXTUAL: - return SignMode_SIGN_MODE_TEXTUAL, nil - case signingv1beta1.SignMode_SIGN_MODE_DIRECT_AUX: - return SignMode_SIGN_MODE_DIRECT_AUX, nil - default: - return SignMode_SIGN_MODE_UNSPECIFIED, fmt.Errorf("unsupported sign mode %s", mode) - } -} - -// InternalSignModeToAPI converts a SignMode to a protobuf SignMode. -func InternalSignModeToAPI(mode SignMode) (signingv1beta1.SignMode, error) { - switch mode { - case SignMode_SIGN_MODE_DIRECT: - return signingv1beta1.SignMode_SIGN_MODE_DIRECT, nil - case SignMode_SIGN_MODE_LEGACY_AMINO_JSON: - return signingv1beta1.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, nil - case SignMode_SIGN_MODE_TEXTUAL: - return signingv1beta1.SignMode_SIGN_MODE_TEXTUAL, nil - case SignMode_SIGN_MODE_DIRECT_AUX: - return signingv1beta1.SignMode_SIGN_MODE_DIRECT_AUX, nil - default: - return signingv1beta1.SignMode_SIGN_MODE_UNSPECIFIED, fmt.Errorf("unsupported sign mode %s", mode) - } -} diff --git a/x/auth/tx/sigs.go b/x/auth/tx/sigs.go index 0ee52820233..d73024ad54a 100644 --- a/x/auth/tx/sigs.go +++ b/x/auth/tx/sigs.go @@ -21,11 +21,9 @@ func SignatureDataToModeInfoAndSig(data signing.SignatureData) (*tx.ModeInfo, [] switch data := data.(type) { case *signing.SingleSignatureData: - signMode, _ := signing.APISignModeToInternal(data.SignMode) - return &tx.ModeInfo{ Sum: &tx.ModeInfo_Single_{ - Single: &tx.ModeInfo_Single{Mode: signMode}, + Single: &tx.ModeInfo_Single{Mode: signing.SignMode(data.SignMode)}, }, }, data.Signature case *signing.MultiSignatureData: