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 Transmuter Contract Codes #3749

Open
wants to merge 4 commits into
base: stage
Choose a base branch
from

Conversation

JohnnyWyles
Copy link
Contributor

Adding the 3 other contract uploads for Transmuter pools so that these can be filtered out in the pools list if wanted.

Transmuter 1.0 already listed
Transmuter 2.0 was never instantiated
This adds 3.0, 3.1 and 3.2 which are the alloyed asset pools - but also are transmuters and often dominate the volume charts.

Copy link

vercel bot commented Aug 16, 2024

@JohnnyWyles is attempting to deploy a commit to the OsmoLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

Walkthrough

The recent update modifies the TransmuterPoolCodeIds constant in both the feature-flag.ts and env.ts files. A deprecation notice has been added to the feature-flag.ts file, indicating that the constant should now reference a new location. The logic for determining the values of TransmuterPoolCodeIds has been updated to include additional identifiers for non-testnet environments, enhancing the recognition of transmuter pools in the application.

Changes

File Change Summary
packages/web/config/feature-flag.ts Added deprecation notice for TransmuterPoolCodeIds; modified value from IS_TESTNET ? ["3084"] : ["148"] to IS_TESTNET ? ["3084"] : ["148", "814", "867", "996"].
packages/server/src/queries/complex/pools/env.ts Modified value of TransmuterPoolCodeIds from IS_TESTNET ? ["3084"] : ["148"] to IS_TESTNET ? ["3084"] : ["148", "814", "867", "996"], expanding available IDs for non-testnet environments.

Suggested reviewers

  • MaxMillington
  • DavideSegullo
  • JoseRFelix
  • CryptoAssassin1

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 31cac31 and 9b189dd.

📒 Files selected for processing (1)
  • packages/web/config/feature-flag.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/web/config/feature-flag.ts (1)

26-27: 🛠️ Refactor suggestion

Improve the deprecation notice and consider removing the constant.

While adding a deprecation notice is a good practice, there are some concerns:

  1. The constant is still defined and exported in this file, which might encourage its continued use.
  2. There's no information about when this constant will be removed or how to migrate to the new location.

Consider the following improvements:

  1. Add more details to the deprecation notice, such as the planned removal date and migration instructions.
  2. If possible, remove the constant from this file entirely and use the new location directly.
  3. If removal is not immediately possible, consider using a TypeScript deprecation decorator for stronger typing and IDE support.

Here's an example of how you could improve the deprecation notice:

/**
 * @deprecated This constant will be removed in the next major version.
 * Please use the constant from 'packages/server/src/queries/complex/pools/env.ts' instead.
 * Migration: Replace all occurrences of this import with the new location.
 */
export const TransmuterPoolCodeIds = IS_TESTNET ? ["3084"] : ["148"];

Or, if you decide to use a TypeScript decorator:

import { deprecated } from 'core-decorators';

class FeatureFlags {
  @deprecated('Use the constant from packages/server/src/queries/complex/pools/env.ts instead.')
  static get TransmuterPoolCodeIds(): string[] {
    return IS_TESTNET ? ["3084"] : ["148"];
  }
}

export const { TransmuterPoolCodeIds } = FeatureFlags;

To ensure that the new location for TransmuterPoolCodeIds exists and is being used, run the following script:

This script will help ensure that the migration to the new location is complete and consistent across the codebase.

✅ Verification successful

Deprecation Verified Successfully

All verification steps passed:

  1. The new file packages/server/src/queries/complex/pools/env.ts exists.
  2. TransmuterPoolCodeIds is defined in the new file.
  3. No usage of TransmuterPoolCodeIds from the old location found.

You can safely proceed with removing the TransmuterPoolCodeIds constant from packages/web/config/feature-flag.ts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and usage of the new TransmuterPoolCodeIds location

# Test 1: Check if the new file exists
if [ -f "packages/server/src/queries/complex/pools/env.ts" ]; then
  echo "New file exists."
else
  echo "Error: New file does not exist."
  exit 1
fi

# Test 2: Check if TransmuterPoolCodeIds is defined in the new file
if grep -q "TransmuterPoolCodeIds" "packages/server/src/queries/complex/pools/env.ts"; then
  echo "TransmuterPoolCodeIds is defined in the new file."
else
  echo "Error: TransmuterPoolCodeIds is not defined in the new file."
  exit 1
fi

# Test 3: Check for any remaining usage of the old location
if rg --type typescript "from ['\"]packages/web/config/feature-flag['\"]" | grep -q "TransmuterPoolCodeIds"; then
  echo "Warning: Found usage of TransmuterPoolCodeIds from the old location."
else
  echo "No usage of TransmuterPoolCodeIds from the old location found."
fi

echo "Verification complete."

Length of output: 628


Script:

#!/bin/bash
# Description: Verify the existence and usage of the new TransmuterPoolCodeIds location

# Test 1: Check if the new file exists
if [ -f "packages/server/src/queries/complex/pools/env.ts" ]; then
  echo "New file exists."
else
  echo "Error: New file does not exist."
  exit 1
fi

# Test 2: Check if TransmuterPoolCodeIds is defined in the new file
if grep -q "TransmuterPoolCodeIds" "packages/server/src/queries/complex/pools/env.ts"; then
  echo "TransmuterPoolCodeIds is defined in the new file."
else
  echo "Error: TransmuterPoolCodeIds is not defined in the new file."
  exit 1
fi

# Test 3: Check for any remaining usage of the old location
# Corrected the file type to 'ts' as 'typescript' was unrecognized
if rg --type ts "from ['\"]packages/web/config/feature-flag['\"]" | grep -q "TransmuterPoolCodeIds"; then
  echo "Warning: Found usage of TransmuterPoolCodeIds from the old location."
else
  echo "No usage of TransmuterPoolCodeIds from the old location found."
fi

echo "Verification complete."

Length of output: 585


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.

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

Outside diff range, codebase verification and nitpick comments (1)
packages/web/config/feature-flag.ts (1)

26-26: Inconsistent Usage of TransmuterPoolCodeIds Across Environments

The TransmuterPoolCodeIds is used in both the client and server code, but there is an inconsistency in the IDs used across these environments. The server-side code does not include the new IDs ("814", "867", "996") added to the client-side configuration.

  • File: packages/server/src/queries/complex/pools/env.ts
    • Line: const TransmuterPoolCodeIds = IS_TESTNET ? ["3084"] : ["148"];

Ensure that the server-side logic is updated to reflect the same set of IDs as the client-side configuration to maintain consistency across environments.

Analysis chain

LGTM! But verify the usage of new TransmuterPoolCodeIds.

The addition of new IDs to TransmuterPoolCodeIds is consistent with the objective of enhancing filtering capabilities. Ensure that these new IDs are correctly utilized in the application logic.

To verify, ensure that the application logic correctly handles these new IDs.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new TransmuterPoolCodeIds in the codebase.

# Test: Search for occurrences of the new IDs. Expect: Usage in relevant logic.
rg --type js '814|867|996'

Length of output: 111376


Script:

#!/bin/bash
# Description: Search for the usage of TransmuterPoolCodeIds in the source files.

# Test: Search for occurrences of TransmuterPoolCodeIds. Expect: Usage in relevant logic.
rg --type js 'TransmuterPoolCodeIds'

Length of output: 36


Script:

#!/bin/bash
# Description: Search for the usage of TransmuterPoolCodeIds across all file types.

# Test: Search for occurrences of TransmuterPoolCodeIds in all files. Expect: Usage in relevant logic.
rg 'TransmuterPoolCodeIds'

Length of output: 471

Copy link

vercel bot commented Oct 2, 2024

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

Name Status Preview Comments Updated (UTC)
osmosis-frontend ❌ Failed (Inspect) Oct 15, 2024 5:11pm

Copy link
Member

@jonator jonator left a comment

Choose a reason for hiding this comment

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

I believe this is connected to legacy query code.

It's preferred to use this now:

const TransmuterPoolCodeIds = IS_TESTNET ? ["3084"] : ["148"];

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

🧹 Outside diff range and nitpick comments (1)
packages/server/src/queries/complex/pools/env.ts (1)

Line range hint 1-24: Consider improvements for overall file structure and maintainability.

While the changes to TransmuterPoolCodeIds are appropriate, here are some suggestions to improve the overall structure and maintainability of the file:

  1. The WhitewhalePoolCodeIds for testnet is set to "?". If this information is available, please update it with the correct code ID.

  2. Consider adding comments to explain the purpose of each constant and their relationships. This will help future maintainers understand the significance of these code IDs.

  3. If more pool types are expected in the future, consider using a more structured approach for managing these constants. For example:

interface PoolCodeIds {
  testnet: string[];
  mainnet: string[];
}

const POOL_CODE_IDS: Record<string, PoolCodeIds> = {
  transmuter: {
    testnet: ["3084"],
    mainnet: ["148", "814", "867", "996"],
  },
  astroportPcl: {
    testnet: ["8611"],
    mainnet: ["842"],
  },
  whitewhale: {
    testnet: ["?"], // TODO: Update with correct testnet code ID
    mainnet: ["503", "641"],
  },
};

export function getCosmwasmPoolTypeFromCodeId(codeId: string): string {
  const environment = IS_TESTNET ? "testnet" : "mainnet";
  for (const [poolType, ids] of Object.entries(POOL_CODE_IDS)) {
    if (ids[environment].includes(codeId)) {
      return `cosmwasm-${poolType}`;
    }
  }
  return "cosmwasm";
}

This structure would make it easier to add new pool types and maintain the code IDs for different environments.

Would you like me to create a separate issue to track these improvements?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c216e0a and 31cac31.

📒 Files selected for processing (1)
  • packages/server/src/queries/complex/pools/env.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/server/src/queries/complex/pools/env.ts (2)

Line range hint 8-24: LGTM: Function behavior correctly updated with new Transmuter pool code IDs.

The getCosmwasmPoolTypeFromCodeId function will now correctly identify the new Transmuter pool types (3.0, 3.1, and 3.2) as "cosmwasm-transmuter". This change aligns with the PR objectives of enhancing filtering capabilities for Transmuter pools in the pools list.

The existing logic in the function remains sound and will automatically accommodate the new code IDs without requiring any changes to the function itself.


4-4: Verify the added Transmuter pool code IDs.

The TransmuterPoolCodeIds constant has been updated to include additional code IDs for non-testnet environments. This change aligns with the PR objectives of adding new versions of Transmuter contracts (3.0, 3.1, and 3.2).

However, to ensure accuracy and completeness:

  1. Please confirm that the new code IDs ("814", "867", "996") correspond to the correct versions (3.0, 3.1, and 3.2) of the Transmuter contracts.
  2. Consider adding comments to indicate which version each code ID represents for better maintainability.

To verify the correctness of these code IDs, you can run the following script:

This will help ensure that the added code IDs are consistent with other parts of the codebase and documentation.

@jonator jonator requested a review from a team October 11, 2024 18:53
Copy link
Member

@jonator jonator left a comment

Choose a reason for hiding this comment

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

@JohnnyWyles if we could add // @deprecated use packages/server/src/queries/complex/pools/env.ts comment above the old one, that would help prevent this confusion in the future

@MaxMillington
Copy link
Collaborator

@JohnnyWyles is there any update on this? need any help?

@JohnnyWyles
Copy link
Contributor Author

@JohnnyWyles is there any update on this? need any help?

I think I did the change that Jon requested?
Not sure what's missing from this

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