lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

refactor: replace unsafe Number constructor with type-safe alternatives

Open IjayAbby opened this issue 9 months ago • 2 comments

Motivation

Remove usage of Number constructor

Description

The Number constructor is very unsafe because:

It takes any as parameter. If we change from passing a string to Number to some object Typescript will compile and we'll get NaN. If you do a text search of the Number constructor there are many occurrences:

If Number arg is already an argument, remove If Number arg is a string, use parseInt() If Number arg is a bigint, use a custom util that types like bigintToNumber(bn: bigint): number If the input of any of those functions is un-trusted data, verify the return is not NaN

Closes #3779

Steps to test or reproduce Run all tests

IjayAbby avatar Apr 30 '25 16:04 IjayAbby

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 30 '25 16:04 CLAassistant

there seem to be merge conflicts, this needs to be resolved, otherwise we can't run the CI

image

putting this into draft for now

nflaig avatar May 16 '25 20:05 nflaig

closing stale PR

wemeetagain avatar Sep 04 '25 15:09 wemeetagain

@wemeetagain I will get this one done tomorrow, apologies

IjayAbby avatar Sep 04 '25 18:09 IjayAbby

Hello @nflaig , i made a PR, kindly help review it, thank you

Beutife avatar Oct 17 '25 01:10 Beutife