-
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.
Added input filed for amount and recipient address
- Loading branch information
1 parent
6f2ff22
commit 40d0d06
Showing
8 changed files
with
814 additions
and
502 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,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 |
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
Oops, something went wrong.