Skip to content

Make contract address dynamic and translate Spanish content to English#7

Merged
davidmelendez merged 3 commits into
FutureMindsTeam:mainfrom
davidmelendez:fix/dinamic-contractadress
Oct 9, 2025
Merged

Make contract address dynamic and translate Spanish content to English#7
davidmelendez merged 3 commits into
FutureMindsTeam:mainfrom
davidmelendez:fix/dinamic-contractadress

Conversation

@davidmelendez
Copy link
Copy Markdown
Contributor

Make contract address dynamic and translate Spanish content to English

📌 Description

This PR makes the Randomness contract address handling dynamic in the RandomnessComponent, allowing it to work with any deployed contract address instead of hardcoding a specific address. Additionally, all Spanish content in both the Randomness contract and UI component has been translated to English for better international collaboration.

Changes Made:

  • Dynamic Address Handling: Updated RandomnessComponent.tsx to use the deployed contract address dynamically
  • Validation Enhancement: Added contract address validation and mismatch detection
  • Spanish to English Translation: Translated all comments, messages, and UI text to English in:
    • Randomness.cairo contract comments
    • RandomnessComponent.tsx UI messages and labels
  • Updated Configuration: Updated tool versions and deployment artifacts for compatibility

🎯 Motivation and Context

Previously, the component expected a specific hardcoded contract address. This made it inflexible when redeploying contracts or working in different environments. By making the address handling dynamic, the component now:

  1. Works with any deployment: Uses the contract address from the actual deployment
  2. Better developer experience: Shows clear validation messages when addresses don't match expected values
  3. Improved maintainability: No need to update hardcoded addresses in the code
  4. International collaboration: English content makes the codebase accessible to international contributors

This change improves flexibility for devnet testing and makes the component more robust across different deployment scenarios.

🛠️ How to Test the Change (if applicable)

  1. 🔹 Deploy Randomness contract to devnet/testnet

    cd packages/snfoundry
    scarb build
    # Deploy and note the contract address
  2. 🔹 Start the development server

    cd packages/nextjs
    yarn dev
  3. 🔹 Navigate to the debug page

    • Open browser to http://localhost:3000/debug
    • The component will automatically use the deployed contract address
  4. 🔹 Verify dynamic address handling

    • Check that the component displays the actual deployed contract address
    • Verify validation checks work with any valid address
    • Confirm error messages appear in English
  5. 🔹 Test random number generation

    • Connect wallet to devnet
    • Enter a seed value
    • Click generate button
    • Verify numbers are generated successfully with the dynamic address

🖼️ Screenshots (if applicable)

Not applicable for this configuration and translation update.

🔍 Type of Change

  • 🐞 Bugfix - Fixes an existing issue or bug in the code.
  • New Feature - Adds a new feature or functionality.
  • 🚀 Hotfix - A quick fix for a critical issue in production.
  • 🔄 Refactoring - Improves the code structure without changing its behavior.
  • 📖 Documentation - Updates or creates new documentation.
  • Other (please specify) - Any other change that does not fit into the categories above.

✅ Checklist Before Merging

  • 🧪 I have tested the code and it works as expected.
  • 🎨 My changes follow the project's coding style.
  • 📖 I have updated the documentation if necessary.
  • ⚠️ No new warnings or errors were introduced.
  • 🔍 I have reviewed and approved my own code before submitting.

📌 Additional Notes

Key Improvements:

  1. Dynamic Contract Address:

    • Component now receives contractAddress as prop from deployment configuration
    • No hardcoded addresses in the component logic
    • Validation compares against expected address but works with any valid address
    • Clear error messages when address mismatches occur
  2. English Translation:

    • Randomness.cairo: All code comments translated to English
    • RandomnessComponent.tsx: Complete UI translation including:
      • Error messages and notifications
      • Form labels and placeholders
      • Status messages and diagnostics
      • Button labels and actions
      • Technical information and help text
  3. Files Modified:

    • packages/nextjs/app/debug/_components/contract/RandomnessComponent.tsx - Dynamic address handling + English translation
    • packages/snfoundry/contracts/src/Randomness.cairo - Comment translation to English
    • packages/nextjs/contracts/deployedContracts.ts - Updated deployment configurations
    • packages/snfoundry/.tool-versions - Updated tool versions
    • packages/snfoundry/contracts/.tool-versions - Updated Cairo/Scarb versions
    • packages/snfoundry/contracts/Scarb.lock - Updated dependencies

Contract Address Flow:

// The component receives the address dynamically:
<RandomnessComponent 
  contractName="Randomness"
  contractAddress={deployedContractAddress} // From deployment config
  onSuccess={handleSuccess}
/>

// Uses deployed address from configuration, not hardcoded values

Target Network:

  • Network: Devnet/Testnet (configurable)
  • Environment: Development/Testing
  • Address Source: Deployment configuration (dynamic)

…essages, and enhance user notifications for better clarity
Copy link
Copy Markdown
Contributor

@kimcascante kimcascante left a comment

Choose a reason for hiding this comment

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

LGTM

@davidmelendez davidmelendez merged commit 60b6df5 into FutureMindsTeam:main Oct 9, 2025
2 checks passed
@davidmelendez davidmelendez deleted the fix/dinamic-contractadress branch October 9, 2025 22:52
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.

3 participants