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

Chore/fix lint errors #291

Merged
merged 3 commits into from
Mar 14, 2023
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: 7 additions & 3 deletions src/components/swap/parts/FirstTimeWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useEffect, useState } from "react";
import { useLocalStorage } from "usehooks-ts";

import { makeAccessibleKeysHandler } from "~/utils/react";

export const FirstTimeWarning = () => {
const [hasMounted, setHasMounted] = useState(false);
const [showFirstTimeWarning, setShowFirstTimeWarning] = useLocalStorage(
Expand All @@ -20,12 +22,12 @@ export const FirstTimeWarning = () => {
return (
<div className="fixed z-50 w-full max-w-screen-md bottom-10 left-10">
<div className="relative block w-7/12 p-4 shadow-lg alert bg-base-100/50 backdrop-blur-lg">
<label
<button
className="absolute btn btn-sm btn-circle right-2 top-2"
onClick={() => setShowFirstTimeWarning(false)}
>
</label>
</button>
<div>
<div>
<h3 className="mb-2 text-lg font-bold">New to Satellite?</h3>
Expand All @@ -41,7 +43,9 @@ export const FirstTimeWarning = () => {
href="https://testnet.satellite.money"
rel="noopener noreferrer"
target="_blank"
onClick={() => setShowFirstTimeWarning(false)}
{...makeAccessibleKeysHandler(
setShowFirstTimeWarning.bind(null, false)
)}
>
Go to testnet
</a>
Expand Down
18 changes: 14 additions & 4 deletions src/components/swap/parts/GenerateDepositAddressButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import BigNumber from "bignumber.js";
import { pick } from "rambda";
import toast from "react-hot-toast";

import { ENVIRONMENT, RESERVED_ADDRESSES } from "~/config/constants";
Expand Down Expand Up @@ -31,7 +32,16 @@ export const GenerateDepositAddressButton: React.FC<Props> = ({
asset,
setSwapStatus,
tokensToTransfer,
} = useSwapStore((state) => state);
} = useSwapStore(
pick([
"srcChain",
"destChain",
"destAddress",
"asset",
"setSwapStatus",
"tokensToTransfer",
])
);

const reservedAddresses = useSwapStore(getReservedAddresses);
const selectedAssetSymbol = useSwapStore(getSelectedAssetSymbol);
Expand All @@ -49,7 +59,7 @@ export const GenerateDepositAddressButton: React.FC<Props> = ({
}

async function handleOnGenerateDepositAddress() {
if ((srcChain as any).id === "terra") {
if (srcChain.id === "terra") {
return toast.error(
"Only the transfers to Terra Classic are allowed for uluna and uusd"
);
Expand Down Expand Up @@ -132,13 +142,13 @@ export const GenerateDepositAddressButton: React.FC<Props> = ({
}

return (
<div
<button
className="w-full btn btn-primary"
onClick={handleOnGenerateDepositAddress}
>
<div className="flex items-center gap-3">
<span>Generate Deposit Address</span>
</div>
</div>
</button>
);
};
6 changes: 3 additions & 3 deletions src/components/swap/parts/StopButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export const StopButton = () => {
}

return (
<div
onClick={handleOnClick}
<button
className="relative tooltip px-2 py-1 rounded-lg border border-[#00a7ff] bg-[#003556] text-[#00a7ff] text-xs cursor-pointer font-semibold"
data-tip="Refresh and make another transfer"
onClick={handleOnClick}
>
Start Over
</div>
</button>
);
};
24 changes: 10 additions & 14 deletions src/components/swap/parts/TopFlows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSwapStore } from "~/store";

import { AssetConfigExtended } from "~/types";
import { SwapStatus } from "~/utils/enums";
import { makeAccessibleKeysHandler } from "~/utils/react";

export const Arrow = () => (
<svg
Expand Down Expand Up @@ -47,16 +48,12 @@ export const TopFlows = () => {
swapStatus,
} = useSwapStore();
const [menuOpened, setMenuOpened] = useState(false);
const menu = useRef(null);
const menu = useRef<HTMLDivElement>(null);

useEffect(() => {
const el = document;
if (!menuOpened) {
(el?.activeElement as any)?.blur();
} else if (
menuOpened &&
!(menu?.current as any)?.contains(el.activeElement)
) {
(document?.activeElement as HTMLElement)?.blur();
} else if (menuOpened && !menu?.current?.contains(document.activeElement)) {
setMenuOpened(false);
}
}, [menuOpened]);
Expand Down Expand Up @@ -135,22 +132,21 @@ export const TopFlows = () => {

return (
<div ref={menu} className="dropdown dropdown-end">
<label
tabIndex={0}
<button
onBlur={(e) => setMenuOpened(false)}
className="px-3 py-1 rounded-lg border border-[#00a7ff] bg-[#003556] text-[#00a7ff] text-xs cursor-pointer font-semibold"
onClick={(e) => setMenuOpened(menuOpened)}
>
Top Flows
</label>
</button>
<ul
tabIndex={0}
className="z-50 p-2 shadow-lg gap-y-2 dropdown-content menu bg-neutral rounded-box w-52 top-8"
onFocus={(e) => setMenuOpened(true)}
>
<li
onClick={handleOnFlow0}
className="border rounded-lg border-[#00b0f4]"
{...makeAccessibleKeysHandler(handleOnFlow0)}
>
<div className="flex">
<Image
Expand Down Expand Up @@ -179,8 +175,8 @@ export const TopFlows = () => {
</div>
</li>
<li
onClick={handleOnFlow1}
className="border rounded-lg border-[#00b0f4]"
{...makeAccessibleKeysHandler(handleOnFlow1)}
>
<div className="flex">
<Image
Expand Down Expand Up @@ -209,8 +205,8 @@ export const TopFlows = () => {
</div>
</li>
<li
onClick={handleOnFlow2}
className="border rounded-lg border-[#00b0f4]"
{...makeAccessibleKeysHandler(handleOnFlow2)}
>
<div className="flex">
<Image
Expand Down Expand Up @@ -240,8 +236,8 @@ export const TopFlows = () => {
</li>

<li
onClick={handleOnFlow3}
className="border rounded-lg border-[#00b0f4]"
{...makeAccessibleKeysHandler(handleOnFlow3)}
>
<div className="flex">
<Image
Expand Down
53 changes: 27 additions & 26 deletions src/components/swap/parts/TransferStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ export const TransferStats = () => {
}

function renderDepositAddress() {
if (swapStatus === SwapStatus.IDLE) return null;
if (!depositAddress) return null;
if (swapStatus === SwapStatus.IDLE) {
return null;
}
if (!depositAddress) {
return null;
}
const showDepositAddress = showDepositAddressCondition({ srcChain, asset });
return (
<li className="flex justify-between">
Expand All @@ -110,19 +114,19 @@ export const TransferStats = () => {
>
Axelar Deposit Address:
</span>
<div className="flex font-bold gap-x-2">
<AddressShortener value={depositAddress} />
<div
className="cursor-pointer"
onClick={() =>
showDepositAddress && copyToClipboard(depositAddress)
}
>
{showDepositAddress && (
<Image src={"/assets/ui/copy.svg"} height={16} width={16} />
)}
{showDepositAddress && (
<div className="flex font-bold gap-x-2">
<AddressShortener value={depositAddress} />
<button onClick={copyToClipboard.bind(null, depositAddress)}>
<Image
src={"/assets/ui/copy.svg"}
height={16}
width={16}
alt="copy icon"
/>
</button>
</div>
</div>
)}
</li>
);
}
Expand Down Expand Up @@ -159,17 +163,17 @@ export const TransferStats = () => {

<span className="flex font-bold gap-x-2">
<AddressShortener value={intermediaryDepositAddress} />
<div
<button
className="cursor-pointer"
onClick={() => copyToClipboard(intermediaryDepositAddress)}
onClick={copyToClipboard.bind(null, intermediaryDepositAddress)}
>
<Image
src={"/assets/ui/copy.svg"}
height={16}
width={16}
alt="copy"
/>
</div>
</button>
</span>
</li>
);
Expand All @@ -181,21 +185,18 @@ export const TransferStats = () => {
}
return (
<li className="flex justify-between">
<span>Destination Address:</span>
<span className="flex font-bold gap-x-2">
<label>Destination Address:</label>
<div className="flex font-bold gap-x-2">
<AddressShortener value={destAddress} />
<div
className="cursor-pointer"
onClick={() => copyToClipboard(destAddress)}
>
<button onClick={copyToClipboard.bind(null, destAddress)}>
<Image
src={"/assets/ui/copy.svg"}
height={16}
width={16}
alt="copy"
/>
</div>
</span>
</button>
</div>
</li>
);
}
Expand Down Expand Up @@ -240,7 +241,7 @@ export const TransferStats = () => {
}

function renderPoolInfo() {
if ((asset as any)?.id === "uusdc") {
if (asset?.id === "uusdc") {
const chainName = destChain?.chainName?.toLowerCase();
const pool = USDC_POOLS[chainName];
const pair = pool?.pairs[0];
Expand Down
20 changes: 10 additions & 10 deletions src/components/swap/states/WaitDepositState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ export const WaitDepositState = () => {
</label>
<div className="flex justify-center font-bold text-info gap-x-2">
<AddressShortener value={depositAddress} />
<div
className="cursor-pointer"
onClick={() =>
showDepositAddress && copyToClipboard(depositAddress)
}
>
{" "}
{showDepositAddress && (
{showDepositAddress && (
<button
className="cursor-pointer"
onClick={() =>
showDepositAddress && copyToClipboard(depositAddress)
}
>
<Image
src={"/assets/ui/copy.svg"}
height={16}
width={16}
alt="copy icon"
/>
)}
</div>
</button>
)}
</div>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/features/dest-asset-selector/components/GMPEToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ export const GMPEToggle = () => {
const { isSquidTrade, setEnableGMPExpress, enableGMPExpress } =
useSquidStateStore();

if (!isSquidTrade) return null;
if (!isSquidTrade) {
return null;
}
return (
<div
onClick={() => setEnableGMPExpress(!enableGMPExpress)}
className="flex items-center justify-between text-left gap-x-2 btn btn-info btn-xs"
>
<p className="text-xs text-accent">GMP Express</p>
<label className="flex items-center justify-between text-left gap-x-2 btn btn-info btn-xs">
<span className="text-xs text-accent">GMP Express</span>
<input
type="checkbox"
checked={enableGMPExpress}
className="checkbox checkbox-xs"
onChange={setEnableGMPExpress.bind(null, !enableGMPExpress)}
/>
</div>
</label>
);
};
10 changes: 3 additions & 7 deletions src/features/dest-chain-selector/DestChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Image from "next/legacy/image";
import { ChainInfo } from "@axelar-network/axelarjs-sdk";
import { useOnClickOutside } from "usehooks-ts";

import { defaultChainImg } from "~/config/constants";
import { InputWrapper } from "~/components/common";

import { ChainsDropdown } from "~/features/dest-chain-selector/ChainsDropdown";
import { useChainFilter } from "~/features/dest-chain-selector/hooks";

import { useSwapStore } from "~/store";

import { defaultChainImg } from "~/config/constants";
import { convertChainName } from "~/utils/transformers";

// TODO: abstract the state into a zustand destChainStore
Expand Down Expand Up @@ -49,11 +49,7 @@ export const DestChainSelector = () => {
<div ref={ref}>
<label className="block text-xs">To</label>
<div className="static w-full mt-1 dropdown dropdown-open">
<div
className="w-full"
tabIndex={0}
onClick={() => setDropdownOpen(true)}
>
<button className="w-full" onClick={() => setDropdownOpen(true)}>
<div className="flex items-center justify-between space-x-2 text-lg font-medium cursor-pointer">
<div className="flex items-center gap-x-2">
<Image
Expand Down Expand Up @@ -83,7 +79,7 @@ export const DestChainSelector = () => {
/>
</div>
</div>
</div>
</button>
<ChainsDropdown
dropdownOpen={dropdownOpen}
filteredChains={filteredChains}
Expand Down
Loading