Skip to content

Refactor/improve code#103

Merged
JoelVR17 merged 21 commits intodevelopfrom
refactor/improve-code
Mar 26, 2026
Merged

Refactor/improve code#103
JoelVR17 merged 21 commits intodevelopfrom
refactor/improve-code

Conversation

@JoelVR17
Copy link
Copy Markdown
Contributor

@JoelVR17 JoelVR17 commented Mar 17, 2026

Summary by CodeRabbit

Release Notes

New Features

  • Added ROI update dialog with percentage input and enhanced error messaging for campaigns
  • Introduced vault enablement actions with success notifications and improved error reporting
  • Added "Repayment" and "Claimable" campaign filter labels for better filtering options
  • Enhanced language switcher with improved locale selection handling

Refactoring

  • Consolidated shared UI components and utilities across apps for better maintainability
  • Centralized configuration constants and improved environment variable management
  • Streamlined campaign management views with standardized toolbar and filtering
  • Simplified internal architecture by moving campaign-related components to shared packages

Chores

  • Updated localization strings in Spanish and English for new features
  • Refined environment configuration examples across applications

@JoelVR17 JoelVR17 self-assigned this Mar 17, 2026
@JoelVR17 JoelVR17 added enhancement New feature or request CORE-DEV labels Mar 17, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 17, 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 20, 2026 9:05pm
investor Ready Ready Preview, Comment Mar 20, 2026 9:05pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9abb07d4-9606-4d7f-9c12-02246980dd43

📥 Commits

Reviewing files that changed from the base of the PR and between ba790aa and 4dd8332.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (125)
  • CLAUDE.md
  • apps/backoffice-tokenization/.env.example
  • apps/backoffice-tokenization/messages/en.json
  • apps/backoffice-tokenization/messages/es.json
  • apps/backoffice-tokenization/next.config.ts
  • apps/backoffice-tokenization/src/app/[locale]/(dashboard)/campaigns/loans/[id]/page.tsx
  • apps/backoffice-tokenization/src/app/[locale]/(dashboard)/campaigns/new/page.tsx
  • apps/backoffice-tokenization/src/app/[locale]/(dashboard)/campaigns/page.tsx
  • apps/backoffice-tokenization/src/app/[locale]/(dashboard)/roi/page.tsx
  • apps/backoffice-tokenization/src/app/[locale]/layout.tsx
  • apps/backoffice-tokenization/src/app/[locale]/page.tsx
  • apps/backoffice-tokenization/src/components/layout/app-header.tsx
  • apps/backoffice-tokenization/src/components/layout/app-sidebar.tsx
  • apps/backoffice-tokenization/src/components/shared/Header.tsx
  • apps/backoffice-tokenization/src/components/shared/campaign-card.tsx
  • apps/backoffice-tokenization/src/components/shared/section-title.tsx
  • apps/backoffice-tokenization/src/components/shared/stat-item.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/campaign-filter.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/campaign-search.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/campaign-toolbar.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/campaigns-view.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/claim-roi-button.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/loans/manage-loans-view.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/UpdateRoiDialog.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/add-funds-dialog.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/create-roi-dialog.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-table-row.tsx
  • apps/backoffice-tokenization/src/features/campaigns/hooks/useUpdateRoiPercentage.ts
  • apps/backoffice-tokenization/src/features/campaigns/services/soroban.service.ts
  • apps/backoffice-tokenization/src/features/campaigns/services/transfer.service.ts
  • apps/backoffice-tokenization/src/features/campaigns/services/vault-balance.service.ts
  • apps/backoffice-tokenization/src/features/campaigns/types/milestone.types.ts
  • apps/backoffice-tokenization/src/features/campaigns/utils/campaign.mapper.ts
  • apps/backoffice-tokenization/src/features/home/BentoGrid.tsx
  • apps/backoffice-tokenization/src/features/manage-escrows/ManageEscrowsView.tsx
  • apps/backoffice-tokenization/src/features/vaults/deploy/dialog/CreateVault.tsx
  • apps/backoffice-tokenization/src/features/vaults/deploy/dialog/useCreateVault.ts
  • apps/backoffice-tokenization/src/features/vaults/deploy/dialog/useEnableVault.ts
  • apps/backoffice-tokenization/src/lib/numeric-input.ts
  • apps/backoffice-tokenization/src/lib/sendTransactionService.ts
  • apps/backoffice-tokenization/src/lib/tokenDeploymentService.ts
  • apps/backoffice-tokenization/src/lib/utils.ts
  • apps/backoffice-tokenization/src/lib/vaultDeploymentService.ts
  • apps/core/.env.example
  • apps/core/src/deploy/deploy.service.ts
  • apps/core/src/vault/vault.service.ts
  • apps/investor-tokenization/.env.example
  • apps/investor-tokenization/messages/en.json
  • apps/investor-tokenization/messages/es.json
  • apps/investor-tokenization/next.config.ts
  • apps/investor-tokenization/src/app/[locale]/campaigns/page.tsx
  • apps/investor-tokenization/src/app/[locale]/claim-roi/page.tsx
  • apps/investor-tokenization/src/app/[locale]/investments/page.tsx
  • apps/investor-tokenization/src/app/[locale]/layout.tsx
  • apps/investor-tokenization/src/app/[locale]/my-investments/page.tsx
  • apps/investor-tokenization/src/components/layout/app-header.tsx
  • apps/investor-tokenization/src/components/layout/app-sidebar.tsx
  • apps/investor-tokenization/src/components/shared/campaign-card.tsx
  • apps/investor-tokenization/src/components/shared/language-switcher.tsx
  • apps/investor-tokenization/src/components/ui/apple-cards-carousel.tsx
  • apps/investor-tokenization/src/features/claim-roi/ClaimROIView.tsx
  • apps/investor-tokenization/src/features/claim-roi/VaultCard.tsx
  • apps/investor-tokenization/src/features/claim-roi/VaultList.tsx
  • apps/investor-tokenization/src/features/claim-roi/config/vaultConfig.ts
  • apps/investor-tokenization/src/features/claim-roi/hooks/useClaimROI.ts
  • apps/investor-tokenization/src/features/claim-roi/hooks/useVaultInfo.ts
  • apps/investor-tokenization/src/features/claim-roi/services/getTokenBalance.ts
  • apps/investor-tokenization/src/features/claim-roi/services/vaultInfo.service.ts
  • apps/investor-tokenization/src/features/investments/InvestmentsView.tsx
  • apps/investor-tokenization/src/features/investments/components/InvestmentCard.tsx
  • apps/investor-tokenization/src/features/investments/hooks/useProjectTokenBalances.hook.ts
  • apps/investor-tokenization/src/features/roi/components/campaign-filter.tsx
  • apps/investor-tokenization/src/features/roi/components/campaign-list.tsx
  • apps/investor-tokenization/src/features/roi/components/campaign-search.tsx
  • apps/investor-tokenization/src/features/roi/components/campaign-toolbar.tsx
  • apps/investor-tokenization/src/features/roi/components/investor-profile-card.tsx
  • apps/investor-tokenization/src/features/roi/constants/campaign-status.ts
  • apps/investor-tokenization/src/features/tokens/components/InvestDialog.tsx
  • apps/investor-tokenization/src/features/transparency/CampaignsGrid.tsx
  • apps/investor-tokenization/src/features/transparency/Carousel.tsx
  • apps/investor-tokenization/src/features/transparency/ProjectCard.tsx
  • apps/investor-tokenization/src/hooks/use-outside-click.tsx
  • apps/investor-tokenization/src/lib/contractErrorHandler.ts
  • apps/investor-tokenization/src/lib/sendTransactionService.ts
  • apps/investor-tokenization/src/lib/sorobanClient.ts
  • apps/investor-tokenization/src/lib/toastWithTx.tsx
  • apps/investor-tokenization/src/lib/tokenDeploymentService.ts
  • apps/investor-tokenization/src/lib/utils.ts
  • apps/investor-tokenization/src/lib/vaultDeploymentService.ts
  • apps/investor-tokenization/src/utils/adjustedAmounts.ts
  • docs/POSTMAN.md
  • docs/REFACTOR_BACKOFFICE_INVESTOR.md
  • docs/TOKENIZE-ESCROW.md
  • docs/TOKEN_BALANCE_SYSTEM.md
  • docs/audits/smart-contracts/vault-contract/SECURITY_AUDIT_VAULT_CONTRACT-V1.0.0.md
  • docs/plans/2026-03-13-update-roi-percentage.md
  • packages/features/package.json
  • packages/features/src/campaign/campaign-toolbar.tsx
  • packages/features/src/campaign/campaigns-view.tsx
  • packages/features/src/campaign/index.ts
  • packages/features/src/index.ts
  • packages/features/tsconfig.json
  • packages/shared/package.json
  • packages/shared/src/index.ts
  • packages/shared/src/lib/campaignStatus.ts
  • packages/shared/src/lib/constants.ts
  • packages/shared/src/lib/contractErrorHandler.ts
  • packages/shared/src/lib/sendTransactionService.ts
  • packages/shared/src/lib/sorobanClient.ts
  • packages/shared/src/lib/sorobanSubmitAndWait.ts
  • packages/shared/src/lib/utils.ts
  • packages/shared/src/types/campaign.ts
  • packages/tw-blocks-shared/src/escrows/escrows-by-role/details/EscrowDetailDialog.tsx
  • packages/tw-blocks-shared/src/escrows/escrows-by-role/details/GeneralInformation.tsx
  • packages/tw-blocks-shared/src/escrows/escrows-by-role/details/StatisticsCard.tsx
  • packages/tw-blocks-shared/src/escrows/escrows-by-signer/details/EscrowDetailDialog.tsx
  • packages/tw-blocks-shared/src/escrows/escrows-by-signer/details/GeneralInformation.tsx
  • packages/tw-blocks-shared/src/escrows/escrows-by-signer/details/StatisticsCard.tsx
  • packages/tw-blocks-shared/src/helpers/format.helper.ts
  • packages/ui/package.json
  • packages/ui/src/app-sidebar.tsx
  • packages/ui/src/index.ts
  • packages/ui/src/language-switcher.tsx
  • packages/ui/src/section-title.tsx
  • packages/ui/src/toast-with-tx.tsx

📝 Walkthrough

Walkthrough

Large-scale refactoring consolidating shared utilities, components, and types into centralized packages (@tokenization/shared, @tokenization/ui, @tokenization/features). Removes duplicate local implementations, migrates imports across apps, adds new shared constants and helpers, and restructures campaign/ROI UI using controlled component patterns and shared views.

Changes

Cohort / File(s) Summary
Environment & Configuration
CLAUDE.md, .env.example files
Updated environment variable documentation and examples, adding new Soroban/Stellar config variables and API keys; consolidated shared configuration constants across backoffice, core, and investor apps.
Shared Package Expansion
packages/shared/*
Added new exported modules for constants (USDC_ADDRESS, SOROBAN_RPC_URL, ESCROW_EXPLORER_URL), sorobanSubmitAndWait (transaction submission/polling helper), improved utils (numeric input, stroops conversion), and updated campaignStatus with new SharedCampaignStatus type.
New Features Package
packages/features/*
Created new @tokenization/features package with shared CampaignToolbar and SharedCampaignsView components, accepting controlled props for search/filter and rendering filtered campaigns with toolbar labels.
UI Package Consolidation
packages/ui/*
Migrated SectionTitle, LanguageSwitcher (refactored to controlled component), and toastWithTx to shared UI package; updated AppSidebar to accept optional pathname prop for active-route control.
Backoffice Campaign UI Refactoring
apps/backoffice-tokenization/src/app/.../(dashboard)/campaigns/*, campaigns/page.tsx
Replaced local state-based campaign management with SharedCampaignsView, added campaign status/search filtering, removed local CampaignFilter/CampaignSearch/CampaignToolbar components.
Backoffice Loans & ROI Pages
apps/backoffice-tokenization/src/app/.../loans/[id]/page.tsx, roi/page.tsx
Converted loans page to client component with React use(params), added i18n via useTranslations("loans"), updated imports to use shared SectionTitle and UI components.
Backoffice ROI & Vault Features
apps/backoffice-tokenization/src/features/campaigns/roi/*, vaults/deploy/*
Removed AddFundsDialog, CreateRoiDialog; updated UpdateRoiDialog with i18n; refactored useUpdateRoiPercentage and useEnableVault to use translated error messages and centralized SendTransactionService.
Backoffice Service Layer Consolidation
apps/backoffice-tokenization/src/features/campaigns/services/*, vaults/deploy/dialog/*
Replaced hardcoded USDC/Soroban config with imports from @tokenization/shared/lib/constants; updated soroban.service.ts to use shared submitSignedTransactionAndWait; removed local SorobanClient implementations.
Backoffice Local Utilities Cleanup
apps/backoffice-tokenization/src/lib/*
Removed local re-exports and implementations (numeric-input.ts, utils.ts, sendTransactionService.ts); deleted deployment services (tokenDeploymentService.ts, vaultDeploymentService.ts).
Backoffice Components & Layout
apps/backoffice-tokenization/src/components/shared/*, src/components/layout/*
Removed Header.tsx, SectionTitle.tsx, StatItem.tsx, CampaignCard local imports; updated AppHeader/AppSidebar to use shared LanguageSwitcher with pathname/locale callback; updated campaign-card.tsx to import from shared packages.
Backoffice Message Localization
apps/backoffice-tokenization/messages/{en,es}.json
Added campaign filter labels (Repayment, Claimable), ROI dialog/action labels, vault enable success toast, and associated error messages for both English and Spanish.
Backoffice Config & Removed Features
apps/backoffice-tokenization/next.config.ts, feature removals
Updated transpilePackages to include @tokenization/features; removed CampaignFilter, CampaignSearch, CampaignToolbar, CampaignsView, ClaimRoiButton, campaign mapper utilities, and entire BentoGrid/ManageEscrowsView modules.
Investor Campaign & ROI Refactoring
apps/investor-tokenization/src/app/.../campaigns/page.tsx, claim-roi/*, roi/*
Removed ClaimROI, Investments page routes; replaced campaigns page with SharedCampaignsView; deleted ClaimROIView, VaultList, VaultCard, VaultConfig and added new useClaimROI hook; removed local campaign-filter/search/toolbar components.
Investor Feature Cleanup
apps/investor-tokenization/src/features/{claim-roi,investments}/*
Deleted entire claim-roi feature (vaultInfo.service.ts, getTokenBalance.ts, hooks, components); removed InvestmentsView, InvestmentCard, useProjectTokenBalances hook; removed claim action from carousel.
Investor Carousel & Transparency Removal
apps/investor-tokenization/src/features/{transparency,components}/ui
Removed 520-line apple-cards-carousel.tsx with carousel context and claim ROI integration; removed Carousel.tsx (DummyContent component); added new CampaignsGrid.tsx using escrow data fetching.
Investor InvestDialog & Tokens
apps/investor-tokenization/src/features/tokens/components/InvestDialog.tsx
Centralized Stellar config imports from @tokenization/shared/lib/constants; updated error handling with localized translation keys; changed Freighter/Soroban error messages to use i18n; updated USDC address reference.
Investor Service & Layout Consolidation
apps/investor-tokenization/src/components/layout/*, src/app/.../layout.tsx
Updated AppHeader/AppSidebar to use shared LanguageSwitcher component with controlled pathname/locale props; updated layout imports to use shared cn utility.
Investor Local Utilities & Removed Services
apps/investor-tokenization/src/lib/*
Removed sorobanClient.ts (375 lines of Soroban RPC client), tokenDeploymentService.ts, vaultDeploymentService.ts, contractErrorHandler.ts; removed utility re-exports and local helper implementations (adjustedAmounts.ts).
Investor Message Localization
apps/investor-tokenization/messages/{en,es}.json
Added campaigns.loading label, investDialog.disclaimerLabel, and error messages for token add failure and Soroban errors (both English and Spanish).
Investor Config
apps/investor-tokenization/next.config.ts
Added @tokenization/features to transpilePackages array.
Core Service Updates
apps/core/.env.example, src/deploy/deploy.service.ts, src/vault/vault.service.ts
Updated environment example with new API keys and configuration; refactored USDC contract ID selection via getUsdcContractId() function reading from process.env; fixed ROI percentage parameter name (new_roi_porcentagenew_roi_percentage).
Shared Package Type Exports
packages/shared/src/types/campaign.ts, package.json
Added new SharedCampaignStatus union type and SharedCampaign interface; updated package exports to expose shared constants, services, and campaign types.
Tw-blocks Utilities Update
packages/tw-blocks-shared/src/*
Updated cn imports from local @/lib/utils to @tokenization/shared/lib/utils; replaced hardcoded escrow explorer URLs with ESCROW_EXPLORER_URL constant; updated formatCurrency to accept `number
Documentation Updates
docs/REFACTOR_*.md, docs/TOKEN_BALANCE_SYSTEM.md, docs/TOKENIZE-ESCROW.md
Added refactoring opportunities document; removed audit report and implementation plan docs; updated tokenization flow and token balance system documentation to reflect removed features.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client<br/>(Browser)
    participant BackofficeApp as Backoffice App
    participant SharedFeatures as `@tokenization/features`<br/>(CampaignsView)
    participant SharedUI as `@tokenization/ui`<br/>(Components)
    participant SharedConstants as `@tokenization/shared`<br/>(Constants)

    Client->>BackofficeApp: Navigate to /campaigns
    BackofficeApp->>SharedFeatures: Render SharedCampaignsView
    activate SharedFeatures
    SharedFeatures->>SharedUI: Render CampaignToolbar
    SharedFeatures->>SharedUI: Render SectionTitle
    Client->>SharedUI: User types in search/selects filter
    SharedUI->>SharedFeatures: onSearchChange/onFilterChange
    SharedFeatures->>SharedFeatures: useMemo: compute filteredCampaigns
    SharedFeatures->>Client: Render filtered CampaignList
    deactivate SharedFeatures
    
    Client->>BackofficeApp: Click "View Vault" action
    BackofficeApp->>SharedConstants: getContractExplorerUrl(contractId)
    SharedConstants->>SharedConstants: Compute URL with NETWORK_PASSPHRASE
    SharedConstants-->>BackofficeApp: Return Stellar Expert URL
    BackofficeApp-->>Client: Open vault contract in new tab
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: investor implementation #77: Both modify environment example files, add/reshape httpClient exports and imports, and expand shared package exports with shared constants/utilities.
  • Feat/i18n en es #100: Both modify internationalization surface across backoffice and investor apps (messages JSON, i18n wiring, language switcher, localized components).
  • feat: ui-ux mockups for backoffice application #65: Both modify the same UI components and utilities (SectionTitle, CampaignToolbar/CampaignsView, numeric-input, campaign types), with main PR moving/consolidating those implementations.

Suggested reviewers

  • armandocodecr
  • zkCaleb-dev

🐰 With features moved and shared with care,
Constants and components now everywhere,
The refactored code hops with delight,
Consolidation making things right! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/improve-code

…ages, enhancing campaign management and user experience
…ts and update translations for improved user experience
@JoelVR17 JoelVR17 marked this pull request as ready for review March 26, 2026 22:12
@JoelVR17 JoelVR17 merged commit e4ca1e6 into develop Mar 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE-DEV enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant