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

UI allowlist #410

Merged
merged 76 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
38b29b4
feat: AllowListInput
Lucianosc Sep 7, 2024
922eab2
add AllowList in PoolForm
Lucianosc Sep 7, 2024
2a6428e
feat AllowList finished
Lucianosc Sep 8, 2024
2f28cf9
Merge commit 'e819f80af6b882b5abb5492dbf73bc755f8bce4f' into ui-allow…
Lucianosc Sep 8, 2024
d788a47
fix PoolForm
Lucianosc Sep 9, 2024
9aca812
fix Button tooltip
Lucianosc Sep 9, 2024
308d167
add subgraph query
Lucianosc Sep 9, 2024
b0fd0c9
feat useCheckllowList
Lucianosc Sep 9, 2024
3843afc
add check allow list implementation
Lucianosc Sep 9, 2024
4fe4fcc
fix sybil resistance order section
Lucianosc Sep 9, 2024
5ea06c2
Merge remote-tracking branch 'origin/allowlist-feature' into ui-allow…
Lucianosc Sep 12, 2024
696bf95
PR fixes
Lucianosc Sep 12, 2024
a48dd93
fixes & clean up
Lucianosc Sep 12, 2024
dc3669f
add sybil resistance restriction for pooltypes
Lucianosc Sep 13, 2024
a1565d6
Change abi to v0_1
Corantin Sep 13, 2024
5b8ed37
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Sep 15, 2024
c128f8a
Merge remote-tracking branch 'origin/allowlist-feature' into ui-allow…
Corantin Sep 16, 2024
3cf4fa7
Merge remote-tracking branch 'origin/dev' into ui-allowlist
Lucianosc Sep 17, 2024
eb4a3ca
wip add sybil resistance inputs in PoolEditForm
Lucianosc Sep 19, 2024
07ae011
minor fixes
Lucianosc Sep 19, 2024
7021296
add fetch passport score in PoolEditForm
Lucianosc Sep 19, 2024
7030770
Merge remote-tracking branch 'origin/dev' into ui-allowlist
Lucianosc Sep 23, 2024
e3acea6
final fix
Lucianosc Sep 24, 2024
a0c199d
add modifyThreshold
Lucianosc Sep 25, 2024
2b2ba3e
build fix
Lucianosc Sep 25, 2024
b99a4d2
Merge branch 'allowlist-feature' into ui-allowlist
Lucianosc Sep 25, 2024
8dad1c6
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Sep 25, 2024
5efd3b6
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Sep 25, 2024
61bcd14
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Sep 26, 2024
81409d7
fix PoolEditForm
Lucianosc Sep 26, 2024
a8d32e3
Fix
Corantin Sep 29, 2024
77afbe6
Merge remote-tracking branch 'origin/ui-allowlist' into ui-allowlist
Lucianosc Oct 1, 2024
ba9811a
minor fix PoolForm
Lucianosc Oct 1, 2024
02a9a01
minor fixes
Lucianosc Oct 1, 2024
3af644b
Fix abi function selection + fix pasport threshold not being added to…
Corantin Oct 3, 2024
c703e3e
Merge remote-tracking branch 'origin/allowlist-feature' into ui-allow…
Corantin Oct 3, 2024
fa2684e
Test change precision to 14
Corantin Oct 3, 2024
5233092
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Oct 4, 2024
40d7c3a
Revert "Test change precision to 14"
Corantin Oct 4, 2024
c1d2ad1
Fix typing from subgraph
Corantin Oct 4, 2024
27ee5a4
Update prod subgraph
Corantin Oct 4, 2024
5b8ad9b
Fix allowing all not set in form value
Corantin Oct 4, 2024
c69070c
Merge branch 'dev' into ui-allowlist
Corantin Oct 9, 2024
7b6a1e5
Build contracts
Corantin Oct 9, 2024
602278f
refactor: update type definitions and streamline imports.
Corantin Oct 9, 2024
3cb0e74
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Oct 9, 2024
870572d
feat: Enhance subgraph schema for collateral management.
Corantin Oct 9, 2024
913120d
:recycle: Refactor GoBackButton navigation logic
Corantin Oct 10, 2024
92e0247
:art: Updated styling for MarkdownEditor
Corantin Oct 10, 2024
4d5bc3d
:recycle: Simplified import and removed unused code
Corantin Oct 10, 2024
fb8ede5
Lock file update
Corantin Oct 10, 2024
62ba2c4
Merge from dev
Corantin Oct 10, 2024
272d611
:bug: Fixed null poolTokenAddress issue
Corantin Oct 10, 2024
de0aa83
Merge branch 'allowlist-feature' into ui-allowlist
Corantin Oct 10, 2024
cc7df62
Merge pull request #464 from 1Hive/enhance-back-button
Corantin Oct 10, 2024
6a966c9
Merge remote-tracking branch 'origin/dev' into ui-allowlist
Corantin Oct 10, 2024
9c2e535
Auto stash before merge of "ui-allowlist" and "origin/dev"
Corantin Oct 10, 2024
0868c93
:recycle: Refactored form input components
Corantin Oct 10, 2024
7880a77
:recycle: Refactored form components for better reusability
Corantin Oct 10, 2024
fbf40ca
Fix readme
Corantin Oct 10, 2024
ae99964
:sparkles: Added cron job and API key validation
Corantin Oct 11, 2024
baf8546
:truck: Moved .vercel.json to apps/web for vercel detection
Corantin Oct 11, 2024
30a8a99
:truck: Move to web folder and rename to vercel.json
Corantin Oct 11, 2024
f3b4175
:recycle: Refactored code to support multiple chains
Corantin Oct 11, 2024
c556a98
:lock: Updated API key handling
Corantin Oct 11, 2024
9670645
:alarm_clock: Updated job schedule in vercel.json
Corantin Oct 11, 2024
8cd160d
:recycle: Refactored daily job route for multi-chain support
Corantin Oct 11, 2024
a77169a
Merge from dev
Corantin Oct 11, 2024
6b98db6
:recycle: Refactored code for multi-chain support and improved UI
Corantin Oct 14, 2024
906f077
Build contracts
Corantin Oct 14, 2024
baea356
:recycle: Refactored code to improve passport scoring system
Corantin Oct 14, 2024
d6971e5
:rotating_light: Fix compile
Corantin Oct 14, 2024
b3e58da
:recycle: Updated PoolGovernance component
Corantin Oct 14, 2024
c707f61
:rotating_light: Fix compile
Corantin Oct 14, 2024
420f7cc
:recycle: Refactored error messages and improved code readability
Corantin Oct 15, 2024
eaea92f
:recycle: Refactored code for better readability and efficiency
Corantin Oct 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useCollectQueryParams } from "@/hooks/useCollectQueryParams";
import { useMetadataIpfsFetch } from "@/hooks/useIpfsFetch";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";
import { PoolTypes } from "@/types";
import { CV_SCALE_PRECISION } from "@/utils/numbers";

export const dynamic = "force-dynamic";

Expand Down Expand Up @@ -98,13 +97,10 @@ export default function Page({
return <div className="mt-52 text-center">Pool {poolId} not found</div>;
}

const pointSystem = data.cvstrategies?.[0].config.pointSystem;
const communityAddress = strategyObj.registryCommunity.id as Address;
const alloInfo = data.allos[0];
const proposalType = strategyObj.config.proposalType;
const poolAmount = strategyObj.poolAmount as number;
const spendingLimitPct =
(Number(strategyObj.config.maxRatio || 0) / CV_SCALE_PRECISION) * 100;

const isEnabled = data.cvstrategies?.[0]?.isEnabled as boolean;

Expand All @@ -118,10 +114,7 @@ export default function Page({
poolId={poolId}
ipfsResult={ipfsResult}
isEnabled={isEnabled}
pointSystem={pointSystem}
chainId={chain}
proposalType={proposalType}
spendingLimitPct={spendingLimitPct}
/>
{isEnabled && (
<>
Expand Down
20 changes: 15 additions & 5 deletions apps/web/components/ActivatePoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
import React from "react";
import { useConnectModal } from "@rainbow-me/rainbowkit";
import { Address, useAccount } from "wagmi";
import { CVStrategy, CVStrategyConfig } from "#/subgraph/.graphclient";
import { Button } from "./Button";
import { usePubSubContext } from "@/contexts/pubsub.context";
import { useChainIdFromPath } from "@/hooks/useChainIdFromPath";
import useCheckAllowList from "@/hooks/useCheckAllowList";
import { useContractWriteWithConfirmations } from "@/hooks/useContractWriteWithConfirmations";
import { ConditionObject, useDisableButtons } from "@/hooks/useDisableButtons";
import { cvStrategyABI } from "@/src/generated";
import { abiWithErrors } from "@/utils/abiWithErrors";
import { useErrorDetails } from "@/utils/getErrorName";

type ActiveMemberProps = {
strategyAddress: Address;
strategy: Pick<CVStrategy, "id"> & {
config: Pick<CVStrategyConfig, "allowlist">;
};
communityAddress: Address;
isMemberActivated: boolean | undefined;
isMember: boolean | undefined;
};

export function ActivatePoints({
strategyAddress,
strategy,
communityAddress,
isMember,
isMemberActivated,
Expand All @@ -29,11 +33,13 @@ export function ActivatePoints({
const { openConnectModal } = useConnectModal();
const chainId = useChainIdFromPath();
const { publish } = usePubSubContext();
const allowList = (strategy?.config?.allowlist as Address[]) ?? [];
const isAllowed = useCheckAllowList(allowList, connectedAccount);

const { write: writeActivatePoints, error: errorActivatePoints } =
useContractWriteWithConfirmations({
chainId,
address: strategyAddress,
address: strategy.id as Address,
contractName: "CV Strategy",
abi: abiWithErrors(cvStrategyABI),
functionName: "activatePoints",
Expand All @@ -52,7 +58,7 @@ export function ActivatePoints({

const { write: writeDeactivatePoints, error: errorDeactivatePoints } =
useContractWriteWithConfirmations({
address: strategyAddress,
address: strategy.id as Address,
abi: abiWithErrors(cvStrategyABI),
contractName: "CV Strategy",
functionName: "deactivatePoints",
Expand Down Expand Up @@ -92,6 +98,10 @@ export function ActivatePoints({
condition: !isMember,
message: "Join community to activate points",
},
{
condition: !isAllowed,
message: "Address not in allowlist",
},
];

const disableActiveBtn = disableActiveBtnCondition.some(
Expand All @@ -107,7 +117,7 @@ export function ActivatePoints({
onClick={handleChange}
btnStyle={isMemberActivated ? "outline" : "filled"}
color={isMemberActivated ? "danger" : "primary"}
disabled={missmatchUrl || disableActiveBtn}
disabled={missmatchUrl || disableActiveBtn || !isAllowed}
tooltip={String(tooltipMessage)}
>
{isMemberActivated ? "Deactivate governance" : "Activate governance"}
Expand Down
13 changes: 10 additions & 3 deletions apps/web/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ type ButtonProps = {
btnStyle?: BtnStyle;
color?: Color;
onClick?: React.DOMAttributes<HTMLButtonElement>["onClick"];
showToolTip?: boolean;
className?: string;
disabled?: boolean;
tooltip?: string;
tooltipClassName?: string;
tooltipSide?:
| "tooltip-top"
| "tooltip-bottom"
Expand Down Expand Up @@ -70,7 +72,9 @@ export function Button({
onClick,
className: styles,
disabled = false,
tooltip = "Connect wallet",
tooltip,
showToolTip = false,
tooltipClassName: tooltipStyles,
tooltipSide = "tooltip-top",
children,
btnStyle = "filled",
Expand Down Expand Up @@ -98,8 +102,11 @@ export function Button({
</button>
);

return disabled ?
<div className={`tooltip ${tooltipSide} ${styles}`} data-tip={tooltip}>
return disabled || showToolTip ?
<div
className={`tooltip ${tooltipSide} ${tooltipStyles}`}
data-tip={tooltip}
>
{buttonElement}
</div>
: buttonElement;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/CheckPassport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function CheckPassport({
) => {
_score = Number(_score);
setScore(_score);
if (score > threshold) {
if (score >= threshold) {
console.debug("Score meets threshold, moving forward...");
} else {
console.debug("Score is too low, opening modal...");
Expand Down
Loading
Loading