Skip to content

Fix TransactionStateInfo: populate all fields that have data, document per-state contract, observe CancellationToken - #17

Merged
Phelecks merged 7 commits into
mainfrom
copilot/update-transaction-status-service
Mar 28, 2026
Merged

Phelecks merged 7 commits into
mainfrom
copilot/update-transaction-status-service

Conversation

Copilot AI commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

ConfirmedNonce appeared useless because every return path set it to null — obscuring that it is meaningfully set for the Replaced state. Broader audit revealed Value and Gas were also left unpopulated for Pending and Replaced even though the transaction object was already fetched. The CancellationToken parameter was also accepted but never observed, making callers unable to cancel long-running status checks.

Changes

  • TransactionStatusService — populate Value and Gas from the already-fetched transaction in Pending and Replaced paths; drop all redundant explicit = null assignments; add cancellationToken.ThrowIfCancellationRequested() before each of the 4 awaited RPC calls (GetTransactionReceipt, GetTransactionByHash ×2, GetTransactionCount) since Nethereum's SendRequestAsync does not accept a CancellationToken
  • TransactionStateInfo — sharpen XML docs: ConfirmedNonce explicitly states Replaced-only; Value/Gas state they are null only for StalePending
  • README — replace the single-if example with a full switch across all 5 states showing every available field, plus a reference table:
Property ConfirmedSuccess/Reverted Pending Replaced StalePending
Receipt / ReceiptStatus / BlockNumber ✅ — — —
Nonce / Value / Gas ✅ ✅ ✅ —
ConfirmedNonce — — ✅ —

StalePending carries only State + TransactionHash — the node no longer holds the transaction.

  • TransactionStatusServiceTests — rewrote all tests to instantiate TransactionStatusService directly and stub the underlying IClient JSON-RPC responses (keyed on eth_getTransactionReceipt, eth_getTransactionByHash, eth_getTransactionCount method names via NSubstitute). Tests now exercise real service logic including the receipt/tx fetch paths, Replaced vs. Pending nonce comparison, and the pruned-transaction null-fallback case. Added a cancellation test verifying OperationCanceledException is thrown when a pre-cancelled token is passed.

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

- Add TransactionReceipt? Receipt to TransactionStateInfo
- Add BigInteger? Value (wei amount) to TransactionStateInfo
- Add BigInteger? Gas (gas limit) to TransactionStateInfo
- Update Nonce XML doc to clarify it is sourced from the transaction object
- TransactionStatusService: for confirmed txs also fetch the transaction
  to populate Nonce, Value, Gas (fields absent from TransactionReceipt)
- Tests: assert Receipt, Nonce, Value, Gas on confirmed-state results;
  add test for graceful null handling when transaction data is unavailable

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/b1b0a706-e15f-4776-8aa0-d9e1adf38d8d

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
Copilot AI changed the title [WIP] Update ITransactionStatusService to return state and properties Enrich TransactionStateInfo with Receipt and transaction-only properties for confirmed transactions Mar 28, 2026
Copilot AI requested a review from Phelecks March 28, 2026 21:06
Copilot AI and others added 2 commits March 28, 2026 22:31
- Drop ConfirmedNonce = null, ReceiptStatus = null, BlockNumber = null,
  Nonce = null from every object initializer where they add no value;
  nullable properties default to null in C#
- Sharpen ConfirmedNonce XML doc: explicitly states it is only populated
  for the Replaced state, null for all other states
- Remove redundant Nonce/Value/Gas = null from the pruned-transaction
  test setup for consistency

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/bcf678a3-75e5-4dd3-9b9b-fce8cd71a977

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
The transaction object is already fetched from the node for both states
but Value and Gas were left unpopulated. Now every state with available
transaction data (ConfirmedSuccess, ConfirmedReverted, Pending, Replaced)
fills Value and Gas; only StalePending leaves them null.
Update XML docs and tests accordingly.

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/bcf678a3-75e5-4dd3-9b9b-fce8cd71a977

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
Copilot AI changed the title Enrich TransactionStateInfo with Receipt and transaction-only properties for confirmed transactions Fill Value and Gas for all states where transaction data is available Mar 28, 2026
@Phelecks
Phelecks marked this pull request as ready for review March 28, 2026 22:36
Copilot AI review requested due to automatic review settings March 28, 2026 22:36
…ulation table

Replace the minimal single-if example with a full switch covering all 5
states, demonstrating every populated field per state. Add a Markdown
table showing exactly which properties are set for each TransactionState,
and a short prose summary explaining the rules.

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/18d9ec2b-f293-4298-8547-d7924195aa7d

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
Copilot AI changed the title Fill Value and Gas for all states where transaction data is available Fix TransactionStateInfo: populate all fields that have data, document per-state contract Mar 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the transaction-state query surface so TransactionStateInfo consistently includes Value and Gas (and now also Nonce for confirmed states) whenever node transaction data is available, and clarifies the DTO’s XML documentation accordingly.

Changes:

  • Populate Nonce, Value, and Gas from the fetched transaction for Confirmed* states (when receipt exists) and for Pending/Replaced.
  • Remove redundant explicit = null assignments in TransactionStatusService return objects.
  • Expand TransactionStateInfo docs and add Receipt to carry the full receipt for confirmed states.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/BlockChainTools/Services/TransactionStatusService.cs Fills Nonce/Value/Gas from transaction data in additional state paths and simplifies object initialization.
src/BlockChainTools/DataTransferObjects/TransactionStateInfo.cs Adds Receipt and documents when ConfirmedNonce, Value, and Gas are expected to be populated.
tests/BlockChainTools.Tests/TransactionStatusServiceTests.cs Updates/extends assertions to include Receipt/Value/Gas fields.

…stub IClient RPC responses

Replace interface-level mocking (Substitute.For<ITransactionStatusService>) with
direct instantiation of TransactionStatusService and NSubstitute stubs on IClient
(keyed on eth_getTransaction* method names). All 6 tests now exercise the real service
logic including receipt/tx fetch paths, Replaced vs Pending nonce comparison, and the
pruned-transaction null-fallback case.

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/ff398c7f-10f8-434d-85a4-2853ff8b65b7

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
…ationRequested before each RPC call

Nethereum's SendRequestAsync does not accept a CancellationToken, so add explicit
cancellationToken.ThrowIfCancellationRequested() before each of the 4 awaited RPC
calls (GetTransactionReceipt, GetTransactionByHash x2, GetTransactionCount).
Also adds a test verifying OperationCanceledException is thrown for pre-cancelled tokens.

Agent-Logs-Url: https://github.com/Tricksfor-Organization/BlockChainTools/sessions/b484f146-89c6-487f-83a5-e2f370307c2c

Co-authored-by: Phelecks <47243363+Phelecks@users.noreply.github.com>
Copilot AI changed the title Fix TransactionStateInfo: populate all fields that have data, document per-state contract Fix TransactionStateInfo: populate all fields that have data, document per-state contract, observe CancellationToken Mar 28, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Phelecks
Phelecks merged commit 46ae638 into main Mar 28, 2026
6 of 7 checks passed
@Phelecks
Phelecks deleted the copilot/update-transaction-status-service branch March 28, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants