Skip to content

Commit

Permalink
Adapt front-end for ERC-20
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed May 16, 2024
1 parent 21dc556 commit 84c6772
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion frontend/src/app/bounty/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "@mantine/core";
import { DateInput } from "@mantine/dates";
import { FileWithPath } from "@mantine/dropzone";
import { Address, isAddress } from "viem";

import { useInputBoxAddInput } from "../../../hooks/contracts";
import { useWaitForTransaction } from "wagmi";
Expand Down Expand Up @@ -52,6 +53,7 @@ const CreateBountyPage: FC = () => {
const [name, setName] = useState<string>();
const [description, setDescription] = useState<string>();
const [imgLink, setImgLink] = useState<string>();
const [token, setToken] = useState<Address>();
const [filename, setFilename] = useState<string>();
const [minDeadline, setMinDeadline] = useState<Date>();
const [deadline, setDeadline] = useState<Date>();
Expand Down Expand Up @@ -90,6 +92,7 @@ const CreateBountyPage: FC = () => {
imgLink,
deadline: (deadline ?? new Date()).getTime() / 1000,
codeZipBinary: appFile ?? "",
token: token ?? "0x0000000000000000000000000000000000000000",
};

const config = usePrepareCreateBounty(bounty);
Expand Down Expand Up @@ -127,6 +130,19 @@ const CreateBountyPage: FC = () => {
placeholder="https://"
onChange={(e) => setImgLink(e.target.value)}
/>
<TextInput
withAsterisk
size="lg"
label="Token address"
value={token}
placeholder="0x"
onChange={(e) => {
const newToken = e.target.value;
if (isAddress(newToken)) {
setToken(newToken);
}
}}
/>

<DateInput
withAsterisk
Expand Down Expand Up @@ -166,7 +182,9 @@ const CreateBountyPage: FC = () => {
!name ||
name.trim().length === 0 ||
!description ||
description.trim().length === 0
description.trim().length === 0 ||
!token ||
!isAddress(token)
}
>
{isLoading ? "Creating Bounty..." : "Create Bounty"}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/model/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Hex } from "viem";
import { Address, Hex } from "viem";

import { CompletionStatus } from "./__generated__/graphql";

Expand All @@ -8,6 +8,7 @@ export interface CreateAppBounty {
imgLink?: string;
deadline: number;
codeZipBinary: string;
token: Address;
}

export interface AddSponsorship {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/model/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface AppBounty {
description: string;
started: number;
deadline: number;
token: Address;
inputIndex: number;
sponsorships: Sponsorship[] | null;
exploit: Exploit | null;
Expand Down

0 comments on commit 84c6772

Please sign in to comment.