-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,703 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useAppKit, useAppKitAccount } from '@reown/appkit/react'; | ||
import { useCallback } from 'react'; | ||
import Jazzicon, { jsNumberForAddress } from 'react-jazzicon' | ||
|
||
import { Button } from './common/Button'; | ||
|
||
export function ConnectButton() { | ||
const { open } = useAppKit(); | ||
const { address } = useAppKitAccount(); | ||
|
||
const handleClick = useCallback(() => { | ||
open(); | ||
}, [open]); | ||
|
||
return ( | ||
<Button dataExist={ Boolean(address) } onClick={ handleClick }> | ||
{ address ? ( | ||
<div className="flex items-center gap-2"> | ||
<Jazzicon diameter={ 20 } seed={ jsNumberForAddress(address) } /> | ||
<span> | ||
{ address.slice(0, 4) }...{ address.slice(-4) } | ||
</span> | ||
</div> | ||
) : ( | ||
'Connect' | ||
) } | ||
</Button> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
type Props = { | ||
dataExist: boolean; | ||
onClick: () => void; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export function Button({ dataExist, onClick, children }: Props) { | ||
return ( | ||
<button | ||
className={` | ||
h-[40px] px-4 rounded-md transition-colors | ||
bg-[#2B6CB0] hover:bg-[#22568c] text-white | ||
data-[selected=true]:bg-[#1011120A] | ||
data-[selected=true]:hover:bg-[#1011120A] | ||
data-[selected=true]:text-[#101112CC] | ||
`} | ||
data-selected={ dataExist } | ||
onClick={ onClick } | ||
> | ||
{ children } | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { cookieStorage, createStorage } from '@wagmi/core'; | ||
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; | ||
import { mainnet, arbitrum } from '@reown/appkit/networks'; | ||
|
||
export const projectId = process.env.NEXT_PUBLIC_REOWN_PROJECT_ID; | ||
|
||
if (!projectId) { | ||
throw new Error('Project ID is not defined'); | ||
} | ||
|
||
export const networks = [mainnet, arbitrum]; | ||
|
||
//Set up the Wagmi Adapter (Config) | ||
export const wagmiAdapter = new WagmiAdapter({ | ||
storage: createStorage({ | ||
storage: cookieStorage | ||
}), | ||
ssr: true, | ||
projectId, | ||
networks, | ||
}); | ||
|
||
export const config = wagmiAdapter.wagmiConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use client'; | ||
|
||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { createAppKit } from '@reown/appkit/react'; | ||
import { mainnet, arbitrum } from '@reown/appkit/networks'; | ||
import React, { type ReactNode } from 'react'; | ||
import { cookieToInitialState, WagmiProvider, type Config } from 'wagmi'; | ||
|
||
import { wagmiAdapter, projectId } from '@/config/wagmi'; | ||
|
||
// Set up queryClient | ||
const queryClient = new QueryClient(); | ||
|
||
if (!projectId) { | ||
throw new Error('Project ID is not defined'); | ||
} | ||
|
||
// Set up metadata | ||
const metadata = { | ||
name: 'Swapscout', | ||
description: 'Swap between chains fast and easy. Powered by Blockscout', | ||
url: 'https://swap.blockscout.com/', | ||
icons: ['https://swap.blockscout.com/favicon-256x256.png'], | ||
} | ||
|
||
// Create the modal | ||
createAppKit({ | ||
adapters: [wagmiAdapter], | ||
projectId, | ||
networks: [mainnet, arbitrum], | ||
defaultNetwork: mainnet, | ||
metadata: metadata, | ||
features: { | ||
analytics: true, // Optional - defaults to your Cloud configuration | ||
}, | ||
}); | ||
|
||
function ContextProvider({ children, cookies }: { children: ReactNode; cookies: string | null }) { | ||
const initialState = cookieToInitialState(wagmiAdapter.wagmiConfig as Config, cookies); | ||
|
||
return ( | ||
<WagmiProvider config={wagmiAdapter.wagmiConfig as Config} initialState={initialState}> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</WagmiProvider> | ||
); | ||
} | ||
|
||
export default ContextProvider; |
Oops, something went wrong.