-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor timestamp nonce ante handler and sigverify
- Loading branch information
1 parent
5d057b7
commit 0e28134
Showing
11 changed files
with
189 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ante | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" | ||
accountpluskeeper "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper" | ||
) | ||
|
||
// IsTimestampNonceTx returns `true` if the supplied `tx` consist of a single signature that uses a timestamp nonce | ||
// value for sequence | ||
func IsTimestampNonceTx(ctx sdk.Context, tx sdk.Tx) (bool, error) { | ||
sigTx, ok := tx.(authsigning.SigVerifiableTx) | ||
if !ok { | ||
return false, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") | ||
} | ||
signatures, err := sigTx.GetSignaturesV2() | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
if len(signatures) != 1 { | ||
return false, errorsmod.Wrap(sdkerrors.ErrTxDecode, "more than one signature") | ||
} | ||
|
||
if accountpluskeeper.IsTimestampNonce(signatures[0].Sequence) { | ||
return true, nil | ||
} else { | ||
return false, nil | ||
} | ||
} |
Oops, something went wrong.