Skip to content

Commit

Permalink
fix: parse permit with try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 committed Dec 17, 2024
1 parent aa89d3b commit 7a1be7c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ export function getOrderPermitAmount(chainId: SupportedChainId, order: ParsedOrd
if (!preHooks) return null

const permitData = preHooks
.map((hook) => erc20Interface.decodeFunctionData('permit', hook.callData))
.map((hook) => {
try {
return erc20Interface.decodeFunctionData('permit', hook.callData)
} catch {
return null
}
})
.find((decoded) => {
return (
decoded &&
decoded.spender?.toLowerCase() === spenderAddress &&
decoded.owner?.toLowerCase() === order.owner.toLowerCase() &&
(decoded.deadline as BigNumber)?.toNumber() > Date.now() / 1000
Expand Down

0 comments on commit 7a1be7c

Please sign in to comment.