Skip to content

Commit

Permalink
fix: added to use builtin min and max from i64
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobressan committed Oct 6, 2023
1 parent 8fa6dd4 commit 044d362
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use serde_json::Value as JsonValue;

use strum_macros::Display;

const JSON_MAX_SAFE_INTERGER: i128 = 9007199254740991;

// We're duplicating the Era struct from Pallas for two reasons: a) we need it
// to be serializable and we don't want to impose serde dependency on Pallas and
// b) we prefer not to add dependencies to Pallas outside of the sources that
Expand Down Expand Up @@ -386,7 +384,7 @@ fn serialize_int_scalar<S>(value: &i128, serializer: S) -> Result<S::Ok, S::Erro
where
S: Serializer,
{
if *value > JSON_MAX_SAFE_INTERGER || *value < -JSON_MAX_SAFE_INTERGER {
if *value > (i64::MAX as i128) || *value < (i64::MIN as i128) {
return value.to_string().serialize(serializer);
}

Expand Down

0 comments on commit 044d362

Please sign in to comment.