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

Update ODS to 1.0.20 #99

Merged
merged 9 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
Binary file modified bun.lockb
Binary file not shown.
5 changes: 1 addition & 4 deletions components/WalletContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Avatar, Card, Link } from "@aragon/ods";
import { useAccount, useEnsName, useEnsAvatar } from "wagmi";
import { Address } from "viem"
import { formatHexString } from "@/utils/evm";
import { useSkipFirstRender } from "@/hooks/useSkipFirstRender";
import { normalize } from 'viem/ens'
import { createClient, http } from 'viem'
import { createConfig } from 'wagmi'
Expand All @@ -14,6 +13,7 @@ import {

const config = createConfig({
chains: [mainnet],
ssr: true,
brickpop marked this conversation as resolved.
Show resolved Hide resolved
client({ chain }) {
return createClient({ chain, transport: http('https://eth-mainnet.g.alchemy.com/v2/' + PUB_ALCHEMY_API_KEY, { batch: true }) })
},
Expand All @@ -34,9 +34,6 @@ const WalletContainer = () => {
})
const { open } = useWeb3Modal();

const skipRender = useSkipFirstRender();
if (skipRender) return <></>;

return (
<Card className="
px-1 py-1 flex items-center border border-neutral-200 !rounded-full hover:drop-shadow cursor-pointer
Expand Down
4 changes: 0 additions & 4 deletions components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import { useWeb3Modal } from "@web3modal/wagmi/react";
import { Button } from "@aragon/ods";
import { useAccount } from "wagmi";
import { Else, If, Then } from "@/components/if";
import { useSkipFirstRender } from "@/hooks/useSkipFirstRender";
import WalletContainer from "./WalletContainer";

const Header = () => {
const { isConnected } = useAccount();
const { open } = useWeb3Modal();

const skipRender = useSkipFirstRender();
if (skipRender) return <></>;

return (
<div className="flex flex-row-reverse w-full mt-5 h-14 md:h-24">
<If condition={isConnected}>
Expand Down
2 changes: 1 addition & 1 deletion context/Web3Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const metadata = {

export const config = createConfig({
chains: [PUB_CHAIN],
ssr: true,
brickpop marked this conversation as resolved.
Show resolved Hide resolved
transports: {
[PUB_CHAIN.id]: http(PUB_WEB3_ENDPOINT, { batch: true }),
},
Expand All @@ -33,5 +34,4 @@ export const config = createConfig({
injected({ shimDisconnect: true }),
// coinbaseWallet({ appName: metadata.name, appLogoUrl: metadata.icons[0] }),
],
// ssr: false,
});
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@
"deploy-dao": "bun ./scripts/deploy.ts"
},
"dependencies": {
"@aragon/ods": "1.0.15",
"@aragon/ods": "1.0.20",
"@shazow/whatsabi": "0.11.0",
"@tanstack/query-async-storage-persister": "^5.25.0",
"@tanstack/react-query": "^5.25.0",
"@tanstack/react-query-persist-client": "^5.25.0",
"@tanstack/query-async-storage-persister": "^5.28.8",
"@tanstack/react-query": "^5.28.8",
"@tanstack/react-query-persist-client": "^5.28.8",
"@typescript-eslint/eslint-plugin": "latest",
"@web3modal/wagmi": "^4.0.1",
"@web3modal/wagmi": "^4.1.1",
"dayjs": "^1.11.10",
"dompurify": "^3.0.8",
"dompurify": "^3.0.11",
"ipfs-http-client": "^60.0.1",
"next": "14.1.0",
"react": "^18",
"next": "14.1.4",
"react": "^18.2.0",
"react-blockies": "^1.4.1",
"react-dom": "^18",
"tailwindcss-fluid-type": "^2.0.3",
"viem": "^2.7.22",
"wagmi": "^2.5.6"
"react-dom": "^18.2.0",
"tailwindcss-fluid-type": "^2.0.6",
"viem": "^2.9.2",
"wagmi": "^2.5.12"
},
"devDependencies": {
"@aragon/osx-commons-configs": "^0.2.0",
"@types/dompurify": "^3.0.5",
"@types/node": "^20",
"@types/react": "^18",
"@types/node": "^20.11.30",
"@types/react": "^18.2.71",
"@types/react-blockies": "^1.4.4",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"dotenv": "^16.4.4",
"eslint": "^8.56.0",
"eslint-config-next": "14.0.2",
"postcss": "^8",
"@types/react-dom": "^18.2.22",
"autoprefixer": "^10.4.19",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-next": "14.1.4",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"tailwindcss": "^3.3.0",
"typescript": "^5"
"tailwindcss": "^3.4.1",
"typescript": "^5.4.3"
},
"prettier": {
"printWidth": 80,
Expand All @@ -55,4 +55,4 @@
"arrowParens": "always",
"useTabs": false
}
}
}
61 changes: 35 additions & 26 deletions plugins/dualGovernance/hooks/useCanCreateProposal.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { Address, keccak256, toHex } from "viem";
import { useState, useEffect } from "react";
import { useBalance, useAccount, useReadContracts, useConfig } from "wagmi";
import { readContract } from "@wagmi/core";
import {
useBalance,
useAccount,
useReadContracts,
useReadContract,
} from "wagmi";
import { OptimisticTokenVotingPluginAbi } from "@/plugins/dualGovernance/artifacts/OptimisticTokenVotingPlugin.sol";
import { DaoAbi } from "@/artifacts/DAO.sol";
import { PUB_CHAIN, PUB_DUAL_GOVERNANCE_PLUGIN_ADDRESS } from "@/constants";

export function useCanCreateProposal() {
const config = useConfig();
const { address } = useAccount();
if (!address) return false;
xavikh marked this conversation as resolved.
Show resolved Hide resolved

const [minProposerVotingPower, setMinProposerVotingPower] =
useState<bigint>();
const [votingToken, setVotingToken] = useState<Address>();
const [daoAddress, setDaoAddress] = useState<Address>();
const [hasCreatePermission, setHasCreatePermission] = useState(false);
const [votingToken, setVotingToken] = useState<Address>();
const [daoAddress, setDaoAddress] = useState<Address>();
const [hasCreatePermission, setHasCreatePermission] = useState(false);
const { data: balance } = useBalance({
address,
token: votingToken,
Expand Down Expand Up @@ -44,6 +49,25 @@ export function useCanCreateProposal() {
],
});

// Check if PROPOSER_PERMISSION is granted to the current wallet
const {
data: hasCreatePermissionData,
refetch: hasCreatePermissionRefetch,
status: hasCreatePermissionStatus,
} = useReadContract({
chainId: PUB_CHAIN.id,
address: daoAddress,
abi: DaoAbi,
functionName: "hasPermission",
// where, who, permissionId, data
args: [
PUB_DUAL_GOVERNANCE_PLUGIN_ADDRESS,
address,
keccak256(toHex("PROPOSER_PERMISSION")),
"0x",
],
});
xavikh marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (!contractReads?.length || contractReads?.length < 2) return;

Expand All @@ -56,29 +80,14 @@ export function useCanCreateProposal() {
contractReads?.[2]?.status,
]);

useEffect(() => {
setHasCreatePermission(!!hasCreatePermissionData);
}, [hasCreatePermissionStatus]);
Fabricevladimir marked this conversation as resolved.
Show resolved Hide resolved

// Check if PROPOSER_PERMISSION is granted to the current wallet
useEffect(() => {
if (!address || !daoAddress) return;

readContract(config, {
chainId: PUB_CHAIN.id,
address: daoAddress,
abi: DaoAbi,
functionName: "hasPermission",
// where, who, permissionId, data
args: [
PUB_DUAL_GOVERNANCE_PLUGIN_ADDRESS,
address,
keccak256(toHex("PROPOSER_PERMISSION")),
"0x",
],
})
.then((result) => {
setHasCreatePermission(!!result);
})
.catch((err) => {
console.error(err);
});
hasCreatePermissionRefetch();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about enabling/disabling query

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook is to update the values in case the wallet address changes

}, [daoAddress, address]);

if (!address) return false;
Expand Down
1 change: 1 addition & 0 deletions plugins/dualGovernance/hooks/useProposalVeto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function useProposalVeto(proposalId: string) {
timeout: 4 * 1000,
});
} else {
console.error(vetoingError);
addAlert("Could not create the proposal", { type: "error" });
}
return;
Expand Down
1 change: 1 addition & 0 deletions plugins/dualGovernance/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Create() {
timeout: 4 * 1000,
});
} else {
console.error(error);
addAlert("Could not create the proposal", { type: "error" });
}
return;
Expand Down
1 change: 1 addition & 0 deletions plugins/lockToVote/hooks/useProposalVeto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function useProposalVeto(proposalId: string) {
timeout: 4 * 1000,
});
} else {
console.error(vetoingError);
addAlert("Could not create the veto", { type: "error" });
}
return;
Expand Down
1 change: 1 addition & 0 deletions plugins/lockToVote/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Create() {
timeout: 4 * 1000,
});
} else {
console.error(error);
addAlert("Could not create the proposal", { type: "error" });
}
return;
Expand Down
1 change: 1 addition & 0 deletions plugins/tokenVoting/hooks/useProposalVoting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function useProposalVoting(proposalId: string) {
timeout: 4 * 1000,
});
} else {
console.error(votingError);
addAlert("Could not create the proposal", { type: "error" });
}
return;
Expand Down
1 change: 1 addition & 0 deletions plugins/tokenVoting/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Create() {
timeout: 4 * 1000,
});
} else {
console.error(error);
addAlert("Could not create the proposal", { type: "error" });
}
return;
Expand Down
Loading