@moonbeam-foundation/sdk 0.5.3 → 0.7.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/README.md +122 -22
- package/dist/abi/index.d.ts +55 -0
- package/dist/abi/index.d.ts.map +1 -0
- package/dist/abi/index.js +227 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/acp/events.d.ts +38 -38
- package/dist/acp/events.d.ts.map +1 -1
- package/dist/acp/events.js.map +1 -1
- package/dist/acp/moonbeam-acp.generated.d.ts +50 -0
- package/dist/acp/moonbeam-acp.generated.d.ts.map +1 -0
- package/dist/acp/moonbeam-acp.generated.js +56 -0
- package/dist/acp/moonbeam-acp.generated.js.map +1 -0
- package/dist/acp/pipeline.js.map +1 -1
- package/dist/acp/registry.d.ts.map +1 -1
- package/dist/acp/registry.js +5 -3
- package/dist/acp/registry.js.map +1 -1
- package/dist/actors/track-record.js.map +1 -1
- package/dist/adapters/acp.js.map +1 -1
- package/dist/adapters/stamp.d.ts +1 -1
- package/dist/adapters/stamp.d.ts.map +1 -1
- package/dist/arbitration/index.d.ts +120 -0
- package/dist/arbitration/index.d.ts.map +1 -0
- package/dist/arbitration/index.js +116 -0
- package/dist/arbitration/index.js.map +1 -0
- package/dist/assurance/assurance-shared.d.ts +1924 -0
- package/dist/assurance/assurance-shared.d.ts.map +1 -0
- package/dist/assurance/assurance-shared.js +2225 -0
- package/dist/assurance/assurance-shared.js.map +1 -0
- package/dist/assurance/index.d.ts +57 -0
- package/dist/assurance/index.d.ts.map +1 -0
- package/dist/assurance/index.js +49 -0
- package/dist/assurance/index.js.map +1 -0
- package/dist/attest/index.d.ts +19 -0
- package/dist/attest/index.d.ts.map +1 -0
- package/dist/attest/index.js +17 -0
- package/dist/attest/index.js.map +1 -0
- package/dist/client/index.d.ts +16 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +21 -1
- package/dist/client/index.js.map +1 -1
- package/dist/connect/logs.js.map +1 -1
- package/dist/core/money.js.map +1 -1
- package/dist/core/settle.js.map +1 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/erc8004/index.d.ts +9 -9
- package/dist/erc8004/index.d.ts.map +1 -1
- package/dist/erc8004/index.js.map +1 -1
- package/dist/erc8183/index.d.ts +12 -12
- package/dist/erc8183/index.d.ts.map +1 -1
- package/dist/erc8183/index.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/judge/index.d.ts +35 -3
- package/dist/judge/index.d.ts.map +1 -1
- package/dist/judge/index.js +41 -2
- package/dist/judge/index.js.map +1 -1
- package/dist/launcher/index.d.ts +3 -3
- package/dist/launcher/index.d.ts.map +1 -1
- package/dist/onboard/index.d.ts +64 -24
- package/dist/onboard/index.d.ts.map +1 -1
- package/dist/onboard/index.js +90 -15
- package/dist/onboard/index.js.map +1 -1
- package/dist/pools/index.d.ts +49 -7
- package/dist/pools/index.d.ts.map +1 -1
- package/dist/pools/index.js +30 -6
- package/dist/pools/index.js.map +1 -1
- package/dist/proof/index.d.ts +117 -0
- package/dist/proof/index.d.ts.map +1 -0
- package/dist/proof/index.js +81 -0
- package/dist/proof/index.js.map +1 -0
- package/dist/resale/index.d.ts +120 -0
- package/dist/resale/index.d.ts.map +1 -0
- package/dist/resale/index.js +117 -0
- package/dist/resale/index.js.map +1 -0
- package/dist/resale/payment-scheme.d.mts +46 -0
- package/dist/resale/payment-scheme.mjs +351 -0
- package/dist/resale/payment-scheme.pin.json +6 -0
- package/dist/rpc/index.d.ts +24 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +66 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/x402/index.d.ts +90 -0
- package/dist/x402/index.d.ts.map +1 -0
- package/dist/x402/index.js +75 -0
- package/dist/x402/index.js.map +1 -0
- package/examples/03-end-to-end-offline.mjs +2 -2
- package/examples/14-grade-record.mjs +6 -4
- package/examples/17-grade-live.mjs +1 -1
- package/examples/20-onboard-client.mjs +2 -2
- package/examples/24-resell-on-base.mjs +17 -0
- package/examples/{30-read-a-real-job.mjs → 30-read-a-job.mjs} +2 -2
- package/examples/32-read-live-from-base.mjs +8 -11
- package/examples/40-the-article.mjs +1 -1
- package/examples/50-x402-pay-a-wall.mjs +17 -0
- package/examples/51-read-a-proof.mjs +21 -0
- package/examples/52-arbitration-calls.mjs +13 -0
- package/examples/53-attested-by-default.mjs +19 -0
- package/examples/README.md +13 -6
- package/examples/data/proof-base-tx-52587000.json +116 -0
- package/package.json +51 -10
- package/skills/moonbeam-actor-backer/SKILL.md +1 -1
- package/skills/moonbeam-actor-challenger/SKILL.md +1 -1
- package/skills/moonbeam-actor-doubter/SKILL.md +1 -1
- package/skills/moonbeam-assurance/SKILL.md +1 -1
|
@@ -0,0 +1,2225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @taifoon/assurance: the assurance product's core. _ASSURANCE_CORE_v1_
|
|
3
|
+
*
|
|
4
|
+
* ONE file with NO imports, pure and browser-safe, so a project that cannot install this package (the site, the SDKs)
|
|
5
|
+
* carries a byte-identical copy and pins its hash (scripts/sync.mjs). What is in it:
|
|
6
|
+
*
|
|
7
|
+
* machine the coordination state machine, generated from schemas/transitions.json: every state, every transition
|
|
8
|
+
* with its trigger and actor per lane, every timeout, ending and exclusion, the source vocabularies, the money
|
|
9
|
+
* effects, the external-cover policy machine, and the revenue hooks of schemas/phase-map.json.
|
|
10
|
+
* next next(state, event, ctx): one step of a job, from a named transition, a source event or the clock.
|
|
11
|
+
* endings endingOf(job): how a job ended, the verdict it writes into the seller's record, and what external cover
|
|
12
|
+
* does with it; whoCanEnd(state): who may end each held state, and when.
|
|
13
|
+
* the job the venue-neutral assured job: price, deposit, cover, evaluator, deadlines, terms.
|
|
14
|
+
* flows quote, buy, settle, claim, composed from an Economy the caller passes in (jev-wilson's economy); this file
|
|
15
|
+
* computes no premium, leg or compensation itself: it picks, checks and refuses.
|
|
16
|
+
*
|
|
17
|
+
* Nothing here reads a network, signs or holds a key. Amounts are bigint smallest units.
|
|
18
|
+
*/
|
|
19
|
+
// ── GENERATED from schemas/transitions.json and schemas/phase-map.json by scripts/gen.mjs: do not edit ──
|
|
20
|
+
export const MACHINE = {
|
|
21
|
+
"version": "coordination.transitions.v1",
|
|
22
|
+
"initial": "Open",
|
|
23
|
+
"lanes": [
|
|
24
|
+
"handshake",
|
|
25
|
+
"hook",
|
|
26
|
+
"erc8183",
|
|
27
|
+
"erc8183-extra",
|
|
28
|
+
"memo-acp"
|
|
29
|
+
],
|
|
30
|
+
"continues": {
|
|
31
|
+
"handshake": "hook"
|
|
32
|
+
},
|
|
33
|
+
"observedLanes": [
|
|
34
|
+
"olas-mech",
|
|
35
|
+
"grid"
|
|
36
|
+
],
|
|
37
|
+
"states": [
|
|
38
|
+
{
|
|
39
|
+
"id": "Open",
|
|
40
|
+
"terminal": false,
|
|
41
|
+
"holdsFunds": false,
|
|
42
|
+
"timeout": null
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "Delivered",
|
|
46
|
+
"terminal": false,
|
|
47
|
+
"holdsFunds": false,
|
|
48
|
+
"timeout": null
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "Created",
|
|
52
|
+
"terminal": false,
|
|
53
|
+
"holdsFunds": false,
|
|
54
|
+
"timeout": {
|
|
55
|
+
"after": "expiredAt",
|
|
56
|
+
"to": "Cancelled"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "Funded",
|
|
61
|
+
"terminal": false,
|
|
62
|
+
"holdsFunds": true,
|
|
63
|
+
"timeout": {
|
|
64
|
+
"after": "expiredAt | hook deadline",
|
|
65
|
+
"to": "Expired"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "Submitted",
|
|
70
|
+
"terminal": false,
|
|
71
|
+
"holdsFunds": true,
|
|
72
|
+
"timeout": {
|
|
73
|
+
"after": "expiredAt | hook deadline",
|
|
74
|
+
"to": "Expired"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "Graded",
|
|
79
|
+
"terminal": false,
|
|
80
|
+
"holdsFunds": true,
|
|
81
|
+
"timeout": {
|
|
82
|
+
"after": "hook deadline",
|
|
83
|
+
"to": "Expired"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "Held",
|
|
88
|
+
"terminal": false,
|
|
89
|
+
"holdsFunds": true,
|
|
90
|
+
"timeout": {
|
|
91
|
+
"after": "hook deadline",
|
|
92
|
+
"to": "Expired"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "Opened",
|
|
97
|
+
"terminal": false,
|
|
98
|
+
"holdsFunds": true,
|
|
99
|
+
"timeout": {
|
|
100
|
+
"after": "hook deadline",
|
|
101
|
+
"to": "Expired"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "RejectPending",
|
|
106
|
+
"terminal": false,
|
|
107
|
+
"holdsFunds": true,
|
|
108
|
+
"timeout": {
|
|
109
|
+
"after": "disputeDeadline (RejectProposed field)",
|
|
110
|
+
"to": "Rejected"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "Disputed",
|
|
115
|
+
"terminal": false,
|
|
116
|
+
"holdsFunds": true,
|
|
117
|
+
"timeout": {
|
|
118
|
+
"after": "arbitrationDeadline (DisputeOpened field)",
|
|
119
|
+
"to": "Rejected"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "Settled",
|
|
124
|
+
"terminal": true,
|
|
125
|
+
"holdsFunds": false,
|
|
126
|
+
"timeout": null
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "Rejected",
|
|
130
|
+
"terminal": true,
|
|
131
|
+
"holdsFunds": false,
|
|
132
|
+
"timeout": null
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "Expired",
|
|
136
|
+
"terminal": true,
|
|
137
|
+
"holdsFunds": false,
|
|
138
|
+
"timeout": null
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": "Cheat",
|
|
142
|
+
"terminal": true,
|
|
143
|
+
"holdsFunds": false,
|
|
144
|
+
"timeout": null
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"id": "Cancelled",
|
|
148
|
+
"terminal": true,
|
|
149
|
+
"holdsFunds": false,
|
|
150
|
+
"timeout": null
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"transitions": [
|
|
154
|
+
{
|
|
155
|
+
"id": "dispatch_no_work",
|
|
156
|
+
"from": "Open",
|
|
157
|
+
"to": "Open",
|
|
158
|
+
"timeout": null,
|
|
159
|
+
"hook": null,
|
|
160
|
+
"by": {
|
|
161
|
+
"handshake": {
|
|
162
|
+
"type": "offchain",
|
|
163
|
+
"name": "dispatch answered without work",
|
|
164
|
+
"actor": "layer"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "dispatch_delivered",
|
|
170
|
+
"from": "Open",
|
|
171
|
+
"to": "Delivered",
|
|
172
|
+
"timeout": null,
|
|
173
|
+
"hook": null,
|
|
174
|
+
"by": {
|
|
175
|
+
"handshake": {
|
|
176
|
+
"type": "offchain",
|
|
177
|
+
"name": "reply held with its keccak digest",
|
|
178
|
+
"actor": "seller (answers its own endpoint; the layer holds the reply)"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"id": "pregrade",
|
|
184
|
+
"from": "Delivered",
|
|
185
|
+
"to": "Delivered",
|
|
186
|
+
"timeout": null,
|
|
187
|
+
"hook": null,
|
|
188
|
+
"by": {
|
|
189
|
+
"handshake": {
|
|
190
|
+
"type": "offchain",
|
|
191
|
+
"name": "RUBRIC_v1 compose on the handshake subject; decision.v2 anchored on JevDecisionLog (36927)",
|
|
192
|
+
"actor": "layer (trial / layer key) or the caller’s TypeSafe credential"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"id": "fund_offer",
|
|
198
|
+
"from": "Open",
|
|
199
|
+
"to": "Funded",
|
|
200
|
+
"timeout": null,
|
|
201
|
+
"hook": null,
|
|
202
|
+
"by": {
|
|
203
|
+
"hook": {
|
|
204
|
+
"type": "call",
|
|
205
|
+
"name": "JobFunded (+ JobCovered)",
|
|
206
|
+
"actor": "buyer (after the seller approves D and the buyer approves P + π)"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"id": "fund_delivered",
|
|
212
|
+
"from": "Delivered",
|
|
213
|
+
"to": "Funded",
|
|
214
|
+
"timeout": null,
|
|
215
|
+
"hook": null,
|
|
216
|
+
"by": {
|
|
217
|
+
"hook": {
|
|
218
|
+
"type": "call",
|
|
219
|
+
"name": "JobFunded (+ JobCovered)",
|
|
220
|
+
"actor": "buyer"
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"id": "create",
|
|
226
|
+
"from": "Open",
|
|
227
|
+
"to": "Created",
|
|
228
|
+
"timeout": null,
|
|
229
|
+
"hook": null,
|
|
230
|
+
"by": {
|
|
231
|
+
"erc8183": {
|
|
232
|
+
"type": "event",
|
|
233
|
+
"name": "JobCreated",
|
|
234
|
+
"actor": "client"
|
|
235
|
+
},
|
|
236
|
+
"erc8183-extra": {
|
|
237
|
+
"type": "event",
|
|
238
|
+
"name": "JobCreated",
|
|
239
|
+
"actor": "client"
|
|
240
|
+
},
|
|
241
|
+
"memo-acp": {
|
|
242
|
+
"type": "event",
|
|
243
|
+
"name": "JobCreated (phase 0 REQUEST)",
|
|
244
|
+
"actor": "client"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"id": "terms",
|
|
250
|
+
"from": "Created",
|
|
251
|
+
"to": "Created",
|
|
252
|
+
"timeout": null,
|
|
253
|
+
"hook": null,
|
|
254
|
+
"by": {
|
|
255
|
+
"erc8183": {
|
|
256
|
+
"type": "event",
|
|
257
|
+
"name": "BudgetSet",
|
|
258
|
+
"actor": "client | provider"
|
|
259
|
+
},
|
|
260
|
+
"erc8183-extra": {
|
|
261
|
+
"type": "event",
|
|
262
|
+
"name": "BudgetSet(uint256,address,uint256) · ProviderSet(uint256,address,uint256)",
|
|
263
|
+
"actor": "client"
|
|
264
|
+
},
|
|
265
|
+
"memo-acp": {
|
|
266
|
+
"type": "event",
|
|
267
|
+
"name": "JobPhaseUpdated 0→1 (NEGOTIATION)",
|
|
268
|
+
"actor": "provider"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"id": "fund",
|
|
274
|
+
"from": "Created",
|
|
275
|
+
"to": "Funded",
|
|
276
|
+
"timeout": null,
|
|
277
|
+
"hook": null,
|
|
278
|
+
"by": {
|
|
279
|
+
"erc8183": {
|
|
280
|
+
"type": "event",
|
|
281
|
+
"name": "JobFunded",
|
|
282
|
+
"actor": "client"
|
|
283
|
+
},
|
|
284
|
+
"erc8183-extra": {
|
|
285
|
+
"type": "event",
|
|
286
|
+
"name": "JobFunded",
|
|
287
|
+
"actor": "client"
|
|
288
|
+
},
|
|
289
|
+
"memo-acp": {
|
|
290
|
+
"type": "event",
|
|
291
|
+
"name": "JobPhaseUpdated 1→2 (TRANSACTION)",
|
|
292
|
+
"actor": "client"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"id": "reject_unfunded",
|
|
298
|
+
"from": "Created",
|
|
299
|
+
"to": "Rejected",
|
|
300
|
+
"timeout": null,
|
|
301
|
+
"hook": null,
|
|
302
|
+
"by": {
|
|
303
|
+
"erc8183": {
|
|
304
|
+
"type": "event",
|
|
305
|
+
"name": "JobRejected",
|
|
306
|
+
"actor": "client"
|
|
307
|
+
},
|
|
308
|
+
"erc8183-extra": {
|
|
309
|
+
"type": "event",
|
|
310
|
+
"name": "JobRejected",
|
|
311
|
+
"actor": "client"
|
|
312
|
+
},
|
|
313
|
+
"memo-acp": {
|
|
314
|
+
"type": "event",
|
|
315
|
+
"name": "JobPhaseUpdated 0|1→5 (REJECTED)",
|
|
316
|
+
"actor": "provider | client"
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"id": "lapse",
|
|
322
|
+
"from": "Created",
|
|
323
|
+
"to": "Cancelled",
|
|
324
|
+
"timeout": {
|
|
325
|
+
"after": "expiredAt",
|
|
326
|
+
"default": true
|
|
327
|
+
},
|
|
328
|
+
"hook": null,
|
|
329
|
+
"by": {
|
|
330
|
+
"erc8183": {
|
|
331
|
+
"type": "timeout",
|
|
332
|
+
"name": "expiredAt passed with no JobFunded",
|
|
333
|
+
"actor": "nobody (the observatory derives lapsed_unfunded)"
|
|
334
|
+
},
|
|
335
|
+
"erc8183-extra": {
|
|
336
|
+
"type": "timeout",
|
|
337
|
+
"name": "expiredAt passed with no JobFunded",
|
|
338
|
+
"actor": "nobody"
|
|
339
|
+
},
|
|
340
|
+
"memo-acp": {
|
|
341
|
+
"type": "timeout",
|
|
342
|
+
"name": "expiredAt passed before TRANSACTION",
|
|
343
|
+
"actor": "nobody"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"id": "expire_unfunded",
|
|
349
|
+
"from": "Created",
|
|
350
|
+
"to": "Expired",
|
|
351
|
+
"timeout": {
|
|
352
|
+
"after": "expiredAt",
|
|
353
|
+
"default": false
|
|
354
|
+
},
|
|
355
|
+
"hook": null,
|
|
356
|
+
"by": {
|
|
357
|
+
"erc8183": {
|
|
358
|
+
"type": "event",
|
|
359
|
+
"name": "JobExpired (no Refunded: nothing was escrowed)",
|
|
360
|
+
"actor": "anyone"
|
|
361
|
+
},
|
|
362
|
+
"erc8183-extra": {
|
|
363
|
+
"type": "event",
|
|
364
|
+
"name": "JobExpired",
|
|
365
|
+
"actor": "anyone"
|
|
366
|
+
},
|
|
367
|
+
"memo-acp": {
|
|
368
|
+
"type": "event",
|
|
369
|
+
"name": "JobPhaseUpdated 0|1→6 (EXPIRED)",
|
|
370
|
+
"actor": "anyone"
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"id": "submit_unfunded",
|
|
376
|
+
"from": "Created",
|
|
377
|
+
"to": "Submitted",
|
|
378
|
+
"timeout": null,
|
|
379
|
+
"hook": null,
|
|
380
|
+
"by": {
|
|
381
|
+
"erc8183": {
|
|
382
|
+
"type": "event",
|
|
383
|
+
"name": "JobSubmitted (+ JobCompleted + PaymentReleased in the same tx when the evaluator is 0x0)",
|
|
384
|
+
"actor": "provider"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"id": "submit",
|
|
390
|
+
"from": "Funded",
|
|
391
|
+
"to": "Submitted",
|
|
392
|
+
"timeout": null,
|
|
393
|
+
"hook": null,
|
|
394
|
+
"by": {
|
|
395
|
+
"erc8183": {
|
|
396
|
+
"type": "event",
|
|
397
|
+
"name": "JobSubmitted",
|
|
398
|
+
"actor": "provider"
|
|
399
|
+
},
|
|
400
|
+
"erc8183-extra": {
|
|
401
|
+
"type": "event",
|
|
402
|
+
"name": "JobSubmitted",
|
|
403
|
+
"actor": "provider"
|
|
404
|
+
},
|
|
405
|
+
"memo-acp": {
|
|
406
|
+
"type": "event",
|
|
407
|
+
"name": "JobPhaseUpdated 2→3 (EVALUATION)",
|
|
408
|
+
"actor": "provider"
|
|
409
|
+
},
|
|
410
|
+
"hook": {
|
|
411
|
+
"type": "call",
|
|
412
|
+
"name": "Submitted",
|
|
413
|
+
"actor": "seller"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"id": "reject_undelivered",
|
|
419
|
+
"from": "Funded",
|
|
420
|
+
"to": "Rejected",
|
|
421
|
+
"timeout": null,
|
|
422
|
+
"hook": null,
|
|
423
|
+
"by": {
|
|
424
|
+
"erc8183": {
|
|
425
|
+
"type": "event",
|
|
426
|
+
"name": "JobRejected",
|
|
427
|
+
"actor": "evaluator"
|
|
428
|
+
},
|
|
429
|
+
"erc8183-extra": {
|
|
430
|
+
"type": "event",
|
|
431
|
+
"name": "JobRejected",
|
|
432
|
+
"actor": "evaluator"
|
|
433
|
+
},
|
|
434
|
+
"memo-acp": {
|
|
435
|
+
"type": "event",
|
|
436
|
+
"name": "JobPhaseUpdated 2→5 (REJECTED)",
|
|
437
|
+
"actor": "provider | evaluator"
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"id": "expire_undelivered",
|
|
443
|
+
"from": "Funded",
|
|
444
|
+
"to": "Expired",
|
|
445
|
+
"timeout": {
|
|
446
|
+
"after": "expiredAt | hook deadline",
|
|
447
|
+
"default": true
|
|
448
|
+
},
|
|
449
|
+
"hook": null,
|
|
450
|
+
"by": {
|
|
451
|
+
"erc8183": {
|
|
452
|
+
"type": "event",
|
|
453
|
+
"name": "JobExpired + Refunded",
|
|
454
|
+
"actor": "anyone"
|
|
455
|
+
},
|
|
456
|
+
"erc8183-extra": {
|
|
457
|
+
"type": "event",
|
|
458
|
+
"name": "JobExpired + Refunded",
|
|
459
|
+
"actor": "anyone"
|
|
460
|
+
},
|
|
461
|
+
"memo-acp": {
|
|
462
|
+
"type": "event",
|
|
463
|
+
"name": "JobPhaseUpdated 2→6 (EXPIRED)",
|
|
464
|
+
"actor": "anyone"
|
|
465
|
+
},
|
|
466
|
+
"hook": {
|
|
467
|
+
"type": "call",
|
|
468
|
+
"name": "Expired(jobId, triggeredBy) (+ NoShowCompensated on a V5 hook)",
|
|
469
|
+
"actor": "anyone"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"id": "complete",
|
|
475
|
+
"from": "Submitted",
|
|
476
|
+
"to": "Settled",
|
|
477
|
+
"timeout": null,
|
|
478
|
+
"hook": null,
|
|
479
|
+
"by": {
|
|
480
|
+
"erc8183": {
|
|
481
|
+
"type": "event",
|
|
482
|
+
"name": "JobCompleted + PaymentReleased (+ EvaluatorFeePaid)",
|
|
483
|
+
"actor": "evaluator (the client itself on 10,927 of 11,052 indexed jobs)"
|
|
484
|
+
},
|
|
485
|
+
"erc8183-extra": {
|
|
486
|
+
"type": "event",
|
|
487
|
+
"name": "PaymentReleased + JobCompleted + Settled",
|
|
488
|
+
"actor": "platform evaluator"
|
|
489
|
+
},
|
|
490
|
+
"memo-acp": {
|
|
491
|
+
"type": "event",
|
|
492
|
+
"name": "JobPhaseUpdated 3→4 (COMPLETED) + USDC to the provider",
|
|
493
|
+
"actor": "evaluator (usually the client)"
|
|
494
|
+
},
|
|
495
|
+
"hook": {
|
|
496
|
+
"type": "call",
|
|
497
|
+
"name": "Completed(jobId, premiumToPool) (+ PremiumSplit on a V5 hook)",
|
|
498
|
+
"actor": "buyer | hook evaluator; a V4 job that names an evaluator: that evaluator only"
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"id": "reject_delivered",
|
|
504
|
+
"from": "Submitted",
|
|
505
|
+
"to": "Rejected",
|
|
506
|
+
"timeout": null,
|
|
507
|
+
"hook": null,
|
|
508
|
+
"by": {
|
|
509
|
+
"erc8183": {
|
|
510
|
+
"type": "event",
|
|
511
|
+
"name": "JobRejected",
|
|
512
|
+
"actor": "evaluator"
|
|
513
|
+
},
|
|
514
|
+
"erc8183-extra": {
|
|
515
|
+
"type": "event",
|
|
516
|
+
"name": "JobRejected",
|
|
517
|
+
"actor": "evaluator"
|
|
518
|
+
},
|
|
519
|
+
"memo-acp": {
|
|
520
|
+
"type": "event",
|
|
521
|
+
"name": "JobPhaseUpdated 3→5 (REJECTED)",
|
|
522
|
+
"actor": "evaluator"
|
|
523
|
+
},
|
|
524
|
+
"hook": {
|
|
525
|
+
"type": "call",
|
|
526
|
+
"name": "Rejected(jobId, verdictDigest)",
|
|
527
|
+
"actor": "buyer | hook evaluator"
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"id": "expire_delivered",
|
|
533
|
+
"from": "Submitted",
|
|
534
|
+
"to": "Expired",
|
|
535
|
+
"timeout": {
|
|
536
|
+
"after": "expiredAt | hook deadline",
|
|
537
|
+
"default": true
|
|
538
|
+
},
|
|
539
|
+
"hook": null,
|
|
540
|
+
"by": {
|
|
541
|
+
"erc8183": {
|
|
542
|
+
"type": "event",
|
|
543
|
+
"name": "JobExpired + Refunded",
|
|
544
|
+
"actor": "anyone"
|
|
545
|
+
},
|
|
546
|
+
"erc8183-extra": {
|
|
547
|
+
"type": "event",
|
|
548
|
+
"name": "JobExpired + Refunded",
|
|
549
|
+
"actor": "anyone"
|
|
550
|
+
},
|
|
551
|
+
"memo-acp": {
|
|
552
|
+
"type": "event",
|
|
553
|
+
"name": "JobPhaseUpdated 3→6 (EXPIRED)",
|
|
554
|
+
"actor": "anyone"
|
|
555
|
+
},
|
|
556
|
+
"hook": {
|
|
557
|
+
"type": "call",
|
|
558
|
+
"name": "Expired(jobId, triggeredBy)",
|
|
559
|
+
"actor": "anyone"
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"id": "cheat",
|
|
565
|
+
"from": "Submitted",
|
|
566
|
+
"to": "Cheat",
|
|
567
|
+
"timeout": null,
|
|
568
|
+
"hook": null,
|
|
569
|
+
"by": {
|
|
570
|
+
"hook": {
|
|
571
|
+
"type": "call",
|
|
572
|
+
"name": "Cheated(jobId, loss, fromDeposit, fromPool)",
|
|
573
|
+
"actor": "arbitrator"
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"id": "cheat_after_reject",
|
|
579
|
+
"from": "Rejected",
|
|
580
|
+
"to": "Cheat",
|
|
581
|
+
"timeout": null,
|
|
582
|
+
"hook": {
|
|
583
|
+
"only": [
|
|
584
|
+
"V1"
|
|
585
|
+
]
|
|
586
|
+
},
|
|
587
|
+
"by": {
|
|
588
|
+
"hook": {
|
|
589
|
+
"type": "call",
|
|
590
|
+
"name": "Cheated(jobId, loss, fromDeposit, fromPool)",
|
|
591
|
+
"actor": "arbitrator"
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"id": "grade_auto",
|
|
597
|
+
"from": "Submitted",
|
|
598
|
+
"to": "Graded",
|
|
599
|
+
"timeout": null,
|
|
600
|
+
"hook": null,
|
|
601
|
+
"by": {
|
|
602
|
+
"hook": {
|
|
603
|
+
"type": "offchain",
|
|
604
|
+
"name": "RUBRIC_v1 compose → complete | reject (auto), decision.v2 anchored",
|
|
605
|
+
"actor": "layer"
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"id": "hold",
|
|
611
|
+
"from": "Submitted",
|
|
612
|
+
"to": "Held",
|
|
613
|
+
"timeout": null,
|
|
614
|
+
"hook": null,
|
|
615
|
+
"by": {
|
|
616
|
+
"hook": {
|
|
617
|
+
"type": "offchain",
|
|
618
|
+
"name": "RUBRIC_v1 compose → needs_review",
|
|
619
|
+
"actor": "layer"
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"id": "graded_complete",
|
|
625
|
+
"from": "Graded",
|
|
626
|
+
"to": "Settled",
|
|
627
|
+
"timeout": null,
|
|
628
|
+
"hook": null,
|
|
629
|
+
"by": {
|
|
630
|
+
"hook": {
|
|
631
|
+
"type": "call",
|
|
632
|
+
"name": "Completed(jobId, premiumToPool)",
|
|
633
|
+
"actor": "buyer"
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
"id": "graded_reject",
|
|
639
|
+
"from": "Graded",
|
|
640
|
+
"to": "Rejected",
|
|
641
|
+
"timeout": null,
|
|
642
|
+
"hook": null,
|
|
643
|
+
"by": {
|
|
644
|
+
"hook": {
|
|
645
|
+
"type": "call",
|
|
646
|
+
"name": "Rejected(jobId, verdictDigest)",
|
|
647
|
+
"actor": "buyer | hook evaluator"
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
"id": "graded_expire",
|
|
653
|
+
"from": "Graded",
|
|
654
|
+
"to": "Expired",
|
|
655
|
+
"timeout": {
|
|
656
|
+
"after": "hook deadline",
|
|
657
|
+
"default": true
|
|
658
|
+
},
|
|
659
|
+
"hook": null,
|
|
660
|
+
"by": {
|
|
661
|
+
"hook": {
|
|
662
|
+
"type": "call",
|
|
663
|
+
"name": "Expired(jobId, triggeredBy)",
|
|
664
|
+
"actor": "anyone"
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
"id": "graded_cheat",
|
|
670
|
+
"from": "Graded",
|
|
671
|
+
"to": "Cheat",
|
|
672
|
+
"timeout": null,
|
|
673
|
+
"hook": null,
|
|
674
|
+
"by": {
|
|
675
|
+
"hook": {
|
|
676
|
+
"type": "call",
|
|
677
|
+
"name": "Cheated",
|
|
678
|
+
"actor": "arbitrator"
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"id": "held_complete",
|
|
684
|
+
"from": "Held",
|
|
685
|
+
"to": "Settled",
|
|
686
|
+
"timeout": null,
|
|
687
|
+
"hook": null,
|
|
688
|
+
"by": {
|
|
689
|
+
"hook": {
|
|
690
|
+
"type": "call",
|
|
691
|
+
"name": "VerdictPosted + Completed",
|
|
692
|
+
"actor": "registered evaluator (devnet JudgeAdapter today)"
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"id": "held_reject",
|
|
698
|
+
"from": "Held",
|
|
699
|
+
"to": "Rejected",
|
|
700
|
+
"timeout": null,
|
|
701
|
+
"hook": null,
|
|
702
|
+
"by": {
|
|
703
|
+
"hook": {
|
|
704
|
+
"type": "call",
|
|
705
|
+
"name": "VerdictPosted + Rejected",
|
|
706
|
+
"actor": "registered evaluator"
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"id": "held_expire",
|
|
712
|
+
"from": "Held",
|
|
713
|
+
"to": "Expired",
|
|
714
|
+
"timeout": {
|
|
715
|
+
"after": "hook deadline",
|
|
716
|
+
"default": true
|
|
717
|
+
},
|
|
718
|
+
"hook": null,
|
|
719
|
+
"by": {
|
|
720
|
+
"hook": {
|
|
721
|
+
"type": "call",
|
|
722
|
+
"name": "Expired(jobId, triggeredBy)",
|
|
723
|
+
"actor": "anyone"
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"id": "held_cheat",
|
|
729
|
+
"from": "Held",
|
|
730
|
+
"to": "Cheat",
|
|
731
|
+
"timeout": null,
|
|
732
|
+
"hook": null,
|
|
733
|
+
"by": {
|
|
734
|
+
"hook": {
|
|
735
|
+
"type": "call",
|
|
736
|
+
"name": "Cheated",
|
|
737
|
+
"actor": "arbitrator"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"id": "open_v4",
|
|
743
|
+
"from": "Open",
|
|
744
|
+
"to": "Opened",
|
|
745
|
+
"timeout": null,
|
|
746
|
+
"hook": {
|
|
747
|
+
"since": "V4"
|
|
748
|
+
},
|
|
749
|
+
"by": {
|
|
750
|
+
"hook": {
|
|
751
|
+
"type": "call",
|
|
752
|
+
"name": "JobOpened (+ JobSpecCommitted, X402PaymentReceived)",
|
|
753
|
+
"actor": "buyer"
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"id": "accept_v4",
|
|
759
|
+
"from": "Opened",
|
|
760
|
+
"to": "Funded",
|
|
761
|
+
"timeout": null,
|
|
762
|
+
"hook": {
|
|
763
|
+
"since": "V4"
|
|
764
|
+
},
|
|
765
|
+
"by": {
|
|
766
|
+
"hook": {
|
|
767
|
+
"type": "call",
|
|
768
|
+
"name": "JobAccepted + JobFunded (+ JobCovered)",
|
|
769
|
+
"actor": "seller (locks its deposit)"
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"id": "cancel_open_v4",
|
|
775
|
+
"from": "Opened",
|
|
776
|
+
"to": "Expired",
|
|
777
|
+
"timeout": null,
|
|
778
|
+
"hook": {
|
|
779
|
+
"since": "V4"
|
|
780
|
+
},
|
|
781
|
+
"by": {
|
|
782
|
+
"hook": {
|
|
783
|
+
"type": "call",
|
|
784
|
+
"name": "OpenCancelled + Settled(ending 7)",
|
|
785
|
+
"actor": "buyer"
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"id": "expire_open_v4",
|
|
791
|
+
"from": "Opened",
|
|
792
|
+
"to": "Expired",
|
|
793
|
+
"timeout": {
|
|
794
|
+
"after": "hook deadline",
|
|
795
|
+
"default": true
|
|
796
|
+
},
|
|
797
|
+
"hook": {
|
|
798
|
+
"since": "V4"
|
|
799
|
+
},
|
|
800
|
+
"by": {
|
|
801
|
+
"hook": {
|
|
802
|
+
"type": "call",
|
|
803
|
+
"name": "Settled(ending 2) + Expired(jobId, triggeredBy)",
|
|
804
|
+
"actor": "anyone"
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"id": "propose_reject_v4",
|
|
810
|
+
"from": "Submitted",
|
|
811
|
+
"to": "RejectPending",
|
|
812
|
+
"timeout": null,
|
|
813
|
+
"hook": {
|
|
814
|
+
"since": "V4"
|
|
815
|
+
},
|
|
816
|
+
"by": {
|
|
817
|
+
"hook": {
|
|
818
|
+
"type": "call",
|
|
819
|
+
"name": "RejectProposed(jobId, verdictDigest, disputeDeadline)",
|
|
820
|
+
"actor": "named evaluator | hook evaluator"
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
"id": "graded_propose_reject_v4",
|
|
826
|
+
"from": "Graded",
|
|
827
|
+
"to": "RejectPending",
|
|
828
|
+
"timeout": null,
|
|
829
|
+
"hook": {
|
|
830
|
+
"since": "V4"
|
|
831
|
+
},
|
|
832
|
+
"by": {
|
|
833
|
+
"hook": {
|
|
834
|
+
"type": "call",
|
|
835
|
+
"name": "VerdictPosted + RejectProposed",
|
|
836
|
+
"actor": "named evaluator (the fee-forwarding JudgeAdapter)"
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"id": "held_propose_reject_v4",
|
|
842
|
+
"from": "Held",
|
|
843
|
+
"to": "RejectPending",
|
|
844
|
+
"timeout": null,
|
|
845
|
+
"hook": {
|
|
846
|
+
"since": "V4"
|
|
847
|
+
},
|
|
848
|
+
"by": {
|
|
849
|
+
"hook": {
|
|
850
|
+
"type": "call",
|
|
851
|
+
"name": "VerdictPosted + RejectProposed",
|
|
852
|
+
"actor": "named evaluator"
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
"id": "finalize_reject_v4",
|
|
858
|
+
"from": "RejectPending",
|
|
859
|
+
"to": "Rejected",
|
|
860
|
+
"timeout": {
|
|
861
|
+
"after": "disputeDeadline",
|
|
862
|
+
"default": true
|
|
863
|
+
},
|
|
864
|
+
"hook": {
|
|
865
|
+
"since": "V4"
|
|
866
|
+
},
|
|
867
|
+
"by": {
|
|
868
|
+
"hook": {
|
|
869
|
+
"type": "call",
|
|
870
|
+
"name": "Rejected + Settled(ending 3) (+ EvaluatorFeePaid)",
|
|
871
|
+
"actor": "anyone"
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
"id": "dispute_v4",
|
|
877
|
+
"from": "RejectPending",
|
|
878
|
+
"to": "Disputed",
|
|
879
|
+
"timeout": null,
|
|
880
|
+
"hook": {
|
|
881
|
+
"since": "V4"
|
|
882
|
+
},
|
|
883
|
+
"by": {
|
|
884
|
+
"hook": {
|
|
885
|
+
"type": "call",
|
|
886
|
+
"name": "DisputeOpened(jobId, arbitrationDeadline)",
|
|
887
|
+
"actor": "seller"
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
"id": "resolve_seller_v4",
|
|
893
|
+
"from": "Disputed",
|
|
894
|
+
"to": "Settled",
|
|
895
|
+
"timeout": null,
|
|
896
|
+
"hook": {
|
|
897
|
+
"since": "V4"
|
|
898
|
+
},
|
|
899
|
+
"by": {
|
|
900
|
+
"hook": {
|
|
901
|
+
"type": "call",
|
|
902
|
+
"name": "DisputeResolved + Completed + Settled(ending 6)",
|
|
903
|
+
"actor": "arbitrator"
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
"id": "resolve_buyer_v4",
|
|
909
|
+
"from": "Disputed",
|
|
910
|
+
"to": "Rejected",
|
|
911
|
+
"timeout": null,
|
|
912
|
+
"hook": {
|
|
913
|
+
"since": "V4"
|
|
914
|
+
},
|
|
915
|
+
"by": {
|
|
916
|
+
"hook": {
|
|
917
|
+
"type": "call",
|
|
918
|
+
"name": "DisputeResolved + Rejected + Settled(ending 3)",
|
|
919
|
+
"actor": "arbitrator"
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
"id": "stale_dispute_v4",
|
|
925
|
+
"from": "Disputed",
|
|
926
|
+
"to": "Rejected",
|
|
927
|
+
"timeout": {
|
|
928
|
+
"after": "arbitrationDeadline",
|
|
929
|
+
"default": true
|
|
930
|
+
},
|
|
931
|
+
"hook": {
|
|
932
|
+
"since": "V4"
|
|
933
|
+
},
|
|
934
|
+
"by": {
|
|
935
|
+
"hook": {
|
|
936
|
+
"type": "call",
|
|
937
|
+
"name": "Rejected + Settled(ending 3)",
|
|
938
|
+
"actor": "anyone"
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
"id": "auto_complete_v4",
|
|
944
|
+
"from": "Submitted",
|
|
945
|
+
"to": "Settled",
|
|
946
|
+
"timeout": {
|
|
947
|
+
"after": "submittedAt + reviewWindow (V4 job terms)",
|
|
948
|
+
"default": true
|
|
949
|
+
},
|
|
950
|
+
"hook": {
|
|
951
|
+
"since": "V4"
|
|
952
|
+
},
|
|
953
|
+
"by": {
|
|
954
|
+
"hook": {
|
|
955
|
+
"type": "call",
|
|
956
|
+
"name": "AutoCompleted + Completed + Settled(ending 5) (+ EvaluatorFeeRefunded)",
|
|
957
|
+
"actor": "anyone"
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"id": "graded_auto_complete_v4",
|
|
963
|
+
"from": "Graded",
|
|
964
|
+
"to": "Settled",
|
|
965
|
+
"timeout": {
|
|
966
|
+
"after": "submittedAt + reviewWindow (V4 job terms)",
|
|
967
|
+
"default": true
|
|
968
|
+
},
|
|
969
|
+
"hook": {
|
|
970
|
+
"since": "V4"
|
|
971
|
+
},
|
|
972
|
+
"by": {
|
|
973
|
+
"hook": {
|
|
974
|
+
"type": "call",
|
|
975
|
+
"name": "AutoCompleted + Completed + Settled(ending 5) (+ EvaluatorFeeRefunded)",
|
|
976
|
+
"actor": "anyone"
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
"id": "held_auto_complete_v4",
|
|
982
|
+
"from": "Held",
|
|
983
|
+
"to": "Settled",
|
|
984
|
+
"timeout": {
|
|
985
|
+
"after": "submittedAt + reviewWindow (V4 job terms)",
|
|
986
|
+
"default": true
|
|
987
|
+
},
|
|
988
|
+
"hook": {
|
|
989
|
+
"since": "V4"
|
|
990
|
+
},
|
|
991
|
+
"by": {
|
|
992
|
+
"hook": {
|
|
993
|
+
"type": "call",
|
|
994
|
+
"name": "AutoCompleted + Completed + Settled(ending 5) (+ EvaluatorFeeRefunded)",
|
|
995
|
+
"actor": "anyone"
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
],
|
|
1000
|
+
"endings": [
|
|
1001
|
+
{
|
|
1002
|
+
"id": "completed",
|
|
1003
|
+
"state": "Settled",
|
|
1004
|
+
"verdict": "correct",
|
|
1005
|
+
"countsInN": true,
|
|
1006
|
+
"jevCase": false
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
"id": "cheated",
|
|
1010
|
+
"state": "Cheat",
|
|
1011
|
+
"verdict": "incorrect",
|
|
1012
|
+
"countsInN": true,
|
|
1013
|
+
"jevCase": false
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
"id": "rejected_delivered",
|
|
1017
|
+
"state": "Rejected",
|
|
1018
|
+
"verdict": "incorrect",
|
|
1019
|
+
"countsInN": true,
|
|
1020
|
+
"jevCase": true
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
"id": "expired_undelivered",
|
|
1024
|
+
"state": "Expired",
|
|
1025
|
+
"verdict": "incorrect",
|
|
1026
|
+
"countsInN": true,
|
|
1027
|
+
"jevCase": false
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
"id": "expired_delivered",
|
|
1031
|
+
"state": "Expired",
|
|
1032
|
+
"verdict": "undecided",
|
|
1033
|
+
"countsInN": false,
|
|
1034
|
+
"jevCase": true
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
"id": "rejected_undelivered",
|
|
1038
|
+
"state": "Rejected",
|
|
1039
|
+
"verdict": "excluded:rejected_before_delivery",
|
|
1040
|
+
"countsInN": false,
|
|
1041
|
+
"jevCase": false
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
"id": "lapsed_unfunded",
|
|
1045
|
+
"state": "Cancelled",
|
|
1046
|
+
"verdict": "excluded:lapsed_unfunded",
|
|
1047
|
+
"countsInN": false,
|
|
1048
|
+
"jevCase": false
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"id": "open",
|
|
1052
|
+
"state": null,
|
|
1053
|
+
"verdict": "excluded:open",
|
|
1054
|
+
"countsInN": false,
|
|
1055
|
+
"jevCase": false
|
|
1056
|
+
}
|
|
1057
|
+
],
|
|
1058
|
+
"exclusions": [
|
|
1059
|
+
{
|
|
1060
|
+
"rule": "budget not > 0 (any ending)",
|
|
1061
|
+
"verdict": "excluded:unpaid"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
"rule": "memo-acp or erc8183-extra, expired_undelivered and never funded",
|
|
1065
|
+
"verdict": "excluded:expired_unfunded"
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
"rule": "memo-acp or erc8183-extra, rejected_undelivered and never funded",
|
|
1069
|
+
"verdict": "excluded:rejected_unfunded"
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
"rule": "V4 hook job the seller never accepted (JobOpened, no JobFunded), expired or cancelled",
|
|
1073
|
+
"verdict": "excluded:expired_unfunded"
|
|
1074
|
+
}
|
|
1075
|
+
],
|
|
1076
|
+
"maps": {
|
|
1077
|
+
"hookState": {
|
|
1078
|
+
"0": "Open",
|
|
1079
|
+
"1": "Funded",
|
|
1080
|
+
"2": "Submitted",
|
|
1081
|
+
"3": "Settled",
|
|
1082
|
+
"4": "Expired",
|
|
1083
|
+
"5": "Rejected",
|
|
1084
|
+
"6": "Cheat",
|
|
1085
|
+
"7": "Opened",
|
|
1086
|
+
"8": "RejectPending",
|
|
1087
|
+
"9": "Disputed"
|
|
1088
|
+
},
|
|
1089
|
+
"memoAcpPhase": {
|
|
1090
|
+
"0": "Created",
|
|
1091
|
+
"1": "Created",
|
|
1092
|
+
"2": "Funded",
|
|
1093
|
+
"3": "Submitted",
|
|
1094
|
+
"4": "Settled",
|
|
1095
|
+
"5": "Rejected",
|
|
1096
|
+
"6": "Expired"
|
|
1097
|
+
},
|
|
1098
|
+
"handshakeState": {
|
|
1099
|
+
"OPEN": "Open",
|
|
1100
|
+
"NOTIFIED": "Open",
|
|
1101
|
+
"PRICED": "Open",
|
|
1102
|
+
"OFFERED": "Open",
|
|
1103
|
+
"DELIVERED": "Delivered",
|
|
1104
|
+
"ACCEPTED": "Funded",
|
|
1105
|
+
"PROVED": "Submitted",
|
|
1106
|
+
"SETTLED": "Settled",
|
|
1107
|
+
"EXPIRED": "Expired",
|
|
1108
|
+
"REJECTED": "Rejected",
|
|
1109
|
+
"CHEAT": "Cheat"
|
|
1110
|
+
},
|
|
1111
|
+
"event": {
|
|
1112
|
+
"JobCreated": "Created",
|
|
1113
|
+
"BudgetSet": "Created",
|
|
1114
|
+
"ProviderSet": "Created",
|
|
1115
|
+
"JobFunded": "Funded",
|
|
1116
|
+
"JobCovered": "Funded",
|
|
1117
|
+
"JobSubmitted": "Submitted",
|
|
1118
|
+
"Submitted": "Submitted",
|
|
1119
|
+
"JobCompleted": "Settled",
|
|
1120
|
+
"PaymentReleased": "Settled",
|
|
1121
|
+
"Settled": "Settled",
|
|
1122
|
+
"Completed": "Settled",
|
|
1123
|
+
"JobRejected": "Rejected",
|
|
1124
|
+
"Rejected": "Rejected",
|
|
1125
|
+
"JobExpired": "Expired",
|
|
1126
|
+
"Expired": "Expired",
|
|
1127
|
+
"Cheated": "Cheat",
|
|
1128
|
+
"Refunded": null,
|
|
1129
|
+
"EvaluatorFeePaid": null,
|
|
1130
|
+
"JobOpened": "Opened",
|
|
1131
|
+
"RejectProposed": "RejectPending",
|
|
1132
|
+
"DisputeOpened": "Disputed",
|
|
1133
|
+
"OpenCancelled": "Expired"
|
|
1134
|
+
},
|
|
1135
|
+
"ending": {
|
|
1136
|
+
"open": null,
|
|
1137
|
+
"lapsed_unfunded": "Cancelled",
|
|
1138
|
+
"completed": "Settled",
|
|
1139
|
+
"rejected_delivered": "Rejected",
|
|
1140
|
+
"rejected_undelivered": "Rejected",
|
|
1141
|
+
"expired_delivered": "Expired",
|
|
1142
|
+
"expired_undelivered": "Expired",
|
|
1143
|
+
"cheated": "Cheat"
|
|
1144
|
+
}
|
|
1145
|
+
},
|
|
1146
|
+
"money": [
|
|
1147
|
+
{
|
|
1148
|
+
"event": "Encumbered",
|
|
1149
|
+
"contract": "pool",
|
|
1150
|
+
"money": "reserve",
|
|
1151
|
+
"with": [
|
|
1152
|
+
"fund_offer",
|
|
1153
|
+
"fund_delivered",
|
|
1154
|
+
"accept_v4"
|
|
1155
|
+
]
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
"event": "JobCoveredCross",
|
|
1159
|
+
"contract": "hook",
|
|
1160
|
+
"money": "reserve",
|
|
1161
|
+
"with": [
|
|
1162
|
+
"fund_offer",
|
|
1163
|
+
"fund_delivered"
|
|
1164
|
+
]
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
"event": "PremiumReceived",
|
|
1168
|
+
"contract": "pool",
|
|
1169
|
+
"money": "in",
|
|
1170
|
+
"with": [
|
|
1171
|
+
"complete",
|
|
1172
|
+
"graded_complete",
|
|
1173
|
+
"held_complete",
|
|
1174
|
+
"auto_complete_v4",
|
|
1175
|
+
"graded_auto_complete_v4",
|
|
1176
|
+
"held_auto_complete_v4",
|
|
1177
|
+
"resolve_seller_v4"
|
|
1178
|
+
]
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
"event": "RewardPremiumReceived",
|
|
1182
|
+
"contract": "pool",
|
|
1183
|
+
"money": "in",
|
|
1184
|
+
"with": [
|
|
1185
|
+
"complete",
|
|
1186
|
+
"graded_complete",
|
|
1187
|
+
"held_complete",
|
|
1188
|
+
"auto_complete_v4",
|
|
1189
|
+
"graded_auto_complete_v4",
|
|
1190
|
+
"held_auto_complete_v4",
|
|
1191
|
+
"resolve_seller_v4"
|
|
1192
|
+
]
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
"event": "Released",
|
|
1196
|
+
"contract": "pool",
|
|
1197
|
+
"money": "release",
|
|
1198
|
+
"with": [
|
|
1199
|
+
"complete",
|
|
1200
|
+
"graded_complete",
|
|
1201
|
+
"held_complete",
|
|
1202
|
+
"reject_delivered",
|
|
1203
|
+
"graded_reject",
|
|
1204
|
+
"held_reject",
|
|
1205
|
+
"expire_undelivered",
|
|
1206
|
+
"expire_delivered",
|
|
1207
|
+
"graded_expire",
|
|
1208
|
+
"held_expire",
|
|
1209
|
+
"cheat",
|
|
1210
|
+
"graded_cheat",
|
|
1211
|
+
"held_cheat",
|
|
1212
|
+
"propose_reject_v4",
|
|
1213
|
+
"graded_propose_reject_v4",
|
|
1214
|
+
"held_propose_reject_v4",
|
|
1215
|
+
"auto_complete_v4",
|
|
1216
|
+
"graded_auto_complete_v4",
|
|
1217
|
+
"held_auto_complete_v4"
|
|
1218
|
+
]
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
"event": "CoverReleaseFailed",
|
|
1222
|
+
"contract": "hook",
|
|
1223
|
+
"money": "release_failed",
|
|
1224
|
+
"with": [
|
|
1225
|
+
"complete",
|
|
1226
|
+
"graded_complete",
|
|
1227
|
+
"held_complete",
|
|
1228
|
+
"reject_delivered",
|
|
1229
|
+
"graded_reject",
|
|
1230
|
+
"held_reject",
|
|
1231
|
+
"expire_undelivered",
|
|
1232
|
+
"expire_delivered",
|
|
1233
|
+
"graded_expire",
|
|
1234
|
+
"held_expire",
|
|
1235
|
+
"cheat",
|
|
1236
|
+
"graded_cheat",
|
|
1237
|
+
"held_cheat",
|
|
1238
|
+
"propose_reject_v4",
|
|
1239
|
+
"graded_propose_reject_v4",
|
|
1240
|
+
"held_propose_reject_v4",
|
|
1241
|
+
"auto_complete_v4",
|
|
1242
|
+
"graded_auto_complete_v4",
|
|
1243
|
+
"held_auto_complete_v4"
|
|
1244
|
+
]
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
"event": "CoverPaid",
|
|
1248
|
+
"contract": "pool",
|
|
1249
|
+
"money": "out",
|
|
1250
|
+
"with": [
|
|
1251
|
+
"cheat",
|
|
1252
|
+
"graded_cheat",
|
|
1253
|
+
"held_cheat",
|
|
1254
|
+
"cheat_after_reject"
|
|
1255
|
+
]
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
"event": "CrossCoverPaid",
|
|
1259
|
+
"contract": "hook",
|
|
1260
|
+
"money": "out",
|
|
1261
|
+
"with": [
|
|
1262
|
+
"cheat",
|
|
1263
|
+
"graded_cheat",
|
|
1264
|
+
"held_cheat"
|
|
1265
|
+
]
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
"event": "Refunded",
|
|
1269
|
+
"contract": "erc8183",
|
|
1270
|
+
"money": "out",
|
|
1271
|
+
"with": [
|
|
1272
|
+
"reject_undelivered",
|
|
1273
|
+
"reject_delivered",
|
|
1274
|
+
"expire_undelivered",
|
|
1275
|
+
"expire_delivered"
|
|
1276
|
+
]
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"event": "EvaluatorFeePaid",
|
|
1280
|
+
"contract": "erc8183 · hook (V4)",
|
|
1281
|
+
"money": "out",
|
|
1282
|
+
"with": [
|
|
1283
|
+
"complete",
|
|
1284
|
+
"graded_complete",
|
|
1285
|
+
"held_complete",
|
|
1286
|
+
"finalize_reject_v4",
|
|
1287
|
+
"resolve_buyer_v4",
|
|
1288
|
+
"stale_dispute_v4"
|
|
1289
|
+
]
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"event": "JobAccepted",
|
|
1293
|
+
"contract": "hook",
|
|
1294
|
+
"money": "in",
|
|
1295
|
+
"with": [
|
|
1296
|
+
"accept_v4"
|
|
1297
|
+
]
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
"event": "EvaluatorFeeRefunded",
|
|
1301
|
+
"contract": "hook",
|
|
1302
|
+
"money": "out",
|
|
1303
|
+
"with": [
|
|
1304
|
+
"complete",
|
|
1305
|
+
"graded_complete",
|
|
1306
|
+
"held_complete",
|
|
1307
|
+
"auto_complete_v4",
|
|
1308
|
+
"graded_auto_complete_v4",
|
|
1309
|
+
"held_auto_complete_v4",
|
|
1310
|
+
"resolve_seller_v4",
|
|
1311
|
+
"cancel_open_v4",
|
|
1312
|
+
"expire_open_v4",
|
|
1313
|
+
"expire_undelivered",
|
|
1314
|
+
"cheat",
|
|
1315
|
+
"graded_cheat",
|
|
1316
|
+
"held_cheat",
|
|
1317
|
+
"finalize_reject_v4",
|
|
1318
|
+
"resolve_buyer_v4",
|
|
1319
|
+
"stale_dispute_v4"
|
|
1320
|
+
]
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
"event": "PremiumSplit",
|
|
1324
|
+
"contract": "hook",
|
|
1325
|
+
"money": "in",
|
|
1326
|
+
"with": [
|
|
1327
|
+
"complete",
|
|
1328
|
+
"graded_complete",
|
|
1329
|
+
"held_complete",
|
|
1330
|
+
"auto_complete_v4",
|
|
1331
|
+
"graded_auto_complete_v4",
|
|
1332
|
+
"held_auto_complete_v4",
|
|
1333
|
+
"resolve_seller_v4"
|
|
1334
|
+
]
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
"event": "NoShowCompensated",
|
|
1338
|
+
"contract": "hook",
|
|
1339
|
+
"money": "out",
|
|
1340
|
+
"with": [
|
|
1341
|
+
"expire_undelivered"
|
|
1342
|
+
]
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
"event": "RejectionCompensated",
|
|
1346
|
+
"contract": "hook",
|
|
1347
|
+
"money": "out",
|
|
1348
|
+
"with": [
|
|
1349
|
+
"finalize_reject_v4",
|
|
1350
|
+
"resolve_buyer_v4",
|
|
1351
|
+
"stale_dispute_v4"
|
|
1352
|
+
]
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
"event": "FeeForwarded",
|
|
1356
|
+
"contract": "judge-adapter",
|
|
1357
|
+
"money": "out",
|
|
1358
|
+
"with": [
|
|
1359
|
+
"complete",
|
|
1360
|
+
"graded_complete",
|
|
1361
|
+
"held_complete",
|
|
1362
|
+
"propose_reject_v4",
|
|
1363
|
+
"graded_propose_reject_v4",
|
|
1364
|
+
"held_propose_reject_v4"
|
|
1365
|
+
]
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
"event": "PayableMemoExecuted",
|
|
1369
|
+
"contract": "memo-acp",
|
|
1370
|
+
"money": "in",
|
|
1371
|
+
"with": [
|
|
1372
|
+
"fund"
|
|
1373
|
+
]
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
"event": "X402PaymentReceived",
|
|
1377
|
+
"contract": "memo-acp · hook (V4)",
|
|
1378
|
+
"money": "in",
|
|
1379
|
+
"with": [
|
|
1380
|
+
"fund",
|
|
1381
|
+
"open_v4"
|
|
1382
|
+
]
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
"event": "ClaimApproved",
|
|
1386
|
+
"contract": "erc8183-extra",
|
|
1387
|
+
"money": "out",
|
|
1388
|
+
"with": [
|
|
1389
|
+
"fund_offer",
|
|
1390
|
+
"fund_delivered",
|
|
1391
|
+
"fund",
|
|
1392
|
+
"submit"
|
|
1393
|
+
]
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
"event": "ClaimSettled",
|
|
1397
|
+
"contract": "erc8183-extra",
|
|
1398
|
+
"money": "out",
|
|
1399
|
+
"with": [
|
|
1400
|
+
"fund_offer",
|
|
1401
|
+
"fund_delivered",
|
|
1402
|
+
"fund",
|
|
1403
|
+
"submit"
|
|
1404
|
+
]
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
"event": "Disbursed",
|
|
1408
|
+
"contract": "erc8183-extra",
|
|
1409
|
+
"money": "out",
|
|
1410
|
+
"with": [
|
|
1411
|
+
"complete",
|
|
1412
|
+
"graded_complete",
|
|
1413
|
+
"held_complete",
|
|
1414
|
+
"submit"
|
|
1415
|
+
]
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
"event": "PlatformFeePaid",
|
|
1419
|
+
"contract": "erc8183-extra",
|
|
1420
|
+
"money": "out",
|
|
1421
|
+
"with": [
|
|
1422
|
+
"complete",
|
|
1423
|
+
"graded_complete",
|
|
1424
|
+
"held_complete",
|
|
1425
|
+
"submit"
|
|
1426
|
+
]
|
|
1427
|
+
}
|
|
1428
|
+
],
|
|
1429
|
+
"cover": {
|
|
1430
|
+
"lane": "external-cover",
|
|
1431
|
+
"states": [
|
|
1432
|
+
{
|
|
1433
|
+
"id": "Quoted",
|
|
1434
|
+
"terminal": false,
|
|
1435
|
+
"holdsFunds": false
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
"id": "Active",
|
|
1439
|
+
"terminal": false,
|
|
1440
|
+
"holdsFunds": true
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
"id": "Settled",
|
|
1444
|
+
"terminal": true,
|
|
1445
|
+
"holdsFunds": false
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
"id": "Expired",
|
|
1449
|
+
"terminal": true,
|
|
1450
|
+
"holdsFunds": false
|
|
1451
|
+
}
|
|
1452
|
+
],
|
|
1453
|
+
"transitions": [
|
|
1454
|
+
{
|
|
1455
|
+
"id": "quote",
|
|
1456
|
+
"from": null,
|
|
1457
|
+
"to": "Quoted",
|
|
1458
|
+
"actor": "layer (observer + pricer + attestor)",
|
|
1459
|
+
"call": "GET /v1/cover/quote"
|
|
1460
|
+
},
|
|
1461
|
+
{
|
|
1462
|
+
"id": "buy",
|
|
1463
|
+
"from": "Quoted",
|
|
1464
|
+
"to": "Active",
|
|
1465
|
+
"actor": "buyer",
|
|
1466
|
+
"call": "buyCover(quote, signatures)"
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
"id": "settle",
|
|
1470
|
+
"from": "Active",
|
|
1471
|
+
"to": "Settled",
|
|
1472
|
+
"actor": "anyone (the statement is the authority)",
|
|
1473
|
+
"call": "settle(policyId, statement, signatures, proof)"
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
"id": "expire",
|
|
1477
|
+
"from": "Active",
|
|
1478
|
+
"to": "Expired",
|
|
1479
|
+
"actor": "anyone",
|
|
1480
|
+
"call": "expire(policyId)"
|
|
1481
|
+
}
|
|
1482
|
+
],
|
|
1483
|
+
"endings": [
|
|
1484
|
+
{
|
|
1485
|
+
"code": 1,
|
|
1486
|
+
"id": "COMPLETED",
|
|
1487
|
+
"pays": false,
|
|
1488
|
+
"from": [
|
|
1489
|
+
"completed"
|
|
1490
|
+
],
|
|
1491
|
+
"premium": "pool"
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
"code": 2,
|
|
1495
|
+
"id": "REFUNDED",
|
|
1496
|
+
"pays": false,
|
|
1497
|
+
"from": [
|
|
1498
|
+
"rejected_undelivered",
|
|
1499
|
+
"rejected_delivered",
|
|
1500
|
+
"expired_undelivered",
|
|
1501
|
+
"expired_delivered"
|
|
1502
|
+
],
|
|
1503
|
+
"premium": "pool"
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
"code": 3,
|
|
1507
|
+
"id": "UNDELIVERED",
|
|
1508
|
+
"pays": true,
|
|
1509
|
+
"from": [
|
|
1510
|
+
"expired_undelivered",
|
|
1511
|
+
"rejected_undelivered",
|
|
1512
|
+
"completed (no deliverable: an operator force-settle, an x402 call that returned nothing)"
|
|
1513
|
+
],
|
|
1514
|
+
"premium": "pool"
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
"code": 4,
|
|
1518
|
+
"id": "DELIVERED_FINDING",
|
|
1519
|
+
"pays": true,
|
|
1520
|
+
"from": [
|
|
1521
|
+
"cheated",
|
|
1522
|
+
"completed",
|
|
1523
|
+
"rejected_delivered",
|
|
1524
|
+
"expired_delivered"
|
|
1525
|
+
],
|
|
1526
|
+
"premium": "pool"
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
"code": 5,
|
|
1530
|
+
"id": "DELIVERED_NO_FINDING",
|
|
1531
|
+
"pays": false,
|
|
1532
|
+
"from": [
|
|
1533
|
+
"rejected_delivered",
|
|
1534
|
+
"expired_delivered",
|
|
1535
|
+
"completed"
|
|
1536
|
+
],
|
|
1537
|
+
"premium": "pool"
|
|
1538
|
+
},
|
|
1539
|
+
{
|
|
1540
|
+
"code": 6,
|
|
1541
|
+
"id": "VOID",
|
|
1542
|
+
"pays": false,
|
|
1543
|
+
"from": [
|
|
1544
|
+
"lapsed_unfunded"
|
|
1545
|
+
],
|
|
1546
|
+
"premium": "buyer"
|
|
1547
|
+
}
|
|
1548
|
+
]
|
|
1549
|
+
},
|
|
1550
|
+
"revenueHooks": [
|
|
1551
|
+
{
|
|
1552
|
+
"hook": "grades_pay_to_key",
|
|
1553
|
+
"phase": 1,
|
|
1554
|
+
"lane": "a grade past the three free ones (the Jev grade of a hire, a listing or a card)",
|
|
1555
|
+
"gate": null
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
"hook": "x402_wall",
|
|
1559
|
+
"phase": 2,
|
|
1560
|
+
"lane": "a paid call to a walled skill, settled by the facilitator to the vault",
|
|
1561
|
+
"gate": null
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
"hook": "routing_fee",
|
|
1565
|
+
"phase": 2,
|
|
1566
|
+
"lane": "a gateway call past the free daily allowance (every hire the loop sends through /gw is one)",
|
|
1567
|
+
"gate": null
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
"hook": "evaluator_fee",
|
|
1571
|
+
"phase": 3,
|
|
1572
|
+
"lane": "an auto-matched hire settled through the layer: paid when our decision stands",
|
|
1573
|
+
"gate": null
|
|
1574
|
+
},
|
|
1575
|
+
{
|
|
1576
|
+
"hook": "resale_fee",
|
|
1577
|
+
"phase": 3,
|
|
1578
|
+
"lane": "a catalogue buy: the seller's price plus the fee, taken at settlement on the settle line",
|
|
1579
|
+
"gate": null
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
"hook": "bridge_fee",
|
|
1583
|
+
"phase": 3,
|
|
1584
|
+
"lane": "a transfer the layer plans between chains for a hire or a caller",
|
|
1585
|
+
"gate": null
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
"hook": "pool_premium_share",
|
|
1589
|
+
"phase": 4,
|
|
1590
|
+
"lane": "the premium of a covered hire: the layer's share of the written split",
|
|
1591
|
+
"gate": "split"
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
"hook": "grid_premium_share",
|
|
1595
|
+
"phase": 4,
|
|
1596
|
+
"lane": "the layer's leg of a GRID line's premium, paid in GRID on top of a GRID job (GRID jobs, GRID cover, made whole in GRID; opens when GRID can be deposited into pools)",
|
|
1597
|
+
"gate": "split"
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
"hook": "partner_bond",
|
|
1601
|
+
"phase": 5,
|
|
1602
|
+
"lane": "an enterprise partner's bond and its members' hires",
|
|
1603
|
+
"gate": null
|
|
1604
|
+
}
|
|
1605
|
+
]
|
|
1606
|
+
};
|
|
1607
|
+
export const STATES = MACHINE.states.map((s) => s.id);
|
|
1608
|
+
export const TRANSITIONS = MACHINE.transitions;
|
|
1609
|
+
export const LANES = MACHINE.lanes;
|
|
1610
|
+
export const ENDINGS = MACHINE.endings;
|
|
1611
|
+
const row = (s) => MACHINE.states.find((r) => r.id === s);
|
|
1612
|
+
export const isState = (s) => typeof s === 'string' && STATES.includes(s);
|
|
1613
|
+
export const isTerminal = (s) => row(s).terminal;
|
|
1614
|
+
export const holdsFunds = (s) => row(s).holdsFunds;
|
|
1615
|
+
/** a lane and the lane it continues as (a handshake continues as a hook job once funded) */
|
|
1616
|
+
export function lanesOf(lane) {
|
|
1617
|
+
const next = MACHINE.continues[lane];
|
|
1618
|
+
return next ? [lane, next] : [lane];
|
|
1619
|
+
}
|
|
1620
|
+
const RANK = { V1: 1, V2: 2, V3: 3, V4: 4, V5: 5 };
|
|
1621
|
+
/** whether a transition runs where this job runs: V4 transitions need a V4+ hook, the V1 defect only a V1 hook */
|
|
1622
|
+
export function runsOn(t, ctx) {
|
|
1623
|
+
if (!t.hook)
|
|
1624
|
+
return true;
|
|
1625
|
+
const v = ctx.hook ?? 'V5';
|
|
1626
|
+
if (t.hook.only)
|
|
1627
|
+
return t.hook.only.includes(v);
|
|
1628
|
+
return RANK[v] >= RANK[t.hook.since];
|
|
1629
|
+
}
|
|
1630
|
+
/** the trigger of a transition on this lane (or the lane it continues as), or null when the lane does not walk it */
|
|
1631
|
+
export function triggerOf(t, lane) {
|
|
1632
|
+
for (const l of lanesOf(lane)) {
|
|
1633
|
+
const b = t.by[l];
|
|
1634
|
+
if (b)
|
|
1635
|
+
return b;
|
|
1636
|
+
}
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
/** every transition out of a state that this lane walks here */
|
|
1640
|
+
export const exits = (from, ctx) => TRANSITIONS.filter((t) => t.from === from && triggerOf(t, ctx.lane) !== null && runsOn(t, ctx));
|
|
1641
|
+
/** the states a lane can reach from the initial state, breadth first */
|
|
1642
|
+
export function reachable(ctx) {
|
|
1643
|
+
const seen = [MACHINE.initial];
|
|
1644
|
+
const q = [...seen];
|
|
1645
|
+
while (q.length) {
|
|
1646
|
+
const s = q.shift();
|
|
1647
|
+
for (const t of exits(s, ctx))
|
|
1648
|
+
if (!seen.includes(t.to)) {
|
|
1649
|
+
seen.push(t.to);
|
|
1650
|
+
q.push(t.to);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
return seen;
|
|
1654
|
+
}
|
|
1655
|
+
/** the clock fields a timeout's `after` names (transitions.json wording: "expiredAt | hook deadline", "submittedAt + reviewWindow …") */
|
|
1656
|
+
export function clockKeys(after) {
|
|
1657
|
+
const k = [];
|
|
1658
|
+
if (/expiredAt/.test(after))
|
|
1659
|
+
k.push('expiredAt');
|
|
1660
|
+
if (/hook deadline/.test(after))
|
|
1661
|
+
k.push('deadline');
|
|
1662
|
+
if (/reviewWindow/.test(after))
|
|
1663
|
+
k.push('reviewEnds');
|
|
1664
|
+
if (/disputeDeadline/.test(after))
|
|
1665
|
+
k.push('disputeDeadline');
|
|
1666
|
+
if (/arbitrationDeadline/.test(after))
|
|
1667
|
+
k.push('arbitrationDeadline');
|
|
1668
|
+
return k;
|
|
1669
|
+
}
|
|
1670
|
+
/** when a timed transition becomes possible on this clock: the earliest deadline it names that is set, or null */
|
|
1671
|
+
export function dueAt(t, clock) {
|
|
1672
|
+
if (!t.timeout)
|
|
1673
|
+
return null;
|
|
1674
|
+
const at = clockKeys(t.timeout.after).map((k) => clock[k]).filter((x) => typeof x === 'number');
|
|
1675
|
+
return at.length ? Math.min(...at) : null;
|
|
1676
|
+
}
|
|
1677
|
+
export function next(state, ev, ctx) {
|
|
1678
|
+
if (!isState(state))
|
|
1679
|
+
return { ok: false, state, error: `unknown state ${String(state)}` };
|
|
1680
|
+
if (ev.kind === 'transition') {
|
|
1681
|
+
const t = TRANSITIONS.find((x) => x.id === ev.id);
|
|
1682
|
+
if (!t)
|
|
1683
|
+
return { ok: false, state, error: `unknown transition ${ev.id}` };
|
|
1684
|
+
if (t.from !== state)
|
|
1685
|
+
return { ok: false, state, error: `${ev.id} leaves ${t.from}, the job is ${state}` };
|
|
1686
|
+
const trig = triggerOf(t, ctx.lane);
|
|
1687
|
+
if (!trig)
|
|
1688
|
+
return { ok: false, state, error: `${ev.id} is not a ${ctx.lane} transition` };
|
|
1689
|
+
if (!runsOn(t, ctx))
|
|
1690
|
+
return { ok: false, state, error: `${ev.id} does not run on a ${ctx.hook ?? 'V5'} hook` };
|
|
1691
|
+
return { ok: true, state: t.to, transition: t.id, trigger: trig };
|
|
1692
|
+
}
|
|
1693
|
+
if (ev.kind === 'event' || ev.kind === 'state') {
|
|
1694
|
+
let to;
|
|
1695
|
+
let label;
|
|
1696
|
+
if (ev.kind === 'state') {
|
|
1697
|
+
if (!isState(ev.to))
|
|
1698
|
+
return { ok: false, state, error: `unknown state ${String(ev.to)}` };
|
|
1699
|
+
to = ev.to;
|
|
1700
|
+
label = `state ${ev.to}`;
|
|
1701
|
+
}
|
|
1702
|
+
else {
|
|
1703
|
+
const ev2s = MACHINE.maps.event;
|
|
1704
|
+
if (!Object.prototype.hasOwnProperty.call(ev2s, ev.name))
|
|
1705
|
+
return { ok: false, state, error: `${ev.name} is not an event of the machine` };
|
|
1706
|
+
to = ev2s[ev.name];
|
|
1707
|
+
label = ev.name;
|
|
1708
|
+
if (to === null)
|
|
1709
|
+
return { ok: true, state, transition: null, trigger: null, effect: ev.name };
|
|
1710
|
+
}
|
|
1711
|
+
const cands = exits(state, ctx).filter((t) => t.to === to && (!ev.via || t.id === ev.via));
|
|
1712
|
+
if (cands.length)
|
|
1713
|
+
return { ok: true, state: to, transition: cands[0].id, trigger: triggerOf(cands[0], ctx.lane) };
|
|
1714
|
+
// several logs of one step (JobFunded + JobCovered, JobCompleted + PaymentReleased) repeat the state: no change
|
|
1715
|
+
if (to === state)
|
|
1716
|
+
return { ok: true, state, transition: null, trigger: null };
|
|
1717
|
+
if (isTerminal(state))
|
|
1718
|
+
return { ok: false, state, error: `${state} is terminal; ${label} cannot follow it` };
|
|
1719
|
+
return { ok: false, state, error: `no ${ctx.lane} transition ${state} → ${to} (${label})` };
|
|
1720
|
+
}
|
|
1721
|
+
const due = exits(state, ctx)
|
|
1722
|
+
.filter((t) => t.timeout?.default)
|
|
1723
|
+
.map((t) => ({ t, at: dueAt(t, ev.clock) }))
|
|
1724
|
+
.filter((x) => x.at !== null && x.at <= ev.now)
|
|
1725
|
+
.sort((a, b) => a.at - b.at);
|
|
1726
|
+
if (!due.length)
|
|
1727
|
+
return { ok: true, state, transition: null, trigger: null };
|
|
1728
|
+
const t = due[0].t;
|
|
1729
|
+
return { ok: true, state: t.to, transition: t.id, trigger: triggerOf(t, ctx.lane) };
|
|
1730
|
+
}
|
|
1731
|
+
/** source vocabularies → machine states (transitions.json maps) */
|
|
1732
|
+
export const stateOf = {
|
|
1733
|
+
/** the hook's State enum: None Funded Submitted Completed Expired Rejected Cheated, then V4 Open RejectPending Disputed */
|
|
1734
|
+
hook: (n) => MACHINE.maps.hookState[String(n)] ?? null,
|
|
1735
|
+
/** memo-ACP JobManager phase 0..6 */
|
|
1736
|
+
memoPhase: (n) => MACHINE.maps.memoAcpPhase[String(n)] ?? null,
|
|
1737
|
+
/** a handshake state; OFFERED with a held delivery is Delivered */
|
|
1738
|
+
handshake: (s, delivered = false) => {
|
|
1739
|
+
const v = MACHINE.maps.handshakeState[s] ?? null;
|
|
1740
|
+
return v === 'Open' && delivered ? 'Delivered' : v;
|
|
1741
|
+
},
|
|
1742
|
+
};
|
|
1743
|
+
/** fold events from a start state; stops at the first refusal and says where */
|
|
1744
|
+
export function run(events, ctx, start = MACHINE.initial) {
|
|
1745
|
+
let s = start;
|
|
1746
|
+
const path = [];
|
|
1747
|
+
for (let i = 0; i < events.length; i++) {
|
|
1748
|
+
const r = next(s, events[i], ctx);
|
|
1749
|
+
if (!r.ok)
|
|
1750
|
+
return { ok: false, state: s, path, at: i, error: r.error };
|
|
1751
|
+
if (r.transition)
|
|
1752
|
+
path.push({ from: s, to: r.state, transition: r.transition });
|
|
1753
|
+
s = r.state;
|
|
1754
|
+
}
|
|
1755
|
+
return { ok: true, state: s, path };
|
|
1756
|
+
}
|
|
1757
|
+
/** every way out of a state on this lane: who acts, and the deadline a timed exit waits for */
|
|
1758
|
+
export function whoCanEnd(state, ctx) {
|
|
1759
|
+
return exits(state, ctx).filter((t) => t.to !== state).map((t) => {
|
|
1760
|
+
const trig = triggerOf(t, ctx.lane);
|
|
1761
|
+
return { transition: t.id, to: t.to, actor: trig.actor, trigger: trig.type, after: t.timeout?.after ?? null, isDefault: !!t.timeout?.default };
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
/** no lockout: a held state has an exit nobody can block (a timeout, or a call anyone may send) */
|
|
1765
|
+
export function unblockable(state, ctx) {
|
|
1766
|
+
return whoCanEnd(state, ctx).find((e) => e.after !== null && (e.trigger === 'timeout' || /\banyone\b|\bnobody\b/.test(e.actor))) ?? null;
|
|
1767
|
+
}
|
|
1768
|
+
// ── endings ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
1769
|
+
const DELIVERED_STATES = ['Submitted', 'Graded', 'Held', 'RejectPending', 'Disputed'];
|
|
1770
|
+
/** the job reached the seller's delivery (a JobSubmitted, or a later state that needs one) */
|
|
1771
|
+
export const deliveredOf = (job) => DELIVERED_STATES.includes(job.state) || job.path.some((p) => DELIVERED_STATES.includes(p.to));
|
|
1772
|
+
/** money was held at some point (the job was funded) */
|
|
1773
|
+
export const fundedOf = (job) => holdsFunds(job.state) || job.path.some((p) => holdsFunds(p.to) && p.to !== 'Opened');
|
|
1774
|
+
/** how a job ended and the verdict it writes into the seller's record (transitions.json endings + exclusions) */
|
|
1775
|
+
export function endingOf(job) {
|
|
1776
|
+
const delivered = deliveredOf(job);
|
|
1777
|
+
const funded = fundedOf(job);
|
|
1778
|
+
let id;
|
|
1779
|
+
switch (job.state) {
|
|
1780
|
+
case 'Settled':
|
|
1781
|
+
id = 'completed';
|
|
1782
|
+
break;
|
|
1783
|
+
case 'Cheat':
|
|
1784
|
+
id = 'cheated';
|
|
1785
|
+
break;
|
|
1786
|
+
case 'Rejected':
|
|
1787
|
+
id = delivered ? 'rejected_delivered' : 'rejected_undelivered';
|
|
1788
|
+
break;
|
|
1789
|
+
case 'Expired':
|
|
1790
|
+
id = delivered ? 'expired_delivered' : 'expired_undelivered';
|
|
1791
|
+
break;
|
|
1792
|
+
case 'Cancelled':
|
|
1793
|
+
id = 'lapsed_unfunded';
|
|
1794
|
+
break;
|
|
1795
|
+
default: id = 'open';
|
|
1796
|
+
}
|
|
1797
|
+
const e = ENDINGS.find((x) => x.id === id);
|
|
1798
|
+
let excluded = e.verdict.startsWith('excluded:') ? e.verdict : null;
|
|
1799
|
+
const lane = job.ctx.lane;
|
|
1800
|
+
if (job.paid === false)
|
|
1801
|
+
excluded = 'excluded:unpaid';
|
|
1802
|
+
else if (!funded && (lane === 'memo-acp' || lane === 'erc8183-extra') && id === 'expired_undelivered')
|
|
1803
|
+
excluded = 'excluded:expired_unfunded';
|
|
1804
|
+
else if (!funded && (lane === 'memo-acp' || lane === 'erc8183-extra') && id === 'rejected_undelivered')
|
|
1805
|
+
excluded = 'excluded:rejected_unfunded';
|
|
1806
|
+
else if (!funded && lanesOf(lane).includes('hook') && job.path.some((p) => p.from === 'Opened') && id === 'expired_undelivered')
|
|
1807
|
+
excluded = 'excluded:expired_unfunded';
|
|
1808
|
+
return { id, state: e.state, verdict: excluded ?? e.verdict, countsInN: excluded ? false : e.countsInN, jevCase: e.jevCase, excluded };
|
|
1809
|
+
}
|
|
1810
|
+
/** what external cover does with an ending (transitions.json external_cover.endings): the policy's ending code */
|
|
1811
|
+
export function coverEndingOf(ending, o) {
|
|
1812
|
+
const pick = (id) => { const c = MACHINE.cover.endings.find((x) => x.id === id); return { id, code: c.code, pays: c.pays, premium: c.premium }; };
|
|
1813
|
+
if (o.sameParty || ending === 'lapsed_unfunded' || ending === 'open')
|
|
1814
|
+
return pick('VOID');
|
|
1815
|
+
if (o.refunded + o.refundable >= o.price && ending !== 'completed')
|
|
1816
|
+
return pick('REFUNDED');
|
|
1817
|
+
if (o.finding && ending !== 'expired_undelivered' && ending !== 'rejected_undelivered')
|
|
1818
|
+
return pick('DELIVERED_FINDING');
|
|
1819
|
+
if (ending === 'cheated')
|
|
1820
|
+
return pick('DELIVERED_FINDING');
|
|
1821
|
+
if (ending === 'expired_undelivered' || ending === 'rejected_undelivered')
|
|
1822
|
+
return pick('UNDELIVERED');
|
|
1823
|
+
if (ending === 'completed')
|
|
1824
|
+
return o.deliveredSomething === false ? pick('UNDELIVERED') : pick('COMPLETED');
|
|
1825
|
+
return pick('DELIVERED_NO_FINDING');
|
|
1826
|
+
}
|
|
1827
|
+
const sum = (l) => l.buyer + l.seller + l.backers + l.layer + l.evaluator;
|
|
1828
|
+
/** quote: the economy's terms, checked against the rules the contracts enforce; refusal over a term the chain would revert */
|
|
1829
|
+
export function quote(i, economy) {
|
|
1830
|
+
if (i.price <= 0n)
|
|
1831
|
+
return { ok: false, why: ['the price must be above zero'] };
|
|
1832
|
+
const q = economy(i);
|
|
1833
|
+
const why = [...q.why];
|
|
1834
|
+
if (!q.insurable)
|
|
1835
|
+
return { ok: false, why: why.length ? why : ['the seller is not insurable on this record'] };
|
|
1836
|
+
if (q.premium !== q.backersLeg + q.layerLeg)
|
|
1837
|
+
why.push(`the premium ${q.premium} is not the backers' leg ${q.backersLeg} plus the layer's leg ${q.layerLeg}`);
|
|
1838
|
+
if (q.layerLeg < q.jobFee)
|
|
1839
|
+
why.push(`the layer's leg ${q.layerLeg} is below the job fee ${q.jobFee}: the layer would work at a loss`);
|
|
1840
|
+
if (q.backersLeg < 0n)
|
|
1841
|
+
why.push('the backers\' leg is negative');
|
|
1842
|
+
if (i.attachment === 'hook' && q.deposit <= i.price)
|
|
1843
|
+
why.push(`the hook needs a deposit above the price (${q.deposit} ≤ ${i.price})`);
|
|
1844
|
+
if (q.compensation.noShow > q.deposit || q.compensation.rejection > q.deposit)
|
|
1845
|
+
why.push('a compensation is larger than the deposit it comes from');
|
|
1846
|
+
// external cover never pays more than the price; a hook line may cover a multiple of it (the economy's cover multiple)
|
|
1847
|
+
if (i.attachment === 'external-cover' && q.cover > i.price)
|
|
1848
|
+
why.push('external cover is larger than the price');
|
|
1849
|
+
for (const [end, l] of Object.entries(q.legs)) {
|
|
1850
|
+
const held = heldFor(end, i.price, q);
|
|
1851
|
+
if (sum(l) !== held)
|
|
1852
|
+
why.push(`${end}: the legs pay ${sum(l)}, the job holds ${held}`);
|
|
1853
|
+
if (Object.values(l).some((x) => x < 0n))
|
|
1854
|
+
why.push(`${end}: a negative leg`);
|
|
1855
|
+
}
|
|
1856
|
+
if (why.length)
|
|
1857
|
+
return { ok: false, why };
|
|
1858
|
+
return { ok: true, quote: q, terms: { token: i.token, price: i.price, premium: q.premium, backersLeg: q.backersLeg, layerLeg: q.layerLeg, jobFee: q.jobFee, deposit: q.deposit, cover: q.cover, compensation: q.compensation, attachment: i.attachment, lockSeconds: i.lockSeconds } };
|
|
1859
|
+
}
|
|
1860
|
+
/** what the job holds at an ending: the buyer's price, premium and fee, and the seller's deposit once it accepted.
|
|
1861
|
+
* A cheat's pool payout comes from outside the job (the pool), so it is added to what the legs may pay. */
|
|
1862
|
+
function heldFor(end, price, q) {
|
|
1863
|
+
const buyer = price + q.premium + q.jobFee;
|
|
1864
|
+
if (end === 'unaccepted')
|
|
1865
|
+
return buyer;
|
|
1866
|
+
return buyer + q.deposit + (end === 'cheated' ? q.cover : 0n);
|
|
1867
|
+
}
|
|
1868
|
+
/** buy: an assured job at its first held state, with the terms committed (no money moves here: the plan does) */
|
|
1869
|
+
export function buy(job, terms, opts = {}) {
|
|
1870
|
+
if (job.buyer.toLowerCase() === job.seller.toLowerCase())
|
|
1871
|
+
return { ok: false, why: ['the buyer is the seller'] };
|
|
1872
|
+
if (terms.attachment === 'none')
|
|
1873
|
+
return { ok: false, why: ['this venue has no assurance attachment'] };
|
|
1874
|
+
const lane = job.ctx.lane;
|
|
1875
|
+
const id = lanesOf(lane).includes('hook')
|
|
1876
|
+
? (opts.open && runsOn(TRANSITIONS.find((t) => t.id === 'open_v4'), job.ctx) ? 'open_v4' : 'fund_offer')
|
|
1877
|
+
: 'fund';
|
|
1878
|
+
const start = id === 'fund' ? 'Created' : 'Open';
|
|
1879
|
+
const r = next(start, { kind: 'transition', id }, { ...job.ctx, lane: lanesOf(lane).includes('hook') ? 'hook' : lane });
|
|
1880
|
+
if (!r.ok)
|
|
1881
|
+
return { ok: false, why: [r.error] };
|
|
1882
|
+
return { ok: true, transition: id, job: { ...job, terms, state: r.state, path: [{ from: start, to: r.state, transition: id }] } };
|
|
1883
|
+
}
|
|
1884
|
+
/** the money ending of a terminal job: which legs of the quote apply */
|
|
1885
|
+
export function moneyEndingOf(job) {
|
|
1886
|
+
const last = job.path.at(-1)?.transition ?? null;
|
|
1887
|
+
const e = endingOf({ ...job, paid: true });
|
|
1888
|
+
if (e.id === 'expired_undelivered' && job.path.some((p) => p.from === 'Opened') && !fundedOf(job))
|
|
1889
|
+
return 'unaccepted';
|
|
1890
|
+
if (!fundedOf(job))
|
|
1891
|
+
return null;
|
|
1892
|
+
switch (e.id) {
|
|
1893
|
+
case 'completed': return last && /auto_complete/.test(last) ? 'auto_completed' : 'completed';
|
|
1894
|
+
case 'cheated': return 'cheated';
|
|
1895
|
+
case 'rejected_delivered':
|
|
1896
|
+
case 'rejected_undelivered': return 'rejected';
|
|
1897
|
+
case 'expired_delivered': return 'expired_delivered';
|
|
1898
|
+
case 'expired_undelivered': return 'no_show';
|
|
1899
|
+
default: return null;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
/** settle: who receives what at this job's ending, from the committed quote; refused while the job is still open */
|
|
1903
|
+
export function settle(job, q) {
|
|
1904
|
+
if (!isTerminal(job.state))
|
|
1905
|
+
return { ok: false, why: [`the job is ${job.state}: not ended`, ...whoCanEnd(job.state, job.ctx).map((e) => `${e.transition}: ${e.actor}${e.after ? ` after ${e.after}` : ''}`)] };
|
|
1906
|
+
const money = moneyEndingOf(job);
|
|
1907
|
+
if (!money)
|
|
1908
|
+
return { ok: false, why: ['this ending moves no assured money (lapsed or unfunded)'] };
|
|
1909
|
+
const legs = q.legs[money];
|
|
1910
|
+
if (!legs)
|
|
1911
|
+
return { ok: false, why: [`the economy priced no ${money} ending`] };
|
|
1912
|
+
return { ok: true, ending: endingOf(job), money, legs };
|
|
1913
|
+
}
|
|
1914
|
+
/** claim: what each party may take out once the job settled (non-zero legs only) */
|
|
1915
|
+
export function claim(job, q) {
|
|
1916
|
+
const s = settle(job, q);
|
|
1917
|
+
if (!s.ok)
|
|
1918
|
+
return s;
|
|
1919
|
+
return { ok: true, claims: Object.entries(s.legs).filter(([, v]) => v > 0n).map(([who, amount]) => ({ who, amount })) };
|
|
1920
|
+
}
|
|
1921
|
+
/** the revenue hooks (phase-map) a venue's assurance earns through, with their phase and gate */
|
|
1922
|
+
export const revenueOf = (hooks) => MACHINE.revenueHooks.filter((r) => hooks.includes(r.hook));
|
|
1923
|
+
// ── attest.ts (profile moonbeam): src/attest.ts, import lines removed by scripts/sync.mjs ──
|
|
1924
|
+
/**
|
|
1925
|
+
* attest: the attested mark, the on-chain attestation and the stamp of one step (a grade, an assurance settle, a resale
|
|
1926
|
+
* step), as UNSIGNED calls aimed at a default network chosen by profile. _ATTEST_BY_DEFAULT_v1_
|
|
1927
|
+
*
|
|
1928
|
+
* ONE file with NO imports, pure and browser-safe, like assurance.ts: @taifoon/jev, @taifoon/assurance (and through its
|
|
1929
|
+
* sync, taifoon-sdk and moonbeam-sdk) carry a byte-identical copy and pin its hash. The addresses come from the address
|
|
1930
|
+
* registry (packages/addresses) through scripts/gen-attest.mjs; nothing below the generated block names an address.
|
|
1931
|
+
*
|
|
1932
|
+
* mark what is attested, offline: the step's kind, the subject ids (decision log + stamp registry) and the
|
|
1933
|
+
* digest = keccak256 of the canonical JSON body (or the digest the caller already has, e.g. Jev's).
|
|
1934
|
+
* attestation JevDecisionLog.record(subject, kind, digest, confidenceBps, model, uri) on every target network, after
|
|
1935
|
+
* JevAnswerLog.record(...) when the step carries Jev's answers.
|
|
1936
|
+
* stamp GradeStampRegistry.stamp(subject, digest, verdict, mode, model, uri) when the step has a verdict.
|
|
1937
|
+
*
|
|
1938
|
+
* Recording is ON by default (the owner's rule of 2026-10-14): profile taifoon → the Taifoon devnet 36927 and the Taifoon
|
|
1939
|
+
* mainnet 3692781 (GRID); profile moonbeam → Base 8453. Any network can be named instead; `networks: 'none'` opts out
|
|
1940
|
+
* (the mark is still returned). A contract the registry does not have on a target network is listed in `missing`, with
|
|
1941
|
+
* no call: nothing is faked. Nothing here signs or sends; the caller signs the calls.
|
|
1942
|
+
*/
|
|
1943
|
+
// ── GENERATED from packages/addresses/addresses.json by scripts/gen-attest.mjs: do not edit ──
|
|
1944
|
+
/** The attestation contracts on every chain the address registry has one on (superseded deploys left out). */
|
|
1945
|
+
export const ATTEST_TARGETS = {
|
|
1946
|
+
143: { name: 'Monad', decisionLog: '0x1aC6266b9926cB3E206D5dc0c9d1B7c873aa150a', answerLog: '0x29fEEc116e0CAbbaf38e9EBF2BBf65d82D672104', stampRegistry: null },
|
|
1947
|
+
5042: { name: 'Arc', decisionLog: '0x863db7dAc69CC614a98822082cbe884F1f3b55cA', answerLog: '0x45214361A8cADb8aEe6302cd5653E119E5a89839', stampRegistry: null },
|
|
1948
|
+
8453: { name: 'Base', decisionLog: '0x209490d6A0FFC5368A42b0c2208BDCda853f6a92', answerLog: '0x8e9B9cE86a2d55c10318607b0c815B7B8C66254d', stampRegistry: null },
|
|
1949
|
+
36927: { name: 'Taifoon devnet', decisionLog: '0x1D622511862DD7DEffB8fEeBc225E0FAdA1e9A05', answerLog: '0xD8c1d8188Fc8EE388792f6EB3B3dbd4f341Ba8e3', stampRegistry: '0xff5B4852AC7066D04FEd8de97bdA52401d03ad6E' },
|
|
1950
|
+
42161: { name: 'Arbitrum One', decisionLog: '0x1aC6266b9926cB3E206D5dc0c9d1B7c873aa150a', answerLog: '0x29fEEc116e0CAbbaf38e9EBF2BBf65d82D672104', stampRegistry: null },
|
|
1951
|
+
3692781: { name: 'Taifoon mainnet', decisionLog: null, answerLog: null, stampRegistry: null },
|
|
1952
|
+
};
|
|
1953
|
+
// ── END GENERATED ──
|
|
1954
|
+
/** The default networks per profile. Taifoon: its devnet and its mainnet (GRID). Moonbeam: Base only. */
|
|
1955
|
+
export const ATTEST_PROFILES = { taifoon: [36927, 3692781], moonbeam: [8453] };
|
|
1956
|
+
// ── keccak256 (the same code as packages/addresses/keccak.mjs; test/attest.test.ts checks known vectors) ──
|
|
1957
|
+
const KM = (1n << 64n) - 1n;
|
|
1958
|
+
const KRC = [
|
|
1959
|
+
0x0000000000000001n, 0x0000000000008082n, 0x800000000000808an, 0x8000000080008000n, 0x000000000000808bn, 0x0000000080000001n,
|
|
1960
|
+
0x8000000080008081n, 0x8000000000008009n, 0x000000000000008an, 0x0000000000000088n, 0x0000000080008009n, 0x000000008000000an,
|
|
1961
|
+
0x000000008000808bn, 0x800000000000008bn, 0x8000000000008089n, 0x8000000000008003n, 0x8000000000008002n, 0x8000000000000080n,
|
|
1962
|
+
0x000000000000800an, 0x800000008000000an, 0x8000000080008081n, 0x8000000000008080n, 0x0000000080000001n, 0x8000000080008008n,
|
|
1963
|
+
];
|
|
1964
|
+
const KR = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14];
|
|
1965
|
+
const krot = (v, n) => (n === 0 ? v : ((v << BigInt(n)) | (v >> BigInt(64 - n))) & KM);
|
|
1966
|
+
function kf(A) {
|
|
1967
|
+
const C = [0n, 0n, 0n, 0n, 0n];
|
|
1968
|
+
const B = new Array(25).fill(0n);
|
|
1969
|
+
const at = (a, i) => a[i];
|
|
1970
|
+
for (let round = 0; round < 24; round++) {
|
|
1971
|
+
for (let x = 0; x < 5; x++)
|
|
1972
|
+
C[x] = at(A, x) ^ at(A, x + 5) ^ at(A, x + 10) ^ at(A, x + 15) ^ at(A, x + 20);
|
|
1973
|
+
for (let x = 0; x < 5; x++) {
|
|
1974
|
+
const d = at(C, (x + 4) % 5) ^ krot(at(C, (x + 1) % 5), 1);
|
|
1975
|
+
for (let y = 0; y < 25; y += 5)
|
|
1976
|
+
A[x + y] = at(A, x + y) ^ d;
|
|
1977
|
+
}
|
|
1978
|
+
for (let x = 0; x < 5; x++)
|
|
1979
|
+
for (let y = 0; y < 5; y++)
|
|
1980
|
+
B[y + 5 * ((2 * x + 3 * y) % 5)] = krot(at(A, x + 5 * y), KR[x + 5 * y]);
|
|
1981
|
+
for (let x = 0; x < 5; x++)
|
|
1982
|
+
for (let y = 0; y < 5; y++)
|
|
1983
|
+
A[x + 5 * y] = at(B, x + 5 * y) ^ (~at(B, (x + 1) % 5 + 5 * y) & KM & at(B, (x + 2) % 5 + 5 * y));
|
|
1984
|
+
A[0] = at(A, 0) ^ KRC[round];
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
/** UTF-8 bytes of a string (no TextEncoder: the file runs where no DOM or Node lib is typed) */
|
|
1988
|
+
function utf8(s) {
|
|
1989
|
+
const out = [];
|
|
1990
|
+
for (const ch of s) {
|
|
1991
|
+
const c = ch.codePointAt(0);
|
|
1992
|
+
if (c < 0x80)
|
|
1993
|
+
out.push(c);
|
|
1994
|
+
else if (c < 0x800)
|
|
1995
|
+
out.push(0xc0 | (c >> 6), 0x80 | (c & 63));
|
|
1996
|
+
else if (c < 0x10000)
|
|
1997
|
+
out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
1998
|
+
else
|
|
1999
|
+
out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
2000
|
+
}
|
|
2001
|
+
return Uint8Array.from(out);
|
|
2002
|
+
}
|
|
2003
|
+
export function attestKeccak(input) {
|
|
2004
|
+
const bytes = typeof input === 'string' ? utf8(input) : input;
|
|
2005
|
+
const rate = 136;
|
|
2006
|
+
const A = new Array(25).fill(0n);
|
|
2007
|
+
const padded = new Uint8Array(Math.ceil((bytes.length + 1) / rate) * rate);
|
|
2008
|
+
padded.set(bytes);
|
|
2009
|
+
padded[bytes.length] = padded[bytes.length] ^ 0x01;
|
|
2010
|
+
padded[padded.length - 1] = padded[padded.length - 1] ^ 0x80;
|
|
2011
|
+
for (let off = 0; off < padded.length; off += rate) {
|
|
2012
|
+
for (let i = 0; i < rate / 8; i++) {
|
|
2013
|
+
let w = 0n;
|
|
2014
|
+
for (let b = 7; b >= 0; b--)
|
|
2015
|
+
w = (w << 8n) | BigInt(padded[off + i * 8 + b]);
|
|
2016
|
+
A[i] = A[i] ^ w;
|
|
2017
|
+
}
|
|
2018
|
+
kf(A);
|
|
2019
|
+
}
|
|
2020
|
+
let out = '0x';
|
|
2021
|
+
for (let i = 0; i < 4; i++)
|
|
2022
|
+
for (let b = 0; b < 8; b++)
|
|
2023
|
+
out += Number((A[i] >> BigInt(8 * b)) & 0xffn).toString(16).padStart(2, '0');
|
|
2024
|
+
return out;
|
|
2025
|
+
}
|
|
2026
|
+
// ── ABI encoding (only the types these three calls use) ──
|
|
2027
|
+
const hexOf = (b) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
|
|
2028
|
+
const bytesOf = (h) => { const s = h.replace(/^0x/, ''); const o = new Uint8Array(s.length / 2); for (let i = 0; i < o.length; i++)
|
|
2029
|
+
o[i] = parseInt(s.slice(i * 2, i * 2 + 2), 16); return o; };
|
|
2030
|
+
const word = (n) => { if (n < 0n || n >= 1n << 256n)
|
|
2031
|
+
throw new Error(`attest: ${n} does not fit a uint256`); return n.toString(16).padStart(64, '0'); };
|
|
2032
|
+
const isHex32 = (v) => /^0x[0-9a-fA-F]{64}$/.test(v);
|
|
2033
|
+
const isAddr = (v) => /^0x[0-9a-fA-F]{40}$/.test(v);
|
|
2034
|
+
function encodeArgs(args) {
|
|
2035
|
+
let head = '';
|
|
2036
|
+
let tail = '';
|
|
2037
|
+
const headLen = args.length * 32;
|
|
2038
|
+
for (const a of args) {
|
|
2039
|
+
if (a.t === 'string') {
|
|
2040
|
+
const b = utf8(String(a.v));
|
|
2041
|
+
head += word(BigInt(headLen + tail.length / 2));
|
|
2042
|
+
tail += word(BigInt(b.length)) + hexOf(b).padEnd(Math.ceil(b.length / 32) * 64, '0');
|
|
2043
|
+
}
|
|
2044
|
+
else if (a.t === 'bytes32') {
|
|
2045
|
+
if (!isHex32(String(a.v)))
|
|
2046
|
+
throw new Error(`attest: ${a.v} is not a bytes32`);
|
|
2047
|
+
head += String(a.v).slice(2).toLowerCase();
|
|
2048
|
+
}
|
|
2049
|
+
else if (a.t === 'address') {
|
|
2050
|
+
if (!isAddr(String(a.v)))
|
|
2051
|
+
throw new Error(`attest: ${a.v} is not an address`);
|
|
2052
|
+
head += String(a.v).slice(2).toLowerCase().padStart(64, '0');
|
|
2053
|
+
}
|
|
2054
|
+
else
|
|
2055
|
+
head += word(BigInt(a.v));
|
|
2056
|
+
}
|
|
2057
|
+
return head + tail;
|
|
2058
|
+
}
|
|
2059
|
+
const selector = (sig) => attestKeccak(sig).slice(2, 10);
|
|
2060
|
+
const call = (sig, args) => `0x${selector(sig)}${encodeArgs(args)}`;
|
|
2061
|
+
export const DECISION_LOG_RECORD_SIG = 'record(bytes32,bytes32,bytes32,uint16,string,string)';
|
|
2062
|
+
export const ANSWER_LOG_RECORD_SIG = 'record(bytes32,bytes32,bytes32,bytes32,bytes32,string,string)';
|
|
2063
|
+
export const STAMP_SIG = 'stamp(bytes32,bytes32,uint8,uint8,string,string)';
|
|
2064
|
+
/** canonical JSON: sorted keys, bigint as a decimal string, no whitespace (the digest's preimage) */
|
|
2065
|
+
export function attestCanonical(v) {
|
|
2066
|
+
if (typeof v === 'bigint')
|
|
2067
|
+
return JSON.stringify(v.toString());
|
|
2068
|
+
if (v === null || typeof v !== 'object')
|
|
2069
|
+
return JSON.stringify(v ?? null);
|
|
2070
|
+
if (Array.isArray(v))
|
|
2071
|
+
return `[${v.map(attestCanonical).join(',')}]`;
|
|
2072
|
+
const o = v;
|
|
2073
|
+
return `{${Object.keys(o).filter((k) => o[k] !== undefined).sort().map((k) => `${JSON.stringify(k)}:${attestCanonical(o[k])}`).join(',')}}`;
|
|
2074
|
+
}
|
|
2075
|
+
const jobRef = (id) => (typeof id === 'string' && isHex32(id) ? id : `0x${word(BigInt(id))}`);
|
|
2076
|
+
/** JevDecisionLog.subjectOf(chainId, at, ref) = keccak256(abi.encode("taifoon.decision.subject.v1", chainId, at, ref)) */
|
|
2077
|
+
export const decisionSubjectOf = (chainId, at, ref) => attestKeccak(bytesOf(encodeArgs([{ t: 'string', v: 'taifoon.decision.subject.v1' }, { t: 'uint', v: chainId }, { t: 'address', v: at }, { t: 'bytes32', v: jobRef(ref) }])));
|
|
2078
|
+
/** GradeStampRegistry.subjectOf(chainId, jobContract, jobId) = keccak256(abi.encode("taifoon.stamp.subject.v1", …)) */
|
|
2079
|
+
export const stampSubjectOf = (chainId, jobContract, jobId) => attestKeccak(bytesOf(encodeArgs([{ t: 'string', v: 'taifoon.stamp.subject.v1' }, { t: 'uint', v: chainId }, { t: 'address', v: jobContract }, { t: 'bytes32', v: jobRef(jobId) }])));
|
|
2080
|
+
/** the stamp verdict of a settled ending, from the seller-record verdict the machine writes (endingOf): correct → 1;
|
|
2081
|
+
* a Jev case (rejected or expired after delivery) → 4, it takes a grade to say more; incorrect → 3; excluded → no stamp */
|
|
2082
|
+
export function stampVerdictOfEnding(e) {
|
|
2083
|
+
if (e.excluded)
|
|
2084
|
+
return null;
|
|
2085
|
+
if (e.verdict === 'correct')
|
|
2086
|
+
return 1;
|
|
2087
|
+
if (e.jevCase || e.verdict === 'undecided')
|
|
2088
|
+
return 4;
|
|
2089
|
+
if (e.verdict === 'incorrect')
|
|
2090
|
+
return 3;
|
|
2091
|
+
return null;
|
|
2092
|
+
}
|
|
2093
|
+
/** the mark, the attestation calls and the stamp call of one step, on the profile's networks (or the ones named) */
|
|
2094
|
+
export function attest(input, opts = {}) {
|
|
2095
|
+
const { subject } = input;
|
|
2096
|
+
if (!isAddr(subject.contract))
|
|
2097
|
+
throw new Error(`attest: subject.contract ${subject.contract} is not an address`);
|
|
2098
|
+
if (!input.kind)
|
|
2099
|
+
throw new Error('attest: a kind names the step');
|
|
2100
|
+
const digest = input.digest ?? attestKeccak(attestCanonical(input.body ?? null));
|
|
2101
|
+
if (!isHex32(digest) || /^0x0{64}$/.test(digest))
|
|
2102
|
+
throw new Error('attest: the digest must be a non-zero bytes32');
|
|
2103
|
+
const confidenceBps = input.confidenceBps ?? 10_000;
|
|
2104
|
+
if (!Number.isInteger(confidenceBps) || confidenceBps < 0 || confidenceBps > 10_000)
|
|
2105
|
+
throw new Error(`attest: confidenceBps ${confidenceBps} is not 0..10000`);
|
|
2106
|
+
const model = input.model;
|
|
2107
|
+
if (!model || utf8(model).length > 64)
|
|
2108
|
+
throw new Error('attest: model is 1..64 bytes');
|
|
2109
|
+
const uri = input.uri ?? `urn:taifoon:${input.kind}:${digest}`;
|
|
2110
|
+
if (utf8(uri).length > 512)
|
|
2111
|
+
throw new Error('attest: uri is ≤ 512 bytes');
|
|
2112
|
+
const verdict = input.verdict ?? null;
|
|
2113
|
+
const mode = input.mode ?? 1;
|
|
2114
|
+
if (verdict !== null && ![1, 2, 3, 4].includes(verdict))
|
|
2115
|
+
throw new Error(`attest: verdict ${verdict} is not 1..4`);
|
|
2116
|
+
const kindId = attestKeccak(input.kind);
|
|
2117
|
+
const mark = { kind: input.kind, kindId, subject: decisionSubjectOf(subject.chainId, subject.contract, subject.jobId), stampSubject: stampSubjectOf(subject.chainId, subject.contract, subject.jobId), digest, confidenceBps, verdict, model, uri };
|
|
2118
|
+
if (opts.networks === 'none')
|
|
2119
|
+
return { mark, recorded: false, networks: [], calls: [], missing: [], status: 'none' };
|
|
2120
|
+
const networks = [...(opts.networks ?? ATTEST_PROFILES[opts.profile ?? 'taifoon'])];
|
|
2121
|
+
const calls = [];
|
|
2122
|
+
const missing = [];
|
|
2123
|
+
for (const chainId of networks) {
|
|
2124
|
+
const t = { name: `chain ${chainId}`, decisionLog: null, answerLog: null, stampRegistry: null, ...ATTEST_TARGETS[chainId], ...opts.targets?.[chainId] };
|
|
2125
|
+
const gap = (contract) => missing.push({ chainId, network: t.name, contract, why: `no ${contract} on ${t.name} (${chainId}) in the address registry` });
|
|
2126
|
+
// the answers first, then the decision that cites them (the order the layer's recorder sends)
|
|
2127
|
+
if (input.answers) {
|
|
2128
|
+
if (t.answerLog)
|
|
2129
|
+
calls.push({ chainId, to: t.answerLog, value: '0', fn: 'JevAnswerLog.record', data: call(ANSWER_LOG_RECORD_SIG, [{ t: 'bytes32', v: attestKeccak(input.answers.useCase) }, { t: 'bytes32', v: mark.subject }, { t: 'bytes32', v: input.answers.inputDigest }, { t: 'bytes32', v: input.answers.answersDigest }, { t: 'bytes32', v: digest }, { t: 'string', v: model }, { t: 'string', v: input.answers.uri ?? uri }]) });
|
|
2130
|
+
else
|
|
2131
|
+
gap('JevAnswerLog');
|
|
2132
|
+
}
|
|
2133
|
+
if (t.decisionLog)
|
|
2134
|
+
calls.push({ chainId, to: t.decisionLog, value: '0', fn: 'JevDecisionLog.record', data: call(DECISION_LOG_RECORD_SIG, [{ t: 'bytes32', v: mark.subject }, { t: 'bytes32', v: kindId }, { t: 'bytes32', v: digest }, { t: 'uint', v: confidenceBps }, { t: 'string', v: model }, { t: 'string', v: uri }]) });
|
|
2135
|
+
else
|
|
2136
|
+
gap('JevDecisionLog');
|
|
2137
|
+
if (verdict !== null) {
|
|
2138
|
+
if (t.stampRegistry)
|
|
2139
|
+
calls.push({ chainId, to: t.stampRegistry, value: '0', fn: 'GradeStampRegistry.stamp', data: call(STAMP_SIG, [{ t: 'bytes32', v: mark.stampSubject }, { t: 'bytes32', v: digest }, { t: 'uint', v: verdict }, { t: 'uint', v: mode }, { t: 'string', v: model }, { t: 'string', v: uri }]) });
|
|
2140
|
+
else
|
|
2141
|
+
gap('GradeStampRegistry');
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
const status = missing.length === 0 ? 'ready' : calls.length === 0 ? 'missing' : 'partial';
|
|
2145
|
+
return { mark, recorded: true, networks, calls, missing, status };
|
|
2146
|
+
}
|
|
2147
|
+
/** the canonical body a settle attests: the job, its ending and the legs (bigint amounts as decimal strings) */
|
|
2148
|
+
export const settleBodyOf = (job, contract, s) => ({
|
|
2149
|
+
v: 'assurance.settle.v1', chainId: job.chainId, contract: contract.toLowerCase(), jobId: String(job.jobId), venue: job.venue,
|
|
2150
|
+
ending: s.ending.id, verdict: s.ending.verdict, money: s.money, legs: s.legs,
|
|
2151
|
+
});
|
|
2152
|
+
/** settle() and the attestation of its result; refused exactly when settle() refuses */
|
|
2153
|
+
export function settleAttested(job, q, opts) {
|
|
2154
|
+
const s = settle(job, q);
|
|
2155
|
+
if (!s.ok)
|
|
2156
|
+
return s;
|
|
2157
|
+
const a = attest({
|
|
2158
|
+
kind: 'assurance.settle', subject: { chainId: job.chainId, contract: opts.contract, jobId: job.jobId },
|
|
2159
|
+
body: settleBodyOf(job, opts.contract, s), model: opts.model ?? 'det:assurance-settle-v1', uri: opts.uri,
|
|
2160
|
+
verdict: stampVerdictOfEnding(s.ending), mode: 1,
|
|
2161
|
+
}, opts);
|
|
2162
|
+
return { ...s, attest: a };
|
|
2163
|
+
}
|
|
2164
|
+
/** the venue's trail as machine events: event names pass through; phases, hook states and handshake states become states */
|
|
2165
|
+
export function eventsOf(trail) {
|
|
2166
|
+
const out = [];
|
|
2167
|
+
for (const s of trail) {
|
|
2168
|
+
if (typeof s.phase === 'number') {
|
|
2169
|
+
const to = stateOf.memoPhase(s.phase);
|
|
2170
|
+
if (to)
|
|
2171
|
+
out.push({ kind: 'state', to });
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
if (typeof s.hookState === 'number') {
|
|
2175
|
+
const to = stateOf.hook(s.hookState);
|
|
2176
|
+
if (to)
|
|
2177
|
+
out.push({ kind: 'state', to });
|
|
2178
|
+
continue;
|
|
2179
|
+
}
|
|
2180
|
+
if (s.handshake) {
|
|
2181
|
+
const to = stateOf.handshake(s.handshake, s.delivered);
|
|
2182
|
+
if (to)
|
|
2183
|
+
out.push({ kind: 'state', to });
|
|
2184
|
+
continue;
|
|
2185
|
+
}
|
|
2186
|
+
out.push({ kind: 'event', name: s.name });
|
|
2187
|
+
}
|
|
2188
|
+
return out;
|
|
2189
|
+
}
|
|
2190
|
+
/** the revenue hooks of phase-map, by name (a typo fails the adapter test) */
|
|
2191
|
+
export const knownHook = (h) => MACHINE.revenueHooks.some((r) => r.hook === h);
|
|
2192
|
+
// The first reseller: Moonbeam Protocol's ACP assurance on Base, GLMR only, mapped read only.
|
|
2193
|
+
const MOONBEAM_HELD = 'GLMR in Moonbeam\'s hook: the buyer\'s price and premium, the seller\'s deposit; the cover reserved in the seller\'s GLMR CoveragePool';
|
|
2194
|
+
export const moonbeamVenue = {
|
|
2195
|
+
id: 'moonbeam',
|
|
2196
|
+
name: 'Moonbeam ACP (reseller, GLMR)',
|
|
2197
|
+
status: 'read-only',
|
|
2198
|
+
ctx: { lane: 'hook', hook: 'V3' },
|
|
2199
|
+
chains: [
|
|
2200
|
+
{ chainId: 8453, escrow: { system: 'moonbeam-acp', chain: 8453, name: 'AssuranceHook (proxy)' }, status: 'read-only' },
|
|
2201
|
+
],
|
|
2202
|
+
payment: 'The buyer funds the job in GLMR on Base: price and premium into Moonbeam\'s hook, the seller\'s GLMR deposit beside it, the cover reserved in the seller\'s GLMR pool. Completion pays the seller price + deposit and the premium to the pool; expiry or a rejection returns the buyer\'s GLMR; an adjudicated cheat pays the buyer from the deposit, then the pool. Every amount is GLMR from the job\'s own numbers: no price feed on the money path.',
|
|
2203
|
+
asset: 'GLMR only',
|
|
2204
|
+
moneyAt: { Funded: MOONBEAM_HELD, Submitted: MOONBEAM_HELD, Graded: `${MOONBEAM_HELD}; the grade is off chain until a call sends it`, Held: `${MOONBEAM_HELD}; waits on the evaluator Moonbeam registers` },
|
|
2205
|
+
refund: { rule: 'hook', how: 'the hook returns the buyer\'s GLMR at expiry (anyone, after the deadline) and at a rejection (V3: immediate, the buyer\'s own call)' },
|
|
2206
|
+
attach: [
|
|
2207
|
+
{ kind: 'hook-cover', how: 'Moonbeam\'s own hook and GLMR pools (its contracts, its governance)' },
|
|
2208
|
+
{ kind: 'grade', how: 'a Jev grade of a Moonbeam job, paid by the caller (the hook stores an evidence digest; the task spec must be committed at funding for a grade to show spec met)' },
|
|
2209
|
+
{ kind: 'proof', how: 'a V5 receipt proof of the hook\'s events on Base' },
|
|
2210
|
+
],
|
|
2211
|
+
revenue: [
|
|
2212
|
+
{ hook: 'grades_pay_to_key', how: 'the Jev grade of a Moonbeam job past the free ones, paid by the caller' },
|
|
2213
|
+
],
|
|
2214
|
+
observe: { index: 'the coordination layer\'s index of hook jobs on Base (its /v1 job reads)', adapter: 'the job trail; the hook State enum through stateOf.hook', reads: ['JobFunded', 'JobCovered', 'Submitted', 'Completed', 'Rejected', 'Expired', 'Cheated', 'PremiumReceived', 'Encumbered'] },
|
|
2215
|
+
coverVenue: null,
|
|
2216
|
+
publicWrites: false,
|
|
2217
|
+
needs: [
|
|
2218
|
+
'The GLMR pools are not open. Moonbeam ACP is in a pilot with selected partners: builders@moonbeam.foundation',
|
|
2219
|
+
'a protocol fee on this line is set by Moonbeam governance; none today',
|
|
2220
|
+
'this hook has no named evaluator and no dispute window: those endings need a newer hook',
|
|
2221
|
+
],
|
|
2222
|
+
};
|
|
2223
|
+
/** the venues of this profile (moonbeam) */
|
|
2224
|
+
export const VENUES = Object.fromEntries([moonbeamVenue].map((v) => [v.id, v]));
|
|
2225
|
+
//# sourceMappingURL=assurance-shared.js.map
|