Skip to content

Commit

Permalink
feat(x/tx): support bytes field as signer (cosmos#21850)
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang authored Sep 26, 2024
1 parent 0ab189c commit dbf6cdb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
4 changes: 4 additions & 0 deletions x/tx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Since v0.13.0, x/tx follows Cosmos SDK semver: https://github.com/cosmos/cosmos-

## [Unreleased]

### Improvements

* [#21850](https://github.com/cosmos/cosmos-sdk/pull/21850) Support bytes field as signer.

## [v0.13.5](https://github.com/cosmos/cosmos-sdk/releases/tag/x/tx/v0.13.5) - 2024-09-18

### Improvements
Expand Down
4 changes: 2 additions & 2 deletions x/tx/internal/testpb/signers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ message DeeplyNestedRepeatedSigner {

message BadSigner {
option (cosmos.msg.v1.signer) = "signer";
bytes signer = 1;
int32 signer = 1;
}

message NoSignerOption {
Expand All @@ -107,4 +107,4 @@ message ValidatorSigner {
service TestSimpleSigner {
option (cosmos.msg.v1.service) = true;
rpc TestSimpleSigner(SimpleSigner) returns (SimpleSigner) {}
}
}
56 changes: 19 additions & 37 deletions x/tx/internal/testpb/signers.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions x/tx/signing/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ func (c *Context) makeGetSignersFunc(descriptor protoreflect.MessageDescriptor)
}
return arr, nil
}
case protoreflect.BytesKind:
fieldGetters[i] = func(msg proto.Message, arr [][]byte) ([][]byte, error) {
addrBz := msg.ProtoReflect().Get(field).Bytes()
return append(arr, addrBz), nil
}
default:
return nil, fmt.Errorf("unexpected field type %s for field %s in message %s", field.Kind(), fieldName, descriptor.FullName())
}
Expand Down

0 comments on commit dbf6cdb

Please sign in to comment.