Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new bridge adapter feature to enable custom ERC20 token bridging functionality. The implementation provides an alternative bridging mechanism through a dedicated bridge adapter contract interface.
Key changes:
- Adds new
BridgeAdapterclass with custom ERC20 bridging capabilities - Introduces
BridgeTokenParamsinterface for bridge adapter operations - Integrates bridge adapter functionality into existing
ERC20class
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/bridge.ts | Adds BridgeTokenParams interface for bridge adapter parameters |
| src/lxly/tokens/erc20.ts | Integrates bridgeToken method using the new bridge adapter |
| src/lxly/index.ts | Exports the new BridgeAdapter class |
| src/lxly/bridge/index.ts | Creates centralized export point for bridge functionality |
| src/lxly/bridge/bridge-adapter.ts | Implements the main BridgeAdapter class with token bridging logic |
| src/lxly/bridge/abi/index.ts | Centralizes bridge-related ABI exports |
| src/lxly/bridge/abi/bridge-adapter.ts | Defines the bridge adapter contract ABI |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| functionName: 'bridgeToken', | ||
| args: [ | ||
| params.recipient as Address, | ||
| BigInt(params.amount), |
There was a problem hiding this comment.
The amount parameter is validated as a string but directly converted to BigInt without error handling. Consider adding validation to ensure the string is a valid numeric format before conversion, or handle potential conversion errors.
| BigInt(params.amount), | |
| (() => { | |
| // Ensure params.amount is a valid non-negative integer string | |
| if (!/^\d+$/.test(params.amount)) { | |
| throw new Error(`Amount must be a valid non-negative integer string, got: "${params.amount}"`); | |
| } | |
| try { | |
| return BigInt(params.amount); | |
| } catch (e) { | |
| throw new Error(`Failed to convert amount to BigInt: ${e instanceof Error ? e.message : String(e)}`); | |
| } | |
| })(), |
| inputs: [ | ||
| { internalType: 'address', name: 'recipient', type: 'address' }, | ||
| { internalType: 'uint256', name: 'amount', type: 'uint256' }, | ||
| { internalType: 'uint32', name: 'destinationNetworkId', type: 'uint32' }, |
There was a problem hiding this comment.
The ABI defines destinationNetworkId as uint32 but the TypeScript interface uses number. Consider using a more specific type or adding validation to ensure the number fits within uint32 range (0 to 4,294,967,295).
No description provided.