Skip to content

Commit

Permalink
chore(x/tx): Harmonize TypeResolver interface (#16846)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jul 11, 2023
1 parent a54ee26 commit 3c1c4c5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions x/tx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## v0.9.0

### Bug Fixes

* [#16681](https://github.com/cosmos/cosmos-sdk/pull/16681): catch and fix `(*Decoder).Decode` crash from invalid length prefix in Tx bytes
* [#16681](https://github.com/cosmos/cosmos-sdk/pull/16681): Catch and fix `(*Decoder).Decode` crash from invalid length prefix in Tx bytes.

### Improvements

* [#16684](https://github.com/cosmos/cosmos-sdk/pull/16684): x/tx/signing/aminojson: use io.WriteString+fmt.Fprintf to remove unnecessary string->[]byte roundtrip
* [#16846](https://github.com/cosmos/cosmos-sdk/pull/16846): Harmonize interface `signing.TypeResolver` with the rest of the codebase (orm and client/v2).
* [#16684](https://github.com/cosmos/cosmos-sdk/pull/16684): Use `io.WriteString`+`fmt.Fprintf` to remove unnecessary `string`->`[]byte` roundtrip.

## v0.8.0

Expand Down
2 changes: 1 addition & 1 deletion x/tx/signing/aminojson/aminojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type SignModeHandler struct {
// SignModeHandlerOptions are the options for the SignModeHandler.
type SignModeHandlerOptions struct {
FileResolver signing.ProtoFileResolver
TypeResolver protoregistry.MessageTypeResolver
TypeResolver signing.TypeResolver
Encoder *Encoder
}

Expand Down
2 changes: 1 addition & 1 deletion x/tx/signing/aminojson/json_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type EncoderOptions struct {
// DonotSortFields when set turns off sorting of field names.
DoNotSortFields bool
// TypeResolver is used to resolve protobuf message types by TypeURL when marshaling any packed messages.
TypeResolver protoregistry.MessageTypeResolver
TypeResolver signing.TypeResolver
// FileResolver is used to resolve protobuf file descriptors TypeURL when TypeResolver fails.
FileResolver signing.ProtoFileResolver
}
Expand Down
7 changes: 6 additions & 1 deletion x/tx/signing/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
"cosmossdk.io/core/address"
)

type TypeResolver interface {
protoregistry.MessageTypeResolver
protoregistry.ExtensionTypeResolver
}

// Context is a context for retrieving the list of signers from a
// message where signers are specified by the cosmos.msg.v1.signer protobuf
// option. It also contains the ProtoFileResolver and address.Codec's used
Expand All @@ -34,7 +39,7 @@ type Options struct {
FileResolver ProtoFileResolver

// TypeResolver is the protobuf type resolver to use for resolving message types.
TypeResolver protoregistry.MessageTypeResolver
TypeResolver TypeResolver

// AddressCodec is the codec for converting addresses between strings and bytes.
AddressCodec address.Codec
Expand Down
2 changes: 2 additions & 0 deletions x/tx/signing/textual/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ var (
)

func FuzzCoinsJSONTestcases(f *testing.F) {
f.Skip() // https://github.com/cosmos/cosmos-sdk/pull/16521#issuecomment-1614507574

// Generate some seeds.
seed, err := os.ReadFile("./internal/testdata/coins.json")
if err != nil {
Expand Down

0 comments on commit 3c1c4c5

Please sign in to comment.