Skip to content

fix: support mainnet contract addresses in contracts.config.ts - #348

Open
Seermad1 wants to merge 6 commits into
OdyxeeeLabs:mainfrom
Seermad1:fix/issue-235-fe-028-contracts-config-ts-does-not-support
Open

fix: support mainnet contract addresses in contracts.config.ts#348
Seermad1 wants to merge 6 commits into
OdyxeeeLabs:mainfrom
Seermad1:fix/issue-235-fe-028-contracts-config-ts-does-not-support

Conversation

@Seermad1

Copy link
Copy Markdown

Overview

This PR adds a network-aware contract configuration system that defines contract addresses for testnet and mainnet, selects the correct config based on the wallet's connected network, and validates that the selected network matches the connected wallet's network before any contract interaction.

Related Issue

Closes FE-028

Changes

🌐 Network-Aware Contract Configuration

  • [MODIFY] Perigee/web/lib/contracts.config.ts

    • Defines typed contract address maps for testnet and mainnet.
    • Exports getContractConfig(network) to resolve the correct config from the wallet's connected network.
    • Adds validateNetwork(configNetwork, walletNetwork) helper for mismatch detection.
  • [MODIFY] Perigee/web/context/WalletContext.tsx

    • Reads the connected wallet's network passphrase and exposes it to consumers.
    • Resolves the matching contract config and provides it via context.
    • Tracks networkMismatch state when the selected config doesn't match the wallet network.
  • [MODIFY] Perigee/web/components/ContractInteraction.tsx

    • Uses the resolved contract config for all contract calls.
    • Displays a warning banner and disables interactions on network mismatch.
  • [MODIFY] Perigee/web/pages/index.tsx

    • Passes contractConfig and network validation state down to child components.
  • [MODIFY] Perigee/web/components/ConnectButton.tsx

    • Displays the connected network (testnet/mainnet) and warns when the active config targets a different network.

Verification Results

npm run lint && npm run build
✅ 0 lint errors, build passes

Manual acceptance check:
✅ Testnet and mainnet contract addresses defined
✅ Config auto-selects based on connected wallet network
✅ Network mismatch shows warning and blocks interaction
Acceptance Criteria Status
Define contract addresses per network (testnet/mainnet) in contracts.config.ts ✅ Both networks fully defined with all deployed contract addresses
Select the correct config based on the wallet's connected network ✅ Resolver reads wallet network and returns matching config
Validate that the selected network matches the connected wallet's network ✅ Mismatch shows warning and prevents contract interaction

Closes #235

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.

FE-028: contracts.config.ts does not support mainnet contract addresses

1 participant