Skip to content
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

Main -> develop #5203

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apps/cowswap-frontend": "1.93.1",
"apps/cowswap-frontend": "1.93.2",
"apps/explorer": "2.38.0",
"libs/permit-utils": "0.5.0",
"libs/widget-lib": "0.18.0",
Expand Down
7 changes: 7 additions & 0 deletions apps/cowswap-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.93.2](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.93.1...cowswap-v1.93.2) (2024-12-13)


### Bug Fixes

* **twap:** cache fb handler verification for 10min ([#5200](https://github.com/cowprotocol/cowswap/issues/5200)) ([c09f073](https://github.com/cowprotocol/cowswap/commit/c09f07338868654a89ba570987a8bc9bec59141c))

## [1.93.1](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.93.0...cowswap-v1.93.1) (2024-12-12)


Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cowswap",
"version": "1.93.1",
"version": "1.93.2",
"description": "CoW Swap",
"main": "index.js",
"author": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export async function verifyExtensibleFallback(
try {
const domainVerifier = await signatureVerifierContract.callStatic.domainVerifiers(safeAddress, domainSeparator)

console.log('FALLBACK HANDLER CHECKED, domainVerifier: ', domainVerifier)
if (domainVerifier.toLowerCase() === composableCowContractAddress.toLowerCase()) {
return ExtensibleFallbackVerification.HAS_DOMAIN_VERIFIER
}

return ExtensibleFallbackVerification.HAS_EXTENSIBLE_FALLBACK
} catch {
} catch (e) {
console.log('FALLBACK HANDLER CHECKED, error: ', e)
return ExtensibleFallbackVerification.HAS_NOTHING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,41 @@ import { useEffect } from 'react'

import { useWalletInfo } from '@cowprotocol/wallet'

import ms from 'ms.macro'
import { useAsyncMemo } from 'use-async-memo'

import { useExtensibleFallbackContext } from '../hooks/useExtensibleFallbackContext'
import { useFallbackHandlerVerification } from '../hooks/useFallbackHandlerVerification'
import { ExtensibleFallbackVerification, verifyExtensibleFallback } from '../services/verifyExtensibleFallback'
import { updateFallbackHandlerVerificationAtom } from '../state/fallbackHandlerVerificationAtom'

const FB_CACHE_TIME = ms`10m`
const FB_UPDATE_TIME_KEY = 'fallbackHandlerUpdateTime'

export function FallbackHandlerVerificationUpdater() {
const { account } = useWalletInfo()
const update = useSetAtom(updateFallbackHandlerVerificationAtom)
const verification = useFallbackHandlerVerification()
const isFallbackHandlerRequired = verification !== ExtensibleFallbackVerification.HAS_DOMAIN_VERIFIER

const fallbackHandlerUpdateTime = localStorage.getItem(FB_UPDATE_TIME_KEY)
const isCacheOutdated = !fallbackHandlerUpdateTime || Date.now() - +fallbackHandlerUpdateTime > FB_CACHE_TIME

const extensibleFallbackContext = useExtensibleFallbackContext()
const fallbackHandlerVerification = useAsyncMemo(
() =>
extensibleFallbackContext && isFallbackHandlerRequired
extensibleFallbackContext && (isFallbackHandlerRequired || isCacheOutdated)
? verifyExtensibleFallback(extensibleFallbackContext)
: null,
[isFallbackHandlerRequired, extensibleFallbackContext],
null
[isFallbackHandlerRequired, isCacheOutdated, extensibleFallbackContext],
null,
)

useEffect(() => {
if (!account || fallbackHandlerVerification === null) return

update({ [account]: fallbackHandlerVerification })
localStorage.setItem(FB_UPDATE_TIME_KEY, Date.now().toString())
}, [fallbackHandlerVerification, update, account])

return null
Expand Down
Loading