feat: USDT approve(0) reset flow for Ethereum mainnet swap#1925
feat: USDT approve(0) reset flow for Ethereum mainnet swap#1925piatoss3612 wants to merge 8 commits intodevelopfrom
Conversation
- Introduced `ObservableQueryERC20Allowance` to fetch and compute ERC20 token allowances. - Added `ObservableQueryERC20AllowanceMap` for managing multiple allowance queries. - Updated `EthereumQueriesImpl` to include the new allowance query functionality. - Added a constant for USDT approval reset requirements and a utility function to check if an approval reset is needed based on chain ID and token address.
- Introduced new components and hooks for resetting USDT allowance in the swap process. - Updated language files to include descriptions and button labels for the allowance reset feature in English, Korean, and Simplified Chinese. - Implemented logic to handle approval reset requirements and transaction simulation for gas estimation.
- Integrated `useUsdtApprovalReset` hook to manage USDT allowance reset logic. - Updated `IBCSwapPage` to conditionally display the allowance reset UI and handle reset actions. - Modified `useQueryRouteRefresh` to account for approval reset state. - Added state management for approval reset pending status in `IBCSwapConfig`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8f3790d29
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…g state - P1: gate requiresApprovalReset by isInputUsdtRequiringReset so a pending reset does not block unrelated token/chain swaps - P2: add on-chain allowance fallback to clear stuck isApprovalResetPending when tx fulfill callback is missed (retry exhaustion, delayed receipt)
…cator - Expose refetchAllowance from useUsdtApprovalReset hook - Call refetchAllowance in both swap success and failure paths so the next attempt evaluates reset UI against fresh on-chain allowance (approve(amount) may have succeeded even when swap failed) - Hide step indicator and "N approvals required" label while showApprovalResetUI is active — the reset info block already communicates the 2-step requirement
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3a53e930e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pre-broadcast failures (gas simulation, tx encoding) were silently swallowed by the outer catch — the loading button briefly flashed then reset with no feedback. Call onResetFailed in the catch so the "transaction-failed" toast surfaces these errors.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 398629c332
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Previously approvalSpenderRef only updated when requiredErc20Approvals[0] existed. After the user lowered the swap amount below their current allowance, the new quote returned no approval and the ref kept pointing to the old spender. The reset UI stayed visible against that stale spender's allowance, but clicking Reset no-op'd because the live tx had no approval — leaving the user stuck. Now the ref is set to null when the ready tx has no approval, only mutating once a fresh tx is observed (preserves the original transient null-tx flicker guard).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 896ae43c27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
sendEthereumTx invokes onBroadcastFailed and then rethrows for any broadcast error, including the user-initiated "Request rejected" case. Without filtering, declining the signing prompt produced a misleading transaction-failed toast. Match the main swap submit path's behavior: skip onResetFailed when the error message is "Request rejected", in both the onBroadcastFailed callback and the outer catch (covers pre-broadcast cancellation paths).
Summary
approve구현 (require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)))) 대응Changes
stores-eth
USDT_APPROVE_RESET_REQUIRED상수 +isApproveResetRequired()감지 함수ObservableQueryERC20Allowance/ObservableQueryERC20AllowanceMap— MobX observable allowance 조회hooks / UI
useUsdtApprovalReset훅 — allowance 조회, spender 캐싱, approve(0) tx 전송, gas estimation, pending 상태 관리UsdtAllowanceResetInfo컴포넌트 — Figma 원본 SVG (도트 패턴 + USDT shield 아이콘) + 안내 텍스트useQueryRouteRefresh— reset 필요 시 route 자동 refresh 차단IBCSwapConfig—isApprovalResetPending상태를 MobX store로 관리 (페이지 이동 간 유지)UX
apps/hooks-internal/src/swap/amount.ts— swap tx data0xdeadbeef변조Tickets
Test plan
0xdeadbeef) 제거 후 전체 스왑 플로우 E2E 확인