Repository navigation
feat: audit reconciliation, branches, transfer history, specific errors - #1687
Merged
yusuftomilola merged 3 commits intoOct 17, 2026
Merged
yusuftomilola merged 3 commits into
yusuftomilola merged 3 commits into
Conversation
Closes DistinctCodes#1497 Closes DistinctCodes#1498 Closes DistinctCodes#1499 Closes DistinctCodes#1500 - assetsup/audit: document the reconciliation contract between the on-chain audit log (the source of truth) and the backend `audit-logs` service, including the composite identity that makes replay idempotent and how divergence is resolved (DistinctCodes#1497). - assetsup/branch: add `register_branch` and `assign_asset_to_branch`. The latter rejects an unknown branch (`BranchNotFound`) and an unknown asset (`AssetNotFound`), so an asset can never be pointed at a stale or misspelled branch id. Adds `get_branch`/`get_branch_assets` reads and the `branch_registered` / `asset_assigned_to_branch` events (DistinctCodes#1498). - assetsup/asset: append every ownership change to a per-asset `TransferHistory` and expose `get_asset_transfer_history`, so the full chain of custody is queryable on-chain and not just the current owner (DistinctCodes#1499). - assetsup/error + insurance: replace reused generic variants with precise ones (`PolicyNotFound`, `ClaimNotFound`, `InvalidPolicyStatus`, `InvalidClaimStatus`, `InvalidPolicyTerms`, `InvalidClaimAmount`, `PolicyAlreadyExists`, `ClaimAlreadyExists`) so integrators can tell failure causes apart (DistinctCodes#1500). Codes 187 onward are allocated, reserving 187 for the insurance expiry reminder from DistinctCodes#1491.
|
@khaadish is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@khaadish 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! 🚀 |
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.
Summary
Implements khaadish's assigned issues for the assetsup contract.
Closes #1497 — Documented on-chain/off-chain audit reconciliation
audit.rsnow documents the contract between the on-chainAuditEntrylog andthe backend
audit-logsservice: the on-chain log is the source of truth, eachentry is identified by
(asset_id, action, actor, timestamp), replaying a ledgerrange is idempotent under that key, and divergence is resolved in favour of the
chain.
detailsis display-only and must not be used for matching.Closes #1498 — Branch assignment validates the branch exists
Adds
register_branch(admin-gated) andassign_asset_to_branch, which nowrejects an unknown branch with
BranchNotFoundand an unknown asset withAssetNotFoundbefore writing. Without the branch check an asset could bepointed at a stale or misspelled branch id and silently vanish from that
branch's inventory. Adds
get_branch/get_branch_assetsreads and thebranch_registered/asset_assigned_to_branchevents.Closes #1499 — Queryable on-chain transfer history
transfer_asset_ownershipnow appends aTransferRecordto a per-asset,append-only
TransferHistory, andget_asset_transfer_historyreturns it oldestfirst. The chain of custody is no longer only reconstructable by replaying
events, and an unknown asset returns
AssetNotFoundrather than an empty list.Closes #1500 — Specific error variants
Replaces reused generic variants in insurance with precise ones:
PolicyNotFound,ClaimNotFound,InvalidPolicyStatus,InvalidClaimStatus,InvalidPolicyTerms,InvalidClaimAmount,PolicyAlreadyExists,ClaimAlreadyExists. Status-transition failures no longer masquerade asUnauthorized, and bad policy terms no longer surface asInvalidPayment, so anintegrator can tell causes apart.
Notes
reminder (No expiry/renewal reminder for insurance policies #1491) so the two insurance PRs do not clash. The gap is intentional.
contracts/EVENTS.mdupdated for the new entrypoints and events.