Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/auth/tx): avoid panic from intoAnyV2 when v1.PublicKey is optional #23148

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### Bug Fixes

* (query) [23002](https://github.com/cosmos/cosmos-sdk/pull/23002) Fix collection filtered pagination.
* (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional.

### API Breaking Changes

Expand Down
8 changes: 5 additions & 3 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@ func intoV2SignerInfo(v1s []*tx.SignerInfo) []*txv1beta1.SignerInfo {
modeInfoV2 := new(txv1beta1.ModeInfo)
intoV2ModeInfo(v1.ModeInfo, modeInfoV2)
v2 := &txv1beta1.SignerInfo{
PublicKey: intoAnyV2([]*codectypes.Any{v1.PublicKey})[0],
ModeInfo: modeInfoV2,
Sequence: v1.Sequence,
ModeInfo: modeInfoV2,
Sequence: v1.Sequence,
}
if v1.PublicKey != nil {
v2.PublicKey = intoAnyV2([]*codectypes.Any{v1.PublicKey})[0]
}
v2s[i] = v2
}
Expand Down
15 changes: 15 additions & 0 deletions x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package tx

import (
"testing"

any "github.com/cosmos/gogoproto/types/any"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/types/tx"
)

func TestIntoV2SignerInfo(t *testing.T) {
require.NotNil(t, intoV2SignerInfo([]*tx.SignerInfo{{}}))
require.NotNil(t, intoV2SignerInfo([]*tx.SignerInfo{{PublicKey: &any.Any{}}}))
}
Loading