Skip to content

Commit

Permalink
Add status to Transaction (#60)
Browse files Browse the repository at this point in the history
* Add status to transaction

* Add changeset

* Cleanup async keyword
  • Loading branch information
DannyDelott authored Apr 26, 2024
1 parent 05f2236 commit 51fd2e4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/rotten-geese-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@delvtech/evm-client-ethers": minor
"@delvtech/evm-client-viem": minor
"@delvtech/evm-client": minor
---

Add status field to Transaction
4 changes: 4 additions & 0 deletions packages/evm-client-ethers/src/network/createNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -92,6 +95,7 @@ export function createNetwork(provider: Provider): Network {
transactionHash: transaction.hash as `0x${string}`,
transactionIndex: transaction.index,
effectiveGasPrice: BigInt(transaction.gasPrice),
status,
};
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/evm-client-viem/src/network/createNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export function createNetwork(publicClient: PublicClient): Network {
};
},

async waitForTransaction(hash, options) {
return await publicClient.waitForTransactionReceipt({
waitForTransaction(hash, options) {
return publicClient.waitForTransactionReceipt({
hash,
timeout: options?.timeout,
});
Expand Down
1 change: 1 addition & 0 deletions packages/evm-client/src/network/stubs/NetworkStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export function transactionToReceipt(
transactionHash: transaction.hash!,
gasUsed: 0n,
logsBloom: '0x',
status: 'success',
}
: undefined;
}
3 changes: 3 additions & 0 deletions packages/evm-client/src/network/types/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51fd2e4

Please sign in to comment.