Skip to content

Commit 09208bc

Browse files
authored
Merge pull request #489 from 1Hive/open-creation
Unrestricted proposal creation + Community params editable (contracts only)
2 parents 00aa527 + 47a7deb commit 09208bc

File tree

103 files changed

+80686
-3370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+80686
-3370
lines changed

apps/web/components/IncreasePower.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const IncreasePower = ({
146146
status: "idle",
147147
}));
148148
setIsOpenModal(true);
149-
handleAllowance();
149+
handleAllowance({});
150150
}
151151

152152
const isInputIncreaseGreaterThanBalance =
@@ -201,7 +201,7 @@ export const IncreasePower = ({
201201
tokenSymbol,
202202
communityAddress as Address,
203203
parseUnits(amount, tokenDecimals),
204-
writeIncreasePower,
204+
() => writeIncreasePower(),
205205
);
206206

207207
// useEffect(() => {

apps/web/components/PoolMetrics.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const PoolMetrics: FC<PoolMetricsProps> = ({
8787
poolToken.symbol,
8888
alloInfo.id as Address,
8989
requestedAmount,
90-
writeFundPool,
90+
() => writeFundPool(),
9191
);
9292

9393
const { tooltipMessage, missmatchUrl } = useDisableButtons();
@@ -113,7 +113,9 @@ export const PoolMetrics: FC<PoolMetricsProps> = ({
113113
status: "idle",
114114
}));
115115
setIsOpenModal(true);
116-
handleAllowance(parseUnits(data.amount.toString(), poolToken.decimals));
116+
handleAllowance({
117+
formAmount: parseUnits(data.amount.toString(), poolToken.decimals),
118+
});
117119
};
118120

119121
return (

apps/web/components/Proposals.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,17 +626,21 @@ export function Proposals({
626626
</div>
627627
: <div>
628628
<div className="flex items-center justify-center gap-6">
629-
<CheckPassport strategy={strategy}>
630-
<Link href={createProposalUrl}>
631-
<Button
632-
icon={<PlusIcon height={24} width={24} />}
633-
disabled={!isConnected || missmatchUrl || !isAllowed}
634-
tooltip="Address not in allowlist"
635-
>
636-
Create a proposal
637-
</Button>
638-
</Link>
639-
</CheckPassport>
629+
<Link href={createProposalUrl}>
630+
<Button
631+
icon={<PlusIcon height={24} width={24} />}
632+
disabled={!isConnected || missmatchUrl || !isMemberCommunity}
633+
tooltip={
634+
isConnected ?
635+
isMemberCommunity ?
636+
undefined
637+
: "Register to community first"
638+
: "Connect wallet first"
639+
}
640+
>
641+
Create a proposal
642+
</Button>
643+
</Link>
640644
</div>
641645
</div>
642646
}

apps/web/components/RegisterMember.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,14 @@ export function RegisterMember({
124124
token.symbol,
125125
communityAddress as Address,
126126
registrationCost,
127-
() => handleRegistration(covenantSignature),
127+
handleRegistration,
128128
);
129129

130130
const message = `You agree with the terms and conditions of ${communityName} covenant:
131131
https://ipfs.io/ipfs/${covenantIpfsHash}`;
132132

133-
const {
134-
covenantAgreementTxProps: covenantAgreementTx,
135-
handleSignature,
136-
covenantSignature,
137-
} = useCovenantAgreementSignature(message, handleAllowance);
133+
const { covenantAgreementTxProps: covenantAgreementTx, handleSignature } =
134+
useCovenantAgreementSignature(message, handleAllowance);
138135

139136
const handleClick = useCallback(() => {
140137
if (isMember) {

apps/web/configs/chains.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export const chainConfigMap: {
107107
),
108108
globalTribunal: "0xb05A948B5c1b057B88D381bDe3A375EfEA87EbAD",
109109
allo: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1",
110-
arbitrator: "0xe32566076534973ff78b512ec6a321a58c2b735c",
111-
passportScorer: "0xfF53a163e43EccC00d8FdE7acA24aa9FA4da7356",
110+
arbitrator: "0x5534fecacd5f84e22c0aba9ea9813ff594d37262",
111+
passportScorer: "0x32fe66622a4d4607241ac723e23fef487acdabb5",
112112
isTestnet: true,
113113
},
114114
// 11155111: {

apps/web/hooks/useContractWriteWithConfirmations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export function useContractWriteWithConfirmations<
100100
console.error(
101101
`Error with transaction [${props.contractName} -> ${props.functionName}]`,
102102
{
103+
errorJson: JSON.stringify(error),
103104
error,
105+
variablesJson: JSON.stringify(variables),
104106
variables,
105107
context,
106108
rawData,

apps/web/hooks/useCovenantAgreementSignature.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ interface CustomError extends Error {
1111

1212
export function useCovenantAgreementSignature(
1313
message: string,
14-
triggerNextTx: () => void,
14+
triggerNextTx: (args: { covenantSignature: `0x${string}` }) => void,
1515
): {
1616
covenantAgreementTxProps: TransactionProps;
17-
covenantSignature: `0x${string}` | undefined;
1817
handleSignature: () => void;
1918
} {
20-
const [covenantSignatureState, setCovenantSignature] =
21-
useState<`0x${string}`>();
2219
const path = usePathname();
2320
const CovenantTitle = (
2421
<div className="flex gap-2">
@@ -60,8 +57,7 @@ export function useCovenantAgreementSignature(
6057
message: getTxMessage("success"),
6158
status: "success",
6259
});
63-
setCovenantSignature(data);
64-
triggerNextTx();
60+
triggerNextTx({ covenantSignature: data });
6561
}
6662
},
6763
});
@@ -78,7 +74,6 @@ export function useCovenantAgreementSignature(
7874

7975
return {
8076
covenantAgreementTxProps,
81-
covenantSignature: covenantSignatureState,
8277
handleSignature: signMessage,
8378
};
8479
}

apps/web/hooks/useHandleAllowance.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useState } from "react";
2+
import { noop } from "lodash-es";
23
import { Address, useContractRead } from "wagmi";
34
import { useChainIdFromPath } from "./useChainIdFromPath";
45
import { useContractWriteWithConfirmations } from "./useContractWriteWithConfirmations";
@@ -13,10 +14,13 @@ export function useHandleAllowance(
1314
tokenSymbol: string,
1415
spenderAddr: Address,
1516
amount: bigint,
16-
triggerNextTx: () => void,
17+
triggerNextTx: (covenantSignature: `0x${string}` | undefined) => void,
1718
): {
1819
allowanceTxProps: TransactionProps;
19-
handleAllowance: (formAmount?: bigint) => void;
20+
handleAllowance: (args: {
21+
formAmount?: bigint;
22+
covenantSignature?: `0x${string}`;
23+
}) => void;
2024
resetState: () => void;
2125
} {
2226
const chainId = useChainIdFromPath();
@@ -25,6 +29,7 @@ export function useHandleAllowance(
2529
message: "",
2630
status: "idle",
2731
});
32+
const [onSuccess, setOnSuccess] = useState<() => void>(noop);
2833

2934
const { refetch: refetchAllowance } = useContractRead({
3035
chainId,
@@ -48,12 +53,16 @@ export function useHandleAllowance(
4853
showNotification: false,
4954
});
5055

51-
const handleAllowance = async (formAmount?: bigint) => {
56+
const handleAllowance = async (args: {
57+
formAmount?: bigint;
58+
covenantSignature?: `0x${string}`;
59+
}) => {
5260
const currentAllowance = await refetchAllowance();
53-
if (formAmount) {
54-
amount = formAmount;
61+
if (args.formAmount) {
62+
amount = args.formAmount;
5563
}
5664
if (!currentAllowance?.data || currentAllowance.data < amount) {
65+
setOnSuccess(() => triggerNextTx(args.covenantSignature));
5766
writeAllowToken({ args: [spenderAddr, amount] });
5867
} else {
5968
await delayAsync(1000);
@@ -62,7 +71,7 @@ export function useHandleAllowance(
6271
message: getTxMessage("success"),
6372
status: "success",
6473
});
65-
triggerNextTx();
74+
triggerNextTx(args.covenantSignature);
6675
}
6776
};
6877

@@ -73,7 +82,7 @@ export function useHandleAllowance(
7382
status: transactionStatus ?? "idle",
7483
});
7584
if (transactionStatus === "success") {
76-
triggerNextTx();
85+
delayAsync(2000).then(() => onSuccess());
7786
}
7887
}, [transactionStatus]);
7988

apps/web/hooks/useHandleRegistration.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export function useHandleRegistration(
5757

5858
const handleRegistration = useCallback(
5959
(covenantSignature: `0x${string}` | undefined) => {
60-
console.log({ covenantSignature });
6160
if (!covenantSignature) {
6261
toast.error("Covenant signature is required");
6362
return;

broadcast/DeployCVMultiChain.s.sol/421614/run-1730500346.json

Lines changed: 2535 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployCVMultiChain.s.sol/421614/run-1730504448.json

Lines changed: 2535 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployCVMultiChain.s.sol/421614/run-latest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@
25292529
"libraries": [],
25302530
"pending": [],
25312531
"returns": {},
2532-
"timestamp": 1729404896,
2532+
"timestamp": 1730504448,
25332533
"chain": 421614,
25342534
"commit": "aaf9065d"
25352535
}

0 commit comments

Comments
 (0)