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

F/auction #49

Merged
merged 7 commits into from
Oct 9, 2024
Merged

F/auction #49

merged 7 commits into from
Oct 9, 2024

Conversation

maxrobot
Copy link
Collaborator

@maxrobot maxrobot commented Oct 9, 2024

see changelog

Summary by CodeRabbit

  • New Features

    • Introduced a new auction module for handling auction-related queries.
    • Added an oracle module to manage oracle functionalities, including price relaying and querying.
    • Enhanced BaseApp with new methods for retrieving blockchain-related information.
  • Bug Fixes

    • Updated dependencies to address issues and enhance stability.
  • Chores

    • Updated changelog with new version entries and dependency modifications.
    • Cleaned up code by removing unused declarations and comments for better readability.

Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces several updates to the injective-test-tube project, including a new version entry in the changelog and modifications to the Cargo.toml file to reflect version changes and new dependencies. Significant changes include the addition of auction and oracle modules with various query methods, enhancements to the BaseApp struct in app.rs, and adjustments to the handling of attributes in event processing. Additionally, the public interface has been modified by commenting out the Execute function in the bindings.rs file.

Changes

File Path Change Summary
packages/injective-test-tube/CHANGELOG.md Updated with new version entry 1.13.2-auction and retained entry for 1.13.2.
packages/injective-test-tube/Cargo.toml Updated package version to 1.13.2-auction, added cosmwasm-schema dependency, and updated injective-std.
packages/injective-test-tube/libinjectivetesttube/main.go Commented out setting os.Stdout to nil in InitTestEnv, with minor comment adjustments.
packages/injective-test-tube/libinjectivetesttube/testenv/setup.go Removed unused balances initialization; simplified account genesis state setup.
packages/injective-test-tube/src/module/auction.rs Introduced Auction module with query functions for auction parameters and results.
packages/injective-test-tube/src/module/mod.rs Added pub use auction::Auction; to export the Auction struct.
packages/injective-test-tube/src/module/oracle.rs Introduced Oracle module with functions for relaying price data and querying states.
packages/test-tube/Cargo.toml Updated dependency versions for cosmrs and prost; adjusted formatting.
packages/test-tube/src/bindings.rs Commented out the Execute function declaration from the C interface.
packages/test-tube/src/runner/app.rs Added new methods to BaseApp for blockchain information retrieval and modified existing methods for clarity.
packages/test-tube/src/runner/result.rs Updated TryFrom implementations to improve attribute handling in event processing.

Possibly related PRs

  • F/auction #49: This PR directly updates the changelog to include the same version entry 1.13.2-auction and mentions the update to [email protected], which is also reflected in the main PR.

Suggested reviewers

  • jbernal87

Poem

🐇 In the garden of code, changes bloom bright,
New modules for auctions, oh what a sight!
With queries and structs, our project takes flight,
A hop and a skip, through day and through night.
Let's celebrate progress, with joy and with cheer,
For the rabbit of coding, the future is clear! 🥕✨


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

@jbernal87 jbernal87 self-requested a review October 9, 2024 10:14
@@ -36,7 +36,7 @@ func InitTestEnv() uint64 {
defer mu.Unlock()

// temp: suppress noise from stdout
os.Stdout = nil
// os.Stdout = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not remove ?

extern "C" {
pub fn Execute(envId: GoUint64, base64ReqDeliverTx: GoString) -> *mut ::std::os::raw::c_char;
}
// extern "C" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove coment

@@ -102,8 +102,8 @@ where
.into_iter()
.map(|a| -> Result<Attribute, Utf8Error> {
Ok(Attribute {
key: a.key.to_string(),
value: a.value.to_string(),
key: std::str::from_utf8(a.key_bytes())?.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

why not import fuction ?

Copy link
Contributor

@jbernal87 jbernal87 left a comment

Choose a reason for hiding this comment

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

Small coments but otherwise LG

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

🧹 Outside diff range and nitpick comments (4)
packages/injective-test-tube/Cargo.toml (1)

7-7: Version update looks good, don't forget to update the changelog.

The version change to "1.13.2-auction" is appropriate for a pre-release version focusing on auction features. This is consistent with the PR title "F/auction".

Ensure that the CHANGELOG.md file is updated to reflect this new version and the changes introduced in this PR.

packages/test-tube/src/runner/result.rs (2)

55-56: Approve changes with a suggestion for optimization

The changes improve the robustness of the code by explicitly handling UTF-8 conversion for attribute keys and values. This is a good practice when dealing with data that might not be valid UTF-8.

However, consider caching the converted strings to avoid repeated conversions in case the Attribute struct is used multiple times. This could potentially improve performance, especially for large numbers of attributes.

Consider caching the converted strings:

let key = std::str::from_utf8(a.key_bytes())?.to_string();
let value = std::str::from_utf8(a.value_bytes())?.to_string();
Ok(Attribute { key, value })

This way, the conversion is done only once per attribute.


105-106: Approve changes with a suggestion for code reuse

The changes here are consistent with the previous implementation, which is good for maintaining uniform behavior across different TryFrom implementations.

However, the repetition of this code in multiple places increases the maintenance burden and the risk of inconsistencies in future updates. Consider extracting this logic into a separate function to promote code reuse.

Consider extracting the attribute conversion logic into a separate function:

fn convert_attribute(a: &AttributeProto) -> Result<Attribute, Utf8Error> {
    Ok(Attribute {
        key: std::str::from_utf8(a.key_bytes())?.to_string(),
        value: std::str::from_utf8(a.value_bytes())?.to_string(),
    })
}

Then use this function in both TryFrom implementations:

e.attributes
    .into_iter()
    .map(convert_attribute)
    .collect::<Result<Vec<Attribute>, Utf8Error>>()?

This approach will make the code more maintainable and reduce the risk of inconsistencies.

packages/test-tube/src/runner/app.rs (1)

Hardcoded denom Usage Detected in get_first_validator_signing_account

The following calls to get_first_validator_signing_account are using the hardcoded "inj" denomination. Please update these to pass dynamic denom values to ensure flexibility and prevent potential transaction fee issues:

  • packages/injective-test-tube/src/module/oracle.rs
🔗 Analysis chain

Line range hint 106-111: Verify the correct usage of denom in get_first_validator_signing_account

The function get_first_validator_signing_account now uses the denom parameter instead of the hardcoded "inj" denomination in the fee setting. Please ensure that all calls to this function pass the appropriate denomination to prevent any issues with transaction fees.

To verify the function usage across the codebase, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all calls to `get_first_validator_signing_account` and check the `denom` parameter.

# Search for function calls and display the relevant lines
rg --type rust 'get_first_validator_signing_account\(' -A 2

Length of output: 1217

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1f59e58 and 341cc1f.

📒 Files selected for processing (11)
  • packages/injective-test-tube/CHANGELOG.md (1 hunks)
  • packages/injective-test-tube/Cargo.toml (1 hunks)
  • packages/injective-test-tube/libinjectivetesttube/main.go (1 hunks)
  • packages/injective-test-tube/libinjectivetesttube/testenv/setup.go (0 hunks)
  • packages/injective-test-tube/src/module/auction.rs (1 hunks)
  • packages/injective-test-tube/src/module/mod.rs (2 hunks)
  • packages/injective-test-tube/src/module/oracle.rs (0 hunks)
  • packages/test-tube/Cargo.toml (1 hunks)
  • packages/test-tube/src/bindings.rs (1 hunks)
  • packages/test-tube/src/runner/app.rs (7 hunks)
  • packages/test-tube/src/runner/result.rs (2 hunks)
💤 Files with no reviewable changes (2)
  • packages/injective-test-tube/libinjectivetesttube/testenv/setup.go
  • packages/injective-test-tube/src/module/oracle.rs
🧰 Additional context used
🔇 Additional comments (14)
packages/injective-test-tube/src/module/mod.rs (3)

1-1: LGTM: New module declaration is consistent with existing structure.

The new 'auction' module declaration is correctly placed and maintains the alphabetical order of module declarations.


Line range hint 1-28: LGTM: File structure and consistency maintained.

The additions to this file (new module declaration and public export) maintain the existing structure and organization. The alphabetical order and grouping of declarations and exports remain consistent.


16-16: LGTM: New public export is consistent with existing structure.

The new 'Auction' export is correctly placed and follows the established pattern.

To ensure the correctness of this export, please verify that the Auction type is properly defined in the auction module. Run the following script to check its definition:

packages/test-tube/Cargo.toml (4)

12-12: LGTM: Consistent formatting for base64 dependency.

The base64 dependency version remains unchanged at "0.21.5". The formatting adjustment improves consistency in the Cargo.toml file.


14-14: LGTM: Consistent formatting for unchanged dependencies.

The versions of cosmwasm-std, serde, serde_json, and thiserror dependencies remain unchanged. The formatting adjustments improve consistency in the Cargo.toml file.

Also applies to: 16-18


13-13: Verify the cosmrs version downgrade and its implications.

The cosmrs dependency version has been changed to "0.20.0". However, this appears to be a downgrade from the previous version "0.15.0" mentioned in the AI summary. This is unusual as typically version numbers increase.

Please confirm if this version change is intentional and explain the rationale behind it. Consider running the following script to check for any breaking changes or compatibility issues:

✅ Verification successful

Confirm the cosmrs version upgrade and its impact.

The cosmrs dependency version has been changed from "0.15.0" to "0.20.0", which is an upgrade rather than a downgrade as initially mentioned. No breaking changes or compatibility issues were found in the documentation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in cosmrs between versions 0.15.0 and 0.20.0

# Test: Search for any mentions of breaking changes or compatibility issues
rg --type md -i '(breaking change|compatibility|upgrade|downgrade).*0\.(15|16|17|18|19|20)' $(fd -e md -e rst)

# Test: Check if the cosmrs crate is used in the codebase
rg --type rust 'use cosmrs::'

Length of output: 873


Script:

#!/bin/bash
# Description: Check for mentions of breaking changes or compatibility issues between cosmrs versions 0.15.0 and 0.20.0

# Search for any mentions of breaking changes or compatibility issues in markdown and reStructuredText files
rg --type md -i '(breaking change|compatibility|upgrade|downgrade).*0\.(15|16|17|18|19|20)' $(fd -e md -e rst)

# Check if the cosmrs crate is used in the Rust codebase without using regex look-around
rg --type rust 'use\s+cosmrs::'

Length of output: 1348


15-15: Verify prost dependency changes and their implications.

The prost dependency has been updated to version "0.13.3" with default features disabled and only the "prost-derive" feature explicitly included. This change might affect the functionality of the package.

Please confirm the following:

  1. The rationale behind disabling default features and only including "prost-derive".
  2. That this change doesn't break any existing functionality.
  3. That there are no breaking changes in the minor version update from 0.12.4 to 0.13.3.

Consider running the following script to check for any potential issues:

packages/injective-test-tube/Cargo.toml (2)

19-19: Dependency version update: Verify compatibility.

The update of injective-std to version "=1.13.2-auction" aligns with the package version update. The use of an exact version match ensures consistency across the project.

Please ensure that this version of injective-std is compatible with all other dependencies and that it includes all necessary features for the auction functionality. You may want to run your test suite to verify everything works as expected with this new version.

To verify the usage and impact of this dependency update, you can run the following script:

#!/bin/bash
# Description: Check for usage of injective-std in the codebase and potential incompatibilities

# Test: Search for imports or uses of injective-std
rg --type rust 'use injective_std::|use injective_std |from injective_std'

# Test: Check for any compiler warnings or errors related to injective-std
cargo check 2>&1 | rg 'injective-std'

15-15: New dependency added: Please provide usage details.

The addition of the cosmwasm-schema dependency is noted. This suggests that the project now requires schema-related functionality from the CosmWasm ecosystem.

Could you please provide more information on how this new dependency will be used in the project? This will help ensure that it's necessary and being used correctly.

To verify the usage of this new dependency, you can run the following script:

packages/test-tube/src/bindings.rs (1)

223-225: ⚠️ Potential issue

Verify the impact of removing the Execute function

The Execute function has been commented out, effectively removing it from the Rust bindings. While this change is consistent with the AI-generated summary, it's important to verify its impact:

  1. Please confirm that this change is intentional and aligns with the PR objectives.
  2. Ensure that no other parts of the codebase are relying on this function. If they are, they will need to be updated accordingly.
  3. Consider adding a comment explaining why this function was removed to improve code maintainability.

To help verify the impact of this change, you can run the following script:

This will help identify any potential places where the Execute function was being used and might need to be updated.

✅ Verification successful

Removal of the Execute function has been verified

The Execute function was commented out in packages/test-tube/src/bindings.rs, and a comprehensive search confirmed that it is not used elsewhere in the codebase. Therefore, removing this function does not impact any existing functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any usage of the Execute function in Rust files
rg --type rust "Execute\s*\(" ./src

Length of output: 83


Script:

#!/bin/bash
# Search for any usage of the Execute function in all Rust files within the repository
rg --type rust "Execute\s*\(" .

Length of output: 171

packages/injective-test-tube/libinjectivetesttube/main.go (1)

39-39: Clarify the purpose and impact of commenting out stdout suppression.

The commented-out line // os.Stdout = nil suggests a change in how stdout is handled during test environment initialization. While this may help with debugging by allowing more verbose output, it could potentially impact tests that rely on controlled stdout behavior.

Consider the following:

  1. Clarify the relationship between this change and the "Temp fix for concurrency issue" mentioned in the comment above the function.
  2. Document the specific reason for this change. Is it for debugging purposes, or does it address a particular problem?
  3. If this is indeed temporary, add a TODO comment with a ticket number or description of when and how this should be reverted.
  4. Evaluate and document any potential impacts on existing tests that might rely on suppressed stdout.

To help assess the impact of this change, you can run the following command to search for tests that might be affected:

This will help identify any tests that might need adjustment due to this change.

✅ Verification successful

Stdout suppression change does not impact existing tests.

The search confirmed that no tests capture or assert on os.Stdout. Commenting out // os.Stdout = nil does not affect any current tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests that capture or assert on stdout content
rg --type go '(os\.Stdout|t\.CaptureOutput|bytes\.Buffer.*os\.Stdout)' test/

Length of output: 124


Script:

#!/bin/bash
# Recursively search for tests that capture or assert on stdout across the entire codebase
rg --type go '(os\.Stdout|t\.CaptureOutput|bytes\.Buffer.*os\.Stdout)' --ignore-dir=node_modules --ignore-dir=dist --ignore-dir=build

Length of output: 578


Script:

#!/bin/bash
# Recursively search for tests that capture or assert on stdout across the entire codebase, excluding specific directories
rg --type go '(os\.Stdout|t\.CaptureOutput|bytes\.Buffer.*os\.Stdout)' --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**'

Length of output: 213

packages/test-tube/src/runner/result.rs (1)

Line range hint 1-280: Summary of changes and recommendations

The changes in this file improve the robustness of attribute handling by explicitly managing UTF-8 conversion. This is a positive change that aligns with best practices for handling potentially non-UTF-8 data.

Key points and recommendations:

  1. The changes are consistent across different TryFrom implementations, which is good for maintaining uniform behavior.
  2. Consider optimizing performance by caching the converted strings, especially if attributes are used multiple times.
  3. To reduce code duplication and improve maintainability, extract the attribute conversion logic into a separate function that can be reused across different implementations.
  4. No changes were made to public interfaces or exported entities, which helps maintain backwards compatibility.

Overall, these changes represent an improvement in code quality and robustness. Implementing the suggested optimizations and refactoring would further enhance the code's efficiency and maintainability.

packages/injective-test-tube/src/module/auction.rs (1)

11-40: LGTM: Correct implementation of the Auction module

The Auction module is well-implemented with the correct use of lifetimes and generics. The fn_query! macro is properly utilized to define the query methods, and the code is clean and adheres to Rust's best practices.

packages/test-tube/src/runner/app.rs (1)

315-323: Good use of Drop trait for resource cleanup

Implementing the Drop trait for BaseApp ensures that resources are properly released when the instance goes out of scope, preventing potential memory leaks or dangling resources.

Comment on lines +8 to +12
## 1.13.2-auction - 2024-08-10

### Changed

- Updated to use `[email protected]` which is a manual fix for the Auction protos
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Date inconsistency and version clarification needed

The new changelog entry follows the established format and provides clear information about the changes. However, there are two points that need attention:

  1. The date (2024-08-10) is earlier than the date of the previous entry (1.13.2 - 2024-28-08). This creates a chronological inconsistency in the changelog.

  2. The version number (1.13.2-auction) suggests this is a special version based on 1.13.2. It would be helpful to add a brief explanation of why this special version was created and how it relates to the main version line.

Consider the following actions:

  1. Adjust the date to maintain chronological order, or if the date is correct, consider moving this entry after the 1.13.2 entry.
  2. Add a brief note explaining the purpose of this special "auction" version and how it fits into the version history.

Example:

## 1.13.2-auction - 2024-08-10

### Changed

- Updated to use `[email protected]` which is a manual fix for the Auction protos
- Note: This is a special version created to address specific Auction proto issues. It is based on version 1.13.2 but is not part of the main release line.

Comment on lines +54 to +88
#[test]
fn auction_integration() {
let app = InjectiveTestApp::new();

let auction = Auction::new(&app);

let response = auction
.query_auction_params(&QueryAuctionParamsRequest {})
.unwrap();
assert_eq!(
response.params,
Some(Params {
auction_period: 604800,
min_next_bid_increment_rate: 2_500_000_000_000_000u128.to_string()
})
);

let response = auction
.query_last_auction_result(&QueryLastAuctionResultRequest {})
.unwrap();
assert!(response.last_auction_result.is_some());

let result = response.last_auction_result.unwrap();
assert_eq!(
result,
LastAuctionResult {
amount: Some(BaseCoin {
denom: "inj".to_string(),
amount: "0".to_string()
}),
winner: "".to_string(),
round: 0u64,
}
);
}
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 tests for all query methods in the Auction module

Currently, the test module includes tests for query_auction_params and query_last_auction_result functions. To ensure comprehensive test coverage and verify the functionality of all query methods, consider adding tests for the query_current_auction_basket and query_module_state functions.

Would you like assistance in writing these additional tests or opening a GitHub issue to track this task?

Comment on lines +131 to +136
/// Get the current block time
pub fn get_block_timestamp(&self) -> Timestamp {
let result = unsafe { GetBlockTime(self.id) };

Timestamp::from_nanos(result as u64)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential negative values in get_block_timestamp

The GetBlockTime(self.id) function returns an i64, which may be negative. Casting a negative i64 to u64 can lead to incorrect timestamp values due to integer underflow. Consider checking for negative values before casting to u64 to ensure correctness.

Apply the following diff to handle potential negative block times:

 pub fn get_block_timestamp(&self) -> Timestamp {
     let result = unsafe { GetBlockTime(self.id) };
+    if result < 0 {
+        // Handle negative block time appropriately
+        // For example, return an error or a default Timestamp
+        panic!("Block time is negative");
+    }
     Timestamp::from_nanos(result as u64)
 }
📝 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
/// Get the current block time
pub fn get_block_timestamp(&self) -> Timestamp {
let result = unsafe { GetBlockTime(self.id) };
Timestamp::from_nanos(result as u64)
}
/// Get the current block time
pub fn get_block_timestamp(&self) -> Timestamp {
let result = unsafe { GetBlockTime(self.id) };
if result < 0 {
// Handle negative block time appropriately
// For example, return an error or a default Timestamp
panic!("Block time is negative");
}
Timestamp::from_nanos(result as u64)
}

Comment on lines +261 to +269
pub fn default_simulation_fee(&self) -> Fee {
Fee::from_amount_and_gas(
cosmrs::Coin {
denom: self.fee_denom.parse().unwrap(),
amount: INJECTIVE_MIN_GAS_PRICE,
},
0u64,
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential parsing errors when parsing fee_denom

In the default_simulation_fee method, using self.fee_denom.parse().unwrap() can cause a panic if fee_denom cannot be parsed into the expected type. To enhance robustness, consider handling the parsing error gracefully.

Apply this diff to handle the parsing error:

 pub fn default_simulation_fee(&self) -> Fee {
     Fee::from_amount_and_gas(
         cosmrs::Coin {
-            denom: self.fee_denom.parse().unwrap(),
+            denom: match self.fee_denom.parse() {
+                Ok(denom) => denom,
+                Err(e) => {
+                    // Handle the error, possibly by returning a Result or a default value
+                    panic!("Invalid fee_denom '{}': {}", self.fee_denom, e);
+                }
+            },
             amount: INJECTIVE_MIN_GAS_PRICE,
         },
         0u64,
     )
 }

Committable suggestion was skipped due to low confidence.

@maxrobot maxrobot merged commit e8fbe0c into dev Oct 9, 2024
4 checks passed
@maxrobot maxrobot deleted the f/auction branch October 9, 2024 10:23
@coderabbitai coderabbitai bot mentioned this pull request Oct 16, 2024
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