From 1c4aeb7696a7e9f1d2dc2ecf2b56cfc71e489483 Mon Sep 17 00:00:00 2001 From: Ryan Goree Date: Tue, 20 Feb 2024 23:42:23 -0600 Subject: [PATCH] Fix getBulkEnsRecords --- apps/council-ui/pages/proposals/details.tsx | 2 -- apps/council-ui/pages/voters/index.tsx | 2 -- .../council-ui/src/utils/getBulkEnsRecords.ts | 30 +++++++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/council-ui/pages/proposals/details.tsx b/apps/council-ui/pages/proposals/details.tsx index 9b3e3fee..48718f84 100644 --- a/apps/council-ui/pages/proposals/details.tsx +++ b/apps/council-ui/pages/proposals/details.tsx @@ -47,8 +47,6 @@ export default function ProposalPage(): ReactElement { ); const { gscMembers } = useGscMembers(); - console.log("coreVoting", coreVoting); - // // voting activity filtering const [gscOnly, setGscOnly] = useState(false); const filteredVotes = useMemo(() => { diff --git a/apps/council-ui/pages/voters/index.tsx b/apps/council-ui/pages/voters/index.tsx index 690035f4..77b9af6f 100644 --- a/apps/council-ui/pages/voters/index.tsx +++ b/apps/council-ui/pages/voters/index.tsx @@ -105,8 +105,6 @@ export function useVoterPageData(): UseQueryResult { ); console.log({ - voterPowerBreakdowns, - mergedBreakdowns, ensRecords, }); diff --git a/apps/council-ui/src/utils/getBulkEnsRecords.ts b/apps/council-ui/src/utils/getBulkEnsRecords.ts index 0671a4ff..b7c92f9b 100644 --- a/apps/council-ui/src/utils/getBulkEnsRecords.ts +++ b/apps/council-ui/src/utils/getBulkEnsRecords.ts @@ -23,12 +23,30 @@ export async function getBulkEnsRecords( client: PublicClient | UsePublicClientReturnType, options?: { chunkSize?: number }, ): Promise { - const chain = client?.chain || chains[0]; + let chain: any = client?.chain || chains[0]; + + // ensjs is currently incompatible with viem v2. There's a PR to fix this + // here: https://github.com/ensdomains/ensjs-v3/pull/175. + // Until then, we have to manually patch the chain definition for mainnet to + // look like the one ensjs expects. + if (chain.id === 1) { + chain = { + ...chain, + network: "homestead", + contracts: { + ...chain.contracts, + ensUniversalResolver: { + address: "0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62", + blockCreated: 16966585, + }, + }, + }; + } let ensClient: ReturnType; try { ensClient = createEnsPublicClient({ - chain: chains[0] as any, + chain: chain, transport: transports[chain.id], }) as ReturnType; } catch (error) { @@ -46,11 +64,11 @@ export async function getBulkEnsRecords( chunkedAddresses.map(async (chunk): Promise<[string, string | null][]> => { // batch call of ens names using MultiCall const batch = await ensClient.ensBatch( - ...chunk.map((address) => - getName.batch({ + ...chunk.map((address) => { + return getName.batch({ address, - }), - ), + }); + }), ); // batch may not exist if gas limited was reached when reading