rainbow-me / rainbow

🌈‒ the Ethereum wallet that lives in your pocket
https://rainbow.me
GNU General Public License v3.0
3.82k stars 590 forks source link

add safe math fns #5765

Closed brunobar79 closed 1 month ago

brunobar79 commented 1 month ago

Fixes APP-####

What changed (plus any additional context for devs)

Wrote basic math functions to safely deal with big numbers operations without any extra dependency (so it can be used in worklets).

Added tests including comparing results with BigNumber.js library which we know it's accurate

Screen recordings / screenshots

Screenshot 2024-05-23 at 6 24 13 PM

What to test

christianbaroni commented 1 month ago

Thoughts on adding validation given the broadness of the string type? Something like:

const isNumberString = (value: string): boolean => {
  return /^\d+(\.\d+)?$/.test(value);
};