Co-authored-by: mmsqe <mavis@crypto.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
2abd2ec8a5
commit
f9041cde5c
@ -40,6 +40,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [v0.50.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.5) - 2024-XX-XX
|
||||
|
||||
### Improvements
|
||||
|
||||
* (x/auth) [#19651](https://github.com/cosmos/cosmos-sdk/pull/19651) Allow empty public keys in `GetSignBytesAdapter`.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (x/auth) [#19549](https://github.com/cosmos/cosmos-sdk/pull/19549) Accept custom get signers when injecting `x/auth/tx`.
|
||||
|
||||
@ -41,20 +41,24 @@ func GetSignBytesAdapter(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var pubKey *anypb.Any
|
||||
if signerData.PubKey != nil {
|
||||
anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pubKey = &anypb.Any{
|
||||
TypeUrl: anyPk.TypeUrl,
|
||||
Value: anyPk.Value,
|
||||
}
|
||||
}
|
||||
txSignerData := txsigning.SignerData{
|
||||
ChainID: signerData.ChainID,
|
||||
AccountNumber: signerData.AccountNumber,
|
||||
Sequence: signerData.Sequence,
|
||||
Address: signerData.Address,
|
||||
PubKey: &anypb.Any{
|
||||
TypeUrl: anyPk.TypeUrl,
|
||||
Value: anyPk.Value,
|
||||
},
|
||||
PubKey: pubKey,
|
||||
}
|
||||
// Generate the bytes to be signed.
|
||||
return handlerMap.GetSignBytes(ctx, txSignMode, txSignerData, txData)
|
||||
|
||||
33
x/auth/signing/adapter_test.go
Normal file
33
x/auth/signing/adapter_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package signing_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsign "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
|
||||
func TestGetSignBytesAdapterNoPublicKey(t *testing.T) {
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
txConfig := encodingConfig.TxConfig
|
||||
_, _, addr := testdata.KeyTestPubAddr()
|
||||
signerData := authsign.SignerData{
|
||||
Address: addr.String(),
|
||||
ChainID: "test-chain",
|
||||
AccountNumber: 11,
|
||||
Sequence: 15,
|
||||
}
|
||||
w := txConfig.NewTxBuilder()
|
||||
_, err := authsign.GetSignBytesAdapter(
|
||||
context.Background(),
|
||||
txConfig.SignModeHandler(),
|
||||
signing.SignMode_SIGN_MODE_DIRECT,
|
||||
signerData,
|
||||
w.GetTx())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user