feat: add gasless minting support #873
Open
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 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
gaslessRevealDepositMethod: A new method has been added to theTBTCclass 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.revealDepositmethod 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.InitiateMintingcomponent now uses the unifiedrevealDepositflow. No complex frontend logic is needed to differentiate between L1 and L2, as the core library handles it automatically.🔧 API Endpoint Centralization
src/threshold-ts/tbtc/constants.ts) has been created to centralize all external API endpoints (api.tbtcscan.com, localhost, etc.).Bug Fixes
CORS Error on Deposit Telemetry:
localhost, the application would make a telemetry call toapi.tbtcscan.com/deposit-data, which failed due to a restrictive CORS policy on the server. This error would halt the deposit process.isLocalhost()utility function has been created. TheuseDepositTelemetryhook 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.QR Code Rendering Error:
QRCodecomponent was throwing an error because it was attempting to render with anundefinedvalue for the BTC deposit address. This happened when the deposit state was prematurely cleared, often as a side effect of the CORS error.MakeDeposit.tsxcomponent has been updated to handle cases where thebtcDepositAddressis not yet available. It now displays a loading state and only renders the QR code once the address has been successfully generated.