-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: IBC Swaps using Squid Router (#1208)
* wip: ibc swaps ui * wip: ibc swaps integration * wip: ibc swap * wip * fetch balances * wip * wip * wip * wip * feat: integrate execute route * add loading state for swap txn * chore: fix lint issues * swap with squid: wip * wip * fix: executeRoute * wip: ibc swap * add validations * track tx status * add retry for stargate client * chore: add exp suggest chain * wip * chore * chore: review changes * feat: add swap route preview * chore: review changes * chore: refactor * refactor
- Loading branch information
1 parent
7c88798
commit 4f4aef2
Showing
29 changed files
with
2,791 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions
112
frontend/src/app/(routes)/transfers/components/AssetsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import React from 'react'; | ||
import TextField from '@mui/material/TextField'; | ||
import Autocomplete from '@mui/material/Autocomplete'; | ||
import Avatar from '@mui/material/Avatar'; | ||
import { CircularProgress, Paper } from '@mui/material'; | ||
import { shortenName } from '@/utils/util'; | ||
import { AssetConfig } from '@/types/swaps'; | ||
|
||
export default function AssetsAutocomplete({ | ||
options, | ||
handleChange, | ||
selectedAsset, | ||
assetsLoading, | ||
}: { | ||
options: AssetConfig[]; | ||
handleChange: (option: AssetConfig | null) => void; | ||
selectedAsset: AssetConfig | null; | ||
assetsLoading: boolean; | ||
}) { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const renderOption = (props: any, option: AssetConfig) => ( | ||
<li {...props} key={option.symbol + option.logoURI + option.denom}> | ||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}> | ||
<Avatar | ||
src={option.logoURI} | ||
alt={option.label} | ||
sx={{ width: '24px', height: '24px' }} | ||
/> | ||
<div className="flex flex-col"> | ||
<span className="font-semibold truncate"> | ||
{shortenName(option.symbol, 15)} | ||
</span> | ||
<span className="font-extralight truncate text-[12px]"> | ||
{shortenName(option.name, 20)} | ||
</span> | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const renderInput = (params: any) => ( | ||
<TextField | ||
className="bg-[#171328] rounded-2xl drop-down" | ||
placeholder="Select Asset" | ||
{...params} | ||
InputProps={{ | ||
...params.InputProps, | ||
startAdornment: ( | ||
<React.Fragment> | ||
{selectedAsset && ( | ||
<Avatar | ||
src={selectedAsset.logoURI} | ||
alt={selectedAsset.label} | ||
style={{ marginRight: 1 }} | ||
sx={{ width: '24px', height: '24px' }} | ||
/> | ||
)} | ||
{params.InputProps.startAdornment} | ||
</React.Fragment> | ||
), | ||
}} | ||
sx={{ | ||
'& .MuiInputBase-input': { | ||
color: 'white', | ||
fontSize: '16px', | ||
fontWeight: 300, | ||
fontFamily: 'inter', | ||
}, | ||
'& .MuiOutlinedInput-notchedOutline': { | ||
border: 'none', | ||
}, | ||
'& .MuiSvgIcon-root': { | ||
color: 'white', | ||
}, | ||
}} | ||
/> | ||
); | ||
|
||
return ( | ||
<Autocomplete | ||
disablePortal | ||
fullWidth | ||
id="chain-autocomplete" | ||
options={options} | ||
getOptionLabel={(option: AssetConfig) => option.symbol} | ||
renderOption={renderOption} | ||
renderInput={renderInput} | ||
onChange={(_, newValue) => handleChange(newValue)} | ||
value={selectedAsset} | ||
PaperComponent={({ children }) => ( | ||
<Paper | ||
style={{ | ||
background: | ||
'linear-gradient(178deg, #241B61 1.71%, #69448D 98.35%, #69448D 98.35%)', | ||
color: 'white', | ||
borderRadius: '12px', | ||
padding: 1, | ||
}} | ||
> | ||
{assetsLoading ? ( | ||
<div className="flex justify-center items-center p-4"> | ||
<CircularProgress color="inherit" size={20} /> | ||
</div> | ||
) : ( | ||
children | ||
)} | ||
</Paper> | ||
)} | ||
/> | ||
); | ||
} |
121 changes: 121 additions & 0 deletions
121
frontend/src/app/(routes)/transfers/components/ChainsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React from 'react'; | ||
import TextField from '@mui/material/TextField'; | ||
import Autocomplete from '@mui/material/Autocomplete'; | ||
import Avatar from '@mui/material/Avatar'; | ||
import { CircularProgress, Paper } from '@mui/material'; | ||
import { shortenName } from '@/utils/util'; | ||
import { ChainConfig } from '@/types/swaps'; | ||
|
||
interface ChainOption { | ||
label: string; | ||
chainID: string; | ||
logoURI: string; | ||
} | ||
|
||
export default function ChainsList({ | ||
options, | ||
handleChange, | ||
selectedChain, | ||
dataLoading, | ||
}: { | ||
options: ChainConfig[]; | ||
handleChange: (option: ChainOption | null) => void; | ||
selectedChain: ChainConfig | null; | ||
dataLoading: boolean; | ||
}) { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const renderOption = (props: any, option: ChainOption) => ( | ||
<li {...props} key={option.chainID}> | ||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}> | ||
<Avatar | ||
src={option.logoURI} | ||
alt={option.label} | ||
sx={{ width: '24px', height: '24px' }} | ||
/> | ||
<div className="flex flex-col"> | ||
<span className="font-semibold truncate text-capitalize"> | ||
{shortenName(option.label, 15)} | ||
</span> | ||
<span className="font-extralight truncate text-[12px]"> | ||
{shortenName(option.chainID, 15)} | ||
</span> | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const renderInput = (params: any) => ( | ||
<TextField | ||
className="bg-[#171328] rounded-2xl drop-down" | ||
placeholder="Select Network" | ||
{...params} | ||
InputProps={{ | ||
...params.InputProps, | ||
startAdornment: ( | ||
<React.Fragment> | ||
{selectedChain && ( | ||
<Avatar | ||
src={selectedChain.logoURI} | ||
alt={selectedChain.label} | ||
style={{ marginRight: 1 }} | ||
sx={{ width: '24px', height: '24px' }} | ||
/> | ||
)} | ||
{params.InputProps.startAdornment} | ||
</React.Fragment> | ||
), | ||
}} | ||
sx={{ | ||
'& .MuiInputBase-input': { | ||
color: 'white', | ||
fontSize: '16px', | ||
fontWeight: 300, | ||
fontFamily: 'inter', | ||
textTransform: 'capitalize', | ||
}, | ||
'& .MuiOutlinedInput-notchedOutline': { | ||
border: 'none', | ||
}, | ||
'& .MuiSvgIcon-root': { | ||
color: 'white', | ||
}, | ||
}} | ||
/> | ||
); | ||
|
||
return ( | ||
<div> | ||
<Autocomplete | ||
disablePortal | ||
fullWidth | ||
id="chain-autocomplete" | ||
options={options} | ||
getOptionLabel={(option: ChainOption) => option.label} | ||
renderOption={renderOption} | ||
renderInput={renderInput} | ||
onChange={(_, newValue) => handleChange(newValue)} | ||
value={selectedChain} | ||
PaperComponent={({ children }) => ( | ||
<Paper | ||
style={{ | ||
background: | ||
'linear-gradient(178deg, #241B61 1.71%, #69448D 98.35%, #69448D 98.35%)', | ||
color: 'white', | ||
borderRadius: '12px', | ||
padding: 1, | ||
}} | ||
> | ||
{dataLoading ? ( | ||
<div className="flex justify-center items-center p-4"> | ||
<CircularProgress color="inherit" size={20} /> | ||
</div> | ||
) : ( | ||
children | ||
)} | ||
</Paper> | ||
)} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.