Skip to content

Commit

Permalink
feat(evm): add 3rd party bridge superbridge (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Nov 13, 2024
1 parent a84a6f6 commit adcdb89
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 55 deletions.
6 changes: 1 addition & 5 deletions apps/evm/src/app/[lang]/(bridge)/bridge/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ const Bridge = ({ searchParams }: Props) => {
const initialChain = useMemo(() => {
const network = urlSearchParams.get('network');

if (!network) {
return L1_CHAIN;
}

if (network === 'bitcoin') {
if (!network || network === 'bitcoin') {
return 'BTC';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type BridgeFormProps = {
};

const allNetworks = [
L1_CHAIN,
'BTC',
L1_CHAIN,
ChainId.ARBITRUM_ONE,
ChainId.BASE,
ChainId.OP,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { ArrowTopRightOnSquare, Avatar, Card, Flex, Link, P } from '@gobob/ui';
import { Trans } from '@lingui/macro';

import { Meson } from './Meson';
import { Owl } from './Owl';
import { Relay } from './Relay';
import { Stargate } from './Stargate';
import { Superbridge } from './Superbridge';
import { Gas } from './Gas';
import { FBTC } from './FBTC';

import { TransactionDirection } from '@/types';

type ExternalBridges = 'stargate' | 'relay' | 'meson' | 'orbiter-finance' | 'owlto-finance';
type ExternalBridges =
| 'superbridge'
| 'relay'
| 'meson'
| 'orbiter-finance'
| 'owlto-finance'
| 'gas'
| 'free'
| 'fbtc';

// TODO: add missing links
const bridges: Record<
ExternalBridges,
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
icon: any | string;
href: string | { [TransactionDirection.L1_TO_L2]: string; [TransactionDirection.L2_TO_L1]: string };
name: string;
disabled: boolean;
}
> = {
stargate: {
href: 'https://stargate.finance/transfer',
icon: Stargate,
name: 'Stargate',
disabled: true
superbridge: {
href: 'https://superbridge.app/',
name: 'Superbridge',
icon: (props: any) => (
<Card background='light' padding='none' rounded='full'>
<Superbridge {...props} />
</Card>
),
disabled: false
},
relay: {
href: 'https://relay.link/bridge/bob/',
Expand Down Expand Up @@ -53,6 +67,28 @@ const bridges: Record<
icon: Owl,
name: 'Owlto Finance',
disabled: false
},
fbtc: {
icon: (props: any) => (
<Card background='light' padding='none' rounded='full'>
<FBTC {...props} />
</Card>
),
href: 'https://fbtc.com/bridge',
name: 'FBTC',
disabled: false
},
free: {
icon: 'https://raw.githubusercontent.com/CodeToFree/free-tunnel/refs/heads/main/public/free.png',
name: 'Free Tech',
disabled: false,
href: 'https://app.free.tech/?token=SolvBTC'
},
gas: {
icon: Gas,
name: 'Gas.zip',
disabled: false,
href: 'https://www.gas.zip/?chainIds=60808'
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex } from '@gobob/ui';
import { ChainId } from '@gobob/chains';
import { Flex } from '@gobob/ui';

import { ExternalBridgeCard, ExternalBridges } from './ExternalBridgeCard';

Expand All @@ -10,7 +10,16 @@ type ExternalBridgeFormProps = {
chain: ChainId | 'BTC';
};

const defaultBridges: ExternalBridges[] = ['meson', 'orbiter-finance', 'owlto-finance', 'relay', 'stargate'];
const defaultBridges: ExternalBridges[] = [
'meson',
'orbiter-finance',
'owlto-finance',
'gas',
'free',
'fbtc',
'relay',
'superbridge'
];

const availableBridges: Partial<Record<ChainId | 'BTC', ExternalBridges[]>> = {
[ChainId.MERLIN]: ['owlto-finance'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { forwardRef } from 'react';
import { Icon, IconProps } from '@gobob/ui';

const FBTC = forwardRef<SVGSVGElement, IconProps>((props, ref) => (
<Icon ref={ref} fill='none' viewBox='0 0 19 26' xmlns='http://www.w3.org/2000/svg' {...props}>
<g id='Group 1000005127'>
<g id='Group 1000005122'>
<g id='Group 1000005123'>
<path
clipRule='evenodd'
d='M15.1715 11.3193C15.1715 14.6115 12.5073 17.2803 9.22091 17.2803C5.93449 17.2803 3.27032 14.6115 3.27032 11.3193C3.27032 6.26915 9.07382 0 9.22091 0C9.368 0 15.1715 6.26915 15.1715 11.3193ZM12.7645 11.3199C12.7645 13.2804 11.1779 14.8697 9.22085 14.8697C7.26377 14.8697 5.67724 13.2804 5.67724 11.3199C5.67724 9.37778 7.23411 7.79994 9.1658 7.77047V11.4292C9.1658 11.4292 11.4109 10.5283 12.5074 9.99008C12.6732 10.4008 12.7645 10.8497 12.7645 11.3199Z'
fill='url(#paint0_linear_5712_9817)'
fillRule='evenodd'
id='Union'
/>
<path
d='M7.88465 20.8015L17.5227 19.768C17.6348 20.823 17.6083 21.8911 17.4426 22.9401L7.84506 22.3445C7.92606 21.8331 7.93979 21.3146 7.88465 20.8015Z'
fill='url(#paint1_linear_5712_9817)'
id='Vector'
/>
<path
d='M10.4109 17.9812L0.907334 19.892C1.1163 20.9321 1.46149 21.943 1.93368 22.8939L10.9107 19.4412C10.6803 18.9777 10.5119 18.4872 10.4109 17.9812Z'
fill='url(#paint2_linear_5712_9817)'
id='Vector_2'
/>
</g>
</g>
</g>
<defs>
<linearGradient
gradientUnits='userSpaceOnUse'
id='paint0_linear_5712_9817'
x1='9.15148'
x2='9.28563'
y1='0.358433'
y2='17.1782'
>
<stop stopColor='#FF05FF' />
<stop offset='0.56' stopColor='#8323FF' />
<stop offset='0.76' stopColor='#8F00FF' />
<stop offset='0.985' stopColor='#4E68FF' />
</linearGradient>
<linearGradient
gradientUnits='userSpaceOnUse'
id='paint1_linear_5712_9817'
x1='19.4997'
x2='9.74626'
y1='19.4999'
y2='22.2729'
>
<stop stopColor='#DFB6FF' />
<stop offset='0.49109' stopColor='#8F00FF' />
<stop offset='0.995' stopColor='#5263FF' />
</linearGradient>
<linearGradient
gradientUnits='userSpaceOnUse'
id='paint2_linear_5712_9817'
x1='9.74978'
x2='-0.92694'
y1='19.4998'
y2='20.4469'
>
<stop offset='0.015' stopColor='#5066FF' />
<stop offset='0.538411' stopColor='#8F00FF' />
<stop offset='1' stopColor='#DFB6FF' />
</linearGradient>
</defs>
</Icon>
));

FBTC.displayName = 'FBTC';

export { FBTC };
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { forwardRef } from 'react';
import { Icon, IconProps } from '@gobob/ui';

const Gas = forwardRef<SVGSVGElement, IconProps>((props, ref) => (
<Icon ref={ref} fill='none' viewBox='0 0 2000 2000' xmlns='http://www.w3.org/2000/svg' {...props}>
<rect fill='#3A6EA5' height='2000' rx='1000' width='2000' />
<path
d='M1022.83 849.212L801.217 1189.58L1000.37 1189.77L978.028 1416.81L1199.64 1076.44L1000.48 1076.25L1022.83 849.212Z'
stroke='white'
strokeLinecap='round'
strokeLinejoin='round'
strokeWidth='35'
/>
<path
d='M1416.67 724.304C1396.08 714.058 1406.37 744.797 1416.67 724.304C1375 707.132 1416.67 778.301 1416.67 724.304C1416.37 724.888 1416.67 747.166 1416.67 724.304C1416.67 747.166 1393.7 724.304 1416.67 724.304V471.281C1416.67 379.812 1343.89 306 1251.99 306H751.99C660.091 306 583.333 379.812 583.333 471.281V1399.5L523.031 1429.51C508.911 1436.54 500 1450.89 500 1466.61V1591.02C500 1613.93 520.646 1633.1 543.656 1633.1H1460.32C1483.33 1633.1 1500 1613.93 1500 1591.02V1466.61C1500 1450.89 1491.09 1436.54 1476.97 1429.51L1416.67 1399.5V724.304C1416.67 670.308 1416.67 697.943 1416.67 724.304C1416.67 792.912 1415.59 717.404 1416.67 724.304ZM1416.67 1550.16H583.333V1492.24L643.635 1462.23C657.755 1455.21 666.667 1440.85 666.667 1425.13V471.279C666.667 425.535 706.029 388.944 751.99 388.944H1251.99C1297.95 388.944 1333.33 425.535 1333.33 471.281V1425.14C1333.33 1440.85 1342.24 1455.21 1356.36 1462.24L1416.67 1492.24V1550.16Z'
fill='white'
/>
<mask fill='white' id='path-4-inside-1_1_21'>
<path d='M743 527C743 499.386 765.386 477 793 477H1207C1234.61 477 1257 499.386 1257 527V702C1257 729.614 1234.61 752 1207 752H793C765.386 752 743 729.614 743 702V527Z' />
</mask>
<path
d='M683 527C683 474.533 725.533 432 778 432H1222C1274.47 432 1317 474.533 1317 527H1197C1197 524.239 1197 522 1197 522H803C803 522 803 524.239 803 527H683ZM1317 702C1317 754.467 1274.47 797 1222 797H778C725.533 797 683 754.467 683 702H803C803 704.761 803 707 803 707H1197C1197 707 1197 704.761 1197 702H1317ZM778 797C725.533 797 683 754.467 683 702V527C683 474.533 725.533 432 778 432L803 522C803 522 803 524.239 803 527V702C803 704.761 803 707 803 707L778 797ZM1222 432C1274.47 432 1317 474.533 1317 527V702C1317 754.467 1274.47 797 1222 797L1197 707C1197 707 1197 704.761 1197 702V527C1197 524.239 1197 522 1197 522L1222 432Z'
fill='white'
mask='url(#path-4-inside-1_1_21)'
/>
</Icon>
));

Gas.displayName = 'Gas';

export { Gas };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { forwardRef } from 'react';
import { Icon, IconProps } from '@gobob/ui';

const Superbridge = forwardRef<SVGSVGElement, IconProps>((props, ref) => (
<Icon ref={ref} fill='none' viewBox='0 0 57 40' xmlns='http://www.w3.org/2000/svg' {...props}>
<path
d='M19.06 29.97L12.66 22.73C11.92 21.89 11 20.41 11 18.79C11 17.17 11.93 15.69 12.66 14.85L16.27 10.77C17.65 9.22005 19.23 8.30005 20.97 8.30005C22.35 8.30005 23.53 8.79005 24.42 9.60005C25.43 10.53 26.06 11.85 26.14 13.28H28.27C28.35 10.66 30.39 8.30005 33.46 8.30005C35.2 8.30005 36.78 9.22005 38.16 10.77L44.83 18.33C45.68 19.29 46.62 20.64 46.62 22.25C46.62 23.74 45.66 25.1 44.96 25.89L41.35 29.97C39.97 31.52 38.39 32.44 36.65 32.44C35.02 32.44 32.82 31.51 31.91 29.06C30.88 28.76 30.14 28.29 29.35 27.37C29.27 30.14 27.23 32.4501 24.16 32.4501C22.26 32.4501 20.49 31.6 19.07 29.98L19.06 29.97ZM13.84 21.68L17.45 25.76C18.57 27.02 19.74 27.69 20.96 27.69C23.17 27.69 24.57 26.01 24.57 24.18C24.57 23.03 23.86 22.49 22.97 21.87C22.76 21.73 22.61 21.47 22.61 21.21C22.61 20.78 22.96 20.42 23.38 20.42C23.55 20.42 23.74 20.48 23.97 20.63C24.65 21.04 25.54 21.94 25.88 22.72H28.54C28.89 21.95 29.77 21.04 30.45 20.63C30.67 20.49 30.86 20.42 31.04 20.42C31.47 20.42 31.81 20.78 31.81 21.21C31.81 21.48 31.65 21.73 31.45 21.87C30.56 22.49 29.85 23.02 29.85 24.18C29.85 26.01 31.24 27.69 33.46 27.69C34.68 27.69 35.85 27.03 36.97 25.76L40.58 21.68C41.17 21.02 41.84 19.88 41.84 18.79C41.84 17.7 41.16 16.56 40.58 15.9L36.97 11.82C35.85 10.56 34.68 9.89005 33.46 9.89005C31.25 9.89005 29.85 11.57 29.85 13.4C29.85 14.55 30.56 15.09 31.45 15.71C31.66 15.85 31.81 16.11 31.81 16.37C31.81 16.8 31.46 17.16 31.04 17.16C30.87 17.16 30.68 17.1 30.45 16.95C29.77 16.54 28.88 15.64 28.54 14.86H25.88C25.53 15.63 24.65 16.54 23.97 16.95C23.75 17.09 23.56 17.16 23.38 17.16C22.95 17.16 22.61 16.8 22.61 16.37C22.61 16.1 22.77 15.85 22.97 15.71C23.86 15.09 24.57 14.56 24.57 13.4C24.57 11.57 23.18 9.89005 20.96 9.89005C19.74 9.89005 18.57 10.55 17.45 11.82L13.84 15.9C13.25 16.56 12.58 17.7 12.58 18.79C12.58 19.88 13.26 21.02 13.84 21.68ZM16.86 14.3L18.52 12.45C18.87 12.07 19.39 12.01 19.72 12.32C20.07 12.6 20 13.13 19.72 13.46L18.06 15.34C17.73 15.7 17.19 15.74 16.86 15.45C16.51 15.15 16.58 14.61 16.86 14.3ZM32.58 11.26C32.69 11.21 32.82 11.2 32.93 11.18C33.45 11.15 33.83 11.48 33.85 11.97C33.87 12.33 33.61 12.67 33.25 12.74C33.04 12.77 32.98 12.88 32.95 13.07C32.92 13.42 32.6 13.69 32.22 13.7C31.75 13.72 31.4 13.37 31.38 12.89C31.38 12.12 31.9 11.48 32.58 11.25V11.26Z'
fill='#242327'
/>
</Icon>
));

Superbridge.displayName = 'Superbridge';

export { Superbridge };

0 comments on commit adcdb89

Please sign in to comment.