From a848a274ce76bb51d3d4ee30f844c5f21f5d3067 Mon Sep 17 00:00:00 2001 From: Paul Cramer Date: Tue, 17 Dec 2024 13:02:37 -0800 Subject: [PATCH] default const --- site/docs/components/AppDemo.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/site/docs/components/AppDemo.tsx b/site/docs/components/AppDemo.tsx index 50fbf9f0945..c2e8c4fc5dc 100644 --- a/site/docs/components/AppDemo.tsx +++ b/site/docs/components/AppDemo.tsx @@ -9,24 +9,16 @@ import '@coinbase/onchainkit/styles.css'; import { createWalletClient } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { useTheme } from '../contexts/Theme.tsx'; -import { type Account } from 'viem'; const queryClient = new QueryClient(); +const DEFAULT_DEMO_PK = + '0x1234567890123456789012345678901234567890123456789012345678901234'; + const demoWalletConnector = () => () => { - const demoWalletPK = import.meta.env.VITE_DEMO_WALLET_PK; + const demoWalletPK = import.meta.env.VITE_DEMO_WALLET_PK || DEFAULT_DEMO_PK; - let account: Account | undefined; - if (demoWalletPK) { - try { - account = privateKeyToAccount(demoWalletPK as `0x${string}`); - } catch (error) { - console.error('Failed to create account from private key:', error); - return null; - } - } else { - return null; - } + const account = privateKeyToAccount(demoWalletPK as `0x${string}`); const client = createWalletClient({ account,