Skip to content
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
15 changes: 15 additions & 0 deletions apps/web/public/.well-known/farcaster.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"accountAssociation": {
"header": "eyJmaWQiOjM2MjEsInR5cGUiOiJjdXN0b2R5Iiwia2V5IjoiMHgyY2Q4NWEwOTMyNjFmNTkyNzA4MDRBNkVBNjk3Q2VBNENlQkVjYWZFIn0",
"payload": "eyJkb21haW4iOiJ1bmlmcmFtZS5vcmcifQ",
"signature": "MHgxZTZlZTkyNmRiZjU5ZDljZjM4MGI1YTU0ZTI2YzUxYjEyN2MyZjM2NTM3ZDJhYWI5ZGZjOTBiMDVlMjRjY2U4MzYxZDk5YmRhOGZmYWU0NjliZTY0ZWNlZTVhZTA5MjYzNWM5NjVlYzFmZmRjNDEwOGZiNjJlNmRmYmRiM2VkNDFi"
},
"frame": {
"name": "Uniframe",
"version": "0.0.1",
"iconUrl": "https://uniframe.org/favicon.png",
"homeUrl": "https://uniframe.org/#/swap",
"splashImageUrl": "https://uniframe.org/favicon.png",
"splashBackgroundColor": "#131313"
}
}
14 changes: 14 additions & 0 deletions apps/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#fff" />
<meta name="format-detection" content="telephone=no">
<meta name="fc:frame" content='{
"version": "next",
"imageUrl": "https://uniframe.org/images/1200x630_Rich_Link_Preview_Image.png",
"button":{
"title": "Swap",
"action": {
"type": "launch_frame",
"name": "Uniframe",
"url": "https://uniframe.org/swap",
"splashImageUrl": "https://uniframe.org/favicon.png",
"splashBackgroundColor": "#131313"
}
}
}' data-rh="true">

<!-- Skip the CSP in specified test environments -->
<% if (!process.env.REACT_APP_SKIP_CSP) { %>
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/components/Web3Provider/wagmiConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { farcasterFrame } from '@farcaster/frame-wagmi-connector'
import { QueryClient } from '@tanstack/react-query'
import { injectedWithFallback } from 'components/Web3Provider/injectedWithFallback'
import { WC_PARAMS } from 'components/Web3Provider/walletConnect'
Expand All @@ -19,6 +20,7 @@ declare module 'wagmi' {
export const wagmiConfig = createConfig({
chains: [getChainInfo(UniverseChainId.Mainnet), ...ALL_CHAIN_IDS.map(getChainInfo)],
connectors: [
farcasterFrame(),
injectedWithFallback(),
walletConnect(WC_PARAMS),
coinbaseWallet({
Expand Down
29 changes: 28 additions & 1 deletion apps/web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import 'sideEffects'

import { getDeviceId } from '@amplitude/analytics-browser'
import { ApolloProvider } from '@apollo/client'
import FrameSDK from '@farcaster/frame-sdk'
import farcasterFrame from '@farcaster/frame-wagmi-connector'
import { PortalProvider } from '@tamagui/portal'
import { QueryClientProvider } from '@tanstack/react-query'
import { MiniKit } from '@worldcoin/minikit-js'
import Web3Provider, { Web3ProviderUpdater } from 'components/Web3Provider'
import { WebUniswapProvider } from 'components/Web3Provider/WebUniswapContext'
import { wagmiConfig } from 'components/Web3Provider/wagmiConfig'
import { AssetActivityProvider } from 'graphql/data/apollo/AssetActivityProvider'
import { TokenBalancesProvider } from 'graphql/data/apollo/TokenBalancesProvider'
import { apolloClient } from 'graphql/data/apollo/client'
Expand Down Expand Up @@ -41,6 +44,7 @@ import { UnitagUpdaterContextProvider } from 'uniswap/src/features/unitags/conte
import { isBrowserRouterEnabled } from 'utils/env'
import { unregister as unregisterServiceWorker } from 'utils/serviceWorker'
import { getCanonicalUrl } from 'utils/urlRoutes'
import { connect } from 'wagmi/actions'

if (window.ethereum) {
window.ethereum.autoRefreshOnNetworkChange = false
Expand Down Expand Up @@ -111,6 +115,27 @@ function MiniKitProvider({ children }: PropsWithChildren) {
return <>{children}</>
}

function FarcasterFrameProvider({ children }: PropsWithChildren) {
useEffect(() => {
const init = async () => {
const context = await FrameSDK.context

// Autoconnect if running in a frame.
if (context?.client.clientFid) {
connect(wagmiConfig, { connector: farcasterFrame() })
}

// Hide splash screen after UI renders.
setTimeout(() => {
FrameSDK.actions.ready()
}, 500)
}
init()
}, [])

return <>{children}</>
}

const container = document.getElementById('root') as HTMLElement

const Router = isBrowserRouterEnabled() ? BrowserRouter : HashRouter
Expand All @@ -136,7 +161,9 @@ createRoot(container).render(
<PortalProvider>
<ThemedGlobalStyle />
<MiniKitProvider>
<App />
<FarcasterFrameProvider>
<App />
</FarcasterFrameProvider>
</MiniKitProvider>
</PortalProvider>
</TamaguiProvider>
Expand Down