Skip to content

Commit 6f2bab5

Browse files
authored
fix(x/auth/tx): add missing CacheWithValue for ExtensionOptions (#23144)
1 parent 58d71c0 commit 6f2bab5

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
5353
### Bug Fixes
5454

5555
* (query) [23002](https://github.com/cosmos/cosmos-sdk/pull/23002) Fix collection filtered pagination.
56+
* (x/auth/tx) [23144](https://github.com/cosmos/cosmos-sdk/pull/23144) Add missing CacheWithValue for ExtensionOptions.
5657
* (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional.
5758

5859
### API Breaking Changes

x/auth/tx/builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func newBuilderFromDecodedTx(
4646
modeInfoV1 := new(tx.ModeInfo)
4747
fromV2ModeInfo(sigInfo.ModeInfo, modeInfoV1)
4848
sigInfos[i] = &tx.SignerInfo{
49-
PublicKey: intoAnyV1([]*anypb.Any{sigInfo.PublicKey})[0],
49+
PublicKey: intoAnyV1(codec, []*anypb.Any{sigInfo.PublicKey})[0],
5050
ModeInfo: modeInfoV1,
5151
Sequence: sigInfo.Sequence,
5252
}

x/auth/tx/gogotx.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/cosmos/gogoproto/proto"
10+
gogoproto "github.com/cosmos/gogoproto/types/any"
1011
"google.golang.org/protobuf/reflect/protoreflect"
1112
"google.golang.org/protobuf/types/known/anypb"
1213

@@ -236,11 +237,11 @@ func (w *gogoTxWrapper) GetSigningTxData() txsigning.TxData {
236237
}
237238

238239
func (w *gogoTxWrapper) GetExtensionOptions() []*codectypes.Any {
239-
return intoAnyV1(w.Tx.Body.ExtensionOptions)
240+
return intoAnyV1(w.cdc, w.Tx.Body.ExtensionOptions)
240241
}
241242

242243
func (w *gogoTxWrapper) GetNonCriticalExtensionOptions() []*codectypes.Any {
243-
return intoAnyV1(w.Tx.Body.NonCriticalExtensionOptions)
244+
return intoAnyV1(w.cdc, w.Tx.Body.NonCriticalExtensionOptions)
244245
}
245246

246247
func (w *gogoTxWrapper) AsTx() (*txtypes.Tx, error) {
@@ -270,13 +271,20 @@ func (w *gogoTxWrapper) AsTxRaw() (*txtypes.TxRaw, error) {
270271
}, nil
271272
}
272273

273-
func intoAnyV1(v2s []*anypb.Any) []*codectypes.Any {
274+
func intoAnyV1(cdc codec.BinaryCodec, v2s []*anypb.Any) []*codectypes.Any {
274275
v1s := make([]*codectypes.Any, len(v2s))
275276
for i, v2 := range v2s {
276-
v1s[i] = &codectypes.Any{
277-
TypeUrl: v2.TypeUrl,
278-
Value: v2.Value,
277+
var value *gogoproto.Any
278+
if msg, err := decodeFromAny(cdc, v2); err == nil {
279+
value, _ = gogoproto.NewAnyWithCacheWithValue(msg)
279280
}
281+
if value == nil {
282+
value = &codectypes.Any{
283+
TypeUrl: v2.TypeUrl,
284+
Value: v2.Value,
285+
}
286+
}
287+
v1s[i] = value
280288
}
281289
return v1s
282290
}

0 commit comments

Comments
 (0)