Skip to content

refactor: use big decimal when formatting units#189

Open
alexbarnsley wants to merge 2 commits intofeat/mainsailfrom
refactor/use-big-decimal-when-formatting-units
Open

refactor: use big decimal when formatting units#189
alexbarnsley wants to merge 2 commits intofeat/mainsailfrom
refactor/use-big-decimal-when-formatting-units

Conversation

@alexbarnsley
Copy link
Member

Summary

https://app.clickup.com/t/86e00vrp2

Checklist

  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

Copilot AI review requested due to automatic review settings March 4, 2026 21:18
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 refactors unit formatting to use Brick\Math\BigDecimal instead of float, improving precision and avoiding float rounding issues when converting from wei to gwei/ark.

Changes:

  • Update UnitConverter::formatUnits() to return BigDecimal and perform division via BigDecimal::dividedBy(...).
  • Expand UnitConverterTest coverage for formatUnits() using data providers and string comparisons.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Utils/UnitConverter.php Switch formatUnits() from bcdiv()+float to BigDecimal division and return type.
tests/Unit/Utils/UnitConverterTest.php Update/expand tests to validate exact decimal string outputs from formatUnits().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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