Skip to content

feat: add campaign clone endpoint and points-to-token redemption - #506

Merged
joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
m1s0g1:Create-mix
Jun 2, 2026
Merged

joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
m1s0g1:Create-mix

Conversation

@m1s0g1

@m1s0g1 m1s0g1 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Closes #450
Closes #458

Full PR Description

Description:

Summary

This PR implements two features:

  1. Issue Backend: Add campaign clone endpoint (duplicate existing campaign as new draft) #458: Campaign clone endpoint for duplicating campaigns
  2. Issue Contracts: Add points-to-token redemption — exchange accumulated points for XLM or custom asset #450: Points-to-token redemption in rewards contract

Changes Made

Issue #458: Campaign Clone Endpoint

  • ✅ Added POST /api/v1/campaigns/:id/clone endpoint (API key required)
  • ✅ Clones all metadata: name (prefixed with 'Copy of'), description, tags, category, imageUrl, rewardPerAction
  • ✅ New campaign gets: status: draft, new UUID, createdAt: now, null campaignContractId
  • ✅ Fields NOT copied: contractId, startDate, endDate, participantCount, auditLogs
  • ✅ Optional request body: { overrides: { name, description, ... } } to override specific fields
  • ✅ Response includes clonedFrom: sourceId
  • ✅ Audit log entry records: cloned_from: :sourceId
  • ✅ Unit tests added and passing

Issue #450: Points-to-Token Redemption

  • ✅ Added set_redemption_rate(env, admin, nonce, asset, rate_bps) — configure redemption rate
  • ✅ Added redeem(env, user, points_amount) — burn points and transfer asset tokens
  • ✅ Added redemption_rate(env)(Address, u32) view function
  • ✅ Added redemption_reserve(env)u64 view function
  • ✅ Added withdraw_reserve(env, admin, nonce, amount) — admin can reclaim assets
  • ✅ Added fund_reserve(env, from, amount) — fund the redemption reserve
  • ✅ Rejects redemption if reserve is insufficient (Error::InsufficientReserve)
  • ✅ Emits redeemed event with topics (redeem, user) and data (points_burned, asset_amount)
  • ✅ Uses SAC (Stellar Asset Contract) for token transfers

Testing

Backend Tests

cd backend
npm test

All clone tests pass:

  • ✅ Clone creates new campaign with copied metadata
  • ✅ Clone with overrides applies custom values
  • ✅ Clone returns undefined for non-existent campaign
  • ✅ Clone generates unique slug for cloned campaign

Contract Build

cd contracts/rewards
cargo build --release

✅ Contract compiles successfully

Checklist

Issue #458

  • Add POST /api/v1/campaigns/:id/clone endpoint (API key required)
  • Clone creates new campaign with copied metadata (name prefixed with 'Copy of')
  • New campaign gets status: draft, new UUID, createdAt: now, null campaignContractId
  • Fields NOT copied: contractId, startDate, endDate, participantCount, auditLogs
  • Optional request body with overrides support
  • Response includes clonedFrom: sourceId
  • Audit log entry records cloned_from
  • Unit tests added and passing

Issue #450

  • Add set_redemption_rate function (admin only with nonce)
  • Add redeem function (burns points, transfers assets)
  • Add redemption_rate view function
  • Add redemption_reserve view function
  • Add withdraw_reserve function (admin only with nonce)
  • Add fund_reserve function
  • Reject redemption if reserve insufficient
  • Emit redeemed event
  • Use SAC for token transfers
  • Contract compiles successfully

Closes #458
Closes #450

@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

@m1s0g1 is attempting to deploy a commit to the joelpeace48-cell's projects Team on Vercel.

A member of the Team first needs to authorize it.

@m1s0g1 m1s0g1 changed the title Create mix feat: start implementation Jun 2, 2026
@m1s0g1 m1s0g1 changed the title feat: start implementation feat: add campaign clone endpoint and points-to-token redemption Jun 2, 2026
@joelpeace48-cell
joelpeace48-cell merged commit 5bf5df2 into FinesseStudioLab:main Jun 2, 2026
0 of 9 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