feat(onchain): add optional receipt_hash to claim/disbursement events…#686
Open
Richardkingz2019 wants to merge 1 commit into
Open
feat(onchain): add optional receipt_hash to claim/disbursement events…#686Richardkingz2019 wants to merge 1 commit into
Richardkingz2019 wants to merge 1 commit into
Conversation
… (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.
|
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. |
|
@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! 🚀 |
Contributor
|
@Richardkingz2019 please fix workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… (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
pub receipt_hash: Option<BytesN<32>>appended at the END of thepayload, preserving forward compatibility for off-chain indexers that
only read the original five fields.
claim_with_receipt(env, id, receipt_hash)anddisburse_with_receipt(env, id, receipt_hash)emit the event withreceipt_hash = Some(hash), leaving the existingclaim/disburseentrypoints to continue emitting the event withreceipt_hash = None.process_disburse(env, id, receipt_hash)factors theshared disburse logic so the receipt-bearing entrypoint is a one-line
call into the same code path.
finalize_claimsignature gains an extrareceipt_hash: Option<BytesN<32>>parameter; existing claim /claim_with_proof callers pass
None, the new claim_with_receiptcaller passes
Some(hash).BytesNadded to the soroban_sdk import.Tests
data_receipt_hashhelper that decodes thenew
Option<BytesN<32>>field from the event data map.test_package_claimed_eventandtest_package_disbursed_eventnowassert the field carries
Nonefor legacy entrypoint invocations.test_package_claimed_event_with_receiptandtest_package_disbursed_event_with_receiptexercises the newentrypoints and assert the field carries
Some(hash)matching thepassed-in 32-byte array.
closes #568