Skip to content

fix(alert): convert akt denom to udenom when saving balance alert thr…#1527

Merged
ygrishajev merged 1 commit intomainfrom
feature/alerts-ui
Jun 23, 2025
Merged

fix(alert): convert akt denom to udenom when saving balance alert thr…#1527
ygrishajev merged 1 commit intomainfrom
feature/alerts-ui

Conversation

@ygrishajev
Copy link
Contributor

@ygrishajev ygrishajev commented Jun 23, 2025

…eshold

Summary by CodeRabbit

  • Bug Fixes

    • Improved denomination handling to ensure correct conversion and alert thresholds for different currencies in deployment alerts.
  • Tests

    • Enhanced test coverage for deployment alerts by parameterizing tests for multiple denominations and verifying denomination-specific thresholds.
    • Updated test helpers to support configurable denominations for more robust testing.

@ygrishajev ygrishajev requested a review from a team as a code owner June 23, 2025 08:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 23, 2025

Walkthrough

The changes introduce denomination-aware logic for deployment alert thresholds and conversions in both the DeploymentAlertsContainer component and its test suite. The deployment seeder utility is updated to generate deployments with configurable denominations, and tests are enhanced to verify correct alert configuration for each denomination.

Changes

File(s) Change Summary
.../DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx Enhanced tests to parameterize by denomination, updated alert threshold checks, and improved setup helper.
.../DeploymentAlertsContainer/DeploymentAlertsContainer.tsx Modified value conversion logic to always use denomToUdenom for non-"uakt" denominations.
.../tests/seeders/deployment.ts Refactored buildRpcDeployment to accept a denom parameter, enabling configurable deployment denominations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeploymentAlertsContainer
    participant denomToUdenom

    User->>DeploymentAlertsContainer: Submit deployment alert config with denom
    alt denom is "uakt"
        DeploymentAlertsContainer->>denomToUdenom: Convert value for "uakt"
        denomToUdenom-->>DeploymentAlertsContainer: Converted value
    else denom is not "uakt"
        DeploymentAlertsContainer->>denomToUdenom: Convert value for non-"uakt"
        denomToUdenom-->>DeploymentAlertsContainer: Converted value
    end
    DeploymentAlertsContainer->>User: Send alert request with correct threshold
Loading

Possibly related PRs

Suggested reviewers

  • stalniy

Poem

Hopping through code with a denomination twist,
Now alerts know which threshold to list!
"uakt" or USDC, the logic is clear,
Deployments adapt, as changes appear.
🐇✨ With tests that are smart,
This bunny’s proud to take part!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-23T08_45_57_839Z-debug-0.log


📜 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 3bbb6b2 and b13889e.

📒 Files selected for processing (3)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (4 hunks)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.tsx (1 hunks)
  • apps/deploy-web/tests/seeders/deployment.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: validate-deploy-web
  • GitHub Check: test-deploy-web-build
🔇 Additional comments (5)
apps/deploy-web/tests/seeders/deployment.ts (2)

10-13: LGTM! Well-designed function signature update.

The addition of the optional denom parameter with proper type constraints and default value maintains backward compatibility while enabling flexible denomination testing. The type union correctly includes UAKT_DENOM and USDC_IBC_DENOMS variants.


83-111: Consistent denomination usage throughout deployment object.

All hardcoded denomination references have been properly replaced with the denom parameter across price, balance, transferred, and funds fields. This ensures the generated deployment object uses the specified denomination consistently.

apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.tsx (1)

67-87: Critical fix implemented correctly.

The updated conversion logic properly handles non-uakt denominations by directly applying denomToUdenom(value) instead of returning the value unchanged. This addresses the core issue described in the PR where AKT denomination needed proper conversion to udenom format when saving balance alert thresholds.

The logic flow is sound:

  • Non-uakt: Direct udenom conversion (appropriate for tokens already in base units)
  • uakt: USD → AKT → udenom conversion (maintains existing price conversion logic)
apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (2)

25-56: Excellent parameterized test coverage.

The parameterized test approach effectively covers both UAKT and USDC denominations with appropriate threshold values that align with the conversion logic:

  • UAKT: 4 → USD-to-AKT conversion (÷2) → denomToUdenom → 2,000,000
  • USDC: 4 → direct denomToUdenom → 4,000,000

This ensures the denomination-specific conversion paths are properly tested.


193-241: Well-structured test setup with proper denomination handling.

The updated setup function correctly:

  • Accepts optional denom parameter with proper typing
  • Passes denom to buildRpcDeployment for consistent test data generation
  • Configures mock pricing appropriately (AKT_PRICE=2 for "uakt", 1 for others)
  • Maintains backward compatibility with default parameter handling
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.

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.

(value: number) => {
if (deployment.denom !== "uakt") {
return value;
return denomToUdenom(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the actual fix

@codecov
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.47%. Comparing base (3bbb6b2) to head (b13889e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1527    +/-   ##
========================================
  Coverage   40.46%   40.47%            
========================================
  Files         871      871            
  Lines       21160    21160            
  Branches     3861     3860     -1     
========================================
+ Hits         8563     8565     +2     
- Misses      11880    12285   +405     
+ Partials      717      310   -407     
Flag Coverage Δ *Carryforward flag
api 71.36% <ø> (ø) Carriedforward from 3bbb6b2
deploy-web 18.74% <100.00%> (+0.01%) ⬆️
notifications 87.98% <ø> (ø) Carriedforward from 3bbb6b2
provider-proxy 82.10% <ø> (ø) Carriedforward from 3bbb6b2

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ymentAlertsContainer/DeploymentAlertsContainer.tsx 91.07% <100.00%> (+3.57%) ⬆️

... and 136 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ygrishajev ygrishajev merged commit 5da379a into main Jun 23, 2025
27 checks passed
@ygrishajev ygrishajev deleted the feature/alerts-ui branch June 23, 2025 09:01
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

Comments