yearn / seafood

Seafood
https://seafood.yearn.watch
13 stars 21 forks source link

fix: add safety checks #119

Closed Majorfi closed 1 year ago

Majorfi commented 1 year ago

Add some safety checks to prevent crashed on undefined.

We have this function in the web-lib that could help to avoid theses issues:

export const formatBN = (amount?: BigNumberish): BigNumber => {
    return BigNumber.from(amount || 0);
};

I also suggest to add the ?. notation for all nested properties and to always use a fallback!

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
seafood ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 10, 2023 at 3:27AM (UTC)
Majorfi commented 1 year ago

Hey!

I would agree with you on the expect/don't expect, but I got rug way too many time so now I tend to put checks everywhere to avoid app-crash It's not the nicest code, but this save some hotfixes later imo

But this should not prevent the data to be here, indeed