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

Fix new created entity outlined #448

Merged
merged 25 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions apps/web/actions/getProposals.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import React from "react";
import { Address } from "viem";
import { getPoolDataDocument, getPoolDataQuery } from "#/subgraph/.graphclient";
import { ProposalForm } from "@/components/Forms";
import { LoadingSpinner } from "@/components/LoadingSpinner";
Expand Down Expand Up @@ -61,7 +60,6 @@ export default function Page({
proposalType={proposalType}
alloInfo={alloInfo}
tokenGarden={tokenGarden}
tokenAddress={garden as Address}
spendingLimit={poolAmountSpendingLimit}
spendingLimitPct={spendingLimitPct}
poolAmount={poolAmount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PoolMetrics, Proposals } from "@/components";
import { LoadingSpinner } from "@/components/LoadingSpinner";
import PoolHeader from "@/components/PoolHeader";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { useMetadataIpfsFetch } from "@/hooks/useIpfsFetch";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";
import { PoolTypes } from "@/types";
Expand Down Expand Up @@ -44,6 +44,7 @@ export default function Page({
},
],
});

const strategyObj = data?.cvstrategies?.[0];
const poolTokenAddr = strategyObj?.token as Address;
const { data: poolToken } = useToken({
Expand Down Expand Up @@ -74,12 +75,18 @@ export default function Page({
}, [strategyObj?.config, strategyObj?.config, strategyObj?.poolAmount]);

useEffect(() => {
const newProposalId = searchParams[QUERY_PARAMS.poolPage.newPropsoal];
if (
newProposalId &&
data &&
!strategyObj?.proposals.some((c) => c.proposalNumber === newProposalId)
) {
const newProposalId = searchParams[QUERY_PARAMS.poolPage.newProposal];
if (!strategyObj) {
return;
}
const fetchedProposals = strategyObj?.proposals.map((p) =>
p.proposalNumber.toString(),
);
if (newProposalId && !fetchedProposals.includes(newProposalId)) {
console.debug("Pool: New proposal not yet fetched, refetching...", {
newProposalId,
fetchedProposals,
});
refetch();
}
}, [searchParams, strategyObj?.proposals]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import MarkdownWrapper from "@/components/MarkdownWrapper";
import { TokenGardenFaucet } from "@/components/TokenGardenFaucet";
import { isProd } from "@/configs/isProd";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { useDisableButtons } from "@/hooks/useDisableButtons";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";
import { PoolTypes } from "@/types";
Expand Down Expand Up @@ -146,11 +146,16 @@ export default function Page({

useEffect(() => {
const newPoolId = searchParams[QUERY_PARAMS.communityPage.newPool];
const fetchedPools = poolsInReview.some((c) => c.poolId === newPoolId);
if (
newPoolId &&
result &&
!poolsInReview.some((c) => c.poolId === newPoolId)
!poolsInReview.some((p) => p.poolId === newPoolId)
) {
console.debug("Community: New pool not yet fetched, refetching...", {
newPoolId,
fetchedPools,
});
refetch();
}
}, [searchParams, poolsInReview]);
Expand Down
12 changes: 8 additions & 4 deletions apps/web/app/(app)/gardens/[chain]/[garden]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { LoadingSpinner } from "@/components/LoadingSpinner";
import { TokenGardenFaucet } from "@/components/TokenGardenFaucet";
import { isProd } from "@/configs/isProd";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { useDisableButtons } from "@/hooks/useDisableButtons";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";

Expand Down Expand Up @@ -80,15 +80,19 @@ export default function Page({
useEffect(() => {
const newCommunityId =
searchParams[QUERY_PARAMS.gardenPage.newCommunity]?.toLowerCase();

const fetchedCommunities = communities.map((c) => c.id.toLowerCase());
if (
newCommunityId &&
result &&
!communities.some((c) => c.id.toLowerCase() === newCommunityId)
!fetchedCommunities.includes(newCommunityId)
) {
console.debug("Garden: New pool not yet fetched, refetching...", {
newCommunityId,
fetchedCommunities,
});
refetch();
}
}, [searchParams, result]);
}, [searchParams, communities]);

if (!result) {
return (
Expand Down
13 changes: 13 additions & 0 deletions apps/web/app/api/ipfs/[hash]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ export async function GET(req: NextRequest, { params }: Params) {
},
});

if (!res.ok) {
return Response.json(
{
message: "Error fetching IPFS content",
status: res.status,
details: await res.text(),
},
{
status: res.status ?? 500,
},
);
}

if (searchParams.get("isText") === "true") {
const text = await res.text();
return Response.json({ text }, { status: 200 });
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/CommunityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Card } from "./Card";
import { Statistic } from "./Statistic";
import { commImg } from "@/assets";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";

type CommunityCardProps = {
name: string;
Expand Down
25 changes: 7 additions & 18 deletions apps/web/components/Forms/ProposalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type ProposalFormProps = {
proposalType: number;
alloInfo: Pick<Allo, "id" | "chainId" | "tokenNative">;
tokenGarden: Pick<TokenGarden, "symbol" | "decimals">;
tokenAddress: Address;
spendingLimit: number;
spendingLimitPct: number;
poolAmount: number;
Expand Down Expand Up @@ -116,7 +115,6 @@ export const ProposalForm = ({
proposalType,
alloInfo,
tokenGarden,
tokenAddress,
spendingLimit,
spendingLimitPct,
}: ProposalFormProps) => {
Expand Down Expand Up @@ -217,16 +215,15 @@ export const ProposalForm = ({
id: proposalId.toString(), // proposalId is a bigint
chainId,
});
setLoading(false);
if (pathname) {
router.push(
pathname.replace(
"/create-proposal",
`?${QUERY_PARAMS.poolPage.newPropsoal}=${proposalId}`,
),
const newPath = pathname.replace(
"/create-proposal",
`?${QUERY_PARAMS.poolPage.newProposal}=${proposalId}`,
);
router.push(newPath);
}
},
onSettled: () => setLoading(false),
});

const poolTokenAddr = strategy?.token as Address;
Expand Down Expand Up @@ -265,7 +262,7 @@ export const ProposalForm = ({
poolId,
previewData.beneficiary,
requestedAmount,
tokenAddress,
poolTokenAddr,
metadata,
]);

Expand All @@ -275,19 +272,11 @@ export const ProposalForm = ({
previewData?.beneficiary ||
"0x0000000000000000000000000000000000000000",
requestedAmount,
tokenAddress,
poolTokenAddr,
metadata,
],
]);

console.debug(
poolId,
previewData.beneficiary,
requestedAmount,
tokenAddress,
metadata,
);

return encodedData;
};

Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { blueLand, grass } from "@/assets";
import { Badge, Card, DisplayNumber, Statistic } from "@/components";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { PointSystems, PoolTypes } from "@/types";
import { capitalize } from "@/utils/text";

Expand All @@ -42,7 +42,7 @@ export function PoolCard({ pool, tokenGarden }: Props) {
const poolType = config?.proposalType as number | undefined;

const isNewPool =
searchParams[QUERY_PARAMS.communityPage.newPool] === pool.poolId;
searchParams[QUERY_PARAMS.communityPage.newPool] === pool.poolId.toString();
return (
<Card
href={`${pathname}/${poolId}`}
Expand Down
15 changes: 11 additions & 4 deletions apps/web/components/PoolGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@
import React from "react";
import { Dnum } from "dnum";
import { Address, useAccount } from "wagmi";
import {
CVStrategy,
CVStrategyConfig,
TokenGarden,
} from "#/subgraph/.graphclient";
import {
ActivatePoints,
Badge,
DisplayNumber,
CheckPassport,
InfoBox,
} from "@/components/";
import { LightCVStrategy } from "@/types";

interface PoolGovernanceProps {
export type PoolGovernanceProps = {
memberPoolWeight: number;
tokenDecimals: number;
strategy: LightCVStrategy;
strategy: Pick<CVStrategy, "id"> & {
registryCommunity: { garden: Pick<TokenGarden, "symbol"> };
config: Pick<CVStrategyConfig, "pointSystem">;
};
communityAddress: Address;
memberTokensInCommunity: number;
isMemberCommunity: boolean;
memberActivatedStrategy: boolean;
}
};

export const PoolGovernance: React.FC<PoolGovernanceProps> = ({
memberPoolWeight,
Expand Down
6 changes: 2 additions & 4 deletions apps/web/components/PoolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ export default function PoolHeader({
<header className="mb-2 flex flex-col">
<div className="flex justify-between flex-wrap">
<div>
<h2>
{ipfsResult?.title}
<h5 className="">#{poolId}</h5>
</h2>
<h2>{ipfsResult?.title}</h2>
<h5 className="">#{poolId}</h5>
</div>
{(isCouncilMember ?? isCouncilSafe) && (
// true
Expand Down
Loading
Loading