Skip to content

Commit

Permalink
🩹 fix capacity formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Mar 6, 2024
1 parent bb78c7f commit 4dd0688
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/metadata/slots/template/data.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,26 @@ fn generate_sdgs_rows_(storage: StorageData, sdgs: Span<u8>) -> String {

#[inline(always)]
fn format_capacity_(capacity: u256) -> String {
if capacity < 1000 {
if capacity < 1_000 {
let mut res = capacity.to_ascii();
res.append('g');
res.span()
} else if capacity < 1000000 {
let mut res = (capacity / 1000).to_ascii();
} else if capacity < 1_000_000 {
let mut res = (capacity / 1_000).to_ascii();
res.append('kg');
res.span()
} else {
} else if capacity < 1_000_000_000 {
let mut res = (capacity / 1_000_000).to_ascii();
res.append('t');
res.span()
} else if capacity < 1_000_000_000_000 {
let mut res = (capacity / 1_000_000_000).to_ascii();
res.append('kt');
res.span()
} else {
let mut res = (capacity / 1_000_000_000_000).to_ascii();
res.append('Mt');
res.span()
}
}

Expand Down

0 comments on commit 4dd0688

Please sign in to comment.