Skip to content

Commit

Permalink
Fix getBulkEnsRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Feb 21, 2024
1 parent f5a8c6e commit 1c4aeb7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 0 additions & 2 deletions apps/council-ui/pages/proposals/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 0 additions & 2 deletions apps/council-ui/pages/voters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ export function useVoterPageData(): UseQueryResult<VoterRowData[]> {
);

console.log({
voterPowerBreakdowns,
mergedBreakdowns,
ensRecords,
});

Expand Down
30 changes: 24 additions & 6 deletions apps/council-ui/src/utils/getBulkEnsRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,30 @@ export async function getBulkEnsRecords(
client: PublicClient | UsePublicClientReturnType,
options?: { chunkSize?: number },
): Promise<EnsRecords> {
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<typeof createEnsPublicClient>;
try {
ensClient = createEnsPublicClient({
chain: chains[0] as any,
chain: chain,
transport: transports[chain.id],
}) as ReturnType<typeof createEnsPublicClient>;
} catch (error) {
Expand All @@ -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
Expand Down

0 comments on commit 1c4aeb7

Please sign in to comment.