Skip to content

Conversation

@atticusofsparta
Copy link
Contributor

@atticusofsparta atticusofsparta commented Jun 26, 2025

Summary by CodeRabbit

  • New Features

    • Added support for configuring and managing a "Hyperbeam URL" network setting within the application, including UI for viewing, updating, and resetting this value.
    • Application settings, including the Hyperbeam URL, are now automatically synchronized with local storage and loaded on startup.
  • Enhancements

    • Hyperbeam URL is now consistently used across domain management, transaction review, registration, and transaction workflows.
    • Improved state management and update flows to ensure the Hyperbeam URL is propagated to all relevant features and actions.
    • Simplified network settings update logic and enhanced validation for the Hyperbeam URL input.
  • Bug Fixes

    • No user-facing bug fixes included in this release.

@atticusofsparta atticusofsparta requested a review from a team as a code owner June 26, 2025 18:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

Walkthrough

This change introduces a globally managed, user-configurable "Hyperbeam URL" network setting. It propagates the hyperbeamUrl value throughout the application's global state, hooks, actions, and UI components, ensures its persistence with localStorage synchronization, and enables dynamic updates and usage across all relevant network interactions and workflows.

Changes

File(s) Change Summary
src/hooks/useSyncSettings/useSyncSettings.tsx, src/hooks/index.ts Added useSyncSettings hook to sync settings (including hyperbeamUrl) with localStorage; exported it.
src/App.tsx Invoked useSyncSettings in the root component.
src/state/contexts/GlobalState.tsx Loads settings (including hyperbeamUrl) from localStorage at startup; updates initial state logic.
src/state/reducers/GlobalReducer.ts Added reducer action to set hyperbeamUrl.
src/components/devtools/NetworkSettings.tsx, src/components/pages/Settings/NetworkSettings.tsx Added UI and logic to view, edit, and reset the hyperbeamUrl network setting; updated state dispatch and validation.
src/components/pages/Register/Checkout.tsx, src/components/pages/Transaction/TransactionReview.tsx Propagated hyperbeamUrl from global state to interaction/update dispatches.
src/components/data-display/tables/DomainsTable.tsx, src/components/layout/Breadcrumbs/Breadcrumbs.tsx, src/components/pages/Manage/Manage.tsx Passed hyperbeamUrl to domain info queries and update actions.
src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx, src/components/modals/ant-management/ReassignNameModal/ReassignNameModal.tsx, src/components/modals/ant-management/ReturnNameModal/ReturnNameModal.tsx, src/components/modals/ant-management/UpgradeDomainModal/UpgradeDomainModal.tsx, src/components/modals/ant-management/UpgradeDomainsModal/UpgradeDomainsModal.tsx Included hyperbeamUrl in update/interaction calls and queries.
src/hooks/useDomainInfo.tsx Added hyperbeamUrl parameter to domain info query functions and hooks.
src/state/actions/dispatchArIOInteraction.ts, src/state/actions/dispatchANTUpdate.ts, src/state/actions/dispatchArNSUpdate.ts Updated function signatures and logic to accept and use hyperbeamUrl.
src/state/actions/dispatchANTInteraction.ts Passed hyperbeamUrl to domain info queries during ANT upgrade.
src/state/contexts/ArNSState.tsx, src/state/contexts/TransactionState.tsx Propagated hyperbeamUrl to update/interaction dispatches in state providers.
src/components/inputs/text/NameTokenSelector/NameTokenSelector.tsx Removed obsolete commented-out code.
src/hooks/useTurboArNSClient.tsx Modified AO client connection config to include explicit mode parameter.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant GlobalState
    participant LocalStorage
    participant NetworkSettings
    participant Actions

    User->>NetworkSettings: Edits Hyperbeam URL
    NetworkSettings->>GlobalState: Dispatch setHyperbeamUrl
    GlobalState->>App: Updates global state
    App->>useSyncSettings: Triggers on state change
    useSyncSettings->>LocalStorage: Save updated settings (including hyperbeamUrl)
    User->>App: Triggers network action (e.g., domain update)
    App->>Actions: Calls action with hyperbeamUrl from state
    Actions->>Network: Uses hyperbeamUrl in request
Loading

Estimated code review effort

4 (~90 minutes)

Possibly related PRs

Suggested reviewers

  • dtfiedler
  • kunstmusik

Poem

A rabbit hopped through fields of code,
Syncing settings as it strode.
Hyperbeam URLs now in tow,
Across the app, their values flow.
With localStorage safe and bright,
Network settings set just right—
The warren’s code runs day and night! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/components/pages/Register/Register.tsx (1)

130-132: LGTM: Consistent Hyperbeam URL configuration pattern.

The conditional logic for setting hyperbeamUrl is identical to the pattern used in EditUndernameModal.tsx, ensuring consistency across ANT contract initializations. The defensive approach of using undefined when Hyperbeam is disabled is appropriate.

This follows the same pattern as noted in EditUndernameModal.tsx - consider the utility function suggestion for reducing code duplication across multiple files.

🧹 Nitpick comments (3)
src/components/modals/ant-management/EditUndernameModal/EditUndernameModal.tsx (1)

53-55: LGTM: Proper conditional Hyperbeam URL configuration.

The conditional logic correctly sets the hyperbeamUrl parameter based on the Hyperbeam configuration flags. The defensive approach of setting undefined when Hyperbeam is disabled is appropriate.

Consider extracting the conditional Hyperbeam URL logic into a utility function since this pattern is repeated across multiple files:

// utils/network.ts
export const getHyperbeamUrl = (aoNetwork: AoNetwork): string | undefined => {
  return aoNetwork.HYPERBEAM.ENABLED ? aoNetwork.HYPERBEAM.URL : undefined;
};

This would improve maintainability and reduce code duplication.

src/hooks/useSyncSettings/useSyncSettings.tsx (2)

74-74: Remove console.log statement from production code.

Console logging should be removed from production code to avoid cluttering browser logs and potential information leakage.

-      console.log('Settings saved to localStorage:', walletKey, settings);

78-78: Consider memoizing complex dependencies to prevent unnecessary re-renders.

The aoNetwork and turboNetwork objects in the dependency array could cause unnecessary effect executions if they're recreated on each render. Consider using useMemo or useCallback to stabilize these references.

+  const memoizedSettings = useMemo(() => ({
+    gateway,
+    aoNetwork,
+    turboNetwork,
+    arioProcessId,
+  }), [gateway, aoNetwork, turboNetwork, arioProcessId]);
+
   useEffect(() => {
     if (!walletAddress) {
       return;
     }
-  }, [walletAddress, gateway, aoNetwork, turboNetwork, arioProcessId]);
+  }, [walletAddress, memoizedSettings]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9291cec and aaa866e.

📒 Files selected for processing (23)
  • src/App.tsx (2 hunks)
  • src/components/data-display/tables/UndernamesSubtable.tsx (2 hunks)
  • src/components/data-display/tables/UndernamesTable.tsx (2 hunks)
  • src/components/devtools/NetworkSettings.tsx (6 hunks)
  • src/components/forms/DomainSettings/DomainSettings.tsx (10 hunks)
  • src/components/inputs/text/NameTokenSelector/NameTokenSelector.tsx (3 hunks)
  • src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx (2 hunks)
  • src/components/modals/ant-management/EditUndernameModal/EditUndernameModal.tsx (2 hunks)
  • src/components/modals/ant-management/ReassignNameModal/ReassignNameModal.tsx (1 hunks)
  • src/components/modals/ant-management/ReturnNameModal/ReturnNameModal.tsx (1 hunks)
  • src/components/modals/ant-management/UpgradeDomainModal/UpgradeDomainModal.tsx (1 hunks)
  • src/components/modals/ant-management/UpgradeDomainsModal/UpgradeDomainsModal.tsx (1 hunks)
  • src/components/pages/Register/Checkout.tsx (1 hunks)
  • src/components/pages/Register/Register.tsx (2 hunks)
  • src/components/pages/Transaction/TransactionReview.tsx (1 hunks)
  • src/hooks/index.ts (1 hunks)
  • src/hooks/useDomainInfo.tsx (2 hunks)
  • src/hooks/useSyncSettings/useSyncSettings.tsx (1 hunks)
  • src/state/actions/dispatchANTInteraction.ts (4 hunks)
  • src/state/actions/dispatchArIOInteraction.ts (4 hunks)
  • src/state/contexts/GlobalState.tsx (2 hunks)
  • src/utils/constants.ts (1 hunks)
  • src/utils/network.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (12)
src/components/data-display/tables/UndernamesTable.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/components/data-display/tables/UndernamesSubtable.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/components/inputs/text/NameTokenSelector/NameTokenSelector.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/components/pages/Register/Register.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/hooks/useDomainInfo.tsx (1)
src/utils/network.ts (1)
  • buildAntStateQuery (49-78)
src/state/actions/dispatchANTInteraction.ts (1)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-162)
src/components/devtools/NetworkSettings.tsx (2)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-162)
src/utils/searchUtils/searchUtils.ts (1)
  • isValidURL (196-198)
src/hooks/useSyncSettings/useSyncSettings.tsx (2)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/state/contexts/WalletState.tsx (1)
  • useWalletState (49-50)
src/components/modals/ant-management/EditUndernameModal/EditUndernameModal.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/utils/network.ts (1)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-162)
src/components/forms/DomainSettings/DomainSettings.tsx (1)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (130-131)
src/state/actions/dispatchArIOInteraction.ts (1)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-162)
🔇 Additional comments (32)
src/utils/constants.ts (1)

129-132: LGTM! Well-structured network configuration addition.

The new HYPERBEAM configuration follows the existing pattern in NETWORK_DEFAULTS and uses conservative defaults with ENABLED: false. The URL appears valid and the structure integrates cleanly with the existing network configurations.

src/components/modals/ant-management/ReturnNameModal/ReturnNameModal.tsx (1)

63-63: Consistent parameter propagation.

The addition of aoNetwork to the dispatchANTInteraction call properly propagates the network configuration from global state, maintaining consistency with the broader update pattern across the application.

src/components/data-display/tables/UndernamesTable.tsx (2)

102-102: Proper global state destructuring update.

Adding aoNetwork to the destructured global state variables follows the consistent pattern for accessing network configuration.


156-156: Consistent parameter addition to ANT interaction.

The aoNetwork parameter is properly passed to dispatchANTInteraction, maintaining consistency with the network configuration propagation pattern across the application.

src/components/modals/ant-management/ReassignNameModal/ReassignNameModal.tsx (1)

139-139: Completes the network configuration propagation.

Adding aoNetwork to the dispatchANTInteraction call properly utilizes the network configuration that was already being destructured from global state, maintaining consistency with the application-wide pattern.

src/components/modals/ant-management/UpgradeDomainsModal/UpgradeDomainsModal.tsx (1)

138-138: Systematic network configuration integration.

The addition of aoNetwork to the dispatchANTInteraction call follows the consistent pattern established across all ANT interaction components, ensuring the Hyperbeam network configuration is properly propagated throughout the upgrade workflow.

src/hooks/index.ts (1)

5-5: LGTM! Export follows established pattern.

The addition of the useSyncSettings export is consistent with the existing hook export pattern in this index file.

src/components/modals/ant-management/UpgradeDomainModal/UpgradeDomainModal.tsx (1)

108-108: LGTM! Network configuration properly propagated.

The addition of aoNetwork parameter to dispatchANTInteraction is consistent with the broader pattern of enabling dynamic network configuration for ANT operations.

src/App.tsx (2)

21-21: LGTM! Proper import of settings synchronization hook.

The import follows the established pattern and correctly references the new useSyncSettings hook.


75-75: LGTM! Appropriate placement for settings synchronization.

Invoking useSyncSettings at the App component level alongside useWanderEvents ensures settings are synchronized with localStorage throughout the application lifecycle.

src/components/data-display/tables/UndernamesSubtable.tsx (2)

59-59: LGTM! Proper state destructuring for network configuration.

Adding aoNetwork to the destructured global state is consistent with the pattern of enabling dynamic network configuration throughout the application.


298-298: LGTM! Network configuration properly passed to ANT interaction.

The addition of aoNetwork parameter to dispatchANTInteraction maintains consistency with the broader pattern of propagating network configuration to ANT operations.

src/components/pages/Transaction/TransactionReview.tsx (1)

128-128: LGTM! Network configuration properly integrated for ArIO interactions.

The addition of aoNetwork parameter to dispatchArIOInteraction extends the dynamic network configuration pattern to ArIO operations, maintaining consistency across the application.

src/components/pages/Register/Checkout.tsx (2)

42-42: LGTM: Proper integration of aoNetwork from global state.

The addition of aoNetwork to the destructured variables from useGlobalState() is consistent with the broader pattern across the codebase for integrating Hyperbeam network configuration.


326-326: LGTM: Consistent propagation of network configuration.

The addition of aoNetwork parameter to the dispatchArIOInteraction call ensures that the Hyperbeam network settings are properly propagated through ARIO interactions, aligning with the PR's objective to support dynamic network configurations.

src/components/modals/ant-management/EditUndernameModal/EditUndernameModal.tsx (1)

35-35: LGTM: Consistent global state integration.

The addition of aoNetwork to the destructured variables from useGlobalState() maintains consistency with the network configuration integration pattern used throughout the application.

src/components/pages/Register/Register.tsx (1)

48-50: LGTM: Consistent global state integration.

The addition of aoNetwork to the destructured variables maintains the consistent pattern of network configuration integration across the application.

src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx (2)

185-185: LGTM: Proper network configuration propagation for ArIO interactions.

The addition of aoNetwork parameter to the dispatchArIOInteraction call ensures that Hyperbeam network settings are properly propagated through primary name request/change workflows.


203-203: LGTM: Consistent network configuration for ANT interactions.

The addition of aoNetwork parameter to the dispatchANTInteraction call maintains consistency with the network configuration propagation pattern and ensures Hyperbeam settings are available for ANT-based primary name removal workflows.

src/components/forms/DomainSettings/DomainSettings.tsx (2)

81-81: LGTM: Consistent global state integration.

The addition of aoNetwork to the destructured variables from useGlobalState() maintains the consistent pattern used throughout the application for network configuration integration.


301-301: LGTM: Comprehensive network configuration propagation across all domain operations.

The systematic addition of aoNetwork parameter to all dispatchANTInteraction calls ensures that Hyperbeam network settings are properly propagated through every domain setting operation (nickname, target ID, ticker, controllers, owner, TTL, logo, description, keywords). This comprehensive coverage is essential for the Hyperbeam feature to work consistently across all ANT interactions in the domain settings interface.

Also applies to: 365-365, 385-385, 414-414, 441-441, 464-464, 497-497, 519-519, 541-541

src/hooks/useDomainInfo.tsx (2)

102-111: LGTM: Correct Hyperbeam integration for ANT initialization.

The conditional hyperbeamUrl logic is properly implemented, checking the enabled flag before setting the URL. This follows the established pattern across the codebase.


114-114: Good: Passing aoNetwork to buildAntStateQuery ensures consistency.

The aoNetwork parameter is correctly passed to ensure the ANT state query uses the same network configuration.

src/state/actions/dispatchArIOInteraction.ts (1)

230-239: LGTM: Consistent Hyperbeam integration in ANT initialization.

The conditional hyperbeamUrl logic is correctly implemented within the PRIMARY_NAME_REQUEST workflow, maintaining consistency with the broader Hyperbeam integration pattern.

src/components/inputs/text/NameTokenSelector/NameTokenSelector.tsx (1)

116-124: LGTM: Consistent Hyperbeam integration across ANT initializations.

Both ANT initialization calls have been correctly updated with the conditional hyperbeamUrl logic, maintaining consistency with the broader codebase integration.

Also applies to: 166-174

src/state/actions/dispatchANTInteraction.ts (1)

64-70: LGTM: Comprehensive Hyperbeam integration in ANT workflows.

Both the main ANT initialization and the upgrade workflow's ANT validation have been correctly updated with conditional hyperbeamUrl logic, ensuring consistent network configuration throughout all ANT interactions.

Also applies to: 241-250

src/utils/network.ts (1)

49-78: ```shell
#!/bin/bash

Inspect the call in useDomainInfo.tsx to confirm aoNetwork is passed

rg -C 3 "fetchQuery(buildAntStateQuery" src/hooks/useDomainInfo.tsx

Inspect the call in useANT.tsx to confirm aoNetwork is passed

rg -C 3 "buildAntStateQuery" src/hooks/useANT/useANT.tsx


</details>
<details>
<summary>src/components/devtools/NetworkSettings.tsx (4)</summary>

`61-118`: **LGTM! Consistent state management pattern.**

The Hyperbeam state variables are properly initialized and synchronized with global state, following the same pattern as other network settings in the component.

---

`222-238`: **LGTM! Well-structured configuration update function.**

The `updateHyperbeamAoNetwork` function correctly merges the new Hyperbeam configuration with existing settings and follows the established error handling pattern.

---

`90-97`: **LGTM! Consistent reset functionality.**

The Hyperbeam reset logic follows the same pattern as other network settings and correctly uses the default values from NETWORK_DEFAULTS.

---

`609-687`: **LGTM! Comprehensive and intuitive UI for Hyperbeam management.**

The UI implementation provides clear visibility of current settings and intuitive controls for both the URL and enabled state. The validation and state update logic are correctly implemented following the established patterns.

</details>
<details>
<summary>src/state/contexts/GlobalState.tsx (1)</summary>

`77-124`: **LGTM! Clean integration of dynamic settings loading.**

The initialization logic properly integrates the loaded settings while maintaining backward compatibility and type safety. The fallback to defaults ensures the application works correctly even when no settings are saved.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines 31 to 73
function loadSettingsFromStorage(): {
gateway: string;
aoNetwork: typeof NETWORK_DEFAULTS.AO;
turboNetwork: typeof NETWORK_DEFAULTS.TURBO;
arioProcessId: string;
} | null {
try {
// Try to get the last used wallet address from localStorage
const walletType = localStorage.getItem('walletType');

// Try multiple storage keys to find saved settings
const possibleKeys = [
walletType ? `${SETTINGS_STORAGE_KEY}_${walletType}` : null,
`${SETTINGS_STORAGE_KEY}_default`,
`${SETTINGS_STORAGE_KEY}_last`,
].filter(Boolean);

for (const storageKey of possibleKeys) {
const savedSettings = localStorage.getItem(storageKey!);

if (savedSettings) {
const settings = JSON.parse(savedSettings);
console.log(
'Loading settings from localStorage:',
storageKey,
settings,
);

return {
gateway: settings.network?.gateway || ARWEAVE_HOST,
aoNetwork: settings.network?.aoNetwork || NETWORK_DEFAULTS.AO,
turboNetwork:
settings.network?.turboNetwork || NETWORK_DEFAULTS.TURBO,
arioProcessId: settings.arns?.arioProcessId || ARIO_PROCESS_ID,
};
}
}
} catch (error) {
console.error('Failed to load settings from localStorage:', error);
}

return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding JSON validation for security and robustness.

The function implements good practices with multiple storage keys, error handling, and fallbacks. However, consider adding validation of the parsed JSON structure to prevent potential issues with corrupted or malicious data.

  for (const storageKey of possibleKeys) {
    const savedSettings = localStorage.getItem(storageKey!);

    if (savedSettings) {
      const settings = JSON.parse(savedSettings);
+     
+     // Validate the structure of loaded settings
+     if (!settings || typeof settings !== 'object') {
+       console.warn('Invalid settings structure in localStorage:', storageKey);
+       continue;
+     }
+     
      console.log(
        'Loading settings from localStorage:',
        storageKey,
        settings,
      );

Also consider removing or reducing the console.log for production builds to avoid log pollution.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function loadSettingsFromStorage(): {
gateway: string;
aoNetwork: typeof NETWORK_DEFAULTS.AO;
turboNetwork: typeof NETWORK_DEFAULTS.TURBO;
arioProcessId: string;
} | null {
try {
// Try to get the last used wallet address from localStorage
const walletType = localStorage.getItem('walletType');
// Try multiple storage keys to find saved settings
const possibleKeys = [
walletType ? `${SETTINGS_STORAGE_KEY}_${walletType}` : null,
`${SETTINGS_STORAGE_KEY}_default`,
`${SETTINGS_STORAGE_KEY}_last`,
].filter(Boolean);
for (const storageKey of possibleKeys) {
const savedSettings = localStorage.getItem(storageKey!);
if (savedSettings) {
const settings = JSON.parse(savedSettings);
console.log(
'Loading settings from localStorage:',
storageKey,
settings,
);
return {
gateway: settings.network?.gateway || ARWEAVE_HOST,
aoNetwork: settings.network?.aoNetwork || NETWORK_DEFAULTS.AO,
turboNetwork:
settings.network?.turboNetwork || NETWORK_DEFAULTS.TURBO,
arioProcessId: settings.arns?.arioProcessId || ARIO_PROCESS_ID,
};
}
}
} catch (error) {
console.error('Failed to load settings from localStorage:', error);
}
return null;
}
for (const storageKey of possibleKeys) {
const savedSettings = localStorage.getItem(storageKey!);
if (savedSettings) {
const settings = JSON.parse(savedSettings);
// Validate the structure of loaded settings
if (!settings || typeof settings !== 'object') {
console.warn('Invalid settings structure in localStorage:', storageKey);
continue;
}
console.log(
'Loading settings from localStorage:',
storageKey,
settings,
);
return {
gateway: settings.network?.gateway || ARWEAVE_HOST,
aoNetwork: settings.network?.aoNetwork || NETWORK_DEFAULTS.AO,
turboNetwork:
settings.network?.turboNetwork || NETWORK_DEFAULTS.TURBO,
arioProcessId: settings.arns?.arioProcessId || ARIO_PROCESS_ID,
};
}
}
🤖 Prompt for AI Agents
In src/state/contexts/GlobalState.tsx around lines 31 to 73, the function
loadSettingsFromStorage parses JSON from localStorage without validating its
structure, which can lead to issues if the data is corrupted or malicious. Add
explicit validation checks after parsing to ensure the expected properties and
types exist before using them. Also, remove or conditionally disable the
console.log statement for production builds to prevent log pollution.

@github-actions
Copy link

github-actions bot commented Jun 26, 2025

Visit the preview URL for this PR (updated for commit 7aecf55):

https://arns-portal--pr799-pe-8241-hyperbeam-se-tsfeuf32.web.app

(expires Wed, 06 Aug 2025 16:46:02 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 1f59769442cb89cf2a92042a342e51fe94047b94

const walletKey = `${SETTINGS_STORAGE_KEY}_${walletAddress}`;

// Also save to a "last" key for persistence across wallet switches
const lastKey = `${SETTINGS_STORAGE_KEY}_last`;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need both? The single key for the wallet address should be sufficient

Comment on lines 103 to 105
hyperbeamUrl: aoNetwork.HYPERBEAM.ENABLED
? aoNetwork.HYPERBEAM.URL
: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need both parameters. Use just the hyphem urls existence to mean it's enabled

useEffect(() => {
setNewHyperbeamUrl(aoNetwork.HYPERBEAM.URL);
setValidHyperbeamUrl(true);
setHyperbeamEnabled(aoNetwork.HYPERBEAM.ENABLED);
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment about only using the presence of a hyperbeam URL on whether or not hyperbeam should be used

@atticusofsparta atticusofsparta force-pushed the PE-8241-hyperbeam-setting branch from afe0c90 to 3e8cea3 Compare July 14, 2025 20:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 345a7ec and 3e8cea3.

📒 Files selected for processing (8)
  • src/components/devtools/NetworkSettings.tsx (5 hunks)
  • src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx (1 hunks)
  • src/components/pages/Register/Checkout.tsx (2 hunks)
  • src/components/pages/Transaction/TransactionReview.tsx (2 hunks)
  • src/hooks/useSyncSettings/useSyncSettings.tsx (1 hunks)
  • src/state/actions/dispatchArIOInteraction.ts (4 hunks)
  • src/state/contexts/GlobalState.tsx (2 hunks)
  • src/state/reducers/GlobalReducer.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/components/pages/Transaction/TransactionReview.tsx
  • src/components/devtools/NetworkSettings.tsx
  • src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx
  • src/components/pages/Register/Checkout.tsx
  • src/hooks/useSyncSettings/useSyncSettings.tsx
  • src/state/contexts/GlobalState.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/state/actions/dispatchArIOInteraction.ts (1)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-159)
🪛 ESLint
src/state/actions/dispatchArIOInteraction.ts

[error] 39-39: 'aoNetwork' is defined but never used.

(@typescript-eslint/no-unused-vars)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build_and_test / lint_test_build
  • GitHub Check: lint_test_build
🔇 Additional comments (3)
src/state/reducers/GlobalReducer.ts (2)

47-50: LGTM! Action type definition follows established patterns.

The new setHyperbeamUrl action type is properly defined with appropriate typing, maintaining consistency with existing action types in the union.


110-114: LGTM! Reducer implementation correctly handles the new action.

The reducer case properly handles the setHyperbeamUrl action by spreading the existing state and updating the hyperbeamUrl property, following Redux best practices.

src/state/actions/dispatchArIOInteraction.ts (1)

233-233: LGTM! Correct usage of hyperbeamUrl in ANT initialization.

The hyperbeamUrl parameter is properly passed to ANT.init, enabling the hyperbeam URL configuration for the ANT process during primary name requests.

@dtfiedler
Copy link
Contributor

Please add HyperBEAM URL to the standard settings page, and make a ticket to consolidate dev settings into the settings panel so we do not have both.

return;
}

// Skip saving on initial load when hyperbeamUrl is undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain why we should skip only if hyperbeam is undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was during iteration, where I wasn't directly defaulting the settings in GlobalState and attempting to do it from the hook instead. Its now unnecessary and removed ca26d18

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(as for why it was there, there was an issue with overwriting the hyperbeam setting that was saved because the initial setting is undefined in the state where as you may have saved a setting to local storage, so it got overwritten before it could be saved, which was a bandaid solution and prompted the change to synchronously load the settings in the global state to avoid the problem completely)

Comment on lines 53 to 57
const possibleKeys = [
walletType ? `${SETTINGS_STORAGE_KEY}_${walletType}` : null,
`${SETTINGS_STORAGE_KEY}_default`,
`${SETTINGS_STORAGE_KEY}_last`,
].filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should only store one key and only use the latest settings. defaults can be held as a constant within the app and do not need to be saved to local storage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

these were not removed/updated in the commit you provideed

Copy link
Contributor

@dtfiedler dtfiedler left a comment

Choose a reason for hiding this comment

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

review comments

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b87c1c6 and ca26d18.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • src/components/pages/Settings/NetworkSettings.tsx (7 hunks)
  • src/hooks/useSyncSettings/useSyncSettings.tsx (1 hunks)
  • src/hooks/useTurboArNSClient.tsx (1 hunks)
  • src/state/contexts/GlobalState.tsx (3 hunks)
🧬 Code Graph Analysis (1)
src/components/pages/Settings/NetworkSettings.tsx (4)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (151-152)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-161)
src/state/actions/dispatchNewGateway.ts (1)
  • dispatchNewGateway (10-41)
src/utils/searchUtils/searchUtils.ts (1)
  • isValidURL (196-198)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/hooks/useSyncSettings/useSyncSettings.tsx
  • src/state/contexts/GlobalState.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/pages/Settings/NetworkSettings.tsx (4)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (151-152)
src/utils/constants.ts (1)
  • NETWORK_DEFAULTS (127-161)
src/state/actions/dispatchNewGateway.ts (1)
  • dispatchNewGateway (10-41)
src/utils/searchUtils/searchUtils.ts (1)
  • isValidURL (196-198)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-to-firebase
🔇 Additional comments (7)
src/hooks/useTurboArNSClient.tsx (1)

18-22: LGTM! Explicit configuration improves clarity.

The change from passing the entire aoNetwork.ARIO object to explicitly specifying individual properties (CU_URL, MU_URL, MODE) makes the configuration more explicit and clear. The hardcoded MODE: 'legacy' appears intentional for this Turbo client connection.

This aligns well with the broader network configuration refactoring mentioned in the PR objectives.

src/components/pages/Settings/NetworkSettings.tsx (6)

27-36: LGTM! Proper state destructuring for new feature.

The addition of hyperbeamUrl to the destructured global state follows the established pattern and is consistent with the PR objectives to add Hyperbeam URL configuration support.


50-53: LGTM! Proper state initialization with fallback.

The new state variables for Hyperbeam URL are correctly initialized with proper fallback handling (hyperbeamUrl || '') and follow the established pattern used by other URL inputs in the component.


95-98: LGTM! Proper useEffect for state synchronization.

The useEffect hook correctly synchronizes local Hyperbeam URL state with global state changes, following the same pattern used for other network settings in the component.


429-488: LGTM! Comprehensive Hyperbeam URL configuration UI.

The new Hyperbeam URL section follows the established UI patterns perfectly:

  • Consistent styling with other input sections
  • Proper validation using isValidURL
  • Clear visual feedback for disabled state
  • Standard set/reset button functionality
  • Proper event handling for input, clear, and enter actions

The implementation is well-structured and maintains consistency with the existing codebase patterns.


147-148: Verified ARIO Nesting Change

All existing code references to aoNetwork.ARIO.* have been located and none rely on a different shape. Nesting the new config properties and GATEWAY_URL under the ARIO key maintains the expected structure for every consumer.


127-128: Gateway update without wallet check is safe

I’ve verified that dispatchNewGateway doesn’t reference the wallet—it only initializes Arweave with the provided gateway and updates the block height and provider in global state. Removing the if (wallet) guard here won’t introduce errors when no wallet is connected.

._dist Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

@atticusofsparta - remove this file

setValidTurboPaymentUrl(true);
updateTurboNetwork(NETWORK_DEFAULTS.TURBO);
// hyperbeam network
setNewHyperbeamUrl(NETWORK_DEFAULTS.AO.ARIO.HYPERBEAM_URL || '');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting seems off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope thats how prettier wants it.

Comment on lines 53 to 57
const possibleKeys = [
walletType ? `${SETTINGS_STORAGE_KEY}_${walletType}` : null,
`${SETTINGS_STORAGE_KEY}_default`,
`${SETTINGS_STORAGE_KEY}_last`,
].filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

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

these were not removed/updated in the commit you provideed

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/hooks/useSyncSettings/useSyncSettings.tsx (3)

6-31: Well-structured interfaces with good TypeScript typing.

The interfaces provide clear contracts for the settings structure. However, I notice hyperbeamUrl appears both at the top level (line 8) and within the aoNetwork sub-objects as HYPERBEAM_URL (lines 14, 21). Consider documenting the distinction between these or consolidating if they serve the same purpose.


46-54: The isInitialLoad ref is unused.

The ref is created and updated but not used in any conditional logic. Based on past review comments, this appears to be intentional after removing skipping logic. Consider removing this unused ref to clean up the code.

-  const isInitialLoad = useRef(true);
-    isInitialLoad.current = false;

68-77: Consider reducing console verbosity for production.

The success console.log (lines 70-74) might be too verbose for production environments. Consider using a more targeted logging approach or removing success logs entirely.

-      console.log(
-        'Settings saved to localStorage:',
-        SETTINGS_STORAGE_KEY,
-        settings,
-      );
+      // Settings saved successfully
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca26d18 and 7aecf55.

📒 Files selected for processing (4)
  • src/components/devtools/NetworkSettings.tsx (5 hunks)
  • src/components/pages/Settings/NetworkSettings.tsx (7 hunks)
  • src/hooks/useSyncSettings/useSyncSettings.tsx (1 hunks)
  • src/state/contexts/GlobalState.tsx (3 hunks)
🧬 Code Graph Analysis (1)
src/hooks/useSyncSettings/useSyncSettings.tsx (2)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (138-139)
src/state/contexts/WalletState.tsx (1)
  • useWalletState (49-50)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/components/devtools/NetworkSettings.tsx
  • src/state/contexts/GlobalState.tsx
  • src/components/pages/Settings/NetworkSettings.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/hooks/useSyncSettings/useSyncSettings.tsx (2)
src/state/contexts/GlobalState.tsx (1)
  • useGlobalState (138-139)
src/state/contexts/WalletState.tsx (1)
  • useWalletState (49-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build_and_test / lint_test_build
  • GitHub Check: lint_test_build
🔇 Additional comments (3)
src/hooks/useSyncSettings/useSyncSettings.tsx (3)

1-2: LGTM! Clean and appropriate imports.

The imports are well-organized and include only the necessary dependencies for the hook's functionality.


4-4: Good practice using a named constant for the storage key.

This prevents magic strings and makes the key reusable across the codebase.


90-90: LGTM! Standard hook export pattern.

The default export follows React hook conventions appropriately.

hyperbeamUrl?: string;
} | null {
try {
const savedSettings = localStorage.getItem(SETTINGS_STORAGE_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think tanstack query supports local storage requests, any thoughts on using that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand what benefit you are interested in here. Do you mean like using local storage for the react query cache, or using react query for interacting with local storage?

If it's the latter, I would say it's not beneficial, and even unnecessary, because local storage is a synchronous data provider, and being local, not remote, has no benefit of being cached or deduplicated in requests for cache keys.

If it's the former, IDB is the better solution because local storage is small.

Comment on lines +75 to +82
// Load saved settings or use defaults
const savedSettings = loadSettingsFromStorage();
const initialGateway = savedSettings?.gateway || ARWEAVE_HOST;
const initialAoNetwork = savedSettings?.aoNetwork || NETWORK_DEFAULTS.AO;
const initialTurboNetwork =
savedSettings?.turboNetwork || NETWORK_DEFAULTS.TURBO;
const initialArioProcessId = savedSettings?.arioProcessId || ARIO_PROCESS_ID;
const initialHyperbeamUrl = savedSettings?.hyperbeamUrl;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use URLs where it makes sense

Suggested change
// Load saved settings or use defaults
const savedSettings = loadSettingsFromStorage();
const initialGateway = savedSettings?.gateway || ARWEAVE_HOST;
const initialAoNetwork = savedSettings?.aoNetwork || NETWORK_DEFAULTS.AO;
const initialTurboNetwork =
savedSettings?.turboNetwork || NETWORK_DEFAULTS.TURBO;
const initialArioProcessId = savedSettings?.arioProcessId || ARIO_PROCESS_ID;
const initialHyperbeamUrl = savedSettings?.hyperbeamUrl;
const initialGateway = new URL(savedSettings?.gateway || ARWEAVE_HOST);
const initialAoNetwork = new URL(savedSettings?.aoNetwork || NETWORK_DEFAULTS.AO);
const initialTurboNetwork =
new URL(savedSettings?.turboNetwork || NETWORK_DEFAULTS.TURBO);
const initialArioProcessId = savedSettings?.arioProcessId || ARIO_PROCESS_ID;
const initialHyperbeamUrl = new URL(savedSettings?.hyperbeamUr)l;
// and then use `url.hostname` or `url.toString()` below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gonna wait on this... In my experience changing to url has had some unforseen side effects and we have some third party clients that are expecting strings.

Copy link
Contributor

Choose a reason for hiding this comment

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

...url.toString()

Copy link
Contributor

@dtfiedler dtfiedler left a comment

Choose a reason for hiding this comment

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

looks good - a few non-blocking questions

@atticusofsparta atticusofsparta merged commit c774dd8 into develop Jul 23, 2025
7 checks passed
@atticusofsparta atticusofsparta deleted the PE-8241-hyperbeam-setting branch July 23, 2025 17:14
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