chore: add missing ParseUnit impls (#1885)

This commit is contained in:
Matthias Seitz 2022-11-22 22:08:23 +01:00 committed by GitHub
parent 49dc487676
commit f4b6178332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -35,7 +35,10 @@ use crate::types::{Address, Bytes, ParseI256Error, I256, U256};
use elliptic_curve::sec1::ToEncodedPoint; use elliptic_curve::sec1::ToEncodedPoint;
use ethabi::ethereum_types::FromDecStrErr; use ethabi::ethereum_types::FromDecStrErr;
use k256::{ecdsa::SigningKey, PublicKey as K256PublicKey}; use k256::{ecdsa::SigningKey, PublicKey as K256PublicKey};
use std::convert::{TryFrom, TryInto}; use std::{
convert::{TryFrom, TryInto},
fmt,
};
use thiserror::Error; use thiserror::Error;
/// Re-export of serde-json /// Re-export of serde-json
@ -80,7 +83,7 @@ pub const EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE: i64 = 200;
/// This enum holds the numeric types that a possible to be returned by `parse_units` and /// This enum holds the numeric types that a possible to be returned by `parse_units` and
/// that are taken by `format_units`. /// that are taken by `format_units`.
#[derive(Copy, Clone)] #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub enum ParseUnits { pub enum ParseUnits {
U256(U256), U256(U256),
I256(I256), I256(I256),
@ -95,6 +98,15 @@ impl From<ParseUnits> for U256 {
} }
} }
impl fmt::Display for ParseUnits {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ParseUnits::U256(val) => val.fmt(f),
ParseUnits::I256(val) => val.fmt(f),
}
}
}
macro_rules! construct_format_units_from { macro_rules! construct_format_units_from {
($( $t:ty[$convert:ident] ),*) => { ($( $t:ty[$convert:ident] ),*) => {
$( $(