Skip to content

Conversation

@aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Jun 25, 2025

  • added a function to convert chain formatted values to human readable in Token class

Summary by CodeRabbit

  • New Features
    • Added the ability to convert chain-formatted token values back into human-readable decimals.
  • Tests
    • Introduced tests to verify correct conversion from chain-formatted values to human-readable decimals.
  • Chores
    • Updated the application version to 1.11.0-rc6.
    • Updated Python version dependency to 3.10 and adjusted testing workflows accordingly.

@aarmoa aarmoa requested a review from Copilot June 25, 2025 13:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a function in the Token class to convert chain formatted values into human readable values.

  • Added tests for human_readable_value conversion in test_token.py
  • Bumped the version in pyproject.toml from 1.11.0-rc5 to 1.11.0-rc6
  • Implemented human_readable_value in Token to perform the conversion

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/core/test_token.py Added a new test case for human readable value conversion
pyproject.toml Updated version number
pyinjective/core/token.py Introduced the human_readable_value method for value conversion
Comments suppressed due to low confidence (1)

pyinjective/core/token.py:29

  • Consider adding a docstring for the human_readable_value method to explain its purpose, input parameters, and return value.
    def human_readable_value(self, chain_formatted_value: Decimal) -> Decimal:

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

A new method, human_readable_value, was added to the Token class to convert chain-formatted decimal values to human-readable decimals. The version in pyproject.toml was incremented to 1.11.0-rc6, and the Python dependency was updated to require Python 3.10 or higher. A corresponding test was introduced to validate the new method's correctness. The GitHub Actions workflow was updated to remove Python 3.9 from the test matrix.

Changes

File(s) Change Summary
pyinjective/core/token.py Added human_readable_value method to the Token class for chain-to-human decimal conversion.
tests/core/test_token.py Added test_human_readable_value to verify the new conversion method in the Token class.
pyproject.toml Updated version from 1.11.0-rc5 to 1.11.0-rc6; raised Python dependency from ^3.9 to ^3.10.
.github/workflows/run-tests.yml Removed Python 3.9 from test matrix; tests now run on Python 3.10, 3.11, and 3.12 only.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Token
    User->>Token: human_readable_value(chain_formatted_value)
    Token-->>User: Returns human-readable Decimal value
Loading

Poem

A token’s value, once chained and tall,
Now reads as humans see, not small.
With decimals moved and numbers right,
Our tests confirm the code’s new might.
Version bumped, the code feels new—
Hopping forward, as rabbits do! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0056e7 and 5bfee3e.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/run-tests.yml (1 hunks)
  • pyinjective/core/token.py (1 hunks)
  • pyproject.toml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/run-tests.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • pyproject.toml
  • pyinjective/core/token.py
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28f1854 and a0056e7.

📒 Files selected for processing (3)
  • pyinjective/core/token.py (1 hunks)
  • pyproject.toml (1 hunks)
  • tests/core/test_token.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
tests/core/test_token.py

15-15: Redefinition of unused inj_token from line 3

(F811)

🪛 Flake8 (7.2.0)
tests/core/test_token.py

[error] 15-15: redefinition of unused 'inj_token' from line 3

(F811)

🪛 GitHub Actions: pre-commit
pyinjective/core/token.py

[error] 25-25: Pre-commit hook 'trailing-whitespace' failed. Trailing whitespace was found and fixed in this file. Run 'pre-commit run --all-files' locally to reproduce.

🔇 Additional comments (3)
pyproject.toml (1)

3-3: LGTM! Appropriate version bump for the new feature.

The version increment from rc5 to rc6 is appropriate for adding the new human_readable_value method to the Token class.

pyinjective/core/token.py (1)

29-30: LGTM! Correct implementation of the inverse conversion.

The human_readable_value method correctly performs the inverse operation of chain_formatted_value by dividing the chain-formatted value by 10^decimals. This provides a clean API for bidirectional conversion between human-readable and chain-formatted token values.

tests/core/test_token.py (1)

15-21: LGTM! Comprehensive test for the new method.

The test correctly verifies that human_readable_value performs the inverse conversion of chain_formatted_value. The test follows the same pattern as the existing test and uses appropriate test data.

Note: The static analysis warnings about inj_token redefinition are false positives - inj_token is a pytest fixture parameter, not an unused import.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedbitarray@​3.4.1 ⏵ 3.4.393100100100100
Updatedclick@​8.1.8 ⏵ 8.2.195 +1100100100100
Addedcoincurve@​21.0.09910010010080
Updatedcertifi@​2025.4.26 ⏵ 2025.6.15100 +110010010070
Addedcoincurve@​18.0.0100100100100100

View full report

@aarmoa aarmoa merged commit e9538ac into dev Jun 25, 2025
10 checks passed
@aarmoa aarmoa deleted the feat/add_human_readable_function_in_token branch June 25, 2025 13:41
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