Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getTransactionHash to use un-decorated function for better tree shaking #116

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-cows-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"op-viem": patch
---

Fix getTransactionHash to use un-decorated function for better tree shaking
3 changes: 2 additions & 1 deletion src/actions/public/L1/getL2HashesForDepositTx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Chain, Hash, PublicClient, TransactionReceipt, Transport } from 'viem'
import { getTransactionReceipt } from 'viem/actions'
import { getL2HashFromL1DepositInfo } from '../../../utils/getL2HashFromL1DepositInfo.js'
import { getTransactionDepositedEvents } from '../../../utils/getTransactionDepositedEvents.js'

Expand All @@ -19,7 +20,7 @@ export async function getL2HashesForDepositTx<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
{ l1TxHash, l1TxReceipt }: GetL2HashesForDepositTxParamters,
): Promise<GetL2HashesForDepositTxReturnType> {
const txReceipt = l1TxReceipt ?? await client.getTransactionReceipt({ hash: l1TxHash })
const txReceipt = l1TxReceipt ?? await getTransactionReceipt(client, { hash: l1TxHash })
const depositEvents = getTransactionDepositedEvents({ txReceipt })

return depositEvents.map(({ event, logIndex }) =>
Expand Down
3 changes: 2 additions & 1 deletion src/actions/public/L2/getWithdrawalMessages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { l2ToL1MessagePasserABI } from '@eth-optimism/contracts-ts'
import { type Chain, decodeEventLog, type Hash, type PublicClient, type TransactionReceipt, type Transport } from 'viem'
import { getTransactionReceipt } from 'viem/actions'
import type { MessagePassedEvent } from '../../../types/withdrawal.js'

export type GetWithdrawalMessagesParameters = {
Expand All @@ -23,7 +24,7 @@ export async function getWithdrawalMessages<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
{ hash, txReceipt }: GetWithdrawalMessagesParameters,
): Promise<GetWithdrawalMessagesReturnType> {
const receipt = txReceipt ?? await client.getTransactionReceipt({ hash })
const receipt = txReceipt ?? await getTransactionReceipt(client, { hash })
const messages: MessagePassedEvent[] = []
for (const log of receipt.logs) {
/// These transactions will contain events from several contracts
Expand Down