Skip to content

Use ArgumentNullException.ThrowIfNull in Client property setter - #10

Merged
Phelecks merged 7 commits into
mainfrom
claude/add-chain-to-cache-key
Mar 28, 2026
Merged

Phelecks merged 7 commits into
mainfrom
claude/add-chain-to-cache-key

Conversation

@Claude

@Claude Claude AI commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

The Client property setter used a verbose manual null-check pattern instead of the idiomatic .NET 6+ helper.

Change

Replaced in CreateDistributedNonceServiceInstance.Client setter:

// Before
if (value is null)
{
    throw new ArgumentNullException(nameof(value));
}

// After
ArgumentNullException.ThrowIfNull(value);

ThrowIfNull auto-captures the parameter name via [CallerArgumentExpression], eliminating the nameof boilerplate while preserving identical runtime behavior.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

@Claude Claude AI changed the title [WIP] Add chain to cache key in DistributedNonceService Add chain ID to distributed lock cache key for multi-chain isolation Mar 28, 2026
@Claude
Claude AI requested a review from Phelecks March 28, 2026 17:16
@Phelecks
Phelecks marked this pull request as ready for review March 28, 2026 17:19
Copilot AI review requested due to automatic review settings March 28, 2026 17:19

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 DistributedNonceService to incorporate the blockchain chain ID into the distributed lock key, preventing cross-chain lock collisions when the same address is used on multiple networks (e.g., Ethereum + Polygon).

Changes:

  • Updated distributed lock key format from DistributedNonce_{address} to DistributedNonce_{chainId}_{address}.
  • Added per-instance chain ID retrieval/caching via an eth_chainId RPC call.
  • Extended integration tests to mock eth_chainId and added a test intended to validate multi-chain isolation.

Reviewed changes

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

File Description
src/DistributedNonce/Services/DistributedNonceService.cs Adds chain ID fetching/caching and incorporates chain ID into lock keys for GetNextNonceAsync and ResetNonceAsync.
tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs Updates RPC mocks to handle eth_chainId and adds an integration test intended to cover chain-based isolation.

Copilot AI changed the title Add chain ID to distributed lock cache key for multi-chain isolation Add chain ID to distributed lock key for multi-chain nonce isolation Mar 28, 2026
Copilot AI changed the title Add chain ID to distributed lock key for multi-chain nonce isolation Consolidate nonce + chain ID init into a single distributed lock Mar 28, 2026
Copilot AI changed the title Consolidate nonce + chain ID init into a single distributed lock Use ArgumentNullException.ThrowIfNull in Client property setter 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 388c307 into main Mar 28, 2026
6 of 7 checks passed
@Phelecks
Phelecks deleted the claude/add-chain-to-cache-key branch March 28, 2026 18:44
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.

4 participants