Skip to content

feat: integrate proposal contract into frontend - #99

Merged
Bran18 merged 19 commits into
Harmonia-Development:mainfrom
derianrddev:feat-57-integrate-proposal-contract
Jul 21, 2025
Merged

feat: integrate proposal contract into frontend#99
Bran18 merged 19 commits into
Harmonia-Development:mainfrom
derianrddev:feat-57-integrate-proposal-contract

Conversation

@derianrddev

@derianrddev derianrddev commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

🛠️ Issue

📖 Description

This PR introduces full integration between the Proposal page UI and the on-chain ProposalContract deployed on the Stellar testnet via Soroban. It enables users to create, list, view details, and vote on proposals by connecting with their wallet.

A dedicated detail page was also created for individual proposals, which fetches and displays data directly from the blockchain. The user experience has been enhanced with loading skeletons and pagination support on the main proposals page.

✅ Changes Made

🔐 Contract Changes

  • Updated the ProposalContract to align categories/types with the frontend
  • Added a function to fetch all proposals from the contract, with corresponding test

🔌 Contract Integration with Frontend

  • Generated TypeScript bindings for ProposalContract
  • Added a ProposalContract wrapper to interact with the Soroban client
  • Integrated wallet connection and Freighter signing support
  • Added useSorobanContract hook to manage contract execution with the wallet
  • Added useProposal hook to interact with the ProposalContract

🧱 Proposal Page Changes

  • Updated the UI to match the latest design
  • Integrated creation and listing of proposals directly from the contract
  • Added pagination support for large proposal sets
  • Updated loading skeletons

📄 Proposal Detail Page Changes

  • Created a dedicated page for viewing proposal details
  • Connected the detail view to fetch proposal data directly from the testnet
  • Added a new ProposalDetailSkeleton for the loading state

⚙️ General Changes

  • Replaced deprecated toast notifications with sonner
  • Removed unnecessary lockfiles (package-lock.json)
  • Deleted autogenerated test_snapshots files that were still tracked despite being ignored
  • Added required environment variables to apps/webapp/.env.sample

🖼️ Media (screenshots/videos)

Screenshot 2025-07-19 103809

Screenshot 2025-07-19 104032

https://www.loom.com/share/e88921b7d98045e6a887ba2fa767930b?sid=a9e59d08-44f3-49f8-baa7-9c022e446f2e

📝 Additional Notes

  • Installed "@stellar/stellar-sdk": "14.0.0-rc.3" because version 13.3.0 has bugs when interacting with contracts on the Stellar testnet.
    More info: stellar/js-stellar-sdk#1185

@derianrddev
derianrddev marked this pull request as ready for review July 20, 2025 22:27
@derianrddev

Copy link
Copy Markdown
Contributor Author

@Bran18 pr ready for review

@Bran18
Bran18 requested a review from Copilot July 21, 2025 17:39
@Bran18
Bran18 self-requested a review July 21, 2025 17:39

@Bran18 Bran18 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, mate! Once again, you've delivered an impressive performance.

Let's merge this one.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the ProposalContract smart contract deployed on Stellar testnet with the frontend, enabling full governance functionality including proposal creation, voting, and real-time data fetching from the blockchain. Key changes include wallet integration using Freighter, TypeScript contract bindings, and a complete UI overhaul with new components for proposal management.

  • Complete integration between frontend and Soroban smart contract on Stellar testnet
  • New wallet connection system with Freighter support and transaction signing
  • Updated UI components with pagination, filtering, and real-time proposal data

Reviewed Changes

Copilot reviewed 59 out of 64 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
apps/webapp/package.json Added Stellar SDK, wallet dependencies, and replaced toast system with Sonner
apps/webapp/lib/contracts/proposal-contract/ Generated TypeScript bindings and wrapper for ProposalContract
apps/webapp/hooks/ New wallet integration hooks and contract interaction utilities
apps/webapp/components/proposals/ Redesigned proposal components with blockchain integration
apps/webapp/app/proposals/ Updated pages to use contract data instead of mock data

Comment on lines +17 to +18
if (typeof window !== 'undefined') {
//@ts-ignore Buffer exists

Copilot AI Jul 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace @ts-ignore with proper type declaration. Use 'window.Buffer = window.Buffer || Buffer' without the comment, or add proper type declarations for Buffer on the Window interface.

Suggested change
if (typeof window !== 'undefined') {
//@ts-ignore Buffer exists
declare global {
interface Window {
Buffer: typeof Buffer
}
}
if (typeof window !== 'undefined') {

Copilot uses AI. Check for mistakes.
Comment on lines +132 to +133
// biome-ignore lint/suspicious/noExplicitAny: using `any` here to support dynamically generated contract instances
(contractInstance: any): boolean => {

Copilot AI Jul 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider creating a proper interface for contract instances instead of using 'any'. Define a base contract interface with the expected 'client' property and signing methods to improve type safety.

Suggested change
// biome-ignore lint/suspicious/noExplicitAny: using `any` here to support dynamically generated contract instances
(contractInstance: any): boolean => {
(contractInstance: ContractInstance): boolean => {

Copilot uses AI. Check for mistakes.
Comment thread apps/webapp/components/proposals/ProposalCard.tsx
}
}

console.log(proposal.status.tag)

Copilot AI Jul 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log statement from production code. This appears to be debugging code that should be cleaned up.

Suggested change
console.log(proposal.status.tag)
// Removed unnecessary console.log statement

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,276 @@
/* eslint-disable */

Copilot AI Jul 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Instead of disabling all ESLint rules, consider using more specific disable comments for the particular rules that need to be bypassed in auto-generated code, or configure ESLint to ignore this generated file.

Suggested change
/* eslint-disable */
// This file contains both auto-generated and manually written code.
// eslint-disable-next-line no-undef

Copilot uses AI. Check for mistakes.
}

export function createProposalContract(): ProposalContract {
const contractId = process.env.NEXT_PUBLIC_CONTRACT_ID_PROPOSAL

Copilot AI Jul 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider validating the contract ID format to ensure it's a valid Stellar contract address before using it. Invalid contract IDs could cause runtime errors or security issues.

Copilot uses AI. Check for mistakes.
@Bran18
Bran18 merged commit 8de567b into Harmonia-Development:main Jul 21, 2025
1 check 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.

Integrate Soroban Proposal Contract into Harmonia Frontend with Freighter and React Hook Support

3 participants