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

Add status to Transaction #60

Merged
merged 3 commits into from
Apr 26, 2024
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
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
Loading