Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Corantin committed Nov 10, 2024
2 parents 456175c + e5c3f73 commit 16a4047
Show file tree
Hide file tree
Showing 104 changed files with 81,308 additions and 3,370 deletions.
619 changes: 619 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/web/components/IncreasePower.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const IncreasePower = ({
status: "idle",
}));
setIsOpenModal(true);
handleAllowance();
handleAllowance({});
}

const isInputIncreaseGreaterThanBalance =
Expand Down Expand Up @@ -201,7 +201,7 @@ export const IncreasePower = ({
tokenSymbol,
communityAddress as Address,
parseUnits(amount, tokenDecimals),
writeIncreasePower,
() => writeIncreasePower(),
);

// useEffect(() => {
Expand Down
6 changes: 4 additions & 2 deletions apps/web/components/PoolMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const PoolMetrics: FC<PoolMetricsProps> = ({
poolToken.symbol,
alloInfo.id as Address,
requestedAmount,
writeFundPool,
() => writeFundPool(),
);

const { tooltipMessage, missmatchUrl } = useDisableButtons();
Expand All @@ -113,7 +113,9 @@ export const PoolMetrics: FC<PoolMetricsProps> = ({
status: "idle",
}));
setIsOpenModal(true);
handleAllowance(parseUnits(data.amount.toString(), poolToken.decimals));
handleAllowance({
formAmount: parseUnits(data.amount.toString(), poolToken.decimals),
});
};

return (
Expand Down
26 changes: 15 additions & 11 deletions apps/web/components/Proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,21 @@ export function Proposals({
</div>
: <div>
<div className="flex items-center justify-center gap-6">
<CheckPassport strategy={strategy}>
<Link href={createProposalUrl}>
<Button
icon={<PlusIcon height={24} width={24} />}
disabled={!isConnected || missmatchUrl || !isAllowed}
tooltip="Address not in allowlist"
>
Create a proposal
</Button>
</Link>
</CheckPassport>
<Link href={createProposalUrl}>
<Button
icon={<PlusIcon height={24} width={24} />}
disabled={!isConnected || missmatchUrl || !isMemberCommunity}
tooltip={
isConnected ?
isMemberCommunity ?
undefined
: "Register to community first"
: "Connect wallet first"
}
>
Create a proposal
</Button>
</Link>
</div>
</div>
}
Expand Down
9 changes: 3 additions & 6 deletions apps/web/components/RegisterMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,14 @@ export function RegisterMember({
token.symbol,
communityAddress as Address,
registrationCost,
() => handleRegistration(covenantSignature),
handleRegistration,
);

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

const {
covenantAgreementTxProps: covenantAgreementTx,
handleSignature,
covenantSignature,
} = useCovenantAgreementSignature(message, handleAllowance);
const { covenantAgreementTxProps: covenantAgreementTx, handleSignature } =
useCovenantAgreementSignature(message, handleAllowance);

const handleClick = useCallback(() => {
if (isMember) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/configs/chains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export const chainConfigMap: {
),
globalTribunal: "0xb05A948B5c1b057B88D381bDe3A375EfEA87EbAD",
allo: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1",
arbitrator: "0xe32566076534973ff78b512ec6a321a58c2b735c",
passportScorer: "0xfF53a163e43EccC00d8FdE7acA24aa9FA4da7356",
arbitrator: "0x5534fecacd5f84e22c0aba9ea9813ff594d37262",
passportScorer: "0x32fe66622a4d4607241ac723e23fef487acdabb5",
isTestnet: true,
},
// 11155111: {
Expand Down
9 changes: 2 additions & 7 deletions apps/web/hooks/useCovenantAgreementSignature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ interface CustomError extends Error {

export function useCovenantAgreementSignature(
message: string,
triggerNextTx: () => void,
triggerNextTx: (args: { covenantSignature: `0x${string}` }) => void,
): {
covenantAgreementTxProps: TransactionProps;
covenantSignature: `0x${string}` | undefined;
handleSignature: () => void;
} {
const [covenantSignatureState, setCovenantSignature] =
useState<`0x${string}`>();
const path = usePathname();
const CovenantTitle = (
<div className="flex gap-2">
Expand Down Expand Up @@ -60,8 +57,7 @@ export function useCovenantAgreementSignature(
message: getTxMessage("success"),
status: "success",
});
setCovenantSignature(data);
triggerNextTx();
triggerNextTx({ covenantSignature: data });
}
},
});
Expand All @@ -78,7 +74,6 @@ export function useCovenantAgreementSignature(

return {
covenantAgreementTxProps,
covenantSignature: covenantSignatureState,
handleSignature: signMessage,
};
}
23 changes: 16 additions & 7 deletions apps/web/hooks/useHandleAllowance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import { noop } from "lodash-es";
import { Address, useContractRead } from "wagmi";
import { useChainIdFromPath } from "./useChainIdFromPath";
import { useContractWriteWithConfirmations } from "./useContractWriteWithConfirmations";
Expand All @@ -13,10 +14,13 @@ export function useHandleAllowance(
tokenSymbol: string,
spenderAddr: Address,
amount: bigint,
triggerNextTx: () => void,
triggerNextTx: (covenantSignature: `0x${string}` | undefined) => void,
): {
allowanceTxProps: TransactionProps;
handleAllowance: (formAmount?: bigint) => void;
handleAllowance: (args: {
formAmount?: bigint;
covenantSignature?: `0x${string}`;
}) => void;
resetState: () => void;
} {
const chainId = useChainIdFromPath();
Expand All @@ -25,6 +29,7 @@ export function useHandleAllowance(
message: "",
status: "idle",
});
const [onSuccess, setOnSuccess] = useState<() => void>(noop);

const { refetch: refetchAllowance } = useContractRead({
chainId,
Expand All @@ -48,12 +53,16 @@ export function useHandleAllowance(
showNotification: false,
});

const handleAllowance = async (formAmount?: bigint) => {
const handleAllowance = async (args: {
formAmount?: bigint;
covenantSignature?: `0x${string}`;
}) => {
const currentAllowance = await refetchAllowance();
if (formAmount) {
amount = formAmount;
if (args.formAmount) {
amount = args.formAmount;
}
if (!currentAllowance?.data || currentAllowance.data < amount) {
setOnSuccess(() => triggerNextTx(args.covenantSignature));
writeAllowToken({ args: [spenderAddr, amount] });
} else {
await delayAsync(1000);
Expand All @@ -62,7 +71,7 @@ export function useHandleAllowance(
message: getTxMessage("success"),
status: "success",
});
triggerNextTx();
triggerNextTx(args.covenantSignature);
}
};

Expand All @@ -73,7 +82,7 @@ export function useHandleAllowance(
status: transactionStatus ?? "idle",
});
if (transactionStatus === "success") {
triggerNextTx();
delayAsync(2000).then(() => onSuccess());
}
}, [transactionStatus]);

Expand Down
1 change: 0 additions & 1 deletion apps/web/hooks/useHandleRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export function useHandleRegistration(

const handleRegistration = useCallback(
(covenantSignature: `0x${string}` | undefined) => {
console.log({ covenantSignature });
if (!covenantSignature) {
toast.error("Covenant signature is required");
return;
Expand Down
2,535 changes: 2,535 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1730500346.json

Large diffs are not rendered by default.

2,535 changes: 2,535 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1730504448.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion broadcast/DeployCVMultiChain.s.sol/421614/run-latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,7 @@
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1729404896,
"timestamp": 1730504448,
"chain": 421614,
"commit": "aaf9065d"
}
Loading

0 comments on commit 16a4047

Please sign in to comment.