Skip to content

Commit

Permalink
feat: added ConnectAccount for Smart Wallet integration (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia authored May 17, 2024
1 parent 8613acc commit 6c6e571
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 340 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-waves-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@coinbase/build-onchain-apps': minor
---

- **feat**: made Smart Wallet the only choice for BOAT.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Whether you're a hackathon participant or an ambitious entrepreneur looking to b

- Progressive Web App support using [Next.js](https://nextjs.org/) 🏗️
- Ethereum L2 support through [Base](https://base.org/) 🔵
- Wallet connect integration with [RainbowKit](https://www.rainbowkit.com) 🌈
- Easy account creation with [Smart Wallet](https://www.smartwallet.dev/why)
- Live examples and documentation for Minting and Payments experiences with [wagmi](https://wagmi.sh/) and [Viem](https://viem.sh/) 🚀
- Latest styling best practices with [Tailwind CSS](https://tailwindcss.com/) 💅
- Easy maintenance with linting, formatting, and tests ✅
Expand Down
18 changes: 0 additions & 18 deletions src/create/getUserInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as prompts from '@clack/prompts';
import { experiences } from './experiences';

export type EnvVar = {
walletConnectProjectID: string;
blockExplorerApiKey: string;
rpcUrl: string;
};
Expand All @@ -26,12 +25,6 @@ export async function getUserInput() {
},
});
},
pickSmartWallet: () => {
return prompts.confirm({
message: 'Do you want to use Smart Wallet?',
initialValue: true,
});
},
selectedModules: () => {
return prompts.multiselect({
message:
Expand All @@ -54,17 +47,6 @@ export async function getUserInput() {

const envVars = await prompts.group(
{
walletConnectProjectID: () => {
if (project.pickSmartWallet) return;
return prompts.text({
message: 'WalletConnect Project ID',
placeholder: 'Visit https://cloud.walletconnect.com',
validate: (value) => {
if (value.length === 0) return;
if (value.length < 32) return 'Key must be 32 characters';
},
});
},
rpcUrl: () => {
return prompts.text({
message: 'Base RPC URL',
Expand Down
1 change: 0 additions & 1 deletion src/create/setupEnvFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function setupEnvFiles(projectDir: string, envVar: EnvVar) {

const envLocalPath = path.join(projectDir, './web/.env.local');
const content = `NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${envVar.walletConnectProjectID ?? '"GET_ID_FROM_WALLET_CONNET" # See https://cloud.walletconnect.com'}
NEXT_PRIVATE_RPC_URL=${envVar.rpcUrl ?? '"GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat'}
NEXT_PRIVATE_PAYMASTER_URL=${envVar.rpcUrl ?? '"GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat'}
NEXT_PUBLIC_PRIVY_ID="GET_FROM_PRIVY"
Expand Down
22 changes: 0 additions & 22 deletions src/create/setupProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,6 @@ export async function setupProject(projectDir: string, project) {
generateNavbarExperiencesList(projectDir, selectedExperiences);
}

if (project.pickSmartWallet) {
removeDownloadedApps(
projectDir + '/web/src/store/createWagmiConfigWithRK.ts'
);
removeDownloadedApps(projectDir + '/web/src/OnchainProvidersWithRK.tsx');
} else {
// Replace createWagmiConfig.ts with createWagmiConfigWithRK.ts content
removeDownloadedApps(projectDir + '/web/src/store/createWagmiConfig.ts');
const newFilename = projectDir + '/web/src/store/createWagmiConfig.ts';
renameDownloadedFile(
projectDir + '/web/src/store/createWagmiConfigWithRK.ts',
newFilename
);
// Replace OnchainProviders.ts with OnchainProvidersWithRK.ts content
removeDownloadedApps(projectDir + '/web/src/OnchainProviders.tsx');
const newProviderFilename = projectDir + '/web/src/OnchainProviders.tsx';
renameDownloadedFile(
projectDir + '/web/src/OnchainProvidersWithRK.tsx',
newProviderFilename
);
}

await execAsync('git add .', { cwd: projectDir, stdio: 'ignore' });
await execAsync('git commit -m "initalized with build-onchain-apps"', {
cwd: projectDir,
Expand Down
1 change: 0 additions & 1 deletion template/web/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID="GET_ID_FROM_WALLET_CONNET" # See https://cloud.walletconnect.com
NEXT_PRIVATE_RPC_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
NEXT_PRIVATE_PAYMASTER_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
NEXT_PUBLIC_PRIVY_ID="GET_FROM_PRIVY"
Expand Down
1 change: 0 additions & 1 deletion template/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#### Step 1: Setup Environment Variables

- Obtain the Wallet Connect Project ID from [walletconnect.com](https://cloud.walletconnect.com/sign-in) and assign to the `.env.local` file
- 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

```bash
Expand Down
7 changes: 3 additions & 4 deletions template/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
"test:coverage:open": "yarn test:coverage && open coverage/lcov-report/index.html"
},
"dependencies": {
"@coinbase/onchainkit": "0.14.2",
"@coinbase/wallet-sdk": "4.0.0-beta.12",
"@coinbase/onchainkit": "0.16.10",
"@coinbase/wallet-sdk": "4.0.0",
"@farcaster/hub-nodejs": "^0.11.9",
"@privy-io/react-auth": "^1.56.2",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@rainbow-me/rainbowkit": "2",
"@react-spring/web": "^9.7.3",
"@tanstack/react-query": "^5.20.1",
"abitype": "^0.10.3",
Expand Down Expand Up @@ -110,6 +109,6 @@
},
"packageManager": "yarn@4.1.0",
"resolutions": {
"@coinbase/wallet-sdk": "npm:@coinbase/wallet-sdk@4.0.0-beta.12"
"@coinbase/wallet-sdk": "npm:@coinbase/wallet-sdk@4.0.0"
}
}
3 changes: 0 additions & 3 deletions template/web/src/OnchainProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const rpcUrl = '/api/rpc';

const wagmiConfig = createWagmiConfig(rpcUrl);

/**
* TODO Docs ~~~
*/
function OnchainProviders({ children }: Props) {
return (
<WagmiProvider config={wagmiConfig}>
Expand Down
47 changes: 0 additions & 47 deletions template/web/src/OnchainProvidersWithRK.tsx

This file was deleted.

16 changes: 3 additions & 13 deletions template/web/src/components/layout/header/AccountConnect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConnectAccount } from '@coinbase/onchainkit/wallet';
import { baseSepolia } from 'viem/chains';
import { useAccount, useChainId, useConnect, useDisconnect } from 'wagmi';
import { AccountDropdown } from './AccountDropdown';
Expand All @@ -11,13 +12,10 @@ import { AccountInfoPanel } from './AccountInfoPanel';
*/
function AccountConnect() {
const account = useAccount();
const { connectors, connect, status } = useConnect();
const { status } = useConnect();
const { disconnect } = useDisconnect();
const connector = connectors[0];
const chainId = useChainId();

console.log('Account Status:', account.status);

return (
<div
className="flex flex-grow"
Expand All @@ -32,15 +30,7 @@ function AccountConnect() {
>
{(() => {
if (account.status === 'disconnected') {
return (
<button
onClick={() => connect({ connector })}
type="button"
className="inline-flex h-10 flex-grow items-center justify-center gap-2 rounded-3xl bg-white px-4 py-2"
>
<div className="text-sm font-medium leading-normal text-black">Connect wallet</div>
</button>
);
return <ConnectAccount />;
}

if (account.status === 'connected' && chainId !== baseSepolia.id) {
Expand Down
20 changes: 0 additions & 20 deletions template/web/src/components/layout/header/Navbar.test.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions template/web/src/components/layout/header/NavbarMobile.test.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions template/web/src/store/createWagmiConfigWithRK.ts

This file was deleted.

Loading

0 comments on commit 6c6e571

Please sign in to comment.