diff --git a/app/vibenet/demos/account/components/CreateAccountModal.tsx b/app/vibenet/demos/account/components/CreateAccountModal.tsx index e6fdd69..71c0046 100644 --- a/app/vibenet/demos/account/components/CreateAccountModal.tsx +++ b/app/vibenet/demos/account/components/CreateAccountModal.tsx @@ -1,14 +1,17 @@ 'use client'; -// The account-creation modal: EOA vs Smart, key minting/picking, salt. Shared -// by every demo that lets a user create a local EIP-8130 account — driven off -// the create-modal slice of `useAccountEngine`'s return value. +// The account-creation modal. "Account Type" is the top-level choice: +// Default — one-click EOA off your first unused key (mints one if none) +// Passkey — one-click smart account owned by your first unused passkey +// Advanced — hand-pick smart/EOA + initial keys + salt +// Default/Passkey stay minimal (name only); Advanced reveals the full controls. +// Driven off the create-modal slice of `useAccountEngine`'s return value. import { Button } from '../../../../components/ui/Button'; import { cn } from '../../../../components/ui/cn'; import { Text } from '../../../../components/ui/Text'; import { Modal } from '../../../../components/ui/Modal'; -import { KIND_LABEL, short, signerIdentity, type WalletSigner } from '../shared'; +import { KIND_LABEL, short, signerIdentity, type CreateMode, type WalletSigner } from '../shared'; import { CheckIcon, KindBadge, TrashIcon } from '../../_shared/primitives'; import type { SignerKind } from '../library/model'; import type { AccountEngine } from '../useAccountEngine'; @@ -17,10 +20,19 @@ type CreateAccountModalProps = { engine: AccountEngine; }; +const MODES: ReadonlyArray = [ + ['default', 'Default', 'Simplest account setup'], + ['passkey', 'Passkey', 'Smart account · passkey'], + ['advanced', 'Advanced', 'Pick type, keys & salt'], +]; + export function CreateAccountModal({ engine }: CreateAccountModalProps) { const { modalOpen, setModalOpen, + createMode, + setCreateMode, + suggestedName, modalType, setModalType, modalLabel, @@ -43,6 +55,13 @@ export function CreateAccountModal({ engine }: CreateAccountModalProps) { randomizeCreateSalt, } = engine; + const busyCreating = busy !== null; + const canCreate = createMode === 'advanced' ? Boolean(modalAddress) : true; + + const submit = () => { + if (canCreate && !busyCreating) void createAccount(); + }; + return ( - Create Account + {busyCreating ? 'Creating…' : 'Create Account'} } >
Account type -
- {( - [ - ['smart', 'Smart Account', 'Counterfactual · keys + salt → address'], - ['eoa', 'EOA', 'Your EOA · delegates to DefaultAccount'], - ] as const - ).map(([type, title, hint]) => ( +
+ {MODES.map(([mode, title, hint]) => (
- {modalType === 'smart' ? ( + {createMode === 'advanced' ? ( <> - !usedSignerIds.has(s.id)} - onDelete={deleteSigner} - isOn={(s) => modalIds.includes(s.id)} - onToggle={(s) => - setModalIds((prev) => (prev.includes(s.id) ? prev.filter((x) => x !== s.id) : [...prev, s.id])) - } - onMint={async (kind) => { - const s = await createSigner(kind); - if (s) setModalIds((prev) => [...prev, s.id]); - }} - /> -