Skip to content

Commit

Permalink
feat: permit2 flag (#320)
Browse files Browse the repository at this point in the history
* feat: add permit2 flag

* test: use permit2 in test fixtures
  • Loading branch information
zzmp authored Dec 5, 2022
1 parent 221ae44 commit 0832a06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cosmos/ControlledSwap.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function Fixture() {
return (
<Row flex align="start" justify="start" gap={0.5}>
<SwapWidget
permit2
value={{
type,
amount,
Expand Down
1 change: 1 addition & 0 deletions src/cosmos/Swap.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function Fixture() {

const widget = (
<SwapWidget
permit2
convenienceFee={convenienceFee}
convenienceFeeRecipient={convenienceFeeRecipient}
defaultInputTokenAddress={defaultInputToken}
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/useSyncFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import { useMemo } from 'react'
// Flags are sticky settings - they cannot be changed without remounting the Widget.
export interface Flags {
brandedFooter?: boolean
permit2?: boolean
}

const flagsAtom = atom<Flags>({})

export function useInitialFlags({ brandedFooter }: Flags): [[Atom<Flags>, Flags]] {
export function useInitialFlags({ brandedFooter, permit2 }: Flags): [[Atom<Flags>, Flags]] {
// Only grab the initial flags on mount - ignore exhaustive-deps.
// eslint-disable-next-line react-hooks/exhaustive-deps
return useMemo(() => [[flagsAtom, { brandedFooter }]], [])
return useMemo(() => [[flagsAtom, { brandedFooter, permit2 }]], [])
}

export function useBrandedFooter() {
return useAtomValue(flagsAtom).brandedFooter ?? true
}

export function usePermit2() {
return useAtomValue(flagsAtom).permit2 ?? false
}

1 comment on commit 0832a06

@vercel
Copy link

@vercel vercel bot commented on 0832a06 Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-seven-tau.vercel.app
widgets-uniswap.vercel.app
widgets-git-main-uniswap.vercel.app

Please sign in to comment.