Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

ethers::utils::format_ether should show decimal places #2435

Merged
merged 1 commit into from
May 27, 2023

Conversation

0xAndoroid
Copy link
Contributor

Motivation

Well, I've just spent 30 minutes trying to understand why I see 0 ETH as the output of my code. Turns out, it was a problem in prase_ether function. Noticed an issue #2356

Solution

Use parse_units(value, "ether").unwrap();
We can safely unwrap here, since parse_units returns Err only when units >= 77.

PR Checklist

  • [ x ] Added Tests
  • [ x ] Added Documentation
  • [ x ] Breaking changes

@DaniPopes
Copy link
Collaborator

This is great, thanks! It's a small enough breaking change that I'm OK with releasing this in a patch or minor version, wdyt @gakonst @prestwich?

@prestwich prestwich merged commit 334bf32 into gakonst:master May 27, 2023
@prestwich
Copy link
Collaborator

prestwich commented May 27, 2023

This is great, thanks! It's a small enough breaking change that I'm OK with releasing this in a patch or minor version, wdyt @gakonst @prestwich?

agreed

@0xAndoroid 0xAndoroid deleted the format_ether_fix branch May 27, 2023 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants