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
2 changes: 1 addition & 1 deletion pkgs/frontend/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Rules that are easy to get wrong:
- **Writes go through `createSubname` only.** `POST /subnames` is an upsert, and every other SDK write helper (`updateSubname`, `addTextRecord`, `setDefaultEvmAddress`, …) rebuilds the record without `owner` and silently wipes ownership. Send the full record each time; an omitted text record is a deletion.
- **Never `throw data(…)` from inside a `try`** in the API route. `data()` returns a `DataWithResponseInit`, so the route's own `catch` swallows it and re-reports a 500 — that was the original 409-becomes-500 bug. Throw `NameApiError(status, message)` and let the boundary translate it.
- `getSingleSubname` does not return `null` on 404 despite its type; `NamespaceProvider` absorbs that.
- Splits register dotted labels (`foo.split.toban.eth`). The provider derives the label from `fullName` rather than `dto.label` so re-parenting on the API side can't truncate it. **Nested labels are still unverified against a live Namespace tenant** — check this on Sepolia staging before trusting split names.
- Splits register dotted labels (`foo.split.toban.eth`). The provider derives the label from `fullName` rather than `dto.label` so re-parenting on the API side can't truncate it. Verified against the live Namespace tenant on both networks (Base `分配1.split.toban.eth`, Sepolia `yosuke-test-20260924.split.toban.eth`): the label round-trips as `<name>.split`, and non-ASCII (Japanese) labels work.

## Testing

Expand Down
17 changes: 17 additions & 0 deletions pkgs/frontend/app/routes/$treeId_.splits.$splitId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ const SplitDetailPage: FC = () => {
const ensFullName = splitEnsEntry?.name
? `${splitEnsEntry.name}.${splitEnsEntry.domain}`
: undefined;
// "What is this split for?" — the `description` text record written at
// creation time. Splits created before the field existed simply have none.
const description = splitEnsEntry?.text_records?.description?.trim();

const recipientNameByAddress = useMemo(() => {
const m = new Map<string, NameData>();
Expand Down Expand Up @@ -268,6 +271,7 @@ const SplitDetailPage: FC = () => {
<CopyIconButton label="ENS名" value={ensFullName} />
)}
</div>
{description && <SplitDescription text={description} />}
{split?.address && <AddressRow address={split.address} />}
<Typography variant="caption" tone="secondary">
{createdAt && `作成日: ${createdAt}`}
Expand Down Expand Up @@ -325,6 +329,7 @@ const SplitDetailPage: FC = () => {
<CopyIconButton label="ENS名" value={ensFullName} />
)}
</div>
{description && <SplitDescription text={description} />}
{split?.address && <AddressRow address={split.address} />}
<Typography variant="bodySm" tone="secondary">
合計 100% ・ 対象 {recipients.list.length}人
Expand Down Expand Up @@ -403,6 +408,18 @@ const DonutSummaryCard: FC<DonutSummaryCardProps> = ({
</Card>
);

// ─── SplitDescription ──────────────────────────────────────────────────────
//
// Sits directly under the title so the first thing a visitor reads after the
// `foo.split.toban.eth` label is *why* this split exists, before the raw
// contract address.

const SplitDescription: FC<{ text: string }> = ({ text }) => (
<Typography variant="bodySm" className="whitespace-pre-wrap break-words">
{text}
</Typography>
);

// ─── AddressRow / CopyIconButton ───────────────────────────────────────────
//
// `AddressRow` shows the full contract address as a single tappable mono-text
Expand Down
27 changes: 27 additions & 0 deletions pkgs/frontend/app/routes/$treeId_.splits._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ const SplitsIndex: FC = () => {
? `${ensEntry.name}.${ensEntry.domain}`
: undefined;
const displayName = ensFullName ?? abbreviateAddress(split.address);
const description = ensEntry?.text_records?.description?.trim();
return {
split,
recipients,
displayName,
ensFullName,
description: description || undefined,
recipientCount: recipients.list.length,
createdAt: created
? dayjs(created * 1000).format("YYYY/MM/DD")
Expand Down Expand Up @@ -337,6 +339,8 @@ interface SplitListItem {
recipients: ConsolidatedRecipients;
displayName: string;
ensFullName?: string;
/** `description` ENS text record — what the split is for, if the creator said. */
description?: string;
recipientCount: number;
createdAt?: string;
}
Expand Down Expand Up @@ -413,6 +417,16 @@ const SplitListCard: FC<SplitListCardProps> = ({
/>
)}
</div>
{item.description && (
<Typography
as="div"
variant="caption"
tone="secondary"
className="mt-0.5 line-clamp-2 break-words"
>
{item.description}
</Typography>
)}
<CopyableAddress address={item.split.address} />
<Typography
as="div"
Expand Down Expand Up @@ -478,6 +492,11 @@ const MasterRow: FC<MasterRowProps> = ({ item, selected, onClick }) => (
<Typography as="div" variant="bodySm" weight="bold" truncate>
{item.displayName}
</Typography>
{item.description && (
<Typography variant="micro" tone="secondary" as="div" truncate>
{item.description}
</Typography>
)}
<Typography variant="micro" tone="secondary" as="div" truncate>
{item.recipientCount}人に分配
{item.createdAt && ` ・ ${item.createdAt}`}
Expand Down Expand Up @@ -523,6 +542,14 @@ const DesktopDetailPreview: FC<DesktopDetailPreviewProps> = ({
<CopyIconButton label="ENS名" value={item.ensFullName} />
)}
</div>
{item.description && (
<Typography
variant="bodySm"
className="mt-1 whitespace-pre-wrap break-words"
>
{item.description}
</Typography>
)}
<CopyableAddress address={item.split.address} className="mt-1" />
<Typography variant="bodySm" tone="secondary" className="mt-1">
合計 100% ・ 対象 {item.recipientCount}人
Expand Down
55 changes: 54 additions & 1 deletion pkgs/frontend/app/routes/$treeId_.splits.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ import {
} from "~/components/ui/dialog";
import { Icon } from "~/components/ui/icon";
import { Input } from "~/components/ui/input";
import { Textarea } from "~/components/ui/textarea";
import { Typography } from "~/components/ui/typography";
import { cn } from "~/lib/utils";

type Step = "form" | "preview" | "done";

const TOTAL_STEPS = 3;
/** Long enough for a sentence or two; ENS text records are kept short. */
const SPLIT_DESCRIPTION_MAX_LENGTH = 200;
const STEP_INDEX: Record<Step, number> = {
form: 0,
preview: 1,
Expand Down Expand Up @@ -139,6 +142,12 @@ const SplitterNew: FC = () => {
return addresses?.[0]?.length === 0;
}, [splitterName, addresses]);

// Free-text "what is this split for?" — stored as the `description` text
// record on the split's ENS subname (the same key member profiles use for
// their bio) so the detail / list screens can explain the split without a
// contract change.
const [description, setDescription] = useState("");

const [dutyWeight, setDutyWeight] = useState(75);
const [recvWeight, setRecvWeight] = useState(50);
const [roles, setRoles] = useState<Record<string, RoleInput>>({});
Expand Down Expand Up @@ -382,9 +391,13 @@ const SplitterNew: FC = () => {
.split;
if (created) {
try {
const trimmedDescription = description.trim();
await setName({
name: `${splitterName}.split`,
address: created,
text_records: trimmedDescription
? { description: trimmedDescription }
: undefined,
});
} catch (error) {
console.warn("Failed to set ENS name:", error);
Expand All @@ -395,7 +408,14 @@ const SplitterNew: FC = () => {
console.error("Failed to create split:", error);
toast.error("分配ルールの作成に失敗しました");
}
}, [calcSplitsParams, createSplits, setName, splitterName, weightParams]);
}, [
calcSplitsParams,
createSplits,
description,
setName,
splitterName,
weightParams,
]);

const previewSlices = useMemo<DonutSlice[]>(() => {
if (!preview || preview.totalOwnership === 0) return [];
Expand Down Expand Up @@ -498,6 +518,30 @@ const SplitterNew: FC = () => {
</Typography>
</div>

<div className="px-5">
<FieldLabel htmlFor="split-description">分配の説明</FieldLabel>
<Textarea
id="split-description"
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="例:2026年5月分の活動への報酬。当番の実績とサンクスをもとに分配します"
maxLength={SPLIT_DESCRIPTION_MAX_LENGTH}
/>
<Typography
variant="micro"
tone="secondary"
as="div"
className="mt-1 flex justify-between gap-2"
>
<span>
なんのための分配かを書いておくと、詳細画面に表示されます
</span>
<span className="tabular-nums">
{description.length} / {SPLIT_DESCRIPTION_MAX_LENGTH}
</span>
</Typography>
</div>

<div className="px-5">
<FieldLabel>何を重視する?</FieldLabel>
<Card className="gap-3 px-4 py-4">
Expand Down Expand Up @@ -786,6 +830,15 @@ const SplitterNew: FC = () => {
<Typography variant="caption" tone="secondary">
{splitterName}
</Typography>
{description.trim() && (
<Typography
variant="bodySm"
tone="secondary"
className="whitespace-pre-wrap"
>
{description.trim()}
</Typography>
)}
</Card>

<section className="flex flex-col gap-2">
Expand Down
Loading