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

FE-Release 2024-09-26 2 #3200

Merged
merged 4 commits into from
Sep 26, 2024
Merged

FE-Release 2024-09-26 2 #3200

merged 4 commits into from
Sep 26, 2024

Conversation

abtestingalpha
Copy link
Collaborator

@abtestingalpha abtestingalpha commented Sep 26, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a utility function for calculating significant decimal places in numbers, enhancing flexibility in display logic.
  • Bug Fixes

    • Updated gas drop display logic to generalize decimal representation based on airdrop amounts.
  • Improvements

    • Enhanced refund process in the FastBridgeV2 contract with additional transaction status checks.
  • Version Updates

    • Incremented package versions for @synapsecns/contracts-rfq (0.5.6 to 0.5.7) and @synapsecns/synapse-interface (0.40.0 to 0.40.1).

911813d: synapse-interface preview link

parodime and others added 4 commits September 26, 2024 14:29
* rearrange refund validation checks [SLT-185]

* test: fix own incorrectly defined tests

---------

Co-authored-by: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com>
 - @synapsecns/contracts-rfq@0.5.7
…SDK gasAirdropAmount [SLT-269] (#3196)

* Generalizes airdrop decimal display based on SDK gasAirdropAmount
 - @synapsecns/synapse-interface@0.40.1
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The pull request introduces several updates across multiple packages, primarily focusing on version bumps and enhancements to the refund function in the FastBridgeV2 contract. The function now includes an additional check for transaction status, ensuring it only processes refunds when the transaction is in the REQUESTED state. Additionally, the synapse-interface package sees improvements in the display logic for gas drop amounts and the introduction of a utility function for calculating significant decimal places.

Changes

File Change Summary
packages/contracts-rfq/CHANGELOG.md Updated changelog for version 0.5.7, indicating a version bump only.
packages/contracts-rfq/contracts/FastBridgeV2.sol Modified refund function to include a transaction status check before processing refunds.
packages/contracts-rfq/package.json Version updated from 0.5.6 to 0.5.7.
packages/contracts-rfq/test/FastBridgeV2.Src.t.sol Updated test functions to use tokenTx instead of ethTx in refund calls.
packages/synapse-interface/CHANGELOG.md Updated changelog for version 0.40.1, documenting a bug fix related to airdrop display.
packages/synapse-interface/components/StateManagedBridge/BridgeExchangeRateInfo.tsx Enhanced gas drop amount display logic and adjusted airdrop dollar amount formatting.
packages/synapse-interface/package.json Version updated from 0.40.0 to 0.40.1.
packages/synapse-interface/utils/getSignificantDecimals.ts Introduced getSignificantDecimals utility function for calculating significant decimal places.
packages/synapse-interface/utils/hooks/useCoingeckoPrice.ts Changed key for "Metis" in ID_MAP from METIS to Metis.

Possibly related PRs

Suggested labels

M-synapse-interface, M-contracts, size/s, Sol, Typescript, M-deps, 2-reviewers

Suggested reviewers

  • aureliusbtc
  • bigboydiamonds
  • ChiTimesChi
  • trajan0x

🐇 In the garden of code, changes bloom bright,
With refunds now checked, all feels just right.
Airdrops displayed with decimals so fair,
In the world of contracts, we show that we care.
Hoppity hop, let the updates take flight,
For in every small change, there's joy and delight! 🌼

Warning

Review ran into problems

🔥 Problems

Error running LanguageTool: LanguageTool error: Unknown error


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.

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

🧹 Outside diff range and nitpick comments (4)
packages/synapse-interface/utils/getSignificantDecimals.ts (2)

1-6: Function signature looks good, but consider adding a safety check.

The function signature is well-defined with clear types. However, to improve robustness, consider adding a check for the existence of parts[1] before assigning it to decimalPart.

You could modify line 6 as follows:

-  const decimalPart = parts[1]
+  const decimalPart = parts[1] || ''

This ensures decimalPart is always a string, even if there's no decimal point in the input.


1-23: Consider adding documentation for the function.

While the function is generally well-implemented, it lacks documentation. Adding a brief comment explaining the function's purpose, parameters, return value, and any important considerations (like how it handles trailing zeros) would improve its maintainability and usability.

Consider adding a JSDoc comment above the function, like this:

/**
 * Calculates the number of significant decimal places in a given number string.
 * @param numberString - The number as a string to analyze.
 * @param defaultDecimals - The number of decimal places to return if the string consists of only zeros after the decimal point. Defaults to 2.
 * @returns The number of significant decimal places.
 * @example
 * getSignificantDecimals("123.4560") // returns 4
 * getSignificantDecimals("123.0000", 2) // returns 2
 */
export const getSignificantDecimals = (
  // ... rest of the function
packages/synapse-interface/components/StateManagedBridge/BridgeExchangeRateInfo.tsx (1)

210-210: Improved currency-specific decimal handling, but consider scalability.

The changes in getAirdropInDollars function improve the handling of decimal places for different currencies:

  1. The introduction of the decimals variable allows for currency-specific precision.
  2. Using decimals in toFixed ensures appropriate rounding for each currency.

While this is an improvement, the current implementation might not scale well if more currencies require different decimal precisions.

Consider a more scalable approach, such as:

  1. Creating a mapping of currencies to their required decimal places.
  2. Using a default value for currencies not in the mapping.

Example:

const CURRENCY_DECIMALS = {
  'JEWEL': 4,
  // Add more currencies as needed
};
const DEFAULT_DECIMALS = 2;

// In the function:
const decimals = CURRENCY_DECIMALS[symbol] || DEFAULT_DECIMALS;

This approach would be more maintainable as new currencies are added.

Also applies to: 216-216

packages/contracts-rfq/test/FastBridgeV2.Src.t.sol (1)

914-914: LGTM with a minor suggestion: Fix typo in function name.

The refund call in the test_refund_revert_justBeforeDeadline_permisionless function correctly tests the expected revert behavior for a permissionless refund attempt just before the deadline.

However, there's a typo in the function name:

-    function test_refund_revert_justBeforeDeadline_permisionless(address caller) public {
+    function test_refund_revert_justBeforeDeadline_permissionless(address caller) public {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0d41bd0 and 257e57c.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • packages/contracts-rfq/CHANGELOG.md (1 hunks)
  • packages/contracts-rfq/contracts/FastBridgeV2.sol (2 hunks)
  • packages/contracts-rfq/package.json (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Src.t.sol (1 hunks)
  • packages/synapse-interface/CHANGELOG.md (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/BridgeExchangeRateInfo.tsx (3 hunks)
  • packages/synapse-interface/package.json (1 hunks)
  • packages/synapse-interface/utils/getSignificantDecimals.ts (1 hunks)
  • packages/synapse-interface/utils/hooks/useCoingeckoPrice.ts (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/contracts-rfq/CHANGELOG.md
  • packages/contracts-rfq/package.json
  • packages/synapse-interface/package.json
  • packages/synapse-interface/utils/hooks/useCoingeckoPrice.ts
🔇 Additional comments (11)
packages/synapse-interface/utils/getSignificantDecimals.ts (2)

8-12: Initial checks are well-implemented.

The checks for no decimal part and for decimal parts consisting only of zeros are correct and efficient. Using defaultDecimals for strings of all zeros is a good approach, allowing for customizable precision in such cases.


22-22: Return statement is correct.

The function correctly returns the count of significant decimals.

packages/synapse-interface/components/StateManagedBridge/BridgeExchangeRateInfo.tsx (3)

14-14: LGTM: New utility function import added.

The addition of the getSignificantDecimals import is appropriate for the changes made in the GasDropLabel component. This promotes better code organization by separating utility functions.


146-147: Improved flexibility in gas drop amount display.

The changes in the GasDropLabel component enhance the display of gas drop amounts:

  1. The introduction of stringifiedGasAmount and the use of getSignificantDecimals allow for dynamic calculation of decimal places.
  2. Using significantDecimals in formatBigIntToString ensures that the displayed amount is always meaningful and appropriate for the value.

This approach is more flexible and maintainable than the previous hardcoded logic.

Also applies to: 152-152


Line range hint 1-218: Overall improvements in value display and code flexibility.

The changes in this file enhance the display of gas drop amounts and airdrop values:

  1. The introduction of getSignificantDecimals improves the flexibility of decimal place display for gas drop amounts.
  2. The modifications in getAirdropInDollars allow for currency-specific decimal precision.

These changes make the code more maintainable and adaptable to different scenarios. The overall structure of the file remains intact, and the changes align well with the provided AI-generated summary.

While the improvements are significant, consider the scalability suggestion for currency-specific decimal handling to future-proof the code.

packages/contracts-rfq/contracts/FastBridgeV2.sol (3)

277-279: Improved security with additional status check

The new check if (bridgeStatuses[transactionId] != BridgeStatus.REQUESTED) revert StatusIncorrect(); enhances the security of the refund function. It ensures that only transactions in the REQUESTED state can be refunded, preventing potential issues with transactions in other states.


290-290: Enhanced clarity in status update comment

The updated comment "if all checks passed, set to REFUNDED status" provides better clarity on when the transaction status is set to REFUNDED. This change accurately reflects the function's logic and improves code readability.


Line range hint 277-290: Summary: Improved refund function security and clarity

The changes to the refund function in the FastBridgeV2 contract enhance both security and clarity:

  1. The new status check ensures that only transactions in the REQUESTED state can be refunded, preventing potential issues with transactions in other states.
  2. The updated comment provides better clarity on when the transaction status is set to REFUNDED.

These improvements align well with the contract's overall design and contribute to its robustness and maintainability.

packages/contracts-rfq/test/FastBridgeV2.Src.t.sol (2)

899-899: LGTM: Refund test implementation looks correct.

The refund call in the test_refund_revert_zeroDelay function is correctly implemented, testing the expected revert behavior when attempting a refund with zero delay.


906-906: LGTM: Refund test for just before deadline is properly implemented.

The refund call in the test_refund_revert_justBeforeDeadline function correctly tests the expected revert behavior when attempting a refund just before the deadline.

packages/synapse-interface/CHANGELOG.md (1)

6-11: LGTM! Good practices observed in this changelog entry.

The changelog entry for version 0.40.1 is well-structured and informative. It's great to see:

  1. A clear description of the bug fix.
  2. Reference to the specific ticket (SLT-269) for traceability.
  3. Link to the exact commit (aa37b50) that implements this change.

These practices make it easier for developers and stakeholders to understand and track changes in the project.

Copy link

codecov bot commented Sep 26, 2024

Bundle Report

Changes will decrease total bundle size by 1.76kB (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
synapse-interface-client-array-push 7.28MB 147 bytes (0.0%) ⬆️
synapse-interface-server-cjs 1.49MB 127 bytes (0.01%) ⬆️
widget-cjs-esm 271.27kB 2.03kB (-0.74%) ⬇️

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.62247%. Comparing base (e897b18) to head (257e57c).
Report is 36 commits behind head on fe-release.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           fe-release       #3200          +/-   ##
=====================================================
+ Coverage    38.35432%   90.62247%   +52.26815%     
=====================================================
  Files             424          60         -364     
  Lines           24464        1237       -23227     
  Branches          148         148                  
=====================================================
- Hits             9383        1121        -8262     
+ Misses          14335         112       -14223     
+ Partials          746           4         -742     
Flag Coverage Δ
cctp-relayer ?
core ?
ethergo ?
git-changes-action ?
omnirpc ?
opbot ?
packages 90.56974% <ø> (ø)
screener-api ?
scribe ?
solidity 90.86758% <100.00000%> (ø)
tools ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Defi-Moses Defi-Moses self-requested a review September 26, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants