Skip to content

feat: add key rental marketplace with listings, rent flow and active rental view (#1360) - #1362

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
maleficboss:feat/key-rental-marketplace
Nov 22, 2026
Merged

Chucks1093 merged 1 commit into
accesslayerorg:devfrom
maleficboss:feat/key-rental-marketplace

Conversation

@maleficboss

Copy link
Copy Markdown
Contributor

Summary

Closes #1360.

Adds the key rental marketplace and the rental management view: holders list keys for a daily fee, renters rent them by the day, and gated content recognises rental access.

Heads-up: the rental contract is not on chain yet. accesslayerorg/accesslayer-contracts#1227 (the rental contract) was closed by accesslayerorg/accesslayer-contracts#1245, but that PR's merged diff only adds the anti-sniper launch window (creator-keys/src/launch_window.rs, lib.rs, test_launch_window.rs). There is no list_rental, rent or is_active_renter anywhere in the contracts repo, and accesslayer-server has no rental endpoints. So this PR:

  • builds the client against the interface specified in that contracts issue: list_rental(owner, key_id, quantity, fee_per_day, max_days, collateral), rent(renter, listing_id, days), is_active_renter(wallet, key_id), end_rental(listing_id) and claim_collateral(owner, listing_id);
  • reads listings from GET /rentals and GET /users/:wallet/rentals, the same split the airdrop flow uses (backend lists, contract writes), because the spec emits rental_listed, rental_started and rental_ended events but has no list views;
  • keeps everything behind a new optional VITE_KEY_RENTAL_CONTRACT_ID. While it is unset, the rental pages show a "not live yet" notice, no rental query runs, every rental action is disabled, and existing pages behave exactly as before.

What's included

  • /rentals (RentalMarketPage): available listings with fee per day, maximum days and collateral, plus loading, error, empty and not-live states.
  • ListRentalModal: key, quantity, fee per day, maximum days and collateral. The quantity is validated against the holder's available balance (liquid keys minus keys already listed). The modal explains that listed keys are escrowed.
  • RentModal: a day selector (input, stepper and quick picks, capped at the listing's maximum) showing the rental fee (fee per day times days), the collateral and the total due. All amounts are integer stroops, so totals are exact, e.g. 1.2345678 XLM × 7 = 8.6419746 XLM.
  • /rentals/mine (MyRentalsPage): Listed, Rented out and Rented in tabs with time remaining. End rental appears only after expiry. Claim collateral appears only for the owner, after the grace period.
  • Listed keys cannot be sold or transferred: on the portfolio holding row and the key page, keys in open listings are subtracted from the sellable and transferable balance (Sell, Transfer, Gift and Batch Transfer, plus the key page's trade dialog and staking vault). A notice explains why, and the Sell tooltip gives the reason when every key is listed.
  • Rented badge: SubscriptionAccessGate unlocks for an active renter via is_active_renter and shows a Rented badge with the time left instead of the holder banner.
  • Data layer: keyRentalContract.service.ts (injectable client factory, like airdropContract.service.ts), keyRental.service.ts, useKeyRentals.ts, keyRental.utils.ts and types/keyRental.ts.
  • Docs: the new variable is added to .env.example and the CONTRIBUTING env table.
Acceptance criterion Where
Listings show fee, maximum days and collateral correctly RentalListingCard; RentalMarketPage.test.tsx checks exact values, including 0.1234567 XLM
The rent modal total equals fee per day times days calculateRentalFeeStroops (bigint); RentModal.test.tsx and keyRental.utils.test.ts
Listed keys cannot be sold or transferred and the UI explains why RentalEscrowNotice plus balance changes in PortfolioHoldingRow and CreatorDetailPage; PortfolioHoldingRow.rentalEscrow.test.tsx
End rental and claim collateral appear only when eligible canEndRental and canClaimCollateral; RentalRow.test.tsx and MyRentalsPage.test.tsx
Gated content shows the Rented badge for rental access SubscriptionAccessGate and RentedBadge; 3 new cases in SubscriptionAccessGate.test.tsx
Tests cover listing, renting and ending 60 new tests across 9 files (below)

Assumptions to confirm once the contract lands

  • Listing ids are u64, day counts u32 and amounts i128 stroops.
  • Escrowed keys stay in the owner's balance (the spec says to "block transfer and sale of escrowed keys"), so the client subtracts them. If list_rental moves keys out instead, drop the subtraction in getEscrowedKeyQuantity's two call sites.
  • The grace period end comes from the indexed listing (grace_ends_at). The normalizer also accepts camelCase, contract field names, seconds, milliseconds and ISO dates, and stroop or XLM amounts.
  • The contract spec has no way to cancel an unrented listing, so listed keys stay escrowed until they are rented and the rental ends.
  • I didn't add a header nav link while rentals aren't live. Happy to add one.

Testing

  • pnpm lint: pass (same as dev)
  • pnpm build: pass (same as dev)

Run locally on Node 22 and pnpm 10.6.5 with pnpm install --frozen-lockfile, comparing dev at 7da03cd with this branch:

Check dev This branch
pnpm lint, pnpm build, scripts/check-no-package-lock.sh (the CI steps) pass pass
pnpm test (not in CI) 3,650 passed, 406 failed, 1 skipped; 109 of 582 files failing 3,710 passed, 406 failed, 1 skipped; 109 of 590 files failing
Failing tests, compared by name identical set except two timing-flaky tests in files this PR doesn't touch: LandingPage.buyFlowEndToEnd › "reports the submitted quantity while the transaction is pending" (failed on dev, passed once and failed twice in three reruns here) and CreatorDashboardPage.whitelist › "renders whitelist management panel…" (failed once, passed in two of three reruns; that page imports none of the changed code)
New rental tests 60 passing: keyRental.utils 23, keyRentalContract.service 8, RentModal 3, ListRentalModal 5, RentalRow 5, RentalMarketPage 6, MyRentalsPage 4, PortfolioHoldingRow.rentalEscrow 3, SubscriptionAccessGate +3
Malware Scan patterns (from malware-scan.yml, run on the diff) 0 findings; no config or package files changed
Test merge with open PRs that touch the same files (#1361, #1348, #1347, #1346, #1337, #1313) all merge cleanly

Mutation checks: making the fee a sum instead of a product fails 4 of the new tests, letting anyone claim collateral fails 2, and ignoring escrow on the holding row fails 1.

SubscriptionAccessGate.test.tsx › "shows locked state when holding is below minimum threshold" already fails on dev: it looks for a "Buy Keys to Unlock" button the component doesn't render. I added the rental-hook mock to that file but left the test as is.

Screenshots: I couldn't take any, because the client doesn't boot locally on dev at 7da03cd:

  • vite and vite preview both throw Buffer is not defined at startup (the Stellar SDK with no Buffer polyfill);
  • with a Buffer shim injected, the App then throws useLocation() may be used only in the context of a <Router> component.

Both happen on untouched dev, on every route, and could be a separate issue. The new UI is covered by the component and page tests above.

Checklist

  • Linked issue or backlog item (Create key rental marketplace with listings, rent flow and active rental view #1360)
  • Scope is limited to the stated change: rental pages, modals and data layer, plus the two integration points the issue names (sale/transfer explanation, Rented badge on gated content)
  • Updated docs if behavior or setup changed (.env.example, CONTRIBUTING env table)
  • Added screenshots for UI changes when relevant (not possible, see above)

…erorg#1360)

Holders can list creator keys for a daily fee and renters can pay for a
number of days to get access, following the rental contract interface
from accesslayer-contracts#1227 (list_rental, rent, is_active_renter,
end_rental, claim_collateral).

- /rentals lists available rentals with fee per day, maximum days and
  collateral, with a List your keys modal validated against the
  holder's available balance and a Rent modal whose total is fee per
  day times days, computed exactly in stroops.
- /rentals/mine shows Listed, Rented out and Rented in tabs with time
  remaining. End rental appears only after expiry and Claim collateral
  only for the owner after the grace period.
- Keys listed for rent are taken out of the sellable and transferable
  balance on the portfolio row and the key page, which explain why.
- Gated content unlocks for an active renter (is_active_renter) and
  shows a Rented badge with the time left.
- Rentals stay disabled behind a "not live yet" notice until
  VITE_KEY_RENTAL_CONTRACT_ID is set; listings are read from the
  backend (GET /rentals, GET /users/:wallet/rentals) like other
  contract-backed lists.
@drips-wave

drips-wave Bot commented Nov 21, 2026

Copy link
Copy Markdown

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

@maleficboss

Copy link
Copy Markdown
Contributor Author

@Chucks1093 this is ready for review whenever you have a moment.

  • Checks: Client CI and the malware scan both pass.
  • No conflicts: it is up to date with dev (7da03cd) and merges cleanly.
  • Until VITE_KEY_RENTAL_CONTRACT_ID is set, the rental pages show an "unavailable" notice instead of calling the contract. The description covers the details and the 60 new tests.

Thanks!

@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

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.

Create key rental marketplace with listings, rent flow and active rental view

2 participants