ability to customize destination address for DEX
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
de0000d6d5
commit
eef0031a4a
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.5.42",
|
"version": "0.5.43",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -55,6 +55,8 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
const [secondsToWait, setSecondsToWait] = useState(localStorage.getItem("dex-deadline") || "60");
|
const [secondsToWait, setSecondsToWait] = useState(localStorage.getItem("dex-deadline") || "60");
|
||||||
const [slippage, setSlippage] = useState(localStorage.getItem("dex-slippage") || "5");
|
const [slippage, setSlippage] = useState(localStorage.getItem("dex-slippage") || "5");
|
||||||
const [formatDecimals, setFormatDecimals] = useState(localStorage.getItem("dex-decimals") || "5");
|
const [formatDecimals, setFormatDecimals] = useState(localStorage.getItem("dex-decimals") || "5");
|
||||||
|
const [actualDestinationAddress, setActualDestinationAddress] = useState(localStorage.getItem("dex-destination"));
|
||||||
|
const [destinationAddress, setDestinationAddress] = useState(actualDestinationAddress);
|
||||||
|
|
||||||
const [tokenAddressTop, setTokenAddressTop] = useState(RESERVE_ADDRESSES[chainId]);
|
const [tokenAddressTop, setTokenAddressTop] = useState(RESERVE_ADDRESSES[chainId]);
|
||||||
const [tokenAddressBottom, setTokenAddressBottom] = useState(FTSO_ADDRESSES[chainId]);
|
const [tokenAddressBottom, setTokenAddressBottom] = useState(FTSO_ADDRESSES[chainId]);
|
||||||
@ -162,6 +164,24 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setDestinationAddressInner = (value) => {
|
||||||
|
const cleanedValue = value.trim();
|
||||||
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(cleanedValue);
|
||||||
|
if (isEvmAddress) {
|
||||||
|
localStorage.setItem("dex-destination", value);
|
||||||
|
setActualDestinationAddress(value);
|
||||||
|
} else if (!isEvmAddress && actualDestinationAddress) {
|
||||||
|
localStorage.removeItem("dex-destination");
|
||||||
|
setActualDestinationAddress(undefined);
|
||||||
|
}
|
||||||
|
setDestinationAddress(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCloseSetting = () => {
|
||||||
|
setDestinationAddress(undefined);
|
||||||
|
handleSettingsOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box height="calc(100vh - 43px)">
|
<Box height="calc(100vh - 43px)">
|
||||||
<Helmet>
|
<Helmet>
|
||||||
@ -203,7 +223,7 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
minHeight="200px"
|
minHeight="200px"
|
||||||
open={settingsOpen}
|
open={settingsOpen}
|
||||||
headerText={"Settings"}
|
headerText={"Settings"}
|
||||||
onClose={() => handleSettingsOpen(false)}
|
onClose={() => handleCloseSetting()}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<InputLabel htmlFor="slippage">Slippage</InputLabel>
|
<InputLabel htmlFor="slippage">Slippage</InputLabel>
|
||||||
@ -267,6 +287,31 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
<Box mt="32px">
|
||||||
|
<InputLabel htmlFor="recipient">
|
||||||
|
{`${actualDestinationAddress ? "Custom" : "Default"} destination address`}
|
||||||
|
</InputLabel>
|
||||||
|
<Box mt="8px">
|
||||||
|
<FormControl variant="outlined" color="primary" fullWidth>
|
||||||
|
<OutlinedInput
|
||||||
|
inputProps={{ "data-testid": "decimals-to-wait" }}
|
||||||
|
type="text"
|
||||||
|
id="destination-to-wait"
|
||||||
|
value={destinationAddress
|
||||||
|
? destinationAddress
|
||||||
|
: actualDestinationAddress ?? address
|
||||||
|
}
|
||||||
|
onChange={event => setDestinationAddressInner(event.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</Box>
|
||||||
|
<Box mt="8px">
|
||||||
|
<Typography variant="body2" color="textSecondary">
|
||||||
|
Recipient address of swapped assets and liquidity tokens
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<TokenModal
|
<TokenModal
|
||||||
@ -322,6 +367,7 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
dexAddresses={dexAddresses}
|
dexAddresses={dexAddresses}
|
||||||
connect={connect}
|
connect={connect}
|
||||||
slippage={slippage}
|
slippage={slippage}
|
||||||
|
destination={actualDestinationAddress ? actualDestinationAddress : address}
|
||||||
secondsToWait={secondsToWait}
|
secondsToWait={secondsToWait}
|
||||||
setTopTokenListOpen={setTopTokenListOpen}
|
setTopTokenListOpen={setTopTokenListOpen}
|
||||||
setBottomTokenListOpen={setBottomTokenListOpen}
|
setBottomTokenListOpen={setBottomTokenListOpen}
|
||||||
@ -338,6 +384,7 @@ const Dex = ({ chainId, address, connect }) => {
|
|||||||
dexAddresses={dexAddresses}
|
dexAddresses={dexAddresses}
|
||||||
connect={connect}
|
connect={connect}
|
||||||
slippage={slippage}
|
slippage={slippage}
|
||||||
|
destination={actualDestinationAddress ? actualDestinationAddress : address}
|
||||||
secondsToWait={secondsToWait}
|
secondsToWait={secondsToWait}
|
||||||
setTopTokenListOpen={setTopTokenListOpen}
|
setTopTokenListOpen={setTopTokenListOpen}
|
||||||
setBottomTokenListOpen={setBottomTokenListOpen}
|
setBottomTokenListOpen={setBottomTokenListOpen}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ const PoolContainer = ({
|
|||||||
dexAddresses,
|
dexAddresses,
|
||||||
connect,
|
connect,
|
||||||
slippage,
|
slippage,
|
||||||
|
destination,
|
||||||
secondsToWait,
|
secondsToWait,
|
||||||
setTopTokenListOpen,
|
setTopTokenListOpen,
|
||||||
setBottomTokenListOpen,
|
setBottomTokenListOpen,
|
||||||
@ -129,8 +130,6 @@ const PoolContainer = ({
|
|||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
|
|
||||||
const deadline = Math.floor(Date.now() / 1000) + secondsToWait;
|
const deadline = Math.floor(Date.now() / 1000) + secondsToWait;
|
||||||
const destination = address;
|
|
||||||
|
|
||||||
const shares = 100000;
|
const shares = 100000;
|
||||||
const one = BigInt(shares * 100);
|
const one = BigInt(shares * 100);
|
||||||
const floatSlippage = slippage === "" ? 0 : parseFloat(slippage);
|
const floatSlippage = slippage === "" ? 0 : parseFloat(slippage);
|
||||||
|
|||||||
@ -27,6 +27,7 @@ const SwapContainer = ({
|
|||||||
setTopTokenListOpen,
|
setTopTokenListOpen,
|
||||||
setBottomTokenListOpen,
|
setBottomTokenListOpen,
|
||||||
slippage,
|
slippage,
|
||||||
|
destination,
|
||||||
secondsToWait,
|
secondsToWait,
|
||||||
setIsSwap,
|
setIsSwap,
|
||||||
formatDecimals
|
formatDecimals
|
||||||
@ -108,8 +109,6 @@ const SwapContainer = ({
|
|||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
|
|
||||||
const deadline = Math.floor(Date.now() / 1000) + secondsToWait;
|
const deadline = Math.floor(Date.now() / 1000) + secondsToWait;
|
||||||
const destination = address;
|
|
||||||
|
|
||||||
const shares = 100000;
|
const shares = 100000;
|
||||||
const one = BigInt(shares * 100);
|
const one = BigInt(shares * 100);
|
||||||
const floatSlippage = slippage === "" ? 0 : parseFloat(slippage);
|
const floatSlippage = slippage === "" ? 0 : parseFloat(slippage);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user