Skip to content

feat: add deadline_expired and nonce_used checks to checkOrderFeasibility#33

Open
init4samwise wants to merge 2 commits intomainfrom
feat/permit2-preflight-checks
Open

feat: add deadline_expired and nonce_used checks to checkOrderFeasibility#33
init4samwise wants to merge 2 commits intomainfrom
feat/permit2-preflight-checks

Conversation

@init4samwise
Copy link
Contributor

@init4samwise init4samwise commented Feb 28, 2026

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 Permit2
  • ensurePermit2Approval - Check and proactively approve (handles USDT-style tokens)
  • isNonceUsed - Check if Permit2 nonce is consumed
  • checkOrderFeasibility - Comprehensive check for balance & allowance

Gap Identified & Implemented

The checkOrderFeasibility function was missing two important checks:

  1. Deadline expiration
  2. Nonce consumption

Changes

Code Changes

  • Added deadline_expired check to checkOrderFeasibility
  • Added nonce_used check to checkOrderFeasibility (calls isNonceUsed)
  • Updated FeasibilityIssueType to include new issue types

Test Changes

  • Added test for deadline_expired detection
  • Added test for nonce_used detection (with vitest mocking)

Documentation Changes

  • Added "Preflight Checks" section to README with:
    • checkOrderFeasibility usage example
    • Table of all issue types and descriptions
    • "Individual Checks" subsection for hasPermit2Approval, isNonceUsed, randomNonce
  • Updated API Reference with FeasibilityResult, FeasibilityIssue, FeasibilityIssueType types
  • Updated API Reference Functions section

Acceptance Criteria

  • Document existing permit2 preflight check functionality
  • Identify gaps in coverage
  • Implement missing functionality (deadline_expired, nonce_used)
  • Add/update tests for preflight checks
  • Update documentation

Testing

All tests pass:

  • pnpm test:run - 185 tests passed
  • pnpm lint - No issues
  • pnpm format:check - All formatted
  • pnpm typecheck - No errors

Closes ENG-1908

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant