refactor!: Add context arg to sign mode handler GetSignBytes (#13701)
* refactor!: Add context arg to sign mode handler `GetSignBytes` * fix build * fix tests * Fix goling * fix lint * Fix lint * Fix test * Update CHANGELOG.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Fix tests * Fix rosetta deps * fix * go mod tidy all * go mod tidy Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
Marko
Julien Robert
parent
5a1fa2ee02
commit
fffc9d07d5
+6
-4
@@ -106,7 +106,8 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
}
|
||||
}
|
||||
|
||||
err = Sign(txf, clientCtx.GetFromName(), tx, true)
|
||||
// When Textual is wired up, the context argument should be retrieved from the client context.
|
||||
err = Sign(context.TODO(), txf, clientCtx.GetFromName(), tx, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -149,6 +150,7 @@ func CalculateGas(
|
||||
// SignWithPrivKey signs a given tx with the given private key, and returns the
|
||||
// corresponding SignatureV2 if the signing is successful.
|
||||
func SignWithPrivKey(
|
||||
ctx context.Context,
|
||||
signMode signing.SignMode, signerData authsigning.SignerData,
|
||||
txBuilder client.TxBuilder, priv cryptotypes.PrivKey, txConfig client.TxConfig,
|
||||
accSeq uint64,
|
||||
@@ -156,7 +158,7 @@ func SignWithPrivKey(
|
||||
var sigV2 signing.SignatureV2
|
||||
|
||||
// Generate the bytes to be signed.
|
||||
signBytes, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
|
||||
signBytes, err := txConfig.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txBuilder.GetTx())
|
||||
if err != nil {
|
||||
return sigV2, err
|
||||
}
|
||||
@@ -227,7 +229,7 @@ func checkMultipleSigners(tx authsigning.Tx) error {
|
||||
// Signing a transaction with mutltiple signers in the DIRECT mode is not supprted and will
|
||||
// return an error.
|
||||
// An error is returned upon failure.
|
||||
func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig bool) error {
|
||||
func Sign(ctx context.Context, txf Factory, name string, txBuilder client.TxBuilder, overwriteSig bool) error {
|
||||
if txf.keybase == nil {
|
||||
return errors.New("keybase must be set prior to signing a transaction")
|
||||
}
|
||||
@@ -298,7 +300,7 @@ func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig boo
|
||||
}
|
||||
|
||||
// Generate the bytes to be signed.
|
||||
bytesToSign, err := txf.txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
|
||||
bytesToSign, err := txf.txConfig.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txBuilder.GetTx())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ func TestSign(t *testing.T) {
|
||||
var prevSigs []signingtypes.SignatureV2
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err = tx.Sign(tc.txf, tc.from, tc.txb, tc.overwrite)
|
||||
err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite)
|
||||
if len(tc.expectedPKs) == 0 {
|
||||
requireT.Error(err)
|
||||
} else {
|
||||
@@ -423,7 +423,7 @@ func TestPreprocessHook(t *testing.T) {
|
||||
msg2 := banktypes.NewMsgSend(addr2, sdk.AccAddress("to"), nil)
|
||||
txb, err := txfDirect.BuildUnsignedTx(msg1, msg2)
|
||||
|
||||
err = tx.Sign(txfDirect, from, txb, false)
|
||||
err = tx.Sign(nil, txfDirect, from, txb, false)
|
||||
requireT.NoError(err)
|
||||
|
||||
// Run preprocessing
|
||||
|
||||
Reference in New Issue
Block a user