Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Revert "remix v2; arbsepolia support; swap routing (#99)"
Browse files Browse the repository at this point in the history
This reverts commit 8a3b00d.
  • Loading branch information
alecananian committed Jan 17, 2024
1 parent 8a3b00d commit 07731b0
Show file tree
Hide file tree
Showing 72 changed files with 37,350 additions and 18,176 deletions.
7 changes: 4 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MAGICSWAP_API_URL=
VITE_ALCHEMY_KEY=
VITE_WALLETCONNECT_PROJECT_ID=
VITE_ENABLE_TESTNETS=true
PUBLIC_ALCHEMY_KEY=
PUBLIC_WALLETCONNECT_PROJECT_ID=
PUBLIC_ENABLE_TESTNETS=true
PUBLIC_NODE_ENV=development
43 changes: 21 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ on:
- develop
pull_request: {}
jobs:
# typecheck:
# name: Check Types
# runs-on: ubuntu-latest
# steps:
# - name: Cancel previous runs
# uses: styfle/[email protected]
# - name: Checkout repo
# uses: actions/checkout@v3
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18
# - name: Install dependencies
# run: npm ci
# - name: Generate code
# run: npm run codegen
# env:
# MAGICSWAP_API_URL: ${{ secrets.MAGICSWAP_API_URL }}
# - name: Check types
# run: npm run typecheck --if-present
typecheck:
name: Check Types
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Generate code
run: npm run codegen
env:
MAGICSWAP_API_URL: ${{ secrets.MAGICSWAP_API_URL }}
- name: Check types
run: npm run typecheck --if-present
build:
name: Build
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
Expand Down Expand Up @@ -81,8 +81,7 @@ jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
# needs: [typecheck, build]
needs: [build]
needs: [typecheck, build]
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
steps:
- name: Cancel previous runs
Expand Down
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion app/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Button = ({
className={twMerge(
"inline-flex w-full items-center justify-center rounded-button border border-transparent bg-ruby-900 px-6.5 py-3 text-sm font-semibold text-white shadow-sm ring-offset-ruby-800 focus:outline-none focus:ring-2 focus:ring-ruby-500 focus:ring-offset-2 sm:text-lg",
className,
isDisabled ? "opacity-50" : "hover:bg-ruby-1000",
isDisabled ? "opacity-50" : "hover:bg-ruby-1000"
)}
disabled={isDisabled}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Graph = ({
],
range: [10, width - 10],
}),
[data, width],
[data, width]
);

const yScale = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions app/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ export const GitHubIcon = createIcon({

export const TwitterIcon = createIcon({
path: (
<path d="M51.9789 0H62.0995L39.9891 24.9919L66 59H45.6335L29.6818 38.3743L11.4296 59H1.30333L24.9526 32.2686L0 0H20.8835L35.3023 18.8528L51.9789 0ZM48.4269 53.0089H54.0348L17.8364 5.67607H11.8186L48.4269 53.0089Z" />
<path d="M24.3998 3.31371C23.5156 3.70551 22.5658 3.97023 21.5672 4.08989C22.5975 3.47339 23.3683 2.50309 23.7358 1.36005C22.7678 1.93502 21.7084 2.33974 20.6036 2.5566C19.8607 1.76335 18.8766 1.23756 17.8042 1.06088C16.7319 0.884204 15.6311 1.06651 14.673 1.57951C13.7148 2.0925 12.9528 2.90748 12.5053 3.89791C12.0578 4.88834 11.9498 5.99881 12.1981 7.05692C10.2367 6.95843 8.3179 6.44863 6.56627 5.56059C4.81464 4.67256 3.2693 3.42613 2.03056 1.9022C1.607 2.63284 1.36346 3.47996 1.36346 4.38214C1.36298 5.19431 1.56299 5.99404 1.94572 6.71037C2.32846 7.42671 2.88209 8.0375 3.55749 8.48855C2.7742 8.46362 2.00819 8.25197 1.32322 7.87121V7.93474C1.32314 9.07384 1.71716 10.1779 2.43843 11.0595C3.1597 11.9412 4.16379 12.5462 5.28032 12.7718C4.55368 12.9684 3.79186 12.9974 3.0524 12.8565C3.36742 13.8366 3.98105 14.6937 4.80738 15.3078C5.63371 15.9218 6.63138 16.2621 7.66072 16.281C5.91336 17.6527 3.75539 18.3967 1.53394 18.3935C1.14043 18.3936 0.747259 18.3706 0.356445 18.3246C2.61134 19.7745 5.2362 20.5439 7.91697 20.5409C16.9917 20.5409 21.9527 13.0249 21.9527 6.50629C21.9527 6.29451 21.9474 6.08061 21.9378 5.86883C22.9028 5.17099 23.7357 4.30685 24.3976 3.31689L24.3998 3.31371Z" />
),
displayName: "TwitterIcon",
width: 66,
height: 59,
width: 25,
height: 21,
});
6 changes: 2 additions & 4 deletions app/components/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ export const NumberField = ({
sanitizedValue > 49
? "focus:border-ruby-500 focus:ring-ruby-500"
: "focus:border-night-500 focus:ring-night-500",
"block w-full rounded-md bg-night-800/60 text-sm focus:border-night-500",
"block w-full rounded-md bg-night-800/60 text-sm focus:border-night-500"
)}
placeholder={props.placeholder}
/>
{children}
</div>
</div>
{props.errorMessage && errorCondition(sanitizedValue) ? (
<p className="mt-2 text-sm text-ruby-600">
{props.errorMessage.toString()}
</p>
<p className="mt-2 text-sm text-ruby-600">{props.errorMessage}</p>
) : null}
</>
);
Expand Down
154 changes: 110 additions & 44 deletions app/components/PairTokenInput.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import { ClientOnly } from "remix-utils/client-only";
import type { BigNumber } from "@ethersproject/bignumber";
import { ArrowUpRightIcon } from "@heroicons/react/24/outline";
import { ChevronDownIcon } from "@heroicons/react/24/solid";
import { ClientOnly } from "remix-utils";

import { TokenLogo } from "./TokenLogo";
import { usePrice } from "~/context/priceContext";
import { useBlockExplorer } from "~/hooks/useBlockExplorer";
import type { Token } from "~/types";
import {
formatBigIntDisplay,
formatBigIntInput,
formatUsdLong,
formatBigNumberDisplay,
formatBigNumberInput,
formatUsdLong, // formatPercent
} from "~/utils/number";

type Props = {
id: string;
label: string;
token: Token;
balance: bigint;
balance: BigNumber;
value: string;
locked?: boolean;
onChange: (value: string) => void;
onTokenClick: () => void;
};
Expand All @@ -26,10 +30,12 @@ export default function PairTokenInput({
token,
balance,
value,
locked = false,
onChange,
onTokenClick,
}: Props) {
const { magicUsd } = usePrice();
const blockExplorer = useBlockExplorer();

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
let periodMatches = 0;
Expand All @@ -45,35 +51,20 @@ export default function PairTokenInput({
return (
<div className="group flex-1">
<div className="rounded-md border border-night-800/50 bg-[#131D2E] transition-colors group-hover:border-night-700/50">
<div className="border-b border-night-800/50 p-4 transition-colors group-hover:border-night-700/50 2xl:p-6">
<div className="border-b border-night-800/50 p-2 transition-colors group-hover:border-night-700/50 sm:p-4 2xl:p-6">
<label htmlFor={id} className="sr-only">
{label}
</label>
<div className="flex items-center justify-between gap-3 focus-within:border-ruby-600">
<button
className="flex shrink-0 items-center gap-2.5"
onClick={onTokenClick}
>
<TokenLogo token={token} className="h-10 w-10 rounded-full" />
<div className="text-left">
<p className="flex items-center gap-1 font-bold">
{token.symbol}
<ChevronDownIcon className="h-4 w-4" />
</p>
{token.symbol !== token.name ? (
<span className="text-sm text-night-300">{token.name}</span>
) : null}
</div>
</button>
<div className="grow text-right">
<input
id={id}
type="text"
className="w-full border-0 border-transparent bg-transparent p-0 text-right focus:ring-0 sm:text-lg lg:text-2xl"
placeholder="0.00"
value={value === "0" ? "" : value}
onChange={handleChange}
/>
<div className="relative focus-within:border-ruby-600">
<input
id={id}
type="text"
className="block w-full border-0 border-transparent bg-transparent pb-6 pr-12 focus:ring-0 sm:text-lg lg:text-2xl"
placeholder="0.00"
value={value === "0" ? "" : value}
onChange={handleChange}
/>
<div className="pointer-events-none absolute bottom-2 left-0 flex flex-col items-end pl-3">
<ClientOnly>
{() => (
<span className="text-xs text-night-500">
Expand All @@ -83,32 +74,107 @@ export default function PairTokenInput({
magicUsd *
(!parsedValue || Number.isNaN(parsedValue)
? 1
: parsedValue),
: parsedValue)
)}
</span>
)}
</ClientOnly>
</div>
<div className="absolute bottom-2 right-0 flex flex-col items-end pr-3">
<div className="relative mb-1 flex items-center space-x-1">
<p className="font-bold text-night-300 sm:text-sm">
{token.symbol}
</p>
{!locked && (
<>
<ChevronDownIcon className="h-4 w-4" />
<button
className="absolute inset-0 h-full w-full"
onClick={onTokenClick}
/>
</>
)}
</div>
<span
className="cursor-pointer text-xs text-night-500"
onClick={() =>
onChange(formatBigNumberInput(balance, token.decimals))
}
>
Balance: {formatBigNumberDisplay(balance, token.decimals)}
</span>
</div>
</div>
</div>
<div className="space-y-4 rounded-lg p-4">
<div className="space-y-4 rounded-lg p-4 2xl:p-6">
<div className="flex items-center justify-between">
<span
className="cursor-pointer text-sm text-night-300"
onClick={() =>
onChange(formatBigIntInput(balance, token.decimals))
}
<a
className="flex items-center gap-2"
href={`${blockExplorer}/token/${token.id}`}
title={`${token.symbol} (${token.id})`}
target="_blank"
rel="noopener noreferrer"
>
Balance:{" "}
<TokenLogo token={token} className="h-5 w-5 rounded-full" />
<span className="truncate text-xs font-bold sm:text-base">
{token.symbol}{" "}
{token.symbol.toLowerCase() !== token.name.toLowerCase() && (
<>({token.name})</>
)}
</span>
<ArrowUpRightIcon className="h-3 w-3" />
</a>
<div className="flex flex-col items-end sm:flex-row sm:items-baseline">
<ClientOnly>
{() => (
<span className="text-night-100">
{formatBigIntDisplay(balance, token.decimals)}
</span>
<p className="whitespace-nowrap text-xs font-normal text-night-300 sm:text-lg">
{formatUsdLong(token.priceMagic * magicUsd)} USD
</p>
)}
</ClientOnly>
</span>
{/* <p
className={twMerge(
"flex items-baseline text-[0.5rem] font-semibold sm:ml-1 sm:text-xs",
{
"text-ruby-900": !positive,
"text-green-600": positive,
}
)}
>
{positive ? (
<ArrowSmUpIcon
className="h-3 w-3 flex-shrink-0 self-center text-green-500 sm:h-4 sm:w-4"
aria-hidden="true"
/>
) : (
<ArrowSmDownIcon
className="h-3 w-3 flex-shrink-0 self-center text-ruby-500 sm:h-4 sm:w-4"
aria-hidden="true"
/>
)}
<span className="sr-only">
{positive ? "Increased by" : "Decreased by"}
</span>
{formatPercent(price24hChange)}
</p> */}
</div>
</div>
{/* {showPriceGraph ? (
<>
<div className="h-24 2xl:h-36">
<TimeIntervalLineGraph
gradient={{
from: positive ? "#96e4df" : "#ee9617",
to: positive ? "#21d190" : "#fe5858",
}}
data={token.price1wUsdIntervals}
/>
</div>
<p className="text-xs font-light text-night-500">
VOL {formatUsd(token.volume1wMagic)}
</p>
</>
) : null} */}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 07731b0

Please sign in to comment.