Skip to content

fix: add missing contract_credited/contract_debited response handling#173

Closed
cuongph87 wants to merge 2 commits intomainfrom
fix/contract-effects-and-deprecated-warnings
Closed

fix: add missing contract_credited/contract_debited response handling#173
cuongph87 wants to merge 2 commits intomainfrom
fix/contract-effects-and-deprecated-warnings

Conversation

@cuongph87
Copy link
Copy Markdown
Contributor

@cuongph87 cuongph87 commented Apr 16, 2026

Auto-generated Summary 🤖

This addresses #172.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@github-actions github-actions Bot added the fix label Apr 16, 2026
@claude
Copy link
Copy Markdown

claude Bot commented Apr 16, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Wires up missing Horizon effect types so contract_credited / contract_debited effects no longer fail polymorphic deserialization (addresses #172).

Changes:

  • Extend EffectResponseJsonConverter to dispatch type_i=96 and type_i=97 to the existing Soroban SAC effect response classes.
  • Update the converter’s “unknown type” error message to include the new supported range.
  • Add MSTest coverage for deserializing both new effect types.

Reviewed changes

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

File Description
StellarDotnetSdk/Converters/EffectResponseJsonConverter.cs Adds type_i switch cases for 96/97 and updates the supported-range message.
StellarDotnetSdk.Tests/Converters/EffectResponseJsonConverterTest.cs Adds tests validating dispatch/binding for contract_credited and contract_debited effects.

Comment on lines +328 to +329
/// <see cref="ContractCreditedEffectResponse" /> and that every wire-format field is
/// bound to the expected property.
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The XML doc for this new test claims "every wire-format field" is verified, but the assertions only cover the subtype dispatch and a subset of fields (TypeId/Type/Contract/Amount/Asset*). Consider either asserting the other common fields (e.g., Id, PagingToken, Account, CreatedAt, Links) or tightening the doc comment to match what the test actually verifies.

Suggested change
/// <see cref="ContractCreditedEffectResponse" /> and that every wire-format field is
/// bound to the expected property.
/// <see cref="ContractCreditedEffectResponse" /> and that the contract, amount, and
/// asset-related fields asserted below are bound to the expected properties.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added assertions.

Comment on lines +372 to +377
/// <summary>
/// Tests deserialization of a contract_debited effect with type_i=97.
/// Payload shape constructed from the same wire format Horizon emits for the symmetric
/// SAC transfer debit, with a credit_alphanum4 asset to exercise the non-native branch
/// of <see cref="ContractDebitedEffectResponse.Asset" />.
/// </summary>
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

This test's summary says the credit_alphanum4 payload is used to exercise the non-native branch of ContractDebitedEffectResponse.Asset, but the test never accesses or asserts the computed Asset property. If the intent is to cover that branch, add an assertion against debited.Asset (type/code/issuer) or update the comment to avoid implying coverage that isn't present.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the assertion.

Comment on lines +123 to +124
96 => root.Deserialize<ContractCreditedEffectResponse>(options),
97 => root.Deserialize<ContractDebitedEffectResponse>(options),
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The PR description/checkboxes state that documentation changes were required and already updated, but this PR only changes the converter and its tests (no docs/README updates). Either include the intended documentation updates or adjust the PR description/checkboxes to avoid a mismatch for reviewers and release notes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants