-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add undefined check for trade order #10754
fix: Add undefined check for trade order #10754
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
96d3522
to
5e31023
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure on sdk typing end we don't allow undefined trade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On https://github.com/pancakeswap/pancake-frontend/blob/develop/apps/web/src/views/Swap/V3Swap/hooks/useSwapBestTrade.ts#L181 , trade is set to undefined as well as it can be set to undefined from this hook https://github.com/pancakeswap/pancake-frontend/blob/develop/apps/web/src/hooks/useBestAMMTrade.ts . So imo type should contain undefined therefore it must be checked on compile time when it is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't make sense if we have a order with type but no trade. Let's make sure if we initialize a order it has to have a valid trade or we don't initialize the order at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, @chefjackson you can review it again
5e31023
to
ff50f27
Compare
1ad2e5f
to
1cd3b89
Compare
PR-Codex overview
This PR focuses on improving the handling of optional values in the
useAllTypeBestTrade
hook and theV3SwapForm
component. It ensures that properties are accessed safely, preventing potential runtime errors when values are undefined.Detailed summary
classicAmmOrder
to returnundefined
ifammCurrentTrade
is falsy.bestOrder
type to allowundefined
.validTrade
assignment to safely accessammOrder.trade
.ammInputAmount
andammOutputAmount
to safely access values fromammOrder
.ammOrder
structure to safely accesstype
.