Skip to content

Commit 7bd34ec

Browse files
committed
feat(maci): cache joinedPoll data
1 parent 6f00478 commit 7bd34ec

File tree

11 files changed

+19408
-4234
lines changed

11 files changed

+19408
-4234
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NEXT_PUBLIC_SECONDS_PER_BLOCK="1"
1414
NEXT_PUBLIC_COORDINATOR_SERVICE_URL="http://localhost:3000/v1"
1515

1616
# UX improvements
17-
NEXT_MINIMUM_START_DELAY_IN_SECONDS="60" # coordinator service scheduler needs a bit of time to process
17+
NEXT_MINIMUM_START_DELAY_IN_SECONDS="30"
1818

1919
# Network and services
2020
NEXT_PUBLIC_CHAIN_NAME="arbitrumSepolia"

bun.lock

Lines changed: 19211 additions & 4127 deletions
Large diffs are not rendered by default.

components/nav/mobileNavDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const MobileNavDialog: React.FC<IMobileNavDialogProps> = (props) => {
2626
>
2727
<span className="flex py-2 pl-3 pr-4">
2828
Powered by <span className="mr-1 text-primary-400">&nbsp;Aragon</span>
29-
<Image src="/logo.png" width="24" height="24" alt="Aragonette" />
29+
<Image src="/logo.png" width="24" height="24" alt="Aragon - MACI Plugin" />
3030
</span>
3131
</Link>
3232
</div>

components/nav/navbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export const Navbar: React.FC = () => {
3232
"outline-none focus:outline-none focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset" // focus styles
3333
)}
3434
>
35-
<Image src="/logo-bw-lg.png" width="36" height="36" className="shrink-0" alt="Aragonette" />
35+
<Image src="/logo-bw-lg.png" width="36" height="36" className="shrink-0" alt="Aragon - MACI Plugin" />
3636
<span className="hidden py-1 text-lg font-semibold leading-tight text-neutral-700 sm:block md:text-xl">
37-
Aragonette
37+
Aragon - MACI Plugin
3838
</span>
3939
</Link>
4040

constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ export const PUBLIC_IPFS_ENDPOINTS = process.env.NEXT_PUBLIC_IPFS_ENDPOINTS ?? "
4343
export const PUBLIC_PINATA_JWT = process.env.NEXT_PUBLIC_PINATA_JWT ?? "";
4444

4545
// General
46-
export const PUBLIC_APP_NAME = "Aragonette";
46+
export const PUBLIC_APP_NAME = "Aragon - MACI Plugin";
4747
export const PUBLIC_APP_DESCRIPTION = "Simplified user interface for Aragon DAO's";
4848

4949
export const PUBLIC_PROJECT_URL = process.env.NEXT_PUBLIC_PROJECT_URL ?? "https://aragon.org/";
5050
export const PUBLIC_WALLET_ICON = "https://avatars.githubusercontent.com/u/37784886";
5151

52-
export const PUBLIC_DISCORD_URL = "https://discord.com/";
52+
export const PUBLIC_DISCORD_URL = "https://discord.com/invite/sF5CT5rzrR";
53+
export const PUBLIC_TWITTER_URL = "https://x.com/PrivacyEthereum";

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "aragonette",
2+
"name": "maci-aragon-osx-gov-app",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
@@ -25,8 +25,8 @@
2525
"@layerzerolabs/lz-definitions": "^2.3.27",
2626
"@layerzerolabs/lz-v2-utilities": "^2.3.27",
2727
"@layerzerolabs/scan-client": "^0.0.8",
28-
"@maci-protocol/domainobjs": "0.0.0-ci.f03b827",
29-
"@maci-protocol/sdk": "0.0.0-ci.f03b827",
28+
"@maci-protocol/domainobjs": "0.0.0-ci.c62bc06",
29+
"@maci-protocol/sdk": "0.0.0-ci.c62bc06",
3030
"@react-native-async-storage/async-storage": "^1.23.1",
3131
"@shazow/whatsabi": "0.11.0",
3232
"@tanstack/query-async-storage-persister": "^5.49.1",

pages/index.tsx

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type ReactNode } from "react";
33
import { useAccount } from "wagmi";
44
import { useWeb3Modal } from "@web3modal/wagmi/react";
55
import { Else, If, Then } from "@/components/if";
6+
import { PUBLIC_DISCORD_URL, PUBLIC_TWITTER_URL } from "@/constants";
67

78
export default function Home() {
89
const { isConnected } = useAccount();
@@ -11,19 +12,82 @@ export default function Home() {
1112
return (
1213
<main className="w-screen max-w-full flex-col">
1314
<Card>
14-
<h1 className="text-2xl font-[700] text-neutral-800">Welcome to Aragonette!</h1>
15+
<h1 className="text-2xl font-[700] text-neutral-800">Welcome to the Aragon - MACI Plugin</h1>
1516
<p className="text-md text-neutral-400">
16-
A beaufitul DAO experience in a simple template that you can customize. Get started by connecting your wallet
17-
and selecting a plugin from the menu.
17+
This user interface was built to showcase the MACI private voting plugin integrated into Aragon OSx. Remember
18+
that this demo is a work in progress.
1819
</p>
1920
<div className="">
2021
<IllustrationHuman className="mx-auto mb-10 max-w-96" body="BLOCKS" expression="SMILE_WINK" hairs="CURLY" />
2122
<div className="flex justify-center">
2223
<If condition={isConnected}>
2324
<Then>
24-
<Button className="mb-2" variant="primary" href="https://devs.aragon.org/docs/osx/" target="_blank">
25-
Learn more about OSx
26-
</Button>
25+
<div className="flex flex-col items-center gap-1">
26+
<Button className="mb-2" variant="primary" href="https://devs.aragon.org/docs/osx/" target="_blank">
27+
Learn more about OSx
28+
</Button>
29+
<Button
30+
className="mb-2"
31+
variant="primary"
32+
href="https://github.com/privacy-scaling-explorations/maci"
33+
target="_blank"
34+
>
35+
Learn more about MACI
36+
</Button>
37+
<Button
38+
className="mb-2"
39+
variant="secondary"
40+
href="https://github.com/privacy-scaling-explorations/maci-voting-plugin-aragon"
41+
target="_blank"
42+
>
43+
Aragon - MACI Plugin
44+
</Button>
45+
<Button
46+
className="mb-2"
47+
variant="secondary"
48+
href="https://github.com/privacy-scaling-explorations/maci-aragon-osx-gov-app"
49+
target="_blank"
50+
>
51+
Aragon - MACI Frontend
52+
</Button>
53+
54+
<div className="mt-4 flex gap-4">
55+
<a
56+
href={PUBLIC_DISCORD_URL}
57+
target="_blank"
58+
rel="noopener noreferrer"
59+
className="text-neutral-500 transition-colors hover:text-primary-500"
60+
aria-label="Discord"
61+
>
62+
<svg
63+
width="24"
64+
height="24"
65+
viewBox="0 0 24 24"
66+
fill="currentColor"
67+
xmlns="http://www.w3.org/2000/svg"
68+
>
69+
<path d="M19.27 5.33C17.94 4.71 16.5 4.26 15 4a.09.09 0 0 0-.07.03c-.18.33-.39.76-.53 1.09a16.09 16.09 0 0 0-4.8 0c-.14-.34-.35-.76-.54-1.09-.01-.02-.04-.03-.07-.03-1.5.26-2.93.71-4.27 1.33-.01 0-.02.01-.03.02-2.72 4.07-3.47 8.03-3.1 11.95 0 .02.01.04.03.05 1.8 1.32 3.53 2.12 5.24 2.65.03.01.06 0 .07-.02.4-.55.76-1.13 1.07-1.74.02-.04 0-.08-.04-.09-.57-.22-1.11-.48-1.64-.78-.04-.02-.04-.08-.01-.11.11-.08.22-.17.33-.25.02-.02.05-.02.07-.01 3.44 1.57 7.15 1.57 10.55 0 .02-.01.05-.01.07.01.11.09.22.17.33.26.04.03.04.09-.01.11-.52.31-1.07.56-1.64.78-.04.01-.05.06-.04.09.32.61.68 1.19 1.07 1.74.03.02.06.03.09.02 1.72-.53 3.45-1.33 5.25-2.65.02-.01.03-.03.03-.05.44-4.53-.73-8.46-3.1-11.95-.01-.01-.02-.02-.04-.02zM8.52 14.91c-1.03 0-1.89-.95-1.89-2.12s.84-2.12 1.89-2.12c1.06 0 1.9.96 1.89 2.12 0 1.17-.84 2.12-1.89 2.12zm6.97 0c-1.03 0-1.89-.95-1.89-2.12s.84-2.12 1.89-2.12c1.06 0 1.9.96 1.89 2.12 0 1.17-.83 2.12-1.89 2.12z" />
70+
</svg>
71+
</a>
72+
<a
73+
href={PUBLIC_TWITTER_URL}
74+
target="_blank"
75+
rel="noopener noreferrer"
76+
className="text-neutral-500 transition-colors hover:text-primary-500"
77+
aria-label="Twitter"
78+
>
79+
<svg
80+
width="24"
81+
height="24"
82+
viewBox="0 0 24 24"
83+
fill="currentColor"
84+
xmlns="http://www.w3.org/2000/svg"
85+
>
86+
<path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z" />
87+
</svg>
88+
</a>
89+
</div>
90+
</div>
2791
</Then>
2892
<Else>
2993
<Button size="md" variant="primary" onClick={() => open()}>

plugins/maciVoting/components/PollCard.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useMaci } from "../hooks/useMaci";
88
import { unixTimestampToDate } from "../utils/formatPollDate";
99
import { VoteOption } from "../utils/types";
1010
import { VoteResultCard } from "./VoteResultCard";
11+
import classNames from "classnames";
1112

1213
const PollCard = ({ pollId }: { pollId: bigint }) => {
1314
// check if the user joined the poll
@@ -18,7 +19,7 @@ const PollCard = ({ pollId }: { pollId: bigint }) => {
1819
const [voteOption, setVoteOption] = useState<VoteOption | undefined>(undefined);
1920

2021
const { data: { voteStartDate, tallied, voteEnded, disabled, results } = {} } = useGetPollData(pollId);
21-
const { joinPollFunction, hasJoinedPoll, joinedPollData } = useJoinPoll(pollId);
22+
const { joinPollFunction, hasJoinedPoll, joinedPollData, isLoading: isLoadingJoinedPoll } = useJoinPoll(pollId);
2223
const { voteFunction } = useVote();
2324

2425
useEffect(() => {
@@ -56,7 +57,7 @@ const PollCard = ({ pollId }: { pollId: bigint }) => {
5657
const { pollStateIndex, voiceCredits } = joinedPollData;
5758

5859
setVoteOption(option);
59-
voteFunction(pollId, pollStateIndex, voiceCredits, option)
60+
await voteFunction(pollId, pollStateIndex, voiceCredits, option)
6061
.catch((error) => {
6162
setError(error.message);
6263
})
@@ -69,14 +70,17 @@ const PollCard = ({ pollId }: { pollId: bigint }) => {
6970
);
7071

7172
const buttonMessage = useMemo(() => {
73+
if (isLoadingJoinedPoll) {
74+
return <PleaseWaitSpinner fullMessage="Checking user status..." />;
75+
}
7276
if (hasJoinedPoll) {
7377
return "Already joined poll";
7478
}
7579
if (isLoading) {
7680
return <PleaseWaitSpinner fullMessage="Joining poll..." />;
7781
}
7882
return "Join poll";
79-
}, [hasJoinedPoll, isLoading]);
83+
}, [isLoadingJoinedPoll, hasJoinedPoll, isLoading]);
8084

8185
if (voteEnded && !tallied)
8286
return (
@@ -140,7 +144,7 @@ const PollCard = ({ pollId }: { pollId: bigint }) => {
140144
In order to submit your vote you need to join the poll using your locally generated MACI public key and your
141145
authorized wallet.
142146
</p>
143-
<Button onClick={onClickJoinPoll} disabled={hasJoinedPoll || isLoading}>
147+
<Button onClick={onClickJoinPoll} disabled={hasJoinedPoll || isLoading || isLoadingJoinedPoll}>
144148
{buttonMessage}
145149
</Button>
146150
</div>
@@ -165,23 +169,23 @@ const PollCard = ({ pollId }: { pollId: bigint }) => {
165169
<div className="flex flex-row gap-x-1">
166170
<Button
167171
onClick={() => onClickVote(VoteOption.Yes)}
168-
disabled={disabled ?? isLoading}
172+
disabled={disabled ? disabled : isLoading}
169173
size="sm"
170174
variant={disabled ? "tertiary" : "success"}
171175
>
172176
{isLoading && voteOption === VoteOption.Yes ? <PleaseWaitSpinner fullMessage="Yes" /> : "Yes"}
173177
</Button>
174178
<Button
175179
onClick={() => onClickVote(VoteOption.No)}
176-
disabled={disabled ?? isLoading}
180+
disabled={disabled ? disabled : isLoading}
177181
size="sm"
178182
variant={disabled ? "tertiary" : "critical"}
179183
>
180184
{isLoading && voteOption === VoteOption.No ? <PleaseWaitSpinner fullMessage="No" /> : "No"}
181185
</Button>
182186
<Button
183187
onClick={() => onClickVote(VoteOption.Abstain)}
184-
disabled={disabled ?? isLoading}
188+
disabled={disabled ? disabled : isLoading}
185189
size="sm"
186190
variant={disabled ? "tertiary" : "warning"}
187191
>

plugins/maciVoting/contexts/MaciContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const MaciProvider = ({ children }: { children: ReactNode }) => {
8787

8888
setMaciKeypair(keypair);
8989
} catch (error) {
90-
setError("Error creating keypair");
90+
setError("Error creating keypair. Please go to MACI Voting and try again.");
9191
setIsLoading(false);
9292
return;
9393
}

0 commit comments

Comments
 (0)