Skip to content

Commit

Permalink
Update cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Jul 10, 2024
1 parent 47794b2 commit 43221ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/getRollupAddress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address, Chain, PublicClient, Transport } from 'viem';
import { sequencerInboxABI } from './abi';

const cache: Record<Address, Address> = {};
const cache: Record<string, Address> = {};
export async function getRollupAddress<TChain extends Chain | undefined>(
publicClient: PublicClient<Transport, TChain>,
params: { sequencerInbox: Address } | { rollupAdminLogic: Address },
Expand All @@ -11,7 +11,7 @@ export async function getRollupAddress<TChain extends Chain | undefined>(
return params.rollupAdminLogic;
}

const addressFromCache = cache[params.sequencerInbox];
const addressFromCache = cache[`${publicClient.chain?.id}_${params.sequencerInbox}`];
if (addressFromCache) {
return addressFromCache;
}
Expand All @@ -22,6 +22,6 @@ export async function getRollupAddress<TChain extends Chain | undefined>(
address: params.sequencerInbox,
abi: sequencerInboxABI,
});
cache[params.sequencerInbox] = rollupAddress;
cache[`${publicClient.chain?.id}_${params.sequencerInbox}`] = rollupAddress;
return rollupAddress;
}

0 comments on commit 43221ac

Please sign in to comment.