diff --git a/.changeset/honest-cows-deliver.md b/.changeset/honest-cows-deliver.md new file mode 100644 index 00000000..dfc00bdb --- /dev/null +++ b/.changeset/honest-cows-deliver.md @@ -0,0 +1,5 @@ +--- +"op-viem": patch +--- + +Fix getTransactionHash to use un-decorated function for better tree shaking diff --git a/src/actions/public/L1/getL2HashesForDepositTx.ts b/src/actions/public/L1/getL2HashesForDepositTx.ts index de9d2bbc..6495eb8a 100644 --- a/src/actions/public/L1/getL2HashesForDepositTx.ts +++ b/src/actions/public/L1/getL2HashesForDepositTx.ts @@ -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' @@ -19,7 +20,7 @@ export async function getL2HashesForDepositTx( client: PublicClient, { l1TxHash, l1TxReceipt }: GetL2HashesForDepositTxParamters, ): Promise { - 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 }) => diff --git a/src/actions/public/L2/getWithdrawalMessages.ts b/src/actions/public/L2/getWithdrawalMessages.ts index 76dad4c3..65d829c1 100644 --- a/src/actions/public/L2/getWithdrawalMessages.ts +++ b/src/actions/public/L2/getWithdrawalMessages.ts @@ -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 = { @@ -23,7 +24,7 @@ export async function getWithdrawalMessages( client: PublicClient, { hash, txReceipt }: GetWithdrawalMessagesParameters, ): Promise { - 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