Skip to content

Commit

Permalink
Merge pull request #855 from makerdao/develop
Browse files Browse the repository at this point in the history
master < develop
  • Loading branch information
adamgoth authored Mar 26, 2024
2 parents e563b97 + f79b6e5 commit a32bbf8
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 48 deletions.
8 changes: 6 additions & 2 deletions modules/app/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const HeaderMenu = ({ onToggleTheme, mode, ...props }): JSX.Element => {
};

const Header = (): JSX.Element => {
const isProduction = process.env.NODE_ENV === 'production';

const router = useRouter();
const [showMobileMenu, setShowMobileMenu] = useState(false);
const bpi = useBreakpointIndex();
Expand Down Expand Up @@ -259,7 +261,7 @@ const Header = (): JSX.Element => {
</ExternalLink>
)}
{bpi > 3 && account && router.pathname.includes('polling') && <BallotStatus mr={3} />}
{bpi > 1 && (
{!isProduction && bpi > 1 && (
<Flex mr={3}>
<NetworkSelect />
</Flex>
Expand Down Expand Up @@ -300,6 +302,8 @@ const Header = (): JSX.Element => {
};

const MobileMenu = ({ hide, router, gas, onToggleTheme, mode, network }) => {
const isProduction = process.env.NODE_ENV === 'production';

useEffect(() => {
if (typeof window !== 'undefined') {
router.events.on('routeChangeComplete', hide);
Expand All @@ -321,7 +325,7 @@ const MobileMenu = ({ hide, router, gas, onToggleTheme, mode, network }) => {
</IconButton>
</InternalLink>
<Flex sx={{ alignItems: 'center', gap: 2 }}>
<NetworkSelect />
{!isProduction && <NetworkSelect />}
<Close sx={{ display: ['block'], '> svg': { size: [4] } }} onClick={hide} />
</Flex>
</Flex>
Expand Down
1 change: 1 addition & 0 deletions modules/app/components/layout/header/NetworkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const NetworkSelect = (): React.ReactElement => {
.filter(
k => ![SupportedChainId.GOERLIFORK].includes(CHAIN_INFO[k].chainId) && CHAIN_INFO[k].type === 'normal'
)
.filter(k => process.env.NODE_ENV !== 'production' || CHAIN_INFO[k].showInProduction)
.map(chainKey => (
<Flex
sx={walletButtonStyle}
Expand Down
4 changes: 1 addition & 3 deletions modules/delegates/helpers/formatDelegationHistoryChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export const formatDelegationHistoryChart = (

const years = differenceInCalendarYears(Date.now(), new Date(lockEvents[0].blockTimestamp));

const end =
years * 365 +
formatIsoDateConversion((new Date()).toISOString());
const end = years * 365 + formatIsoDateConversion(new Date().toISOString());

const output: MKRWeightHisory[] = [];

Expand Down
4 changes: 2 additions & 2 deletions modules/executive/api/fetchExecutiveVoteTally.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export async function fetchExecutiveVoteTally(chief: Chief): Promise<any | null>
}
});

// We need to split the voters array into chunks of 1000 addresses because our
// We need to split the voters array into chunks because our
// Alchemy key doesn't support batch requests larger than 1000 queries each
const chunkSize = 1000;
const chunkSize = 900;
const voterChunks = Array.from({ length: Math.ceil(voters.length / chunkSize) }, (_, i) =>
voters.slice(i * chunkSize, i * chunkSize + chunkSize)
);
Expand Down
12 changes: 6 additions & 6 deletions modules/polling/components/PollWinningOptionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export default function PollWinningOptionBox({
isDefault = true;
}

// Winner will be null if the winning conditions are not met, but we want to display the leading option too
const leadingOption = typeof tally.winner === 'number' ? tally.winner : tally.results[0].optionId;
const leadingOptionName = `${
typeof tally.winner === 'number' ? tally.winningOptionName : tally.results[0].optionName
//don't show "& n more" if isDefault since there's only ever 1 default option
}${!isDefault && numberOfLeadingOptions > 1 ? ` & ${numberOfLeadingOptions - 1} more` : ''}`;
// Winner will be null if the winning conditions are not met, but we want to display the leading option too
const leadingOption = typeof tally.winner === 'number' ? tally.winner : tally.results[0].optionId;
const leadingOptionName = `${
typeof tally.winner === 'number' ? tally.winningOptionName : tally.results[0].optionName
//don't show "& n more" if isDefault since there's only ever 1 default option
}${!isDefault && numberOfLeadingOptions > 1 ? ` & ${numberOfLeadingOptions - 1} more` : ''}`;

return (
<Flex sx={{ py: 2, justifyContent: 'center' }}>
Expand Down
26 changes: 25 additions & 1 deletion modules/tags/constants/poll-tags-mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -1042,5 +1042,29 @@
"1064": ["high-impact", "risk-parameter", "spark"],
"1065": ["high-impact", "spark"],
"1066": ["medium-impact", "spark"],
"1067": ["high-impact", "risk-parameter", "spark"]
"1067": ["high-impact", "risk-parameter", "spark"],
"1068": ["high-impact", "risk-parameter", "spark"],
"1069": ["high-impact", "spark"],
"1070": ["high-impact", "oracle", "spark"],
"1071": ["medium-impact", "risk-parameter", "auctions"],
"1072": ["high-impact", "ratification", "mips", "endgame"],
"1073": ["high-impact", "ratification", "mips", "endgame"],
"1074": ["high-impact", "ratification", "mips", "endgame"],
"1075": ["high-impact", "ratification", "mips", "endgame"],
"1076": ["high-impact", "risk-parameter", "spark"],
"1077": ["medium-impact", "risk-parameter"],
"1078": ["medium-impact", "risk-parameter"],
"1080": ["high-impact", "risk-parameter", "spark"],
"1081": ["high-impact", "risk-parameter", "spark"],
"1082": ["high-impact", "risk-parameter", "spark"],
"1083": ["high-impact", "risk-parameter"],
"1084": ["high-impact", "risk-parameter", "endgame", "d3m", "spark"],
"1085": ["high-impact", "risk-parameter", "endgame", "spark"],
"1086": ["medium-impact", "misc-governance", "endgame"],
"1087": ["high-impact", "ratification", "mips"],
"1088": ["high-impact", "mips"],
"1089": ["high-impact", "risk-parameter"],
"1090": ["high-impact", "spark"],
"1091": ["high-impact", "spark"],
"1092": ["high-impact", "spark"]
}
2 changes: 1 addition & 1 deletion modules/web3/components/NetworkAlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const NetworkAlertModal = ({

<Text sx={{ mt: 3 }}>
Your wallet is connected to an unsupported network, please switch it to{' '}
{SupportedNetworks.MAINNET} or {SupportedNetworks.GOERLI} to continue.
{SupportedNetworks.MAINNET} to continue.
</Text>
{/* <Button onClick={() => handleSwitchNetwork(SupportedNetworks.MAINNET)}>Switch to mainnet</Button>
<Button onClick={() => handleSwitchNetwork(SupportedNetworks.GOERLI)}>Switch to goerli</Button> */}
Expand Down
18 changes: 12 additions & 6 deletions modules/web3/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const CHAIN_INFO: ChainInfo = {
rpcs: {
[NodeProviders.INFURA]: `https://mainnet.infura.io/v3/${config.INFURA_KEY}`,
[NodeProviders.ALCHEMY]: `https://eth-mainnet.g.alchemy.com/v2/${config.ALCHEMY_KEY}`
}
},
showInProduction: true
},
[SupportedChainId.GOERLI]: {
blockExplorerUrl: 'goerli.etherscan.io',
Expand All @@ -75,7 +76,8 @@ export const CHAIN_INFO: ChainInfo = {
rpcs: {
[NodeProviders.INFURA]: `https://goerli.infura.io/v3/${config.INFURA_KEY}`,
[NodeProviders.ALCHEMY]: `https://eth-goerli.alchemyapi.io/v2/${config.ALCHEMY_KEY}`
}
},
showInProduction: false
},
[SupportedChainId.GOERLIFORK]: {
blockExplorerUrl: 'goerli.etherscan.io',
Expand All @@ -88,7 +90,8 @@ export const CHAIN_INFO: ChainInfo = {
spockUrl: LOCAL_SPOCK_URL,
rpcs: {
[NodeProviders.LOCAL]: 'http://127.0.0.1:8545/'
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUMTESTNET]: {
blockExplorerUrl: 'goerli-rollup-explorer.arbitrum.io',
Expand All @@ -100,7 +103,8 @@ export const CHAIN_INFO: ChainInfo = {
defaultRpc: NodeProviders.ALCHEMY,
rpcs: {
[NodeProviders.ALCHEMY]: `https://arb-goerli.g.alchemy.com/v2/${config.ALCHEMY_ARBITRUM_TESTNET_KEY}`
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUMTESTNETFORK]: {
blockExplorerUrl: 'goerli-rollup-explorer.arbitrum.io',
Expand All @@ -113,7 +117,8 @@ export const CHAIN_INFO: ChainInfo = {
spockUrl: LOCAL_SPOCK_URL,
rpcs: {
[NodeProviders.LOCAL]: 'http://127.0.0.1:8546/'
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUM]: {
blockExplorerUrl: 'arbiscan.io',
Expand All @@ -125,7 +130,8 @@ export const CHAIN_INFO: ChainInfo = {
defaultRpc: NodeProviders.ALCHEMY,
rpcs: {
[NodeProviders.ALCHEMY]: `https://arb-mainnet.g.alchemy.com/v2/${config.ALCHEMY_ARBITRUM_KEY}`
}
},
showInProduction: false
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/web3/helpers/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const networkNameToChainId = (networkName: string): number => {

export const isSupportedChain = (chainId?: number): boolean => {
if (!chainId) return false;
return CHAIN_INFO[chainId] && CHAIN_INFO[chainId].type === 'normal';
return CHAIN_INFO[chainId] && CHAIN_INFO[chainId].type === 'normal' && (process.env.NODE_ENV !== 'production' || CHAIN_INFO[chainId].showInProduction);
};

export const getGaslessNetwork = (network: SupportedNetworks): SupportedNetworks => {
Expand Down
2 changes: 1 addition & 1 deletion modules/web3/helpers/getContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getContracts = (

// If our account or network changes, recreate the contracts SDK
if (changeAccount || changeNetwork || !contracts || (needsSigner && !hasSigner(contracts))) {
const providerToUse = provider ?? getDefaultProvider(rpcUrl);
const providerToUse = provider ?? getDefaultProvider(network);

const signerOrProvider = needsSigner
? (providerToUse as providers.Web3Provider).getSigner(account)
Expand Down
27 changes: 15 additions & 12 deletions modules/web3/helpers/getDefaultProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ import { ethers, providers } from 'ethers';
ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR);

export const getDefaultProvider = (
network: SupportedNetworks | string | undefined,
optionsOverrides?: Record<string, string>
): providers.BaseProvider => {
const options = {
infura: config.INFURA_KEY,
alchemy: config.ALCHEMY_KEY,
pocket: config.POCKET_KEY,
etherscan: config.ETHERSCAN_KEY,
...(optionsOverrides || {})
network: SupportedNetworks | string | undefined
): providers.FallbackProvider => {
const infuraProvider = new ethers.providers.InfuraProvider(network, config.INFURA_KEY);
const alchemyProvider = new ethers.providers.AlchemyProvider(network, config.ALCHEMY_KEY);
const pocketProvider = new ethers.providers.PocketProvider(network, config.POCKET_KEY);
const etherscanProvider = new ethers.providers.EtherscanProvider(network, config.ETHERSCAN_KEY);

const provider = new ethers.providers.FallbackProvider([
{ provider: infuraProvider, priority: 2 },
{ provider: alchemyProvider, priority: 1 },
{ provider: pocketProvider, priority: 3 },
{ provider: etherscanProvider, priority: 3 }
], 1); //Quorum of 1

return provider;
};

return ethers.getDefaultProvider(network, options);
};
4 changes: 3 additions & 1 deletion modules/web3/helpers/getEthersContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getRPCFromChainID } from './getRPC';
import { chainIdToNetworkName } from './chain';
import { SupportedChainId } from '../constants/chainID';
import { Contract, ethers, providers } from 'ethers';
import { DEFAULT_NETWORK } from '../constants/networks';
Expand All @@ -21,8 +22,9 @@ export const getEthersContracts = <T extends Contract>(
readOnly?: boolean
): T => {
const rcpUrl = getRPCFromChainID(chainId ?? DEFAULT_NETWORK.chainId);
const network = chainIdToNetworkName(chainId ?? DEFAULT_NETWORK.chainId);

const providerToUse = readOnly ? new providers.JsonRpcBatchProvider(rcpUrl) : getDefaultProvider(rcpUrl);
const providerToUse = readOnly ? new providers.JsonRpcBatchProvider(rcpUrl) : getDefaultProvider(network);

const signerOrProvider =
account && provider
Expand Down
1 change: 1 addition & 0 deletions modules/web3/types/chain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type SupportedChain = {
defaultRpc: string;
spockUrl?: string;
type: 'gasless' | 'normal';
showInProduction: boolean;
rpcs: {
[key: string]: string;
};
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


"@adobe/css-tools@^4.0.1":
version "4.3.1"
resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.3.1.tgz#abfccb8ca78075a2b6187345c26243c1a0842f28"
integrity sha512-/62yikz7NLScCGAAST5SHdnjaDJQBDq0M2muyRTpf2VQhw6StBg2ALiu73zSJQ4fMVLA+0uBhBHAle7Wg+2kSg==
version "4.3.2"
resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.3.2.tgz#a6abc715fb6884851fca9dad37fc34739a04fd11"
integrity sha512-DA5a1C0gD/pLOvhv33YMrbf2FK3oUzwNl9oOJqE4XVjuEtt6XIakRcsd7eLiOSPkp1kTRQGICTA8cKra/vFbjw==

"@ampproject/remapping@^2.2.0":
version "2.2.1"
Expand Down Expand Up @@ -8482,9 +8482,9 @@ focus-lock@^0.11.6:
tslib "^2.0.3"

follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.14.7, follow-redirects@^1.14.9, follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
version "1.15.6"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==

for-each@^0.3.3:
version "0.3.3"
Expand Down Expand Up @@ -10561,9 +10561,9 @@ joi@^17.7.0:
"@sideway/pinpoint" "^2.0.0"

jose@^4.11.4:
version "4.14.4"
resolved "https://registry.yarnpkg.com/jose/-/jose-4.14.4.tgz#59e09204e2670c3164ee24cbfe7115c6f8bff9ca"
integrity sha512-j8GhLiKmUAh+dsFXlX1aJCbt5KMibuKb+d7j1JaOJG6s2UjX1PQlW+OKB/sD4a/5ZYF4RcmYmLSndOoU3Lt/3g==
version "4.15.5"
resolved "https://registry.yarnpkg.com/jose/-/jose-4.15.5.tgz#6475d0f467ecd3c630a1b5dadd2735a7288df706"
integrity sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==

js-cookie@^2.2.1:
version "2.2.1"
Expand Down Expand Up @@ -15149,9 +15149,9 @@ undici-types@~5.26.4:
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici@^5.14.0:
version "5.26.3"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.26.3.tgz#ab3527b3d5bb25b12f898dfd22165d472dd71b79"
integrity sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==
version "5.28.3"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.3.tgz#a731e0eff2c3fcfd41c1169a869062be222d1e5b"
integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==
dependencies:
"@fastify/busboy" "^2.0.0"

Expand Down

0 comments on commit a32bbf8

Please sign in to comment.