Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Wallet Connectors #55

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@coinbase/onchainkit": "^0.35.6",
"@coinbase/onchainkit": "^0.36.10",
"next": "^14.2.5",
"permissionless": "^0.1.26",
"react": "^18",
Expand Down
1 change: 0 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NEXT_PUBLIC_URL } from '../config';

import './global.css';
import '@coinbase/onchainkit/styles.css';
import '@rainbow-me/rainbowkit/styles.css';
import dynamic from 'next/dynamic';

const OnchainProviders = dynamic(
Expand Down
6 changes: 1 addition & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ONCHAINKIT_LINK } from 'src/links';
import OnchainkitSvg from 'src/svg/OnchainkitSvg';
import { useAccount } from 'wagmi';
import LoginButton from '../components/LoginButton';
import SignupButton from '../components/SignupButton';

export default function Page() {
const { address } = useAccount();
Expand All @@ -23,10 +22,7 @@ export default function Page() {
>
<OnchainkitSvg />
</a>
<div className="flex items-center gap-3">
<SignupButton />
{!address && <LoginButton />}
</div>
<div className="flex items-center gap-3">{<LoginButton />}</div>
</div>
</section>
<section className="templateSection flex w-full flex-col items-center justify-center gap-4 rounded-xl bg-gray-100 px-2 py-4 md:grow">
Expand Down
8 changes: 1 addition & 7 deletions src/components/LoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@
import WalletWrapper from './WalletWrapper';

export default function LoginButton() {
return (
<WalletWrapper
className="min-w-[90px]"
text="Log in"
withWalletAggregator={true}
/>
);
return <WalletWrapper className="min-w-[90px]" text="Log in" />;
}
20 changes: 15 additions & 5 deletions src/components/OnchainProviders.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';
import { OnchainKitProvider } from '@coinbase/onchainkit';
import { RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { ReactNode } from 'react';
import { base } from 'viem/chains';
Expand All @@ -18,10 +17,21 @@ function OnchainProviders({ children }: Props) {
return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<OnchainKitProvider apiKey={NEXT_PUBLIC_CDP_API_KEY} chain={base}>
<RainbowKitProvider modalSize="compact">
{children}
</RainbowKitProvider>
<OnchainKitProvider
apiKey={NEXT_PUBLIC_CDP_API_KEY}
config={{
appearance: {
name: 'OnchainKit Template',
mode: 'auto',
theme: 'default',
},
wallet: {
display: 'modal',
},
}}
chain={base}
>
{children}
</OnchainKitProvider>
</QueryClientProvider>
</WagmiProvider>
Expand Down
58 changes: 0 additions & 58 deletions src/components/SignupButton.test.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/SignupButton.tsx

This file was deleted.

8 changes: 1 addition & 7 deletions src/components/WalletWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@ import {
type WalletWrapperParams = {
text?: string;
className?: string;
withWalletAggregator?: boolean;
};
export default function WalletWrapper({
className,
text,
withWalletAggregator = false,
}: WalletWrapperParams) {
return (
<>
<Wallet>
<ConnectWallet
withWalletAggregator={withWalletAggregator}
text={text}
className={className}
>
<ConnectWallet text={text} className={className}>
<Avatar className="h-6 w-6" />
<Name />
</ConnectWallet>
Expand Down
33 changes: 8 additions & 25 deletions src/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
'use client';
import { connectorsForWallets } from '@rainbow-me/rainbowkit';
import {
coinbaseWallet,
metaMaskWallet,
rainbowWallet,
} from '@rainbow-me/rainbowkit/wallets';

import { useMemo } from 'react';
import { http, createConfig } from 'wagmi';
import { base, baseSepolia } from 'wagmi/chains';
import { coinbaseWallet } from 'wagmi/connectors';
import { NEXT_PUBLIC_WC_PROJECT_ID } from './config';

export function useWagmiConfig() {
Expand All @@ -19,28 +15,15 @@ export function useWagmiConfig() {
}

return useMemo(() => {
const connectors = connectorsForWallets(
[
{
groupName: 'Recommended Wallet',
wallets: [coinbaseWallet],
},
{
groupName: 'Other Wallets',
wallets: [rainbowWallet, metaMaskWallet],
},
],
{
appName: 'onchainkit',
projectId,
},
);

const wagmiConfig = createConfig({
chains: [base, baseSepolia],
// turn off injected provider discovery
multiInjectedProviderDiscovery: false,
connectors,
connectors: [
coinbaseWallet({
preference: 'all',
}),
],
ssr: true,
transports: {
[base.id]: http(),
Expand All @@ -49,5 +32,5 @@ export function useWagmiConfig() {
});

return wagmiConfig;
}, [projectId]);
}, []);
}