13 lines
318 B
TypeScript
13 lines
318 B
TypeScript
import { Decimal } from '../../common/decimal';
|
|
|
|
const NANO = 1_000_000_000n;
|
|
|
|
export type ProtoDecimal = { units?: string | number; nano?: string | number };
|
|
|
|
export function decimal(value: ProtoDecimal): Decimal {
|
|
return {
|
|
value: BigInt(value.units ?? 0) * NANO + BigInt(value.nano ?? 0),
|
|
scale: 9,
|
|
};
|
|
}
|