Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏆 feat/trophy page #1987

Conversation

bal7hazar
Copy link
Contributor

@bal7hazar bal7hazar commented Nov 4, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced account management functionality with improved state handling.
    • Added a "Trophies" button in the navigation menu for quick access to profile features.
    • Introduced a new building thumbnail for "Trophy."
  • Improvements

    • Implemented device detection logic to optimize graphics settings based on battery status.
    • Updated package dependencies for better performance and stability.
  • Bug Fixes

    • Adjusted loading screen logic to accurately reflect connection status.

These updates improve user experience and enhance the overall functionality of the application.

Copy link

vercel bot commented Nov 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 5:16pm

Copy link
Contributor

mentatbot bot commented Nov 4, 2024

You are out of MentatBot reviews. Your usage will refresh November 11 at 08:00 AM.

Copy link

vercel bot commented Nov 4, 2024

@bal7hazar is attempting to deploy a commit to the Loot Bibliotheca Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The pull request includes updates to several files within the eternum-client project. Key changes involve version increments for two dependencies in package.json, enhancements to account management in DojoContext.tsx and accountStore.tsx, and the introduction of new constants in starknet-provider.tsx. Additionally, a new property for building thumbnails is added in config.tsx, and the SecondaryMenuItems.tsx component is updated to incorporate account-related features. These modifications collectively improve state management and user interface elements.

Changes

File Path Change Summary
client/package.json Updated @cartridge/connector and @cartridge/controller versions from ^0.5.0-alpha.4 to 0.5.0-alpha.7.
client/src/hooks/context/DojoContext.tsx Added import for ControllerConnector, updated useControllerAccount to handle connector, refined account management logic.
client/src/hooks/context/accountStore.tsx Updated AccountState interface to include connector and setConnector, initialized connector to null.
client/src/hooks/context/starknet-provider.tsx Added constants slot and namespace, included them in ControllerConnector instantiation.
client/src/ui/config.tsx Added trophy property to BuildingThumbs, defined checkIfGameIsRunningOnLaptop, exported IS_LOW_GRAPHICS_ENABLED and IS_MOBILE.
client/src/ui/modules/navigation/SecondaryMenuItems.tsx Added useAccountStore import, introduced CircleButton for "Trophies" to open profile.

Possibly related PRs

  • Enh/client config manager #1848: The changes in this PR involve updates to the ClientConfigManager, which may relate to the dependency updates in the main PR as they both involve managing configurations and dependencies within the project.
  • feat: optimize resourceChip #1976: This PR modifies the ResourceChip component, which may indirectly relate to the overall project structure and dependencies, particularly if the ResourceChip relies on the updated packages mentioned in the main PR.

Suggested reviewers

  • ponderingdemocritus

🐰 In the meadow, changes bloom,
With connectors and trophies, there's plenty of room.
The accounts now dance, with state in their hands,
While menus and thumbnails take their stands.
Hopping along, we celebrate this spree,
In the world of Eternum, oh so carefree! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@bal7hazar bal7hazar changed the base branch from main to next November 4, 2024 21:10
@ponderingdemocritus ponderingdemocritus marked this pull request as ready for review November 4, 2024 23:49
Copy link
Contributor

@ponderingdemocritus ponderingdemocritus left a comment

Choose a reason for hiding this comment

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

need to test in next branch live but looks good

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: 2

🧹 Outside diff range and nitpick comments (4)
client/src/hooks/context/accountStore.tsx (1)

1-1: LGTM! Consider adding JSDoc comments.

The addition of the ControllerConnector type and related interface properties is well-structured. The nullable type for the connector property is appropriate for state management.

Consider adding JSDoc comments to document the purpose of these new properties:

 interface AccountState {
   account: Account | AccountInterface | null;
   setAccount: (account: Account | AccountInterface) => void;
+  /** Controller connector instance for managing trophy-related functionality */
   connector: ControllerConnector | null;
+  /** Sets the controller connector instance */
   setConnector: (connector: ControllerConnector) => void;
 }

Also applies to: 8-9

client/src/hooks/context/starknet-provider.tsx (1)

9-10: Add documentation for configuration constants.

The purpose and significance of these configuration values should be documented. Consider moving these values to a centralized configuration file for easier maintenance and version control.

+// Unique identifier for the current version/release of the application
 const slot: string = "eternum-rc1-1";
+// Application namespace for controller connector isolation
 const namespace: string = "eternum";
client/src/ui/config.tsx (2)

Line range hint 5-23: Replace deprecated battery API with more reliable device detection.

The current implementation has several concerns:

  1. navigator.getBattery() is deprecated and not widely supported across browsers
  2. Battery charging state is not a reliable indicator for device type
  3. The function name suggests laptop detection but it's actually used for graphics settings

Consider using more reliable methods such as:

const checkDeviceCapabilities = () => {
  // Check GPU capabilities
  const canvas = document.createElement('canvas');
  const gl = canvas.getContext('webgl');
  if (!gl) return true; // Return true for low graphics if WebGL not supported
  
  const debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
  if (!debugInfo) return true;
  
  const renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
  
  // Check if integrated GPU (common in laptops) or mobile GPU
  const isLowPower = /(Intel|AMD|Mobile|Iris|HD Graphics)/i.test(renderer);
  
  localStorage.setItem("LOW_GRAPHICS_FLAG", isLowPower.toString());
  localStorage.setItem("INITIAL_LAPTOP_CHECK", "true");
  
  return isLowPower;
};

Line range hint 25-28: Improve device detection implementation.

  1. Awaiting at module level can block module initialization
  2. User Agent string detection is not recommended for device detection

Consider this alternative approach:

export const getDeviceCapabilities = () => {
  // Use feature detection instead of UA strings
  const isMobile = 'ontouchstart' in window || 
    navigator.maxTouchPoints > 0 || 
    matchMedia('(pointer:coarse)').matches;
    
  return {
    isMobile,
    isLowGraphics: checkDeviceCapabilities()
  };
};

// Then use it in your components
const { isMobile, isLowGraphics } = getDeviceCapabilities();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ae3465f and f6fd4c4.

⛔ Files ignored due to path filters (2)
  • client/public/images/buildings/thumb/trophy.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • client/package.json (1 hunks)
  • client/src/hooks/context/DojoContext.tsx (2 hunks)
  • client/src/hooks/context/accountStore.tsx (1 hunks)
  • client/src/hooks/context/starknet-provider.tsx (1 hunks)
  • client/src/ui/config.tsx (1 hunks)
  • client/src/ui/modules/navigation/SecondaryMenuItems.tsx (3 hunks)
🔇 Additional comments (8)
client/src/hooks/context/accountStore.tsx (1)

15-16: Verify connector cleanup on account changes.

The implementation looks good, but we should ensure the connector is properly cleaned up when the account changes to prevent memory leaks or stale connections.

Let's verify if there's any cleanup logic elsewhere in the codebase:

✅ Verification successful

Connector cleanup is properly handled through Starknet React hooks

The connector cleanup is handled automatically through the Starknet React hooks integration:

  1. The connector state in accountStore is managed through useAccount hook in DojoContext.tsx:
const { account: controllerAccount, connector, isConnected } = useAccount();
useEffect(() => {
  if (connector) {
    useAccountStore.getState().setConnector(connector as ControllerConnector);
  }
}, [controllerAccount, isConnected, connector]);
  1. The useAccount hook from @starknet-react/core handles the lifecycle of the connector, including cleanup when the account changes or disconnects. The StarknetConfig provider in the app properly configures this behavior.

No additional cleanup is needed in the accountStore as the connector state is managed by the framework's hooks.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for connector cleanup logic in account-related files
rg -l 'setConnector.*null|cleanup.*connector' --type tsx --type ts

# Search for useEffect hooks that might handle connector cleanup
ast-grep --pattern 'useEffect(() => {
  $$$
  setConnector($$$)
  $$$
})'

Length of output: 172


Script:

#!/bin/bash
# Search for connector cleanup logic in account-related files with correct file extensions
rg -l 'setConnector.*null|cleanup.*connector' -g '*.tsx' -g '*.ts'

# Search for useEffect hooks that might handle connector cleanup
rg -A 5 'useEffect.*setConnector' -g '*.tsx' -g '*.ts'

# Look for account change handlers that might cleanup connector
rg -A 5 'account.*change|onAccountChange' -g '*.tsx' -g '*.ts'

# Search for connector cleanup in disconnect handlers
rg -A 5 'disconnect.*connector|cleanup.*connector' -g '*.tsx' -g '*.ts'

Length of output: 264


Script:

#!/bin/bash
# Let's look at the entire accountStore implementation to understand the connector usage
fd "accountStore.tsx" --type f --exec cat {}

# Search for files that import and use the connector
rg "import.*accountStore" -g '*.tsx' -g '*.ts' -A 3

# Look for wallet connection/disconnection handling
rg "connect|disconnect" -g '*.tsx' -g '*.ts' -A 5

Length of output: 21852

client/src/hooks/context/starknet-provider.tsx (1)

14-15: LGTM! Verify integration with account management.

The configuration updates look correct. Since this is part of a larger account management feature, ensure that these changes are properly integrated with the account store and controller context.

Let's verify the integration with related components:

✅ Verification successful

Integration with account management verified

The changes are properly integrated with the account management system:

  • ControllerConnector is correctly imported and used in accountStore.tsx with proper state management
  • The connector is properly integrated in DojoContext.tsx with account state synchronization
  • The account store maintains the connector state and provides setter methods
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration between ControllerConnector and account management

# Check for related account management implementations
echo "Checking account management integration..."
rg -l "ControllerConnector" --type tsx

# Verify consistent namespace usage
echo "\nVerifying namespace consistency..."
rg "eternum-rc1-1|eternum" --type tsx

Length of output: 312


Script:

#!/bin/bash
# Let's try without file type restriction since tsx extension might not be recognized
echo "Checking ControllerConnector usage..."
rg -l "ControllerConnector"

echo -e "\nChecking namespace and slot references..."
rg "namespace.*slot|slot.*namespace"

echo -e "\nChecking account management related code..."
rg -l "account.*management|AccountManagement|AccountStore"

Length of output: 926


Script:

#!/bin/bash
# Let's examine the integration points more closely

# Check the implementation in accountStore.tsx
echo "Checking accountStore.tsx implementation..."
rg -A 5 "ControllerConnector" client/src/hooks/context/accountStore.tsx

# Check how namespace and slot are used in starknet-provider
echo -e "\nChecking starknet-provider implementation..."
rg -A 10 "namespace.*slot|slot.*namespace" client/src/hooks/context/starknet-provider.tsx

# Check DojoContext integration
echo -e "\nChecking DojoContext integration..."
rg -A 5 "ControllerConnector" client/src/hooks/context/DojoContext.tsx

Length of output: 1569

client/package.json (1)

20-21: Verify the minimum required versions for cartridge packages.

The update of both @cartridge/connector and @cartridge/controller from alpha.4 to alpha.6 appears to support the account management changes. However, since these are alpha versions:

  1. Please verify if alpha.6 is the minimum required version or if alpha.4 would still work
  2. Consider documenting the reason for these version updates in the PR description
  3. Be cautious of potential breaking changes in these alpha releases

Let's verify the minimum required versions:

✅ Verification successful

Based on the package.json files found, I can now generate a final response:

Version updates are required for trophy page implementation

The version updates to alpha.6 are necessary as evidenced by:

  1. The client package requires these specific versions for new account management features
  2. The landing package is already using alpha.5, indicating a progressive upgrade path
  3. These packages are core dependencies for the client's functionality, used alongside other Dojo-related packages

The synchronized update of both packages to the same version is the correct approach since they are tightly coupled components of the Cartridge framework.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are any breaking changes between alpha.4 and alpha.6

# Look for import statements and usage patterns of these packages
echo "Searching for @cartridge/* package usage patterns..."
rg --type typescript "@cartridge/(connector|controller)" -A 5

# Check the changelog or release notes in package.json
echo "Checking for potential breaking changes in package.json..."
rg "\"@cartridge/(connector|controller)\"" package.json

Length of output: 396


Script:

#!/bin/bash
# Search for TypeScript/JavaScript files using cartridge packages
echo "Searching for cartridge package imports..."
rg -t js -t jsx -t ts -t tsx "@cartridge/(connector|controller)" -A 5

# Look for package.json files and their content
echo "Checking package.json files..."
fd package.json --exec cat {}

# Look for any migration guides or documentation
echo "Checking for documentation..."
fd -e md -e txt | xargs rg -l "cartridge|migration|upgrade"

Length of output: 10656

client/src/ui/config.tsx (1)

72-72: LGTM! Trophy thumbnail addition is well-implemented.

The new trophy thumbnail path follows the established pattern and aligns with the PR's objective of adding a trophy page.

client/src/ui/modules/navigation/SecondaryMenuItems.tsx (2)

1-1: LGTM!

The import is correctly placed and necessary for the new trophy feature implementation.


36-39: Remove console.log statements

These debug statements should not be committed to production code.

client/src/hooks/context/DojoContext.tsx (2)

4-4: LGTM: Import aligns with connector integration.

The import of ControllerConnector is necessary for the enhanced account management functionality.


68-76: Verify connector state management across the application.

The addition of connector state management might affect other components that rely on the account store.

Let's verify the connector usage and cleanup:

✅ Verification successful

Connector state management is properly implemented

Based on the verification results:

  1. The connector state is cleanly managed in a centralized store (accountStore.tsx)
  2. Usage is limited to DojoContext (for setting) and SecondaryMenuItems (for reading)
  3. No cleanup is needed as the store handles state persistence
  4. The implementation follows proper patterns with typed interfaces
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for connector usage in components and potential memory leaks
echo "Searching for connector usage in components..."
rg -l "useAccountStore.*connector" --type tsx

echo "Checking for proper cleanup in components using connector..."
rg -A 5 "useEffect.*connector" --type tsx

Length of output: 381


Script:

#!/bin/bash
# Search for connector usage in components with correct file extension
echo "Searching for connector usage in components..."
rg -l "useAccountStore.*connector" --type ts --type tsx --type jsx --type js

echo "Checking for proper cleanup in components using connector..."
rg -A 5 "useEffect.*connector" --type ts --type tsx --type jsx --type js

# Search for connector-related state management
echo "Searching for connector state management..."
rg "setConnector|getConnector" --type ts --type tsx --type jsx --type js

# Look for account store implementation
echo "Looking for account store implementation..."
fd "AccountStore" --type f --exec cat {}

Length of output: 783


Script:

#!/bin/bash
# Search for files and patterns without relying on file extensions
echo "Searching for connector usage..."
rg -l "useAccountStore.*connector"

echo "Checking for connector-related effects..."
rg -A 5 "useEffect.*connector"

echo "Searching for connector state management..."
rg "setConnector|getConnector"

echo "Looking for account store files..."
fd "AccountStore"

Length of output: 876


Script:

#!/bin/bash
# Let's examine the specific files we found
echo "Content of SecondaryMenuItems.tsx..."
cat client/src/ui/modules/navigation/SecondaryMenuItems.tsx

echo -e "\nContent of accountStore.tsx..."
cat client/src/hooks/context/accountStore.tsx

echo -e "\nChecking for cleanup patterns..."
rg -B 5 -A 5 "useEffect.*connector.*return"

Length of output: 5538

client/src/ui/modules/navigation/SecondaryMenuItems.tsx Outdated Show resolved Hide resolved
client/src/hooks/context/DojoContext.tsx Outdated Show resolved Hide resolved
@bal7hazar bal7hazar changed the title 🚧 Add trophy page 🚧 feat/trophy page Nov 6, 2024
@bal7hazar bal7hazar marked this pull request as ready for review November 6, 2024 17:15
@bal7hazar bal7hazar changed the title 🚧 feat/trophy page 🏆 feat/trophy page Nov 6, 2024
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: 2

🧹 Outside diff range and nitpick comments (2)
client/src/hooks/context/starknet-provider.tsx (2)

4-4: Consider moving configuration constants to a dedicated config file.

These configuration constants (slot, namespace, colorMode) would be better placed in a dedicated configuration file. This would:

  • Centralize configuration management
  • Make it easier to update values across environments
  • Improve maintainability

Also applies to: 10-12


14-21: Maintain consistent ordering of properties.

Consider ordering the ControllerConnector properties to match the order of their constant declarations above for better code readability:

 const controller = new ControllerConnector({
   rpc: import.meta.env.VITE_PUBLIC_NODE_URL,
-  namespace,
-  slot,
   policies,
   theme,
+  slot,
+  namespace,
   colorMode,
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f6fd4c4 and ff1ee97.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • client/package.json (1 hunks)
  • client/src/hooks/context/DojoContext.tsx (3 hunks)
  • client/src/hooks/context/starknet-provider.tsx (1 hunks)
  • client/src/ui/modules/navigation/SecondaryMenuItems.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • client/package.json
  • client/src/ui/modules/navigation/SecondaryMenuItems.tsx
🔇 Additional comments (2)
client/src/hooks/context/DojoContext.tsx (2)

4-4: LGTM: Import addition is appropriate.

The ControllerConnector import is correctly added and properly used for type casting in the connector management.


158-158: ⚠️ Potential issue

Avoid hardcoding environment flags.

The isDev flag is hardcoded to false, which could make local development difficult. Consider deriving this value from environment variables or build configuration.

Consider using environment variables:

- const isDev = false;
+ const isDev = import.meta.env.MODE === 'development' || import.meta.env.VITE_ENV === 'development';

Let's check if there are any environment-related configurations:

Comment on lines 14 to 21
const controller = new ControllerConnector({
rpc: import.meta.env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
policies,
theme,
colorMode,
});
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

Add environment variable validation.

Consider adding validation for the VITE_PUBLIC_NODE_URL environment variable to prevent runtime errors:

+if (!import.meta.env.VITE_PUBLIC_NODE_URL) {
+  throw new Error('VITE_PUBLIC_NODE_URL environment variable is not set');
+}

 const controller = new ControllerConnector({
   rpc: import.meta.env.VITE_PUBLIC_NODE_URL,
   namespace,
   slot,
   policies,
   theme,
   colorMode,
 });
📝 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
const controller = new ControllerConnector({
rpc: import.meta.env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
policies,
theme,
colorMode,
});
if (!import.meta.env.VITE_PUBLIC_NODE_URL) {
throw new Error('VITE_PUBLIC_NODE_URL environment variable is not set');
}
const controller = new ControllerConnector({
rpc: import.meta.env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
policies,
theme,
colorMode,
});

Comment on lines +68 to +82
const { account, connector, isConnected } = useAccount();

useEffect(() => {
if (controllerAccount) {
useAccountStore.getState().setAccount(controllerAccount);
if (account) {
useAccountStore.getState().setAccount(account);
}
}, [controllerAccount, isConnected]);
return controllerAccount;
}, [account, isConnected]);

useEffect(() => {
if (connector) {
useAccountStore.getState().setConnector(connector as ControllerConnector);
}
}, [connector, isConnected]);

return account;
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

Improve error handling in useControllerAccount effects.

While the separation of concerns between account and connector effects is a good improvement, the implementation could still benefit from proper error handling and cleanup functions as suggested in the previous review.

Consider adding error handling and cleanup:

  useEffect(() => {
    if (account) {
+     try {
        useAccountStore.getState().setAccount(account);
+     } catch (error) {
+       console.error('Failed to set account:', error);
+     }
    }
+   return () => {
+     // Cleanup when component unmounts or account changes
+   };
  }, [account, isConnected]);

  useEffect(() => {
    if (connector) {
+     try {
        useAccountStore.getState().setConnector(connector as ControllerConnector);
+     } catch (error) {
+       console.error('Failed to set connector:', error);
+     }
    }
+   return () => {
+     // Cleanup when component unmounts or connector changes
+   };
  }, [connector, isConnected]);

Committable suggestion skipped: line range outside the PR's diff.

@ponderingdemocritus ponderingdemocritus merged commit 17ce64e into BibliothecaDAO:next Nov 6, 2024
7 of 8 checks 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.

2 participants