From cc0b38c4168afb85954ce089e1ceaeea5248f706 Mon Sep 17 00:00:00 2001 From: yegetaneh firew Date: Sat, 24 Oct 2026 05:15:56 +0000 Subject: [PATCH] Support ENS names wherever an address is accepted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add lib/blockchain/ens.ts: resolveAddress() accepts a 0x address or an ENS name, normalizes the name and resolves it on Sepolia's ENS. - Balance, token balance, wallet analysis and prepareTransaction accept names and return the name alongside the resolved address. - Transfer previews record toEnsName, show "name resolves to 0x…" in the recipient check and warn the user to confirm the resolved address. The wallet still signs only the resolved address. - Cards show the name next to the short address; the agent prompt and tool descriptions mention ENS. - Add tests/ens.test.ts. --- README.md | 1 + src/components/cards/activity-card.tsx | 2 +- src/components/cards/primitives.tsx | 12 ++- src/components/cards/read-cards.tsx | 4 +- .../cards/transaction-preview-card.tsx | 2 +- src/lib/agent/prompt.ts | 2 + src/lib/agent/tools.ts | 9 ++- src/lib/blockchain/ens.ts | 54 ++++++++++++++ src/lib/blockchain/reader.ts | 7 +- src/lib/blockchain/transfer.ts | 21 +++++- tests/ens.test.ts | 73 +++++++++++++++++++ 11 files changed, 170 insertions(+), 17 deletions(-) create mode 100644 src/lib/blockchain/ens.ts create mode 100644 tests/ens.test.ts diff --git a/README.md b/README.md index 6e13d50..32a6d69 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Chainly is an AI agent for **Ethereum Sepolia** (chain ID `11155111`). You ask q - 🔎 **Read:** ETH balances, ERC-20 balances (USDC, WETH and LINK by symbol, or any contract), transaction details, gas prices, block info. - 📊 **Analyze:** explorer history turned into money in and out, net flow, gas spent, counterparties, contract usage, a daily chart and insights backed by the data. - ✍️ **Prepare:** validates the address, amount, balance and network, estimates gas, and shows a preview card. **You** sign in your wallet. +- 🏷️ **ENS names:** use `alice.eth` anywhere an address is expected. Names resolve on Sepolia's own ENS registry (mainnet names may not exist there), and previews show the name next to the resolved address that your wallet signs. - 🛡️ **Safety:** - No signing tools. - The sender is locked to the connected wallet. diff --git a/src/components/cards/activity-card.tsx b/src/components/cards/activity-card.tsx index ce1d536..40ba6dd 100644 --- a/src/components/cards/activity-card.tsx +++ b/src/components/cards/activity-card.tsx @@ -23,7 +23,7 @@ export function ActivityCard({ data }: { data: Data }) { title="Wallet activity" meta={ - · {s.totalTransactions} txs · {data.source} + · {s.totalTransactions} txs · {data.source} } right={} diff --git a/src/components/cards/primitives.tsx b/src/components/cards/primitives.tsx index 0401a48..32221e1 100644 --- a/src/components/cards/primitives.tsx +++ b/src/components/cards/primitives.tsx @@ -49,7 +49,7 @@ export function Row({ label, children }: { label: string; children: ReactNode }) ); } -export function AddressLink({ address, chars = 4 }: { address: string | null | undefined; chars?: number }) { +export function AddressLink({ address, name, chars = 4 }: { address: string | null | undefined; name?: string | null; chars?: number }) { const { copied, copy } = useCopy(); if (!address) return —; return ( @@ -59,9 +59,15 @@ export function AddressLink({ address, chars = 4 }: { address: string | null | u target="_blank" rel="noreferrer" className="underline-offset-2 hover:text-foreground hover:underline" - title={address} + title={name ? `${name} → ${address}` : address} > - {shortAddress(address, chars)} + {name ? ( + <> + {name} {shortAddress(address, chars)} + + ) : ( + shortAddress(address, chars) + )}