Skip to content

Commit

Permalink
fix: allow empty public keys (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Jan 19, 2024
1 parent 590938d commit 0244d0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,17 @@ func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
rawSigs := make([][]byte, n)

for i, sig := range signatures {
var modeInfo *tx.ModeInfo
var (
modeInfo *tx.ModeInfo
any *codectypes.Any
err error
)
modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data)
any, err := codectypes.NewAnyWithValue(sig.PubKey)
if err != nil {
return err
if sig.PubKey != nil {
any, err = codectypes.NewAnyWithValue(sig.PubKey)
if err != nil {
return err
}
}
signerInfos[i] = &tx.SignerInfo{
PublicKey: any,
Expand Down
14 changes: 14 additions & 0 deletions x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ func TestTxBuilder(t *testing.T) {
})
}

func TestSetSignaturesNoPublicKey(t *testing.T) {
_, pubkey, _ := testdata.KeyTestPubAddr()
txBuilder := newBuilder(nil)
sig2 := signing.SignatureV2{
Data: &signing.SingleSignatureData{
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
Signature: legacy.Cdc.MustMarshal(pubkey),
},
Sequence: 1,
}
err := txBuilder.SetSignatures(sig2)
require.NoError(t, err)
}

func TestBuilderValidateBasic(t *testing.T) {
// keys and addresses
_, pubKey1, addr1 := testdata.KeyTestPubAddr()
Expand Down

0 comments on commit 0244d0c

Please sign in to comment.