Skip to content

Commit

Permalink
feat: support bytes field as signer
Browse files Browse the repository at this point in the history
should be harmless to support bytes field, and bytes fields are more efficient than string,
  • Loading branch information
yihuang committed Sep 23, 2024
1 parent 4666e1d commit 0c99504
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
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 0c99504

Please sign in to comment.