Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add From<FPDecimal> for Uint256 for FPDecimal #217

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/injective-math/src/fp_decimal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ impl From<Uint128> for FPDecimal {
}
}

impl From<FPDecimal> for Uint256 {
fn from(value: FPDecimal) -> Self {
value.to_u256()
}
Comment on lines +75 to +78
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation for the From<FPDecimal> for Uint256 implementation.

It's important to document how the conversion handles the sign of FPDecimal and any potential edge cases. This will help future developers understand the conversion process better and ensure correct usage.

}

impl From<Uint256> for FPDecimal {
fn from(x: Uint256) -> FPDecimal {
FPDecimal::from_str(&x.to_string()).unwrap()
Expand Down
Loading