Skip to content
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
40 changes: 16 additions & 24 deletions app/vibenet/demos/b20/B20Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { isAddress, type Address, type Hex } from 'viem';
import { trackB20Action, trackB20ModuleSelect } from '../../../analytics/events';
import { Tabs } from '../../../components/ui/Tabs';
import { walletErrorMessage } from '../../library/wallet';
import { ActivityLog } from '../account/components/ActivityLog';
import { useAccountEngine } from '../account/useAccountEngine';
import { AccountDemoShell } from '../_components/AccountDemoShell';
import { ActivityRows } from './components/Activity';
import { AnnouncementModule, SampleAnnouncementViewer } from './components/AnnouncementModule';
import { DeployModule } from './components/DeployModule';
import { MemoModule } from './components/MemoModule';
Expand All @@ -28,15 +28,7 @@ import {
} from './lib/protocol';
import { readRecent, readRecentPolicies, writeRecent, writeRecentPolicy } from './lib/recent';
import { sampleTokenForAddress } from './lib/samples';
import type {
ActivityItem,
CreatedToken,
Module,
RecentPolicy,
RecentToken,
TokenAccess,
TokenInfo,
} from './lib/types';
import type { CreatedToken, Module, RecentPolicy, RecentToken, TokenAccess, TokenInfo } from './lib/types';

export function B20Demo() {
const [module, setModule] = useState<Module>('policy');
Expand All @@ -60,7 +52,6 @@ export function B20Demo() {
const [inspectError, setInspectError] = useState('');
const [checkAddress, setCheckAddress] = useState('');
const [checks, setChecks] = useState<Record<string, boolean> | null>(null);
const [activity, setActivity] = useState<ActivityItem[]>([]);
const [busy, setBusy] = useState<string | null>(null);
const [isOperator, setIsOperator] = useState(false);
const [isTokenAdmin, setIsTokenAdmin] = useState(false);
Expand Down Expand Up @@ -264,26 +255,27 @@ export function B20Demo() {
}
setBusy(action);
trackB20Action(module, action, 'submitted');
setActivity((rows) => [{ label, state: 'pending' }, ...rows]);
try {
// Sign + broadcast through the shared account engine so account deploy,
// sub-account, gas-estimation, and staged-settings behavior stays in one
// implementation across demos.
const { hash } = await engine.sendActiveCall({ to, data });
setActivity((rows) => [
{ label, hash, state: 'success' },
...rows.filter((row) => row.label !== label || row.state !== 'pending'),
]);
// implementation across demos. Logging via pushActivity puts this send in
// the same history the account demo reads, so both demos share one trail.
const { hash, serialized } = await engine.sendActiveCall({ to, data });
engine.pushActivity({
kind: 'transact',
title: label,
txHash: hash,
serialized,
network: engine.chain.name,
mode: engine.chain.mode,
account: activeAccount.address as Address,
});
trackB20Action(module, action, 'success');
refreshWallet(activeAccount.address as Address);
if (token) await inspect(token.address);
return hash;
} catch (error) {
const detail = walletErrorMessage(error);
setActivity((rows) => [
{ label, state: 'error', detail },
...rows.filter((row) => row.label !== label || row.state !== 'pending'),
]);
trackB20Action(module, action, 'error');
setInspectError(detail);
return null;
Expand Down Expand Up @@ -323,8 +315,8 @@ export function B20Demo() {
return (
<AccountDemoShell
engine={engine}
activity={<ActivityRows rows={activity} />}
activityCount={activity.length}
activity={<ActivityLog activity={engine.activity} accounts={engine.accounts} />}
activityCount={engine.activity.length}
activityEmptyMessage="Nothing has happened yet."
className="animate-in gap-5 pb-6 dark:text-white"
>
Expand Down
46 changes: 0 additions & 46 deletions app/vibenet/demos/b20/components/Activity.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/vibenet/demos/b20/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export type TokenInfo = RecentToken & {
policies: Array<{ scope: string; label: string; id: bigint; exists: boolean; admin: Address }>;
};

export type ActivityItem = { label: string; hash?: Hex; state: 'success' | 'error' | 'pending'; detail?: string };

export type CreatedToken = RecentToken & { hash: Hex; configured: string[] };

type PolicySummary = {
Expand Down
Loading