Skip to content

feat(onchain): add optional receipt_hash to claim/disbursement events…#686

Open
Richardkingz2019 wants to merge 1 commit into
Pulsefy:mainfrom
Richardkingz2019:feature/issue-568-receipt-hash
Open

feat(onchain): add optional receipt_hash to claim/disbursement events…#686
Richardkingz2019 wants to merge 1 commit into
Pulsefy:mainfrom
Richardkingz2019:feature/issue-568-receipt-hash

Conversation

@Richardkingz2019

Copy link
Copy Markdown

… (Issue #568)

Introduces an OPTIONAL receipt_hash commitment on the on-chain PackageClaimed and PackageDisbursed events so callers can anchor an off-chain delivery receipt (e.g. SHA-256 of a signed proof of receipt) on chain while keeping the existing call sites backward-compatible.

Contract changes

  • PackageClaimed and PackageDisbursed events gained
    pub receipt_hash: Option<BytesN<32>> appended at the END of the
    payload, preserving forward compatibility for off-chain indexers that
    only read the original five fields.
  • New entrypoints claim_with_receipt(env, id, receipt_hash) and
    disburse_with_receipt(env, id, receipt_hash) emit the event with
    receipt_hash = Some(hash), leaving the existing claim /
    disburse entrypoints to continue emitting the event with
    receipt_hash = None.
  • Internal helper process_disburse(env, id, receipt_hash) factors the
    shared disburse logic so the receipt-bearing entrypoint is a one-line
    call into the same code path.
  • finalize_claim signature gains an extra
    receipt_hash: Option<BytesN<32>> parameter; existing claim /
    claim_with_proof callers pass None, the new claim_with_receipt
    caller passes Some(hash).
  • BytesN added to the soroban_sdk import.

Tests

  • tests/events.rs adds a data_receipt_hash helper that decodes the
    new Option<BytesN<32>> field from the event data map.
  • test_package_claimed_event and test_package_disbursed_event now
    assert the field carries None for legacy entrypoint invocations.
  • New test_package_claimed_event_with_receipt and
    test_package_disbursed_event_with_receipt exercises the new
    entrypoints and assert the field carries Some(hash) matching the
    passed-in 32-byte array.

closes #568

… (Issue Pulsefy#568)

Introduces an OPTIONAL receipt_hash commitment on the on-chain
PackageClaimed and PackageDisbursed events so callers can anchor an
off-chain delivery receipt (e.g. SHA-256 of a signed proof of receipt) on
chain while keeping the existing call sites backward-compatible.

Contract changes
----------------
*   PackageClaimed and PackageDisbursed events gained
    `pub receipt_hash: Option<BytesN<32>>` appended at the END of the
    payload, preserving forward compatibility for off-chain indexers that
    only read the original five fields.
*   New entrypoints `claim_with_receipt(env, id, receipt_hash)` and
    `disburse_with_receipt(env, id, receipt_hash)` emit the event with
    `receipt_hash = Some(hash)`, leaving the existing `claim` /
    `disburse` entrypoints to continue emitting the event with
    `receipt_hash = None`.
*   Internal helper `process_disburse(env, id, receipt_hash)` factors the
    shared disburse logic so the receipt-bearing entrypoint is a one-line
    call into the same code path.
*   `finalize_claim` signature gains an extra
    `receipt_hash: Option<BytesN<32>>` parameter; existing claim /
    claim_with_proof callers pass `None`, the new claim_with_receipt
    caller passes `Some(hash)`.
*   `BytesN` added to the soroban_sdk import.

Tests
-----
*   tests/events.rs adds a `data_receipt_hash` helper that decodes the
    new `Option<BytesN<32>>` field from the event data map.
*   `test_package_claimed_event` and `test_package_disbursed_event` now
    assert the field carries `None` for legacy entrypoint invocations.
*   New `test_package_claimed_event_with_receipt` and
    `test_package_disbursed_event_with_receipt` exercises the new
    entrypoints and assert the field carries `Some(hash)` matching the
    passed-in 32-byte array.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Cedarich's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Richardkingz2019 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich

Copy link
Copy Markdown
Contributor

@Richardkingz2019 please fix workflow

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.

Add Claim Receipt Hash Commitment (Optional Metadata)

2 participants