Skip to content

Commit

Permalink
🥢 mainnet token preview
Browse files Browse the repository at this point in the history
  • Loading branch information
nerderlyne committed Aug 13, 2024
1 parent 7156e84 commit 64ff92b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
17 changes: 0 additions & 17 deletions ui/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ body {
font-style: normal;
}

.command-prompt-input {
caret-color: white;
caret-shape: block;
background-color: black;
}

.command-prompt-input:focus {
outline: none;
}

.command-prompt-input::after {
content: '|';
animation: blink-animation 1s infinite;
display: inline-block;
margin-left: -1px;
}

@keyframes blink-animation {
50% {
opacity: 0;
Expand Down
Binary file modified ui/bun.lockb
Binary file not shown.
19 changes: 10 additions & 9 deletions ui/components/shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { ShellHistory } from "./shell-history";
import { cn } from "@/lib/utils";
import { IntentsEngineAbi } from "@/lib/abi/IntentsEngineAbi";
import { IntentsEngineAbiArb } from "@/lib/abi/IntentsEngineAbiArb";
import { IntentsEngineAbiOp} from "@/lib/abi/IntentsEngineAbiOp";
import { IntentsEngineAbiBase} from "@/lib/abi/IntentsEngineAbiBase";
import { IntentsEngineAbiOp } from "@/lib/abi/IntentsEngineAbiOp";
import { IntentsEngineAbiBase } from "@/lib/abi/IntentsEngineAbiBase";

const formSchema = z.object({
command: z.string().min(2),
Expand Down Expand Up @@ -109,20 +109,22 @@ export const Shell = () => {

addLine(<p>Preview: {serialize(preview)}</p>);

if (isAddressEqual(preview[2], zeroAddress)) {
const token = preview[3];

if (isAddressEqual(token, zeroAddress)) {
// invalid token
throw new Error(
"This token is not supported by the Intents Engine. Did you misspell the token symbol?",
);
}

if (isAddressEqual(preview[2], ETH_ADDRESS)) {
if (isAddressEqual(token, ETH_ADDRESS)) {
// sending ether directly
value = preview[1];
} else {
// consent to spend tokens
const allowance = await client.readContract({
address: preview[2],
address: token,
abi: erc20Abi,
functionName: "allowance",
args: [address, ieAddress],
Expand All @@ -131,7 +133,7 @@ export const Shell = () => {
if (allowance < preview[1]) {
// we do a lil approve dance
const approveTxHash = await writeContractAsync({
address: preview[2],
address: token,
abi: erc20Abi,
functionName: "approve",
args: [ieAddress, maxUint256],
Expand Down Expand Up @@ -521,7 +523,7 @@ export const Shell = () => {
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="mb-2 w-screen flex flex-row"
className="mb-2 flex flex-row"
>
<FormField
control={form.control}
Expand All @@ -532,8 +534,7 @@ export const Shell = () => {
<FormControl>
<input
className={cn(
"command-prompt-input",
" min-w-3/4 focus:outline-none w-full",
"bg-black min-w-3/4 focus:outline-none w-full",
)}
{...field}
/>
Expand Down

0 comments on commit 64ff92b

Please sign in to comment.