-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update charts to use best te unit for values (#527)
* fix: Update `DailyAvgBlobFeeChart` and `DailyAvgBlobGasPriceChart` to use best unit for values * chore: update changeset * Revert `prettyFormatWei` function * feat: Adds useArrayBestUnit * fix: Update DailyAvgBlobFeeChart to use best unit for values * feat: Update DailyAvgMaxBlobGasFeeChart to use formatted number in yAxisTooltip * feat: Adds yAxisLabel DailyAvgMaxBlobGasFeeChart * chore: Added EthAmount * refactor: useArrayBestUnit * refactor: useScaledWeiAmounts nitpicks * refactor: Update `countIntegerDigits` function to handle scientific notation in eth-format * feat: Update yAxisLabel in DailyAvgBlobFeeChart, DailyAvgBlobGasPriceChart, DailyBlobFeeChart and DailyAvgMaxBlobGasFeeChart * chore: Update DailyAvgMaxBlobGasFeeChart grid configuration * chore: Update grid configuration for DailyAvgBlobFeeChart, DailyAvgBlobGasPriceChart, and DailyBlobFeeChart
- Loading branch information
1 parent
399c98c
commit c9a6ada
Showing
8 changed files
with
106 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blobscan/web": patch | ||
--- | ||
|
||
Updated `DailyAvgBlobFeeChart` and `DailyAvgBlobGasPriceChart` to use the best unit for values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useMemo } from "react"; | ||
|
||
import type { EtherUnit } from "@blobscan/eth-units"; | ||
import { convertWei, findBestUnit } from "@blobscan/eth-units"; | ||
|
||
type ScaledWeiAmounts = { | ||
unit: EtherUnit; | ||
scaledValues?: string[]; | ||
}; | ||
|
||
export function useScaledWeiAmounts(arr?: number[], toUnit?: EtherUnit) { | ||
return useMemo<ScaledWeiAmounts>(() => { | ||
if (!arr) { | ||
return { | ||
unit: "wei", | ||
}; | ||
} | ||
|
||
const unit = toUnit ?? findBestUnit(Math.max(...arr)); | ||
|
||
return { | ||
unit, | ||
scaledValues: arr.map((item) => convertWei(item, unit)), | ||
}; | ||
}, [arr, toUnit]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters