Skip to content

Frontend: All contract parameters are hardcoded across multiple components #31

@Mosas2000

Description

@Mosas2000

Summary

The contract address (SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5T) and contract name (sprintfund-core) are hardcoded as string constants in at least five separate files: page.tsx, CreateProposalForm.tsx, ProposalList.tsx, UserDashboard.tsx, Stats.tsx, and ExecuteProposal.tsx.

Problem

If the contract is redeployed or the network changes, every file needs manual updates. There is already a discrepancy where scripts reference sprintfund-core-v3 while the frontend uses sprintfund-core.

Recommended Fix

Create a central configuration file:

// config/contract.ts
export const CONTRACT_CONFIG = {
  address: process.env.NEXT_PUBLIC_CONTRACT_ADDRESS || 'SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5T',
  name: process.env.NEXT_PUBLIC_CONTRACT_NAME || 'sprintfund-core',
};

Import from this single source in all components.

Impact

Medium - Maintenance burden and risk of inconsistency across the codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfrontendFrontend related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions