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

Release bugs fix part 3 #360

Merged
merged 10 commits into from
Aug 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function Page({
currentConvictionPct,
thresholdPct,
totalSupportPct,
updateConvictionLast,
updatedConviction,
} = useConvictionRead({
proposalData,
tokenData: data?.tokenGarden,
Expand Down Expand Up @@ -136,7 +136,7 @@ export default function Page({
!proposalData ||
!ipfsResult ||
proposalIdNumber == null ||
updateConvictionLast == null
updatedConviction == null
) {
return (
<div className="mt-96">
Expand Down
8 changes: 3 additions & 5 deletions apps/web/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ export function Breadcrumbs() {
<h5>Disclaimer</h5>
</div>
<p className="text-wrap text-justify">
You are exploring the frontier with our contracts.{" "}
<span className="subtitle2">
Please note that they have not been audited yet
</span>
. Exercise caution and proceed at your own risk.
Our smart contracts{" "}
<span className="subtitle2">have not been audited</span> yet. Be
caution and proceed at your own risk.
</p>
<div>
<Button
Expand Down
10 changes: 5 additions & 5 deletions apps/web/components/Charts/ConvictionBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ export const ConvictionBarChart = ({
},
animation: true,
barGap: "-100%",
showBackground: true,
backgroundStyle: {
color: "#D5D5D5",
},
series: [
{
type: "bar",
Expand All @@ -261,11 +265,7 @@ export const ConvictionBarChart = ({
color: "#A8E066",
borderRadius: borderRadius,
},
showBackground: true,
backgroundStyle: {
color: "#D5D5D5",
borderRadius: borderRadius,
},

label: {
show: !compact ?? false,
position: "insideRight",
Expand Down
35 changes: 1 addition & 34 deletions apps/web/components/ConnectWalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import React, { Fragment } from "react";
import { Menu, Transition } from "@headlessui/react";
import {
ChevronUpIcon,
PowerIcon,
ArrowTopRightOnSquareIcon,
} from "@heroicons/react/24/solid";
import { ChevronUpIcon, PowerIcon } from "@heroicons/react/24/solid";
import { ConnectButton } from "@rainbow-me/rainbowkit";
import cn from "classnames";
import Image from "next/image";
Expand Down Expand Up @@ -193,35 +189,6 @@ export function ConnectWallet() {
Disconnect
</Button>
</Menu.Item>
<div className="flex gap-2 items-center justify-end border-t-[1px] border-neutral-soft pt-4">
<a
href="/"
target="_blank"
rel="noreferrer"
className="text-primary-content subtitle2 flex items-center gap-1"
>
Home
<ArrowTopRightOnSquareIcon
width={16}
height={16}
className="text-primary-content"
/>
</a>
<div className="text-neutral-soft">|</div>
<a
href="https://docs.gardens.fund"
target="_blank"
rel="noreferrer"
className="text-primary-content subtitle2 flex items-center gap-1"
>
Docs
<ArrowTopRightOnSquareIcon
width={16}
height={16}
className="text-primary-content"
/>
</a>
</div>
</div>
</Menu.Items>
</Transition>
Expand Down
43 changes: 19 additions & 24 deletions apps/web/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import React from "react";
import { Disclosure } from "@headlessui/react";
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline";
import {
ArrowTopRightOnSquareIcon,
Bars3Icon,
XMarkIcon,
} from "@heroicons/react/24/outline";
import Image from "next/image";
import Link from "next/link";
import { newLogo } from "@/assets";
Expand Down Expand Up @@ -38,19 +42,21 @@ export function NavBar() {
pre-beta release{" "}
</p>
</div>
<div className="hidden sm:ml-4 sm:flex sm:space-x-8">
{/* {navItems.map(({ name, href }) => (
<Link
key={href}
href={href}
className="inline-flex items-center border-b-2 border-transparent px-1 pt-1 text-sm font-medium text-gray-500 hover:border-gray-300 hover:text-gray-700"
>
{name}
</Link>
))} */}
</div>
</div>
<div className="hidden sm:ml-6 sm:flex sm:items-center">
<div className="hidden sm:ml-6 sm:flex sm:items-center gap-4">
<a
href="https://docs.gardens.fund"
target="_blank"
rel="noreferrer"
className="text-primary-content subtitle2 flex items-center gap-1 hover:opacity-90"
>
Docs
<ArrowTopRightOnSquareIcon
width={16}
height={16}
className="text-primary-content"
/>
</a>
<ConnectWallet />
</div>
<div className="-mr-2 flex items-center sm:hidden">
Expand All @@ -71,7 +77,6 @@ export function NavBar() {
</div>
</div>
</div>

<Disclosure.Panel className="sm:hidden">
<div className="space-y-1 pb-3 pt-2">
{navItems.map(({ name, href }) => (
Expand All @@ -84,16 +89,6 @@ export function NavBar() {
</Link>
))}
</div>
<div className="flex border-t border-gray-200 p-4">
{/* <ConnectButton /> */}
{/* <Button
disabled={connecting}
onClick={() => (wallet ? disconnect(wallet) : connect())}
className="bg-primary"
>
{connecting ? "Connecting" : wallet ? "Disconnect" : "Connect"}
</Button> */}
</div>
</Disclosure.Panel>
</>
)}
Expand Down
25 changes: 11 additions & 14 deletions apps/web/components/PoolGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const PoolGovernance: React.FC<PoolGovernanceProps> = ({
{address && (
<div className="mt-4 flex flex-col justify-between items-start">
<div className="flex flex-1 gap-10">
<div className="flex flex-col items-start gap-4">
<div className="flex flex-col items-start gap-2">
<div className="flex items-center gap-6">
<p className="subtitle2">Your stake in the community:</p>
<DisplayNumber
Expand All @@ -76,22 +76,19 @@ export const PoolGovernance: React.FC<PoolGovernanceProps> = ({
<Badge status={memberActivatedStrategy ? 1 : 0} />
</div>
{showPoolGovernanceData && (
<div className="flex gap-6">
<div className="flex flex-col items-start gap-1">
<p className="subtitle2">Your governance weight:</p>
<h2 className="text-primary-content">
{memberPoolWeight.toFixed(2)} %
</h2>
</div>

<InfoBox
content={poolSystemDefinition[poolSystem]}
infoBoxType="info"
classNames="flex-1 w-full"
/>
<div className="flex items-start gap-6">
<p className="subtitle2">Your governance weight:</p>
<p className="subtitle2 text-primary-content">
{memberPoolWeight.toFixed(2)} %
</p>
</div>
)}
</div>
<InfoBox
content={poolSystemDefinition[poolSystem]}
infoBoxType="info"
classNames="flex-1 w-full"
/>
</div>
</div>
)}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/components/PoolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ export default function PoolHeader({
const filteredPoolConfig =
PoolTypes[proposalType] === "signaling" ?
poolConfig.filter(
(config) => !["Spending limit", "Min Threshold"].includes(config.label),
(config) =>
!["Spending limit", "Min Threshold", "Min conviction"].includes(
config.label,
),
)
: poolConfig;

Expand Down
1 change: 0 additions & 1 deletion apps/web/components/Proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AdjustmentsHorizontalIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { filter } from "lodash-es";
import Link from "next/link";
import { Address as AddressType, useAccount } from "wagmi";
import {
Expand Down
66 changes: 54 additions & 12 deletions apps/web/hooks/useConvictionRead.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zeroAddress } from "viem";
import { Address, useContractRead } from "wagmi";
import { Address, useBlockNumber, useContractRead } from "wagmi";
import {
CVProposal,
CVStrategy,
Expand All @@ -13,7 +13,12 @@ import { calculatePercentageBigInt } from "@/utils/numbers";
type ProposalDataLight = Maybe<
Pick<
CVProposal,
"proposalNumber" | "convictionLast" | "stakedAmount" | "threshold"
| "proposalNumber"
| "convictionLast"
| "stakedAmount"
| "threshold"
| "requestedAmount"
| "blockLast"
Mati0x marked this conversation as resolved.
Show resolved Hide resolved
> & {
strategy: Pick<
CVStrategy,
Expand All @@ -37,37 +42,65 @@ export const useConvictionRead = ({
enabled: !!proposalData,
};

const { data: updateConvictionLast, error } = useContractRead({
//const blockNumber = useBlockNumber();
//const timePassed = BigInt(blockNumber?.data ?? 0n) - (blockLast ?? 0n);

//new way of getting conviction from contract
// const { data: convictionFromContract, error: errorConviction } =
// useContractRead({
// ...cvStrategyContract,
// functionName: "calculateConviction",
// args: [
// timePassed,
// proposalData?.convictionLast,
// proposalData?.stakedAmount,
// ],
// enabled: enabled,
// });

const { data: updatedConviction, error: errorConviction } = useContractRead({
...cvStrategyContract,
functionName: "updateProposalConviction" as any,
args: [BigInt(proposalData?.proposalNumber ?? 0)],
enabled,
});

if (error) {
logOnce("error", "Error reading conviction", error);
const { data: thresholdFromContract, error: errorThreshold } =
useContractRead({
...cvStrategyContract,
functionName: "calculateThreshold" as any,
args: [proposalData?.requestedAmount ?? 0],
enabled,
});

if (errorThreshold) {
logOnce("error", "Error reading threshold", errorThreshold);
}

if (errorConviction) {
logOnce("error", "Error reading conviction", errorConviction);
}

if (!enabled) {
return {
thresholdPct: undefined,
totalSupportPct: undefined,
currentConvictionPct: undefined,
updateConvictionLast: undefined,
updatedConviction: undefined,
};
}

if (!proposalData || updateConvictionLast == null) {
if (!proposalData || updatedConviction == null) {
return {
thresholdPct: undefined,
totalSupportPct: undefined,
currentConvictionPct: undefined,
updateConvictionLast: undefined,
updatedConviction: undefined,
};
}

let thresholdPct = calculatePercentageBigInt(
proposalData!.threshold,
thresholdFromContract as bigint,
proposalData.strategy.maxCVSupply,
token?.decimals ?? 18,
);
Expand All @@ -79,22 +112,31 @@ export const useConvictionRead = ({
);

let currentConvictionPct = calculatePercentageBigInt(
updateConvictionLast as bigint,
BigInt(updatedConviction.toString()),
proposalData.strategy.maxCVSupply,
token?.decimals ?? 18,
);

// console.log({
// convictionFromContract,
// updatedConviction,
// convictionLast,
// maxCVSupply: proposalData.strategy.maxCVSupply,
// stakedAmount: proposalData.stakedAmount,
// totalEffectiveActivePoints:
// proposalData.strategy.totalEffectiveActivePoints,
// });

logOnce("debug", "Conviction computed numbers", {
thresholdPct,
totalSupportPct,
currentConvictionPct,
updateConvictionLast,
});

return {
thresholdPct,
totalSupportPct,
currentConvictionPct,
updateConvictionLast,
updatedConviction,
};
};
2 changes: 1 addition & 1 deletion pkg/contracts/out/Allo.sol/Allo.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/CVStrategyV0_0.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/IPointStrategy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/StrategyStruct.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20.sol/ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/FAllo.sol/FAllo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/GV2ERC20.sol/GV2ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IAllo.sol/IAllo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IArbitrator.sol/IArbitrator.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Metadata.sol/IERC20Metadata.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Permit.sol/IERC20Permit.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IRegistry.sol/IRegistry.json

Large diffs are not rendered by default.

Loading
Loading