diff --git a/agentkit/package.json b/agentkit/package.json index 26549fd..8a3119c 100644 --- a/agentkit/package.json +++ b/agentkit/package.json @@ -1,6 +1,6 @@ { "name": "@worldcoin/agentkit", - "version": "0.1.4", + "version": "0.1.5", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.mjs", "types": "./dist/cjs/index.d.ts", diff --git a/agentkit/src/agent-book.ts b/agentkit/src/agent-book.ts index f793d6b..0215a4d 100644 --- a/agentkit/src/agent-book.ts +++ b/agentkit/src/agent-book.ts @@ -6,8 +6,6 @@ const WORLD_MAINNET = 'eip155:480' as const const AGENT_BOOK_ADDRESS: `0x${string}` = '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' -export type AgentBookNetwork = 'world' - const AGENT_BOOK_ABI = [ { inputs: [{ internalType: 'address', name: '', type: 'address' }], @@ -21,26 +19,20 @@ const AGENT_BOOK_ABI = [ export interface AgentBookOptions { /** Custom viem PublicClient. Overrides automatic client creation. */ client?: PublicClient - /** Custom contract address. Overrides the built-in network → address mapping. */ + /** Custom contract address. Overrides the built-in World Chain deployment. */ contractAddress?: `0x${string}` /** Custom RPC URL. Defaults to the chain's default RPC. */ rpcUrl?: string - /** Pin lookup to the built-in World Chain AgentBook deployment. */ - network?: AgentBookNetwork } export function createAgentBookVerifier(options: AgentBookOptions = {}) { - function resolveLookupChainId(): typeof WORLD_MAINNET { - return WORLD_MAINNET - } - function getClient(chainId: string): PublicClient { if (options.client) return options.client const numericId = - options.contractAddress && options.rpcUrl && !options.network + options.contractAddress && options.rpcUrl ? extractEVMChainId(chainId) - : extractEVMChainId(resolveLookupChainId()) + : extractEVMChainId(WORLD_MAINNET) return getPublicClient(numericId, options.rpcUrl) } diff --git a/agentkit/src/index.ts b/agentkit/src/index.ts index 93915f2..a1253d3 100644 --- a/agentkit/src/index.ts +++ b/agentkit/src/index.ts @@ -40,12 +40,7 @@ export { } from './solana' // AgentBook -export { - createAgentBookVerifier, - type AgentBookVerifier, - type AgentBookOptions, - type AgentBookNetwork, -} from './agent-book' +export { createAgentBookVerifier, type AgentBookVerifier, type AgentBookOptions } from './agent-book' // Storage export { InMemoryAgentKitStorage, type AgentKitStorage } from './storage' diff --git a/cli/package.json b/cli/package.json index 407bbb8..3611256 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@worldcoin/agentkit-cli", - "version": "0.1.5", + "version": "0.1.6", "description": "Register agent wallets with World ID-verified humans via AgentBook.", "type": "module", "main": "dist/index.js", diff --git a/cli/src/index.ts b/cli/src/index.ts index 5e0f1b7..ee378fc 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -11,11 +11,7 @@ import qrcode from 'qrcode-terminal' // ─── Config ────────────────────────────────────────────────────────────────── -const NETWORKS = { - world: { chain: worldchain, address: '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' as const }, -} as const - -const NETWORK_NAMES = Object.keys(NETWORKS) as [keyof typeof NETWORKS, ...Array] +const AGENT_BOOK_CONTRACT = '0xA23aB2712eA7BBa896930544C7d6636a96b944dA' as const const AGENT_BOOK_ABI = [ { @@ -29,9 +25,7 @@ const AGENT_BOOK_ABI = [ const APP_ID = 'app_a7c3e2b6b83927251a0db5345bd7146a' const ACTION = 'agentbook-registration' -const DEFAULT_AUTO_API_URLS: Partial> = { - world: 'https://x402-worldchain.vercel.app', -} +const DEFAULT_API_URL = 'https://x402-worldchain.vercel.app' // ─── CLI ───────────────────────────────────────────────────────────────────── @@ -46,11 +40,10 @@ cli.command('register', { address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address').describe('Agent wallet address'), }), options: z.object({ - network: z.enum(NETWORK_NAMES).default('world').describe('Target network'), auto: z.boolean().default(true).describe('Submit registration to the default relay or API_URL override'), manual: z.boolean().optional().describe('Print manual call data instead of submitting through a relay'), }), - alias: { network: 'n', auto: 'a', manual: 'm' }, + alias: { auto: 'a', manual: 'm' }, env: z.object({ API_URL: z .string() @@ -64,7 +57,6 @@ cli.command('register', { nullifierHash: z.string(), proof: z.array(z.string()), contract: z.string(), - network: z.string(), txHash: z.string().optional(), }), examples: [ @@ -72,15 +64,14 @@ cli.command('register', { ], async run(c) { const agentAddress = c.args.address as `0x${string}` - const deployment = NETWORKS[c.options.network] const shouldAuto = c.options.manual ? false : c.options.auto // 1. Read next nonce from AgentBook contract if (!c.agent) console.log(`Looking up next nonce for ${agentAddress}...`) - const client = createPublicClient({ chain: deployment.chain, transport: http() }) + const client = createPublicClient({ chain: worldchain, transport: http() }) const nonce = await client.readContract({ - address: deployment.address, + address: AGENT_BOOK_CONTRACT, abi: AGENT_BOOK_ABI, functionName: 'getNextNonce', args: [agentAddress], @@ -142,8 +133,7 @@ cli.command('register', { nonce: nonce.toString(), nullifierHash: completion.proof.nullifier_hash, proof, - contract: deployment.address, - network: c.options.network, + contract: AGENT_BOOK_CONTRACT, } if (!shouldAuto) { @@ -151,7 +141,7 @@ cli.command('register', { console.log() console.log('Submit this transaction on-chain:') console.log() - console.log(`Contract: ${deployment.address}`) + console.log(`Contract: ${AGENT_BOOK_CONTRACT}`) console.log( 'Function: register(address agent, uint256 root, uint256 nonce, uint256 nullifierHash, uint256[8] proof)' ) @@ -160,13 +150,7 @@ cli.command('register', { return registration } - const apiUrl = c.env.API_URL ?? DEFAULT_AUTO_API_URLS[c.options.network] - if (!apiUrl) { - return c.error({ - code: 'MISSING_API_URL', - message: `No default registration relay is configured for network ${c.options.network}. Set API_URL to use --auto on this network.`, - }) - } + const apiUrl = c.env.API_URL ?? DEFAULT_API_URL const registerUrl = `${apiUrl.replace(/\/$/, '')}/register`