(value, unit)
| 55 | * or the name of a unit (e.g. ``"gwei"`` for 9 decimal places). |
| 56 | */ |
| 57 | export function parseUnits(value, unit) { |
| 58 | assertArgument(typeof (value) === "string", "value must be a string", "value", value); |
| 59 | let decimals = 18; |
| 60 | if (typeof (unit) === "string") { |
| 61 | const index = names.indexOf(unit); |
| 62 | assertArgument(index >= 0, "invalid unit", "unit", unit); |
| 63 | decimals = 3 * index; |
| 64 | } |
| 65 | else if (unit != null) { |
| 66 | decimals = getNumber(unit, "unit"); |
| 67 | } |
| 68 | return FixedNumber.fromString(value, { decimals, width: 512 }).value; |
| 69 | } |
| 70 | /** |
| 71 | * Converts %%value%% into a //decimal string// using 18 decimal places. |
| 72 | */ |
no test coverage detected