Skip to content

feat: add creator key performance bond status API - #1094

Closed
Chinko21 wants to merge 6 commits into
accesslayerorg:mainfrom
Chinko21:fix/issue-1062-build-performance-bond-status-api-for-creator
Closed

Chinko21 wants to merge 6 commits into
accesslayerorg:mainfrom
Chinko21:fix/issue-1062-build-performance-bond-status-api-for-creator

Conversation

@Chinko21

Copy link
Copy Markdown

Overview

This PR exposes REST endpoints for creator key performance bond status, returning amount deposited, current state, and forfeiture history sourced from the bond contract and indexed BondForfeited events. It adds a 60s stale-while-revalidate cache around the get_bond_status contract call and returns 404 for keys without a bond record.

Related Issue

Changes

🔐 Creator Bond Service

  • [ADD] src/modules/creator/creator-bond.service.ts

    • Fetches bond state via get_bond_status contract call with a 60s stale-while-revalidate cache.
    • Returns amount, state (deposited/released/forfeited), and creator for a key.
    • Returns 404 for keys with no bond record.
    • Reads forfeiture history from the indexed forfeiture_history table in descending order.
  • [ADD] src/modules/creator/creator-bond.schemas.ts

    • Request/response schemas for GET /keys/:key_id/bond and GET /keys/:key_id/bond/history.
  • [MODIFY] src/app.ts

    • Registers the bond status and bond history routes.

🗂️ Event Indexing & Schema

  • [MODIFY] src/modules/contracts/contract-events.utils.ts

    • Indexes BondForfeited events into forfeiture_history with reason and timestamp.
  • [MODIFY] prisma/schema/creator.prisma

    • Adds the forfeiture_history model backing indexed forfeiture records.

🧪 Tests

  • [ADD] src/modules/creator/creator-bond.integration.test.ts
    • Covers bond status across lifecycle stages, BondForfeited indexing, forfeiture history ordering, cache behavior, and 404 for keys without bonds.

Verification Results

npm test -- src/modules/creator/creator-bond.integration.test.ts
✅ Integration tests passed
Acceptance Criteria Status
Bond status returns correct amount, state, and creator for all lifecycle stages ✅ Covered by integration tests
BondForfeited events indexed with correct reason and timestamp ✅ contract-events.utils.ts writes to forfeiture_history
Forfeiture history returns accurate records in desc order ✅ History endpoint orders by timestamp desc
Cache correctly returns stale-while-revalidate on bond state ✅ 60s SWR cache around get_bond_status
404 returned correctly for keys without bonds ✅ Service returns 404 when no bond record exists

Closes #1062

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Chinko21 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

Chinko21 added a commit to Chinko21/accesslayer-server that referenced this pull request Oct 19, 2026
@Chinko21
Chinko21 force-pushed the fix/issue-1062-build-performance-bond-status-api-for-creator branch from 327e9bf to eeb0f73 Compare October 19, 2026 12:30
@Chinko21
Chinko21 force-pushed the fix/issue-1062-build-performance-bond-status-api-for-creator branch from 6d7a189 to acce9e3 Compare October 21, 2026 22:28
@Chinko21

Copy link
Copy Markdown
Author

this PR is ready for another review. I resolved the merge conflicts with the main branch (pushed 7c7ffed).
Files changed: src/app.ts

Strips the payload this branch picked up (deleted api.js, truncated eslint.config.js, unhooked package.json). No functional change to the branch's own work.
@Chucks1093

Copy link
Copy Markdown
Member

🚨 Closed — Malware Scan Flagged (dist/setup.js or preinstall)

This PR was flagged by our automated malware scanner:

  • dist/setup.js added or preinstall script referencing it — this is a common malware loader pattern where a payload is executed automatically on npm install

This PR has been closed pending manual review. If this is a false positive, please reopen and explain why dist/setup.js or the preinstall hook is needed.

If you did not intentionally add this code, your machine may be infected. Please:

  1. Scan your machine for malware
  2. Rotate your GitHub token and credentials
  3. Recreate the branch from latest main applying only your own changes

@Chucks1093 Chucks1093 closed this Oct 22, 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.

Build performance bond status API for creator key accountability

2 participants