@clawlogic/sdk 0.0.1

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.
Files changed (62) hide show
  1. package/README.md +227 -0
  2. package/dist/abis/agentIdentityRegistryAbi.d.ts +532 -0
  3. package/dist/abis/agentIdentityRegistryAbi.d.ts.map +1 -0
  4. package/dist/abis/agentIdentityRegistryAbi.js +2 -0
  5. package/dist/abis/agentIdentityRegistryAbi.js.map +1 -0
  6. package/dist/abis/agentRegistryAbi.d.ts +265 -0
  7. package/dist/abis/agentRegistryAbi.d.ts.map +1 -0
  8. package/dist/abis/agentRegistryAbi.js +151 -0
  9. package/dist/abis/agentRegistryAbi.js.map +1 -0
  10. package/dist/abis/agentReputationRegistryAbi.d.ts +224 -0
  11. package/dist/abis/agentReputationRegistryAbi.d.ts.map +1 -0
  12. package/dist/abis/agentReputationRegistryAbi.js +2 -0
  13. package/dist/abis/agentReputationRegistryAbi.js.map +1 -0
  14. package/dist/abis/agentValidationRegistryAbi.d.ts +281 -0
  15. package/dist/abis/agentValidationRegistryAbi.d.ts.map +1 -0
  16. package/dist/abis/agentValidationRegistryAbi.js +2 -0
  17. package/dist/abis/agentValidationRegistryAbi.js.map +1 -0
  18. package/dist/abis/outcomeTokenAbi.d.ts +255 -0
  19. package/dist/abis/outcomeTokenAbi.d.ts.map +1 -0
  20. package/dist/abis/outcomeTokenAbi.js +152 -0
  21. package/dist/abis/outcomeTokenAbi.js.map +1 -0
  22. package/dist/abis/predictionMarketHookAbi.d.ts +396 -0
  23. package/dist/abis/predictionMarketHookAbi.d.ts.map +1 -0
  24. package/dist/abis/predictionMarketHookAbi.js +212 -0
  25. package/dist/abis/predictionMarketHookAbi.js.map +1 -0
  26. package/dist/client.d.ts +241 -0
  27. package/dist/client.d.ts.map +1 -0
  28. package/dist/client.js +569 -0
  29. package/dist/client.js.map +1 -0
  30. package/dist/config.d.ts +84 -0
  31. package/dist/config.d.ts.map +1 -0
  32. package/dist/config.js +134 -0
  33. package/dist/config.js.map +1 -0
  34. package/dist/identity.d.ts +133 -0
  35. package/dist/identity.d.ts.map +1 -0
  36. package/dist/identity.js +314 -0
  37. package/dist/identity.js.map +1 -0
  38. package/dist/index.d.ts +13 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +19 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/types.d.ts +191 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +11 -0
  45. package/dist/types.js.map +1 -0
  46. package/package.json +51 -0
  47. package/src/abis/.gitkeep +0 -0
  48. package/src/abis/AgentRegistry.json +1 -0
  49. package/src/abis/ENSAgentHelper.json +1 -0
  50. package/src/abis/OutcomeToken.json +1 -0
  51. package/src/abis/PredictionMarketHook.json +1 -0
  52. package/src/abis/agentIdentityRegistryAbi.ts +1 -0
  53. package/src/abis/agentRegistryAbi.ts +150 -0
  54. package/src/abis/agentReputationRegistryAbi.ts +1 -0
  55. package/src/abis/agentValidationRegistryAbi.ts +1 -0
  56. package/src/abis/outcomeTokenAbi.ts +153 -0
  57. package/src/abis/predictionMarketHookAbi.ts +214 -0
  58. package/src/client.ts +722 -0
  59. package/src/config.ts +161 -0
  60. package/src/identity.ts +395 -0
  61. package/src/index.ts +48 -0
  62. package/src/types.ts +207 -0
package/src/config.ts ADDED
@@ -0,0 +1,161 @@
1
+ import type { ClawlogicConfig, DeploymentInfo } from './types.js';
2
+
3
+ // ─────────────────────────────────────────────────────────────────────────────
4
+ // Arbitrum Sepolia
5
+ // ─────────────────────────────────────────────────────────────────────────────
6
+
7
+ /**
8
+ * Arbitrum Sepolia chain ID.
9
+ */
10
+ export const ARBITRUM_SEPOLIA_CHAIN_ID = 421614;
11
+
12
+ /**
13
+ * Default RPC URL for Arbitrum Sepolia.
14
+ */
15
+ export const ARBITRUM_SEPOLIA_RPC_URL = 'https://sepolia-rollup.arbitrum.io/rpc';
16
+
17
+ /**
18
+ * Default configuration for Arbitrum Sepolia testnet.
19
+ *
20
+ * Contract addresses are placeholders and will be updated after deployment.
21
+ * Use `loadConfig()` to load real addresses from a deployments JSON file.
22
+ */
23
+ export const ARBITRUM_SEPOLIA_CONFIG: ClawlogicConfig = {
24
+ chainId: ARBITRUM_SEPOLIA_CHAIN_ID,
25
+ rpcUrl: ARBITRUM_SEPOLIA_RPC_URL,
26
+ contracts: {
27
+ agentRegistry: '0x0000000000000000000000000000000000000000',
28
+ predictionMarketHook: '0x0000000000000000000000000000000000000000',
29
+ poolManager: '0x0000000000000000000000000000000000000000',
30
+ optimisticOracleV3: '0x0000000000000000000000000000000000000000',
31
+ },
32
+ };
33
+
34
+ // ─────────────────────────────────────────────────────────────────────────────
35
+ // Circle Arc Testnet
36
+ // ─────────────────────────────────────────────────────────────────────────────
37
+
38
+ /**
39
+ * Circle Arc testnet chain ID.
40
+ */
41
+ export const ARC_TESTNET_CHAIN_ID = 5042002;
42
+
43
+ /**
44
+ * Default RPC URL for Circle Arc testnet.
45
+ */
46
+ export const ARC_TESTNET_RPC_URL = 'https://rpc.testnet.arc.network';
47
+
48
+ /**
49
+ * Block explorer URL for Circle Arc testnet.
50
+ */
51
+ export const ARC_TESTNET_EXPLORER_URL = 'https://testnet.arcscan.app';
52
+
53
+ /**
54
+ * Default configuration for Circle Arc testnet.
55
+ *
56
+ * Arc is Circle's EVM-compatible L1 where USDC is the native gas token.
57
+ * On Arc, `msg.value` sends native USDC (18 decimals), so the existing
58
+ * `mintOutcomeTokens()` payable function works directly -- collateral is
59
+ * USDC instead of ETH.
60
+ *
61
+ * Important: Uniswap V4 and UMA OOV3 are NOT natively available on Arc.
62
+ * The deployment uses mock contracts for both. V4 pool swaps are not
63
+ * functional; only the prediction market lifecycle operates.
64
+ *
65
+ * Contract addresses are placeholders and will be updated after deployment.
66
+ * Use `loadConfigFromDeployment()` to load real addresses.
67
+ */
68
+ export const ARC_TESTNET_CONFIG: ClawlogicConfig = {
69
+ chainId: ARC_TESTNET_CHAIN_ID,
70
+ rpcUrl: ARC_TESTNET_RPC_URL,
71
+ contracts: {
72
+ agentRegistry: '0x0000000000000000000000000000000000000000',
73
+ predictionMarketHook: '0x0000000000000000000000000000000000000000',
74
+ poolManager: '0x0000000000000000000000000000000000000000',
75
+ optimisticOracleV3: '0x0000000000000000000000000000000000000000',
76
+ },
77
+ };
78
+
79
+ /**
80
+ * Load a ClawlogicConfig from a deployments JSON file.
81
+ *
82
+ * The deployments JSON must conform to the DeploymentInfo interface:
83
+ * ```json
84
+ * {
85
+ * "chainId": 421614,
86
+ * "deployer": "0x...",
87
+ * "deployedAt": "2026-02-XX",
88
+ * "blockNumber": 0,
89
+ * "contracts": {
90
+ * "AgentRegistry": "0x...",
91
+ * "PredictionMarketHook": "0x...",
92
+ * "PoolManager": "0x..."
93
+ * }
94
+ * }
95
+ * ```
96
+ *
97
+ * @param deployment - The parsed deployment info object.
98
+ * @param rpcUrl - Optional RPC URL override. Defaults based on chain ID:
99
+ * - Arc testnet (5042002) -> Arc testnet RPC
100
+ * - All others -> Arbitrum Sepolia public RPC
101
+ * @returns A ClawlogicConfig ready for use with the ClawlogicClient.
102
+ */
103
+ export function loadConfigFromDeployment(
104
+ deployment: DeploymentInfo,
105
+ rpcUrl?: string,
106
+ ): ClawlogicConfig {
107
+ const defaultRpc =
108
+ deployment.chainId === ARC_TESTNET_CHAIN_ID
109
+ ? ARC_TESTNET_RPC_URL
110
+ : ARBITRUM_SEPOLIA_RPC_URL;
111
+
112
+ const zero = '0x0000000000000000000000000000000000000000' as `0x${string}`;
113
+
114
+ return {
115
+ chainId: deployment.chainId,
116
+ rpcUrl: rpcUrl ?? defaultRpc,
117
+ contracts: {
118
+ agentRegistry: deployment.contracts.AgentRegistry as `0x${string}`,
119
+ predictionMarketHook: deployment.contracts.PredictionMarketHook as `0x${string}`,
120
+ poolManager: deployment.contracts.PoolManager as `0x${string}`,
121
+ optimisticOracleV3: (deployment.contracts.OptimisticOracleV3 ?? zero) as `0x${string}`,
122
+ bondCurrency: (deployment.contracts.BondCurrency ?? zero) as `0x${string}`,
123
+ ensRegistry: (deployment.contracts.ENSRegistry ?? zero) as `0x${string}`,
124
+ agentIdentityRegistry: (deployment.contracts.AgentIdentityRegistry ?? zero) as `0x${string}`,
125
+ agentValidationRegistry: (deployment.contracts.AgentValidationRegistry ?? zero) as `0x${string}`,
126
+ agentReputationRegistry: (deployment.contracts.AgentReputationRegistry ?? zero) as `0x${string}`,
127
+ phalaVerifier: (deployment.contracts.PhalaVerifier ?? zero) as `0x${string}`,
128
+ },
129
+ };
130
+ }
131
+
132
+ /**
133
+ * Create a ClawlogicConfig from explicit contract addresses.
134
+ *
135
+ * @param addresses - Object with contract addresses.
136
+ * @param chainId - Chain ID (default: Arbitrum Sepolia 421614).
137
+ * @param rpcUrl - RPC URL (default: Arbitrum Sepolia public RPC).
138
+ * @returns A ClawlogicConfig ready for use with the ClawlogicClient.
139
+ */
140
+ export function createConfig(
141
+ addresses: {
142
+ agentRegistry: `0x${string}`;
143
+ predictionMarketHook: `0x${string}`;
144
+ poolManager: `0x${string}`;
145
+ optimisticOracleV3?: `0x${string}`;
146
+ },
147
+ chainId = ARBITRUM_SEPOLIA_CHAIN_ID,
148
+ rpcUrl = ARBITRUM_SEPOLIA_RPC_URL,
149
+ ): ClawlogicConfig {
150
+ return {
151
+ chainId,
152
+ rpcUrl,
153
+ contracts: {
154
+ agentRegistry: addresses.agentRegistry,
155
+ predictionMarketHook: addresses.predictionMarketHook,
156
+ poolManager: addresses.poolManager,
157
+ optimisticOracleV3:
158
+ addresses.optimisticOracleV3 ?? '0x0000000000000000000000000000000000000000',
159
+ },
160
+ };
161
+ }
@@ -0,0 +1,395 @@
1
+ /**
2
+ * @file identity.ts
3
+ *
4
+ * Phase 1 Identity & Trust infrastructure for $CLAWLOGIC.
5
+ *
6
+ * Provides SDK methods for:
7
+ * - ENS agent identity resolution
8
+ * - ERC-8004 identity, reputation, and validation registries
9
+ * - Phala TEE attestation verification
10
+ */
11
+
12
+ import type {
13
+ PublicClient,
14
+ WalletClient,
15
+ Transport,
16
+ Chain,
17
+ Account,
18
+ } from 'viem';
19
+ import { namehash } from 'viem/ens';
20
+ import type {
21
+ AgentInfo,
22
+ ReputationScore,
23
+ GlobalReputationScore,
24
+ ValidationProof,
25
+ AgentRegistrationOptions,
26
+ } from './types.js';
27
+ import { ValidationType } from './types.js';
28
+
29
+ // Placeholder ABIs - will be populated after contract deployment
30
+ import { agentIdentityRegistryAbi } from './abis/agentIdentityRegistryAbi.js';
31
+ import { agentReputationRegistryAbi } from './abis/agentReputationRegistryAbi.js';
32
+ import { agentValidationRegistryAbi } from './abis/agentValidationRegistryAbi.js';
33
+
34
+ /**
35
+ * Extended contract addresses for Phase 1 identity infrastructure.
36
+ */
37
+ export interface IdentityContracts {
38
+ agentIdentityRegistry: `0x${string}`;
39
+ agentReputationRegistry: `0x${string}`;
40
+ agentValidationRegistry: `0x${string}`;
41
+ ensRegistry?: `0x${string}`; // Optional: 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e on most chains
42
+ }
43
+
44
+ /**
45
+ * Identity client for Phase 1 ENS + ERC-8004 + TEE functionality.
46
+ *
47
+ * This class extends the base ClawlogicClient with identity-related methods.
48
+ * Use this alongside ClawlogicClient for full protocol interaction.
49
+ */
50
+ export class IdentityClient {
51
+ constructor(
52
+ private readonly publicClient: PublicClient<Transport, Chain>,
53
+ private readonly walletClient: WalletClient<Transport, Chain, Account> | undefined,
54
+ private readonly contracts: IdentityContracts,
55
+ ) {}
56
+
57
+ // ═══════════════════════════════════════════════════════════════════════════
58
+ // ENS Methods
59
+ // ═══════════════════════════════════════════════════════════════════════════
60
+
61
+ /**
62
+ * Resolve an ENS name to an agent address.
63
+ *
64
+ * @param ensName - ENS name (e.g., "alpha.agent.eth")
65
+ * @returns Agent address, or null if not found
66
+ */
67
+ async resolveAgentENS(ensName: string): Promise<`0x${string}` | null> {
68
+ try {
69
+ // ENS resolution is handled by AgentRegistry.getAgentByENS(), not the
70
+ // identity registry. Use the main ClawlogicClient for ENS resolution.
71
+ // This method is a no-op placeholder; callers should use
72
+ // ClawlogicClient.getAgentByENS() directly.
73
+ return null;
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Get the ENS name for a given agent address (reverse resolution).
81
+ *
82
+ * @param address - Agent address
83
+ * @returns ENS name, or null if not linked
84
+ */
85
+ async getAgentENSName(address: `0x${string}`): Promise<string | null> {
86
+ try {
87
+ // This will be implemented once AgentRegistry includes ENS reverse mapping
88
+ // For now, return null (requires contract support)
89
+ return null;
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+
95
+ // ═══════════════════════════════════════════════════════════════════════════
96
+ // ERC-8004 Identity Registry Methods
97
+ // ═══════════════════════════════════════════════════════════════════════════
98
+
99
+ /**
100
+ * Get the ERC-8004 identity token for an agent address.
101
+ *
102
+ * @param address - Agent address
103
+ * @returns Object with tokenId and metadataURI, or null if no identity exists
104
+ */
105
+ async getAgentIdentityToken(
106
+ address: `0x${string}`,
107
+ ): Promise<{ tokenId: bigint; metadataURI: string } | null> {
108
+ try {
109
+ // Check balance first — should be 1 if agent has identity
110
+ const balance = await this.publicClient.readContract({
111
+ address: this.contracts.agentIdentityRegistry,
112
+ abi: agentIdentityRegistryAbi,
113
+ functionName: 'balanceOf',
114
+ args: [address],
115
+ }) as bigint;
116
+
117
+ if (balance === 0n) {
118
+ return null;
119
+ }
120
+
121
+ // The registry doesn't have tokenOfOwnerByIndex (not ERC-721 Enumerable).
122
+ // Scan sequential token IDs from 1..totalAgents to find one owned by address.
123
+ const totalAgents = await this.publicClient.readContract({
124
+ address: this.contracts.agentIdentityRegistry,
125
+ abi: agentIdentityRegistryAbi,
126
+ functionName: 'totalAgents',
127
+ }) as bigint;
128
+
129
+ for (let id = 1n; id <= totalAgents; id++) {
130
+ try {
131
+ const owner = await this.publicClient.readContract({
132
+ address: this.contracts.agentIdentityRegistry,
133
+ abi: agentIdentityRegistryAbi,
134
+ functionName: 'ownerOf',
135
+ args: [id],
136
+ }) as `0x${string}`;
137
+
138
+ if (owner.toLowerCase() === address.toLowerCase()) {
139
+ const metadataURI = await this.publicClient.readContract({
140
+ address: this.contracts.agentIdentityRegistry,
141
+ abi: agentIdentityRegistryAbi,
142
+ functionName: 'tokenURI',
143
+ args: [id],
144
+ }) as string;
145
+ return { tokenId: id, metadataURI };
146
+ }
147
+ } catch {
148
+ // Token ID might not exist; continue scanning
149
+ }
150
+ }
151
+
152
+ return null;
153
+ } catch {
154
+ return null;
155
+ }
156
+ }
157
+
158
+ // ═══════════════════════════════════════════════════════════════════════════
159
+ // ERC-8004 Reputation Registry Methods
160
+ // ═══════════════════════════════════════════════════════════════════════════
161
+
162
+ /**
163
+ * Get the reputation score for an agent.
164
+ *
165
+ * @param agentId - ERC-8004 agent identity token ID
166
+ * @returns Reputation score with assertions, volume, and accuracy
167
+ */
168
+ async getAgentReputation(agentId: bigint): Promise<ReputationScore> {
169
+ const result = await this.publicClient.readContract({
170
+ address: this.contracts.agentReputationRegistry,
171
+ abi: agentReputationRegistryAbi,
172
+ functionName: 'getReputationScore',
173
+ args: [agentId],
174
+ });
175
+
176
+ const score = result as {
177
+ totalAssertions: bigint;
178
+ successfulAssertions: bigint;
179
+ totalVolume: bigint;
180
+ lastUpdated: bigint;
181
+ };
182
+
183
+ return {
184
+ totalAssertions: score.totalAssertions,
185
+ successfulAssertions: score.successfulAssertions,
186
+ totalVolume: score.totalVolume,
187
+ lastUpdated: score.lastUpdated,
188
+ };
189
+ }
190
+
191
+ /**
192
+ * Get the assertion accuracy percentage for an agent.
193
+ *
194
+ * @param agentId - ERC-8004 agent identity token ID
195
+ * @returns Accuracy as a number 0-100 (percentage)
196
+ */
197
+ async getAssertionAccuracy(agentId: bigint): Promise<number> {
198
+ const accuracy = await this.publicClient.readContract({
199
+ address: this.contracts.agentReputationRegistry,
200
+ abi: agentReputationRegistryAbi,
201
+ functionName: 'getAccuracy',
202
+ args: [agentId],
203
+ }) as bigint;
204
+
205
+ // Convert from basis points (0-10000) to percentage (0-100)
206
+ return Number(accuracy) / 100;
207
+ }
208
+
209
+ /**
210
+ * Get global reputation aggregated across all chains.
211
+ *
212
+ * This method queries The Graph subgraph (Phase 3.3) for cross-chain data.
213
+ * For single-chain use, falls back to local chain reputation.
214
+ *
215
+ * @param agentId - ERC-8004 agent identity token ID
216
+ * @returns Global reputation score
217
+ */
218
+ async getGlobalReputation(agentId: bigint): Promise<GlobalReputationScore> {
219
+ // TODO: Implement The Graph query in Phase 3.3
220
+ // For now, return local chain reputation only
221
+ const localScore = await this.getAgentReputation(agentId);
222
+ const accuracy = await this.getAssertionAccuracy(agentId);
223
+
224
+ return {
225
+ agentId,
226
+ chainScores: new Map(), // Will be populated in Phase 3.3
227
+ totalAssertions: localScore.totalAssertions,
228
+ successfulAssertions: localScore.successfulAssertions,
229
+ accuracy: BigInt(Math.round(accuracy * 100)), // Convert to basis points
230
+ };
231
+ }
232
+
233
+ // ═══════════════════════════════════════════════════════════════════════════
234
+ // ERC-8004 Validation Registry Methods
235
+ // ═══════════════════════════════════════════════════════════════════════════
236
+
237
+ /**
238
+ * Check if an agent has a specific validation type verified.
239
+ *
240
+ * @param agentId - ERC-8004 agent identity token ID
241
+ * @param validationType - Type of validation to check (TEE, STAKE, ZKML)
242
+ * @returns True if validated, false otherwise
243
+ */
244
+ async isValidated(
245
+ agentId: bigint,
246
+ validationType: ValidationType,
247
+ ): Promise<boolean> {
248
+ const result = await this.publicClient.readContract({
249
+ address: this.contracts.agentValidationRegistry,
250
+ abi: agentValidationRegistryAbi,
251
+ functionName: 'isValidated',
252
+ args: [agentId, validationType],
253
+ });
254
+
255
+ return result as boolean;
256
+ }
257
+
258
+ /**
259
+ * Get validation proof for a specific validation type.
260
+ *
261
+ * @param agentId - ERC-8004 agent identity token ID
262
+ * @param validationType - Type of validation
263
+ * @returns Validation proof data, or null if not found
264
+ */
265
+ async getValidationProof(
266
+ agentId: bigint,
267
+ validationType: ValidationType,
268
+ ): Promise<ValidationProof | null> {
269
+ try {
270
+ const result = await this.publicClient.readContract({
271
+ address: this.contracts.agentValidationRegistry,
272
+ abi: agentValidationRegistryAbi,
273
+ functionName: 'getValidation',
274
+ args: [agentId, validationType],
275
+ });
276
+
277
+ const validation = result as {
278
+ validationType: number;
279
+ proof: `0x${string}`;
280
+ timestamp: bigint;
281
+ valid: boolean;
282
+ };
283
+
284
+ return {
285
+ validationType: validation.validationType as ValidationType,
286
+ proof: validation.proof,
287
+ timestamp: validation.timestamp,
288
+ valid: validation.valid,
289
+ };
290
+ } catch {
291
+ return null;
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Check if an agent is TEE-verified.
297
+ *
298
+ * Convenience method for checking TEE validation status.
299
+ *
300
+ * @param address - Agent address
301
+ * @returns True if TEE-verified, false otherwise
302
+ */
303
+ async isTeeVerified(address: `0x${string}`): Promise<boolean> {
304
+ const identity = await this.getAgentIdentityToken(address);
305
+ if (!identity) {
306
+ return false;
307
+ }
308
+
309
+ return this.isValidated(identity.tokenId, ValidationType.TEE);
310
+ }
311
+
312
+ // ═══════════════════════════════════════════════════════════════════════════
313
+ // Write Methods (require wallet client)
314
+ // ═══════════════════════════════════════════════════════════════════════════
315
+
316
+ /**
317
+ * Submit a validation proof for verification.
318
+ *
319
+ * @param agentId - ERC-8004 agent identity token ID
320
+ * @param proof - Validation proof bytes
321
+ * @param validationType - Type of validation being submitted
322
+ * @returns Transaction hash
323
+ */
324
+ async submitValidation(
325
+ agentId: bigint,
326
+ proof: `0x${string}`,
327
+ validationType: ValidationType,
328
+ ): Promise<`0x${string}`> {
329
+ if (!this.walletClient) {
330
+ throw new Error('IdentityClient: Wallet client required for write operations');
331
+ }
332
+
333
+ const hash = await this.walletClient.writeContract({
334
+ address: this.contracts.agentValidationRegistry,
335
+ abi: agentValidationRegistryAbi,
336
+ functionName: 'submitValidation',
337
+ args: [agentId, proof, validationType],
338
+ });
339
+
340
+ return hash;
341
+ }
342
+
343
+ // ═══════════════════════════════════════════════════════════════════════════
344
+ // Helper Methods
345
+ // ═══════════════════════════════════════════════════════════════════════════
346
+
347
+ /**
348
+ * Get extended agent info including ENS, identity token, and reputation.
349
+ *
350
+ * This is a convenience method that aggregates data from multiple registries.
351
+ *
352
+ * @param address - Agent address
353
+ * @returns Extended AgentInfo with all identity data
354
+ */
355
+ async getExtendedAgentInfo(address: `0x${string}`): Promise<AgentInfo & {
356
+ ensName: string | null;
357
+ identityToken: { tokenId: bigint; metadataURI: string } | null;
358
+ teeVerified: boolean;
359
+ }> {
360
+ // Get base agent info (from main AgentRegistry)
361
+ // This will be called from the main client
362
+
363
+ // Get ENS name
364
+ const ensName = await this.getAgentENSName(address);
365
+
366
+ // Get identity token
367
+ const identityToken = await this.getAgentIdentityToken(address);
368
+
369
+ // Get reputation if identity exists
370
+ let reputationScore: ReputationScore | undefined;
371
+ if (identityToken) {
372
+ reputationScore = await this.getAgentReputation(identityToken.tokenId);
373
+ }
374
+
375
+ // Check TEE verification
376
+ const teeVerified = identityToken
377
+ ? await this.isValidated(identityToken.tokenId, ValidationType.TEE)
378
+ : false;
379
+
380
+ // Return extended info (base info will be merged by caller)
381
+ return {
382
+ address,
383
+ name: '', // Will be filled by caller from AgentRegistry
384
+ attestation: '0x', // Will be filled by caller
385
+ registeredAt: 0n, // Will be filled by caller
386
+ exists: true,
387
+ ensNode: ensName ? namehash(ensName) : undefined,
388
+ agentId: identityToken?.tokenId,
389
+ reputationScore,
390
+ ensName,
391
+ identityToken,
392
+ teeVerified,
393
+ };
394
+ }
395
+ }
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // @clawlogic/sdk - Public API
3
+ // ─────────────────────────────────────────────────────────────────────────────
4
+
5
+ // Main client
6
+ export { ClawlogicClient } from './client.js';
7
+
8
+ // Phase 1: Identity & Trust infrastructure
9
+ export { IdentityClient } from './identity.js';
10
+ export type { IdentityContracts } from './identity.js';
11
+
12
+ // Type definitions
13
+ export type {
14
+ MarketInfo,
15
+ AgentInfo,
16
+ ClawlogicConfig,
17
+ DeploymentInfo,
18
+ MarketEvent,
19
+ MarketEventCallback,
20
+ ReputationScore,
21
+ GlobalReputationScore,
22
+ ValidationProof,
23
+ AgentRegistrationOptions,
24
+ } from './types.js';
25
+ export { ValidationType } from './types.js';
26
+
27
+ // Configuration helpers
28
+ export {
29
+ ARBITRUM_SEPOLIA_CONFIG,
30
+ ARBITRUM_SEPOLIA_CHAIN_ID,
31
+ ARBITRUM_SEPOLIA_RPC_URL,
32
+ ARC_TESTNET_CONFIG,
33
+ ARC_TESTNET_CHAIN_ID,
34
+ ARC_TESTNET_RPC_URL,
35
+ ARC_TESTNET_EXPLORER_URL,
36
+ loadConfigFromDeployment,
37
+ createConfig,
38
+ } from './config.js';
39
+
40
+ // ABIs (for advanced usage / direct contract interaction)
41
+ export { agentRegistryAbi } from './abis/agentRegistryAbi.js';
42
+ export { predictionMarketHookAbi } from './abis/predictionMarketHookAbi.js';
43
+ export { outcomeTokenAbi } from './abis/outcomeTokenAbi.js';
44
+
45
+ // Phase 1: Identity ABIs
46
+ export { agentIdentityRegistryAbi } from './abis/agentIdentityRegistryAbi.js';
47
+ export { agentReputationRegistryAbi } from './abis/agentReputationRegistryAbi.js';
48
+ export { agentValidationRegistryAbi } from './abis/agentValidationRegistryAbi.js';