Skip to content

Commit

Permalink
impl Felt.to_bigint() method
Browse files Browse the repository at this point in the history
  • Loading branch information
pefontana committed Dec 18, 2023
1 parent 8a86316 commit dd7580e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/starknet-types-core/src/felt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ impl Felt {
.collect();
BigUint::new(big_digits)
}

pub fn to_bigint(&self) -> BigInt {
self.to_biguint().to_bigint().unwrap()
}
}

#[cfg(feature = "arbitrary")]
Expand Down Expand Up @@ -833,10 +837,6 @@ mod arithmetic {
}
}

pub fn felt_to_bigint(felt: Felt) -> BigInt {
felt.to_biguint().to_bigint().unwrap()
}

#[cfg(feature = "serde")]
mod serde {
use ::serde::{de, ser::SerializeSeq, Deserialize, Serialize};
Expand Down Expand Up @@ -1692,7 +1692,7 @@ mod test {

for number_str in numbers_str {
assert_eq!(
felt_to_bigint(Felt::from_hex(number_str).unwrap()),
Felt::from_hex(number_str).unwrap().to_bigint(),
BigInt::from_str_radix(&number_str[2..], 16).unwrap()
);

Expand Down

0 comments on commit dd7580e

Please sign in to comment.