-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from base-org/lukas/use-latest-proposed-l2-bl…
…ock-for-proofs [fix] use latest proposed l2 block for withdrawal proofs
- Loading branch information
Showing
4 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { l2OutputOracleABI } from '@eth-optimism/contracts-ts' | ||
import type { Chain, PublicClient, Transport } from 'viem' | ||
import { readContract } from 'viem/actions' | ||
import { type RawOrContractAddress, resolveAddress } from '../../../types/addresses.js' | ||
|
||
export type GetLatestProposedL2BlockNumberParameters< | ||
TChain extends Chain | undefined = Chain | undefined, | ||
_chainId = TChain extends Chain ? TChain['id'] : number, | ||
> = { l2OutputOracle: RawOrContractAddress<_chainId> } | ||
|
||
export type GetLatestProposedL2BlockNumberReturnType = { | ||
l2BlockNumber: bigint | ||
} | ||
|
||
export async function getLatestProposedL2BlockNumber<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
{ | ||
l2OutputOracle, | ||
}: GetLatestProposedL2BlockNumberParameters<TChain>, | ||
): Promise<GetLatestProposedL2BlockNumberReturnType> { | ||
const resolvedAddress = resolveAddress(l2OutputOracle) | ||
|
||
const l2BlockNumber = await readContract(client, { | ||
address: resolvedAddress, | ||
abi: l2OutputOracleABI, | ||
functionName: 'latestBlockNumber', | ||
}) | ||
|
||
return { l2BlockNumber } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters