@varun-ai07/covenant-mcp 2.3.6 → 2.3.8

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 (84) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/lib/sqlite-store.d.ts.map +1 -1
  4. package/dist/lib/sqlite-store.js +2 -1
  5. package/dist/lib/sqlite-store.js.map +1 -1
  6. package/dist/lib/store.d.ts.map +1 -1
  7. package/dist/lib/store.js +2 -1
  8. package/dist/lib/store.js.map +1 -1
  9. package/dist/server.js +1 -1
  10. package/package.json +1 -1
  11. package/dist/sdk/chunk-3R2WXEXL.mjs +0 -828
  12. package/dist/sdk/chunk-6ORMNSPN.mjs +0 -842
  13. package/dist/sdk/chunk-FH2MCRWQ.mjs +0 -8732
  14. package/dist/sdk/chunk-Y3YIH5K3.mjs +0 -816
  15. package/dist/sdk/config.d.ts +0 -121
  16. package/dist/sdk/config.d.ts.map +0 -1
  17. package/dist/sdk/config.js +0 -196
  18. package/dist/sdk/config.js.map +0 -1
  19. package/dist/sdk/contracts/AgentCollective.json +0 -467
  20. package/dist/sdk/contracts/AgentRegistry.d.ts +0 -144
  21. package/dist/sdk/contracts/AgentRegistry.d.ts.map +0 -1
  22. package/dist/sdk/contracts/AgentRegistry.js +0 -92
  23. package/dist/sdk/contracts/AgentRegistry.js.map +0 -1
  24. package/dist/sdk/contracts/COVENANTRouter.json +0 -206
  25. package/dist/sdk/contracts/CovenantArbitration.json +0 -546
  26. package/dist/sdk/contracts/CovenantAttestation.json +0 -476
  27. package/dist/sdk/contracts/CovenantEscrow.d.ts +0 -70
  28. package/dist/sdk/contracts/CovenantEscrow.d.ts.map +0 -1
  29. package/dist/sdk/contracts/CovenantEscrow.js +0 -3
  30. package/dist/sdk/contracts/CovenantEscrow.js.map +0 -1
  31. package/dist/sdk/contracts/CovenantEscrow.json +0 -783
  32. package/dist/sdk/contracts/CovenantGovernance.json +0 -729
  33. package/dist/sdk/contracts/CovenantIdentity.d.ts +0 -70
  34. package/dist/sdk/contracts/CovenantIdentity.d.ts.map +0 -1
  35. package/dist/sdk/contracts/CovenantIdentity.js +0 -3
  36. package/dist/sdk/contracts/CovenantIdentity.js.map +0 -1
  37. package/dist/sdk/contracts/CovenantIdentity.json +0 -800
  38. package/dist/sdk/contracts/CovenantSettlement.json +0 -609
  39. package/dist/sdk/contracts/DisputeResolution.d.ts +0 -122
  40. package/dist/sdk/contracts/DisputeResolution.d.ts.map +0 -1
  41. package/dist/sdk/contracts/DisputeResolution.js +0 -86
  42. package/dist/sdk/contracts/DisputeResolution.js.map +0 -1
  43. package/dist/sdk/contracts/GrantProgram.json +0 -373
  44. package/dist/sdk/contracts/InsurancePool.d.ts +0 -209
  45. package/dist/sdk/contracts/InsurancePool.d.ts.map +0 -1
  46. package/dist/sdk/contracts/InsurancePool.js +0 -153
  47. package/dist/sdk/contracts/InsurancePool.js.map +0 -1
  48. package/dist/sdk/contracts/InsurancePool.json +0 -456
  49. package/dist/sdk/contracts/MultiTokenEscrow.json +0 -435
  50. package/dist/sdk/contracts/OpenTaskMarket.d.ts +0 -190
  51. package/dist/sdk/contracts/OpenTaskMarket.d.ts.map +0 -1
  52. package/dist/sdk/contracts/OpenTaskMarket.js +0 -117
  53. package/dist/sdk/contracts/OpenTaskMarket.js.map +0 -1
  54. package/dist/sdk/contracts/ParallelTaskBatch.json +0 -511
  55. package/dist/sdk/contracts/ReceiptVerifierV2.d.ts +0 -168
  56. package/dist/sdk/contracts/ReceiptVerifierV2.d.ts.map +0 -1
  57. package/dist/sdk/contracts/ReceiptVerifierV2.js +0 -109
  58. package/dist/sdk/contracts/ReceiptVerifierV2.js.map +0 -1
  59. package/dist/sdk/contracts/RevisionManager.json +0 -489
  60. package/dist/sdk/contracts/TaskEscrow.d.ts +0 -222
  61. package/dist/sdk/contracts/TaskEscrow.d.ts.map +0 -1
  62. package/dist/sdk/contracts/TaskEscrow.js +0 -144
  63. package/dist/sdk/contracts/TaskEscrow.js.map +0 -1
  64. package/dist/sdk/contracts/TrainingMarketplace.json +0 -357
  65. package/dist/sdk/index.d.mts +0 -385
  66. package/dist/sdk/index.d.ts +0 -35
  67. package/dist/sdk/index.d.ts.map +0 -1
  68. package/dist/sdk/index.js +0 -284
  69. package/dist/sdk/index.js.map +0 -1
  70. package/dist/sdk/index.mjs +0 -32
  71. package/dist/sdk/types.d.ts +0 -110
  72. package/dist/sdk/types.d.ts.map +0 -1
  73. package/dist/sdk/types.js +0 -17
  74. package/dist/sdk/types.js.map +0 -1
  75. package/dist/sdk/v2.d.mts +0 -100
  76. package/dist/sdk/v2.d.ts +0 -100
  77. package/dist/sdk/v2.d.ts.map +0 -1
  78. package/dist/sdk/v2.js +0 -2615
  79. package/dist/sdk/v2.js.map +0 -1
  80. package/dist/sdk/v2.mjs +0 -571
  81. package/dist/sdk/v5-extensions.d.ts +0 -133
  82. package/dist/sdk/v5-extensions.d.ts.map +0 -1
  83. package/dist/sdk/v5-extensions.js +0 -993
  84. package/dist/sdk/v5-extensions.js.map +0 -1
@@ -1,816 +0,0 @@
1
- // src/config.ts
2
- var DEFAULT_ADDRESSES = {
3
- // Base Sepolia Testnet
4
- 84532: {
5
- // Core Protocol
6
- AgentRegistry: "0xB215589dA259A98eEE8BF39739F6255131ac33A1",
7
- TaskEscrow: "0xFD081B5cB8bAE37DC878078bE3165932b0bC0BB3",
8
- ReceiptVerifier: "0xa47D15099be6aC516B53a6859D468E9004eEf76b",
9
- // Market & Batching
10
- OpenTaskMarket: "0x5ccF09469222E5046b0830c6d71ed6B912bE70e6",
11
- ParallelTaskBatch: "0xaf23D40668f0e33426824Bf2027A0E9cD26c11Bc",
12
- // Collective & Insurance
13
- AgentCollective: "0x0CDE9560D2E95338922c40A52A2c81cdd20613d1",
14
- AgentInsurance: "0x1798d370e3C566001A84F38EbDc0F6F1Db6bdd55",
15
- // Dispute Resolution
16
- DisputeArbitration: "0x37A62C6eDd18461CCe00B6772Da8640C75DE740e",
17
- // ZK Verifiers
18
- Groth16VerifierCapability: "0xd7108ed5C8577B30f6FC024319ebE8B380DaAb85",
19
- CapabilityVerifier: "0x628CB2cA13f6FeAc48e0f24f45C3AF2Dbb1c02Fb",
20
- Groth16VerifierReputation: "0xbe6AfBa53E06099410d78d56A75b689dfCa6532F",
21
- ReputationVerifier: "0x1ac2532e39591cdb5E00Fb9d7C0f47E082d0F149",
22
- // Router & Integration
23
- COVENANTRouter: "0x565C48FEFc39c9D98a37cCE30583913C7d0d5e09",
24
- LitProtocolIntegration: "0x9322B12111699Dd05DD3d0c5D8D08b764051A89f"
25
- },
26
- // Hardhat Local (placeholder addresses)
27
- 31337: {
28
- AgentRegistry: "0x0000000000000000000000000000000000000000",
29
- TaskEscrow: "0x0000000000000000000000000000000000000000",
30
- ReceiptVerifier: "0x0000000000000000000000000000000000000000",
31
- OpenTaskMarket: "0x0000000000000000000000000000000000000000",
32
- ParallelTaskBatch: "0x0000000000000000000000000000000000000000",
33
- AgentCollective: "0x0000000000000000000000000000000000000000",
34
- AgentInsurance: "0x0000000000000000000000000000000000000000",
35
- DisputeArbitration: "0x0000000000000000000000000000000000000000"
36
- },
37
- // Base Mainnet (placeholder - not deployed yet)
38
- 8453: {
39
- AgentRegistry: "0x0000000000000000000000000000000000000000",
40
- TaskEscrow: "0x0000000000000000000000000000000000000000",
41
- ReceiptVerifier: "0x0000000000000000000000000000000000000000",
42
- OpenTaskMarket: "0x0000000000000000000000000000000000000000",
43
- ParallelTaskBatch: "0x0000000000000000000000000000000000000000",
44
- AgentCollective: "0x0000000000000000000000000000000000000000",
45
- AgentInsurance: "0x0000000000000000000000000000000000000000",
46
- DisputeArbitration: "0x0000000000000000000000000000000000000000"
47
- }
48
- };
49
- var V2_ADDRESSES = {
50
- // Base Sepolia Testnet
51
- 84532: {
52
- AgentRegistry: "0x773d1954997b6A91e917e0c2326ABCcAf36e21E1",
53
- TaskEscrow: "0xf4d0765A935E36F888d899D9A7C9156CeCdEa6F5",
54
- ReceiptVerifier: "0x05cC13692755015FCb11e95d609187b214197edF",
55
- InsurancePool: "0x920f3925122B3Ce9380A220AA748e67bD787BE1d",
56
- DisputeResolution: "0xFA6dd0929a4ACCCC2E083DaDaD89226dd71Ef28F"
57
- },
58
- // Hardhat Local (placeholder addresses)
59
- 31337: {
60
- AgentRegistry: "0x0000000000000000000000000000000000000000",
61
- TaskEscrow: "0x0000000000000000000000000000000000000000",
62
- ReceiptVerifier: "0x0000000000000000000000000000000000000000",
63
- InsurancePool: "0x0000000000000000000000000000000000000000",
64
- DisputeResolution: "0x0000000000000000000000000000000000000000"
65
- },
66
- // Base Mainnet (placeholder - not deployed yet)
67
- 8453: {
68
- AgentRegistry: "0x0000000000000000000000000000000000000000",
69
- TaskEscrow: "0x0000000000000000000000000000000000000000",
70
- ReceiptVerifier: "0x0000000000000000000000000000000000000000",
71
- InsurancePool: "0x0000000000000000000000000000000000000000",
72
- DisputeResolution: "0x0000000000000000000000000000000000000000"
73
- }
74
- };
75
- var CHAIN_CONFIGS = {
76
- 84532: {
77
- chain: {
78
- id: 84532,
79
- name: "Base Sepolia",
80
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
81
- rpcUrls: { default: { http: ["https://sepolia.base.org"] } }
82
- }
83
- },
84
- 8453: {
85
- chain: {
86
- id: 8453,
87
- name: "Base",
88
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
89
- rpcUrls: { default: { http: ["https://mainnet.base.org"] } }
90
- }
91
- },
92
- 31337: {
93
- chain: {
94
- id: 31337,
95
- name: "Hardhat Local",
96
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
97
- rpcUrls: { default: { http: ["http://localhost:8545"] } }
98
- }
99
- }
100
- };
101
- var CHAINS = {
102
- baseSepolia: {
103
- id: 84532,
104
- name: "Base Sepolia",
105
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
106
- rpcUrls: {
107
- default: { http: ["https://sepolia.base.org"] }
108
- },
109
- blockExplorers: {
110
- default: { name: "Basescan", url: "https://sepolia.basescan.org" }
111
- },
112
- testnet: true
113
- },
114
- base: {
115
- id: 8453,
116
- name: "Base",
117
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
118
- rpcUrls: {
119
- default: { http: ["https://mainnet.base.org"] }
120
- },
121
- blockExplorers: {
122
- default: { name: "Basescan", url: "https://basescan.org" }
123
- }
124
- }
125
- };
126
- function getContractAddresses(chainId, overrides) {
127
- const defaults = DEFAULT_ADDRESSES[chainId];
128
- if (!defaults) {
129
- throw new Error(`Unsupported chain ID: ${chainId}. Supported: ${Object.keys(DEFAULT_ADDRESSES).join(", ")}`);
130
- }
131
- return { ...defaults, ...overrides };
132
- }
133
- function isDeployed(chainId) {
134
- const addresses = DEFAULT_ADDRESSES[chainId];
135
- if (!addresses) return false;
136
- return addresses.AgentRegistry !== "0x0000000000000000000000000000000000000000";
137
- }
138
- function getV2ContractAddresses(chainId, overrides) {
139
- const defaults = V2_ADDRESSES[chainId];
140
- if (!defaults) {
141
- throw new Error(`Unsupported chain ID for V2: ${chainId}. Supported: ${Object.keys(V2_ADDRESSES).join(", ")}`);
142
- }
143
- return { ...defaults, ...overrides };
144
- }
145
-
146
- // src/contracts/AgentRegistry.ts
147
- var AgentRegistryABI = [
148
- // Read functions
149
- {
150
- name: "getAgent",
151
- type: "function",
152
- stateMutability: "view",
153
- inputs: [{ name: "agent", type: "address" }],
154
- outputs: [
155
- { name: "did", type: "bytes32" },
156
- { name: "name", type: "string" },
157
- { name: "capabilities", type: "string[]" },
158
- { name: "reputation", type: "uint256" },
159
- { name: "stakedAmount", type: "uint256" },
160
- { name: "tasksCompleted", type: "uint256" },
161
- { name: "tasksFailed", type: "uint256" },
162
- { name: "totalValueTransferred", type: "uint256" },
163
- { name: "isActive", type: "bool" },
164
- { name: "registeredAt", type: "uint256" },
165
- { name: "walletAddress", type: "address" }
166
- ]
167
- },
168
- {
169
- name: "getAgentCount",
170
- type: "function",
171
- stateMutability: "view",
172
- inputs: [],
173
- outputs: [{ name: "", type: "uint256" }]
174
- },
175
- {
176
- name: "getAgentsByCapability",
177
- type: "function",
178
- stateMutability: "view",
179
- inputs: [
180
- { name: "capability", type: "string" },
181
- { name: "offset", type: "uint256" },
182
- { name: "limit", type: "uint256" }
183
- ],
184
- outputs: [{ name: "", type: "address[]" }]
185
- },
186
- {
187
- name: "getAllAgents",
188
- type: "function",
189
- stateMutability: "view",
190
- inputs: [
191
- { name: "offset", type: "uint256" },
192
- { name: "limit", type: "uint256" }
193
- ],
194
- outputs: [{ name: "", type: "address[]" }]
195
- },
196
- // Write functions
197
- {
198
- name: "register",
199
- type: "function",
200
- stateMutability: "payable",
201
- inputs: [
202
- { name: "name", type: "string" },
203
- { name: "capabilities", type: "string[]" }
204
- ],
205
- outputs: []
206
- },
207
- {
208
- name: "deactivate",
209
- type: "function",
210
- stateMutability: "nonpayable",
211
- inputs: [],
212
- outputs: []
213
- },
214
- // Events
215
- {
216
- name: "AgentRegistered",
217
- type: "event",
218
- inputs: [
219
- { name: "agent", type: "address", indexed: true },
220
- { name: "did", type: "bytes32", indexed: true },
221
- { name: "name", type: "string", indexed: false },
222
- { name: "stake", type: "uint256", indexed: false }
223
- ]
224
- },
225
- {
226
- name: "ReputationUpdated",
227
- type: "event",
228
- inputs: [
229
- { name: "agent", type: "address", indexed: true },
230
- { name: "delta", type: "int256", indexed: false },
231
- { name: "newReputation", type: "uint256", indexed: false }
232
- ]
233
- }
234
- ];
235
-
236
- // src/contracts/TaskEscrow.ts
237
- var TaskEscrowABI = [
238
- // Read functions
239
- {
240
- name: "getTask",
241
- type: "function",
242
- stateMutability: "view",
243
- inputs: [{ name: "taskId", type: "uint256" }],
244
- outputs: [
245
- { name: "taskId", type: "uint256" },
246
- { name: "client", type: "address" },
247
- { name: "worker", type: "address" },
248
- { name: "payment", type: "uint256" },
249
- { name: "deadline", type: "uint256" },
250
- { name: "descriptionHash", type: "string" },
251
- { name: "deliverableHash", type: "string" },
252
- { name: "status", type: "uint8" },
253
- { name: "createdAt", type: "uint256" },
254
- { name: "completedAt", type: "uint256" },
255
- { name: "protocolFee", type: "uint256" },
256
- { name: "totalValue", type: "uint256" }
257
- ]
258
- },
259
- {
260
- name: "getTaskCount",
261
- type: "function",
262
- stateMutability: "view",
263
- inputs: [],
264
- outputs: [{ name: "", type: "uint256" }]
265
- },
266
- {
267
- name: "getClientTasks",
268
- type: "function",
269
- stateMutability: "view",
270
- inputs: [{ name: "client", type: "address" }],
271
- outputs: [{ name: "", type: "uint256[]" }]
272
- },
273
- {
274
- name: "getWorkerTasks",
275
- type: "function",
276
- stateMutability: "view",
277
- inputs: [{ name: "worker", type: "address" }],
278
- outputs: [{ name: "", type: "uint256[]" }]
279
- },
280
- // Write functions
281
- {
282
- name: "createTask",
283
- type: "function",
284
- stateMutability: "payable",
285
- inputs: [
286
- { name: "worker", type: "address" },
287
- { name: "deadline", type: "uint256" },
288
- { name: "descriptionHash", type: "string" }
289
- ],
290
- outputs: [{ name: "", type: "uint256" }]
291
- },
292
- {
293
- name: "fundTask",
294
- type: "function",
295
- stateMutability: "payable",
296
- inputs: [{ name: "taskId", type: "uint256" }],
297
- outputs: []
298
- },
299
- {
300
- name: "startTask",
301
- type: "function",
302
- stateMutability: "nonpayable",
303
- inputs: [{ name: "taskId", type: "uint256" }],
304
- outputs: []
305
- },
306
- {
307
- name: "submitWork",
308
- type: "function",
309
- stateMutability: "nonpayable",
310
- inputs: [
311
- { name: "taskId", type: "uint256" },
312
- { name: "deliverableHash", type: "string" }
313
- ],
314
- outputs: []
315
- },
316
- {
317
- name: "verifyTask",
318
- type: "function",
319
- stateMutability: "nonpayable",
320
- inputs: [
321
- { name: "taskId", type: "uint256" },
322
- { name: "success", type: "bool" }
323
- ],
324
- outputs: []
325
- },
326
- {
327
- name: "disputeTask",
328
- type: "function",
329
- stateMutability: "payable",
330
- inputs: [{ name: "taskId", type: "uint256" }],
331
- outputs: []
332
- },
333
- {
334
- name: "cancelTask",
335
- type: "function",
336
- stateMutability: "nonpayable",
337
- inputs: [{ name: "taskId", type: "uint256" }],
338
- outputs: []
339
- },
340
- // Events
341
- {
342
- name: "TaskCreated",
343
- type: "event",
344
- inputs: [
345
- { name: "taskId", type: "uint256", indexed: true },
346
- { name: "client", type: "address", indexed: true },
347
- { name: "worker", type: "address", indexed: true },
348
- { name: "payment", type: "uint256", indexed: false },
349
- { name: "deadline", type: "uint256", indexed: false }
350
- ]
351
- },
352
- {
353
- name: "WorkSubmitted",
354
- type: "event",
355
- inputs: [
356
- { name: "taskId", type: "uint256", indexed: true },
357
- { name: "deliverableHash", type: "string", indexed: false }
358
- ]
359
- },
360
- {
361
- name: "TaskCompleted",
362
- type: "event",
363
- inputs: [
364
- { name: "taskId", type: "uint256", indexed: true },
365
- { name: "workerPayment", type: "uint256", indexed: false }
366
- ]
367
- },
368
- {
369
- name: "TaskDisputed",
370
- type: "event",
371
- inputs: [
372
- { name: "taskId", type: "uint256", indexed: true },
373
- { name: "disputedBy", type: "address", indexed: false }
374
- ]
375
- }
376
- ];
377
-
378
- // src/contracts/OpenTaskMarket.ts
379
- var OpenTaskMarketABI = [
380
- // Read functions
381
- {
382
- name: "getOpenTask",
383
- type: "function",
384
- stateMutability: "view",
385
- inputs: [{ name: "taskId", type: "uint256" }],
386
- outputs: [
387
- { name: "client", type: "address" },
388
- { name: "maxPayment", type: "uint256" },
389
- { name: "deadline", type: "uint256" },
390
- { name: "descriptionHash", type: "string" },
391
- { name: "bidders", type: "address[]" },
392
- { name: "selectedWorker", type: "address" },
393
- { name: "status", type: "uint8" }
394
- ]
395
- },
396
- {
397
- name: "getBid",
398
- type: "function",
399
- stateMutability: "view",
400
- inputs: [
401
- { name: "taskId", type: "uint256" },
402
- { name: "bidder", type: "address" }
403
- ],
404
- outputs: [
405
- { name: "price", type: "uint256" },
406
- { name: "timeEstimate", type: "uint256" },
407
- { name: "proposalHash", type: "string" },
408
- { name: "bidAt", type: "uint256" }
409
- ]
410
- },
411
- {
412
- name: "getOpenTaskCount",
413
- type: "function",
414
- stateMutability: "view",
415
- inputs: [],
416
- outputs: [{ name: "", type: "uint256" }]
417
- },
418
- // Write functions
419
- {
420
- name: "postOpenTask",
421
- type: "function",
422
- stateMutability: "payable",
423
- inputs: [
424
- { name: "maxPayment", type: "uint256" },
425
- { name: "deadline", type: "uint256" },
426
- { name: "descriptionHash", type: "string" }
427
- ],
428
- outputs: [{ name: "", type: "uint256" }]
429
- },
430
- {
431
- name: "submitBid",
432
- type: "function",
433
- stateMutability: "nonpayable",
434
- inputs: [
435
- { name: "taskId", type: "uint256" },
436
- { name: "price", type: "uint256" },
437
- { name: "timeEstimate", type: "uint256" },
438
- { name: "proposalHash", type: "string" }
439
- ],
440
- outputs: []
441
- },
442
- {
443
- name: "selectWorker",
444
- type: "function",
445
- stateMutability: "nonpayable",
446
- inputs: [
447
- { name: "taskId", type: "uint256" },
448
- { name: "worker", type: "address" }
449
- ],
450
- outputs: []
451
- },
452
- {
453
- name: "withdrawBid",
454
- type: "function",
455
- stateMutability: "nonpayable",
456
- inputs: [{ name: "taskId", type: "uint256" }],
457
- outputs: []
458
- },
459
- // Events
460
- {
461
- name: "TaskPosted",
462
- type: "event",
463
- inputs: [
464
- { name: "taskId", type: "uint256", indexed: true },
465
- { name: "client", type: "address", indexed: true },
466
- { name: "maxPayment", type: "uint256", indexed: false },
467
- { name: "deadline", type: "uint256", indexed: false },
468
- { name: "descriptionHash", type: "string", indexed: false }
469
- ]
470
- },
471
- {
472
- name: "BidSubmitted",
473
- type: "event",
474
- inputs: [
475
- { name: "taskId", type: "uint256", indexed: true },
476
- { name: "bidder", type: "address", indexed: true },
477
- { name: "price", type: "uint256", indexed: false },
478
- { name: "timeEstimate", type: "uint256", indexed: false },
479
- { name: "proposalHash", type: "string", indexed: false }
480
- ]
481
- },
482
- {
483
- name: "WorkerSelected",
484
- type: "event",
485
- inputs: [
486
- { name: "taskId", type: "uint256", indexed: true },
487
- { name: "worker", type: "address", indexed: true },
488
- { name: "selectedPrice", type: "uint256", indexed: false }
489
- ]
490
- }
491
- ];
492
-
493
- // src/types.ts
494
- var ReceiptType = /* @__PURE__ */ ((ReceiptType2) => {
495
- ReceiptType2[ReceiptType2["TaskCompleted"] = 0] = "TaskCompleted";
496
- ReceiptType2[ReceiptType2["AgentVerified"] = 1] = "AgentVerified";
497
- ReceiptType2[ReceiptType2["DisputeResolved"] = 2] = "DisputeResolved";
498
- ReceiptType2[ReceiptType2["InsuranceClaim"] = 3] = "InsuranceClaim";
499
- ReceiptType2[ReceiptType2["MilestoneReached"] = 4] = "MilestoneReached";
500
- ReceiptType2[ReceiptType2["ReputationUpdated"] = 5] = "ReputationUpdated";
501
- return ReceiptType2;
502
- })(ReceiptType || {});
503
-
504
- // src/index.ts
505
- var CovenantSDK = class {
506
- publicClient;
507
- walletClient;
508
- addresses;
509
- chain;
510
- account;
511
- constructor(config) {
512
- this.publicClient = config.publicClient;
513
- this.walletClient = config.walletClient;
514
- this.account = config.walletClient?.account;
515
- this.addresses = getContractAddresses(config.chainId, config.contractAddresses);
516
- this.chain = CHAIN_CONFIGS[config.chainId]?.chain ?? {
517
- id: config.chainId,
518
- name: `Chain ${config.chainId}`,
519
- nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
520
- rpcUrls: { default: { http: [] } }
521
- };
522
- }
523
- // =========================================================================
524
- // Agent Methods
525
- // =========================================================================
526
- /**
527
- * Get agent data by address
528
- */
529
- async getAgent(address) {
530
- const result = await this.publicClient.readContract({
531
- address: this.addresses.AgentRegistry,
532
- abi: AgentRegistryABI,
533
- functionName: "getAgent",
534
- args: [address]
535
- });
536
- return this.parseAgentData(result);
537
- }
538
- /**
539
- * Get total number of registered agents
540
- */
541
- async getAgentCount() {
542
- return await this.publicClient.readContract({
543
- address: this.addresses.AgentRegistry,
544
- abi: AgentRegistryABI,
545
- functionName: "getAgentCount",
546
- args: []
547
- });
548
- }
549
- /**
550
- * Find agents by capability
551
- */
552
- async findAgents(capability, minReputation, limit = 20) {
553
- const addresses = await this.publicClient.readContract({
554
- address: this.addresses.AgentRegistry,
555
- abi: AgentRegistryABI,
556
- functionName: "getAgentsByCapability",
557
- args: [capability, BigInt(0), BigInt(limit)]
558
- });
559
- if (minReputation !== void 0) {
560
- const filtered = [];
561
- for (const addr of addresses) {
562
- const agent = await this.getAgent(addr);
563
- if (agent.reputation >= BigInt(minReputation)) {
564
- filtered.push(addr);
565
- }
566
- }
567
- return filtered;
568
- }
569
- return addresses;
570
- }
571
- /**
572
- * Get all agents with pagination
573
- */
574
- async getAllAgents(offset = 0, limit = 50) {
575
- return await this.publicClient.readContract({
576
- address: this.addresses.AgentRegistry,
577
- abi: AgentRegistryABI,
578
- functionName: "getAllAgents",
579
- args: [BigInt(offset), BigInt(limit)]
580
- });
581
- }
582
- /**
583
- * Register a new agent (requires wallet)
584
- */
585
- async registerAgent(name, capabilities, stake) {
586
- this.requireWallet();
587
- return await this.walletClient.writeContract({
588
- address: this.addresses.AgentRegistry,
589
- abi: AgentRegistryABI,
590
- functionName: "register",
591
- args: [name, capabilities],
592
- value: stake,
593
- chain: this.chain,
594
- account: this.account
595
- });
596
- }
597
- // =========================================================================
598
- // Task Methods
599
- // =========================================================================
600
- /**
601
- * Get task data by ID
602
- */
603
- async getTask(taskId) {
604
- const result = await this.publicClient.readContract({
605
- address: this.addresses.TaskEscrow,
606
- abi: TaskEscrowABI,
607
- functionName: "getTask",
608
- args: [taskId]
609
- });
610
- return this.parseTaskData(result);
611
- }
612
- /**
613
- * Get total number of tasks
614
- */
615
- async getTaskCount() {
616
- return await this.publicClient.readContract({
617
- address: this.addresses.TaskEscrow,
618
- abi: TaskEscrowABI,
619
- functionName: "getTaskCount",
620
- args: []
621
- });
622
- }
623
- /**
624
- * Get all task IDs for a client
625
- */
626
- async getClientTasks(client) {
627
- return await this.publicClient.readContract({
628
- address: this.addresses.TaskEscrow,
629
- abi: TaskEscrowABI,
630
- functionName: "getClientTasks",
631
- args: [client]
632
- });
633
- }
634
- /**
635
- * Get all task IDs for a worker
636
- */
637
- async getWorkerTasks(worker) {
638
- return await this.publicClient.readContract({
639
- address: this.addresses.TaskEscrow,
640
- abi: TaskEscrowABI,
641
- functionName: "getWorkerTasks",
642
- args: [worker]
643
- });
644
- }
645
- /**
646
- * Create a new task (requires wallet)
647
- */
648
- async createTask(worker, payment, deadline, descriptionHash) {
649
- this.requireWallet();
650
- return await this.walletClient.writeContract({
651
- address: this.addresses.TaskEscrow,
652
- abi: TaskEscrowABI,
653
- functionName: "createTask",
654
- args: [worker, deadline, descriptionHash],
655
- value: payment,
656
- chain: this.chain,
657
- account: this.account
658
- });
659
- }
660
- /**
661
- * Submit work for a task (requires wallet)
662
- */
663
- async submitWork(taskId, deliverableHash) {
664
- this.requireWallet();
665
- return await this.walletClient.writeContract({
666
- address: this.addresses.TaskEscrow,
667
- abi: TaskEscrowABI,
668
- functionName: "submitWork",
669
- args: [taskId, deliverableHash],
670
- chain: this.chain,
671
- account: this.account
672
- });
673
- }
674
- /**
675
- * Verify task completion (requires wallet)
676
- */
677
- async verifyTask(taskId, success) {
678
- this.requireWallet();
679
- return await this.walletClient.writeContract({
680
- address: this.addresses.TaskEscrow,
681
- abi: TaskEscrowABI,
682
- functionName: "verifyTask",
683
- args: [taskId, success],
684
- chain: this.chain,
685
- account: this.account
686
- });
687
- }
688
- /**
689
- * Dispute a task (requires wallet)
690
- */
691
- async disputeTask(taskId, disputeBond) {
692
- this.requireWallet();
693
- return await this.walletClient.writeContract({
694
- address: this.addresses.TaskEscrow,
695
- abi: TaskEscrowABI,
696
- functionName: "disputeTask",
697
- args: [taskId],
698
- value: disputeBond,
699
- chain: this.chain,
700
- account: this.account
701
- });
702
- }
703
- // =========================================================================
704
- // Open Task Market Methods
705
- // =========================================================================
706
- /**
707
- * Post an open task for bidding
708
- */
709
- async postOpenTask(maxPayment, deadline, descriptionHash) {
710
- this.requireWallet();
711
- return await this.walletClient.writeContract({
712
- address: this.addresses.OpenTaskMarket,
713
- abi: OpenTaskMarketABI,
714
- functionName: "postOpenTask",
715
- args: [maxPayment, deadline, descriptionHash],
716
- value: maxPayment,
717
- chain: this.chain,
718
- account: this.account
719
- });
720
- }
721
- /**
722
- * Submit a bid on an open task
723
- */
724
- async submitBid(taskId, price, timeEstimate, proposalHash) {
725
- this.requireWallet();
726
- return await this.walletClient.writeContract({
727
- address: this.addresses.OpenTaskMarket,
728
- abi: OpenTaskMarketABI,
729
- functionName: "submitBid",
730
- args: [taskId, price, timeEstimate, proposalHash],
731
- chain: this.chain,
732
- account: this.account
733
- });
734
- }
735
- /**
736
- * Select a worker for an open task
737
- */
738
- async selectWorker(taskId, worker) {
739
- this.requireWallet();
740
- return await this.walletClient.writeContract({
741
- address: this.addresses.OpenTaskMarket,
742
- abi: OpenTaskMarketABI,
743
- functionName: "selectWorker",
744
- args: [taskId, worker],
745
- chain: this.chain,
746
- account: this.account
747
- });
748
- }
749
- // =========================================================================
750
- // Utility Methods
751
- // =========================================================================
752
- /**
753
- * Wait for a transaction to be confirmed
754
- */
755
- async waitForTransaction(hash) {
756
- return await this.publicClient.waitForTransactionReceipt({ hash });
757
- }
758
- /**
759
- * Get contract addresses being used
760
- */
761
- getAddresses() {
762
- return { ...this.addresses };
763
- }
764
- // =========================================================================
765
- // Private Helpers
766
- // =========================================================================
767
- requireWallet() {
768
- if (!this.walletClient) {
769
- throw new Error("Wallet client required for write operations. Pass walletClient in config.");
770
- }
771
- }
772
- parseAgentData(result) {
773
- return {
774
- did: result[0],
775
- name: result[1],
776
- capabilities: result[2],
777
- reputation: result[3],
778
- stakedAmount: result[4],
779
- tasksCompleted: result[5],
780
- tasksFailed: result[6],
781
- totalValueTransferred: result[7],
782
- isActive: result[8],
783
- registeredAt: result[9],
784
- walletAddress: result[10]
785
- };
786
- }
787
- parseTaskData(result) {
788
- const statusMap = ["Open", "Funded", "InProgress", "Submitted", "Completed", "Disputed", "Failed", "Cancelled"];
789
- return {
790
- taskId: result[0],
791
- client: result[1],
792
- worker: result[2],
793
- payment: result[3],
794
- deadline: result[4],
795
- descriptionHash: result[5],
796
- deliverableHash: result[6],
797
- status: statusMap[result[7]] || "Open",
798
- createdAt: result[8],
799
- completedAt: result[9],
800
- protocolFee: result[10],
801
- totalValue: result[11]
802
- };
803
- }
804
- };
805
-
806
- export {
807
- DEFAULT_ADDRESSES,
808
- V2_ADDRESSES,
809
- CHAIN_CONFIGS,
810
- CHAINS,
811
- getContractAddresses,
812
- isDeployed,
813
- getV2ContractAddresses,
814
- ReceiptType,
815
- CovenantSDK
816
- };