Skip to content

feat(contracts): resource_credits queries + expiry + tests + event_ticketing scaffold#874

Merged
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
Tinna23:feature/ct-05-08-resource-credits-and-event-ticketing
Apr 26, 2026
Merged

feat(contracts): resource_credits queries + expiry + tests + event_ticketing scaffold#874
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
Tinna23:feature/ct-05-08-resource-credits-and-event-ticketing

Conversation

@Tinna23
Copy link
Copy Markdown
Contributor

@Tinna23 Tinna23 commented Apr 26, 2026

Summary

Implements four issues assigned to @Tinna23 in a single branch.

Closes #769
Closes #770
Closes #771
Closes #772


Changes

CT-05 — Credit balance & supply query functions (#769)

  • get_balance(env, member) -> u128 — returns member's credit balance (0 if unset)
  • get_total_supply(env) -> u128 — returns total credits in circulation
  • get_admin(env) -> Result<Address, Error> — returns current admin
  • All three are read-only (no state mutation)

CT-06 — Credit expiry mechanism (#770)

  • CreditBalance in types.rs gains expires_at: Option<u64>
  • mint_credits accepts optional expires_at: Option<u64>
  • transfer_credits returns Error::CreditsExpired when sender's credits are past expiry
  • spend_credits returns Error::CreditsExpired when credits are expired
  • is_expired(env, member) -> bool query added

CT-07 — Test suite for resource_credits (#771)

14 tests in src/test.rs covering:

  • initialize sets admin and rejects re-initialization
  • mint_credits increases balance and total supply; rejects non-admin
  • transfer_credits moves credits correctly; fails with InsufficientBalance
  • spend_credits reduces balance and supply; fails with InsufficientBalance
  • Expired credits cannot be transferred or spent
  • get_balance returns 0 for unknown members
  • get_admin and get_total_supply return correct values

CT-08 — Scaffold event_ticketing contract (#772)

New contract at contracts/sandbox/event_ticketing/:

  • Cargo.toml with soroban-sdk workspace dependency
  • src/types.rs: Event, Ticket, EventStatus, TicketStatus
  • src/errors.rs: 10 error variants (AdminNotSet, AlreadyInitialized, Unauthorized, EventNotFound, TicketNotFound, EventSoldOut, EventNotActive, InvalidTimeRange, InvalidPrice, TicketNotTransferable)
  • src/lib.rs: DataKey enum (Admin, PaymentToken, Event(String), EventList, Ticket(String), EventTickets(String), OwnerTickets(Address)) + initialize stub

Workspace

  • Both sandbox/resource_credits and sandbox/event_ticketing added to contracts/Cargo.toml workspace members

…tracts

CT-05 (DistinctCodes#769): Add get_balance, get_total_supply, get_admin query functions
CT-06 (DistinctCodes#770): Add credit expiry mechanism with expires_at, CreditsExpired, is_expired
CT-07 (DistinctCodes#771): Comprehensive test suite for resource_credits contract
CT-08 (DistinctCodes#772): Scaffold event_ticketing contract with types, errors, DataKey, initialize

- contracts/sandbox/resource_credits: full contract with query functions,
  expiry mechanism, and 14 tests covering all functions and error paths
- contracts/sandbox/event_ticketing: scaffolded contract with Event/Ticket
  types, 10 error variants, DataKey enum, and initialize stub
- contracts/Cargo.toml: added both sandbox contracts to workspace members
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@Tinna23 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

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

@yusuftomilola yusuftomilola merged commit 80b2a69 into DistinctCodes:main Apr 26, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants