Skip to content

feat: add approveForTrustline functionality and integrate with token …#94

Merged
JoelVR17 merged 3 commits intodevelopfrom
feat/add-trustline
Mar 13, 2026
Merged

feat: add approveForTrustline functionality and integrate with token …#94
JoelVR17 merged 3 commits intodevelopfrom
feat/add-trustline

Conversation

@Villarley
Copy link
Collaborator

@Villarley Villarley commented Mar 13, 2026

…service

Summary by CodeRabbit

New Features

  • Streamlined two-step investment workflow with automatic token approval before purchase completion
  • Integrated Freighter wallet support enabling direct token installation and simplified token management
  • Enhanced investment progress tracking with visual step indicators for each transaction phase
  • Configurable Soroban RPC URL endpoints for improved network flexibility and deployment reliability

@vercel
Copy link

vercel bot commented Mar 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
backoffice-tokenization Ready Ready Preview, Comment Mar 13, 2026 11:25pm
investor Ready Ready Preview, Comment Mar 13, 2026 11:25pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Warning

Rate limit exceeded

@Villarley has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 36 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7bf2236c-9067-4c6a-89c1-808999a3f7fa

📥 Commits

Reviewing files that changed from the base of the PR and between 8f2031d and 1e2a7f5.

📒 Files selected for processing (1)
  • apps/investor-tokenization/src/features/transparency/ProjectCard.tsx
📝 Walkthrough

Walkthrough

This PR introduces a two-step investment flow by adding trustline approval support. It includes a new DTO and service method for approving tokens, a controller endpoint to handle approval requests, a Soroban helper to fetch ledger sequences, and UI updates to add tokens to Freighter before completing purchases.

Changes

Cohort / File(s) Summary
Backend: Participation Token Module
apps/core/src/participation-token/dto/approve-for-trustline.dto.ts, apps/core/src/participation-token/participation-token.controller.ts, apps/core/src/participation-token/participation-token.service.ts
New DTO class with contractId, from, spender, and callerPublicKey fields; new POST endpoint /approve-for-trustline that delegates to service; new service method that fetches latest ledger, computes expiration, and builds contract call transaction with fixed 100M USDC amount.
Backend: Soroban Service
apps/core/src/soroban/soroban.service.ts
New rpc.Server instance initialization and public method getLatestLedgerSequence() to fetch latest ledger sequence from RPC.
Frontend: Context & Propagation
apps/investor-tokenization/src/features/tokens/context/SelectedEscrowContext.tsx, apps/investor-tokenization/src/components/ui/apple-cards-carousel.tsx, apps/investor-tokenization/src/features/transparency/ProjectCard.tsx
Added optional tokenFactoryId field to SelectedEscrowValue context type; propagate tokenFactoryId through provider in carousel and ProjectCard components.
Frontend: Investment Flow
apps/investor-tokenization/src/features/tokens/components/InvestDialog.tsx, apps/investor-tokenization/src/features/tokens/services/token.service.ts
Introduced two-step investment (trustline approval via Freighter, then token purchase); added configurable SOROBAN_RPC_URL; new approveForTrustline() service method; added submit step tracking and dynamic button label reflecting progress; enhanced error handling for both approval and purchase steps.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant InvestDialog
    participant TokenService
    participant Core API
    participant Soroban RPC
    participant Freighter
    participant Contract

    User->>InvestDialog: Click invest (trustline step)
    InvestDialog->>TokenService: approveForTrustline(payload)
    TokenService->>Core API: POST /participate-token/approve-for-trustline
    Core API->>Soroban RPC: getLatestLedgerSequence()
    Soroban RPC-->>Core API: ledger sequence
    Core API->>Contract: buildContractCallTransaction(approve)
    Contract-->>Core API: unsignedXdr
    Core API-->>TokenService: { unsignedXdr }
    TokenService-->>InvestDialog: { xdr }
    InvestDialog->>Freighter: addToken(tokenFactoryId)
    Freighter-->>InvestDialog: token added
    InvestDialog->>InvestDialog: Switch to buy step
    User->>InvestDialog: Click invest (buy step)
    InvestDialog->>TokenService: buyToken(payload)
    TokenService->>Core API: POST /participate-token/buy
    Core API-->>TokenService: { xdr }
    TokenService-->>InvestDialog: { xdr }
    InvestDialog->>Freighter: Sign and submit transaction
    Freighter-->>InvestDialog: transaction complete
    InvestDialog->>User: Investment successful
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • JoelVR17
  • zkCaleb-dev
  • armandocodecr

Poem

🐰 Hop along, dear tokens in flight,
A trustline approved, shining bright,
Two steps of care, a ledger's delight,
Freighter adds magic to earn you right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: adding approveForTrustline functionality and integrating it with token services, which aligns with the comprehensive changes across DTOs, controllers, services, and frontend components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-trustline
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@JoelVR17 JoelVR17 merged commit fe9ddd9 into develop Mar 13, 2026
3 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

Development

Successfully merging this pull request may close these issues.

2 participants