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

Add Opus Seasons #293

Merged
merged 3 commits into from
Feb 10, 2025
Merged

Add Opus Seasons #293

merged 3 commits into from
Feb 10, 2025

Conversation

starknetdev
Copy link
Member

@starknetdev starknetdev commented Feb 10, 2025

Summary by CodeRabbit

  • New Features
    • The application now highlights an active season branded as “Opus Season 1,” featuring updated partnership details, on-chain tournament prize information, and a clear season end date.
  • Style
    • The prize display has been enhanced with simplified calculations and a refreshed layout, including a visual indicator for additional prizes.
  • Configuration Updates
    • The tournament identifier has been updated to reflect changes in tournament management.

- switch environment from dark shuffle tournament to season
- improve styles
Copy link

vercel bot commented Feb 10, 2025

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

Name Status Preview Comments Updated (UTC)
loot-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 10, 2025 1:38pm

Copy link

coderabbitai bot commented Feb 10, 2025

Walkthrough

The changes update environment flags to mark the current season as active while deactivating a specific tournament. UI components have been refreshed to display new season details, including updated texts, spacing, and prize calculations. Additionally, the code managing prize rendering is simplified by removing extra state variables. Finally, the tournament identifier has been updated in both configuration and transaction-related utility functions, with a refactoring that enhances code clarity.

Changes

File(s) Summary of Changes
ui/.env Updated environment variables: NEXT_PUBLIC_SEASON_ACTIVE changed from "false" to "true" and NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE changed from "true" to "false".
ui/src/app/components/start/CreateAdventurer.tsx
ui/src/app/components/start/Prizes.tsx
ui/src/app/components/start/SeasonDetails.tsx
- CreateAdventurer.tsx: Altered container styling, updated heading from "Enter Season 0" to "Opus Season 1", revised descriptive text, and added a season end date.
- Prizes.tsx: Commented out asynchronous fetching and state for lordsDollar; simplified prize value calculation and added conditional divider rendering.
- SeasonDetails.tsx: Updated heading, simplified prize calculation, and added an indication of more prizes.
ui/src/app/lib/networkConfig.ts
ui/src/app/lib/utils/syscalls.ts
In networkConfig.ts, updated the tournamentId in the mainnet configuration from "0x1" to "0x4". In syscalls.ts, refactored the startSeason function by introducing a local tournamentId variable retrieved from networkConfig, which replaces the inline reference to improve readability.

Sequence Diagram(s)

sequenceDiagram
    participant U as User Action
    participant S as startSeason Function
    participant N as Network Config
    participant T as Transaction Service

    U->>S: Initiate start season
    S->>N: Retrieve tournamentId for current network
    N-->>S: Return tournamentId ("0x4")
    S->>T: Call enterTournamentTx(tournamentId)
    T-->>S: Transaction result
    S->>U: Return updated season status
Loading

Possibly related PRs

  • Integrate Dark Shuffle Tournament #290: The changes in the main PR, specifically the updates to environment variables in ui/.env, are related to the introduction of tournament-related variables, which aligns with the modifications in the retrieved PR that also involve tournament configurations, particularly the addition of tournament-related environment variables.

Poem

Hop, skip, and bound through lines of code,
A season reborn as true flags are showed.
Tournaments shift with a gentle nudge,
Code streamlined without a grudge.
I’m a rabbit, hopping in digital glee – cheers to change and agility!
🐇💻


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f9f700 and 99fab64.

📒 Files selected for processing (1)
  • ui/src/app/lib/utils/syscalls.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/src/app/lib/utils/syscalls.ts

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

@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

🔭 Outside diff range comments (1)
ui/src/app/components/start/SeasonDetails.tsx (1)

4-7: Remove unused prop lordsValue.

The lordsValue prop is passed to the component but is no longer used in the prize calculations.

Apply this diff to remove the unused prop:

 interface SeasonDetailsProps {
   prizes: any;
-  lordsValue: any;
 }
🧹 Nitpick comments (7)
ui/src/app/components/start/Prizes.tsx (4)

11-11: Remove commented out code.

Instead of keeping commented out code in the codebase, it should be removed since it can be retrieved from version control if needed. This improves code readability and maintainability.

-  // const [lordsDollar, setLordsDollar] = useState<bigint>(0n);
-
-  // const handleLordsDollarValue = async () => {
-  //   const value = await lordsDollarValue();
-  //   setLordsDollar(value);
-  // };
-
-  // useEffect(() => {
-  //   handleLordsDollarValue();
-  // }, []);

Also applies to: 13-16, 18-20


42-42: Fix typo in className.

The class name "item-scrol" appears to be missing an 'l' at the end.

-            className="flex flex-row gap-5 overflow-scroll item-scrol h-10"
+            className="flex flex-row gap-5 overflow-scroll item-scroll h-10"

83-83: Remove commented out Lords icon component.

Remove the commented out code to maintain clean and readable codebase.

-                    {/* <Lords className="self-center w-4 h-4 sm:w-5 sm:h-5 fill-current" /> */}

84-86: Improve readability of token value calculation.

While the direct division simplifies the logic, the magic number 10 ** 18 should be extracted as a named constant to improve code readability and maintainability.

+const TOKEN_DECIMALS = 18;
+const TOKEN_DIVISOR = 10 ** TOKEN_DECIMALS;
+
 const Prizes = ({ prizes, lordsDollarValue }: Prizes) => {
   // ...
-                      ${tokenValue / 10 ** 18}
+                      ${tokenValue / TOKEN_DIVISOR}
ui/src/app/components/start/CreateAdventurer.tsx (3)

163-163: Move end date to configuration.

The season end date is hardcoded. Consider moving it to a configuration file or environment variable for easier updates.


156-161: Enhance external link security.

The external link to Opus website should include security-related attributes.

Apply this diff to enhance link security:

 <a
   className="underline uppercase"
   href="https://www.opus.money/"
+  target="_blank"
+  rel="noopener noreferrer"
+  aria-label="Visit Opus website"
 >
   Visit Opus
 </a>

174-182: Remove commented-out code.

The "No Season Active" section is commented out. Since it's no longer needed, it should be removed to maintain code cleanliness.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ffefcf and 2f9f700.

📒 Files selected for processing (6)
  • ui/.env (1 hunks)
  • ui/src/app/components/start/CreateAdventurer.tsx (1 hunks)
  • ui/src/app/components/start/Prizes.tsx (3 hunks)
  • ui/src/app/components/start/SeasonDetails.tsx (4 hunks)
  • ui/src/app/lib/networkConfig.ts (1 hunks)
  • ui/src/app/lib/utils/syscalls.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test Contracts (game)
🔇 Additional comments (5)
ui/src/app/lib/networkConfig.ts (1)

70-70: LGTM! Tournament ID updated for the new season.

The change updates the tournament identifier from "0x1" to "0x4" in the mainnet configuration, which aligns with adding a new Opus season.

ui/src/app/lib/utils/syscalls.ts (1)

1661-1667: LGTM! Improved code readability.

The changes enhance code readability by extracting the tournament ID into a variable before using it in the enterTournamentTx call.

ui/src/app/components/start/Prizes.tsx (1)

53-82: Well-structured prize rendering with improved visual hierarchy!

The changes nicely implement:

  • Visual separation between prizes using dividers
  • Position-based trophy colors
  • Clear spacing and alignment
ui/src/app/components/start/SeasonDetails.tsx (1)

37-38: Verify prize calculation changes.

The prize calculations have been simplified to only divide by 10^18. Please ensure this matches the token decimals and doesn't affect the displayed values.

Run the following script to verify the token decimals:

Also applies to: 55-56, 73-74

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Check token decimals in the contract
ast-grep --pattern $'contract ERC20 {
  $$$
  decimals() {
    $$$
  }
  $$$
}'

Length of output: 80


I'll run a more generic search to gather evidence of how the token decimals are defined in the repository. This updated script searches for files containing both the "ERC20" contract definition and the "decimals" function. We can then verify if the token uses 18 decimals as assumed.

Once we have the output, we can confirm whether the token decimals value is explicitly set (or assumed standard 18) in the contract. If no explicit decimals are found, please perform a manual check to ensure the value is as expected.


🏁 Script executed:

#!/bin/bash
# Step 1: Search for the ERC20 contract definitions
echo "Searching for ERC20 contract definitions..."
rg --ignore-case "contract ERC20" -n .

# Step 2: Search for the decimals function definition
echo "Searching for decimals function definitions..."
rg --ignore-case "function decimals\(" -n .

Length of output: 286


Manual Verification Required: Token Decimals Confirmation

The search did not yield any explicit definitions of an ERC20 decimals function, so we cannot confirm automatically whether the token uses 18 decimals. Please manually verify in your token contract or related deployment documentation that the decimals are indeed 18 to ensure the simplified prize calculation is correct.

ui/.env (1)

3-6: Verify tournament configuration consistency.

The tournament is marked as inactive, but tournament ID and start time are still configured. Please verify if these values are still needed.

Run the following script to check tournament configuration usage:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check usage of tournament configuration
rg "NEXT_PUBLIC_DS_TOURNAMENT_ID|NEXT_PUBLIC_DS_TOURNAMENT_START_TIME" -A 2

Length of output: 648


I'll now search for references to NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE to see if its value is used conditionally with the other tournament configuration values.


🏁 Script executed:

#!/bin/bash
rg "NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE" -A 2 -B 2

Length of output: 771


Tournament configuration values are in active use despite the tournament being marked inactive.

  • The tournament ID is referenced in ui/src/app/components/leaderboard/SeasonTable.tsx.
  • The tournament start time is referenced in ui/src/app/components/start/DSTournamentOverview.tsx.
  • The active flag, checked in multiple locations (e.g., ui/src/app/page.tsx and SeasonTable.tsx), determines whether tournament features should be enabled.

This indicates that the values are retained intentionally—likely to enable quick toggling of tournament mode when needed. If the decision is to permanently disable tournament functionality, these values and their associated logic might be removed. Otherwise, their presence is consistent with the current design.

@starknetdev starknetdev merged commit 5657a0c into main Feb 10, 2025
10 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.

1 participant