Skip to content

Conversation

@evandrosaturnino
Copy link
Contributor

@evandrosaturnino evandrosaturnino commented Oct 31, 2025

Summary

This pull request introduces a feature enhancement: gasless deposits for L1 networks (Ethereum Mainnet and Sepolia). It also resolves critical bugs related to CORS policy and UI rendering that were affecting the deposit flow, particularly in local development environments.

Changes

Gasless L1 Deposits

  • New gaslessRevealDeposit Method: A new method has been added to the TBTC class to interact with a relayer service for processing L1 deposit reveals. This allows users to mint tBTC on L1 without needing to pay for the gas of the reveal transaction themselves.
  • Automatic Gasless Flow: The existing revealDeposit method has been updated to automatically detect when a user is on an L1 network. It seamlessly uses the gasless reveal mechanism in this case, while continuing to use the standard on-chain reveal for L2 and cross-chain deposits.
  • Frontend Integration: The InitiateMinting component now uses the unified revealDeposit flow. No complex frontend logic is needed to differentiate between L1 and L2, as the core library handles it automatically.

🔧 API Endpoint Centralization

  • A new constants file (src/threshold-ts/tbtc/constants.ts) has been created to centralize all external API endpoints (api.tbtcscan.com, localhost, etc.).
  • Both the new gasless implementation and the existing Solana depositor interface have been refactored to use these shared constants, improving maintainability and consistency.

Bug Fixes

  1. CORS Error on Deposit Telemetry:

    • Problem: When generating a new deposit address on localhost, the application would make a telemetry call to api.tbtcscan.com/deposit-data, which failed due to a restrictive CORS policy on the server. This error would halt the deposit process.
    • Solution: A new isLocalhost() utility function has been created. The useDepositTelemetry hook now uses this utility to detect if the app is running in a local development environment and skips the telemetry API call, preventing the CORS error from occurring. Error handling has been made more robust to ensure telemetry failures do not block the user flow.
  2. QR Code Rendering Error:

    • Problem: The QRCode component was throwing an error because it was attempting to render with an undefined value for the BTC deposit address. This happened when the deposit state was prematurely cleared, often as a side effect of the CORS error.
    • Solution: The MakeDeposit.tsx component has been updated to handle cases where the btcDepositAddress is not yet available. It now displays a loading state and only renders the QR code once the address has been successfully generated.

@evandrosaturnino evandrosaturnino self-assigned this Oct 31, 2025
@github-actions
Copy link

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.

2 participants