Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into frontend-passport-inte…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
Lucianosc committed Jul 26, 2024
2 parents 52cc209 + 8b43875 commit 7b836f5
Show file tree
Hide file tree
Showing 74 changed files with 2,616 additions and 2,345 deletions.
18 changes: 3 additions & 15 deletions apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,14 @@ module.exports = {
],
"prefer-const": "off",
"@typescript-eslint/consistent-type-definitions": "off",
curly: ["error", "multi-line"],
"no-unused-expressions": "error",
"no-unsafe-optional-chaining": "error",
"comma-dangle": ["error", "always-multiline"],
semi: ["error", "always"],
"brace-style": ["error"],
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/quotes": ["error", "double"],
"import/extensions": "off",
"no-multiple-empty-lines": ["error", { max: 1 }],
"no-trailing-spaces": "error",
"no-multi-spaces": "error",
"@typescript-eslint/quotes": ["error", "double"],
"@typescript-eslint/no-use-before-define": "off",
"jsx-a11y/no-static-element-interactions": "off",
"no-irregular-whitespace": "error",
"object-property-newline": [
"error",
{ allowAllPropertiesOnSameLine: true },
],
"semi-spacing": "error",
"react/no-array-index-key": "warn",
indent: "off",
"@typescript-eslint/indent": "off",
},
};
24 changes: 13 additions & 11 deletions apps/web/actions/getProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ export async function getProposals(

const transformProposals = async function (_strategy: LightCVStrategy) {
const proposalsData = await fetchIPFSDataBatch(_strategy.proposals);
const transformedProposals = proposalsData.map((data, index) => {
const p = _strategy.proposals[index];
return {
...p,
voterStakedPointsPct: 0,
stakedAmount: _strategy.proposals[index].stakedAmount,
title: data.title,
type: _strategy.config?.proposalType as number,
status: _strategy.proposals[index].proposalStatus,
};
}).sort((a, b) => +a.proposalNumber - +b.proposalNumber); // Sort by proposal number ascending
const transformedProposals = proposalsData
.map((data, index) => {
const p = _strategy.proposals[index];
return {
...p,
voterStakedPointsPct: 0,
stakedAmount: _strategy.proposals[index].stakedAmount,
title: data.title,
type: _strategy.config?.proposalType as number,
status: _strategy.proposals[index].proposalStatus,
};
})
.sort((a, b) => +a.proposalNumber - +b.proposalNumber); // Sort by proposal number ascending

return transformedProposals;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ export default function Page({
Proposal passed and executed successfully
</div>
</div>
: ( <ConvictionBarChart
: <ConvictionBarChart
currentConvictionPct={currentConvictionPct}
thresholdPct={thresholdPct}
proposalSupportPct={totalSupportPct}
isSignalingType={isSignalingType}
proposalId={proposalIdNumber}
/>
)}
}
</section>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default function Page({
const tokenGarden = data.tokenGarden;

const maxRatioDivPrecision =
(Number(strategyObj.config?.maxRatio) / CV_SCALE_PRECISION) *
MAX_RATIO_CONSTANT;
(Number(strategyObj.config?.maxRatio) / CV_SCALE_PRECISION) *
MAX_RATIO_CONSTANT;

const spendingLimitPct = maxRatioDivPrecision * 100;
const poolAmountSpendingLimit = poolAmount * maxRatioDivPrecision;
Expand All @@ -60,7 +60,7 @@ export default function Page({
<section className="section-layout">
<div className="text-center sm:mt-5">
<h2 className="text-xl font-semibold leading-6 text-gray-900">
Create a Proposal in Pool
Create a Proposal in Pool
</h2>
<div className="mt-1">
<p className="text-sm">{metadata.title}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function Page({
}, [error]);

const [ipfsResult, setIpfsResult] =
useState<Awaited<ReturnType<typeof getIpfsMetadata>>>();
useState<Awaited<ReturnType<typeof getIpfsMetadata>>>();

const metadata = data?.cvstrategies?.[0]?.metadata;

Expand All @@ -93,7 +93,11 @@ export default function Page({

useEffect(() => {
const newProposalId = searchParams[QUERY_PARAMS.poolPage.newPropsoal];
if (newProposalId && data && !strategyObj?.proposals.some(c => c.proposalNumber === newProposalId)) {
if (
newProposalId &&
data &&
!strategyObj?.proposals.some((c) => c.proposalNumber === newProposalId)
) {
refetch();
}
}, [searchParams, strategyObj?.proposals]);
Expand Down Expand Up @@ -121,7 +125,7 @@ export default function Page({
const isEnabled = data.cvstrategies?.[0]?.isEnabled as boolean;

const spendingLimitPct =
(Number(strategyObj?.config?.maxRatio || 0) / CV_SCALE_PRECISION) * 100;
(Number(strategyObj?.config?.maxRatio || 0) / CV_SCALE_PRECISION) * 100;

return (
<div className="page-layout">
Expand All @@ -135,18 +139,12 @@ export default function Page({
</header>
<p>{ipfsResult.description}</p>
<div className="mb-10 mt-8 flex flex-col items-start gap-2">
<Statistic
label="pool type"
icon={<InformationCircleIcon />}
>
<Statistic label="pool type" icon={<InformationCircleIcon />}>
<Badge type={proposalType} />
</Statistic>

{poolTypes[proposalType] === "funding" && (
<Statistic
label="funding token"
icon={<InformationCircleIcon />}
>
<Statistic label="funding token" icon={<InformationCircleIcon />}>
<Badge
isCapitalize
label={tokenGarden.symbol}
Expand All @@ -165,29 +163,21 @@ export default function Page({
classNames="text-secondary-content"
icon={<ChartBarIcon />}
/>
<Badge
label={pointSystems[pointSystem]}
icon={<BoltIcon />}
/>
<Badge label={pointSystems[pointSystem]} icon={<BoltIcon />} />
</div>
</Statistic>
</div>
{!isEnabled ? (
{!isEnabled ?
<div className="banner">
<ClockIcon className="h-8 w-8 text-secondary-content" />
<h6>Waiting for council approval</h6>
</div>
) : (
<Image
src={
poolTypes[proposalType] === "funding"
? blueLand
: grassLarge
}
: <Image
src={poolTypes[proposalType] === "funding" ? blueLand : grassLarge}
alt="pool image"
className="h-12 w-full rounded-lg object-cover"
/>
)}
}
</section>

{isEnabled && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,23 @@ export default function Page({
let alloAddr = result?.allos[0]?.id as Address;
let communityName = result?.registryCommunity?.communityName as string;

return result ? (
<div className="page-layout">
<section className="section-layout">
<div className="text-center sm:mt-5">
<h2 className="text-xl font-semibold leading-6 text-gray-900">
Create a Pool in {communityName} community
</h2>
</div>
<PoolForm
alloAddr={alloAddr}
token={token as TokenGarden}
communityAddr={community as Address}
chainId={chain}
/>
</section>
</div>
) : (
<div className="mt-96">
<LoadingSpinner />
</div>
);
return result ?
<div className="page-layout">
<section className="section-layout">
<div className="text-center sm:mt-5">
<h2 className="text-xl font-semibold leading-6 text-gray-900">
Create a Pool in {communityName} community
</h2>
</div>
<PoolForm
alloAddr={alloAddr}
token={token as TokenGarden}
communityAddr={community as Address}
chainId={chain}
/>
</section>
</div>
: <div className="mt-96">
<LoadingSpinner />
</div>;
}
60 changes: 21 additions & 39 deletions apps/web/app/(app)/gardens/[chain]/[garden]/[community]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ export default function Page({
} = result?.registryCommunity ?? {};

const communityStakedTokens =
members?.reduce(
(acc: bigint, member) => acc + BigInt(member?.stakedTokens),
0n,
) ?? 0;
members?.reduce(
(acc: bigint, member) => acc + BigInt(member?.stakedTokens),
0n,
) ?? 0;

strategies = strategies ?? [];

const signalingPools = strategies.filter(
(strategy) =>
poolTypes[strategy.config?.proposalType] === "signaling" &&
strategy.isEnabled,
strategy.isEnabled,
);

const fundingPools = strategies.filter(
(strategy) =>
poolTypes[strategy.config?.proposalType] === "funding" &&
strategy.isEnabled,
strategy.isEnabled,
);
const activePools = strategies?.filter((strategy) => strategy?.isEnabled);

Expand Down Expand Up @@ -172,8 +172,8 @@ export default function Page({
} else {
return (
BigInt(registerStakeAmount) +
BigInt(registerStakeAmount) /
(BigInt(SCALE_PRECISION) / BigInt(communityFee))
BigInt(registerStakeAmount) /
(BigInt(SCALE_PRECISION) / BigInt(communityFee))
);
}
} else {
Expand All @@ -199,24 +199,15 @@ export default function Page({
<EthAddress address={communityAddr as Address} />
</div>
<div className="flex flex-col gap-2">
<Statistic
label="members"
count={members?.length ?? 0}
/>
<Statistic label="members" count={members?.length ?? 0} />
<Statistic
label="pools"
icon={<RectangleGroupIcon />}
count={activePools.length ?? 0}
/>
<Statistic
label="staked tokens"
icon={<CurrencyDollarIcon />}
>
<Statistic label="staked tokens" icon={<CurrencyDollarIcon />}>
<DisplayNumber
number={[
BigInt(communityStakedTokens),
tokenGarden.decimals,
]}
number={[BigInt(communityStakedTokens), tokenGarden.decimals]}
compact={true}
tokenSymbol={tokenGarden.symbol}
/>
Expand All @@ -228,10 +219,7 @@ export default function Page({
data-tip={`Registration amount: ${parseToken(registrationAmount)} ${tokenGarden.symbol}\nCommunity fee: ${parseToken(parsedCommunityFee())} ${tokenGarden.symbol}`}
>
<DisplayNumber
number={[
getTotalRegistrationCost(),
tokenGarden?.decimals,
]}
number={[getTotalRegistrationCost(), tokenGarden?.decimals]}
className="font-semibold"
disableTooltip={true}
compact={true}
Expand Down Expand Up @@ -277,13 +265,13 @@ export default function Page({
tooltip={tooltipMessage}
icon={<PlusIcon height={24} width={24} />}
>
Create Pool
Create Pool
</Button>
</Link>
</header>
<div className="flex flex-col gap-4">
<h4 className="text-secondary-content">
Funding pools ({fundingPools.length})
Funding pools ({fundingPools.length})
</h4>
<div className="flex flex-row flex-wrap gap-10">
{fundingPools.map((pool) => (
Expand All @@ -299,7 +287,7 @@ export default function Page({
</div>
<div className="flex flex-col gap-4">
<h4 className="text-secondary-content">
Signaling pools ({signalingPools.length})
Signaling pools ({signalingPools.length})
</h4>
<div className="flex flex-row flex-wrap gap-10">
{signalingPools.map((pool) => (
Expand All @@ -315,7 +303,7 @@ export default function Page({
</div>
<div className="flex flex-col gap-4">
<h4 className="text-secondary-content">
Pools in Review ({poolsInReview.length})
Pools in Review ({poolsInReview.length})
</h4>
<div className="flex flex-row flex-wrap gap-10">
{poolsInReview.map((pool) => (
Expand All @@ -332,15 +320,11 @@ export default function Page({
</section>
<section className="section-layout">
<h2 className="mb-4">Covenant</h2>
{covenantIpfsHash ? (
covenant ? (
{covenantIpfsHash ?
covenant ?
<p>{covenant}</p>
) : (
<LoadingSpinner />
)
) : (
<p className="italic">No covenant was submitted.</p>
)}
: <LoadingSpinner />
: <p className="italic">No covenant was submitted.</p>}
<div className="mt-10 flex justify-center">
<Image
src={groupFlowers}
Expand All @@ -351,9 +335,7 @@ export default function Page({
/>
</div>
</section>
{!isProd && tokenGarden && (
<TokenGardenFaucet token={tokenGarden} />
)}
{!isProd && tokenGarden && <TokenGardenFaucet token={tokenGarden} />}
</div>
);
}
Loading

0 comments on commit 7b836f5

Please sign in to comment.