Skip to content

Commit 6c6e571

Browse files
authored
feat: added ConnectAccount for Smart Wallet integration (coinbase#490)
1 parent 8613acc commit 6c6e571

15 files changed

+37
-340
lines changed

.changeset/smooth-waves-give.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@coinbase/build-onchain-apps': minor
3+
---
4+
5+
- **feat**: made Smart Wallet the only choice for BOAT.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Whether you're a hackathon participant or an ambitious entrepreneur looking to b
1818

1919
- Progressive Web App support using [Next.js](https://nextjs.org/) 🏗️
2020
- Ethereum L2 support through [Base](https://base.org/) 🔵
21-
- Wallet connect integration with [RainbowKit](https://www.rainbowkit.com) 🌈
21+
- Easy account creation with [Smart Wallet](https://www.smartwallet.dev/why)
2222
- Live examples and documentation for Minting and Payments experiences with [wagmi](https://wagmi.sh/) and [Viem](https://viem.sh/) 🚀
2323
- Latest styling best practices with [Tailwind CSS](https://tailwindcss.com/) 💅
2424
- Easy maintenance with linting, formatting, and tests ✅

src/create/getUserInput.ts

-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as prompts from '@clack/prompts';
22
import { experiences } from './experiences';
33

44
export type EnvVar = {
5-
walletConnectProjectID: string;
65
blockExplorerApiKey: string;
76
rpcUrl: string;
87
};
@@ -26,12 +25,6 @@ export async function getUserInput() {
2625
},
2726
});
2827
},
29-
pickSmartWallet: () => {
30-
return prompts.confirm({
31-
message: 'Do you want to use Smart Wallet?',
32-
initialValue: true,
33-
});
34-
},
3528
selectedModules: () => {
3629
return prompts.multiselect({
3730
message:
@@ -54,17 +47,6 @@ export async function getUserInput() {
5447

5548
const envVars = await prompts.group(
5649
{
57-
walletConnectProjectID: () => {
58-
if (project.pickSmartWallet) return;
59-
return prompts.text({
60-
message: 'WalletConnect Project ID',
61-
placeholder: 'Visit https://cloud.walletconnect.com',
62-
validate: (value) => {
63-
if (value.length === 0) return;
64-
if (value.length < 32) return 'Key must be 32 characters';
65-
},
66-
});
67-
},
6850
rpcUrl: () => {
6951
return prompts.text({
7052
message: 'Base RPC URL',

src/create/setupEnvFiles.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export function setupEnvFiles(projectDir: string, envVar: EnvVar) {
77

88
const envLocalPath = path.join(projectDir, './web/.env.local');
99
const content = `NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
10-
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${envVar.walletConnectProjectID ?? '"GET_ID_FROM_WALLET_CONNET" # See https://cloud.walletconnect.com'}
1110
NEXT_PRIVATE_RPC_URL=${envVar.rpcUrl ?? '"GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat'}
1211
NEXT_PRIVATE_PAYMASTER_URL=${envVar.rpcUrl ?? '"GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat'}
1312
NEXT_PUBLIC_PRIVY_ID="GET_FROM_PRIVY"

src/create/setupProject.ts

-22
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,6 @@ export async function setupProject(projectDir: string, project) {
154154
generateNavbarExperiencesList(projectDir, selectedExperiences);
155155
}
156156

157-
if (project.pickSmartWallet) {
158-
removeDownloadedApps(
159-
projectDir + '/web/src/store/createWagmiConfigWithRK.ts'
160-
);
161-
removeDownloadedApps(projectDir + '/web/src/OnchainProvidersWithRK.tsx');
162-
} else {
163-
// Replace createWagmiConfig.ts with createWagmiConfigWithRK.ts content
164-
removeDownloadedApps(projectDir + '/web/src/store/createWagmiConfig.ts');
165-
const newFilename = projectDir + '/web/src/store/createWagmiConfig.ts';
166-
renameDownloadedFile(
167-
projectDir + '/web/src/store/createWagmiConfigWithRK.ts',
168-
newFilename
169-
);
170-
// Replace OnchainProviders.ts with OnchainProvidersWithRK.ts content
171-
removeDownloadedApps(projectDir + '/web/src/OnchainProviders.tsx');
172-
const newProviderFilename = projectDir + '/web/src/OnchainProviders.tsx';
173-
renameDownloadedFile(
174-
projectDir + '/web/src/OnchainProvidersWithRK.tsx',
175-
newProviderFilename
176-
);
177-
}
178-
179157
await execAsync('git add .', { cwd: projectDir, stdio: 'ignore' });
180158
await execAsync('git commit -m "initalized with build-onchain-apps"', {
181159
cwd: projectDir,

template/web/.env.local.example

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
2-
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID="GET_ID_FROM_WALLET_CONNET" # See https://cloud.walletconnect.com
32
NEXT_PRIVATE_RPC_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
43
NEXT_PRIVATE_PAYMASTER_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
54
NEXT_PUBLIC_PRIVY_ID="GET_FROM_PRIVY"

template/web/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#### Step 1: Setup Environment Variables
66

7-
- Obtain the Wallet Connect Project ID from [walletconnect.com](https://cloud.walletconnect.com/sign-in) and assign to the `.env.local` file
87
- Obtain a Base RPC URL from [Coinbase Developer Platform](https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat) and assign to the `.env.local` file
98

109
```bash

template/web/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
"test:coverage:open": "yarn test:coverage && open coverage/lcov-report/index.html"
1919
},
2020
"dependencies": {
21-
"@coinbase/onchainkit": "0.14.2",
22-
"@coinbase/wallet-sdk": "4.0.0-beta.12",
21+
"@coinbase/onchainkit": "0.16.10",
22+
"@coinbase/wallet-sdk": "4.0.0",
2323
"@farcaster/hub-nodejs": "^0.11.9",
2424
"@privy-io/react-auth": "^1.56.2",
2525
"@radix-ui/react-dropdown-menu": "^2.0.6",
2626
"@radix-ui/react-icons": "^1.3.0",
2727
"@radix-ui/react-navigation-menu": "^1.1.4",
28-
"@rainbow-me/rainbowkit": "2",
2928
"@react-spring/web": "^9.7.3",
3029
"@tanstack/react-query": "^5.20.1",
3130
"abitype": "^0.10.3",
@@ -110,6 +109,6 @@
110109
},
111110
"packageManager": "[email protected]",
112111
"resolutions": {
113-
"@coinbase/wallet-sdk": "npm:@coinbase/[email protected]-beta.12"
112+
"@coinbase/wallet-sdk": "npm:@coinbase/[email protected]"
114113
}
115114
}

template/web/src/OnchainProviders.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const rpcUrl = '/api/rpc';
1515

1616
const wagmiConfig = createWagmiConfig(rpcUrl);
1717

18-
/**
19-
* TODO Docs ~~~
20-
*/
2118
function OnchainProviders({ children }: Props) {
2219
return (
2320
<WagmiProvider config={wagmiConfig}>

template/web/src/OnchainProvidersWithRK.tsx

-47
This file was deleted.

template/web/src/components/layout/header/AccountConnect.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ConnectAccount } from '@coinbase/onchainkit/wallet';
12
import { baseSepolia } from 'viem/chains';
23
import { useAccount, useChainId, useConnect, useDisconnect } from 'wagmi';
34
import { AccountDropdown } from './AccountDropdown';
@@ -11,13 +12,10 @@ import { AccountInfoPanel } from './AccountInfoPanel';
1112
*/
1213
function AccountConnect() {
1314
const account = useAccount();
14-
const { connectors, connect, status } = useConnect();
15+
const { status } = useConnect();
1516
const { disconnect } = useDisconnect();
16-
const connector = connectors[0];
1717
const chainId = useChainId();
1818

19-
console.log('Account Status:', account.status);
20-
2119
return (
2220
<div
2321
className="flex flex-grow"
@@ -32,15 +30,7 @@ function AccountConnect() {
3230
>
3331
{(() => {
3432
if (account.status === 'disconnected') {
35-
return (
36-
<button
37-
onClick={() => connect({ connector })}
38-
type="button"
39-
className="inline-flex h-10 flex-grow items-center justify-center gap-2 rounded-3xl bg-white px-4 py-2"
40-
>
41-
<div className="text-sm font-medium leading-normal text-black">Connect wallet</div>
42-
</button>
43-
);
33+
return <ConnectAccount />;
4434
}
4535

4636
if (account.status === 'connected' && chainId !== baseSepolia.id) {

template/web/src/components/layout/header/Navbar.test.tsx

-20
This file was deleted.

template/web/src/components/layout/header/NavbarMobile.test.tsx

-31
This file was deleted.

template/web/src/store/createWagmiConfigWithRK.ts

-34
This file was deleted.

0 commit comments

Comments
 (0)