diff --git a/cypress/e2e/permit2.test.ts b/cypress/e2e/permit2.test.ts index 4abcc743ce..325f8945ae 100644 --- a/cypress/e2e/permit2.test.ts +++ b/cypress/e2e/permit2.test.ts @@ -29,7 +29,7 @@ describe('Permit2', () => { cy.hardhat() .then(({ approval, wallet }) => approval.getTokenAllowanceForPermit2({ owner: wallet, token: inputToken })) .then((allowance) => { - Cypress.log({ name: `Token allowace: ${allowance.toString()}` }) + Cypress.log({ name: `Token allowance: ${allowance.toString()}` }) cy.wrap(allowance).should('deep.equal', MaxUint256) }) } @@ -39,7 +39,7 @@ describe('Permit2', () => { cy.hardhat() .then(({ approval, wallet }) => approval.getPermit2Allowance({ owner: wallet, token: inputToken })) .then((allowance) => { - Cypress.log({ name: `Permit2 allowace: ${allowance.amount.toString()}` }) + Cypress.log({ name: `Permit2 allowance: ${allowance.amount.toString()}` }) cy.wrap(allowance.amount).should('deep.equal', MaxUint160) // Asserts that the on-chain expiration is in 30 days, within a tolerance of 40 seconds. const THIRTY_DAYS_SECONDS = 2_592_000 diff --git a/src/lib/hooks/useBlockNumber.tsx b/src/lib/hooks/useBlockNumber.tsx index c4b047c5c5..094c7875c4 100644 --- a/src/lib/hooks/useBlockNumber.tsx +++ b/src/lib/hooks/useBlockNumber.tsx @@ -7,9 +7,9 @@ import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, const MISSING_PROVIDER = Symbol() const BlockNumberContext = createContext< | { - value?: number fastForward(block: number): void - mainnetValue?: number + block?: number + mainnetBlock?: number } | typeof MISSING_PROVIDER >(MISSING_PROVIDER) @@ -22,17 +22,17 @@ function useBlockNumberContext() { return blockNumber } -/** Requires that BlockUpdater be installed in the DOM tree. */ -export default function useBlockNumber(): number | undefined { - return useBlockNumberContext().value -} - export function useFastForwardBlockNumber(): (block: number) => void { return useBlockNumberContext().fastForward } +/** Requires that BlockUpdater be installed in the DOM tree. */ +export default function useBlockNumber(): number | undefined { + return useBlockNumberContext().block +} + export function useMainnetBlockNumber(): number | undefined { - return useBlockNumberContext().mainnetValue + return useBlockNumberContext().mainnetBlock } export function BlockNumberProvider({ children }: { children: ReactNode }) { @@ -106,13 +106,17 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) { const value = useMemo( () => ({ - value: chainId === activeChainId ? block : undefined, fastForward: (update: number) => { if (block && update > block) { - setChainBlock({ chainId: activeChainId, block: update }) + setChainBlock({ + chainId: activeChainId, + block: update, + mainnetBlock: activeChainId === ChainId.MAINNET ? update : mainnetBlock, + }) } }, - mainnetValue: mainnetBlock, + block: chainId === activeChainId ? block : undefined, + mainnetBlock, }), [activeChainId, block, chainId, mainnetBlock] )