-
Notifications
You must be signed in to change notification settings - Fork 102
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
feat(permit): allowance warning #3184
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
apps/cowswap-frontend/src/modules/ordersTable/pure/OrdersTableContainer/OrderRow/index.tsx
Outdated
Show resolved
Hide resolved
const recoveredOwner = await recoverPermitOwnerPromise | ||
|
||
// Permit is valid when recovered owner matches order owner | ||
return recoveredOwner.toLowerCase() === order.owner.toLowerCase() |
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.
This is it.
If recovered owner matches order owner, permit is still valid!
// TODO: Any way to make this typing mess any cleaner? | ||
if (decodedValues && typeof decodedValues === 'object') { | ||
const copy: Record<string, any> = {} | ||
|
||
Object.keys(decodedValues).forEach((key) => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
const value = decodedValues[key] | ||
if (BigNumber.isBigNumber(value)) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
copy[key] = value.toHexString() | ||
} else { | ||
copy[key] = value | ||
} | ||
}) | ||
console.log(`bug--decodeABIParameters`, decodedValues, copy) | ||
|
||
return copy as T | ||
} |
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.
Open to suggestions on how to make this better/with no @ts-ignore
s
apps/cowswap-frontend/src/modules/ordersTable/containers/OrdersTableWidget/index.tsx
Outdated
Show resolved
Hide resolved
@@ -29,3 +29,5 @@ export const ORDER_TYPE_SUPPORTS_PERMIT: Record<TradeType, boolean> = { | |||
[TradeType.LIMIT_ORDER]: true, | |||
[TradeType.ADVANCED_ORDERS]: false, | |||
} | |||
|
|||
export const PENDING_ORDER_PERMIT_CHECK_INTERVAL = ms`1min` |
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.
Should we do it more often?
73fb2c1
to
a432bf6
Compare
apps/cowswap-frontend/src/modules/permit/state/ordersPermitStatusAtom.ts
Outdated
Show resolved
Hide resolved
apps/cowswap-frontend/src/modules/ordersTable/containers/OrdersTableWidget/index.tsx
Outdated
Show resolved
Hide resolved
@@ -410,6 +412,10 @@ export function OrdersTable({ | |||
if (isParsedOrder(item)) { | |||
const order = item | |||
|
|||
const orderParams = getOrderParams(chainId, balancesAndAllowances, order) |
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.
Aha, there is a key of the changes
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.
Works perfectly!
Checked even with different browsers - everything is good.
I've left a couple of comments, but they are about code style, feel free to ignore them.
Merging, please post merge review |
Summary
Fixes #3146
Update allowance warning check for limit orders
Now the UI will take into account permits still not executed when calculating whether the allowance warning should be displayed:
Before:
After:
TODO:
Move to jotai/updater
Check periodically
Test more use cases
Add it to Activity modal (SWAP orders)
To Test