Skip to content

Commit

Permalink
Merge pull request #106 from polywrap/dev
Browse files Browse the repository at this point in the history
Release/dev
  • Loading branch information
cbrzn authored Feb 8, 2024
2 parents e6c7f9a + 02599a9 commit 0aa7596
Show file tree
Hide file tree
Showing 44 changed files with 2,368 additions and 1,586 deletions.
1 change: 1 addition & 0 deletions ops/scripts/generate_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def run():
create_table_statements = [stmt.replace('"public".', '') for stmt in create_table_statements]
# Remove some unsupported SQL features that break omymodels
create_table_statements = [stmt.replace('DEFAULT "gen_random_uuid"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('DEFAULT "auth"."uid"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('with time zone DEFAULT "now"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('with time zone', '') for stmt in create_table_statements]
create_table_statements = [re.sub(r'(?m)CONSTRAINT.*\n?', '', stmt) for stmt in create_table_statements]
Expand Down
3 changes: 3 additions & 0 deletions web/app/actions/createFundingPlan.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"use server";

import { NetworkName } from "@/utils/ethereum";

interface CreateFundingPlanArguments {
decimals: number;
token: string;
network: NetworkName;
strategies: Array<{
project_id: string;
weight: number;
Expand Down
8 changes: 4 additions & 4 deletions web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ html {
}

body {
@apply font-medium text-indigo-900;
@apply font-medium text-indigo-800;
}

p {
Expand All @@ -19,15 +19,15 @@ a {
}

th {
@apply px-4 pt-4 pb-2 text-indigo-900/50 font-semibold text-xs leading-none uppercase;
@apply px-4 pt-4 pb-2 text-indigo-800/50 font-semibold text-xs leading-none uppercase;
}

td {
@apply p-4;
}

.checkbox {
@apply rounded border-2 border-indigo-500 w-5 h-5 transition-colors duration-300 cursor-pointer hover:border-indigo-400;
@apply rounded border-2 border-indigo-500 w-5 h-5 transition-colors duration-300 hover:border-indigo-400;
}

.checkbox.checked {
Expand All @@ -53,5 +53,5 @@ td {
}

.text-subdued {
@apply text-indigo-900/60;
@apply text-indigo-800/60;
}
74 changes: 32 additions & 42 deletions web/app/s/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Disclaimer from "@/components/Disclaimer";
import RealtimeLogs from "@/components/RealtimeLogs";
import Strategy from "@/components/Strategy";
import { StrategyWithProjects } from "@/components/StrategyTable";
import { StrategiesWithProjects } from "@/hooks/useStrategiesHandler";
import TextField from "@/components/TextField";
import { Tables } from "@/supabase/dbTypes";
import { getNetworkNameFromChainId } from "@/utils/ethereum";
import { checkIfFinished } from "@/utils/logs";
import { createSupabaseServerClientWithSession } from "@/utils/supabase-server";

Expand All @@ -22,13 +23,14 @@ export default async function StrategyPage({
prompt,
strategy_entries(
*,
project:projects(*)
),
funding_entries(
amount,
token,
weight,
project_id
project:projects(
*,
applications(
network,
created_at,
recipient
)
)
),
logs(
id,
Expand All @@ -52,60 +54,48 @@ export default async function StrategyPage({
const strategyCreated = checkIfFinished(run.data.logs);
if (!strategyCreated) {
return (
<div className="w-full flex justify-center h-full p-16">
<div className="w-full max-w-3xl flex flex-col gap-8">
<div className="w-full flex flex-col items-center justify-between h-full pt-16 pb-8 px-16">
<div className="w-full max-w-sm space-y-8">
<div className="flex flex-col gap-2">
<TextField
label="Results for"
value={run.data.prompt}
readOnly
/>
<TextField label="Results for" value={run.data.prompt} readOnly />
</div>
<div className="w-full h-[1px] bg-indigo-500" />
<RealtimeLogs
logs={run.data.logs}
run={{ id: params.id, prompt: run.data.prompt }}
/>
</div>
<Disclaimer />
</div>
);
}

const data = run.data.strategy_entries as unknown as StrategyWithProjects;
const data = run.data.strategy_entries as unknown as StrategiesWithProjects;

const networks = data.flatMap((s) =>
s.project.applications.map((a) => getNetworkNameFromChainId(a.network))
);
const networksFromProjects = Array.from(new Set(networks));

const strategy = data
.map((s) => {
if (run.data.funding_entries.length) {
const selected = run.data.funding_entries.find(
({ project_id }) => s.project_id === project_id
);
const weight = selected?.weight || s.weight || 0;
return {
...s,
selected: !!selected,
amount: selected?.amount,
weight,
defaultWeight: s.weight as number,
};
}
const strategies = data
.map((strategy, i) => {
const lastApplication = strategy.project.applications
.sort((a, b) => a.created_at - b.created_at)
.slice(-1)[0];
return {
...s,
selected: run.data.funding_entries.length === 0,
defaultWeight: s.weight as number,
...strategy,
defaultWeight: strategy.weight as number,
network: networks[i],
recipient: lastApplication.recipient,
};
})
.sort((a, b) => (b.impact || 0) - (a.impact || 0));

const amount = run.data.funding_entries.reduce((acc, x) => {
return acc + Number(x.amount);
}, 0);

return (
<Strategy
strategy={strategy}
fetchedStrategies={strategies}
prompt={run.data.prompt}
runId={run.data.id}
amount={amount.toString()}
networks={networksFromProjects}
/>
);
}
16 changes: 1 addition & 15 deletions web/app/s/[id]/transaction/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import FundingReview from "@/components/FundingReview";
import { FundingEntry } from "@/components/FundingTable";
import { createSupabaseServerClientWithSession } from "@/utils/supabase-server";

export default async function Page({ params }: { params: { id: string } }) {
const supabase = await createSupabaseServerClientWithSession()

const run = await supabase
.from("funding_entries_view")
.select("*")
.eq("run_id", params.id);

if (run.error || !run.data) {
console.error(run.error);
throw Error(`Run with ID ${params.id} not found.`);
}

return <FundingReview entries={run.data as FundingEntry[]} />;
return <FundingReview id={params.id} />;
}
36 changes: 36 additions & 0 deletions web/components/Disclaimer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use client";

import { X } from "@phosphor-icons/react/dist/ssr";
import { useState } from "react";

const Disclaimer = () => {
const [showDisclaimer, setShowDisclaimer] = useState<boolean>(true);
return showDisclaimer ? (
<div className='px-6'>
<div className='fixed bottom-16 left-1/2 transform -translate-x-1/2 max-w-screen-sm w-full z-10'>
<X
onClick={() => setShowDisclaimer(false)}
className='absolute top-4 right-4 text-indigo-800 hover:text-indigo-500 cursor-pointer'
size={20}
weight='bold'
/>
<div className='p-6 bg-indigo-25 rounded-2xl border-2 border-indigo-200 space-y-1 shadow-md shadow-primary-shadow/20'>
<div className='font-bold text-sm'>
This AI agent is experimental:
</div>
<div className='text-[10px]'>
The agent is doing its best to evaluate project relevance, impact,
and funding needs based on publicly available data from Gitcoin, but
we cannot guarantee that it will be completely accurate. The agent
will also provide the recipient addresses of each project based on
data in their Gitcoin applications, but we cannot guarantee that
each project is still in control of its address, so please do not
send large amounts.
</div>
</div>
</div>
</div>
) : null;
};

export default Disclaimer;
Loading

0 comments on commit 0aa7596

Please sign in to comment.