-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into use-wallet-service-getCallsStatus
- Loading branch information
Showing
20 changed files
with
1,244 additions
and
767 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
25 changes: 25 additions & 0 deletions
25
advanced/dapps/chain-abstraction-demo/components/ui/input.tsx
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,25 @@ | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> {} | ||
|
||
const Input = React.forwardRef<HTMLInputElement, InputProps>( | ||
({ className, type, ...props }, ref) => { | ||
return ( | ||
<input | ||
type={type} | ||
className={cn( | ||
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", | ||
className | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Input.displayName = "Input" | ||
|
||
export { Input } |
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,28 +1,31 @@ | ||
import { defaultWagmiConfig } from "@web3modal/wagmi/react/config"; | ||
import { cookieStorage, createStorage, http } from '@wagmi/core' | ||
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi' | ||
import { arbitrum, optimism, base } from '@reown/appkit/networks' | ||
|
||
import { cookieStorage, createStorage } from "wagmi"; | ||
import { arbitrum, base, optimism } from "wagmi/chains"; | ||
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID | ||
|
||
// Get projectId from https://cloud.walletconnect.com | ||
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID; | ||
if (!projectId) { | ||
throw new Error('Project ID is not defined') | ||
} | ||
|
||
export const networks = [base, optimism, arbitrum] | ||
|
||
export const wagmiAdapter = new WagmiAdapter({ | ||
storage: createStorage({ | ||
storage: cookieStorage | ||
}), | ||
ssr: true, | ||
projectId, | ||
networks | ||
}) | ||
|
||
if (!projectId) throw new Error("Project ID is not defined"); | ||
|
||
export const metadata = { | ||
name: "AppKit", | ||
description: "AppKit Example", | ||
name: "Chain Abstraction Demo", | ||
description: "A demo of Chain Abstraction", | ||
url: "https://web3modal.com", // origin must match your domain & subdomain | ||
icons: ["https://avatars.githubusercontent.com/u/37784886"], | ||
}; | ||
|
||
// Create wagmiConfig | ||
const chains = [base, optimism, arbitrum] as const; | ||
export const config = defaultWagmiConfig({ | ||
chains, | ||
projectId, | ||
metadata, | ||
ssr: true, | ||
storage: createStorage({ | ||
storage: cookieStorage, | ||
}), | ||
}); | ||
|
||
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { Hex } from "viem"; | ||
|
||
export const tokenAddresses: Record<number, Hex> = { | ||
42161: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' // Arbitrum | ||
42161: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // Arbitrum | ||
10: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', // Optimism | ||
8453: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Base | ||
} |
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,37 +1,35 @@ | ||
"use client"; | ||
'use client' | ||
|
||
import React, { ReactNode } from "react"; | ||
import { config, projectId, metadata } from "@/config"; | ||
import { wagmiAdapter, projectId, metadata } from '@/config' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { createAppKit } from '@reown/appkit/react' | ||
import { arbitrum, base, optimism } from '@reown/appkit/networks' | ||
import React, { type ReactNode } from 'react' | ||
import { cookieToInitialState, WagmiProvider, type Config } from 'wagmi' | ||
|
||
import { createWeb3Modal } from "@web3modal/wagmi/react"; | ||
|
||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
|
||
import { State, WagmiProvider } from "wagmi"; | ||
|
||
// Setup queryClient | ||
const queryClient = new QueryClient(); | ||
|
||
if (!projectId) throw new Error("Project ID is not defined"); | ||
|
||
// Create modal | ||
createWeb3Modal({ | ||
metadata, | ||
wagmiConfig: config, | ||
const modal = createAppKit({ | ||
adapters: [wagmiAdapter], | ||
projectId, | ||
enableAnalytics: true, // Optional - defaults to your Cloud configuration | ||
}); | ||
networks: [base, optimism, arbitrum], | ||
defaultNetwork: base, | ||
metadata: metadata, | ||
features: { | ||
analytics: true | ||
} | ||
}) | ||
|
||
function AppKitProvider({ children, cookies }: { children: ReactNode; cookies: string | null }) { | ||
const initialState = cookieToInitialState(wagmiAdapter.wagmiConfig as Config, cookies) | ||
|
||
export default function AppKitProvider({ | ||
children, | ||
initialState, | ||
}: { | ||
children: ReactNode; | ||
initialState?: State; | ||
}) { | ||
return ( | ||
<WagmiProvider config={config} initialState={initialState}> | ||
<WagmiProvider config={wagmiAdapter.wagmiConfig } initialState={initialState}> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</WagmiProvider> | ||
); | ||
) | ||
} | ||
|
||
export default AppKitProvider |
Oops, something went wrong.