Skip to content

refactor: use big decimal when formatting units#189

Merged
ItsANameToo merged 2 commits intofeat/mainsailfrom
refactor/use-big-decimal-when-formatting-units
Mar 10, 2026
Merged

refactor: use big decimal when formatting units#189
ItsANameToo merged 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.

@ItsANameToo ItsANameToo merged commit 92b95bf into feat/mainsail Mar 10, 2026
2 checks passed
@ItsANameToo ItsANameToo deleted the refactor/use-big-decimal-when-formatting-units branch March 10, 2026 14:07
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.

3 participants