Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Liquidity Bridge Integration #99

Draft
wants to merge 10 commits into
base: staging
Choose a base branch
from
Draft

[WIP] Liquidity Bridge Integration #99

wants to merge 10 commits into from

Conversation

abheektripathy
Copy link
Member

No description provided.

Copy link

vercel bot commented Feb 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bridge-ui ❌ Failed (Inspect) Feb 10, 2025 4:38am

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces significant changes to implement a liquidity bridge integration across the bridge UI, with major modifications to chain selection and transaction handling.

  • Removal of chain combination validation in chainselectormodal.tsx could allow invalid chain pairs (BASE<->AVAIL), potentially causing failed transactions
  • New AdvancedSettings component has unused slippage state and non-persisted settings that reset on remount
  • useLiquidityBridge hook has incomplete ERC20 to Avail bridging flow and hardcoded tx_index value
  • getERC20AvailBalance in useEthWallet.ts has dependency array issues and lacks proper error handling
  • Downgrade of @polkadot/types from v11.3.1 to v10.13.1 in package.json requires careful testing for compatibility

22 file(s) reviewed, 38 comment(s)
Edit PR Review Bot Settings | Greptile

</Dialog>
);
<div className="flex items-center justify-center p-4 text-[#8B8EA3] text-sm border-t bg-[#1D2230] rounded-b-xl border-[#252A3C]">
looking for the testnet bridge, <a href="https://turing.bridge.avail.so/" className="italic cursor-pointer ml-1 underline">click here</a>
Copy link

Choose a reason for hiding this comment

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

syntax: sentence should be capitalized and use proper punctuation

Suggested change
looking for the testnet bridge, <a href="https://turing.bridge.avail.so/" className="italic cursor-pointer ml-1 underline">click here</a>
Looking for the testnet bridge? <a href="https://turing.bridge.avail.so/" className="italic cursor-pointer ml-1 underline">Click here</a>

Comment on lines 13 to 14
const [autoClaim, setAutoClaim] = useState(true);
const [slippage, setSlippage] = useState('0.5');
Copy link

Choose a reason for hiding this comment

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

logic: These states should be moved to a global store (e.g. useCommonStore) since they affect bridge behavior and need to persist between component remounts

Comment on lines +27 to +30
<ArrowLeft
className="text-gray-400 hover:text-white hover:cursor-pointer"
onClick={() => setIsOpen(false)}
/>
Copy link

Choose a reason for hiding this comment

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

logic: Redundant close handler - the Dialog already handles closing via onOpenChange. Remove the onClick handler to avoid potential race conditions

Suggested change
<ArrowLeft
className="text-gray-400 hover:text-white hover:cursor-pointer"
onClick={() => setIsOpen(false)}
/>
<ArrowLeft
className="text-gray-400 hover:text-white hover:cursor-pointer"
/>

const AdvancedSettings = () => {
const [isOpen, setIsOpen] = useState(false);
const [autoClaim, setAutoClaim] = useState(true);
const [slippage, setSlippage] = useState('0.5');
Copy link

Choose a reason for hiding this comment

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

logic: slippage state is defined but never used in the UI or passed to bridge functions

@@ -0,0 +1,53 @@
import React, { useState } from 'react';
import { ArrowLeft, Info, Settings } from 'lucide-react';
Copy link

Choose a reason for hiding this comment

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

style: Info icon is imported but never used in the component

Suggested change
import { ArrowLeft, Info, Settings } from 'lucide-react';
import { ArrowLeft, Settings } from 'lucide-react';

address: account.address,
});

const verification = signatureVerify(u8aToHex(messageBytes), signature, account.address);
Copy link

Choose a reason for hiding this comment

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

style: Message bytes are converted to hex twice - once for signing and once for verification. Consider reusing the hex value

atomicAmount
)
.signAndSend(account.address, options, (result: ISubmittableResult) => {
console.log(`Tx status: ${result.status}`);
Copy link

Choose a reason for hiding this comment

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

style: Using console.log for transaction status. Should use Logger utility for consistency

Suggested change
console.log(`Tx status: ${result.status}`);
Logger.info(`Tx status: ${result.status}`);

Comment on lines +25 to +31
sender_address: string;
tx_index: number;
block_hash: string;
eth_receiver_address: string;
amount: string;
}
Copy link

Choose a reason for hiding this comment

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

style: fields match those used in useLiquidityBridge.ts, but consider adding validation for eth_receiver_address format since it's used for Ethereum addresses

sender_address: string;
tx_index: number;
status: "InProgress" | "Completed" | "Failed";
Copy link

Choose a reason for hiding this comment

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

logic: status values don't align with TransactionStatus enum defined above. Consider reusing those values for consistency

Suggested change
status: "InProgress" | "Completed" | "Failed";
status: TransactionStatus.INITIATED | TransactionStatus.BRIDGED | TransactionStatus.FAILED;

block_hash: string;
eth_receiver_address: string;
amount: string;
Copy link

Choose a reason for hiding this comment

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

style: amount is defined as string but should probably use BigInt for consistency with ethBalance interface above

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.

1 participant