feat: add deadline_expired and nonce_used checks to checkOrderFeasibility#33
Open
init4samwise wants to merge 2 commits intomainfrom
Open
feat: add deadline_expired and nonce_used checks to checkOrderFeasibility#33init4samwise wants to merge 2 commits intomainfrom
init4samwise wants to merge 2 commits intomainfrom
Conversation
…lity - Add deadline_expired check: detects orders with expired permit deadlines - Add nonce_used check: detects orders whose Permit2 nonce has been consumed - Add tests for both new check types - Update CHANGELOG with new functionality Closes ENG-1908
- Add comprehensive 'Preflight Checks' section documenting checkOrderFeasibility - Document all issue types: insufficient_balance, insufficient_allowance, nonce_used, deadline_expired - Add 'Individual Checks' subsection covering hasPermit2Approval, isNonceUsed, randomNonce - Update API Reference with FeasibilityResult, FeasibilityIssue, FeasibilityIssueType types - Update API Reference Functions with preflight check functions
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes ENG-1908: Evaluate Permit2 preflight checks in TypeScript SDK.
Research Findings
The SDK already had comprehensive Permit2 preflight functionality including:
hasPermit2Approval- Check ERC20 allowance to Permit2ensurePermit2Approval- Check and proactively approve (handles USDT-style tokens)isNonceUsed- Check if Permit2 nonce is consumedcheckOrderFeasibility- Comprehensive check for balance & allowanceGap Identified & Implemented
The
checkOrderFeasibilityfunction was missing two important checks:Changes
Code Changes
deadline_expiredcheck tocheckOrderFeasibilitynonce_usedcheck tocheckOrderFeasibility(callsisNonceUsed)FeasibilityIssueTypeto include new issue typesTest Changes
deadline_expireddetectionnonce_useddetection (with vitest mocking)Documentation Changes
checkOrderFeasibilityusage examplehasPermit2Approval,isNonceUsed,randomNonceFeasibilityResult,FeasibilityIssue,FeasibilityIssueTypetypesAcceptance Criteria
Testing
All tests pass:
pnpm test:run- 185 tests passedpnpm lint- No issuespnpm format:check- All formattedpnpm typecheck- No errorsCloses ENG-1908