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

fix: dependencies version and SSR lottie rendering #983

Open
wants to merge 1 commit into
base: testnet
Choose a base branch
from

Conversation

PedroRosalba
Copy link

@PedroRosalba PedroRosalba commented Jan 10, 2025

Fixed the dependencies version and the Lottie calls that were being made w SSR which were preventing the app to run properly

Summary by CodeRabbit

  • Performance Optimization

    • Updated Lottie component imports to use dynamic loading with server-side rendering disabled across multiple UI components
    • Improved client-side rendering performance for animation components
  • Dependency Update

    • Upgraded get-starknet-core package to version 4.0.0

Copy link

vercel bot commented Jan 10, 2025

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

Name Status Preview Comments Updated (UTC)
app-starknet-id ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 10:08pm

Copy link

vercel bot commented Jan 10, 2025

@PedroRosalba is attempting to deploy a commit to the LFG Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

The pull request involves modifications across multiple UI components and the package configuration. The primary changes include dynamically importing the Lottie component from lottie-react using Next.js's dynamic function with server-side rendering (SSR) disabled. This approach ensures that the Lottie animations are only rendered on the client side. Additionally, the get-starknet-core package was upgraded from version 3.3.4 to 4.0.0, which may introduce new features or breaking changes.

Changes

File Change Summary
components/UI/confirmationTx.tsx Dynamic import of Lottie with SSR disabled
components/UI/isSendingTx.tsx Dynamic import of Lottie with SSR disabled
components/UI/modalMessage.tsx Dynamic import of Lottie with SSR disabled
components/UI/registerConfirmationModal.tsx Dynamic import of Lottie with SSR disabled
components/UI/screens/successScreen.tsx Dynamic import of Lottie with SSR disabled
components/UI/txConfirmationModal.tsx Dynamic import of Lottie with SSR disabled
package.json Upgraded get-starknet-core from ^3.3.4 to ^4.0.0

Suggested labels

🔥 Ready for review

Suggested reviewers

  • fricoben

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (7)
components/UI/screens/successScreen.tsx (1)

4-8: LGTM! Dynamic import implementation looks correct.

The dynamic import of Lottie with ssr: false will prevent hydration mismatches by ensuring the animation only renders client-side.

Consider adding type definitions for Lottie props to improve type safety:

import type { LottieComponentProps } from 'lottie-react';
components/UI/isSendingTx.tsx (1)

Line range hint 16-16: Consider using className for consistent styling.

For consistency with other components, consider using className instead of inline style for width.

-        <Lottie style={{ width: "500px" }} animationData={sendingLottie} loop />
+        <Lottie className="w-[500px]" animationData={sendingLottie} loop />
components/UI/txConfirmationModal.tsx (1)

Line range hint 35-44: Add security attributes to external link.

When opening external links, it's recommended to add security-related attributes.

                window.open(
                  `https://${
                    process.env.NEXT_PUBLIC_IS_TESTNET === "true"
                      ? "sepolia."
                      : ""
-                 }starkscan.co/tx/${txHash}`
+                 }starkscan.co/tx/${txHash}`,
+                 '_blank',
+                 'noopener,noreferrer'
                )
components/UI/modalMessage.tsx (1)

Line range hint 12-12: Improve type definition for lottie prop.

The current unknown type for the lottie prop could be more specific.

-  lottie?: unknown; // Lottie doesn't have a special type
+  lottie?: Record<string, unknown>; // Type for JSON animation data
components/UI/confirmationTx.tsx (1)

5-7: Consider handling loading state.

Since dynamic imports can introduce a brief loading delay, consider adding a loading placeholder or skeleton UI while the Lottie component is being loaded.

 import dynamic from "next/dynamic";
 
-const Lottie = dynamic(() => import("lottie-react"), { ssr: false });
+const Lottie = dynamic(() => import("lottie-react"), { 
+  ssr: false,
+  loading: () => <div className="w-48 h-48 animate-pulse bg-gray-200 rounded-full" />
+});
components/UI/registerConfirmationModal.tsx (1)

Line range hint 33-43: Extract duplicated explorer URL logic.

The explorer URL construction logic is duplicated across components. Consider extracting it into a utility function for better maintainability.

// utils/explorer.ts
export const getExplorerUrl = (txHash: string): string => {
  const network = process.env.NEXT_PUBLIC_IS_TESTNET === "true" ? "sepolia." : "";
  return `https://${network}starkscan.co/tx/${txHash}`;
};

Then update the usage:

-window.open(
-  `https://${
-    process.env.NEXT_PUBLIC_IS_TESTNET === "true"
-      ? "sepolia."
-      : ""
-  }starkscan.co/tx/${txHash}`
-)
+window.open(getExplorerUrl(txHash))
package.json (1)

Line range hint 29-29: Consider pinning the lottie-react version.

Given that this PR addresses SSR-related issues with Lottie animations, consider pinning the lottie-react version to prevent potential future SSR issues from minor version updates. Replace ^2.4.0 with 2.4.0.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8f3a996 and dfde1f1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • components/UI/confirmationTx.tsx (1 hunks)
  • components/UI/isSendingTx.tsx (1 hunks)
  • components/UI/modalMessage.tsx (1 hunks)
  • components/UI/registerConfirmationModal.tsx (1 hunks)
  • components/UI/screens/successScreen.tsx (1 hunks)
  • components/UI/txConfirmationModal.tsx (1 hunks)
  • package.json (1 hunks)
🔇 Additional comments (7)
components/UI/isSendingTx.tsx (1)

6-8: LGTM! Dynamic import implementation is consistent.

The dynamic import matches the pattern used across other components.

components/UI/txConfirmationModal.tsx (1)

5-8: LGTM! Dynamic import implementation is consistent.

The dynamic import matches the pattern used across other components.

components/UI/modalMessage.tsx (2)

5-8: LGTM! Dynamic import implementation is consistent.

The dynamic import matches the pattern used across other components.


Line range hint 1-1: Verify dependency version changes.

The PR objectives mention fixing dependency versions, but the changes are not visible in the provided files. Please ensure that the dependency version updates are included in the PR.

✅ Verification successful

Dependency version changes confirmed

The PR includes the dependency updates as mentioned in the objectives, specifically updating get-starknet-core from ^3.3.4 to ^4.0.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for package.json changes
git diff origin/main...HEAD -- package.json

Length of output: 86


Script:

#!/bin/bash
# First, check if package.json exists and its location
fd package.json

# Then, check its contents
cat $(fd package.json) 2>/dev/null || echo "No package.json found"

# Try different git diff syntax
git diff HEAD~1 -- $(fd package.json) 2>/dev/null || echo "No git diff available"

Length of output: 2820

components/UI/confirmationTx.tsx (1)

5-7: LGTM! Correct implementation of dynamic import.

The dynamic import of Lottie with SSR disabled is the right approach to fix the SSR rendering issues.

components/UI/registerConfirmationModal.tsx (1)

5-7: LGTM! Consistent implementation across components.

The dynamic import implementation matches the pattern used in other components, maintaining consistency in the codebase.

package.json (1)

Line range hint 13-15: Verify compatibility between Starknet packages.

The upgrade of get-starknet-core to version 4 requires verification of compatibility with other Starknet-related packages:

  • starknet (^6.11.0)
  • starknetid.js (^4.0.1)
  • starknetkit (^2.6.2)
  • @starknet-react/core (^3.6.2)

Let's check the peer dependencies and version requirements:

Also applies to: 34-36

✅ Verification successful

All Starknet packages are compatible

The upgrade to get-starknet-core v4 is compatible with all related packages:

  • starknetkit@2.6.2 already uses get-starknet-core ^4.0.4
  • @starknet-react/core@3.6.2 requires get-starknet-core ^4.0.0
  • starknet@6.11.0 satisfies all peer dependency requirements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch package.json files from npm to check peer dependencies
echo "Checking peer dependencies for @starknet-io/get-starknet-core@4.0.4:"
curl -s https://registry.npmjs.org/@starknet-io/get-starknet-core/4.0.4 | jq '.peerDependencies'

echo -e "\nChecking peer dependencies for @starknet-react/core@3.6.2:"
curl -s https://registry.npmjs.org/@starknet-react/core/3.6.2 | jq '.peerDependencies'

Length of output: 549


Script:

#!/bin/bash
# Check starknetkit dependencies
echo "Checking dependencies for starknetkit@2.6.2:"
curl -s https://registry.npmjs.org/starknetkit/2.6.2 | jq '.dependencies, .peerDependencies'

Length of output: 637

@@ -33,7 +33,7 @@
"dotenv": "^16.3.1",
"eslint-config-next": "^13.4.7",
"ethers": "^6.12.1",
"get-starknet-core": "^3.3.4",
"get-starknet-core": "^4.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Migrate to @starknet-io/get-starknet-core and remove the unscoped package

The codebase currently uses both packages:

  • @starknet-io/get-starknet-core (4.0.4) - The official scoped package
  • get-starknet-core (^4.0.0) - The legacy unscoped package

To avoid potential conflicts and reduce bundle size:

  1. Update hooks/isDeployed.tsx to use @starknet-io/get-starknet-core
  2. Remove the unscoped get-starknet-core from package.json
  3. Run package manager to update dependencies
🔗 Analysis chain

Remove duplicate Starknet core dependency.

There are two similar packages in the dependencies:

  • get-starknet-core at version ^4.0.0
  • @starknet-io/get-starknet-core at version 4.0.4

This duplication could lead to increased bundle size and potential version conflicts.

Let's verify which package is actually being used in the codebase:

Consider removing the duplicate and standardizing on @starknet-io/get-starknet-core as it appears to be the official scoped package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for imports of both packages to determine which one is actively used
echo "Searching for get-starknet-core imports:"
rg "from ['\"]get-starknet-core['\"]" -A 2

echo -e "\nSearching for @starknet-io/get-starknet-core imports:"
rg "from ['\"]@starknet-io/get-starknet-core['\"]" -A 2

Length of output: 696


Script:

#!/bin/bash
# Check the content of both files to understand the usage context
echo "Content of hooks/isDeployed.tsx:"
cat hooks/isDeployed.tsx

echo -e "\nContent of utils/connectorWrapper.ts:"
cat utils/connectorWrapper.ts

# Search for any other potential imports or uses
echo -e "\nAny other references to these packages:"
rg -i "starknet.*core" --type ts --type tsx

Length of output: 45132


Script:

#!/bin/bash
# Check package.json for any other related dependencies
echo "Checking package.json for related dependencies:"
cat package.json

# Search for any other imports or uses of these packages
echo -e "\nSearching for any other imports or uses:"
rg "from ['\"](@starknet-io/|)get-starknet-core['\"]" --type ts --type jsx --type tsx

Length of output: 2668


Script:

#!/bin/bash
# Search with a more flexible pattern and include file content
echo "Searching for get-starknet-core imports and usage:"
rg -B 2 -A 2 "get-starknet-core" --type ts --type tsx

# Check if there are any other files importing from these packages
echo -e "\nSearching for any Starknet-related imports:"
rg "from ['\"].*starknet.*['\"]" --type ts --type tsx

Length of output: 383


Script:

#!/bin/bash
# Search without file type restrictions
echo "Searching for get-starknet-core imports and usage:"
rg -B 3 -A 3 "get-starknet-core"

# Check for any file extensions first
echo -e "\nListing relevant files:"
find . -type f -name "*.ts" -o -name "*.tsx" | grep -v "node_modules"

Length of output: 16491

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.

1 participant