-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from HAPPYS1NGH/walletconnect
Added complete support for Walletconnect
- Loading branch information
Showing
9 changed files
with
3,441 additions
and
2,467 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
Large diffs are not rendered by default.
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
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,3 @@ | ||
export default function ConnectButton() { | ||
return <w3m-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
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 |
---|---|---|
@@ -1 +1 @@ | ||
export const counterAddress = "0x75b167a1628b6F239C0BEA211d731578bA90465a" | ||
export const counterAddress = "0x0A37fC81Da775CBf75A49b45Cbda60F5F80E1a14"; |
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 |
---|---|---|
@@ -1,32 +1,50 @@ | ||
"use client"; | ||
import { WagmiProvider } from "wagmi"; | ||
import { | ||
darkTheme, | ||
lightTheme, | ||
RainbowKitProvider, | ||
} from "@rainbow-me/rainbowkit"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { config } from "../utils/config"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
export default function Web3Provider({ | ||
children, | ||
}) { | ||
'use client' | ||
|
||
import { wagmiAdapter, projectId } from '@/utils/config' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { createAppKit } from '@reown/appkit/react' | ||
import { mainnet, arbitrum, sepolia } from '@reown/appkit/networks' | ||
import React from 'react' | ||
import { cookieToInitialState, WagmiProvider } from 'wagmi' | ||
|
||
// Set up queryClient | ||
const queryClient = new QueryClient() | ||
|
||
if (!projectId) { | ||
throw new Error('Project ID is not defined') | ||
} | ||
|
||
|
||
const metadata = { | ||
name: "rabble-starter-kit", | ||
description: "Rabble Mini App Starter Kit", | ||
url: "https://rabble-tg-mini-app-nextjs-js-git-walletconnect-happysingh.vercel.app/", // origin must match your domain & subdomain | ||
icons: ["https://rabble-tg-mini-app-nextjs-js-git-walletconnect-happysingh.vercel.app/butterfly.svg"] | ||
} | ||
|
||
// Create the modal | ||
const modal = createAppKit({ | ||
adapters: [wagmiAdapter], | ||
projectId, | ||
networks: [mainnet, arbitrum, sepolia], | ||
defaultNetwork: sepolia, | ||
metadata: metadata, | ||
features: { | ||
analytics: true, // Optional - defaults to your Cloud configuration | ||
}, | ||
themeVariables: { | ||
'--w3m-accent': '#08F7AF', | ||
} | ||
}) | ||
|
||
function ContextProvider({ children, cookies }) { | ||
const initialState = cookieToInitialState(wagmiAdapter.wagmiConfig, cookies) | ||
|
||
return ( | ||
<WagmiProvider config={config}> | ||
<QueryClientProvider client={queryClient}> | ||
<RainbowKitProvider | ||
theme={darkTheme({ | ||
accentColor: "#21C896", | ||
accentColorForeground: "white", | ||
borderRadius: "medium", | ||
fontStack: "system", | ||
})} | ||
> | ||
{children} | ||
</RainbowKitProvider> | ||
</QueryClientProvider> | ||
<WagmiProvider config={wagmiAdapter.wagmiConfig} initialState={initialState}> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</WagmiProvider> | ||
); | ||
) | ||
} | ||
|
||
export default ContextProvider |
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 |
---|---|---|
@@ -1,39 +1,24 @@ | ||
import { getDefaultWallets, getDefaultConfig } from "@rainbow-me/rainbowkit" | ||
import { | ||
argentWallet, | ||
trustWallet, | ||
ledgerWallet, | ||
} from "@rainbow-me/rainbowkit/wallets" | ||
import { | ||
arbitrum, | ||
arbitrumSepolia, | ||
localhost, | ||
} from "wagmi/chains" | ||
import { cookieStorage, createStorage, http } from "@wagmi/core"; | ||
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi"; | ||
import { arbitrum, sepolia } from "@reown/appkit/networks"; | ||
|
||
const { wallets } = getDefaultWallets() | ||
// Get projectId from https://cloud.reown.com | ||
export const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID; | ||
|
||
export const WALLETCONNECT_PROJECT_ID = | ||
process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID ?? "" | ||
if (!WALLETCONNECT_PROJECT_ID) { | ||
console.warn( | ||
"You need to provide a NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID env variable" | ||
) | ||
if (!projectId) { | ||
throw new Error("Project ID is not defined"); | ||
} | ||
export const config = getDefaultConfig({ | ||
appName: "RainbowKit demo", | ||
projectId: WALLETCONNECT_PROJECT_ID, | ||
wallets: [ | ||
...wallets, | ||
{ | ||
groupName: "Other", | ||
wallets: [argentWallet, trustWallet, ledgerWallet], | ||
}, | ||
], | ||
chains: [ | ||
arbitrumSepolia, | ||
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === "true" | ||
? [arbitrumSepolia, arbitrum, localhost] | ||
: []), | ||
], | ||
|
||
export const networks = [arbitrum, sepolia]; | ||
|
||
//Set up the Wagmi Adapter (Config) | ||
export const wagmiAdapter = new WagmiAdapter({ | ||
storage: createStorage({ | ||
storage: cookieStorage, | ||
}), | ||
ssr: true, | ||
}) | ||
projectId, | ||
networks, | ||
}); | ||
|
||
export const config = wagmiAdapter.wagmiConfig; |