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

Merge to main to test domain #21

Merged
merged 11 commits into from
Feb 5, 2025
Merged
Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "scores-frame",
"name": "farcastle-proposals-frame",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -8,9 +8,9 @@
"clean": "rm -rf .next/cache",
"start": "next start",
"lint": "next lint",
"pages:build": "rm -rf .next && next build && rm -rf .next/cache",
"pages:deploy": "npx @cloudflare/next-on-pages deploy .next",
"preview": "bun run pages:build && wrangler pages dev"
"pages:build": "npx @cloudflare/next-on-pages",
"preview": "bun run pages:build && wrangler pages dev",
"deploy": "bun run pages:build && wrangler pages deploy"
},
"dependencies": {
"@farcaster/frame-sdk": "^0.0.16",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ImageResponse } from "next/og";

export const alt = "Farcastle Proposal";
export const runtime = "edge";

export const alt = "Farcastle DAO Proposals";
export const size = {
width: 600,
height: 400,
Expand Down
1 change: 1 addition & 0 deletions src/app/dao/[chainid]/[daoid]/[proposaltype]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Proposal from "./proposal";
const appUrl = process.env.NEXT_PUBLIC_URL;

export const revalidate = 300;
export const runtime = "edge";

type Props = {
params: Promise<{ chainid: string; daoid: string; proposaltype: string }>;
Expand Down
3 changes: 3 additions & 0 deletions src/app/dao/[chainid]/[daoid]/[proposaltype]/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export default function Proposal() {
localABIs: {},
};

// TODO: is safeID and chainID needed at both levels?
// how to swap txes for fundung?

const txPrep = await prepareTX({
tx: formConfig.tx,
chainId: daochain as ValidNetwork,
Expand Down
2 changes: 2 additions & 0 deletions src/app/dao/[chainid]/[daoid]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ImageResponse } from "next/og";

export const runtime = "edge";

export const alt = "Farcastle DAO Proposals";
export const size = {
width: 600,
Expand Down
1 change: 1 addition & 0 deletions src/app/dao/[chainid]/[daoid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DaoHome from "./dao-home";
const appUrl = process.env.NEXT_PUBLIC_URL;

export const revalidate = 300;
export const runtime = "edge";

type Props = {
params: Promise<{ chainid: string; daoid: string }>;
Expand Down
67 changes: 66 additions & 1 deletion src/components/forms/RequestFunding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "@/components/ui/form";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { FormComponentProps } from "../app/FormSwitcher";
import { useParams } from "next/navigation";
import { useDao } from "@/hooks/useDao";
import { useDaoTokenBalances } from "@/hooks/useDaoTokenBalances";
import { FormActionButtons } from "../app/FormActionButtons";
import { ProposalMetaFields } from "../app/ProposalMetaFields";
import { Input } from "@/components/ui/input";

const formSchema = z.object({
title: z.string().min(2, {
message: "Title must be at least 2 characters.",
}),
description: z.string(),
link: z.string().url().optional().or(z.literal("")),
recipient: z.string(),
tokenAddress: z.string(),
tokenAmount: z.string(),
});

export const RequestFunding = ({
Expand All @@ -33,6 +44,9 @@ export const RequestFunding = ({
title: "",
description: "",
link: "",
recipient: "",
tokenAmount: "",
tokenAddress: "",
},
});

Expand Down Expand Up @@ -63,6 +77,57 @@ export const RequestFunding = ({
>
<ProposalMetaFields disabled={disabled} />

<FormField
control={form.control}
name="recipient"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Recipient</FormLabel>
</div>
<FormControl>
<Input id="recipient" placeholder="Address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="tokenAddress"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Token Address</FormLabel>
</div>
<FormControl>
<Input id="tokenAddress" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="tokenAmount"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Funding Requested</FormLabel>
</div>
<FormControl>
<Input id="tokenAmount" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormActionButtons
submitButtonText={submitButtonText}
loading={loading}
Expand Down
48 changes: 24 additions & 24 deletions src/components/forms/SampleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ import {
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { zodResolver } from '@hookform/resolvers/zod';
import { InfoIcon } from 'lucide-react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { FormActionButtons } from '../app/FormActionButtons';
import { FormComponentProps } from '../app/FormSwitcher';
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { zodResolver } from "@hookform/resolvers/zod";
import { InfoIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { FormActionButtons } from "../app/FormActionButtons";
import { FormComponentProps } from "../app/FormSwitcher";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";

const formSchema = z.object({
title: z.string().min(2, {
message: 'Try harder',
message: "Try harder",
}),
description: z.string().min(1, {
message: 'Write something',
message: "Write something",
}),
model: z.string().min(1, {
message: 'Make a selection',
message: "Make a selection",
}),
choice: z.enum(['all', 'some', 'none'], {
required_error: 'Choose an option',
choice: z.enum(["all", "some", "none"], {
required_error: "Choose an option",
}),
});

Expand All @@ -49,18 +49,18 @@ export const SampleForm = ({
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
title: '',
description: '',
model: '',
title: "",
description: "",
model: "",
},
});

const onSubmit = (values: z.infer<typeof formSchema>) => {
const preparedValues = {
...values,
};
console.log('values', values);
console.log('preparedValues', preparedValues);
console.log("values", values);
console.log("preparedValues", preparedValues);
console.log(handleSubmit);
// handleSubmit(preparedValues);
};
Expand Down Expand Up @@ -201,7 +201,7 @@ export const SampleForm = ({
/>

<FormActionButtons
submitButtonText={'Create Proposal'}
submitButtonText={"Create Proposal"}
loading={loading}
confirmed={confirmed}
disabled={disabled}
Expand Down
14 changes: 7 additions & 7 deletions src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';
"use client";

import { cn } from '@/lib/cn';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';
import * as React from 'react';
import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check } from "lucide-react";
import { cn } from "@/lib/cn";

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
Expand All @@ -12,13 +12,13 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer h-4 w-4 shrink-0 rounded-sm border border-aliceBlue ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
"peer h-4 w-4 shrink-0 rounded-sm border border-aliceBlue ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
Expand Down
5 changes: 4 additions & 1 deletion src/components/ui/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function Header() {
<div className="text-3xl font-fraktur pt-[2px] leading-[30px] h-[30px] text-primary">
proposals
</div>
<HeaderLogoSvg className="opacity-100" onClick={onLogoClick} />
<HeaderLogoSvg
className="opacity-100 hover:cursor-pointer"
onClick={onLogoClick}
/>
</div>
);
}
Expand Down
21 changes: 11 additions & 10 deletions src/hooks/useDao.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useQuery } from '@tanstack/react-query';
import { GraphQLClient } from 'graphql-request';
import { useQuery } from "@tanstack/react-query";
import { GraphQLClient } from "graphql-request";

import { getGraphUrl } from '@/lib/endpoints';
import { FIND_DAO } from '@/lib/graph-queries';
import { DaoItem, DaoProfile, RecordItem } from '@/lib/types';
import { useDaoHooksConfig } from '@/providers/DaoHooksProvider';
import { getGraphUrl } from "@/lib/endpoints";
import { FIND_DAO } from "@/lib/graph-queries";
import { DaoItem, DaoProfile, RecordItem } from "@/lib/types";
import { useDaoHooksConfig } from "@/providers/DaoHooksProvider";

export const addParsedContent = <T>(record?: RecordItem): T | undefined => {
if (record?.contentType === 'json') {
if (record?.contentType === "json") {
try {
const obj = JSON.parse(record.content);
return obj;
} catch (e) {
console.log('err', e);
console.log("err", e);
return;
}
}
Expand All @@ -25,8 +25,9 @@ export const useDao = ({
chainid?: string;
daoid?: string;
}) => {
// All hooks must be called at the top level
const { config } = useDaoHooksConfig();

console.log("useDao config", config);
const { data, ...rest } = useQuery<{ dao: DaoItem }>({
queryKey: [`get-dao-${chainid}-${daoid}`],
enabled: Boolean(chainid && daoid && config?.graphKey),
Expand All @@ -37,7 +38,7 @@ export const useDao = ({
const dhUrl = getGraphUrl({
chainid,
graphKey: config.graphKey,
subgraphKey: 'DAOHAUS',
subgraphKey: "DAOHAUS",
});
const graphQLClient = new GraphQLClient(dhUrl);
const daores = (await graphQLClient.request(FIND_DAO, { daoid })) as {
Expand Down
Loading