Skip to content

feat: add fraction event and order listing lexicons - #167

Closed
satyam-mishra-pce wants to merge 1 commit into
mainfrom
fractions
Closed

feat: add fraction event and order listing lexicons#167
satyam-mishra-pce wants to merge 1 commit into
mainfrom
fractions

Conversation

@satyam-mishra-pce

@satyam-mishra-pce satyam-mishra-pce commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces three new lexicons to model the fractional sales lifecycle for hypercerts:

  • org.hypercerts.fraction.transferEvent — immutable event record for peer-to-peer fraction transfers. Carries a full cryptographic proof directly on the record (signedAt, nonce, chainId, signerEVMAddress, signature), scoped to a specific activity claim via activityClaimUri.

  • org.hypercerts.fraction.saleEvent — immutable event record for fraction purchases. References an org.hypercerts.funding.receipt AT-URI as proof of the transaction, keeping the sale provenance linked to the existing funding receipt lexicon.

  • org.hypercerts.order.listing — mutable listing record for the sale of fractions of an activity claim. Lives under org.hypercerts.order (separate from the fraction namespace, since it is logically independent). Keyed by the activity claim's rkey to enforce one listing per claim and enable automatic invalidation when the claim is deleted. Fields: goalInUSD, currency (open-ended with known values), allowOversell, status (open / paused / closed).

Design notes

  • Transfer and sale are modelled as separate lexicons (not a union on a single record) since they carry fundamentally different proof payloads and are always created as distinct event types.
  • Both fraction event lexicons are immutable by design — each record represents a point-in-time event; aggregate stats are computed over the full set of events.
  • The order/listing rkey convention (matching the activity claim rkey) is documented in the record description rather than enforced by the schema, consistent with how ATProto handles such patterns.

Checklist

  • npm run gen-api — clean, all three types generated with no validation errors
  • npm run format:check — all files pass Prettier
  • npm run test — 7/7 tests pass
  • Changeset added (.changeset/add-fraction-lexicons.md, minor)

Summary by CodeRabbit

  • New Features
    • Enabled peer-to-peer transfers of activity claim fractions with secure cryptographic verification and signature authentication.
    • Implemented comprehensive sale event tracking for fraction purchases, with automatic linking to funding receipts for transaction verification.
    • Introduced listing management system for fraction sales, featuring customizable pricing, multi-currency support, and flexible oversell configuration options.

@changeset-bot

changeset-bot Bot commented Mar 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d241b7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hypercerts-org/lexicon Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Mar 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@satyam-mishra-pce has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89be08ec-0d90-4714-a4bc-b49eaff26ab3

📥 Commits

Reviewing files that changed from the base of the PR and between f1e2bd3 and d241b7e.

📒 Files selected for processing (6)
  • .changeset/add-fraction-lexicons.md
  • ERD.puml
  • SCHEMAS.md
  • lexicons/org/hypercerts/fraction/saleEvent.json
  • lexicons/org/hypercerts/fraction/transferEvent.json
  • lexicons/org/hypercerts/order/listing.json
📝 Walkthrough

Walkthrough

This pull request adds three new lexicon schemas to the @hypercerts-org/lexicon package and bumps the minor version. The additions include immutable event records for fraction transfers and sales, plus a mutable listing schema for managing fraction sales, all supporting the trading infrastructure for activity claim fractions.

Changes

Cohort / File(s) Summary
Changeset Metadata
.changeset/add-fraction-lexicons.md
Minor version bump documenting three new lexicon additions for fraction transfers, sales, and order listings.
Fraction Event Lexicons
lexicons/org/hypercerts/fraction/transferEvent.json, lexicons/org/hypercerts/fraction/saleEvent.json
Immutable event schemas for peer-to-peer transfers and purchase transactions, including cryptographic proof fields (signatures, nonces, chainId) and receipt references respectively.
Order Listing Lexicon
lexicons/org/hypercerts/order/listing.json
Mutable sale listing record keyed by activity claim rkey with fields for pricing (goalInUSD, currency), overselling policy, and status tracking (open/paused/closed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • add funding receipt schema #37: Introduces the org.hypercerts.funding.receipt schema that the new saleEvent lexicon explicitly references as proof of purchase.

Suggested reviewers

  • s-adamantine
  • pheuberger

Poem

🐰✨ Three schemas hop into the lexicon so fine,
Transfers, sales, and listings align,
Fractions now trade with cryptographic grace,
New lexicons add structure to this place! 📋🎉


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Lexicon Documentation Sync ❌ Error PR adds three new lexicon JSON files but fails to update SCHEMAS.md and ERD.puml as required by custom check criteria. Execute npm run gen-schemas-md to regenerate SCHEMAS.md and manually update ERD.puml to add transferEvent, saleEvent, listing entities with their relationships.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add fraction event and order listing lexicons' accurately describes the main changes: adding three new lexicons (transferEvent, saleEvent, and listing) for the fractional sales lifecycle.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Lexicons Styleguide Compliance ✅ Passed All three new lexicon files are fully compliant with the AT Protocol Lexicon Style Guide, including proper reverse domain naming, required fields, comprehensive descriptions, correct record definitions, camelCase naming, appropriate type definitions with constraints, and correct URI/DID formats.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fractions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lexicons/org/hypercerts/fraction/transferEvent.json (1)

48-56: Consider documenting when nonce and chainId can be omitted.

Both fields are optional but the descriptions imply they're important for cryptographic verification. If there are valid scenarios where these can be absent (e.g., legacy transfers, certain chain types), adding a note explaining when omission is acceptable would help consumers understand proper usage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lexicons/org/hypercerts/fraction/transferEvent.json` around lines 48 - 56,
Update the transferEvent JSON schema documentation for the nonce and chainId
properties to explicitly state when they are optional and when they are
required; add a short note to the "nonce" description indicating acceptable
omission cases (e.g., legacy transfers that used alternative replay protections
or off-chain nonces) and to the "chainId" description indicating cases where
chainId may be omitted (e.g., when transfers are chain-agnostic, occur on
non-EVM chains, or when provenance is derived from other metadata), and include
guidance on verification implications (how to verify when those fields are
absent) so consumers know how to handle omission during cryptographic checks for
nonce and chainId in transferEvent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/add-fraction-lexicons.md:
- Around line 1-11: Update the generated SCHEMAS.md by running the project's
schema generation script so it includes the three new lexicons:
org.hypercerts.fraction.transferEvent, org.hypercerts.fraction.saleEvent, and
org.hypercerts.order.listing (ensure the generated entries reflect the fields
described in the diff such as activityClaimUri,
signedAt/nonce/chainId/signerEVMAddress/signature for transferEvent, receipt
AT-URI for saleEvent, and goalInUSD/currency/allowOversell/status/rkey for
listing). Then manually edit ERD.puml to add the three entities (transferEvent
with optional from/to DIDs and activityClaimUri reference, saleEvent with
activityClaimUri and receipt AT-URI, and listing keyed by activity claim rkey)
and draw their relationships to existing activityClaim and funding/receipt
entities so the diagram matches the new schema.

---

Nitpick comments:
In `@lexicons/org/hypercerts/fraction/transferEvent.json`:
- Around line 48-56: Update the transferEvent JSON schema documentation for the
nonce and chainId properties to explicitly state when they are optional and when
they are required; add a short note to the "nonce" description indicating
acceptable omission cases (e.g., legacy transfers that used alternative replay
protections or off-chain nonces) and to the "chainId" description indicating
cases where chainId may be omitted (e.g., when transfers are chain-agnostic,
occur on non-EVM chains, or when provenance is derived from other metadata), and
include guidance on verification implications (how to verify when those fields
are absent) so consumers know how to handle omission during cryptographic checks
for nonce and chainId in transferEvent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db07ad43-9259-4e85-90db-e9f2805cec4b

📥 Commits

Reviewing files that changed from the base of the PR and between 82ee279 and f1e2bd3.

📒 Files selected for processing (4)
  • .changeset/add-fraction-lexicons.md
  • lexicons/org/hypercerts/fraction/saleEvent.json
  • lexicons/org/hypercerts/fraction/transferEvent.json
  • lexicons/org/hypercerts/order/listing.json

Comment thread .changeset/add-fraction-lexicons.md
…ctional sales

Introduces three new lexicons:

- org.hypercerts.fraction.transferEvent — immutable event for peer-to-peer
  fraction transfers, with full cryptographic proof (signedAt, nonce, chainId,
  signerEVMAddress, signature), amount as numeric string, and fiat currency
- org.hypercerts.fraction.saleEvent — immutable event for fraction purchases,
  referencing an org.hypercerts.funding.receipt AT-URI as proof, amount as
  numeric string, and fiat currency
- org.hypercerts.order.listing — mutable sale listing keyed by activity claim
  rkey (one listing per claim); fields: goal (numeric string), currency
  (fiat, open-ended knownValues), allowOversell, status (open/paused/closed)

Also updates SCHEMAS.md (regenerated) and ERD.puml with the three new entities
and their relationships to activity, contributorEntity, and fundingReceipt.

@aspiers aspiers 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.

As per discussion earlier this week, I think this needs further thought. ATProto does not provide a way to easily build an immutable append-only ledger with double-counting protection or other business logic enshrined. I think we would be better off tracking this onchain. It could even be a custodial pseudo-token which is like ERC20 but not compliant and tracks balanceOf by ATProto DID instead of onchain address.

@satyam-mishra-pce

Copy link
Copy Markdown
Contributor Author

Agree. I think this can be closed now.

@aspiers aspiers closed this Mar 19, 2026
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.

2 participants