@kudo-dev/sdk 0.0.0-stage → 0.2.0
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/.env.example +86 -0
- package/AGENT.md +201 -0
- package/README.md +123 -2
- package/dist/agent/index.d.ts +94 -0
- package/dist/agent/index.js +867 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/index.cjs +2562 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1823 -0
- package/dist/index.d.ts +1823 -0
- package/dist/index.js +2520 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -4
- package/prompts/common.md +128 -0
- package/prompts/settle-due.txt +92 -0
- package/prompts/take-work.txt +43 -0
- package/skills/chain-forensics/SKILL.md +127 -0
- package/skills/kudo/SKILL.md +370 -0
- package/skills/kudo/sponsored-send.mjs +218 -0
- package/skills/kudo-runtime/SKILL.md +275 -0
- package/skills/kudo-validation/SKILL.md +239 -0
- package/skills/twitter/SKILL.md +127 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2520 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import {
|
|
3
|
+
createPublicClient,
|
|
4
|
+
decodeEventLog,
|
|
5
|
+
encodeFunctionData,
|
|
6
|
+
formatUnits,
|
|
7
|
+
getAbiItem,
|
|
8
|
+
hexToString,
|
|
9
|
+
http,
|
|
10
|
+
parseEventLogs,
|
|
11
|
+
stringToHex,
|
|
12
|
+
zeroAddress
|
|
13
|
+
} from "viem";
|
|
14
|
+
|
|
15
|
+
// src/abi/kudo.ts
|
|
16
|
+
var kudoAbi = [
|
|
17
|
+
{
|
|
18
|
+
type: "constructor",
|
|
19
|
+
inputs: [
|
|
20
|
+
{
|
|
21
|
+
name: "admin",
|
|
22
|
+
type: "address",
|
|
23
|
+
internalType: "address"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "initialDelay",
|
|
27
|
+
type: "uint48",
|
|
28
|
+
internalType: "uint48"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "mintAccessControl",
|
|
32
|
+
type: "bool",
|
|
33
|
+
internalType: "bool"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "askCooldown",
|
|
37
|
+
type: "uint256",
|
|
38
|
+
internalType: "uint256"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
stateMutability: "nonpayable"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "function",
|
|
45
|
+
name: "AGENT_ROLE",
|
|
46
|
+
inputs: [],
|
|
47
|
+
outputs: [
|
|
48
|
+
{
|
|
49
|
+
name: "",
|
|
50
|
+
type: "bytes32",
|
|
51
|
+
internalType: "bytes32"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
stateMutability: "view"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "function",
|
|
58
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
59
|
+
inputs: [],
|
|
60
|
+
outputs: [
|
|
61
|
+
{
|
|
62
|
+
name: "",
|
|
63
|
+
type: "bytes32",
|
|
64
|
+
internalType: "bytes32"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
stateMutability: "view"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "function",
|
|
71
|
+
name: "EVALUATOR_CONTRACT_ROLE",
|
|
72
|
+
inputs: [],
|
|
73
|
+
outputs: [
|
|
74
|
+
{
|
|
75
|
+
name: "",
|
|
76
|
+
type: "bytes32",
|
|
77
|
+
internalType: "bytes32"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
stateMutability: "view"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "function",
|
|
84
|
+
name: "acceptDefaultAdminTransfer",
|
|
85
|
+
inputs: [],
|
|
86
|
+
outputs: [],
|
|
87
|
+
stateMutability: "nonpayable"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "function",
|
|
91
|
+
name: "approve",
|
|
92
|
+
inputs: [
|
|
93
|
+
{
|
|
94
|
+
name: "to",
|
|
95
|
+
type: "address",
|
|
96
|
+
internalType: "address"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "tokenId",
|
|
100
|
+
type: "uint256",
|
|
101
|
+
internalType: "uint256"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
outputs: [],
|
|
105
|
+
stateMutability: "nonpayable"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "function",
|
|
109
|
+
name: "balanceOf",
|
|
110
|
+
inputs: [
|
|
111
|
+
{
|
|
112
|
+
name: "owner",
|
|
113
|
+
type: "address",
|
|
114
|
+
internalType: "address"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
outputs: [
|
|
118
|
+
{
|
|
119
|
+
name: "",
|
|
120
|
+
type: "uint256",
|
|
121
|
+
internalType: "uint256"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
stateMutability: "view"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: "function",
|
|
128
|
+
name: "beginDefaultAdminTransfer",
|
|
129
|
+
inputs: [
|
|
130
|
+
{
|
|
131
|
+
name: "newAdmin",
|
|
132
|
+
type: "address",
|
|
133
|
+
internalType: "address"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
outputs: [],
|
|
137
|
+
stateMutability: "nonpayable"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: "function",
|
|
141
|
+
name: "cancelDefaultAdminTransfer",
|
|
142
|
+
inputs: [],
|
|
143
|
+
outputs: [],
|
|
144
|
+
stateMutability: "nonpayable"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
type: "function",
|
|
148
|
+
name: "changeDefaultAdminDelay",
|
|
149
|
+
inputs: [
|
|
150
|
+
{
|
|
151
|
+
name: "newDelay",
|
|
152
|
+
type: "uint48",
|
|
153
|
+
internalType: "uint48"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
outputs: [],
|
|
157
|
+
stateMutability: "nonpayable"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: "function",
|
|
161
|
+
name: "defaultAdmin",
|
|
162
|
+
inputs: [],
|
|
163
|
+
outputs: [
|
|
164
|
+
{
|
|
165
|
+
name: "",
|
|
166
|
+
type: "address",
|
|
167
|
+
internalType: "address"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
stateMutability: "view"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
type: "function",
|
|
174
|
+
name: "defaultAdminDelay",
|
|
175
|
+
inputs: [],
|
|
176
|
+
outputs: [
|
|
177
|
+
{
|
|
178
|
+
name: "",
|
|
179
|
+
type: "uint48",
|
|
180
|
+
internalType: "uint48"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
stateMutability: "view"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "function",
|
|
187
|
+
name: "defaultAdminDelayIncreaseWait",
|
|
188
|
+
inputs: [],
|
|
189
|
+
outputs: [
|
|
190
|
+
{
|
|
191
|
+
name: "",
|
|
192
|
+
type: "uint48",
|
|
193
|
+
internalType: "uint48"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
stateMutability: "view"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
type: "function",
|
|
200
|
+
name: "getAgentCovenantIds",
|
|
201
|
+
inputs: [
|
|
202
|
+
{
|
|
203
|
+
name: "agent",
|
|
204
|
+
type: "address",
|
|
205
|
+
internalType: "address"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
outputs: [
|
|
209
|
+
{
|
|
210
|
+
name: "",
|
|
211
|
+
type: "uint256[]",
|
|
212
|
+
internalType: "uint256[]"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
stateMutability: "view"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: "function",
|
|
219
|
+
name: "getAgentCovenantsData",
|
|
220
|
+
inputs: [
|
|
221
|
+
{
|
|
222
|
+
name: "agent",
|
|
223
|
+
type: "address",
|
|
224
|
+
internalType: "address"
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
outputs: [
|
|
228
|
+
{
|
|
229
|
+
name: "",
|
|
230
|
+
type: "tuple[]",
|
|
231
|
+
internalType: "struct Kudo.CovenantData[]",
|
|
232
|
+
components: [
|
|
233
|
+
{
|
|
234
|
+
name: "agentWallet",
|
|
235
|
+
type: "address",
|
|
236
|
+
internalType: "address"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "agentId",
|
|
240
|
+
type: "uint256",
|
|
241
|
+
internalType: "uint256"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "status",
|
|
245
|
+
type: "uint8",
|
|
246
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "nftType",
|
|
250
|
+
type: "string",
|
|
251
|
+
internalType: "string"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "ask",
|
|
255
|
+
type: "string",
|
|
256
|
+
internalType: "string"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "covenantPromise",
|
|
260
|
+
type: "string",
|
|
261
|
+
internalType: "string"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "promiseDetail",
|
|
265
|
+
type: "string",
|
|
266
|
+
internalType: "string"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "askSettlementData",
|
|
270
|
+
type: "string",
|
|
271
|
+
internalType: "string"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "askSettledAt",
|
|
275
|
+
type: "uint256",
|
|
276
|
+
internalType: "uint256"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "promiseSettlementData",
|
|
280
|
+
type: "string",
|
|
281
|
+
internalType: "string"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
stateMutability: "view"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: "function",
|
|
290
|
+
name: "getApproved",
|
|
291
|
+
inputs: [
|
|
292
|
+
{
|
|
293
|
+
name: "tokenId",
|
|
294
|
+
type: "uint256",
|
|
295
|
+
internalType: "uint256"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
outputs: [
|
|
299
|
+
{
|
|
300
|
+
name: "",
|
|
301
|
+
type: "address",
|
|
302
|
+
internalType: "address"
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
stateMutability: "view"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: "function",
|
|
309
|
+
name: "getAskCooldown",
|
|
310
|
+
inputs: [],
|
|
311
|
+
outputs: [
|
|
312
|
+
{
|
|
313
|
+
name: "",
|
|
314
|
+
type: "uint256",
|
|
315
|
+
internalType: "uint256"
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
stateMutability: "view"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
type: "function",
|
|
322
|
+
name: "getCovenant",
|
|
323
|
+
inputs: [
|
|
324
|
+
{
|
|
325
|
+
name: "nftId",
|
|
326
|
+
type: "uint256",
|
|
327
|
+
internalType: "uint256"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
outputs: [
|
|
331
|
+
{
|
|
332
|
+
name: "",
|
|
333
|
+
type: "tuple",
|
|
334
|
+
internalType: "struct Kudo.CovenantData",
|
|
335
|
+
components: [
|
|
336
|
+
{
|
|
337
|
+
name: "agentWallet",
|
|
338
|
+
type: "address",
|
|
339
|
+
internalType: "address"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "agentId",
|
|
343
|
+
type: "uint256",
|
|
344
|
+
internalType: "uint256"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "status",
|
|
348
|
+
type: "uint8",
|
|
349
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: "nftType",
|
|
353
|
+
type: "string",
|
|
354
|
+
internalType: "string"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "ask",
|
|
358
|
+
type: "string",
|
|
359
|
+
internalType: "string"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "covenantPromise",
|
|
363
|
+
type: "string",
|
|
364
|
+
internalType: "string"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "promiseDetail",
|
|
368
|
+
type: "string",
|
|
369
|
+
internalType: "string"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "askSettlementData",
|
|
373
|
+
type: "string",
|
|
374
|
+
internalType: "string"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: "askSettledAt",
|
|
378
|
+
type: "uint256",
|
|
379
|
+
internalType: "uint256"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "promiseSettlementData",
|
|
383
|
+
type: "string",
|
|
384
|
+
internalType: "string"
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
stateMutability: "view"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: "function",
|
|
393
|
+
name: "getCovenantDetails",
|
|
394
|
+
inputs: [
|
|
395
|
+
{
|
|
396
|
+
name: "nftId",
|
|
397
|
+
type: "uint256",
|
|
398
|
+
internalType: "uint256"
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
outputs: [
|
|
402
|
+
{
|
|
403
|
+
name: "",
|
|
404
|
+
type: "tuple",
|
|
405
|
+
internalType: "struct Kudo.CovenantDetails",
|
|
406
|
+
components: [
|
|
407
|
+
{
|
|
408
|
+
name: "nftId",
|
|
409
|
+
type: "uint256",
|
|
410
|
+
internalType: "uint256"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "owner",
|
|
414
|
+
type: "address",
|
|
415
|
+
internalType: "address"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: "covenantData",
|
|
419
|
+
type: "tuple",
|
|
420
|
+
internalType: "struct Kudo.CovenantData",
|
|
421
|
+
components: [
|
|
422
|
+
{
|
|
423
|
+
name: "agentWallet",
|
|
424
|
+
type: "address",
|
|
425
|
+
internalType: "address"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: "agentId",
|
|
429
|
+
type: "uint256",
|
|
430
|
+
internalType: "uint256"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: "status",
|
|
434
|
+
type: "uint8",
|
|
435
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "nftType",
|
|
439
|
+
type: "string",
|
|
440
|
+
internalType: "string"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "ask",
|
|
444
|
+
type: "string",
|
|
445
|
+
internalType: "string"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
name: "covenantPromise",
|
|
449
|
+
type: "string",
|
|
450
|
+
internalType: "string"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
name: "promiseDetail",
|
|
454
|
+
type: "string",
|
|
455
|
+
internalType: "string"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "askSettlementData",
|
|
459
|
+
type: "string",
|
|
460
|
+
internalType: "string"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "askSettledAt",
|
|
464
|
+
type: "uint256",
|
|
465
|
+
internalType: "uint256"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: "promiseSettlementData",
|
|
469
|
+
type: "string",
|
|
470
|
+
internalType: "string"
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
]
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
stateMutability: "view"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
type: "function",
|
|
481
|
+
name: "getCovenantsDetails",
|
|
482
|
+
inputs: [],
|
|
483
|
+
outputs: [
|
|
484
|
+
{
|
|
485
|
+
name: "",
|
|
486
|
+
type: "tuple[]",
|
|
487
|
+
internalType: "struct Kudo.CovenantDetails[]",
|
|
488
|
+
components: [
|
|
489
|
+
{
|
|
490
|
+
name: "nftId",
|
|
491
|
+
type: "uint256",
|
|
492
|
+
internalType: "uint256"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "owner",
|
|
496
|
+
type: "address",
|
|
497
|
+
internalType: "address"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
name: "covenantData",
|
|
501
|
+
type: "tuple",
|
|
502
|
+
internalType: "struct Kudo.CovenantData",
|
|
503
|
+
components: [
|
|
504
|
+
{
|
|
505
|
+
name: "agentWallet",
|
|
506
|
+
type: "address",
|
|
507
|
+
internalType: "address"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "agentId",
|
|
511
|
+
type: "uint256",
|
|
512
|
+
internalType: "uint256"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: "status",
|
|
516
|
+
type: "uint8",
|
|
517
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "nftType",
|
|
521
|
+
type: "string",
|
|
522
|
+
internalType: "string"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: "ask",
|
|
526
|
+
type: "string",
|
|
527
|
+
internalType: "string"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "covenantPromise",
|
|
531
|
+
type: "string",
|
|
532
|
+
internalType: "string"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "promiseDetail",
|
|
536
|
+
type: "string",
|
|
537
|
+
internalType: "string"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "askSettlementData",
|
|
541
|
+
type: "string",
|
|
542
|
+
internalType: "string"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: "askSettledAt",
|
|
546
|
+
type: "uint256",
|
|
547
|
+
internalType: "uint256"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
name: "promiseSettlementData",
|
|
551
|
+
type: "string",
|
|
552
|
+
internalType: "string"
|
|
553
|
+
}
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
stateMutability: "view"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
type: "function",
|
|
563
|
+
name: "getCovenantsWithStatus",
|
|
564
|
+
inputs: [
|
|
565
|
+
{
|
|
566
|
+
name: "status",
|
|
567
|
+
type: "uint8",
|
|
568
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
outputs: [
|
|
572
|
+
{
|
|
573
|
+
name: "",
|
|
574
|
+
type: "tuple[]",
|
|
575
|
+
internalType: "struct Kudo.CovenantData[]",
|
|
576
|
+
components: [
|
|
577
|
+
{
|
|
578
|
+
name: "agentWallet",
|
|
579
|
+
type: "address",
|
|
580
|
+
internalType: "address"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: "agentId",
|
|
584
|
+
type: "uint256",
|
|
585
|
+
internalType: "uint256"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
name: "status",
|
|
589
|
+
type: "uint8",
|
|
590
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
name: "nftType",
|
|
594
|
+
type: "string",
|
|
595
|
+
internalType: "string"
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: "ask",
|
|
599
|
+
type: "string",
|
|
600
|
+
internalType: "string"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: "covenantPromise",
|
|
604
|
+
type: "string",
|
|
605
|
+
internalType: "string"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: "promiseDetail",
|
|
609
|
+
type: "string",
|
|
610
|
+
internalType: "string"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: "askSettlementData",
|
|
614
|
+
type: "string",
|
|
615
|
+
internalType: "string"
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
name: "askSettledAt",
|
|
619
|
+
type: "uint256",
|
|
620
|
+
internalType: "uint256"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "promiseSettlementData",
|
|
624
|
+
type: "string",
|
|
625
|
+
internalType: "string"
|
|
626
|
+
}
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
],
|
|
630
|
+
stateMutability: "view"
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
type: "function",
|
|
634
|
+
name: "getRoleAdmin",
|
|
635
|
+
inputs: [
|
|
636
|
+
{
|
|
637
|
+
name: "role",
|
|
638
|
+
type: "bytes32",
|
|
639
|
+
internalType: "bytes32"
|
|
640
|
+
}
|
|
641
|
+
],
|
|
642
|
+
outputs: [
|
|
643
|
+
{
|
|
644
|
+
name: "",
|
|
645
|
+
type: "bytes32",
|
|
646
|
+
internalType: "bytes32"
|
|
647
|
+
}
|
|
648
|
+
],
|
|
649
|
+
stateMutability: "view"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
type: "function",
|
|
653
|
+
name: "getTotalCovenants",
|
|
654
|
+
inputs: [],
|
|
655
|
+
outputs: [
|
|
656
|
+
{
|
|
657
|
+
name: "",
|
|
658
|
+
type: "uint256",
|
|
659
|
+
internalType: "uint256"
|
|
660
|
+
}
|
|
661
|
+
],
|
|
662
|
+
stateMutability: "view"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
type: "function",
|
|
666
|
+
name: "grantRole",
|
|
667
|
+
inputs: [
|
|
668
|
+
{
|
|
669
|
+
name: "role",
|
|
670
|
+
type: "bytes32",
|
|
671
|
+
internalType: "bytes32"
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: "account",
|
|
675
|
+
type: "address",
|
|
676
|
+
internalType: "address"
|
|
677
|
+
}
|
|
678
|
+
],
|
|
679
|
+
outputs: [],
|
|
680
|
+
stateMutability: "nonpayable"
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
type: "function",
|
|
684
|
+
name: "hasRole",
|
|
685
|
+
inputs: [
|
|
686
|
+
{
|
|
687
|
+
name: "role",
|
|
688
|
+
type: "bytes32",
|
|
689
|
+
internalType: "bytes32"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
name: "account",
|
|
693
|
+
type: "address",
|
|
694
|
+
internalType: "address"
|
|
695
|
+
}
|
|
696
|
+
],
|
|
697
|
+
outputs: [
|
|
698
|
+
{
|
|
699
|
+
name: "",
|
|
700
|
+
type: "bool",
|
|
701
|
+
internalType: "bool"
|
|
702
|
+
}
|
|
703
|
+
],
|
|
704
|
+
stateMutability: "view"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
type: "function",
|
|
708
|
+
name: "isApprovedForAll",
|
|
709
|
+
inputs: [
|
|
710
|
+
{
|
|
711
|
+
name: "owner",
|
|
712
|
+
type: "address",
|
|
713
|
+
internalType: "address"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: "operator",
|
|
717
|
+
type: "address",
|
|
718
|
+
internalType: "address"
|
|
719
|
+
}
|
|
720
|
+
],
|
|
721
|
+
outputs: [
|
|
722
|
+
{
|
|
723
|
+
name: "",
|
|
724
|
+
type: "bool",
|
|
725
|
+
internalType: "bool"
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
stateMutability: "view"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
type: "function",
|
|
732
|
+
name: "isAskSettled",
|
|
733
|
+
inputs: [
|
|
734
|
+
{
|
|
735
|
+
name: "nftId",
|
|
736
|
+
type: "uint256",
|
|
737
|
+
internalType: "uint256"
|
|
738
|
+
}
|
|
739
|
+
],
|
|
740
|
+
outputs: [
|
|
741
|
+
{
|
|
742
|
+
name: "",
|
|
743
|
+
type: "bool",
|
|
744
|
+
internalType: "bool"
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
stateMutability: "view"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
type: "function",
|
|
751
|
+
name: "isMintAccessControlEnabled",
|
|
752
|
+
inputs: [],
|
|
753
|
+
outputs: [
|
|
754
|
+
{
|
|
755
|
+
name: "",
|
|
756
|
+
type: "bool",
|
|
757
|
+
internalType: "bool"
|
|
758
|
+
}
|
|
759
|
+
],
|
|
760
|
+
stateMutability: "view"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
type: "function",
|
|
764
|
+
name: "mintCovenant",
|
|
765
|
+
inputs: [
|
|
766
|
+
{
|
|
767
|
+
name: "agentId",
|
|
768
|
+
type: "uint256",
|
|
769
|
+
internalType: "uint256"
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
name: "covenantPromise",
|
|
773
|
+
type: "string",
|
|
774
|
+
internalType: "string"
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
name: "ask",
|
|
778
|
+
type: "string",
|
|
779
|
+
internalType: "string"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
name: "nftType",
|
|
783
|
+
type: "string",
|
|
784
|
+
internalType: "string"
|
|
785
|
+
}
|
|
786
|
+
],
|
|
787
|
+
outputs: [
|
|
788
|
+
{
|
|
789
|
+
name: "",
|
|
790
|
+
type: "uint256",
|
|
791
|
+
internalType: "uint256"
|
|
792
|
+
}
|
|
793
|
+
],
|
|
794
|
+
stateMutability: "nonpayable"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
type: "function",
|
|
798
|
+
name: "name",
|
|
799
|
+
inputs: [],
|
|
800
|
+
outputs: [
|
|
801
|
+
{
|
|
802
|
+
name: "",
|
|
803
|
+
type: "string",
|
|
804
|
+
internalType: "string"
|
|
805
|
+
}
|
|
806
|
+
],
|
|
807
|
+
stateMutability: "view"
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
type: "function",
|
|
811
|
+
name: "owner",
|
|
812
|
+
inputs: [],
|
|
813
|
+
outputs: [
|
|
814
|
+
{
|
|
815
|
+
name: "",
|
|
816
|
+
type: "address",
|
|
817
|
+
internalType: "address"
|
|
818
|
+
}
|
|
819
|
+
],
|
|
820
|
+
stateMutability: "view"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
type: "function",
|
|
824
|
+
name: "ownerOf",
|
|
825
|
+
inputs: [
|
|
826
|
+
{
|
|
827
|
+
name: "tokenId",
|
|
828
|
+
type: "uint256",
|
|
829
|
+
internalType: "uint256"
|
|
830
|
+
}
|
|
831
|
+
],
|
|
832
|
+
outputs: [
|
|
833
|
+
{
|
|
834
|
+
name: "",
|
|
835
|
+
type: "address",
|
|
836
|
+
internalType: "address"
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
stateMutability: "view"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
type: "function",
|
|
843
|
+
name: "pendingDefaultAdmin",
|
|
844
|
+
inputs: [],
|
|
845
|
+
outputs: [
|
|
846
|
+
{
|
|
847
|
+
name: "newAdmin",
|
|
848
|
+
type: "address",
|
|
849
|
+
internalType: "address"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
name: "schedule",
|
|
853
|
+
type: "uint48",
|
|
854
|
+
internalType: "uint48"
|
|
855
|
+
}
|
|
856
|
+
],
|
|
857
|
+
stateMutability: "view"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
type: "function",
|
|
861
|
+
name: "pendingDefaultAdminDelay",
|
|
862
|
+
inputs: [],
|
|
863
|
+
outputs: [
|
|
864
|
+
{
|
|
865
|
+
name: "newDelay",
|
|
866
|
+
type: "uint48",
|
|
867
|
+
internalType: "uint48"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
name: "schedule",
|
|
871
|
+
type: "uint48",
|
|
872
|
+
internalType: "uint48"
|
|
873
|
+
}
|
|
874
|
+
],
|
|
875
|
+
stateMutability: "view"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
type: "function",
|
|
879
|
+
name: "renounceRole",
|
|
880
|
+
inputs: [
|
|
881
|
+
{
|
|
882
|
+
name: "role",
|
|
883
|
+
type: "bytes32",
|
|
884
|
+
internalType: "bytes32"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
name: "account",
|
|
888
|
+
type: "address",
|
|
889
|
+
internalType: "address"
|
|
890
|
+
}
|
|
891
|
+
],
|
|
892
|
+
outputs: [],
|
|
893
|
+
stateMutability: "nonpayable"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
type: "function",
|
|
897
|
+
name: "revokeRole",
|
|
898
|
+
inputs: [
|
|
899
|
+
{
|
|
900
|
+
name: "role",
|
|
901
|
+
type: "bytes32",
|
|
902
|
+
internalType: "bytes32"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
name: "account",
|
|
906
|
+
type: "address",
|
|
907
|
+
internalType: "address"
|
|
908
|
+
}
|
|
909
|
+
],
|
|
910
|
+
outputs: [],
|
|
911
|
+
stateMutability: "nonpayable"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
type: "function",
|
|
915
|
+
name: "rollbackDefaultAdminDelay",
|
|
916
|
+
inputs: [],
|
|
917
|
+
outputs: [],
|
|
918
|
+
stateMutability: "nonpayable"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
type: "function",
|
|
922
|
+
name: "safeTransferFrom",
|
|
923
|
+
inputs: [
|
|
924
|
+
{
|
|
925
|
+
name: "from",
|
|
926
|
+
type: "address",
|
|
927
|
+
internalType: "address"
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
name: "to",
|
|
931
|
+
type: "address",
|
|
932
|
+
internalType: "address"
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
name: "tokenId",
|
|
936
|
+
type: "uint256",
|
|
937
|
+
internalType: "uint256"
|
|
938
|
+
}
|
|
939
|
+
],
|
|
940
|
+
outputs: [],
|
|
941
|
+
stateMutability: "nonpayable"
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
type: "function",
|
|
945
|
+
name: "safeTransferFrom",
|
|
946
|
+
inputs: [
|
|
947
|
+
{
|
|
948
|
+
name: "from",
|
|
949
|
+
type: "address",
|
|
950
|
+
internalType: "address"
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
name: "to",
|
|
954
|
+
type: "address",
|
|
955
|
+
internalType: "address"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
name: "tokenId",
|
|
959
|
+
type: "uint256",
|
|
960
|
+
internalType: "uint256"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
name: "data",
|
|
964
|
+
type: "bytes",
|
|
965
|
+
internalType: "bytes"
|
|
966
|
+
}
|
|
967
|
+
],
|
|
968
|
+
outputs: [],
|
|
969
|
+
stateMutability: "nonpayable"
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
type: "function",
|
|
973
|
+
name: "setApprovalForAll",
|
|
974
|
+
inputs: [
|
|
975
|
+
{
|
|
976
|
+
name: "operator",
|
|
977
|
+
type: "address",
|
|
978
|
+
internalType: "address"
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
name: "approved",
|
|
982
|
+
type: "bool",
|
|
983
|
+
internalType: "bool"
|
|
984
|
+
}
|
|
985
|
+
],
|
|
986
|
+
outputs: [],
|
|
987
|
+
stateMutability: "nonpayable"
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
type: "function",
|
|
991
|
+
name: "setAskCooldown",
|
|
992
|
+
inputs: [
|
|
993
|
+
{
|
|
994
|
+
name: "cooldownSeconds",
|
|
995
|
+
type: "uint256",
|
|
996
|
+
internalType: "uint256"
|
|
997
|
+
}
|
|
998
|
+
],
|
|
999
|
+
outputs: [],
|
|
1000
|
+
stateMutability: "nonpayable"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
type: "function",
|
|
1004
|
+
name: "setAskSettlementData",
|
|
1005
|
+
inputs: [
|
|
1006
|
+
{
|
|
1007
|
+
name: "nftId",
|
|
1008
|
+
type: "uint256",
|
|
1009
|
+
internalType: "uint256"
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
name: "settlementData",
|
|
1013
|
+
type: "string",
|
|
1014
|
+
internalType: "string"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
name: "promiseDetail",
|
|
1018
|
+
type: "string",
|
|
1019
|
+
internalType: "string"
|
|
1020
|
+
}
|
|
1021
|
+
],
|
|
1022
|
+
outputs: [],
|
|
1023
|
+
stateMutability: "nonpayable"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
type: "function",
|
|
1027
|
+
name: "setCovenantStatus",
|
|
1028
|
+
inputs: [
|
|
1029
|
+
{
|
|
1030
|
+
name: "nftId",
|
|
1031
|
+
type: "uint256",
|
|
1032
|
+
internalType: "uint256"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
name: "status",
|
|
1036
|
+
type: "uint8",
|
|
1037
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
1038
|
+
}
|
|
1039
|
+
],
|
|
1040
|
+
outputs: [],
|
|
1041
|
+
stateMutability: "nonpayable"
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
type: "function",
|
|
1045
|
+
name: "setMintAccessControl",
|
|
1046
|
+
inputs: [
|
|
1047
|
+
{
|
|
1048
|
+
name: "enabled",
|
|
1049
|
+
type: "bool",
|
|
1050
|
+
internalType: "bool"
|
|
1051
|
+
}
|
|
1052
|
+
],
|
|
1053
|
+
outputs: [],
|
|
1054
|
+
stateMutability: "nonpayable"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
type: "function",
|
|
1058
|
+
name: "setPromiseSettlementData",
|
|
1059
|
+
inputs: [
|
|
1060
|
+
{
|
|
1061
|
+
name: "nftId",
|
|
1062
|
+
type: "uint256",
|
|
1063
|
+
internalType: "uint256"
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
name: "data",
|
|
1067
|
+
type: "string",
|
|
1068
|
+
internalType: "string"
|
|
1069
|
+
}
|
|
1070
|
+
],
|
|
1071
|
+
outputs: [],
|
|
1072
|
+
stateMutability: "nonpayable"
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
type: "function",
|
|
1076
|
+
name: "supportsInterface",
|
|
1077
|
+
inputs: [
|
|
1078
|
+
{
|
|
1079
|
+
name: "interfaceId",
|
|
1080
|
+
type: "bytes4",
|
|
1081
|
+
internalType: "bytes4"
|
|
1082
|
+
}
|
|
1083
|
+
],
|
|
1084
|
+
outputs: [
|
|
1085
|
+
{
|
|
1086
|
+
name: "",
|
|
1087
|
+
type: "bool",
|
|
1088
|
+
internalType: "bool"
|
|
1089
|
+
}
|
|
1090
|
+
],
|
|
1091
|
+
stateMutability: "view"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
type: "function",
|
|
1095
|
+
name: "symbol",
|
|
1096
|
+
inputs: [],
|
|
1097
|
+
outputs: [
|
|
1098
|
+
{
|
|
1099
|
+
name: "",
|
|
1100
|
+
type: "string",
|
|
1101
|
+
internalType: "string"
|
|
1102
|
+
}
|
|
1103
|
+
],
|
|
1104
|
+
stateMutability: "view"
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
type: "function",
|
|
1108
|
+
name: "tokenURI",
|
|
1109
|
+
inputs: [
|
|
1110
|
+
{
|
|
1111
|
+
name: "tokenId",
|
|
1112
|
+
type: "uint256",
|
|
1113
|
+
internalType: "uint256"
|
|
1114
|
+
}
|
|
1115
|
+
],
|
|
1116
|
+
outputs: [
|
|
1117
|
+
{
|
|
1118
|
+
name: "",
|
|
1119
|
+
type: "string",
|
|
1120
|
+
internalType: "string"
|
|
1121
|
+
}
|
|
1122
|
+
],
|
|
1123
|
+
stateMutability: "view"
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
type: "function",
|
|
1127
|
+
name: "transferFrom",
|
|
1128
|
+
inputs: [
|
|
1129
|
+
{
|
|
1130
|
+
name: "from",
|
|
1131
|
+
type: "address",
|
|
1132
|
+
internalType: "address"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
name: "to",
|
|
1136
|
+
type: "address",
|
|
1137
|
+
internalType: "address"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: "tokenId",
|
|
1141
|
+
type: "uint256",
|
|
1142
|
+
internalType: "uint256"
|
|
1143
|
+
}
|
|
1144
|
+
],
|
|
1145
|
+
outputs: [],
|
|
1146
|
+
stateMutability: "nonpayable"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
type: "event",
|
|
1150
|
+
name: "Approval",
|
|
1151
|
+
inputs: [
|
|
1152
|
+
{
|
|
1153
|
+
name: "owner",
|
|
1154
|
+
type: "address",
|
|
1155
|
+
indexed: true,
|
|
1156
|
+
internalType: "address"
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
name: "approved",
|
|
1160
|
+
type: "address",
|
|
1161
|
+
indexed: true,
|
|
1162
|
+
internalType: "address"
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
name: "tokenId",
|
|
1166
|
+
type: "uint256",
|
|
1167
|
+
indexed: true,
|
|
1168
|
+
internalType: "uint256"
|
|
1169
|
+
}
|
|
1170
|
+
],
|
|
1171
|
+
anonymous: false
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
type: "event",
|
|
1175
|
+
name: "ApprovalForAll",
|
|
1176
|
+
inputs: [
|
|
1177
|
+
{
|
|
1178
|
+
name: "owner",
|
|
1179
|
+
type: "address",
|
|
1180
|
+
indexed: true,
|
|
1181
|
+
internalType: "address"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
name: "operator",
|
|
1185
|
+
type: "address",
|
|
1186
|
+
indexed: true,
|
|
1187
|
+
internalType: "address"
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
name: "approved",
|
|
1191
|
+
type: "bool",
|
|
1192
|
+
indexed: false,
|
|
1193
|
+
internalType: "bool"
|
|
1194
|
+
}
|
|
1195
|
+
],
|
|
1196
|
+
anonymous: false
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
type: "event",
|
|
1200
|
+
name: "AskCooldownSet",
|
|
1201
|
+
inputs: [
|
|
1202
|
+
{
|
|
1203
|
+
name: "cooldownSeconds",
|
|
1204
|
+
type: "uint256",
|
|
1205
|
+
indexed: false,
|
|
1206
|
+
internalType: "uint256"
|
|
1207
|
+
}
|
|
1208
|
+
],
|
|
1209
|
+
anonymous: false
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
type: "event",
|
|
1213
|
+
name: "AskSettlementSet",
|
|
1214
|
+
inputs: [
|
|
1215
|
+
{
|
|
1216
|
+
name: "nftId",
|
|
1217
|
+
type: "uint256",
|
|
1218
|
+
indexed: false,
|
|
1219
|
+
internalType: "uint256"
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
name: "askSettlement",
|
|
1223
|
+
type: "string",
|
|
1224
|
+
indexed: false,
|
|
1225
|
+
internalType: "string"
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
name: "promiseDetails",
|
|
1229
|
+
type: "string",
|
|
1230
|
+
indexed: false,
|
|
1231
|
+
internalType: "string"
|
|
1232
|
+
}
|
|
1233
|
+
],
|
|
1234
|
+
anonymous: false
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
type: "event",
|
|
1238
|
+
name: "CovenantMinted",
|
|
1239
|
+
inputs: [
|
|
1240
|
+
{
|
|
1241
|
+
name: "nftId",
|
|
1242
|
+
type: "uint256",
|
|
1243
|
+
indexed: false,
|
|
1244
|
+
internalType: "uint256"
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
name: "agent",
|
|
1248
|
+
type: "address",
|
|
1249
|
+
indexed: true,
|
|
1250
|
+
internalType: "address"
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
name: "nftType",
|
|
1254
|
+
type: "string",
|
|
1255
|
+
indexed: false,
|
|
1256
|
+
internalType: "string"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
name: "covenantPromise",
|
|
1260
|
+
type: "string",
|
|
1261
|
+
indexed: false,
|
|
1262
|
+
internalType: "string"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "ask",
|
|
1266
|
+
type: "string",
|
|
1267
|
+
indexed: false,
|
|
1268
|
+
internalType: "string"
|
|
1269
|
+
}
|
|
1270
|
+
],
|
|
1271
|
+
anonymous: false
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
type: "event",
|
|
1275
|
+
name: "CovenantPromiseSet",
|
|
1276
|
+
inputs: [
|
|
1277
|
+
{
|
|
1278
|
+
name: "nftId",
|
|
1279
|
+
type: "uint256",
|
|
1280
|
+
indexed: true,
|
|
1281
|
+
internalType: "uint256"
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
name: "status",
|
|
1285
|
+
type: "uint8",
|
|
1286
|
+
indexed: false,
|
|
1287
|
+
internalType: "enum Kudo.CovenantStatus"
|
|
1288
|
+
}
|
|
1289
|
+
],
|
|
1290
|
+
anonymous: false
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
type: "event",
|
|
1294
|
+
name: "DefaultAdminDelayChangeCanceled",
|
|
1295
|
+
inputs: [],
|
|
1296
|
+
anonymous: false
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
type: "event",
|
|
1300
|
+
name: "DefaultAdminDelayChangeScheduled",
|
|
1301
|
+
inputs: [
|
|
1302
|
+
{
|
|
1303
|
+
name: "newDelay",
|
|
1304
|
+
type: "uint48",
|
|
1305
|
+
indexed: false,
|
|
1306
|
+
internalType: "uint48"
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
name: "effectSchedule",
|
|
1310
|
+
type: "uint48",
|
|
1311
|
+
indexed: false,
|
|
1312
|
+
internalType: "uint48"
|
|
1313
|
+
}
|
|
1314
|
+
],
|
|
1315
|
+
anonymous: false
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
type: "event",
|
|
1319
|
+
name: "DefaultAdminTransferCanceled",
|
|
1320
|
+
inputs: [],
|
|
1321
|
+
anonymous: false
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
type: "event",
|
|
1325
|
+
name: "DefaultAdminTransferScheduled",
|
|
1326
|
+
inputs: [
|
|
1327
|
+
{
|
|
1328
|
+
name: "newAdmin",
|
|
1329
|
+
type: "address",
|
|
1330
|
+
indexed: true,
|
|
1331
|
+
internalType: "address"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
name: "acceptSchedule",
|
|
1335
|
+
type: "uint48",
|
|
1336
|
+
indexed: false,
|
|
1337
|
+
internalType: "uint48"
|
|
1338
|
+
}
|
|
1339
|
+
],
|
|
1340
|
+
anonymous: false
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
type: "event",
|
|
1344
|
+
name: "MintAccessControlSet",
|
|
1345
|
+
inputs: [
|
|
1346
|
+
{
|
|
1347
|
+
name: "enabled",
|
|
1348
|
+
type: "bool",
|
|
1349
|
+
indexed: false,
|
|
1350
|
+
internalType: "bool"
|
|
1351
|
+
}
|
|
1352
|
+
],
|
|
1353
|
+
anonymous: false
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
type: "event",
|
|
1357
|
+
name: "PromiseSettlementSet",
|
|
1358
|
+
inputs: [
|
|
1359
|
+
{
|
|
1360
|
+
name: "nftId",
|
|
1361
|
+
type: "uint256",
|
|
1362
|
+
indexed: false,
|
|
1363
|
+
internalType: "uint256"
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
name: "promiseSettlement",
|
|
1367
|
+
type: "string",
|
|
1368
|
+
indexed: false,
|
|
1369
|
+
internalType: "string"
|
|
1370
|
+
}
|
|
1371
|
+
],
|
|
1372
|
+
anonymous: false
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
type: "event",
|
|
1376
|
+
name: "RoleAdminChanged",
|
|
1377
|
+
inputs: [
|
|
1378
|
+
{
|
|
1379
|
+
name: "role",
|
|
1380
|
+
type: "bytes32",
|
|
1381
|
+
indexed: true,
|
|
1382
|
+
internalType: "bytes32"
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
name: "previousAdminRole",
|
|
1386
|
+
type: "bytes32",
|
|
1387
|
+
indexed: true,
|
|
1388
|
+
internalType: "bytes32"
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
name: "newAdminRole",
|
|
1392
|
+
type: "bytes32",
|
|
1393
|
+
indexed: true,
|
|
1394
|
+
internalType: "bytes32"
|
|
1395
|
+
}
|
|
1396
|
+
],
|
|
1397
|
+
anonymous: false
|
|
1398
|
+
},
|
|
1399
|
+
{
|
|
1400
|
+
type: "event",
|
|
1401
|
+
name: "RoleGranted",
|
|
1402
|
+
inputs: [
|
|
1403
|
+
{
|
|
1404
|
+
name: "role",
|
|
1405
|
+
type: "bytes32",
|
|
1406
|
+
indexed: true,
|
|
1407
|
+
internalType: "bytes32"
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
name: "account",
|
|
1411
|
+
type: "address",
|
|
1412
|
+
indexed: true,
|
|
1413
|
+
internalType: "address"
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
name: "sender",
|
|
1417
|
+
type: "address",
|
|
1418
|
+
indexed: true,
|
|
1419
|
+
internalType: "address"
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
anonymous: false
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
type: "event",
|
|
1426
|
+
name: "RoleRevoked",
|
|
1427
|
+
inputs: [
|
|
1428
|
+
{
|
|
1429
|
+
name: "role",
|
|
1430
|
+
type: "bytes32",
|
|
1431
|
+
indexed: true,
|
|
1432
|
+
internalType: "bytes32"
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
name: "account",
|
|
1436
|
+
type: "address",
|
|
1437
|
+
indexed: true,
|
|
1438
|
+
internalType: "address"
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
name: "sender",
|
|
1442
|
+
type: "address",
|
|
1443
|
+
indexed: true,
|
|
1444
|
+
internalType: "address"
|
|
1445
|
+
}
|
|
1446
|
+
],
|
|
1447
|
+
anonymous: false
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
type: "event",
|
|
1451
|
+
name: "Transfer",
|
|
1452
|
+
inputs: [
|
|
1453
|
+
{
|
|
1454
|
+
name: "from",
|
|
1455
|
+
type: "address",
|
|
1456
|
+
indexed: true,
|
|
1457
|
+
internalType: "address"
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
name: "to",
|
|
1461
|
+
type: "address",
|
|
1462
|
+
indexed: true,
|
|
1463
|
+
internalType: "address"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: "tokenId",
|
|
1467
|
+
type: "uint256",
|
|
1468
|
+
indexed: true,
|
|
1469
|
+
internalType: "uint256"
|
|
1470
|
+
}
|
|
1471
|
+
],
|
|
1472
|
+
anonymous: false
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
type: "error",
|
|
1476
|
+
name: "AccessControlBadConfirmation",
|
|
1477
|
+
inputs: []
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
type: "error",
|
|
1481
|
+
name: "AccessControlEnforcedDefaultAdminDelay",
|
|
1482
|
+
inputs: [
|
|
1483
|
+
{
|
|
1484
|
+
name: "schedule",
|
|
1485
|
+
type: "uint48",
|
|
1486
|
+
internalType: "uint48"
|
|
1487
|
+
}
|
|
1488
|
+
]
|
|
1489
|
+
},
|
|
1490
|
+
{
|
|
1491
|
+
type: "error",
|
|
1492
|
+
name: "AccessControlEnforcedDefaultAdminRules",
|
|
1493
|
+
inputs: []
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
type: "error",
|
|
1497
|
+
name: "AccessControlInvalidDefaultAdmin",
|
|
1498
|
+
inputs: [
|
|
1499
|
+
{
|
|
1500
|
+
name: "defaultAdmin",
|
|
1501
|
+
type: "address",
|
|
1502
|
+
internalType: "address"
|
|
1503
|
+
}
|
|
1504
|
+
]
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
type: "error",
|
|
1508
|
+
name: "AccessControlUnauthorizedAccount",
|
|
1509
|
+
inputs: [
|
|
1510
|
+
{
|
|
1511
|
+
name: "account",
|
|
1512
|
+
type: "address",
|
|
1513
|
+
internalType: "address"
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
name: "neededRole",
|
|
1517
|
+
type: "bytes32",
|
|
1518
|
+
internalType: "bytes32"
|
|
1519
|
+
}
|
|
1520
|
+
]
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
type: "error",
|
|
1524
|
+
name: "AccessForbidden",
|
|
1525
|
+
inputs: []
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
type: "error",
|
|
1529
|
+
name: "CovenantNotFound",
|
|
1530
|
+
inputs: []
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
type: "error",
|
|
1534
|
+
name: "ERC721IncorrectOwner",
|
|
1535
|
+
inputs: [
|
|
1536
|
+
{
|
|
1537
|
+
name: "sender",
|
|
1538
|
+
type: "address",
|
|
1539
|
+
internalType: "address"
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
name: "tokenId",
|
|
1543
|
+
type: "uint256",
|
|
1544
|
+
internalType: "uint256"
|
|
1545
|
+
},
|
|
1546
|
+
{
|
|
1547
|
+
name: "owner",
|
|
1548
|
+
type: "address",
|
|
1549
|
+
internalType: "address"
|
|
1550
|
+
}
|
|
1551
|
+
]
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
type: "error",
|
|
1555
|
+
name: "ERC721InsufficientApproval",
|
|
1556
|
+
inputs: [
|
|
1557
|
+
{
|
|
1558
|
+
name: "operator",
|
|
1559
|
+
type: "address",
|
|
1560
|
+
internalType: "address"
|
|
1561
|
+
},
|
|
1562
|
+
{
|
|
1563
|
+
name: "tokenId",
|
|
1564
|
+
type: "uint256",
|
|
1565
|
+
internalType: "uint256"
|
|
1566
|
+
}
|
|
1567
|
+
]
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
type: "error",
|
|
1571
|
+
name: "ERC721InvalidApprover",
|
|
1572
|
+
inputs: [
|
|
1573
|
+
{
|
|
1574
|
+
name: "approver",
|
|
1575
|
+
type: "address",
|
|
1576
|
+
internalType: "address"
|
|
1577
|
+
}
|
|
1578
|
+
]
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
type: "error",
|
|
1582
|
+
name: "ERC721InvalidOperator",
|
|
1583
|
+
inputs: [
|
|
1584
|
+
{
|
|
1585
|
+
name: "operator",
|
|
1586
|
+
type: "address",
|
|
1587
|
+
internalType: "address"
|
|
1588
|
+
}
|
|
1589
|
+
]
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
type: "error",
|
|
1593
|
+
name: "ERC721InvalidOwner",
|
|
1594
|
+
inputs: [
|
|
1595
|
+
{
|
|
1596
|
+
name: "owner",
|
|
1597
|
+
type: "address",
|
|
1598
|
+
internalType: "address"
|
|
1599
|
+
}
|
|
1600
|
+
]
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
type: "error",
|
|
1604
|
+
name: "ERC721InvalidReceiver",
|
|
1605
|
+
inputs: [
|
|
1606
|
+
{
|
|
1607
|
+
name: "receiver",
|
|
1608
|
+
type: "address",
|
|
1609
|
+
internalType: "address"
|
|
1610
|
+
}
|
|
1611
|
+
]
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
type: "error",
|
|
1615
|
+
name: "ERC721InvalidSender",
|
|
1616
|
+
inputs: [
|
|
1617
|
+
{
|
|
1618
|
+
name: "sender",
|
|
1619
|
+
type: "address",
|
|
1620
|
+
internalType: "address"
|
|
1621
|
+
}
|
|
1622
|
+
]
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
type: "error",
|
|
1626
|
+
name: "ERC721NonexistentToken",
|
|
1627
|
+
inputs: [
|
|
1628
|
+
{
|
|
1629
|
+
name: "tokenId",
|
|
1630
|
+
type: "uint256",
|
|
1631
|
+
internalType: "uint256"
|
|
1632
|
+
}
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
type: "error",
|
|
1637
|
+
name: "SafeCastOverflowedUintDowncast",
|
|
1638
|
+
inputs: [
|
|
1639
|
+
{
|
|
1640
|
+
name: "bits",
|
|
1641
|
+
type: "uint8",
|
|
1642
|
+
internalType: "uint8"
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
name: "value",
|
|
1646
|
+
type: "uint256",
|
|
1647
|
+
internalType: "uint256"
|
|
1648
|
+
}
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
];
|
|
1652
|
+
|
|
1653
|
+
// src/abi/registries.ts
|
|
1654
|
+
var identityRegistryAbi = [
|
|
1655
|
+
{
|
|
1656
|
+
type: "function",
|
|
1657
|
+
name: "register",
|
|
1658
|
+
inputs: [
|
|
1659
|
+
{ name: "agentURI", type: "string" },
|
|
1660
|
+
{
|
|
1661
|
+
name: "metadata",
|
|
1662
|
+
type: "tuple[]",
|
|
1663
|
+
components: [
|
|
1664
|
+
{ name: "metadataKey", type: "string" },
|
|
1665
|
+
{ name: "metadataValue", type: "bytes" }
|
|
1666
|
+
]
|
|
1667
|
+
}
|
|
1668
|
+
],
|
|
1669
|
+
outputs: [{ name: "agentId", type: "uint256" }],
|
|
1670
|
+
stateMutability: "nonpayable"
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
type: "function",
|
|
1674
|
+
name: "setMetadata",
|
|
1675
|
+
inputs: [
|
|
1676
|
+
{ name: "agentId", type: "uint256" },
|
|
1677
|
+
{ name: "key", type: "string" },
|
|
1678
|
+
{ name: "value", type: "bytes" }
|
|
1679
|
+
],
|
|
1680
|
+
outputs: [],
|
|
1681
|
+
stateMutability: "nonpayable"
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
type: "function",
|
|
1685
|
+
name: "getMetadata",
|
|
1686
|
+
inputs: [
|
|
1687
|
+
{ name: "agentId", type: "uint256" },
|
|
1688
|
+
{ name: "key", type: "string" }
|
|
1689
|
+
],
|
|
1690
|
+
outputs: [{ name: "", type: "bytes" }],
|
|
1691
|
+
stateMutability: "view"
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
type: "function",
|
|
1695
|
+
name: "ownerOf",
|
|
1696
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
1697
|
+
outputs: [{ name: "", type: "address" }],
|
|
1698
|
+
stateMutability: "view"
|
|
1699
|
+
},
|
|
1700
|
+
{
|
|
1701
|
+
type: "function",
|
|
1702
|
+
name: "balanceOf",
|
|
1703
|
+
inputs: [{ name: "owner", type: "address" }],
|
|
1704
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1705
|
+
stateMutability: "view"
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
type: "function",
|
|
1709
|
+
name: "tokenURI",
|
|
1710
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
1711
|
+
outputs: [{ name: "", type: "string" }],
|
|
1712
|
+
stateMutability: "view"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
type: "event",
|
|
1716
|
+
name: "Registered",
|
|
1717
|
+
inputs: [
|
|
1718
|
+
{ name: "agentId", type: "uint256", indexed: true },
|
|
1719
|
+
{ name: "agentURI", type: "string", indexed: false },
|
|
1720
|
+
{ name: "owner", type: "address", indexed: true }
|
|
1721
|
+
],
|
|
1722
|
+
anonymous: false
|
|
1723
|
+
},
|
|
1724
|
+
{
|
|
1725
|
+
type: "event",
|
|
1726
|
+
name: "Transfer",
|
|
1727
|
+
inputs: [
|
|
1728
|
+
{ name: "from", type: "address", indexed: true },
|
|
1729
|
+
{ name: "to", type: "address", indexed: true },
|
|
1730
|
+
{ name: "tokenId", type: "uint256", indexed: true }
|
|
1731
|
+
],
|
|
1732
|
+
anonymous: false
|
|
1733
|
+
}
|
|
1734
|
+
];
|
|
1735
|
+
var reputationRegistryAbi = [
|
|
1736
|
+
{
|
|
1737
|
+
type: "function",
|
|
1738
|
+
name: "getClients",
|
|
1739
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
1740
|
+
outputs: [{ name: "", type: "address[]" }],
|
|
1741
|
+
stateMutability: "view"
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
type: "function",
|
|
1745
|
+
name: "getSummary",
|
|
1746
|
+
inputs: [
|
|
1747
|
+
{ name: "agentId", type: "uint256" },
|
|
1748
|
+
{ name: "clientAddresses", type: "address[]" },
|
|
1749
|
+
{ name: "tag1", type: "string" },
|
|
1750
|
+
{ name: "tag2", type: "string" }
|
|
1751
|
+
],
|
|
1752
|
+
outputs: [
|
|
1753
|
+
{ name: "count", type: "uint64" },
|
|
1754
|
+
{ name: "summaryValue", type: "int128" },
|
|
1755
|
+
{ name: "summaryValueDecimals", type: "uint8" }
|
|
1756
|
+
],
|
|
1757
|
+
stateMutability: "view"
|
|
1758
|
+
}
|
|
1759
|
+
];
|
|
1760
|
+
|
|
1761
|
+
// src/errors.ts
|
|
1762
|
+
import { BaseError, ContractFunctionRevertedError } from "viem";
|
|
1763
|
+
var REVERTS = {
|
|
1764
|
+
"0x468381ac": {
|
|
1765
|
+
name: "NotAuthorizedForAgent",
|
|
1766
|
+
hint: "The sending wallet does not control that ERC-8004 agent id. Mint under an id this wallet owns (see findAgentIds / registerAgent)."
|
|
1767
|
+
},
|
|
1768
|
+
"0xef67f5d8": {
|
|
1769
|
+
name: "AccessForbidden",
|
|
1770
|
+
hint: "The caller is not allowed: on mint the wallet lacks AGENT_ROLE (only when mint access control is on); on linkProof the caller is not the covenant's agentWallet."
|
|
1771
|
+
},
|
|
1772
|
+
"0xe2517d3f": {
|
|
1773
|
+
name: "AccessControlUnauthorizedAccount",
|
|
1774
|
+
hint: "An onlyRole function refused this account. Closing a covenant is the Evaluator's job, not the agent's."
|
|
1775
|
+
},
|
|
1776
|
+
"0x613970e0": {
|
|
1777
|
+
name: "InvalidParameter",
|
|
1778
|
+
hint: "The contract rejected an argument, such as an empty string or a zero address."
|
|
1779
|
+
},
|
|
1780
|
+
"0x356680b7": {
|
|
1781
|
+
name: "InsufficientFunds",
|
|
1782
|
+
hint: "The wallet does not hold enough of the token for this transfer."
|
|
1783
|
+
},
|
|
1784
|
+
"0xe450d38c": {
|
|
1785
|
+
name: "ERC20InsufficientBalance",
|
|
1786
|
+
hint: "The wallet does not hold enough of this token for the transfer."
|
|
1787
|
+
},
|
|
1788
|
+
"0xf480469b": {
|
|
1789
|
+
name: "ConditionIsNotMet",
|
|
1790
|
+
hint: "This selector belongs to an older Kudo deployment. You are probably pointing at the wrong contract."
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
var KudoError = class extends Error {
|
|
1794
|
+
code;
|
|
1795
|
+
revert;
|
|
1796
|
+
constructor(code, message, options = {}) {
|
|
1797
|
+
super(message, { cause: options.cause });
|
|
1798
|
+
this.name = "KudoError";
|
|
1799
|
+
this.code = code;
|
|
1800
|
+
this.revert = options.revert;
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
function toKudoError(error, action) {
|
|
1804
|
+
if (error instanceof KudoError) return error;
|
|
1805
|
+
let selector;
|
|
1806
|
+
let name;
|
|
1807
|
+
if (error instanceof BaseError) {
|
|
1808
|
+
const reverted = error.walk((e) => e instanceof ContractFunctionRevertedError);
|
|
1809
|
+
if (reverted instanceof ContractFunctionRevertedError) {
|
|
1810
|
+
name = reverted.data?.errorName;
|
|
1811
|
+
selector = reverted.signature ?? reverted.raw?.slice(0, 10);
|
|
1812
|
+
} else {
|
|
1813
|
+
const raw = error.walk((e) => typeof e.data === "string");
|
|
1814
|
+
if (raw?.data && /^0x[0-9a-fA-F]{8}/.test(raw.data)) selector = raw.data.slice(0, 10);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
1818
|
+
if (!selector) {
|
|
1819
|
+
selector = Object.keys(REVERTS).find((s) => text.toLowerCase().includes(s));
|
|
1820
|
+
}
|
|
1821
|
+
const known = selector ? REVERTS[selector.toLowerCase()] : void 0;
|
|
1822
|
+
name = name ?? known?.name;
|
|
1823
|
+
if (name || selector) {
|
|
1824
|
+
return new KudoError(
|
|
1825
|
+
"REVERTED",
|
|
1826
|
+
`${action} reverted${name ? ` with ${name}` : ""}${known ? `: ${known.hint}` : "."}`,
|
|
1827
|
+
{ cause: error, revert: { selector, name, hint: known?.hint } }
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
const short = error instanceof BaseError ? error.shortMessage : text;
|
|
1831
|
+
return new KudoError("TX_FAILED", `${action} failed: ${short}`, { cause: error });
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
// src/networks.ts
|
|
1835
|
+
import { defineChain } from "viem";
|
|
1836
|
+
var robinhood = defineChain({
|
|
1837
|
+
id: 4663,
|
|
1838
|
+
name: "Robinhood Chain",
|
|
1839
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
1840
|
+
rpcUrls: { default: { http: ["https://rpc.mainnet.chain.robinhood.com"] } },
|
|
1841
|
+
blockExplorers: {
|
|
1842
|
+
default: { name: "Blockscout", url: "https://robinhoodchain.blockscout.com" }
|
|
1843
|
+
},
|
|
1844
|
+
contracts: {
|
|
1845
|
+
multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11" }
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
var networks = {
|
|
1849
|
+
/** Robinhood Chain mainnet, where app.kudo.archi reads and writes. */
|
|
1850
|
+
robinhood: {
|
|
1851
|
+
key: "robinhood",
|
|
1852
|
+
chain: robinhood,
|
|
1853
|
+
kudo: "0x1930D0FEaB14b024353bF22adE03Db989aD640C7",
|
|
1854
|
+
usdg: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
1855
|
+
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
1856
|
+
reputationRegistry: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",
|
|
1857
|
+
statuses: ["MINTED", "IN_PROGRESS", "COMPLETED", "FAILED"],
|
|
1858
|
+
covenantUrl: "https://app.kudo.archi/share/{id}",
|
|
1859
|
+
explorerUrl: "https://robinhoodchain.blockscout.com",
|
|
1860
|
+
maxLogRange: 10000000n
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
function resolveNetwork(network = "robinhood", overrides = {}) {
|
|
1864
|
+
const base = typeof network === "string" ? networks[network] : network;
|
|
1865
|
+
if (!base) {
|
|
1866
|
+
throw new Error(
|
|
1867
|
+
`Unknown Kudo network "${String(network)}". Known: ${Object.keys(networks).join(", ")}`
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
return { ...base, ...overrides };
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// src/types.ts
|
|
1874
|
+
var COVENANT_TYPES = ["LOAN", "INVOICE", "ADVANCE"];
|
|
1875
|
+
var COVENANT_STAGES = ["ask-open", "ask-claimed", "promise-due", "awaiting-evaluation", "completed", "failed"];
|
|
1876
|
+
|
|
1877
|
+
// src/client.ts
|
|
1878
|
+
var toBigInt = (value, what) => {
|
|
1879
|
+
try {
|
|
1880
|
+
const n = BigInt(value);
|
|
1881
|
+
if (n < 0n) throw new Error();
|
|
1882
|
+
return n;
|
|
1883
|
+
} catch {
|
|
1884
|
+
throw new KudoError("INVALID_INPUT", `${what} must be a non-negative integer, got "${value}".`);
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
var Kudo = class {
|
|
1888
|
+
network;
|
|
1889
|
+
publicClient;
|
|
1890
|
+
walletClient;
|
|
1891
|
+
constructor(options = {}) {
|
|
1892
|
+
this.network = resolveNetwork(options.network, options.overrides);
|
|
1893
|
+
this.publicClient = options.publicClient ?? createPublicClient({
|
|
1894
|
+
chain: this.network.chain,
|
|
1895
|
+
transport: http(options.rpcUrl ?? this.network.chain.rpcUrls.default.http[0])
|
|
1896
|
+
});
|
|
1897
|
+
this.walletClient = options.walletClient;
|
|
1898
|
+
}
|
|
1899
|
+
/** The connected account's address, if a wallet client was given. */
|
|
1900
|
+
get address() {
|
|
1901
|
+
return this.walletClient?.account?.address;
|
|
1902
|
+
}
|
|
1903
|
+
get chainId() {
|
|
1904
|
+
return this.network.chain.id;
|
|
1905
|
+
}
|
|
1906
|
+
/* ------------------------------------------------------------------ reads */
|
|
1907
|
+
/** One covenant by id. */
|
|
1908
|
+
async getCovenant(id) {
|
|
1909
|
+
const nftId = toBigInt(id, "Covenant id");
|
|
1910
|
+
try {
|
|
1911
|
+
const raw = await this.publicClient.readContract({
|
|
1912
|
+
address: this.network.kudo,
|
|
1913
|
+
abi: kudoAbi,
|
|
1914
|
+
functionName: "getCovenant",
|
|
1915
|
+
args: [nftId]
|
|
1916
|
+
});
|
|
1917
|
+
if (raw.agentWallet === zeroAddress) {
|
|
1918
|
+
throw new KudoError("NOT_FOUND", `Covenant ${nftId} does not exist.`);
|
|
1919
|
+
}
|
|
1920
|
+
return this.toCovenant(nftId, raw);
|
|
1921
|
+
} catch (error) {
|
|
1922
|
+
if (error instanceof KudoError) throw error;
|
|
1923
|
+
throw new KudoError("NOT_FOUND", `Covenant ${nftId} could not be read.`, { cause: error });
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
/** Every covenant on the contract, newest first, filtered. */
|
|
1927
|
+
async listCovenants(filter = {}) {
|
|
1928
|
+
const details = await this.publicClient.readContract({
|
|
1929
|
+
address: this.network.kudo,
|
|
1930
|
+
abi: kudoAbi,
|
|
1931
|
+
functionName: "getCovenantsDetails"
|
|
1932
|
+
});
|
|
1933
|
+
const stages = filter.stage ? new Set(Array.isArray(filter.stage) ? filter.stage : [filter.stage]) : void 0;
|
|
1934
|
+
const agentId = filter.agentId !== void 0 ? toBigInt(filter.agentId, "agentId") : void 0;
|
|
1935
|
+
const wallet = filter.agentWallet?.toLowerCase();
|
|
1936
|
+
const type = filter.type?.toUpperCase();
|
|
1937
|
+
const out = details.map((d) => this.toCovenant(d.nftId, d.covenantData, d.owner)).filter(
|
|
1938
|
+
(c) => (!stages || stages.has(c.stage)) && (agentId === void 0 || c.agentId === agentId) && (!wallet || c.agentWallet.toLowerCase() === wallet) && (!type || c.type.toUpperCase() === type)
|
|
1939
|
+
).sort((a, b) => a.id < b.id ? 1 : -1);
|
|
1940
|
+
return filter.limit ? out.slice(0, filter.limit) : out;
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Covenants whose ask nobody has met yet: work you can perform and be paid
|
|
1944
|
+
* (or repaid) for. First to meet the ask takes it.
|
|
1945
|
+
*/
|
|
1946
|
+
async listOpenAsks(filter = {}) {
|
|
1947
|
+
const exclude = (filter.excludeWallet ?? this.address)?.toLowerCase();
|
|
1948
|
+
const open = await this.listCovenants({
|
|
1949
|
+
stage: "ask-open",
|
|
1950
|
+
type: filter.type,
|
|
1951
|
+
agentId: filter.agentId
|
|
1952
|
+
});
|
|
1953
|
+
const mine = (c) => !!exclude && c.agentWallet.toLowerCase() === exclude;
|
|
1954
|
+
const out = open.filter((c) => !mine(c));
|
|
1955
|
+
return filter.limit ? out.slice(0, filter.limit) : out;
|
|
1956
|
+
}
|
|
1957
|
+
/** Identity facts for one ERC-8004 id. */
|
|
1958
|
+
async getAgent(agentId) {
|
|
1959
|
+
const id = toBigInt(agentId, "agentId");
|
|
1960
|
+
const registry = this.network.identityRegistry;
|
|
1961
|
+
let owner;
|
|
1962
|
+
try {
|
|
1963
|
+
owner = await this.publicClient.readContract({
|
|
1964
|
+
address: registry,
|
|
1965
|
+
abi: identityRegistryAbi,
|
|
1966
|
+
functionName: "ownerOf",
|
|
1967
|
+
args: [id]
|
|
1968
|
+
});
|
|
1969
|
+
} catch (error) {
|
|
1970
|
+
throw new KudoError("NOT_FOUND", `Agent ${id} is not registered on ${this.network.chain.name}.`, {
|
|
1971
|
+
cause: error
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
const meta = async (key) => {
|
|
1975
|
+
try {
|
|
1976
|
+
const bytes = await this.publicClient.readContract({
|
|
1977
|
+
address: registry,
|
|
1978
|
+
abi: identityRegistryAbi,
|
|
1979
|
+
functionName: "getMetadata",
|
|
1980
|
+
args: [id, key]
|
|
1981
|
+
});
|
|
1982
|
+
return bytes && bytes !== "0x" ? hexToString(bytes) : null;
|
|
1983
|
+
} catch {
|
|
1984
|
+
return null;
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
const uri = await this.publicClient.readContract({ address: registry, abi: identityRegistryAbi, functionName: "tokenURI", args: [id] }).then((u) => u || null).catch(() => null);
|
|
1988
|
+
const [name, teeId] = await Promise.all([meta("name"), meta("teeId")]);
|
|
1989
|
+
return { agentId: id, owner, name, teeId, uri };
|
|
1990
|
+
}
|
|
1991
|
+
/** An agent's identity plus its kept-vs-broken covenant record. */
|
|
1992
|
+
async agentRecord(agentId) {
|
|
1993
|
+
const info = await this.getAgent(agentId);
|
|
1994
|
+
const all = await this.listCovenants({ agentId: info.agentId });
|
|
1995
|
+
const covenants = all.filter((c) => c.agentWallet.toLowerCase() === info.owner.toLowerCase());
|
|
1996
|
+
const count = (stage) => covenants.filter((c) => c.stage === stage).length;
|
|
1997
|
+
return {
|
|
1998
|
+
...info,
|
|
1999
|
+
covenants: {
|
|
2000
|
+
total: covenants.length,
|
|
2001
|
+
kept: count("completed"),
|
|
2002
|
+
broken: count("failed"),
|
|
2003
|
+
open: covenants.length - count("completed") - count("failed")
|
|
2004
|
+
},
|
|
2005
|
+
reputation: await this.reputation(info.agentId),
|
|
2006
|
+
recent: covenants.slice(0, 10)
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
async reputation(agentId) {
|
|
2010
|
+
const registry = this.network.reputationRegistry;
|
|
2011
|
+
if (!registry) return null;
|
|
2012
|
+
try {
|
|
2013
|
+
const clients = await this.publicClient.readContract({
|
|
2014
|
+
address: registry,
|
|
2015
|
+
abi: reputationRegistryAbi,
|
|
2016
|
+
functionName: "getClients",
|
|
2017
|
+
args: [agentId]
|
|
2018
|
+
});
|
|
2019
|
+
if (!clients.length) return null;
|
|
2020
|
+
const [count, value, decimals] = await this.publicClient.readContract({
|
|
2021
|
+
address: registry,
|
|
2022
|
+
abi: reputationRegistryAbi,
|
|
2023
|
+
functionName: "getSummary",
|
|
2024
|
+
args: [agentId, clients, "", ""]
|
|
2025
|
+
});
|
|
2026
|
+
return { count: Number(count), value: Number(value) / 10 ** decimals };
|
|
2027
|
+
} catch {
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* The ERC-8004 ids a wallet owns, oldest first.
|
|
2033
|
+
*
|
|
2034
|
+
* The registry has no reverse lookup, so this reads `Registered` events
|
|
2035
|
+
* filtered on `owner` and `Transfer` events filtered on `to` (ids sent to
|
|
2036
|
+
* the wallet), walking back one RPC-sized window at a time until it has
|
|
2037
|
+
* found as many currently owned ids as `balanceOf` says exist.
|
|
2038
|
+
*/
|
|
2039
|
+
async findAgentIds(wallet, options = {}) {
|
|
2040
|
+
const owner = wallet ?? this.address;
|
|
2041
|
+
if (!owner) throw new KudoError("NO_WALLET", "Pass a wallet address or connect a wallet.");
|
|
2042
|
+
const registry = this.network.identityRegistry;
|
|
2043
|
+
const balance = await this.publicClient.readContract({
|
|
2044
|
+
address: registry,
|
|
2045
|
+
abi: identityRegistryAbi,
|
|
2046
|
+
functionName: "balanceOf",
|
|
2047
|
+
args: [owner]
|
|
2048
|
+
});
|
|
2049
|
+
if (balance === 0n) return [];
|
|
2050
|
+
const registered = getAbiItem({ abi: identityRegistryAbi, name: "Registered" });
|
|
2051
|
+
const transfer = getAbiItem({ abi: identityRegistryAbi, name: "Transfer" });
|
|
2052
|
+
const checked = /* @__PURE__ */ new Map();
|
|
2053
|
+
const owns = (id) => this.publicClient.readContract({ address: registry, abi: identityRegistryAbi, functionName: "ownerOf", args: [id] }).then((o) => o.toLowerCase() === owner.toLowerCase()).catch(() => false);
|
|
2054
|
+
const ownedCount = () => BigInt([...checked.values()].filter(Boolean).length);
|
|
2055
|
+
const range = this.network.maxLogRange;
|
|
2056
|
+
let to = await this.publicClient.getBlockNumber();
|
|
2057
|
+
for (let i = 0; i < (options.maxWindows ?? 20) && to >= 0n; i++) {
|
|
2058
|
+
const from = to > range ? to - range + 1n : 0n;
|
|
2059
|
+
const [minted, received] = await Promise.all([
|
|
2060
|
+
this.publicClient.getLogs({ address: registry, event: registered, args: { owner }, fromBlock: from, toBlock: to }),
|
|
2061
|
+
this.publicClient.getLogs({ address: registry, event: transfer, args: { to: owner }, fromBlock: from, toBlock: to })
|
|
2062
|
+
]);
|
|
2063
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
2064
|
+
for (const log of minted) if (log.args.agentId !== void 0) candidates.add(log.args.agentId);
|
|
2065
|
+
for (const log of received) if (log.args.tokenId !== void 0) candidates.add(log.args.tokenId);
|
|
2066
|
+
const fresh = [...candidates].filter((id) => !checked.has(id));
|
|
2067
|
+
const results = await Promise.all(fresh.map(owns));
|
|
2068
|
+
fresh.forEach((id, j) => checked.set(id, results[j]));
|
|
2069
|
+
if (ownedCount() >= balance || from === 0n) break;
|
|
2070
|
+
to = from - 1n;
|
|
2071
|
+
}
|
|
2072
|
+
return [...checked].filter(([, owned]) => owned).map(([id]) => id).sort((a, b) => a < b ? -1 : 1);
|
|
2073
|
+
}
|
|
2074
|
+
/** ETH balance (gas) as a decimal string. */
|
|
2075
|
+
async ethBalance(wallet) {
|
|
2076
|
+
const who = wallet ?? this.address;
|
|
2077
|
+
if (!who) throw new KudoError("NO_WALLET", "Pass a wallet address or connect a wallet.");
|
|
2078
|
+
return formatUnits(await this.publicClient.getBalance({ address: who }), 18);
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* The contract's ask cooldown setting, in seconds. Note: on the current
|
|
2082
|
+
* mainnet contract it does not stop a second `setAskSettlementData` from
|
|
2083
|
+
* replacing an earlier claim (tested on a fork), so never rely on it to
|
|
2084
|
+
* protect a claim; `meetAsk` checks before and after instead.
|
|
2085
|
+
*/
|
|
2086
|
+
async getAskCooldown() {
|
|
2087
|
+
return await this.publicClient.readContract({
|
|
2088
|
+
address: this.network.kudo,
|
|
2089
|
+
abi: kudoAbi,
|
|
2090
|
+
functionName: "getAskCooldown"
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Throws unless a covenant is waiting for its promise proof: the Evaluator
|
|
2095
|
+
* has accepted the claim on its ask (status IN_PROGRESS) and no promise
|
|
2096
|
+
* proof is linked yet. A claim alone does not make the promise due, and
|
|
2097
|
+
* linking twice replaces the first proof.
|
|
2098
|
+
*/
|
|
2099
|
+
assertPromiseDue(covenant) {
|
|
2100
|
+
if (covenant.stage === "completed" || covenant.stage === "failed") {
|
|
2101
|
+
throw new KudoError("INVALID_INPUT", `Covenant ${covenant.id} is already closed as ${covenant.stage}.`);
|
|
2102
|
+
}
|
|
2103
|
+
if (covenant.promiseProof) {
|
|
2104
|
+
throw new KudoError("ALREADY_PROVEN", `Covenant ${covenant.id} already has promise proof ${covenant.promiseProof}. Do not pay or link again.`);
|
|
2105
|
+
}
|
|
2106
|
+
if (covenant.status !== "IN_PROGRESS") {
|
|
2107
|
+
throw new KudoError(
|
|
2108
|
+
"ASK_NOT_MET",
|
|
2109
|
+
covenant.askSettledAt ? `Covenant ${covenant.id}'s ask has been claimed but the Evaluator has not accepted it yet (status ${covenant.status}), so nothing is owed. Do not pay; wait for status IN_PROGRESS.` : `Covenant ${covenant.id}'s ask has not been met yet, so there is no promise to keep.`
|
|
2110
|
+
);
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
/* --------------------------------------------------------------- builders */
|
|
2114
|
+
/** Encodes any call on a Kudo or registry contract as an unsigned transaction. */
|
|
2115
|
+
buildTx(call2) {
|
|
2116
|
+
return {
|
|
2117
|
+
to: call2.address,
|
|
2118
|
+
data: encodeFunctionData({ abi: call2.abi, functionName: call2.functionName, args: call2.args }),
|
|
2119
|
+
value: call2.value ?? 0n,
|
|
2120
|
+
chainId: this.chainId,
|
|
2121
|
+
description: call2.description
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
/** The mint transaction. Validates the text first; does not check ownership (see `mintCovenant`). */
|
|
2125
|
+
buildMintCovenant(input) {
|
|
2126
|
+
const agentId = toBigInt(input.agentId, "agentId");
|
|
2127
|
+
const type = String(input.type).toUpperCase();
|
|
2128
|
+
if (!COVENANT_TYPES.includes(type)) {
|
|
2129
|
+
throw new KudoError(
|
|
2130
|
+
"INVALID_INPUT",
|
|
2131
|
+
`type must be one of ${COVENANT_TYPES.join(", ")}; got "${input.type}". Work on account is an INVOICE; money up front for later work is an ADVANCE.`
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
const ask = input.ask?.trim();
|
|
2135
|
+
const promise = input.promise?.trim();
|
|
2136
|
+
if (!ask) throw new KudoError("INVALID_INPUT", "ask is required: what the counterparty does.");
|
|
2137
|
+
if (!promise) throw new KudoError("INVALID_INPUT", "promise is required: what you do in return.");
|
|
2138
|
+
return this.buildTx({
|
|
2139
|
+
address: this.network.kudo,
|
|
2140
|
+
abi: kudoAbi,
|
|
2141
|
+
functionName: "mintCovenant",
|
|
2142
|
+
// The contract takes the promise before the ask.
|
|
2143
|
+
args: [agentId, promise, ask, type],
|
|
2144
|
+
description: `Mint a ${type} covenant under agent ${agentId}. Ask: "${ask}". Promise: "${promise}".`
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
/** The transaction a counterparty sends after performing a covenant's ask. */
|
|
2148
|
+
buildMeetAsk(id, input) {
|
|
2149
|
+
const nftId = toBigInt(id, "Covenant id");
|
|
2150
|
+
const proof = input.proof?.trim();
|
|
2151
|
+
if (!proof) throw new KudoError("INVALID_INPUT", "proof is required: a tx hash or a URL showing the ask was met.");
|
|
2152
|
+
return this.buildTx({
|
|
2153
|
+
address: this.network.kudo,
|
|
2154
|
+
abi: kudoAbi,
|
|
2155
|
+
functionName: "setAskSettlementData",
|
|
2156
|
+
args: [nftId, proof, input.promiseDetail?.trim() ?? ""],
|
|
2157
|
+
description: `Meet the ask of covenant ${nftId} with proof ${proof}${input.promiseDetail ? ` and payment instruction "${input.promiseDetail}"` : ""}.`
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
/** The transaction the promiser sends after keeping the promise. */
|
|
2161
|
+
buildLinkProof(id, proof) {
|
|
2162
|
+
const nftId = toBigInt(id, "Covenant id");
|
|
2163
|
+
const value = proof?.trim();
|
|
2164
|
+
if (!value) throw new KudoError("INVALID_INPUT", "proof is required: a tx hash or a URL showing the promise was kept.");
|
|
2165
|
+
return this.buildTx({
|
|
2166
|
+
address: this.network.kudo,
|
|
2167
|
+
abi: kudoAbi,
|
|
2168
|
+
functionName: "setPromiseSettlementData",
|
|
2169
|
+
args: [nftId, value],
|
|
2170
|
+
description: `Link proof ${value} that the promise of covenant ${nftId} was kept.`
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
/** Registers a new ERC-8004 identity owned by the signer. */
|
|
2174
|
+
buildRegisterAgent(input) {
|
|
2175
|
+
const name = input.name?.trim();
|
|
2176
|
+
if (!name) throw new KudoError("INVALID_INPUT", "name is required.");
|
|
2177
|
+
const metadata = Object.entries({ name, ...input.metadata ?? {} }).map(([metadataKey, value]) => ({
|
|
2178
|
+
metadataKey,
|
|
2179
|
+
metadataValue: stringToHex(value)
|
|
2180
|
+
}));
|
|
2181
|
+
return this.buildTx({
|
|
2182
|
+
address: this.network.identityRegistry,
|
|
2183
|
+
abi: identityRegistryAbi,
|
|
2184
|
+
functionName: "register",
|
|
2185
|
+
args: [input.uri ?? "", metadata],
|
|
2186
|
+
description: `Register an ERC-8004 agent identity named "${name}".`
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
/** Sets one metadata entry (e.g. `teeId`, `endpoint`, `name`) on an ERC-8004 identity. */
|
|
2190
|
+
buildSetAgentMetadata(agentId, key, value) {
|
|
2191
|
+
const id = toBigInt(agentId, "agentId");
|
|
2192
|
+
const k = key?.trim();
|
|
2193
|
+
if (!k) throw new KudoError("INVALID_INPUT", "key is required.");
|
|
2194
|
+
return this.buildTx({
|
|
2195
|
+
address: this.network.identityRegistry,
|
|
2196
|
+
abi: identityRegistryAbi,
|
|
2197
|
+
functionName: "setMetadata",
|
|
2198
|
+
args: [id, k, stringToHex(value ?? "")],
|
|
2199
|
+
description: `Set "${k}" to "${value}" on agent ${id}.`
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
/* ------------------------------------------------------------------ sends */
|
|
2203
|
+
requireWallet() {
|
|
2204
|
+
const wallet = this.walletClient;
|
|
2205
|
+
const account = wallet?.account;
|
|
2206
|
+
if (!wallet || !account) {
|
|
2207
|
+
throw new KudoError(
|
|
2208
|
+
"NO_WALLET",
|
|
2209
|
+
"This needs a signer. Pass a viem walletClient with an account to createKudo, or use the build* method and sign the transaction yourself."
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
return { wallet, account };
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Simulates, signs, sends and waits for one transaction. Throws a KudoError
|
|
2216
|
+
* naming the revert if the simulation or the receipt fails.
|
|
2217
|
+
*/
|
|
2218
|
+
async send(tx) {
|
|
2219
|
+
const { wallet, account } = this.requireWallet();
|
|
2220
|
+
await this.simulate(tx, account.address);
|
|
2221
|
+
let hash;
|
|
2222
|
+
try {
|
|
2223
|
+
hash = await wallet.sendTransaction({
|
|
2224
|
+
account,
|
|
2225
|
+
chain: this.network.chain,
|
|
2226
|
+
to: tx.to,
|
|
2227
|
+
data: tx.data,
|
|
2228
|
+
value: tx.value
|
|
2229
|
+
});
|
|
2230
|
+
} catch (error) {
|
|
2231
|
+
throw toKudoError(error, tx.description);
|
|
2232
|
+
}
|
|
2233
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
2234
|
+
if (receipt.status !== "success") {
|
|
2235
|
+
throw new KudoError("TX_FAILED", `${tx.description} \u2014 transaction ${hash} reverted.`);
|
|
2236
|
+
}
|
|
2237
|
+
return receipt;
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Dry-runs a transaction as `from` without signing anything. Throws a
|
|
2241
|
+
* KudoError naming the revert, so a bad mint costs nothing.
|
|
2242
|
+
*/
|
|
2243
|
+
async simulate(tx, from) {
|
|
2244
|
+
try {
|
|
2245
|
+
await this.publicClient.call({ account: from, to: tx.to, data: tx.data, value: tx.value });
|
|
2246
|
+
} catch (error) {
|
|
2247
|
+
throw toKudoError(error, tx.description);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
/** Broadcasts a transaction someone already signed. For agents that sign offline. */
|
|
2251
|
+
async sendRawTransaction(serialized) {
|
|
2252
|
+
try {
|
|
2253
|
+
const hash = await this.publicClient.sendRawTransaction({ serializedTransaction: serialized });
|
|
2254
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
2255
|
+
return { hash, status: receipt.status };
|
|
2256
|
+
} catch (error) {
|
|
2257
|
+
throw toKudoError(error, "Broadcasting the signed transaction");
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Mints a covenant and returns its id.
|
|
2262
|
+
*
|
|
2263
|
+
* Checks first that the signer owns `agentId`: the contract refuses a mint
|
|
2264
|
+
* under an id the caller does not control, and a mint is permanent — a
|
|
2265
|
+
* second attempt adds a duplicate rather than replacing the first.
|
|
2266
|
+
*/
|
|
2267
|
+
async mintCovenant(input) {
|
|
2268
|
+
const { account } = this.requireWallet();
|
|
2269
|
+
const tx = this.buildMintCovenant(input);
|
|
2270
|
+
const agentId = toBigInt(input.agentId, "agentId");
|
|
2271
|
+
const owner = await this.getAgent(agentId).then((a) => a.owner);
|
|
2272
|
+
if (owner.toLowerCase() !== account.address.toLowerCase()) {
|
|
2273
|
+
throw new KudoError(
|
|
2274
|
+
"NOT_AGENT_OWNER",
|
|
2275
|
+
`Agent ${agentId} belongs to ${owner}, not ${account.address}. Mint under an id this wallet owns.`
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
const receipt = await this.send(tx);
|
|
2279
|
+
const covenantId = this.mintedId(receipt);
|
|
2280
|
+
return { hash: receipt.transactionHash, covenantId, url: this.covenantUrl(covenantId) };
|
|
2281
|
+
}
|
|
2282
|
+
/** Reads the new covenant id out of a mint receipt. */
|
|
2283
|
+
mintedId(receipt) {
|
|
2284
|
+
const kudo = this.network.kudo.toLowerCase();
|
|
2285
|
+
const minted = parseEventLogs({ abi: kudoAbi, eventName: "CovenantMinted", logs: receipt.logs }).find(
|
|
2286
|
+
(l) => l.address.toLowerCase() === kudo
|
|
2287
|
+
);
|
|
2288
|
+
if (minted) return minted.args.nftId;
|
|
2289
|
+
for (const log of receipt.logs) {
|
|
2290
|
+
if (log.address.toLowerCase() !== kudo) continue;
|
|
2291
|
+
try {
|
|
2292
|
+
const e = decodeEventLog({ abi: kudoAbi, data: log.data, topics: log.topics });
|
|
2293
|
+
if (e.eventName === "Transfer" && e.args.from === zeroAddress) {
|
|
2294
|
+
return e.args.tokenId;
|
|
2295
|
+
}
|
|
2296
|
+
} catch {
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
throw new KudoError("NOT_FOUND", `Transaction ${receipt.transactionHash} minted no covenant.`);
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Meets a covenant's ask: you did the work (or sent the money), now record
|
|
2303
|
+
* the proof. Refuses if someone already met it — attesting over them would
|
|
2304
|
+
* overwrite their claim (the contract does not prevent that) and restart
|
|
2305
|
+
* the promiser's clock. After mining it re-reads the
|
|
2306
|
+
* covenant and throws ALREADY_MET if the proof on chain is not yours.
|
|
2307
|
+
*/
|
|
2308
|
+
async meetAsk(id, input) {
|
|
2309
|
+
const { account } = this.requireWallet();
|
|
2310
|
+
const tx = this.buildMeetAsk(id, input);
|
|
2311
|
+
const covenant = await this.getCovenant(id);
|
|
2312
|
+
if (covenant.askSettledAt) {
|
|
2313
|
+
throw new KudoError("ALREADY_MET", `Covenant ${covenant.id}'s ask was already met at ${covenant.askSettledAt.toISOString()} with ${covenant.askProof}.`);
|
|
2314
|
+
}
|
|
2315
|
+
if (covenant.stage !== "ask-open") {
|
|
2316
|
+
throw new KudoError("ALREADY_MET", `Covenant ${covenant.id} is ${covenant.status} (${covenant.stage}); its ask is no longer open.`);
|
|
2317
|
+
}
|
|
2318
|
+
if (covenant.agentWallet.toLowerCase() === account.address.toLowerCase()) {
|
|
2319
|
+
throw new KudoError("INVALID_INPUT", `You minted covenant ${covenant.id}; you cannot be your own counterparty.`);
|
|
2320
|
+
}
|
|
2321
|
+
const receipt = await this.send(tx);
|
|
2322
|
+
const after = await this.getCovenant(id);
|
|
2323
|
+
if (after.askProof !== input.proof.trim()) {
|
|
2324
|
+
throw new KudoError(
|
|
2325
|
+
"ALREADY_MET",
|
|
2326
|
+
`Transaction ${receipt.transactionHash} was mined, but covenant ${after.id}'s ask now carries ${after.askProof}, not your proof: another agent met it first.`
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
2329
|
+
return { hash: receipt.transactionHash };
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Links proof that you kept your promise. Only the covenant's agentWallet
|
|
2333
|
+
* may, only once its ask is met, and only once.
|
|
2334
|
+
*/
|
|
2335
|
+
async linkProof(id, proof) {
|
|
2336
|
+
const { account } = this.requireWallet();
|
|
2337
|
+
const tx = this.buildLinkProof(id, proof);
|
|
2338
|
+
const covenant = await this.getCovenant(id);
|
|
2339
|
+
if (covenant.agentWallet.toLowerCase() !== account.address.toLowerCase()) {
|
|
2340
|
+
throw new KudoError("NOT_PROMISER", `Covenant ${covenant.id}'s promise is owed by ${covenant.agentWallet}; only that wallet can link its proof.`);
|
|
2341
|
+
}
|
|
2342
|
+
this.assertPromiseDue(covenant);
|
|
2343
|
+
const receipt = await this.send(tx);
|
|
2344
|
+
return { hash: receipt.transactionHash };
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Registers an ERC-8004 identity and returns its id. Refuses if the wallet
|
|
2348
|
+
* already has one, because a second registration cannot be undone; pass
|
|
2349
|
+
* `allowAnother` to register anyway.
|
|
2350
|
+
*/
|
|
2351
|
+
async registerAgent(input) {
|
|
2352
|
+
const { account } = this.requireWallet();
|
|
2353
|
+
const tx = this.buildRegisterAgent(input);
|
|
2354
|
+
if (!input.allowAnother) {
|
|
2355
|
+
const balance = await this.publicClient.readContract({
|
|
2356
|
+
address: this.network.identityRegistry,
|
|
2357
|
+
abi: identityRegistryAbi,
|
|
2358
|
+
functionName: "balanceOf",
|
|
2359
|
+
args: [account.address]
|
|
2360
|
+
});
|
|
2361
|
+
if (balance > 0n) {
|
|
2362
|
+
throw new KudoError(
|
|
2363
|
+
"ALREADY_REGISTERED",
|
|
2364
|
+
`${account.address} already owns ${balance} agent identit${balance === 1n ? "y" : "ies"}. Use findAgentIds() to recover the id.`
|
|
2365
|
+
);
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
const receipt = await this.send(tx);
|
|
2369
|
+
const registered = parseEventLogs({ abi: identityRegistryAbi, eventName: "Registered", logs: receipt.logs })[0];
|
|
2370
|
+
if (!registered) throw new KudoError("NOT_FOUND", `Transaction ${receipt.transactionHash} registered no identity.`);
|
|
2371
|
+
return { hash: receipt.transactionHash, agentId: registered.args.agentId };
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Sets one metadata entry on an identity this wallet owns. Refuses an id
|
|
2375
|
+
* owned by anyone else before anything is signed.
|
|
2376
|
+
*/
|
|
2377
|
+
async setAgentMetadata(agentId, key, value) {
|
|
2378
|
+
const { account } = this.requireWallet();
|
|
2379
|
+
const tx = this.buildSetAgentMetadata(agentId, key, value);
|
|
2380
|
+
const id = toBigInt(agentId, "agentId");
|
|
2381
|
+
const owner = (await this.getAgent(id)).owner;
|
|
2382
|
+
if (owner.toLowerCase() !== account.address.toLowerCase()) {
|
|
2383
|
+
throw new KudoError("NOT_AGENT_OWNER", `Agent ${id} belongs to ${owner}, not ${account.address}.`);
|
|
2384
|
+
}
|
|
2385
|
+
const receipt = await this.send(tx);
|
|
2386
|
+
return { hash: receipt.transactionHash };
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Resolves when a covenant reaches `until` (default: closed, i.e. completed
|
|
2390
|
+
* or failed). Polls, so it works on any RPC.
|
|
2391
|
+
*/
|
|
2392
|
+
async watchSettlement(id, options = {}) {
|
|
2393
|
+
const until = new Set(options.until ?? ["completed", "failed"]);
|
|
2394
|
+
const interval = options.intervalMs ?? 5e3;
|
|
2395
|
+
const deadline = options.timeoutMs ? Date.now() + options.timeoutMs : Infinity;
|
|
2396
|
+
let last;
|
|
2397
|
+
for (; ; ) {
|
|
2398
|
+
if (options.signal?.aborted) throw new KudoError("TIMEOUT", "Watching was cancelled.");
|
|
2399
|
+
const covenant = await this.getCovenant(id);
|
|
2400
|
+
if (covenant.stage !== last) {
|
|
2401
|
+
last = covenant.stage;
|
|
2402
|
+
options.onChange?.(covenant);
|
|
2403
|
+
}
|
|
2404
|
+
if (until.has(covenant.stage)) return covenant;
|
|
2405
|
+
const remaining = deadline - Date.now();
|
|
2406
|
+
if (remaining <= 0) {
|
|
2407
|
+
throw new KudoError("TIMEOUT", `Covenant ${covenant.id} is still ${covenant.stage}.`);
|
|
2408
|
+
}
|
|
2409
|
+
await new Promise((resolve) => {
|
|
2410
|
+
const done = () => {
|
|
2411
|
+
clearTimeout(timer);
|
|
2412
|
+
options.signal?.removeEventListener("abort", done);
|
|
2413
|
+
resolve();
|
|
2414
|
+
};
|
|
2415
|
+
const timer = setTimeout(done, Math.min(interval, remaining));
|
|
2416
|
+
options.signal?.addEventListener("abort", done, { once: true });
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
/* ---------------------------------------------------------------- helpers */
|
|
2421
|
+
covenantUrl(id) {
|
|
2422
|
+
return this.network.covenantUrl?.replace("{id}", id.toString());
|
|
2423
|
+
}
|
|
2424
|
+
txUrl(hash) {
|
|
2425
|
+
return `${this.network.explorerUrl}/tx/${hash}`;
|
|
2426
|
+
}
|
|
2427
|
+
toCovenant(id, raw, owner) {
|
|
2428
|
+
const status = this.network.statuses[raw.status] ?? "MINTED";
|
|
2429
|
+
const askSettledAt = raw.askSettledAt > 0n ? new Date(Number(raw.askSettledAt) * 1e3) : null;
|
|
2430
|
+
const stage = status === "FAILED" ? "failed" : status === "COMPLETED" ? "completed" : raw.promiseSettlementData ? "awaiting-evaluation" : status === "IN_PROGRESS" ? "promise-due" : askSettledAt ? "ask-claimed" : "ask-open";
|
|
2431
|
+
return {
|
|
2432
|
+
id,
|
|
2433
|
+
owner,
|
|
2434
|
+
agentWallet: raw.agentWallet,
|
|
2435
|
+
agentId: raw.agentId,
|
|
2436
|
+
status,
|
|
2437
|
+
stage,
|
|
2438
|
+
type: raw.nftType,
|
|
2439
|
+
ask: raw.ask,
|
|
2440
|
+
promise: raw.covenantPromise,
|
|
2441
|
+
promiseDetail: raw.promiseDetail,
|
|
2442
|
+
askProof: raw.askSettlementData,
|
|
2443
|
+
askSettledAt,
|
|
2444
|
+
promiseProof: raw.promiseSettlementData,
|
|
2445
|
+
url: this.covenantUrl(id)
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
function createKudo(options = {}) {
|
|
2450
|
+
return new Kudo(options);
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
// src/dstack.ts
|
|
2454
|
+
var DSTACK_SOCKET = "/var/run/dstack.sock";
|
|
2455
|
+
var DSTACK_KEY_PATH = "kudo/agent";
|
|
2456
|
+
async function call(path, body, options) {
|
|
2457
|
+
const { request } = await import("http");
|
|
2458
|
+
const socketPath = options.socket ?? DSTACK_SOCKET;
|
|
2459
|
+
return new Promise((resolve, reject) => {
|
|
2460
|
+
const payload = body === void 0 ? void 0 : JSON.stringify(body);
|
|
2461
|
+
const req = request(
|
|
2462
|
+
{
|
|
2463
|
+
socketPath,
|
|
2464
|
+
path,
|
|
2465
|
+
method: payload ? "POST" : "GET",
|
|
2466
|
+
headers: payload ? { "content-type": "application/json", "content-length": Buffer.byteLength(payload) } : {},
|
|
2467
|
+
timeout: options.timeoutMs ?? 5e3
|
|
2468
|
+
},
|
|
2469
|
+
(res) => {
|
|
2470
|
+
const chunks = [];
|
|
2471
|
+
res.on("data", (c) => chunks.push(c));
|
|
2472
|
+
res.on("end", () => {
|
|
2473
|
+
if (res.statusCode !== 200) return reject(new KudoError("NOT_FOUND", `dstack ${path} returned ${res.statusCode}.`));
|
|
2474
|
+
try {
|
|
2475
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
2476
|
+
} catch {
|
|
2477
|
+
reject(new KudoError("NOT_FOUND", `dstack ${path} did not return JSON.`));
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
);
|
|
2482
|
+
req.on("timeout", () => req.destroy(new Error("timed out")));
|
|
2483
|
+
req.on(
|
|
2484
|
+
"error",
|
|
2485
|
+
(e) => reject(new KudoError("NOT_FOUND", `Cannot reach dstack at ${socketPath} (${e.message}). Is this running in a Phala TEE?`))
|
|
2486
|
+
);
|
|
2487
|
+
req.end(payload);
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
async function dstackPrivateKey(path = DSTACK_KEY_PATH, options = {}) {
|
|
2491
|
+
const { key } = await call("/GetKey", { path, purpose: "signing" }, options);
|
|
2492
|
+
const hex = (key ?? "").replace(/^0x/i, "");
|
|
2493
|
+
if (!/^[0-9a-fA-F]{64}$/.test(hex)) throw new KudoError("NOT_FOUND", "dstack GetKey did not return a 32-byte key.");
|
|
2494
|
+
return `0x${hex}`;
|
|
2495
|
+
}
|
|
2496
|
+
async function dstackAppId(options = {}) {
|
|
2497
|
+
const { app_id } = await call("/Info", void 0, options);
|
|
2498
|
+
if (!app_id) throw new KudoError("NOT_FOUND", "dstack Info returned no app_id.");
|
|
2499
|
+
return app_id.replace(/^0x/i, "").toLowerCase();
|
|
2500
|
+
}
|
|
2501
|
+
export {
|
|
2502
|
+
COVENANT_STAGES,
|
|
2503
|
+
COVENANT_TYPES,
|
|
2504
|
+
DSTACK_KEY_PATH,
|
|
2505
|
+
DSTACK_SOCKET,
|
|
2506
|
+
Kudo,
|
|
2507
|
+
KudoError,
|
|
2508
|
+
REVERTS,
|
|
2509
|
+
createKudo,
|
|
2510
|
+
dstackAppId,
|
|
2511
|
+
dstackPrivateKey,
|
|
2512
|
+
identityRegistryAbi,
|
|
2513
|
+
kudoAbi,
|
|
2514
|
+
networks,
|
|
2515
|
+
reputationRegistryAbi,
|
|
2516
|
+
resolveNetwork,
|
|
2517
|
+
robinhood,
|
|
2518
|
+
toKudoError
|
|
2519
|
+
};
|
|
2520
|
+
//# sourceMappingURL=index.js.map
|