From e26ebe2a6976aa78fd2b2471c4887bced568e97c Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Mon, 20 Nov 2023 11:44:05 -0600 Subject: [PATCH 01/24] ci: add build-a-bull deployment --- .github/workflows/pr.yml | 9 ++++ .github/workflows/release.yml | 23 ++++++++++ infrastructure/bin/infrastructure.ts | 66 +++++++++++++++++++--------- infrastructure/package.json | 13 +++--- 4 files changed, 85 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 35309771..4e4321dc 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,6 +32,15 @@ jobs: secrets: chromatic-token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} npm-auth-token: ${{ secrets.GITHUB_TOKEN }} + build-event-dapp: + name: Events Dapp + uses: ./.github/workflows/node-ci.yml + with: + working-directory: ./src/build-a-bull + audit-script: npm run audit --audit-level=high + run-dispatch: true + secrets: + npm-auth-token: ${{ secrets.GITHUB_TOKEN }} build-api: name: Api uses: ./.github/workflows/node-ci.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a63324d2..2d0967a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,13 @@ jobs: pre-run-script: cd ../dapp && npm ci compile-script: npm run typecheck audit-script: npm run audit --audit-level=high + ci-events-dapp: + name: CI Events Dapp + uses: ./.github/workflows/node-ci.yml + with: + working-directory: ./src/build-a-bull + compile-script: npm run typecheck + audit-script: npm run audit --audit-level=high ci-api: name: CI API uses: ./.github/workflows/node-ci.yml @@ -75,6 +82,18 @@ jobs: needs: - ci-xgov-dapp - ci-algorand + build-events-dapp: + name: Build Events Dapp + uses: ./.github/workflows/node-build-zip.yml + with: + working-directory: ./src/build-a-bull + build-path: dist + artifact-name: build-a-bull-dapp + static-site: true + static-site-env-prefix: VITE + needs: + - ci-events-dapp + - ci-algorand build-api: name: Build API uses: ./.github/workflows/node-build-zip.yml @@ -101,6 +120,7 @@ jobs: needs: - build-dapp - build-xgov-dapp + - build-events-dapp - build-infrastructure - build-api steps: @@ -141,6 +161,7 @@ jobs: VITE_NFT_EXPLORER_URL: ${{ vars.NFT_EXPLORER_URL }} VITE_IS_TESTNET: ${{ vars.IS_TESTNET }} VITE_XGOV_CREATOR_ALLOW_LIST: ${{ vars.XGOV_CREATOR_ALLOW_LIST_ADDRESSES }} + VITE_HACKATHON_CREATOR_ALLOW_LIST: ${{ vars.HACKATHON_CREATOR_ALLOW_LIST_ADDRESSES }} VITE_CREATOR_ALLOW_LIST: ${{ vars.CREATOR_ALLOW_LIST_ADDRESSES }} VITE_HIDDEN_VOTING_ROUND_IDS: ${{ vars.HIDDEN_VOTING_ROUND_IDS }} VITE_XGOV_GOVENERS_URL: ${{ vars.XGOV_GOVENERS_URL }} @@ -155,6 +176,7 @@ jobs: needs: - build-dapp - build-xgov-dapp + - build-events-dapp - build-infrastructure - build-api steps: @@ -195,6 +217,7 @@ jobs: VITE_NFT_EXPLORER_URL: ${{ vars.NFT_EXPLORER_URL }} VITE_IS_TESTNET: ${{ vars.IS_TESTNET }} VITE_XGOV_CREATOR_ALLOW_LIST: ${{ vars.XGOV_CREATOR_ALLOW_LIST_ADDRESSES }} + VITE_HACKATHON_CREATOR_ALLOW_LIST: ${{ vars.HACKATHON_CREATOR_ALLOW_LIST_ADDRESSES }} VITE_CREATOR_ALLOW_LIST: ${{ vars.CREATOR_ALLOW_LIST_ADDRESSES }} VITE_HIDDEN_VOTING_ROUND_IDS: ${{ vars.HIDDEN_VOTING_ROUND_IDS }} VITE_XGOV_GOVENERS_URL: ${{ vars.XGOV_GOVENERS_URL }} diff --git a/infrastructure/bin/infrastructure.ts b/infrastructure/bin/infrastructure.ts index 9ac4c83d..081be25d 100644 --- a/infrastructure/bin/infrastructure.ts +++ b/infrastructure/bin/infrastructure.ts @@ -16,6 +16,7 @@ const deployer = new CDKDeployer({ const appDomainName = deployer.getEnvPrefixedDomainName(`voting.${process.env.BASE_DOMAIN}`) const apiDomainName = `api.${appDomainName}` const xGovAppDomainName = deployer.getEnvPrefixedDomainName(`xgov.${process.env.BASE_DOMAIN}`) +const eventsAppDomainName = deployer.getEnvPrefixedDomainName(`build-a-bull.${process.env.BASE_DOMAIN}`) const apiCertificateRequest: CertificateRequest = { isWildCard: false, @@ -25,30 +26,44 @@ const apiCertificateRequest: CertificateRequest = { const dns = appDomainName ? deployer.deploy( - DnsStack, - 'dns-web', - { - domainName: appDomainName, - generateCertificate: true, - parameterRegions: [deployer.defaultRegion], - certificateRequests: [DnsStack.ROOT_CERT_REQUEST, apiCertificateRequest], - }, - 'us-east-1', - ) + DnsStack, + 'dns-web', + { + domainName: appDomainName, + generateCertificate: true, + parameterRegions: [deployer.defaultRegion], + certificateRequests: [DnsStack.ROOT_CERT_REQUEST, apiCertificateRequest], + }, + 'us-east-1', + ) : undefined const xGovDns = xGovAppDomainName ? deployer.deploy( - DnsStack, - 'dns-xgovweb', - { - domainName: xGovAppDomainName, - generateCertificate: true, - parameterRegions: [deployer.defaultRegion], - certificateRequests: [DnsStack.ROOT_CERT_REQUEST], - }, - 'us-east-1', - ) + DnsStack, + 'dns-xgovweb', + { + domainName: xGovAppDomainName, + generateCertificate: true, + parameterRegions: [deployer.defaultRegion], + certificateRequests: [DnsStack.ROOT_CERT_REQUEST], + }, + 'us-east-1', + ) + : undefined + +const eventsDns = eventsAppDomainName + ? deployer.deploy( + DnsStack, + 'dns-eventsweb', + { + domainName: eventsAppDomainName, + generateCertificate: true, + parameterRegions: [deployer.defaultRegion], + certificateRequests: [DnsStack.ROOT_CERT_REQUEST], + }, + 'us-east-1', + ) : undefined const responseHeaders: ResponseHeadersPolicyProps = { @@ -119,6 +134,13 @@ const xGovApp = deployer.deploy(StaticWebsiteStack, 'xgovweb', { responseHeaders: responseHeaders, }) +const eventsApp = deployer.deploy(StaticWebsiteStack, 'eventweb', { + websiteFolder: process.env.WEBSITE_BUILD_PATH_XGOV ?? path.join(__dirname, '..', '..', 'src', 'build-a-bull', 'dist'), + websiteNpmBuildCommand: 'build-events-dapp', + customDomain: eventsDns?.getDefaultCustomDomainProps(deployer.defaultRegion, eventsAppDomainName), + responseHeaders: responseHeaders, +}) + if (dns) { app.addDependency(dns) api.addDependency(dns) @@ -127,3 +149,7 @@ if (dns) { if (xGovDns) { xGovApp.addDependency(xGovDns) } + +if (eventsDns) { + eventsApp.addDependency(eventsDns) +} diff --git a/infrastructure/package.json b/infrastructure/package.json index 3ba6936c..707de5d7 100644 --- a/infrastructure/package.json +++ b/infrastructure/package.json @@ -8,19 +8,20 @@ "build": "npm run clean && tsc && copyfiles package.json package-lock.json cdk.json build && cd build && npm ci --omit=dev && json -I -f cdk.json -e \"this.app='node bin/infrastructure.js'\"", "clean": "rimraf build", "cdk": "cdk", - "bootstrap:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/voting-metadata-api/.env -- npm run bootstrap", + "bootstrap:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/voting-metadata-api/.env -- npm run bootstrap", "bootstrap": "cross-env-shell npm run cdk -- bootstrap aws://$CDK_DEFAULT_ACCOUNT/$AWS_DEFAULT_REGION && cross-env-shell npm run cdk -- bootstrap aws://$CDK_DEFAULT_ACCOUNT/us-east-1", - "diff:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/voting-metadata-api/.env -- npm run diff", + "diff:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/voting-metadata-api/.env -- npm run diff", "diff": "npm run cdk -- diff", - "deploy:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/voting-metadata-api/.env -- npm run deploy && npm run set-secrets:local", + "deploy:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/voting-metadata-api/.env -- npm run deploy && npm run set-secrets:local", "deploy": "npm run cdk -- deploy \"*\" --ci --require-approval never --outputs-file ./cdk-outputs.json", - "destroy:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/voting-metadata-api/.env -- npm run cdk -- destroy --all", - "graph:local": "cross-env NO_BUILD=true dotenv -e .env -e ../src/xgov-dapp/.env -e ../src/dapp/.env -e ../src/voting-metadata-api/.env -- npm run graph && move-cli diagram.png ../docs/stack.png", + "destroy:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/voting-metadata-api/.env -- npm run cdk -- destroy --all", + "graph:local": "cross-env NO_BUILD=true dotenv -e .env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/dapp/.env -e ../src/voting-metadata-api/.env -- npm run graph && move-cli diagram.png ../docs/stack.png", "graph": "npm run cdk -- synth --context environment=env && npx cdk-dia", - "set-secrets:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/voting-metadata-api/.env -- ts-node lib/set-aws-secrets.ts", + "set-secrets:local": "dotenv -e .env -e ../src/dapp/.env -e ../src/xgov-dapp/.env -e ../src/build-a-bull/.env -e ../src/voting-metadata-api/.env -- ts-node lib/set-aws-secrets.ts", "set-secrets": "node lib/set-aws-secrets.js", "build-dapp": "cd ../src/dapp/ && npm run build", "build-xgov-dapp": "cd ../src/xgov-dapp/ && npm run build", + "build-events-dapp": "cd ../src/build-a-bull/ && npm run build", "build-api": "cd ../src/voting-metadata-api && npm run build", "format": "prettier --write .", "audit:resolve": "resolve-audit", From 426e53688c2b3c7b0b4cc974739032a5600e4eec Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Mon, 20 Nov 2023 11:49:52 -0600 Subject: [PATCH 02/24] ci: remove chromatic from build-a-bull --- .github/workflows/pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4e4321dc..8370563f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -38,7 +38,6 @@ jobs: with: working-directory: ./src/build-a-bull audit-script: npm run audit --audit-level=high - run-dispatch: true secrets: npm-auth-token: ${{ secrets.GITHUB_TOKEN }} build-api: From 4d4f60516b6a5e160af0fc07261ea507b853fd34 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:45:43 +0100 Subject: [PATCH 03/24] feat: ENG-64 Adds placeholder to occupy same height as READ MORE button --- src/build-a-bull/src/shared/ProposalCard.tsx | 3 ++- src/xgov-dapp/src/shared/ProposalCard.tsx | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/build-a-bull/src/shared/ProposalCard.tsx b/src/build-a-bull/src/shared/ProposalCard.tsx index e0dbadd0..376b8f14 100644 --- a/src/build-a-bull/src/shared/ProposalCard.tsx +++ b/src/build-a-bull/src/shared/ProposalCard.tsx @@ -46,7 +46,7 @@ export const ProposalCard = ({ } return ( - +
{hasPassed && } @@ -89,6 +89,7 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} +
) } diff --git a/src/xgov-dapp/src/shared/ProposalCard.tsx b/src/xgov-dapp/src/shared/ProposalCard.tsx index f7338c35..69902e78 100644 --- a/src/xgov-dapp/src/shared/ProposalCard.tsx +++ b/src/xgov-dapp/src/shared/ProposalCard.tsx @@ -3,6 +3,7 @@ import LaunchIcon from '@mui/icons-material/Launch' import { Chip, Collapse, LinearProgress, Link, Paper, Typography } from '@mui/material' import { AbstainChip, CategoryChip, DidNotPassChip, MockProposalChip, PassedChip, VotesNeededToPassChip } from './Chips' import { useOverflow } from './hooks/useOverflow' +import { Visibility } from '@mui/icons-material' export type ProposalCardProps = { link: string | undefined @@ -80,6 +81,7 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} +
) } @@ -130,6 +132,7 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} +
) } From 846d539549b8fc765700d250b1cb21cbede9f0a5 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:48:04 +0100 Subject: [PATCH 04/24] remove typos --- src/build-a-bull/src/shared/ProposalCard.tsx | 2 +- src/xgov-dapp/src/shared/ProposalCard.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/build-a-bull/src/shared/ProposalCard.tsx b/src/build-a-bull/src/shared/ProposalCard.tsx index 376b8f14..307e8e74 100644 --- a/src/build-a-bull/src/shared/ProposalCard.tsx +++ b/src/build-a-bull/src/shared/ProposalCard.tsx @@ -46,7 +46,7 @@ export const ProposalCard = ({ } return ( - +
{hasPassed && } diff --git a/src/xgov-dapp/src/shared/ProposalCard.tsx b/src/xgov-dapp/src/shared/ProposalCard.tsx index 69902e78..8193ffd8 100644 --- a/src/xgov-dapp/src/shared/ProposalCard.tsx +++ b/src/xgov-dapp/src/shared/ProposalCard.tsx @@ -3,7 +3,6 @@ import LaunchIcon from '@mui/icons-material/Launch' import { Chip, Collapse, LinearProgress, Link, Paper, Typography } from '@mui/material' import { AbstainChip, CategoryChip, DidNotPassChip, MockProposalChip, PassedChip, VotesNeededToPassChip } from './Chips' import { useOverflow } from './hooks/useOverflow' -import { Visibility } from '@mui/icons-material' export type ProposalCardProps = { link: string | undefined From 770410e1787c8c211a4b202da8e2726662717c93 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:31:10 +0100 Subject: [PATCH 05/24] feat: uses Collapse size instead of adding extra div --- src/build-a-bull/src/shared/ProposalCard.tsx | 3 +-- src/xgov-dapp/src/shared/ProposalCard.tsx | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/build-a-bull/src/shared/ProposalCard.tsx b/src/build-a-bull/src/shared/ProposalCard.tsx index 307e8e74..5cd735a4 100644 --- a/src/build-a-bull/src/shared/ProposalCard.tsx +++ b/src/build-a-bull/src/shared/ProposalCard.tsx @@ -80,7 +80,7 @@ export const ProposalCard = ({
{description && ( - + )} @@ -89,7 +89,6 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} -
) } diff --git a/src/xgov-dapp/src/shared/ProposalCard.tsx b/src/xgov-dapp/src/shared/ProposalCard.tsx index 8193ffd8..56a3b074 100644 --- a/src/xgov-dapp/src/shared/ProposalCard.tsx +++ b/src/xgov-dapp/src/shared/ProposalCard.tsx @@ -71,8 +71,8 @@ export const ProposalCard = ({
{description && ( - - {description} + + )} {(isOverflow || hasOpened) && ( @@ -80,7 +80,6 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} -
) } @@ -122,7 +121,7 @@ export const ProposalCard = ({
{description && ( - + )} @@ -131,7 +130,6 @@ export const ProposalCard = ({ {expanded ? 'Show Less' : 'Read More'} )} -
) } From 56831752fee46b719eccc2efb358c5d89ed7e557 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:41:03 +0100 Subject: [PATCH 06/24] fix: remove extra in abstain logic --- src/xgov-dapp/src/shared/ProposalCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xgov-dapp/src/shared/ProposalCard.tsx b/src/xgov-dapp/src/shared/ProposalCard.tsx index 56a3b074..ce7f061b 100644 --- a/src/xgov-dapp/src/shared/ProposalCard.tsx +++ b/src/xgov-dapp/src/shared/ProposalCard.tsx @@ -122,7 +122,7 @@ export const ProposalCard = ({ {description && ( - + {description} )} {(isOverflow || hasOpened) && ( From d5170f588a80b6b4c2413c14496c55e70ba9cfb8 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:42:50 +0100 Subject: [PATCH 07/24] fix: remove extra in abstain logic fix --- src/xgov-dapp/src/shared/ProposalCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xgov-dapp/src/shared/ProposalCard.tsx b/src/xgov-dapp/src/shared/ProposalCard.tsx index ce7f061b..a1229f04 100644 --- a/src/xgov-dapp/src/shared/ProposalCard.tsx +++ b/src/xgov-dapp/src/shared/ProposalCard.tsx @@ -72,7 +72,7 @@ export const ProposalCard = ({ {description && ( - + {description} )} {(isOverflow || hasOpened) && ( @@ -122,7 +122,7 @@ export const ProposalCard = ({ {description && ( - {description} + )} {(isOverflow || hasOpened) && ( From 102b98358a258e6b40a693564d96a98a9002e008 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Thu, 30 Nov 2023 14:30:42 -0600 Subject: [PATCH 08/24] refactor: move to NO_SNAPSHOT --- .../src/features/rounds/VotingRoundTile.tsx | 2 +- .../src/features/rounds/index.tsx | 6 +- .../src/features/vote-creation/RoundInfo.tsx | 67 ----------------- .../features/vote-creation/review/index.tsx | 60 +++++++-------- .../src/features/vote/VoteResults.tsx | 3 +- .../src/features/vote/VotingStats.tsx | 8 +- src/build-a-bull/src/features/vote/index.tsx | 75 ++++--------------- src/build-a-bull/src/root.tsx | 2 +- src/build-a-bull/src/shared/ProposalCard.tsx | 4 +- 9 files changed, 57 insertions(+), 170 deletions(-) diff --git a/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx b/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx index 0dffe590..769bc8ad 100644 --- a/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx +++ b/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx @@ -209,7 +209,7 @@ export const VotingRoundTile = ({ globalState, votingRoundStatus }: VotingRoundT />
- +
diff --git a/src/build-a-bull/src/features/rounds/index.tsx b/src/build-a-bull/src/features/rounds/index.tsx index aacf3229..8a6cc904 100644 --- a/src/build-a-bull/src/features/rounds/index.tsx +++ b/src/build-a-bull/src/features/rounds/index.tsx @@ -71,7 +71,7 @@ const VotingRounds = () => { const openRounds = globalStates ? getRounds( globalStates, - (r) => getHasVoteStarted(r) && !getHasVoteEnded(r) && r.vote_type == VoteType.PARTITIONED_WEIGHTING, + (r) => getHasVoteStarted(r) && !getHasVoteEnded(r) && r.vote_type == VoteType.NO_SNAPSHOT, (r: VotingRoundGlobalState) => r.end_time, ) : [] @@ -79,7 +79,7 @@ const VotingRounds = () => { const upcomingRounds = globalStates ? getRounds( globalStates, - (r) => !getHasVoteStarted(r) && !getHasVoteEnded(r) && r.vote_type == VoteType.PARTITIONED_WEIGHTING, + (r) => !getHasVoteStarted(r) && !getHasVoteEnded(r) && r.vote_type == VoteType.NO_SNAPSHOT, (r: VotingRoundGlobalState) => r.start_time, ) : [] @@ -87,7 +87,7 @@ const VotingRounds = () => { const closedRounds = globalStates ? getRounds( globalStates, - (r) => getHasVoteEnded(r) && r.vote_type == VoteType.PARTITIONED_WEIGHTING, + (r) => getHasVoteEnded(r) && r.vote_type == VoteType.NO_SNAPSHOT, (r: VotingRoundGlobalState) => r.end_time, ) : [] diff --git a/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx b/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx index 67f9448e..d5009a58 100644 --- a/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx +++ b/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx @@ -23,9 +23,7 @@ const formSchema = zfd.formData({ voteInformationUrl: zfd.text(z.string().trim().url().optional()), start: zfd.text(), end: zfd.text(), - communityGrantAllocation: zfd.numeric(z.number().positive().min(1, 'Must be at least 1')), proposalFile: zfd.text(z.string().trim().min(1, 'Required').superRefine(validateProposalCsv)), - snapshotFile: zfd.text(z.string().trim().min(1, 'Required').superRefine(validateSnapshotCsv)), }) function validateProposalCsv(value: string, ctx: z.RefinementCtx) { @@ -69,59 +67,6 @@ function validateProposalCsv(value: string, ctx: z.RefinementCtx) { }) } -function validateSnapshotCsv(value: string, ctx: z.RefinementCtx) { - const parsed = Papa.parse(value, { header: true, delimiter: ',' }) - const requiredFields = ['address', 'weight'] - if (parsed.errors.length > 0) { - parsed.errors.forEach((error) => { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `${error.message} ` + `on row: ${error.row + 1}`, - }) - }) - } - if (parsed.meta.fields) { - if ( - !requiredFields.every((field) => { - return parsed.meta.fields && parsed.meta.fields.includes(field) - }) - ) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The csv must have a header row with the following fields: ${requiredFields.join(', ')}`, - }) - } - } - if (parsed.data.length <= 0) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'No addresses found', - }) - } - parsed.data.forEach((row, index) => { - try { - decodeAddress(row.address) - } catch (e) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The address on row: ${index + 1} is not valid`, - }) - } - if (!row.weight) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The address on row: ${index + 1} has no weight associated with it`, - }) - } - if (isNaN(Number(row.weight)) || Number(row.weight) === 0) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The address on row: ${index + 1} has an invalid weight associated with it`, - }) - } - }) -} - export type Fields = z.infer export default function RoundInfo() { @@ -169,11 +114,6 @@ export default function RoundInfo() { fromISO: (date) => dayjs(date) as unknown as Date, })}
- {helper.textField({ - label: 'Community grant allocation', - field: 'communityGrantAllocation', - hint: 'Amount of microALGO to allocate to the community grant pool', - })} {helper.textFileFormField({ label: 'Proposals', field: 'proposalFile', @@ -181,13 +121,6 @@ export default function RoundInfo() { longHint: 'Upload a CSV file with 5 columns containing the proposals. The headers should be "title", "description", "link", "category", "threshold"', })} - {helper.textFileFormField({ - label: 'Allowlist snapshot file', - field: 'snapshotFile', - hint: 'Upload snapshot .csv file', - longHint: - 'Upload a CSV file with 2 columns containing the addresses and weights for the allowlist. The headers should be "address" and "weight".', - })}
{helper.submitButton({ label: 'Next', className: 'mt-8' })}
)} diff --git a/src/build-a-bull/src/features/vote-creation/review/index.tsx b/src/build-a-bull/src/features/vote-creation/review/index.tsx index bd43fc5b..ccd6e5e6 100644 --- a/src/build-a-bull/src/features/vote-creation/review/index.tsx +++ b/src/build-a-bull/src/features/vote-creation/review/index.tsx @@ -2,8 +2,8 @@ import { Alert, Box, Button, Link, Stack, TextField, Typography } from '@mui/mat import { useState } from 'react' import { useNavigate } from 'react-router-dom' -import api from '../../../shared/api' -import { LoadingDialog } from '../../../shared/loading/LoadingDialog' +import api from '@/shared/api' +import { LoadingDialog } from '@/shared/loading/LoadingDialog' import { VoteCreationReviewSteps, useAppReference, @@ -56,12 +56,34 @@ export default function Review() { setAuth(await auth.execute({ signer })) break case VoteCreationReviewSteps.Create: + console.log({ + auth: authData, + newRound: { + ...roundInfo, + voteType: VoteType.NO_SNAPSHOT, + questions: proposals.map((proposal) => { + return { + questionTitle: proposal.title, + questionDescription: proposal.description, + metadata: { + link: proposal.link, + category: proposal.category, + focus_area: proposal.focus_area, + threshold: Number(proposal.threshold), + ask: Number(proposal.ask), + }, + answers: ['Yes', 'No'], + } + }), + }, + signer, + }) // eslint-disable-next-line no-case-declarations const app = await create.execute({ auth: authData, newRound: { ...roundInfo, - voteType: VoteType.PARTITIONED_WEIGHTING, + voteType: VoteType.NO_SNAPSHOT, questions: proposals.map((proposal) => { return { questionTitle: proposal.title, @@ -73,7 +95,7 @@ export default function Review() { threshold: Number(proposal.threshold), ask: Number(proposal.ask), }, - answers: ['yes'], + answers: ['Yes', 'No'], } }), }, @@ -89,10 +111,12 @@ export default function Review() { break case VoteCreationReviewSteps.Bootstrap: + console.log(proposals) await bootstrap.execute({ app: appRef, signer, - totalQuestionOptions: proposals.length, + // Two options per proposal + totalQuestionOptions: proposals.length * 2, }) break } @@ -138,7 +162,7 @@ export default function Review() {
Preview of {roundInfo.voteTitle} -
+
Proposals @@ -162,35 +186,11 @@ export default function Review() { })}
- -
- - Voting Addresses - - {roundInfo.snapshotFile && ( -
- -
- )} -
-
Session Period - - - - Community Allocation: - - - {roundInfo.communityGrantAllocation ? roundInfo.communityGrantAllocation.microAlgos().algos.toLocaleString('en-US') : 0}{' '} - ALGO{roundInfo.communityGrantAllocation === 1 ? '' : 's'} - - {(roundInfo.communityGrantAllocation || 0).microAlgos().toString()} - - Review everything on this page carefully, as it cannot be changed once you create the voting round! diff --git a/src/build-a-bull/src/features/vote/VoteResults.tsx b/src/build-a-bull/src/features/vote/VoteResults.tsx index e92a7392..acc34c5b 100644 --- a/src/build-a-bull/src/features/vote/VoteResults.tsx +++ b/src/build-a-bull/src/features/vote/VoteResults.tsx @@ -27,7 +27,7 @@ export type VoteResultsProps = { votingRoundGlobalState: VotingRoundGlobalState isLoadingVotingRoundData: boolean isLoadingVotingRoundResults: boolean - snapshot: VoteGatingSnapshot | undefined + snapshot?: VoteGatingSnapshot | undefined myVotes?: string[] } @@ -150,7 +150,6 @@ export const VoteResults = ({
diff --git a/src/build-a-bull/src/features/vote/VotingStats.tsx b/src/build-a-bull/src/features/vote/VotingStats.tsx index d669a9d0..2c83a5fa 100644 --- a/src/build-a-bull/src/features/vote/VotingStats.tsx +++ b/src/build-a-bull/src/features/vote/VotingStats.tsx @@ -1,16 +1,14 @@ import { ChartPieIcon } from '@heroicons/react/24/solid' import { Box, Skeleton, Typography } from '@mui/material' import React from 'react' -import { VoteGatingSnapshot } from '@/shared/IPFSGateway' import { VotingRoundGlobalState } from '@/shared/VotingRoundContract' interface VotingStatsComponentProps { votingRoundGlobalState: VotingRoundGlobalState - snapshot: VoteGatingSnapshot | undefined isLoading: boolean } -const VotingStats: React.FC = ({ votingRoundGlobalState, snapshot, isLoading }) => { +const VotingStats: React.FC = ({ votingRoundGlobalState, isLoading }) => { return (
@@ -21,8 +19,8 @@ const VotingStats: React.FC = ({ votingRoundGlobalSta Voting stats {isLoading ? : null} - {!isLoading && snapshot && votingRoundGlobalState && ( - {`${votingRoundGlobalState.voter_count} out of ${snapshot.snapshot.length} wallets voted`} + {!isLoading && votingRoundGlobalState && ( + {`${votingRoundGlobalState.voter_count} wallets voted`} )}  
diff --git a/src/build-a-bull/src/features/vote/index.tsx b/src/build-a-bull/src/features/vote/index.tsx index 92dd7e64..dd08fff1 100644 --- a/src/build-a-bull/src/features/vote/index.tsx +++ b/src/build-a-bull/src/features/vote/index.tsx @@ -5,7 +5,7 @@ import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward' import CancelIcon from '@mui/icons-material/Cancel' import ClearIcon from '@mui/icons-material/Clear' import ShuffleOnIcon from '@mui/icons-material/ShuffleOn' -import { Alert, Box, Button, IconButton, InputAdornment, Link, Skeleton, TextField, Typography } from '@mui/material' +import { Alert, Box, Button, Checkbox, IconButton, InputAdornment, Link, Skeleton, TextField, Typography } from '@mui/material' import clsx from 'clsx' import { useEffect, useMemo, useState } from 'react' import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom' @@ -52,7 +52,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const [votingRoundGlobalState, setVotingRoundGlobalState] = useState(undefined) const [votingRoundMetadata, setVotingRoundMetadata] = useState(undefined) - const [snapshot, setSnapshot] = useState(undefined) const [votingRoundResults, setVotingRoundResults] = useState(undefined) const [optionIdsToCount, setOptionIdsToCount] = useState<{ [optionId: string]: number } | undefined>(undefined) const [voterVotes, setVoterVotes] = useState(undefined) @@ -63,7 +62,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const [error, setError] = useState(null) const [allowlistSignature, setAllowlistSignature] = useState(null) - const [allowedToVote, setAllowToVote] = useState(false) const [voteWeight, setVoteWeight] = useState(0) const [voteAllocationsPercentage, setVoteAllocationsPercentage] = useState({}) const [voteAllocations, setVoteAllocations] = useState({}) @@ -77,16 +75,18 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const hasVoteEnded = !votingRoundGlobalState ? false : getHasVoteEnded(votingRoundGlobalState) const isVoteCreator = votingRoundMetadata?.created.by === activeAddress ? true : false - const canVote = hasVoteStarted && !hasVoteEnded && allowedToVote + const canVote = hasVoteStarted && !hasVoteEnded const hasVoted = voterVotes !== undefined ? true : false const hasClosed = votingRoundGlobalState && votingRoundGlobalState.close_time !== undefined ? true : false + + const totalVotes = useMemo(()=>votingRoundResults ? votingRoundResults.reduce((c, r)=>c + r.count, 0) : 0, [votingRoundResults]) + const canSubmitVote = canVote && totalAllocatedPercentage >= 100 && // totalAllocated === voteWeight && activeAddress && - allowlistSignature && votingRoundMetadata && !hasVoted @@ -146,7 +146,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const refetchVoteRoundData = async (voteId: number | undefined) => { setVotingRoundGlobalState(undefined) setVotingRoundMetadata(undefined) - setSnapshot(undefined) setError(null) if (voteId) { setIsLoadingVotingRoundData(true) @@ -161,11 +160,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | throw new Error(`Could not retrieve voting round metadata with cid: ${globalState.metadata_ipfs_cid}`) } - if (roundMetadata.voteGatingSnapshotCid) { - const snapshot = await fetchVotingSnapshot(roundMetadata.voteGatingSnapshotCid) - setSnapshot(snapshot) - } - setVotingRoundGlobalState(globalState) setVotingRoundMetadata(roundMetadata) setIsLoadingVotingRoundData(false) @@ -215,25 +209,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | } } - useEffect(() => { - setAllowlistSignature(null) - setAllowToVote(false) - if (snapshot?.snapshot) { - const addressSnapshot = snapshot?.snapshot.find((addressSnapshot) => { - return addressSnapshot.address === activeAddress - }) - if (addressSnapshot) { - setAllowlistSignature(addressSnapshot.signature) - setAllowToVote(true) - if (addressSnapshot.weight && isFinite(addressSnapshot.weight)) { - setVoteWeight(addressSnapshot.weight) - } else { - setVoteWeight(1) - } - } - } - }, [snapshot, activeAddress]) - const handleError = (e: unknown) => { if (e instanceof Error) { setError(e.message) @@ -272,10 +247,10 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | } await submitVote({ - signature: allowlistSignature, + signature: allowlistSignature || '', selectedOptionIndexes: votingRoundMetadata.questions.map(() => 0), - weighting: voteWeight, - weightings: votingRoundMetadata.questions.map((question) => (newVoteAllocations[question.id] ? newVoteAllocations[question.id] : 0)), + weighting: 0, + weightings: votingRoundMetadata.questions.map(() => 0), signer: { addr: activeAddress, signer }, appId: voteId, }) @@ -371,7 +346,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | votingRoundGlobalState={votingRoundGlobalState} isLoadingVotingRoundResults={isLoadingVotingRoundResults} isLoadingVotingRoundData={isLoadingVotingRoundData} - snapshot={snapshot} /> ) } @@ -457,32 +431,15 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | votesTally={ optionIdsToCount && optionIdsToCount[question.options[0].id] ? optionIdsToCount[question.options[0].id] : 0 } + totalVotes={totalVotes} /> )}
{canVote && !hasVoted && ( - <> - %, - }} - id={question.id} - variant="outlined" - onChange={(e) => { - updateVoteAllocations(question.id, parseFloat(e.target.value)) - }} - value={voteAllocationsPercentage[question.id] ? `${voteAllocationsPercentage[question.id]}` : 0} - /> -    ~{voteAllocations[question.id] ? voteAllocations[question.id] : 0} votes - + { + // updateVoteAllocations(question.id, parseFloat(e.target.value)) + }}/> )}
@@ -512,7 +469,7 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
)} - {!isLoadingVotingRoundData && (!hasVoteStarted || !activeAddress || !allowedToVote) && ( + {!isLoadingVotingRoundData && (!hasVoteStarted || !activeAddress) && (
@@ -538,8 +495,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
- ) : !allowedToVote ? ( - Your wallet is not on the allow list for this voting round. ) : ( '' )} @@ -554,9 +509,9 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | )} - {votingRoundGlobalState && snapshot && ( + {votingRoundGlobalState && (
- +
)} diff --git a/src/build-a-bull/src/root.tsx b/src/build-a-bull/src/root.tsx index fc1c093f..9f1571f9 100644 --- a/src/build-a-bull/src/root.tsx +++ b/src/build-a-bull/src/root.tsx @@ -54,7 +54,7 @@ export default function Root() { } /> - + {/**/} ) diff --git a/src/build-a-bull/src/shared/ProposalCard.tsx b/src/build-a-bull/src/shared/ProposalCard.tsx index e0dbadd0..fcd41912 100644 --- a/src/build-a-bull/src/shared/ProposalCard.tsx +++ b/src/build-a-bull/src/shared/ProposalCard.tsx @@ -13,6 +13,7 @@ export type ProposalCardProps = { threshold: number | undefined ask: number | undefined votesTally: number | undefined + totalVotes: number | undefined hasClosed?: boolean forcePass?: boolean } @@ -26,6 +27,7 @@ export const ProposalCard = ({ threshold, ask, votesTally = 0, + totalVotes = 0, hasClosed = false, forcePass = false, }: ProposalCardProps) => { @@ -72,7 +74,7 @@ export const ProposalCard = ({
- {threshold && `${votesTally.toLocaleString()} of ${threshold.toLocaleString()} Votes`} + {threshold && `${votesTally.toLocaleString()} of ${totalVotes} Votes`} {hasClosed && hasPassed && ask && {`${ask.toLocaleString()} ALGO awarded`}} From 48f066b901dbf6fdccf14c946542dd5a0b7537fa Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Fri, 1 Dec 2023 09:34:21 -0600 Subject: [PATCH 09/24] refactor: configure bab voting --- src/build-a-bull/src/features/vote/index.tsx | 52 +++----------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/src/build-a-bull/src/features/vote/index.tsx b/src/build-a-bull/src/features/vote/index.tsx index dd08fff1..c13467ab 100644 --- a/src/build-a-bull/src/features/vote/index.tsx +++ b/src/build-a-bull/src/features/vote/index.tsx @@ -82,10 +82,10 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const totalVotes = useMemo(()=>votingRoundResults ? votingRoundResults.reduce((c, r)=>c + r.count, 0) : 0, [votingRoundResults]) + const [voteState, setVoteState] = useState<{[k: string]: boolean}>({}) + const canSubmitVote = canVote && - totalAllocatedPercentage >= 100 && - // totalAllocated === voteWeight && activeAddress && votingRoundMetadata && !hasVoted @@ -105,21 +105,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | */ const [filteredItems, setFilteredItems] = useState([]) - const updateVoteAllocations = (proposalId: string, amount: number) => { - const newVoteAllocationsPercentage = { ...voteAllocationsPercentage } - if (!isFinite(amount)) { - amount = 0 - } - - if (amount > 100 - totalAllocatedPercentage + voteAllocationsPercentage[proposalId]) { - amount = 100 - totalAllocatedPercentage + voteAllocationsPercentage[proposalId] - } - - newVoteAllocationsPercentage[proposalId] = amount - setVoteAllocations({ ...voteAllocations, [proposalId]: Math.round((amount / 100) * voteWeight) }) - setVoteAllocationsPercentage(newVoteAllocationsPercentage) - } - useEffect(() => { const newVoteAllocationsPercentage = {} as VoteAllocation const newVoteAllocations = {} as VoteAllocation @@ -222,33 +207,12 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const handleSubmitVote = async () => { if (!canSubmitVote) return - const sumOfVotes = Object.values(voteAllocations).reduce((a, b) => a + b, 0) - const difference = voteWeight - sumOfVotes - - const newVoteAllocations = { ...voteAllocations } - - if (difference !== 0) { - let isAdjusted = false - if (difference < 0) { - Object.entries(newVoteAllocations).forEach(([key, value]) => { - if (value > Math.abs(difference) && !isAdjusted) { - newVoteAllocations[key] = value - Math.abs(difference) - isAdjusted = true - } - }) - } else { - Object.entries(newVoteAllocations).forEach(([key, value]) => { - if (newVoteAllocations[key] > 0 && !isAdjusted) { - newVoteAllocations[key] = value + difference - isAdjusted = true - } - }) - } - } - await submitVote({ signature: allowlistSignature || '', - selectedOptionIndexes: votingRoundMetadata.questions.map(() => 0), + selectedOptionIndexes: votingRoundMetadata.questions.map((q) => { + // Has been selected and selection is true, otherwise vote No + return q.id in voteState ? voteState[q.id] ? 0 : 1 : 1 + }), weighting: 0, weightings: votingRoundMetadata.questions.map(() => 0), signer: { addr: activeAddress, signer }, @@ -437,8 +401,8 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
{canVote && !hasVoted && ( - { - // updateVoteAllocations(question.id, parseFloat(e.target.value)) + { + setVoteState({...voteState, [question.id]: e.target.checked}) }}/> )}
From d37229517fbd017b9e9f2b30f0e6a13d4c7a88ee Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Mon, 4 Dec 2023 11:37:37 -0600 Subject: [PATCH 10/24] chore: change subdomain to bab --- infrastructure/bin/infrastructure.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/bin/infrastructure.ts b/infrastructure/bin/infrastructure.ts index 081be25d..6463f3d5 100644 --- a/infrastructure/bin/infrastructure.ts +++ b/infrastructure/bin/infrastructure.ts @@ -16,7 +16,7 @@ const deployer = new CDKDeployer({ const appDomainName = deployer.getEnvPrefixedDomainName(`voting.${process.env.BASE_DOMAIN}`) const apiDomainName = `api.${appDomainName}` const xGovAppDomainName = deployer.getEnvPrefixedDomainName(`xgov.${process.env.BASE_DOMAIN}`) -const eventsAppDomainName = deployer.getEnvPrefixedDomainName(`build-a-bull.${process.env.BASE_DOMAIN}`) +const eventsAppDomainName = deployer.getEnvPrefixedDomainName(`bab.${process.env.BASE_DOMAIN}`) const apiCertificateRequest: CertificateRequest = { isWildCard: false, From b0f233ce201ae7eb96dba4c0b512f8c7f112b1a1 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 12:39:17 -0600 Subject: [PATCH 11/24] build: make voteTotal optional --- .../src/features/rounds/VotingRoundTile.tsx | 2 +- .../features/vote-creation/review/index.tsx | 22 ------------------- src/build-a-bull/src/shared/ProposalCard.tsx | 2 +- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx b/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx index 769bc8ad..c2baa330 100644 --- a/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx +++ b/src/build-a-bull/src/features/rounds/VotingRoundTile.tsx @@ -209,7 +209,7 @@ export const VotingRoundTile = ({ globalState, votingRoundStatus }: VotingRoundT />
- +
diff --git a/src/build-a-bull/src/features/vote-creation/review/index.tsx b/src/build-a-bull/src/features/vote-creation/review/index.tsx index ccd6e5e6..3f75c2ec 100644 --- a/src/build-a-bull/src/features/vote-creation/review/index.tsx +++ b/src/build-a-bull/src/features/vote-creation/review/index.tsx @@ -56,28 +56,6 @@ export default function Review() { setAuth(await auth.execute({ signer })) break case VoteCreationReviewSteps.Create: - console.log({ - auth: authData, - newRound: { - ...roundInfo, - voteType: VoteType.NO_SNAPSHOT, - questions: proposals.map((proposal) => { - return { - questionTitle: proposal.title, - questionDescription: proposal.description, - metadata: { - link: proposal.link, - category: proposal.category, - focus_area: proposal.focus_area, - threshold: Number(proposal.threshold), - ask: Number(proposal.ask), - }, - answers: ['Yes', 'No'], - } - }), - }, - signer, - }) // eslint-disable-next-line no-case-declarations const app = await create.execute({ auth: authData, diff --git a/src/build-a-bull/src/shared/ProposalCard.tsx b/src/build-a-bull/src/shared/ProposalCard.tsx index fcd41912..fcff3f17 100644 --- a/src/build-a-bull/src/shared/ProposalCard.tsx +++ b/src/build-a-bull/src/shared/ProposalCard.tsx @@ -13,7 +13,7 @@ export type ProposalCardProps = { threshold: number | undefined ask: number | undefined votesTally: number | undefined - totalVotes: number | undefined + totalVotes?: number | undefined hasClosed?: boolean forcePass?: boolean } From eae77ff7165ff2f6c62d18914f847ec37300bb1c Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 12:48:07 -0600 Subject: [PATCH 12/24] chore: remove debug statement --- src/build-a-bull/src/features/vote-creation/review/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/build-a-bull/src/features/vote-creation/review/index.tsx b/src/build-a-bull/src/features/vote-creation/review/index.tsx index 3f75c2ec..8ea73206 100644 --- a/src/build-a-bull/src/features/vote-creation/review/index.tsx +++ b/src/build-a-bull/src/features/vote-creation/review/index.tsx @@ -89,7 +89,6 @@ export default function Review() { break case VoteCreationReviewSteps.Bootstrap: - console.log(proposals) await bootstrap.execute({ app: appRef, signer, From 809de10d7fbcd0f5bfc1993e8c8468cbcd9b836f Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 13:21:39 -0600 Subject: [PATCH 13/24] fix: total vote count --- src/build-a-bull/src/features/vote/index.tsx | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/build-a-bull/src/features/vote/index.tsx b/src/build-a-bull/src/features/vote/index.tsx index c13467ab..6bc1414a 100644 --- a/src/build-a-bull/src/features/vote/index.tsx +++ b/src/build-a-bull/src/features/vote/index.tsx @@ -61,7 +61,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const [error, setError] = useState(null) - const [allowlistSignature, setAllowlistSignature] = useState(null) const [voteWeight, setVoteWeight] = useState(0) const [voteAllocationsPercentage, setVoteAllocationsPercentage] = useState({}) const [voteAllocations, setVoteAllocations] = useState({}) @@ -79,16 +78,19 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const hasVoted = voterVotes !== undefined ? true : false const hasClosed = votingRoundGlobalState && votingRoundGlobalState.close_time !== undefined ? true : false + function getTotalVotes() { + return votingRoundResults && votingRoundMetadata + ? votingRoundResults.reduce((c, r) => { + const isYesOption = votingRoundMetadata.questions.map((q) => q.options[0]).some((el) => el.id === r.optionId) + return isYesOption ? c + r.count : c + }, 0) + : 0 + } + const totalVotes = useMemo(() => getTotalVotes(), [votingRoundResults, votingRoundMetadata]) - const totalVotes = useMemo(()=>votingRoundResults ? votingRoundResults.reduce((c, r)=>c + r.count, 0) : 0, [votingRoundResults]) - - const [voteState, setVoteState] = useState<{[k: string]: boolean}>({}) + const [voteState, setVoteState] = useState<{ [k: string]: boolean }>({}) - const canSubmitVote = - canVote && - activeAddress && - votingRoundMetadata && - !hasVoted + const canSubmitVote = canVote && activeAddress && votingRoundMetadata && !hasVoted type VoteAllocation = { [key: string]: number @@ -208,10 +210,10 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | if (!canSubmitVote) return await submitVote({ - signature: allowlistSignature || '', + signature: '', selectedOptionIndexes: votingRoundMetadata.questions.map((q) => { // Has been selected and selection is true, otherwise vote No - return q.id in voteState ? voteState[q.id] ? 0 : 1 : 1 + return q.id in voteState ? (voteState[q.id] ? 0 : 1) : 1 }), weighting: 0, weightings: votingRoundMetadata.questions.map(() => 0), @@ -401,9 +403,12 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
{canVote && !hasVoted && ( - { - setVoteState({...voteState, [question.id]: e.target.checked}) - }}/> + { + setVoteState({ ...voteState, [question.id]: e.target.checked }) + }} + /> )}
From 1a6b8cf9205d8a1a28fd2cfcc20fe3a4079eced9 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 14:18:29 -0600 Subject: [PATCH 14/24] fix: update bab path for cloudfront --- .github/workflows/release.yml | 2 ++ infrastructure/bin/infrastructure.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d0967a9..786a2e34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -134,6 +134,7 @@ jobs: BASE_DOMAIN: algorand.foundation WEBSITE_BUILD_PATH: ${{ github.workspace }}/dapp/dist WEBSITE_BUILD_PATH_XGOV: ${{ github.workspace }}/xgov-dapp/dist + WEBSITE_BUILD_PATH_BAB: ${{ github.workspace }}/build-a-bull/dist API_BUILD_PATH: ${{ github.workspace }}/api/build WEB3_STORAGE_API_TOKEN: ${{ secrets.WEB3_STORAGE_API_TOKEN }} NODE_ENV: production @@ -190,6 +191,7 @@ jobs: BASE_DOMAIN: algorand.foundation WEBSITE_BUILD_PATH: ${{ github.workspace }}/dapp/dist WEBSITE_BUILD_PATH_XGOV: ${{ github.workspace }}/xgov-dapp/dist + WEBSITE_BUILD_PATH_BAB: ${{ github.workspace }}/build-a-bull/dist API_BUILD_PATH: ${{ github.workspace }}/api/build WEB3_STORAGE_API_TOKEN: ${{ secrets.WEB3_STORAGE_API_TOKEN }} NODE_ENV: production diff --git a/infrastructure/bin/infrastructure.ts b/infrastructure/bin/infrastructure.ts index 6463f3d5..f00c3a54 100644 --- a/infrastructure/bin/infrastructure.ts +++ b/infrastructure/bin/infrastructure.ts @@ -135,7 +135,7 @@ const xGovApp = deployer.deploy(StaticWebsiteStack, 'xgovweb', { }) const eventsApp = deployer.deploy(StaticWebsiteStack, 'eventweb', { - websiteFolder: process.env.WEBSITE_BUILD_PATH_XGOV ?? path.join(__dirname, '..', '..', 'src', 'build-a-bull', 'dist'), + websiteFolder: process.env.WEBSITE_BUILD_PATH_BAB ?? path.join(__dirname, '..', '..', 'src', 'build-a-bull', 'dist'), websiteNpmBuildCommand: 'build-events-dapp', customDomain: eventsDns?.getDefaultCustomDomainProps(deployer.defaultRegion, eventsAppDomainName), responseHeaders: responseHeaders, From 09fb6afbef746fce0d8b980c9ccad38b1d16b30c Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 14:30:57 -0600 Subject: [PATCH 15/24] debug: shell into actions --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 786a2e34..3be340f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -124,6 +124,8 @@ jobs: - build-infrastructure - build-api steps: + - name: Setup upterm session + uses: lhotari/action-upterm@v1 - name: Deploy uses: makerxstudio/shared-config/.github/actions/node-deploy-cdk@main env: From 3e4cc538e90d58136f18ed5bdd84ab11b144704c Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 14:46:18 -0600 Subject: [PATCH 16/24] fix: baba artifact name --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3be340f9..b6761845 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,7 +88,7 @@ jobs: with: working-directory: ./src/build-a-bull build-path: dist - artifact-name: build-a-bull-dapp + artifact-name: build-a-bull static-site: true static-site-env-prefix: VITE needs: @@ -124,8 +124,6 @@ jobs: - build-infrastructure - build-api steps: - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - name: Deploy uses: makerxstudio/shared-config/.github/actions/node-deploy-cdk@main env: From be5701eb4278c8c97ec071011cc730dfc941e4b8 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Dec 2023 14:53:54 -0600 Subject: [PATCH 17/24] fix: adds build a bull to artifact unzips --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6761845..0e1fd297 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -144,6 +144,7 @@ jobs: app-artifact-unzips: |- dapp:dapp/dist xgov-dapp:xgov-dapp/dist + build-a-bull:build-a-bull/dist api:api/build aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY_SECRET }} @@ -201,6 +202,7 @@ jobs: app-artifact-unzips: |- dapp:dapp/dist xgov-dapp:xgov-dapp/dist + build-a-bull:build-a-bull/dist api:api/build aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY_SECRET }} From 5e1d88234a1ebe7aa516f8a074ec8c097e759bbc Mon Sep 17 00:00:00 2001 From: Ori Shem-Tov Date: Wed, 6 Dec 2023 16:58:16 +0200 Subject: [PATCH 18/24] feat: Automated generation of the approved list for fund distribution --- .../src/features/vote/VoteResults.tsx | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/src/xgov-dapp/src/features/vote/VoteResults.tsx b/src/xgov-dapp/src/features/vote/VoteResults.tsx index a66289a6..4e26031e 100644 --- a/src/xgov-dapp/src/features/vote/VoteResults.tsx +++ b/src/xgov-dapp/src/features/vote/VoteResults.tsx @@ -39,7 +39,8 @@ export const VoteResults = ({ isLoadingVotingRoundResults, snapshot, }: VoteResultsProps) => { - const [isDownloadingCsv, setIsDownloadingCsv] = useState(false) + const [isDownloadingAddressesCsv, setIsDownloadingAddressesCsv] = useState(false) + const [isDownloadingProposalsCsv, setIsDownloadingProposalsCsv] = useState(false) const [error, setError] = useState(null) const isReserveListEnabled = reserveListSupportedVersions.includes(votingRoundMetadata?.version || '1.0.0') @@ -93,7 +94,7 @@ export const VoteResults = ({ const generateAddressesThatVotedCsv = async () => { if (votingRoundMetadata) { - setIsDownloadingCsv(true) + setIsDownloadingAddressesCsv(true) setError(null) try { const addresses = await fetchAddressesThatVoted(votingRoundGlobalState.appId) @@ -114,7 +115,49 @@ export const VoteResults = ({ setError('Unexpected error') } } - setIsDownloadingCsv(false) + setIsDownloadingAddressesCsv(false) + } + } + + const generateProposalsResultsCsv = async () => { + if (votingRoundMetadataClone) { + setIsDownloadingProposalsCsv(true) + setError(null) + try { + const csvData = Papa.unparse( + votingRoundMetadataClone.questions.map((question) => { + const threshold = question.metadata?.threshold + const votesTally = + question.options.length > 0 && optionIDsToCounts[question.options[0].id] ? optionIDsToCounts[question.options[0].id] : 0 + const percentage = threshold && threshold > 0 ? Math.min(100, (votesTally / threshold) * 100) : 100 + const hasPassed = percentage >= 100 + return { + question: question.prompt, + description: question.description, + category: question.metadata?.category, + focus_area: question.metadata?.focus_area, + link: question.metadata?.link, + threshold: question.metadata?.threshold, + ask: question.metadata?.ask, + votes: votesTally, + is_reserve_list: isReserveListEnabled && reserveList.length > 0 && reserveList.some((q) => q.id === question.id), + passed: hasPassed || (isReserveListEnabled && reserveList.length > 0 && passedReserveList.has(question.id)), + } + }), + ) + + const blob = new Blob([csvData], { type: 'text/csv' }) + saveAs(blob, `proposals-${votingRoundMetadataClone.title}.csv`) + } catch (e) { + if (e instanceof Error) { + setError(e.message) + } else { + // eslint-disable-next-line no-console + console.error(e) + setError('Unexpected error') + } + } + setIsDownloadingProposalsCsv(false) } } @@ -252,12 +295,23 @@ export const VoteResults = ({ variant="contained" color="primary" onClick={generateAddressesThatVotedCsv} - disabled={isLoadingVotingRoundData || isDownloadingCsv} + disabled={isLoadingVotingRoundData || isDownloadingAddressesCsv} endIcon={} > Download addresses that voted +
+ +
{error && (
From 80b0c1c6940c456c012755a5f751ba9cf1779b8e Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Wed, 6 Dec 2023 12:51:55 -0600 Subject: [PATCH 19/24] chore: update voting instructions --- .../src/features/vote/VotingInstructions.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/build-a-bull/src/features/vote/VotingInstructions.tsx b/src/build-a-bull/src/features/vote/VotingInstructions.tsx index 4c35f9a5..967612a0 100644 --- a/src/build-a-bull/src/features/vote/VotingInstructions.tsx +++ b/src/build-a-bull/src/features/vote/VotingInstructions.tsx @@ -13,18 +13,11 @@ export const VotingInstructions = ({ voteWeight }: { voteWeight: number }) => { Voting instructions - For this event, your voting power is{' '} - - {voteWeight.toLocaleString()} Vote{voteWeight === 1 ? '' : 's'} - - . - - - Please distribute percentages of your voting power to your selected project below, totalling to{' '} + Select the projects you wish to vote for 100%. - Once you cast your vote{voteWeight === 1 ? '' : 's'}, you cannot change them. + Once you cast your vote, you cannot change them.
From ce7c6f6f2c15a11821744b279ebf16d9c6b2c0bf Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Wed, 6 Dec 2023 12:52:42 -0600 Subject: [PATCH 20/24] chore: update voting header and submit message --- src/build-a-bull/src/features/vote/index.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/build-a-bull/src/features/vote/index.tsx b/src/build-a-bull/src/features/vote/index.tsx index 6bc1414a..c2a70896 100644 --- a/src/build-a-bull/src/features/vote/index.tsx +++ b/src/build-a-bull/src/features/vote/index.tsx @@ -360,17 +360,6 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | Projects )} -
- {canVote && !hasVoted && ( - <> - Your allocations - - {totalAllocatedPercentage}% total · {100 - totalAllocatedPercentage}% remaining to allocate - - - )} -
- {isLoadingVotingRoundData && (
@@ -515,7 +504,7 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
- {!hasVoted ? 'Once your allocations total to 100%, you’ll be able to cast your votes!' : "You've already voted!"} + {!hasVoted ? 'Submit your vote!' : "You've already voted!"}
From c0634d0bd8e411b1ea3665bdbba3cd656aeb8d2a Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Wed, 6 Dec 2023 12:53:59 -0600 Subject: [PATCH 21/24] feat: download results csv --- .../src/features/vote/VoteResults.tsx | 188 ++++-------------- 1 file changed, 37 insertions(+), 151 deletions(-) diff --git a/src/build-a-bull/src/features/vote/VoteResults.tsx b/src/build-a-bull/src/features/vote/VoteResults.tsx index acc34c5b..3287bf89 100644 --- a/src/build-a-bull/src/features/vote/VoteResults.tsx +++ b/src/build-a-bull/src/features/vote/VoteResults.tsx @@ -2,24 +2,16 @@ import FileDownloadIcon from '@mui/icons-material/FileDownload' import { Alert, Button, Skeleton, Typography } from '@mui/material' import { saveAs } from 'file-saver' import Papa from 'papaparse' -import { useMemo, useState } from 'react' +import { useState } from 'react' import { Link } from 'react-router-dom' -import { Question, VoteGatingSnapshot, VotingRoundMetadata } from '@/shared/IPFSGateway' -import { VotingRoundGlobalState, fetchAddressesThatVoted } from '@/shared/VotingRoundContract' +import { VotingRoundMetadata } from '@/shared/IPFSGateway' +import { VotingRoundGlobalState } from '@/shared/VotingRoundContract' import { ProposalCard } from '@/shared/ProposalCard' import { VotingRoundResult } from '@/shared/types' -import { - generateOptionIDsToCountsMapping, - generatePassedReserveList, - generateReserveList, - isReserveList, - transformToDynamicThresholds, -} from '@/utils/common' -import AlgoStats from './AlgoStats' +import { generateOptionIDsToCountsMapping } from '@/utils/common' import { VoteDetails } from './VoteDetails' import VotingStats from './VotingStats' import { VotingTime } from './VotingTime' -import { dynamicThresholdSupportedVersions, reserveListSupportedVersions } from '@/constants' export type VoteResultsProps = { votingRoundResults: VotingRoundResult[] | undefined @@ -27,7 +19,6 @@ export type VoteResultsProps = { votingRoundGlobalState: VotingRoundGlobalState isLoadingVotingRoundData: boolean isLoadingVotingRoundResults: boolean - snapshot?: VoteGatingSnapshot | undefined myVotes?: string[] } @@ -37,74 +28,30 @@ export const VoteResults = ({ votingRoundGlobalState, isLoadingVotingRoundData, isLoadingVotingRoundResults, - snapshot, }: VoteResultsProps) => { - const [isDownloadingCsv, setIsDownloadingCsv] = useState(false) + const [isDownloadingProposalsCsv, setIsDownloadingProposalsCsv] = useState(false) const [error, setError] = useState(null) - const isReserveListEnabled = reserveListSupportedVersions.includes(votingRoundMetadata?.version || '1.0.0') - const isDynamicThresholdEnabled = dynamicThresholdSupportedVersions.includes(votingRoundMetadata?.version || '1.0.0') - const optionIDsToCounts = votingRoundResults !== undefined ? generateOptionIDsToCountsMapping(votingRoundResults) : {} - // clone the voting round metadata and adjust the threshold to be out of total votes instead of total voting power - // we clone the metadata so that we don't mutate the original metadata - const votingRoundMetadataClone = useMemo(() => { - if ( - votingRoundMetadata === undefined || - snapshot === undefined || - votingRoundResults === undefined || - isLoadingVotingRoundResults === true || - isLoadingVotingRoundData === true - ) { - return undefined - } - if (!isDynamicThresholdEnabled) { - return votingRoundMetadata - } - const totalVotes = votingRoundResults.reduce((accumulator, curr) => { - return accumulator + curr.count - }, 0) - - const totalVotingPower = snapshot.snapshot.reduce((accumulator, curr) => { - return accumulator + (curr.weight || 0) - }, 0) - // change threshold to be out of total votes instead of total voting power - // according to https://algorandfoundation.atlassian.net/browse/AF-73 - return transformToDynamicThresholds(votingRoundMetadata, totalVotes, totalVotingPower) - }, [votingRoundMetadata, snapshot, isLoadingVotingRoundData, isLoadingVotingRoundResults]) - - const reserveList = useMemo(() => { - if (!isReserveListEnabled) { - return [] - } - if (votingRoundMetadataClone === undefined) { - return [] - } - return generateReserveList(votingRoundMetadataClone, optionIDsToCounts) - }, [votingRoundMetadataClone]) - - const passedReserveList = useMemo>(() => { - if (reserveList.length === 0 || votingRoundResults === undefined || votingRoundMetadataClone === undefined) { - return new Set() - } - return generatePassedReserveList(reserveList, votingRoundResults, votingRoundMetadataClone) - }, [reserveList, votingRoundResults, votingRoundMetadataClone]) - - const generateAddressesThatVotedCsv = async () => { + const generateProposalsResultsCsv = async () => { if (votingRoundMetadata) { - setIsDownloadingCsv(true) + setIsDownloadingProposalsCsv(true) setError(null) try { - const addresses = await fetchAddressesThatVoted(votingRoundGlobalState.appId) const csvData = Papa.unparse( - addresses.map((address) => { - return { address } + votingRoundMetadata.questions.map((question) => { + const votesTally = + question.options.length > 0 && optionIDsToCounts[question.options[0].id] ? optionIDsToCounts[question.options[0].id] : 0 + return { + project: question.prompt, + votes: votesTally, + } }), ) const blob = new Blob([csvData], { type: 'text/csv' }) - saveAs(blob, `voters-${votingRoundMetadata.title}.csv`) + saveAs(blob, `proposals-${votingRoundMetadata.title}.csv`) } catch (e) { if (e instanceof Error) { setError(e.message) @@ -114,7 +61,7 @@ export const VoteResults = ({ setError('Unexpected error') } } - setIsDownloadingCsv(false) + setIsDownloadingProposalsCsv(false) } } @@ -137,15 +84,6 @@ export const VoteResults = ({ roundMetadata={votingRoundMetadata} /> -
- -
))} {!isLoadingVotingRoundResults && - votingRoundMetadataClone?.questions - .filter((q) => - isReserveListEnabled && q.options.length > 0 && optionIDsToCounts[q.options[0].id] - ? !isReserveList(q, optionIDsToCounts[q.options[0].id]) - : true, - ) - .map((question) => ( -
- {question.metadata && ( - 0 && optionIDsToCounts[question.options[0].id] - ? optionIDsToCounts[question.options[0].id] - : 0 - } - hasClosed={true} - /> - )} -
- ))} - {isReserveListEnabled && reserveList.length > 0 && ( - <> -
- Reserve List + votingRoundMetadata?.questions.map((question) => ( +
+ {question.metadata && ( + 0 && optionIDsToCounts[question.options[0].id] ? optionIDsToCounts[question.options[0].id] : 0 + } + hasClosed={true} + /> + )}
- {isLoadingVotingRoundData || - (isLoadingVotingRoundResults && ( - <> -
- -
-
- -
-
- -
- - ))} - {!isLoadingVotingRoundResults && - reserveList.map((question) => ( -
- {question.metadata && ( - 0 && optionIDsToCounts[question.options[0].id] - ? optionIDsToCounts[question.options[0].id] - : 0 - } - hasClosed={true} - forcePass={passedReserveList.has(question.id)} - /> - )} -
- ))} - - )} + ))}
{error && ( From 23651134a9975f8f86bfc410f073e5d9f9230040 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Thu, 7 Dec 2023 10:20:16 -0600 Subject: [PATCH 22/24] refactor: remove category from filter --- src/build-a-bull/src/features/vote/FilterMenu.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/build-a-bull/src/features/vote/FilterMenu.tsx b/src/build-a-bull/src/features/vote/FilterMenu.tsx index d445262b..28904b6a 100644 --- a/src/build-a-bull/src/features/vote/FilterMenu.tsx +++ b/src/build-a-bull/src/features/vote/FilterMenu.tsx @@ -100,17 +100,6 @@ export function FilterMenu({ {fa} ))} - - - Category - - {categories.map((fa) => ( - onChange('category', fa)}> - {isSelected('category', fa) ? : } - {fa} - - ))} - Clear
From d699f6f4f8f8966958e68df4c142e6d1806cce68 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Thu, 7 Dec 2023 10:56:22 -0600 Subject: [PATCH 23/24] refactor: remove percentage from instructions --- src/build-a-bull/src/features/vote/VotingInstructions.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/build-a-bull/src/features/vote/VotingInstructions.tsx b/src/build-a-bull/src/features/vote/VotingInstructions.tsx index 967612a0..83f0505a 100644 --- a/src/build-a-bull/src/features/vote/VotingInstructions.tsx +++ b/src/build-a-bull/src/features/vote/VotingInstructions.tsx @@ -13,8 +13,7 @@ export const VotingInstructions = ({ voteWeight }: { voteWeight: number }) => { Voting instructions - Select the projects you wish to vote for - 100%. + Select the projects you wish to vote for. Once you cast your vote, you cannot change them. From f73a5d2be912a6bd12097d4c25fcdef29fae492b Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Thu, 7 Dec 2023 11:28:02 -0600 Subject: [PATCH 24/24] chore: fix bab lint errors --- .../src/components/siteHeader.tsx | 2 +- .../src/features/vote-creation/RoundInfo.tsx | 2 -- .../features/vote-creation/review/index.tsx | 2 +- .../src/features/vote/FilterMenu.tsx | 11 +--------- .../src/features/vote/VotingInstructions.tsx | 6 ++---- .../src/features/vote/VotingStats.tsx | 4 +--- src/build-a-bull/src/features/vote/index.tsx | 16 ++++++--------- src/build-a-bull/src/root.tsx | 20 +++++++++---------- src/build-a-bull/src/shared/api.ts | 2 +- 9 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/build-a-bull/src/components/siteHeader.tsx b/src/build-a-bull/src/components/siteHeader.tsx index 71fe6552..df9ed57f 100644 --- a/src/build-a-bull/src/components/siteHeader.tsx +++ b/src/build-a-bull/src/components/siteHeader.tsx @@ -7,7 +7,7 @@ import algorandFoundationLogo from '../assets/algorand-foundation-logo.svg' import { useConnectedWallet, useCreatorAddresses, useSetShowConnectWalletModal } from '../features/wallet/state' import { getWalletLabel } from '../shared/wallet' import { MenuIcon, XIcon } from './icons' -import { forwardRef } from "react"; +import { forwardRef } from 'react' interface Link { name: string diff --git a/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx b/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx index d5009a58..b408a07c 100644 --- a/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx +++ b/src/build-a-bull/src/features/vote-creation/RoundInfo.tsx @@ -1,10 +1,8 @@ import { ValidatedForm, z, zfd } from '@makerx/forms-mui' import { Typography } from '@mui/material' -import { decodeAddress } from 'algosdk' import dayjs from 'dayjs' import Papa from 'papaparse' import { useNavigate } from 'react-router-dom' -import { SnapshotRow } from '@/shared/csvSigner' import { useRoundInfo, useSetRoundInfo } from './state' export type Proposal = { diff --git a/src/build-a-bull/src/features/vote-creation/review/index.tsx b/src/build-a-bull/src/features/vote-creation/review/index.tsx index 8ea73206..24e74c27 100644 --- a/src/build-a-bull/src/features/vote-creation/review/index.tsx +++ b/src/build-a-bull/src/features/vote-creation/review/index.tsx @@ -1,4 +1,4 @@ -import { Alert, Box, Button, Link, Stack, TextField, Typography } from '@mui/material' +import { Alert, Button, Link, Typography } from '@mui/material' import { useState } from 'react' import { useNavigate } from 'react-router-dom' diff --git a/src/build-a-bull/src/features/vote/FilterMenu.tsx b/src/build-a-bull/src/features/vote/FilterMenu.tsx index 28904b6a..2a4dd1de 100644 --- a/src/build-a-bull/src/features/vote/FilterMenu.tsx +++ b/src/build-a-bull/src/features/vote/FilterMenu.tsx @@ -1,5 +1,5 @@ import { MouseEvent, useMemo, useState } from 'react' -import { Divider, IconButton, ListItemIcon, Menu, MenuItem } from '@mui/material' +import { IconButton, ListItemIcon, Menu, MenuItem } from '@mui/material' import FilterAltIcon from '@mui/icons-material/FilterAlt' import { Question } from '@/shared/IPFSGateway' import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank' @@ -42,15 +42,6 @@ export function FilterMenu({ }, [] as string[]) }, [questions]) - const categories = useMemo(() => { - return questions.reduce((prev, curr) => { - if (typeof curr?.metadata?.category === 'string' && !prev.includes(curr.metadata.category)) { - prev.push(curr.metadata.category) - } - return prev - }, [] as string[]) - }, [questions]) - const isSelected = (type: string, name: string) => { return selected.some((s) => s.type === type && s.name === name) } diff --git a/src/build-a-bull/src/features/vote/VotingInstructions.tsx b/src/build-a-bull/src/features/vote/VotingInstructions.tsx index 83f0505a..9b213e4b 100644 --- a/src/build-a-bull/src/features/vote/VotingInstructions.tsx +++ b/src/build-a-bull/src/features/vote/VotingInstructions.tsx @@ -2,7 +2,7 @@ import { BoltIcon } from '@heroicons/react/24/solid' import { Typography } from '@mui/material' import { Box } from '@mui/system' -export const VotingInstructions = ({ voteWeight }: { voteWeight: number }) => { +export const VotingInstructions = (_: { voteWeight: number }) => { return (
@@ -12,9 +12,7 @@ export const VotingInstructions = ({ voteWeight }: { voteWeight: number }) => { Voting instructions - - Select the projects you wish to vote for. - + Select the projects you wish to vote for. Once you cast your vote, you cannot change them. diff --git a/src/build-a-bull/src/features/vote/VotingStats.tsx b/src/build-a-bull/src/features/vote/VotingStats.tsx index 2c83a5fa..bbae0f5a 100644 --- a/src/build-a-bull/src/features/vote/VotingStats.tsx +++ b/src/build-a-bull/src/features/vote/VotingStats.tsx @@ -19,9 +19,7 @@ const VotingStats: React.FC = ({ votingRoundGlobalSta Voting stats {isLoading ? : null} - {!isLoading && votingRoundGlobalState && ( - {`${votingRoundGlobalState.voter_count} wallets voted`} - )} + {!isLoading && votingRoundGlobalState && {`${votingRoundGlobalState.voter_count} wallets voted`}}  
diff --git a/src/build-a-bull/src/features/vote/index.tsx b/src/build-a-bull/src/features/vote/index.tsx index c2a70896..74585c9b 100644 --- a/src/build-a-bull/src/features/vote/index.tsx +++ b/src/build-a-bull/src/features/vote/index.tsx @@ -5,11 +5,11 @@ import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward' import CancelIcon from '@mui/icons-material/Cancel' import ClearIcon from '@mui/icons-material/Clear' import ShuffleOnIcon from '@mui/icons-material/ShuffleOn' -import { Alert, Box, Button, Checkbox, IconButton, InputAdornment, Link, Skeleton, TextField, Typography } from '@mui/material' +import { Alert, Box, Button, Checkbox, IconButton, Link, Skeleton, Typography } from '@mui/material' import clsx from 'clsx' import { useEffect, useMemo, useState } from 'react' import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom' -import { Question, VoteGatingSnapshot, VotingRoundMetadata, fetchVotingRoundMetadata, fetchVotingSnapshot } from '@/shared/IPFSGateway' +import { Question, VotingRoundMetadata, fetchVotingRoundMetadata } from '@/shared/IPFSGateway' import { TallyCounts, VotingRoundGlobalState, @@ -61,15 +61,13 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' | const [error, setError] = useState(null) - const [voteWeight, setVoteWeight] = useState(0) - const [voteAllocationsPercentage, setVoteAllocationsPercentage] = useState({}) - const [voteAllocations, setVoteAllocations] = useState({}) + const [voteWeight] = useState(0) + const [_, setVoteAllocationsPercentage] = useState({}) + const [__, setVoteAllocations] = useState({}) const { loading: submittingVote, execute: submitVote, error: errorSubmittingVote } = api.useSubmitVote() const { loading: closingVotingRound, execute: closeVotingRound, error: closingVotingRoundError } = api.useCloseVotingRound() - const totalAllocatedPercentage = Object.values(voteAllocationsPercentage).reduce((a, b) => a + b, 0) - const hasVoteStarted = !votingRoundGlobalState ? false : getHasVoteStarted(votingRoundGlobalState) const hasVoteEnded = !votingRoundGlobalState ? false : getHasVoteEnded(votingRoundGlobalState) const isVoteCreator = votingRoundMetadata?.created.by === activeAddress ? true : false @@ -503,9 +501,7 @@ function Vote({ sort: sortProp = 'none' }: { sort?: 'ascending' | 'descending' |
- - {!hasVoted ? 'Submit your vote!' : "You've already voted!"} - + {!hasVoted ? 'Submit your vote!' : "You've already voted!"}