@stage-labs/metro 0.1.0-beta.163 → 0.1.0-beta.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stage-labs/metro",
3
- "version": "0.1.0-beta.163",
3
+ "version": "0.1.0-beta.164",
4
4
  "description": "The metro command line. Sign in once per machine, then hand your MCP connector list to Claude Code without the credentials touching disk, argv or shell history.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.1.0-beta.163",
3
+ "version": "0.1.0-beta.164",
4
4
  "description": "Metro for Claude Code, installed by the metro daemon on this machine: every connector the agent holds as its own MCP server relayed through the daemon, the orchestrator-only guard on the main thread, and the standing rules loaded at each session start. No vendor credential ever sits in a config file.",
5
5
  "author": {
6
6
  "name": "Bonustrack",
@@ -1,4 +1,5 @@
1
- import { namehash, type Hex } from 'viem';
1
+ import { createPublicClient, http, namehash, type Hex } from 'viem';
2
+ import { base } from 'viem/chains';
2
3
  import { normalize } from 'viem/ens';
3
4
  import { makeProfileCache, type SenderProfile as Profile } from '@metro-labs/core/stations/sender-profile';
4
5
  import { respond } from './wire.js';
@@ -7,7 +8,6 @@ import { accountForCall, accounts, type Account } from './accounts.js';
7
8
  import { resolveAddresses } from './conv-helpers.js';
8
9
  import { nameOf } from './names.js';
9
10
  import { BASENAME_L2_RESOLVER, BASENAME_REGISTRY, NAME_ABI, REGISTRY_ABI, reverseNodeOf } from './profile.js';
10
- import { makePublicClient, type BaseClient } from './smart.js';
11
11
 
12
12
  export interface SenderProfile {
13
13
  address: string;
@@ -17,7 +17,7 @@ export interface SenderProfile {
17
17
  avatar: string | null;
18
18
  }
19
19
 
20
- const BASE_RPC = 'https://mainnet.base.org';
20
+ const BASE_RPC = 'https://rpc.brovider.xyz/8453';
21
21
  const ZERO = '0x0000000000000000000000000000000000000000';
22
22
  const AVATAR_RE = /^(https?:\/\/|ipfs:\/\/|data:image\/)/i;
23
23
 
@@ -34,28 +34,32 @@ const TEXT_ABI = [
34
34
 
35
35
  export const baseRpc = (): string => process.env.METRO_BASE_RPC ?? BASE_RPC;
36
36
 
37
- let reader: BaseClient | null = null;
38
- const readerFor = (): BaseClient => (reader ??= makePublicClient(baseRpc()));
37
+ const makeReader = (rpc: string) => createPublicClient({ chain: base, transport: http(rpc), batch: { multicall: true } });
38
+
39
+ export type Reader = ReturnType<typeof makeReader>;
40
+
41
+ let reader: Reader | null = null;
42
+ const readerFor = (): Reader => (reader ??= makeReader(baseRpc()));
39
43
 
40
44
  const trimmed = (v: string): string | null => (v.trim() === '' ? null : v.trim());
41
45
 
42
- async function resolverOf(client: BaseClient, node: Hex): Promise<Hex> {
43
- const found: Hex = await client.readContract({ address: BASENAME_REGISTRY, abi: REGISTRY_ABI, functionName: 'resolver', args: [node] }).catch(() => ZERO);
46
+ async function resolverOf(client: Reader, node: Hex): Promise<Hex> {
47
+ const found: Hex = await client.readContract({ address: BASENAME_REGISTRY, abi: REGISTRY_ABI, functionName: 'resolver', args: [node] });
44
48
  return found === ZERO ? BASENAME_L2_RESOLVER : found;
45
49
  }
46
50
 
47
- async function primaryName(client: BaseClient, address: string): Promise<string | null> {
51
+ async function primaryName(client: Reader, address: string): Promise<string | null> {
48
52
  const node = reverseNodeOf(address);
49
- const found = await client.readContract({ address: await resolverOf(client, node), abi: NAME_ABI, functionName: 'name', args: [node] }).catch(() => '');
53
+ const found = await client.readContract({ address: await resolverOf(client, node), abi: NAME_ABI, functionName: 'name', args: [node] });
50
54
  return found === '' ? null : found;
51
55
  }
52
56
 
53
- async function recordsOf(client: BaseClient, name: string, address: string): Promise<SenderProfile | null> {
57
+ async function recordsOf(client: Reader, name: string, address: string): Promise<SenderProfile | null> {
54
58
  const node = namehash(normalize(name));
55
59
  const resolver = { address: await resolverOf(client, node), abi: TEXT_ABI } as const;
56
- const text = (key: string): Promise<string> => client.readContract({ ...resolver, functionName: 'text', args: [node, key] }).catch(() => '');
60
+ const text = (key: string): Promise<string> => client.readContract({ ...resolver, functionName: 'text', args: [node, key] });
57
61
  const [forward, displayName, about, avatar] = await Promise.all([
58
- client.readContract({ ...resolver, functionName: 'addr', args: [node] }).catch(() => ZERO),
62
+ client.readContract({ ...resolver, functionName: 'addr', args: [node] }),
59
63
  text('name'),
60
64
  text('description'),
61
65
  text('avatar'),
@@ -64,11 +68,11 @@ async function recordsOf(client: BaseClient, name: string, address: string): Pro
64
68
  return { address, name, displayName: trimmed(displayName), about: trimmed(about), avatar: AVATAR_RE.test(avatar.trim()) ? avatar.trim() : null };
65
69
  }
66
70
 
67
- export async function profileOf(address: string, client: BaseClient = readerFor(), fetchImpl: typeof fetch = fetch): Promise<SenderProfile> {
71
+ export async function profileOf(address: string, client: Reader = readerFor(), fetchImpl: typeof fetch = fetch): Promise<SenderProfile> {
68
72
  const bare: SenderProfile = { address, name: null, displayName: null, about: null, avatar: null };
69
- const name = (await primaryName(client, address)) ?? (await nameOf(address, fetchImpl).catch(() => null));
73
+ const name = (await primaryName(client, address)) ?? (await nameOf(address, fetchImpl));
70
74
  if (name === null) return bare;
71
- return (await recordsOf(client, name, address).catch(() => null)) ?? bare;
75
+ return (await recordsOf(client, name, address)) ?? bare;
72
76
  }
73
77
 
74
78
  const key = (acct: Account, inboxId: string): string => `${acct.cfg.id}:${inboxId}`;
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.163"
2
+ "version": "0.1.0-beta.164"
3
3
  }