diff --git a/actions/createProposal.ts b/actions/createProposal.ts index ad0818fe7d..4a71abf9d5 100644 --- a/actions/createProposal.ts +++ b/actions/createProposal.ts @@ -71,7 +71,8 @@ export const createProposal = async ( proposalIndex: number, instructionsData: InstructionDataWithHoldUpTime[], isDraft: boolean, - client?: VotingClient + client?: VotingClient, + callbacks?: Parameters[0]['callbacks'] ): Promise => { const instructions: TransactionInstruction[] = [] @@ -227,6 +228,7 @@ export const createProposal = async ( }) await sendTransactionsV3({ + callbacks, connection, wallet, transactionInstructions: txes, @@ -279,6 +281,7 @@ export const createProposal = async ( }) await sendTransactionsV3({ + callbacks, connection, wallet, transactionInstructions: txes, diff --git a/components/treasuryV2/Details/WalletDetails/Info/Rules/index.tsx b/components/treasuryV2/Details/WalletDetails/Info/Rules/index.tsx index 2a7b32cb97..aa022f2933 100644 --- a/components/treasuryV2/Details/WalletDetails/Info/Rules/index.tsx +++ b/components/treasuryV2/Details/WalletDetails/Info/Rules/index.tsx @@ -12,6 +12,7 @@ import { VoteTipping } from '@solana/spl-governance' import cx from 'classnames' import React, { useState } from 'react' import { BigNumber } from 'bignumber.js' +import { useRouter } from 'next/router' import { formatNumber } from '@utils/formatNumber' import { ntext } from '@utils/ntext' @@ -21,6 +22,7 @@ import useRealm from '@hooks/useRealm' import Tooltip from '@components/Tooltip' import { DISABLED_VOTER_WEIGHT } from '@tools/constants' import Address from '@components/Address' +import useQueryContext from '@hooks/useQueryContext' import Section from '../../../Section' import TokenIcon from '../../../../icons/TokenIcon' @@ -66,6 +68,17 @@ export function durationStr(duration: number, short = false) { return count + (short ? 's' : ' ' + ntext(count, 'second')) } +function votingLengthText(time: number) { + const hours = time / UNIX_HOUR + const days = Math.floor(hours / 24) + const remainingHours = (time - days * UNIX_DAY) / UNIX_HOUR + + return ( + durationStr(days * UNIX_DAY) + + (remainingHours ? ` ${durationStr(remainingHours * UNIX_HOUR)}` : '') + ) +} + interface Props { className?: string wallet: Wallet @@ -73,7 +86,9 @@ interface Props { export default function Rules(props: Props) { const [editRulesOpen, setEditRulesOpen] = useState(false) - const { ownVoterWeight } = useRealm() + const { ownVoterWeight, symbol } = useRealm() + const router = useRouter() + const { fmtUrlWithCluster } = useQueryContext() const programVersion = useProgramVersion() @@ -123,7 +138,15 @@ export default function Rules(props: Props) { 'disabled:opacity-50' )} disabled={!canEditRules} - onClick={() => setEditRulesOpen(true)} + onClick={() => { + if (props.wallet.governanceAccount) { + router.push( + fmtUrlWithCluster( + `/realm/${symbol}/governance/${props.wallet.governanceAccount.pubkey.toBase58()}/edit` + ) + ) + } + }} >
Edit Rules
@@ -138,8 +161,17 @@ export default function Rules(props: Props) {
} - name="Max Voting Time" - value={durationStr(props.wallet.rules.common.maxVotingTime)} + name="Unrestricted Voting Time" + value={votingLengthText( + props.wallet.rules.common.maxVotingTime + )} + /> +
} + name="Voting Cool-Off Time" + value={durationStr( + props.wallet.rules.common.votingCoolOffSeconds + )} />
} diff --git a/hooks/useTreasuryInfo/getRulesFromAccount.ts b/hooks/useTreasuryInfo/getRulesFromAccount.ts index 5a8f046da5..4f8818f019 100644 --- a/hooks/useTreasuryInfo/getRulesFromAccount.ts +++ b/hooks/useTreasuryInfo/getRulesFromAccount.ts @@ -17,6 +17,7 @@ export function getRulesFromAccount( rules.common = { maxVotingTime: govConfig.maxVotingTime, minInstructionHoldupTime: govConfig.minInstructionHoldUpTime, + votingCoolOffSeconds: govConfig.votingCoolOffTime, } } diff --git a/hub/.eslintrc.json b/hub/.eslintrc.json index f35f06c9c1..a796cbd634 100644 --- a/hub/.eslintrc.json +++ b/hub/.eslintrc.json @@ -5,7 +5,10 @@ "tsconfigRootDir": ".", "sourceType": "module" }, - "plugins": ["@typescript-eslint/eslint-plugin", "import"], + "plugins": [ + "@typescript-eslint/eslint-plugin", + "import" + ], "extends": [ "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended" @@ -15,7 +18,10 @@ "node": true, "jest": true }, - "ignorePatterns": [".eslintrc.js", "migrations"], + "ignorePatterns": [ + ".eslintrc.js", + "migrations" + ], "rules": { "@typescript-eslint/interface-name-prefix": "off", "@typescript-eslint/explicit-function-return-type": "off", @@ -27,7 +33,9 @@ "error", { "newlines-between": "always-and-inside-groups", - "pathGroupsExcludedImportTypes": ["builtin"], + "pathGroupsExcludedImportTypes": [ + "builtin" + ], "pathGroups": [ { "pattern": "@hub/**/**", @@ -52,6 +60,10 @@ { "pattern": "@verify-wallet/**/**", "group": "parent" + }, + { + "pattern": "@hooks/**/**", + "group": "parent" } ], "alphabetize": { diff --git a/hub/App.tsx b/hub/App.tsx index ad09290645..b3e730f218 100644 --- a/hub/App.tsx +++ b/hub/App.tsx @@ -1,6 +1,7 @@ import Head from 'next/head'; +import { useRouter } from 'next/router'; import Script from 'next/script'; -import React from 'react'; +import React, { useEffect } from 'react'; import { GlobalHeader } from '@hub/components/GlobalHeader'; import { MinimalHeader } from '@hub/components/GlobalHeader/MinimalHeader'; @@ -56,9 +57,31 @@ interface Props { } export function App(props: Props) { + const router = useRouter(); + const isDarkMode = router.pathname.startsWith('/realm/[id]/governance'); + + useEffect(() => { + if (isDarkMode) { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + }, [isDarkMode]); + return ( + {isDarkMode && ( +