Skip to content

Commit

Permalink
add token search param to external link to arb bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Oct 18, 2024
1 parent c39e9ce commit 2d10b0d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
10 changes: 5 additions & 5 deletions components/dialogs/transfer/bridge-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import {
import { cn } from "@/lib/utils"

export function BridgePrompt({
baseToken,
token,
formattedL1Balance,
}: {
baseToken?: Token
token?: Token
formattedL1Balance: string
}) {
if (!baseToken) return null
if (!token) return null
return (
<Tooltip>
<TooltipTrigger asChild>
<a
className={cn(
"group flex gap-4 border p-4 transition-colors hover:cursor-pointer hover:border-primary",
)}
href={constructArbitrumBridgeUrl(formattedL1Balance)}
href={constructArbitrumBridgeUrl(formattedL1Balance, token.address)}
rel="noopener noreferrer"
target="_blank"
>
Expand All @@ -49,7 +49,7 @@ export function BridgePrompt({
</TooltipTrigger>
<TooltipContent>
{`To deposit into Renegade, you must first bridge
your ${baseToken.ticker} to Arbitrum`}
your ${token.ticker} to Arbitrum`}
</TooltipContent>
</Tooltip>
)
Expand Down
22 changes: 9 additions & 13 deletions components/dialogs/transfer/default-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export function DefaultForm({

<div
className={cn("flex justify-between", {
hidden: !userHasL1Balance || !isDeposit,
hidden: !userHasL1Balance || !isDeposit || !l1Token?.address,
})}
>
<div className="flex items-center gap-1 text-sm text-muted-foreground">
Expand All @@ -597,26 +597,22 @@ export function DefaultForm({
Ethereum
</div>
<Tooltip>
<TooltipTrigger
asChild
className={cn({
hidden: !userHasL1Balance,
})}
>
<TooltipTrigger asChild>
<Button
asChild
className="h-5 cursor-pointer p-0 font-mono text-sm"
type="button"
variant="link"
>
<a
href={constructArbitrumBridgeUrl(formattedL1Balance)}
href={constructArbitrumBridgeUrl(
formattedL1Balance,
l1Token?.address,
)}
rel="noopener noreferrer"
target="_blank"
>
{baseToken
? `${l1BalanceLabel} ${baseToken.ticker}`
: "--"}
{l1Token ? `${l1BalanceLabel} ${l1Token.ticker}` : "--"}
</a>
</Button>
</TooltipTrigger>
Expand All @@ -631,12 +627,12 @@ export function DefaultForm({

<div
className={cn({
hidden: !userHasL1Balance || !isDeposit,
hidden: !userHasL1Balance || !isDeposit || !l1Token?.address,
})}
>
<BridgePrompt
baseToken={baseToken}
formattedL1Balance={formattedL1Balance}
token={l1Token}
/>
</div>

Expand Down
8 changes: 7 additions & 1 deletion components/dialogs/transfer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ export function isMaxBalance({
}
}

export function constructArbitrumBridgeUrl(amount: string) {
export function constructArbitrumBridgeUrl(
amount: string,
mint?: `0x${string}`,
) {
const base = new URL("https://bridge.arbitrum.io/")
base.searchParams.set("amount", amount)
base.searchParams.set("destinationChain", "arbitrum-one")
base.searchParams.set("sourceChain", "ethereum")
if (mint) {
base.searchParams.set("token", mint)
}

return base.toString()
}
2 changes: 1 addition & 1 deletion components/dialogs/transfer/usdc-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ export function USDCForm({
})}
>
<BridgePrompt
baseToken={baseToken}
formattedL1Balance={formattedL1Balance}
token={l1Token}
/>
</div>

Expand Down
2 changes: 1 addition & 1 deletion components/dialogs/transfer/weth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,8 @@ export function WETHForm({
})}
>
<BridgePrompt
baseToken={baseToken}
formattedL1Balance={formattedL1Balance}
token={l1Token}
/>
</div>

Expand Down

0 comments on commit 2d10b0d

Please sign in to comment.