Skip to content

Commit

Permalink
Fix getTransactionHash to use un-decorated function for better tree s…
Browse files Browse the repository at this point in the history
…haking (#116)

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

* fix lint error

* add changeset manually
  • Loading branch information
kyscott18 committed Sep 20, 2023
1 parent 548c233 commit 745a65a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
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

0 comments on commit 745a65a

Please sign in to comment.