Skip to content

fix: enforce unwrap daily limit#138

Open
ZaerCompany wants to merge 1 commit into
tari-project:developmentfrom
ZaerCompany:codex-fix-unwrap-daily-limit
Open

fix: enforce unwrap daily limit#138
ZaerCompany wants to merge 1 commit into
tari-project:developmentfrom
ZaerCompany:codex-fix-unwrap-daily-limit

Conversation

@ZaerCompany
Copy link
Copy Markdown

Fixes #137

Summary

  • fetch and store the remaining unwrap daily limit immediately when Ethereum -> Tari is selected
  • refresh the stored value every 30 seconds so input validation receives the live limit
  • stop the unwrap path before wallet signature / contract submission when the amount exceeds the remaining limit, including a zero remaining limit
  • clear the stale warning state when a later preflight check passes

Context

This restores the protection originally added in #96. During the later store cleanup, the polling hook's returned value stopped being written to remainingDailyLimit, and the final preflight guard was reduced to an inert new Error(...) expression with no control-flow exit.

Verification

  • git diff --check origin/development...HEAD
  • code-path audit: the UI updater now calls setRemainingDailyLimit(await fetchDailyLimit()) immediately and on the interval; the final guard returns before parseEther, typed-data signing, and writeContract

Local validation constraint

npm ci --ignore-scripts --no-audit --no-fund could not complete in this environment because @tari-project/wxtm-bridge-contracts@0.1.12 is served from GitHub Packages and the available token does not have the required package-read scope. Please run the normal build in the maintainer environment with package access.

@github-actions
Copy link
Copy Markdown

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the daily limit fetching and validation logic. In app/page.tsx, the daily limit is now fetched immediately on mount and updated periodically. In hooks/use-bridge-to-tari.ts, the limit check was simplified to return a boolean instead of instantiating an unused error. Feedback points out that removing the limitXtm check could allow transactions to bypass the limit if the value is undefined or NaN, and recommends adding an active flag to the asynchronous useEffect hook to prevent state updates on unmounted components.

Comment thread hooks/use-bridge-to-tari.ts Outdated
Comment thread app/page.tsx Outdated
@ZaerCompany ZaerCompany force-pushed the codex-fix-unwrap-daily-limit branch from c1255b3 to e998a06 Compare May 30, 2026 23:02
@ZaerCompany ZaerCompany force-pushed the codex-fix-unwrap-daily-limit branch from a44d5ca to e998a06 Compare May 30, 2026 23:14
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.

Unwrap daily-limit guard no longer blocks over-limit transactions

1 participant