Skip to content

Commit

Permalink
Merge pull request #11 from aragon/f/delegation-wall
Browse files Browse the repository at this point in the history
Delegation wall
  • Loading branch information
brickpop authored Jul 15, 2024
2 parents 03b371a + 60aa1f9 commit 6221c8d
Show file tree
Hide file tree
Showing 46 changed files with 1,533 additions and 765 deletions.
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ NEXT_PUBLIC_DAO_ADDRESS=0x464E808De86C90Ea0423854cABE887b6AEF85c1E
NEXT_PUBLIC_TOKEN_ADDRESS=0x7Ae1BbFfF99316922cebC74C9465d8E3Cdfc65e3

# Plugin addresses
NEXT_PUBLIC_MULTISIG_PLUGIN_ADDRESS=0x07d0ac4ef82cA8E799BAB1f07f5e4f1De933E88C
NEXT_PUBLIC_EMERGENCY_MULTISIG_PLUGIN_ADDRESS=0x143209C5fc8004c4B41cA7Bd27666d884B35c809
NEXT_PUBLIC_DUAL_GOVERNANCE_PLUGIN_ADDRESS=0x73aA4dBD85eca05542013dcd893CC9DD0c681184
NEXT_PUBLIC_PUBLIC_KEY_REGISTRY_CONTRACT_ADDRESS=0xD4615654030982779AC1DD0ff3e69FCD8f8b702d
NEXT_PUBLIC_DELEGATION_WALL_CONTRACT_ADDRESS=0x32ccaee7288e43128C99B5505e6B9cF395ED8b64
NEXT_PUBLIC_MULTISIG_PLUGIN_ADDRESS=0x284F47A42f1Eb96f0F1540931F8Ef04F4243Fb33
NEXT_PUBLIC_EMERGENCY_MULTISIG_PLUGIN_ADDRESS=0x0E09bFDA087cf60Bd03A767A03bf88e9E3824c39
NEXT_PUBLIC_DUAL_GOVERNANCE_PLUGIN_ADDRESS=0xf52B4681F1eB88C5b028510a3F365b5d04fa3295
NEXT_PUBLIC_PUBLIC_KEY_REGISTRY_CONTRACT_ADDRESS=0x3b1a9c9198eF98d987A6361219FC59c3F805537d
NEXT_PUBLIC_DELEGATION_WALL_CONTRACT_ADDRESS=0xfdFd89FA33B92Cd1c49A2Ae452294Bc2C89f810D

NEXT_PUBLIC_TAIKO_BRIDGE_ADDRESS=0x1234567890123456789012345678901234567890

Expand Down
Binary file modified bun.lockb
Binary file not shown.
5 changes: 1 addition & 4 deletions components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ export const Layout: React.FC<{ children: ReactNode }> = (props) => {
<div className="flex flex-col items-center gap-20">
<div className="flex w-full flex-col items-center">
<Navbar />
{/*<div className="flex w-full flex-col items-center px-4 py-6 md:w-4/5 md:p-6 lg:w-2/3 xl:py-10 2xl:w-3/5">*/}
<div className="flex w-full flex-col items-center">{props.children}</div>
<div className="w-full">{props.children}</div>
</div>

{/* Footer */}
</div>
);
};
13 changes: 13 additions & 0 deletions components/layout/main-section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import classNames from "classnames";
import React, { type ReactNode } from "react";

interface IMainSectionProps {
children?: ReactNode;
className?: string;
}

export const MainSection: React.FC<IMainSectionProps> = (props) => {
const { children, className } = props;

return <div className={classNames("mx-auto w-full max-w-screen-xl px-4 py-6", className)}>{children}</div>;
};
5 changes: 5 additions & 0 deletions components/layout/section-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { type ReactNode } from "react";

export function SectionView({ children }: { children: ReactNode }) {
return <div className="mb-6 flex w-full flex-row content-center justify-between">{children}</div>;
}
4 changes: 2 additions & 2 deletions components/nav/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Navbar: React.FC = () => {
<Link
href="/"
className={classNames(
"ml-10 flex items-center gap-x-5 rounded-full py-3 pb-5 md:rounded-lg",
"flex items-center gap-x-5 rounded-full py-3 pb-5 md:rounded-lg lg:ml-10",
"outline-none focus:outline-none focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset" // focus styles
)}
>
Expand Down Expand Up @@ -63,7 +63,7 @@ export const Navbar: React.FC = () => {
</div>

{/* Tab wrapper */}
<ul className="hidden gap-x-10 md:flex lg:pl-14">
<ul className="hidden gap-x-10 md:flex lg:pl-10">
{navLinks.map(({ id, name, path }) => (
<NavLink name={name} path={path} id={id} key={id} />
))}
Expand Down
4 changes: 2 additions & 2 deletions components/proposal/proposalBodySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export const BodySection: React.FC<IBodySectionProps> = (props) => {

return (
<CardCollapsible
buttonLabelClosed="Read full PIP"
buttonLabelClosed="Expend description"
buttonLabelOpened="Read less"
collapsedSize="md"
className="w-full shadow-neutral"
>
<div className="flex flex-col gap-y-4">
<Heading size="h2">Proposal description</Heading>
<hr className="rounded-full border-neutral-100" />
<hr className="border-neutral-100" />
<DocumentParser document={body} className={proseClasses} />
</div>
</CardCollapsible>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ export const BreakdownApprovalThresholdResult: React.FC<IBreakdownApprovalThresh
{/* Button */}
{cta && (
<span>
<Button
size="md"
className="!rounded-full"
disabled={cta.disabled}
onClick={() => cta.onClick?.()}
isLoading={cta.isLoading}
>
<Button size="md" disabled={cta.disabled} onClick={() => cta.onClick?.()} isLoading={cta.isLoading}>
{cta?.label}
</Button>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,12 @@ export const BreakdownMajorityVotingResult: React.FC<IBreakdownMajorityVotingRes
{/* Button group */}
{cta && (
<div className="flex w-full flex-col gap-y-4 md:flex-row md:gap-x-4">
<Button
size="md"
className="!rounded-full"
disabled={disabled}
onClick={handleVoteClick}
isLoading={cta.isLoading}
>
<Button size="md" disabled={disabled} onClick={handleVoteClick} isLoading={cta.isLoading}>
{label}
</Button>

{showOptions && (
<Button size="md" className="!rounded-full" onClick={() => setShowOptions(false)} variant="tertiary">
<Button size="md" onClick={() => setShowOptions(false)} variant="tertiary">
Cancel
</Button>
)}
Expand Down
1 change: 1 addition & 0 deletions constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const DETERMINISTIC_EMERGENCY_PAYLOAD =
// General
export const PUB_APP_NAME = "Taiko";
export const PUB_APP_DESCRIPTION = "Taiko's official UI to interact with the DAO smart contract";
export const PUB_TOKEN_SYMBOL = "TKO";

export const PUB_PROJECT_LOGO = "/logo-tk.svg";
export const PUB_PROJECT_URL = "https://taiko.xyz/";
Expand Down
37 changes: 24 additions & 13 deletions hooks/useAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ export const useAbi = (contractAddress: Address) => {
error,
} = useQuery<AbiFunction[], Error>({
queryKey: ["abi", resolvedAddress || "", !!publicClient],
queryFn: () => {
queryFn: async () => {
if (!resolvedAddress || !isAddress(resolvedAddress) || !publicClient) {
return Promise.resolve([]);
return [];
} else if (!(await isContract(resolvedAddress, publicClient))) {
return [];
}

const abiLoader = getEtherscanAbiLoader();
return whatsabi
.autoload(resolvedAddress, {
provider: publicClient,
abiLoader,
abiLoader: getEtherscanAbiLoader(),
followProxies: false,
enableExperimentalMetadata: true,
})
Expand All @@ -68,15 +69,7 @@ export const useAbi = (contractAddress: Address) => {
type: item.type,
});
}
functionItems.sort((a, b) => {
const a_RO = ["pure", "view"].includes(a.stateMutability);
const b_RO = ["pure", "view"].includes(b.stateMutability);

if (a_RO === b_RO) return 0;
else if (a_RO) return 1;
else if (b_RO) return -1;
return 0;
});
functionItems.sort(abiSortCallback);
return functionItems;
})
.catch((err) => {
Expand Down Expand Up @@ -139,3 +132,21 @@ function getEtherscanAbiLoader() {
throw new Error("Unknown chain");
}
}

function isContract(address: Address, publicClient: ReturnType<typeof usePublicClient>) {
if (!publicClient) return Promise.reject(new Error("Invalid client"));

return publicClient.getCode({ address }).then((bytecode) => {
return bytecode !== undefined && bytecode !== "0x";
});
}

function abiSortCallback(a: AbiFunction, b: AbiFunction) {
const a_RO = ["pure", "view"].includes(a.stateMutability);
const b_RO = ["pure", "view"].includes(b.stateMutability);

if (a_RO === b_RO) return 0;
else if (a_RO) return 1;
else if (b_RO) return -1;
return 0;
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@aragon/ods": "1.0.30",
"@hookform/resolvers": "^3.9.0",
"@react-native-async-storage/async-storage": "^1.23.1",
"@shazow/whatsabi": "0.11.0",
"@tanstack/query-async-storage-persister": "^5.28.8",
Expand All @@ -40,6 +41,7 @@
"react": "^18.2.0",
"react-blockies": "^1.4.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.52.1",
"tailwindcss-fluid-type": "^2.0.6",
"viem": "2.17.0",
"wagmi": "2.10.9"
Expand Down
110 changes: 92 additions & 18 deletions plugins/delegateAnnouncer/artifacts/DelegateAnnouncer.sol.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,119 @@
export const DelegateAnnouncerAbi = [
{
anonymous: false,
type: "function",
name: "candidateAddresses",
inputs: [
{
indexed: true,
internalType: "address",
name: "dao",
type: "address",
name: "",
type: "uint256",
internalType: "uint256",
},
],
outputs: [
{
indexed: true,
name: "",
type: "address",
internalType: "address",
name: "delegate",
},
],
stateMutability: "view",
},
{
type: "function",
name: "candidateCount",
inputs: [],
outputs: [
{
name: "",
type: "uint256",
internalType: "uint256",
},
],
stateMutability: "view",
},
{
type: "function",
name: "candidates",
inputs: [
{
name: "",
type: "address",
internalType: "address",
},
],
outputs: [
{
indexed: false,
internalType: "bytes",
name: "message",
type: "bytes",
internalType: "bytes",
},
{
name: "socialUrl",
type: "bytes",
internalType: "bytes",
},
],
name: "AnnounceDelegation",
type: "event",
stateMutability: "view",
},
{
inputs: [
type: "function",
name: "getCandidateAddresses",
inputs: [],
outputs: [
{
internalType: "address",
name: "dao",
type: "address",
name: "",
type: "address[]",
internalType: "address[]",
},
],
stateMutability: "view",
},
{
type: "function",
name: "register",
inputs: [
{
name: "_message",
type: "bytes",
internalType: "bytes",
name: "message",
},
{
name: "_socialUrl",
type: "bytes",
internalType: "bytes",
},
],
name: "announceDelegation",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
type: "event",
name: "CandidateRegistered",
inputs: [
{
name: "candidate",
type: "address",
indexed: true,
internalType: "address",
},
{
name: "message",
type: "bytes",
indexed: false,
internalType: "bytes",
},
{
name: "socialUrl",
type: "bytes",
indexed: false,
internalType: "bytes",
},
],
anonymous: false,
},
{
type: "error",
name: "EmptyMessage",
inputs: [],
},
] as const;
1 change: 1 addition & 0 deletions plugins/delegateAnnouncer/artifacts/iVotes.sol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { parseAbi } from "viem";

export const iVotesAbi = parseAbi([
"function getVotes(address owner) view returns (uint256)",
"function balanceOf(address owner) view returns (uint256)",
"function delegate(address delegatee) external",
"function delegates(address account) public view returns (address)",
]);
Loading

0 comments on commit 6221c8d

Please sign in to comment.