From 40b196c832f78b69b7abf0a3483df51468baf7cc Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Fri, 26 Apr 2024 14:32:54 -0700 Subject: [PATCH 1/3] Add status to transaction --- packages/evm-client-ethers/src/network/createNetwork.ts | 4 ++++ packages/evm-client-viem/src/network/createNetwork.ts | 2 +- packages/evm-client/src/network/stubs/NetworkStub.ts | 1 + packages/evm-client/src/network/types/Transaction.ts | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/evm-client-ethers/src/network/createNetwork.ts b/packages/evm-client-ethers/src/network/createNetwork.ts index d1ac465..5d081a7 100644 --- a/packages/evm-client-ethers/src/network/createNetwork.ts +++ b/packages/evm-client-ethers/src/network/createNetwork.ts @@ -81,6 +81,9 @@ export function createNetwork(provider: Provider): Network { return; } + // status is either 0 (reverted) or 1 (success) + const status = !transaction.status ? 'reverted' : 'success'; + return { blockHash: transaction.blockHash as `0x${string}`, blockNumber: BigInt(transaction.blockNumber), @@ -92,6 +95,7 @@ export function createNetwork(provider: Provider): Network { transactionHash: transaction.hash as `0x${string}`, transactionIndex: transaction.index, effectiveGasPrice: BigInt(transaction.gasPrice), + status, }; }, }; diff --git a/packages/evm-client-viem/src/network/createNetwork.ts b/packages/evm-client-viem/src/network/createNetwork.ts index d2d7388..b55ebff 100644 --- a/packages/evm-client-viem/src/network/createNetwork.ts +++ b/packages/evm-client-viem/src/network/createNetwork.ts @@ -73,7 +73,7 @@ export function createNetwork(publicClient: PublicClient): Network { }, async waitForTransaction(hash, options) { - return await publicClient.waitForTransactionReceipt({ + return publicClient.waitForTransactionReceipt({ hash, timeout: options?.timeout, }); diff --git a/packages/evm-client/src/network/stubs/NetworkStub.ts b/packages/evm-client/src/network/stubs/NetworkStub.ts index 0e988a2..1ca8893 100644 --- a/packages/evm-client/src/network/stubs/NetworkStub.ts +++ b/packages/evm-client/src/network/stubs/NetworkStub.ts @@ -154,6 +154,7 @@ export function transactionToReceipt( transactionHash: transaction.hash!, gasUsed: 0n, logsBloom: '0x', + status: 'success', } : undefined; } diff --git a/packages/evm-client/src/network/types/Transaction.ts b/packages/evm-client/src/network/types/Transaction.ts index 9954889..967c74d 100644 --- a/packages/evm-client/src/network/types/Transaction.ts +++ b/packages/evm-client/src/network/types/Transaction.ts @@ -45,6 +45,9 @@ export interface TransactionReceipt { logsBloom: `0x${string}`; transactionHash: `0x${string}`; transactionIndex: number; + + status: 'success' | 'reverted'; + /** * The actual value per gas deducted from the sender's account. Before * EIP-1559, this is equal to the transaction's gas price. After, it is equal From 5424904016153a0458c6862743e74589c338df33 Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Fri, 26 Apr 2024 14:34:09 -0700 Subject: [PATCH 2/3] Add changeset --- .changeset/rotten-geese-cheer.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/rotten-geese-cheer.md diff --git a/.changeset/rotten-geese-cheer.md b/.changeset/rotten-geese-cheer.md new file mode 100644 index 0000000..7e7e13b --- /dev/null +++ b/.changeset/rotten-geese-cheer.md @@ -0,0 +1,7 @@ +--- +"@delvtech/evm-client-ethers": minor +"@delvtech/evm-client-viem": minor +"@delvtech/evm-client": minor +--- + +Add status field to Transaction From 1b58bafe249308795f7f9b2c8a5c83469c51f9b8 Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Fri, 26 Apr 2024 15:22:58 -0700 Subject: [PATCH 3/3] Cleanup async keyword --- packages/evm-client-viem/src/network/createNetwork.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/evm-client-viem/src/network/createNetwork.ts b/packages/evm-client-viem/src/network/createNetwork.ts index b55ebff..ee0a673 100644 --- a/packages/evm-client-viem/src/network/createNetwork.ts +++ b/packages/evm-client-viem/src/network/createNetwork.ts @@ -72,7 +72,7 @@ export function createNetwork(publicClient: PublicClient): Network { }; }, - async waitForTransaction(hash, options) { + waitForTransaction(hash, options) { return publicClient.waitForTransactionReceipt({ hash, timeout: options?.timeout,