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

Feature/bridge #211

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/bridge/public/thirdparty/external-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions apps/bridge/src/components/bridge/CTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { useIsChainID } from "@hooks/web3/read/useIsChainID";
import { useCallApprove } from "@hooks/web3/bridge/write/useCallApprove";
import { useSwitchToNetwork } from "@hooks/web3/write/useSwitchToNetwork";
import { useIsWalletMultisig } from "@hooks/useIsWalletMultisig";
import Link from "next/link";
import Image from "next/image";

// Contains a button & a modal to control allowance and deposits/withdrawals
export default function CTA({
Expand All @@ -37,8 +39,10 @@ export default function CTA({
allowance,
selectedTokenAmount = "",
destinationTokenAmount = "",
selectedToken,
setCTAPage,
setWalletModalOpen,
tokens,
} = useContext(StateContext);

// check that we're connected to the appropriate chain
Expand All @@ -64,6 +68,16 @@ export default function CTA({
// create an allowance approval request on the selected token
const { approve, approvalStatus } = useCallApprove(selected || {});

const type = chainId === L1_CHAIN_ID ? Direction.Deposit : Direction.Withdraw;

// get the selection Token
const selection =
tokens.find((v) => {
return selectedToken[type] === v.name && v.chainId === chainId;
}) ||
tokens[chainId === L1_CHAIN_ID ? 0 : 1] ||
{};

// ensure we don't overflow
const fixDecimals = useCallback(
(value: string) => {
Expand Down Expand Up @@ -169,6 +183,35 @@ export default function CTA({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [client?.address]);

if (selection.extensions?.thirdparty) {
return (
<div className="mt-4">
<Link
href={selection.extensions.thirdparty.url}
rel="noreferrer noopener"
target="_blank"
>
<Button
type="button"
size="full"
className="h-14 flex items-center justify-center gap-1"
>
{direction === Direction.Deposit
? `Deposit with ${selection.extensions.thirdparty.name}`
: `Withdraw with ${selection.extensions.thirdparty.name}`}
<Image
className="translate -translate-y-[2px]"
src="/thirdparty/external-dark.svg"
alt="external"
width={16}
height={16}
/>
</Button>
</Link>
</div>
);
}

return (
<div className="mt-4">
{!client?.address ? (
Expand Down
6 changes: 5 additions & 1 deletion apps/bridge/src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ export interface Token {
decimals: number;
logoURI: string;
extensions: {
optimismBridgeAddress: Address;
optimismBridgeAddress?: Address;
thirdparty?: {
name: string;
url: string;
};
};
balance?: BigNumberish;
allowance?: BigNumberish;
Expand Down
Loading