From 0f3363d9564bc6ed5abbda99b5379928faad9889 Mon Sep 17 00:00:00 2001 From: Andy Wang <41224501+andy-t-wang@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:54:34 -0700 Subject: [PATCH] remove other chains --- agentkit/src/agent-book.ts | 42 ++++++++----------------------- agentkit/tests/agent-book.test.ts | 14 +---------- cli/src/index.ts | 16 +++--------- 3 files changed, 15 insertions(+), 57 deletions(-) diff --git a/agentkit/src/agent-book.ts b/agentkit/src/agent-book.ts index 4e2c0ac..f793d6b 100644 --- a/agentkit/src/agent-book.ts +++ b/agentkit/src/agent-book.ts @@ -3,20 +3,10 @@ import { extractEVMChainId } from './evm' import { getPublicClient } from './viem-client' const WORLD_MAINNET = 'eip155:480' as const -const BASE_MAINNET = 'eip155:8453' as const -const BASE_SEPOLIA = 'eip155:84532' as const -type KnownChainId = typeof WORLD_MAINNET | typeof BASE_MAINNET | typeof BASE_SEPOLIA +const AGENT_BOOK_ADDRESS: `0x${string}` = '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' -/** Known AgentBook deployments keyed by CAIP-2 network identifier. */ -const KNOWN_DEPLOYMENTS: Record = { - [WORLD_MAINNET]: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA', - [BASE_MAINNET]: '0xE1D1D3526A6FAa37eb36bD10B933C1b77f4561a4', - [BASE_SEPOLIA]: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA', -} - - -export type AgentBookNetwork = 'world' | 'base' | 'base-sepolia' +export type AgentBookNetwork = 'world' const AGENT_BOOK_ABI = [ { @@ -35,53 +25,41 @@ export interface AgentBookOptions { contractAddress?: `0x${string}` /** Custom RPC URL. Defaults to the chain's default RPC. */ rpcUrl?: string - /** Pin lookup to the built-in Base or Base Sepolia AgentBook deployment. */ + /** Pin lookup to the built-in World Chain AgentBook deployment. */ network?: AgentBookNetwork } export function createAgentBookVerifier(options: AgentBookOptions = {}) { - function resolveLookupChainId(chainId: string): KnownChainId { - if (options.network === 'base') return BASE_MAINNET - if (options.network === 'world') return WORLD_MAINNET - if (options.network === 'base-sepolia') return BASE_SEPOLIA - - if (chainId === WORLD_MAINNET || chainId === BASE_MAINNET || chainId === BASE_SEPOLIA) { - return chainId - } - - // AgentBook is only deployed on WorldChain, Base mainnet and Base Sepolia. - // Default Worldchain mainnet unless explicitly pinned. + function resolveLookupChainId(): typeof WORLD_MAINNET { return WORLD_MAINNET } function getClient(chainId: string): PublicClient { if (options.client) return options.client - const lookupChainId = resolveLookupChainId(chainId) - const numericId = options.contractAddress && options.rpcUrl && !options.network ? extractEVMChainId(chainId) - : extractEVMChainId(lookupChainId) + : extractEVMChainId(resolveLookupChainId()) return getPublicClient(numericId, options.rpcUrl) } - function getContractAddress(chainId: string): `0x${string}` { + function getContractAddress(): `0x${string}` { if (options.contractAddress) return options.contractAddress - return KNOWN_DEPLOYMENTS[resolveLookupChainId(chainId)] + return AGENT_BOOK_ADDRESS } return { /** * Look up the anonymous human identifier for an agent's wallet address. * @param address The agent's wallet address. - * @param chainId CAIP-2 chain identifier (e.g. "eip155:480"). Built-in - * lookup resolves to Base mainnet or Base Sepolia only. + * @param chainId CAIP-2 chain identifier (e.g. "eip155:480"). Lookup always + * resolves to the World Chain AgentBook deployment. * @returns The human ID (hex string) if registered, or null. */ async lookupHuman(address: string, chainId: string): Promise { - const contractAddress = getContractAddress(chainId) + const contractAddress = getContractAddress() const client = getClient(chainId) try { diff --git a/agentkit/tests/agent-book.test.ts b/agentkit/tests/agent-book.test.ts index 836c112..dd9f825 100644 --- a/agentkit/tests/agent-book.test.ts +++ b/agentkit/tests/agent-book.test.ts @@ -24,7 +24,7 @@ describe('createAgentBookVerifier', () => { expect(calls).toEqual([{ address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' }]) }) - it('uses Base Sepolia when the request chain is Base Sepolia', async () => { + it('defaults to World Chain for unknown chains', async () => { const calls: Array<{ address: string }> = [] const verifier = createAgentBookVerifier({ client: createMockClient(1n, calls), @@ -35,18 +35,6 @@ describe('createAgentBookVerifier', () => { expect(calls).toEqual([{ address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' }]) }) - it('allows pinning lookup to Base Sepolia explicitly', async () => { - const calls: Array<{ address: string }> = [] - const verifier = createAgentBookVerifier({ - client: createMockClient(1n, calls), - network: 'base-sepolia', - }) - - await verifier.lookupHuman('0x1234567890abcdef1234567890abcdef12345678', 'eip155:480') - - expect(calls).toEqual([{ address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' }]) - }) - it('still honors custom contract deployments', async () => { const calls: Array<{ address: string }> = [] const verifier = createAgentBookVerifier({ diff --git a/cli/src/index.ts b/cli/src/index.ts index 946c381..5e0f1b7 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -3,7 +3,7 @@ import './polyfill.js' import { Cli, z } from 'incur' import { createPublicClient, http, decodeAbiParameters } from 'viem' import type { Hex } from 'viem' -import { base, baseSepolia, worldchain } from 'viem/chains' +import { worldchain } from 'viem/chains' import { createWorldBridgeStore } from '@worldcoin/idkit-core' import type { ISuccessResult } from '@worldcoin/idkit-core' import { solidityEncode } from '@worldcoin/idkit-core/hashing' @@ -12,9 +12,7 @@ import qrcode from 'qrcode-terminal' // ─── Config ────────────────────────────────────────────────────────────────── const NETWORKS = { - base: { chain: base, address: '0xE1D1D3526A6FAa37eb36bD10B933C1b77f4561a4' as const }, - world: { chain: worldchain, address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' as const}, - 'base-sepolia': { chain: baseSepolia, address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' as const }, + world: { chain: worldchain, address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' as const }, } as const const NETWORK_NAMES = Object.keys(NETWORKS) as [keyof typeof NETWORKS, ...Array] @@ -32,7 +30,6 @@ const AGENT_BOOK_ABI = [ const APP_ID = 'app_a7c3e2b6b83927251a0db5345bd7146a' const ACTION = 'agentbook-registration' const DEFAULT_AUTO_API_URLS: Partial> = { - base: 'https://x402-worldchain.vercel.app', world: 'https://x402-worldchain.vercel.app', } @@ -58,7 +55,7 @@ cli.command('register', { API_URL: z .string() .optional() - .describe('Override API base URL for registration relay; base mainnet defaults to https://x402-worldchain.vercel.app'), + .describe('Override API base URL for registration relay; defaults to https://x402-worldchain.vercel.app'), }), output: z.object({ agent: z.string(), @@ -71,12 +68,7 @@ cli.command('register', { txHash: z.string().optional(), }), examples: [ - { args: { address: '0x1234567890abcdef1234567890abcdef12345678' }, description: 'Register on Base mainnet' }, - { - args: { address: '0x1234567890abcdef1234567890abcdef12345678' }, - options: { network: 'base-sepolia' }, - description: 'Register on Sepolia', - }, + { args: { address: '0x1234567890abcdef1234567890abcdef12345678' }, description: 'Register on World Chain' }, ], async run(c) { const agentAddress = c.args.address as `0x${string}`