@shippedcalls/sdk 0.3.1 → 0.5.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 +72 -13
- package/dist/abi.d.ts +1328 -0
- package/dist/abi.js +1703 -0
- package/dist/abi.js.map +1 -1
- package/dist/assets.d.ts +34 -0
- package/dist/assets.js +48 -0
- package/dist/assets.js.map +1 -0
- package/dist/chain.d.ts +4 -0
- package/dist/chain.js +4 -0
- package/dist/chain.js.map +1 -1
- package/dist/cli.js +121 -38
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +112 -17
- package/dist/client.js +279 -69
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +33 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +588 -0
- package/dist/jobs.js +347 -0
- package/dist/jobs.js.map +1 -0
- package/dist/odds.d.ts +7 -6
- package/dist/odds.js +13 -12
- package/dist/odds.js.map +1 -1
- package/dist/types.d.ts +90 -30
- package/package.json +3 -3
- package/skill/SKILL.md +25 -14
- package/skill/references/api.md +30 -12
- package/skill/references/funding.md +4 -2
- package/skill/references/jobs.md +30 -0
- package/skill/references/settlement.md +5 -2
- package/skill/references/write-path.md +30 -2
- package/skill/scripts/calls.sh +1 -1
- package/src/abi.ts +1705 -0
- package/src/assets.ts +65 -0
- package/src/chain.ts +4 -0
- package/src/cli.ts +118 -39
- package/src/client.ts +297 -71
- package/src/errors.ts +35 -3
- package/src/index.ts +4 -2
- package/src/jobs.ts +467 -0
- package/src/odds.ts +13 -12
- package/src/types.ts +77 -26
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import { type Abi, type Account, type Address, type Hash, type Hex, type PublicClient, type TransactionReceipt } from "viem";
|
|
2
|
+
import type { Tx } from "./types.js";
|
|
3
|
+
export declare const USDG_DECIMALS = 6;
|
|
4
|
+
export declare const MAX_TITLE = 96;
|
|
5
|
+
export declare const MAX_MILESTONE = 2048;
|
|
6
|
+
export declare const MIN_LEAD = 600;
|
|
7
|
+
export declare const MIN_WINDOW = 3600;
|
|
8
|
+
export declare const MAX_WINDOW: number;
|
|
9
|
+
export declare const DEFAULT_REVIEW_WINDOW: number;
|
|
10
|
+
/** The council makes three model calls a case, so a job it reviews pays for them. */
|
|
11
|
+
export declare const COUNCIL_MIN_FEE = 250000n;
|
|
12
|
+
/** The registry pays a reviewer at most a tenth of what the job holds. */
|
|
13
|
+
export declare const MAX_REVIEWER_SHARE_DIVISOR = 10n;
|
|
14
|
+
/** The most one `fund` or `open` may lock unless the caller raises it, in USDG units. */
|
|
15
|
+
export declare const DEFAULT_MAX_JOB_FUND = 25000000n;
|
|
16
|
+
export declare const deedsAbi: readonly [{
|
|
17
|
+
readonly name: "create";
|
|
18
|
+
readonly type: "function";
|
|
19
|
+
readonly stateMutability: "nonpayable";
|
|
20
|
+
readonly inputs: readonly [{
|
|
21
|
+
readonly type: "tuple";
|
|
22
|
+
readonly components: readonly [{
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly name: "title";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly name: "milestone";
|
|
28
|
+
}, {
|
|
29
|
+
readonly type: "address";
|
|
30
|
+
readonly name: "project";
|
|
31
|
+
}, {
|
|
32
|
+
readonly type: "uint8";
|
|
33
|
+
readonly name: "projectKind";
|
|
34
|
+
}, {
|
|
35
|
+
readonly type: "address";
|
|
36
|
+
readonly name: "asset";
|
|
37
|
+
}, {
|
|
38
|
+
readonly type: "uint64";
|
|
39
|
+
readonly name: "deadline";
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: "address";
|
|
42
|
+
readonly name: "verifier";
|
|
43
|
+
}, {
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
readonly name: "backupVerifier";
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
readonly name: "appealPanel";
|
|
49
|
+
}, {
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
readonly name: "check";
|
|
52
|
+
}, {
|
|
53
|
+
readonly type: "bytes";
|
|
54
|
+
readonly name: "checkData";
|
|
55
|
+
}, {
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
readonly name: "refundTo";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "uint16";
|
|
60
|
+
readonly name: "defaultRemainderBps";
|
|
61
|
+
}, {
|
|
62
|
+
readonly type: "uint16";
|
|
63
|
+
readonly name: "refundCapBps";
|
|
64
|
+
}, {
|
|
65
|
+
readonly type: "bool";
|
|
66
|
+
readonly name: "allowPartial";
|
|
67
|
+
}, {
|
|
68
|
+
readonly type: "uint32";
|
|
69
|
+
readonly name: "verifierGrace";
|
|
70
|
+
}, {
|
|
71
|
+
readonly type: "uint32";
|
|
72
|
+
readonly name: "backupGrace";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "uint32";
|
|
75
|
+
readonly name: "appealWindow";
|
|
76
|
+
}, {
|
|
77
|
+
readonly type: "uint32";
|
|
78
|
+
readonly name: "panelWindow";
|
|
79
|
+
}, {
|
|
80
|
+
readonly type: "uint128";
|
|
81
|
+
readonly name: "appealBond";
|
|
82
|
+
}, {
|
|
83
|
+
readonly type: "uint128";
|
|
84
|
+
readonly name: "verifierFee";
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "address[]";
|
|
87
|
+
readonly name: "refundExcluded";
|
|
88
|
+
}];
|
|
89
|
+
readonly name: "t";
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "uint256";
|
|
92
|
+
readonly name: "deposit";
|
|
93
|
+
}];
|
|
94
|
+
readonly outputs: readonly [{
|
|
95
|
+
readonly type: "uint256";
|
|
96
|
+
readonly name: "deedId";
|
|
97
|
+
}];
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "fund";
|
|
100
|
+
readonly type: "function";
|
|
101
|
+
readonly stateMutability: "nonpayable";
|
|
102
|
+
readonly inputs: readonly [{
|
|
103
|
+
readonly type: "uint256";
|
|
104
|
+
readonly name: "deedId";
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "uint256";
|
|
107
|
+
readonly name: "amount";
|
|
108
|
+
}];
|
|
109
|
+
readonly outputs: readonly [];
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "postEvidence";
|
|
112
|
+
readonly type: "function";
|
|
113
|
+
readonly stateMutability: "nonpayable";
|
|
114
|
+
readonly inputs: readonly [{
|
|
115
|
+
readonly type: "uint256";
|
|
116
|
+
readonly name: "deedId";
|
|
117
|
+
}, {
|
|
118
|
+
readonly type: "string";
|
|
119
|
+
readonly name: "uri";
|
|
120
|
+
}, {
|
|
121
|
+
readonly type: "bytes32";
|
|
122
|
+
readonly name: "contentHash";
|
|
123
|
+
}];
|
|
124
|
+
readonly outputs: readonly [];
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "rule";
|
|
127
|
+
readonly type: "function";
|
|
128
|
+
readonly stateMutability: "nonpayable";
|
|
129
|
+
readonly inputs: readonly [{
|
|
130
|
+
readonly type: "uint256";
|
|
131
|
+
readonly name: "deedId";
|
|
132
|
+
}, {
|
|
133
|
+
readonly type: "uint16";
|
|
134
|
+
readonly name: "remainderBps";
|
|
135
|
+
}, {
|
|
136
|
+
readonly type: "string";
|
|
137
|
+
readonly name: "reason";
|
|
138
|
+
}];
|
|
139
|
+
readonly outputs: readonly [];
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "concede";
|
|
142
|
+
readonly type: "function";
|
|
143
|
+
readonly stateMutability: "nonpayable";
|
|
144
|
+
readonly inputs: readonly [{
|
|
145
|
+
readonly type: "uint256";
|
|
146
|
+
readonly name: "deedId";
|
|
147
|
+
}, {
|
|
148
|
+
readonly type: "string";
|
|
149
|
+
readonly name: "reason";
|
|
150
|
+
}];
|
|
151
|
+
readonly outputs: readonly [];
|
|
152
|
+
}, {
|
|
153
|
+
readonly name: "settleDefault";
|
|
154
|
+
readonly type: "function";
|
|
155
|
+
readonly stateMutability: "nonpayable";
|
|
156
|
+
readonly inputs: readonly [{
|
|
157
|
+
readonly type: "uint256";
|
|
158
|
+
readonly name: "deedId";
|
|
159
|
+
}];
|
|
160
|
+
readonly outputs: readonly [];
|
|
161
|
+
}, {
|
|
162
|
+
readonly name: "withdrawFor";
|
|
163
|
+
readonly type: "function";
|
|
164
|
+
readonly stateMutability: "nonpayable";
|
|
165
|
+
readonly inputs: readonly [{
|
|
166
|
+
readonly type: "address";
|
|
167
|
+
readonly name: "account";
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "address";
|
|
170
|
+
readonly name: "asset";
|
|
171
|
+
}];
|
|
172
|
+
readonly outputs: readonly [{
|
|
173
|
+
readonly type: "uint256";
|
|
174
|
+
}];
|
|
175
|
+
}, {
|
|
176
|
+
readonly name: "getDeed";
|
|
177
|
+
readonly type: "function";
|
|
178
|
+
readonly stateMutability: "view";
|
|
179
|
+
readonly inputs: readonly [{
|
|
180
|
+
readonly type: "uint256";
|
|
181
|
+
readonly name: "deedId";
|
|
182
|
+
}];
|
|
183
|
+
readonly outputs: readonly [{
|
|
184
|
+
readonly type: "tuple";
|
|
185
|
+
readonly components: readonly [{
|
|
186
|
+
readonly type: "address";
|
|
187
|
+
readonly name: "creator";
|
|
188
|
+
}, {
|
|
189
|
+
readonly type: "uint8";
|
|
190
|
+
readonly name: "status";
|
|
191
|
+
}, {
|
|
192
|
+
readonly type: "uint8";
|
|
193
|
+
readonly name: "ruling";
|
|
194
|
+
}, {
|
|
195
|
+
readonly type: "uint16";
|
|
196
|
+
readonly name: "remainderBps";
|
|
197
|
+
}, {
|
|
198
|
+
readonly type: "uint16";
|
|
199
|
+
readonly name: "feeBps";
|
|
200
|
+
}, {
|
|
201
|
+
readonly type: "bool";
|
|
202
|
+
readonly name: "overturned";
|
|
203
|
+
}, {
|
|
204
|
+
readonly type: "uint64";
|
|
205
|
+
readonly name: "createdAt";
|
|
206
|
+
}, {
|
|
207
|
+
readonly type: "uint64";
|
|
208
|
+
readonly name: "ruledAt";
|
|
209
|
+
}, {
|
|
210
|
+
readonly type: "uint64";
|
|
211
|
+
readonly name: "appealedAt";
|
|
212
|
+
}, {
|
|
213
|
+
readonly type: "uint64";
|
|
214
|
+
readonly name: "settledAt";
|
|
215
|
+
}, {
|
|
216
|
+
readonly type: "uint64";
|
|
217
|
+
readonly name: "checkMetAt";
|
|
218
|
+
}, {
|
|
219
|
+
readonly type: "uint64";
|
|
220
|
+
readonly name: "windowEnd";
|
|
221
|
+
}, {
|
|
222
|
+
readonly type: "address";
|
|
223
|
+
readonly name: "ruledBy";
|
|
224
|
+
}, {
|
|
225
|
+
readonly type: "address";
|
|
226
|
+
readonly name: "appellant";
|
|
227
|
+
}, {
|
|
228
|
+
readonly type: "uint256";
|
|
229
|
+
readonly name: "balance";
|
|
230
|
+
}, {
|
|
231
|
+
readonly name: "terms";
|
|
232
|
+
readonly type: "tuple";
|
|
233
|
+
readonly components: readonly [{
|
|
234
|
+
readonly type: "string";
|
|
235
|
+
readonly name: "title";
|
|
236
|
+
}, {
|
|
237
|
+
readonly type: "string";
|
|
238
|
+
readonly name: "milestone";
|
|
239
|
+
}, {
|
|
240
|
+
readonly type: "address";
|
|
241
|
+
readonly name: "project";
|
|
242
|
+
}, {
|
|
243
|
+
readonly type: "uint8";
|
|
244
|
+
readonly name: "projectKind";
|
|
245
|
+
}, {
|
|
246
|
+
readonly type: "address";
|
|
247
|
+
readonly name: "asset";
|
|
248
|
+
}, {
|
|
249
|
+
readonly type: "uint64";
|
|
250
|
+
readonly name: "deadline";
|
|
251
|
+
}, {
|
|
252
|
+
readonly type: "address";
|
|
253
|
+
readonly name: "verifier";
|
|
254
|
+
}, {
|
|
255
|
+
readonly type: "address";
|
|
256
|
+
readonly name: "backupVerifier";
|
|
257
|
+
}, {
|
|
258
|
+
readonly type: "address";
|
|
259
|
+
readonly name: "appealPanel";
|
|
260
|
+
}, {
|
|
261
|
+
readonly type: "address";
|
|
262
|
+
readonly name: "check";
|
|
263
|
+
}, {
|
|
264
|
+
readonly type: "bytes";
|
|
265
|
+
readonly name: "checkData";
|
|
266
|
+
}, {
|
|
267
|
+
readonly type: "address";
|
|
268
|
+
readonly name: "refundTo";
|
|
269
|
+
}, {
|
|
270
|
+
readonly type: "uint16";
|
|
271
|
+
readonly name: "defaultRemainderBps";
|
|
272
|
+
}, {
|
|
273
|
+
readonly type: "uint16";
|
|
274
|
+
readonly name: "refundCapBps";
|
|
275
|
+
}, {
|
|
276
|
+
readonly type: "bool";
|
|
277
|
+
readonly name: "allowPartial";
|
|
278
|
+
}, {
|
|
279
|
+
readonly type: "uint32";
|
|
280
|
+
readonly name: "verifierGrace";
|
|
281
|
+
}, {
|
|
282
|
+
readonly type: "uint32";
|
|
283
|
+
readonly name: "backupGrace";
|
|
284
|
+
}, {
|
|
285
|
+
readonly type: "uint32";
|
|
286
|
+
readonly name: "appealWindow";
|
|
287
|
+
}, {
|
|
288
|
+
readonly type: "uint32";
|
|
289
|
+
readonly name: "panelWindow";
|
|
290
|
+
}, {
|
|
291
|
+
readonly type: "uint128";
|
|
292
|
+
readonly name: "appealBond";
|
|
293
|
+
}, {
|
|
294
|
+
readonly type: "uint128";
|
|
295
|
+
readonly name: "verifierFee";
|
|
296
|
+
}, {
|
|
297
|
+
readonly type: "address[]";
|
|
298
|
+
readonly name: "refundExcluded";
|
|
299
|
+
}];
|
|
300
|
+
}];
|
|
301
|
+
}];
|
|
302
|
+
}, {
|
|
303
|
+
readonly name: "owed";
|
|
304
|
+
readonly type: "function";
|
|
305
|
+
readonly stateMutability: "view";
|
|
306
|
+
readonly inputs: readonly [{
|
|
307
|
+
readonly type: "address";
|
|
308
|
+
readonly name: "account";
|
|
309
|
+
}, {
|
|
310
|
+
readonly type: "address";
|
|
311
|
+
readonly name: "asset";
|
|
312
|
+
}];
|
|
313
|
+
readonly outputs: readonly [{
|
|
314
|
+
readonly type: "uint256";
|
|
315
|
+
}];
|
|
316
|
+
}, {
|
|
317
|
+
readonly name: "timeline";
|
|
318
|
+
readonly type: "function";
|
|
319
|
+
readonly stateMutability: "view";
|
|
320
|
+
readonly inputs: readonly [{
|
|
321
|
+
readonly type: "uint256";
|
|
322
|
+
readonly name: "deedId";
|
|
323
|
+
}];
|
|
324
|
+
readonly outputs: readonly [{
|
|
325
|
+
readonly type: "uint64";
|
|
326
|
+
readonly name: "deadline";
|
|
327
|
+
}, {
|
|
328
|
+
readonly type: "uint64";
|
|
329
|
+
readonly name: "verifierEnd";
|
|
330
|
+
}, {
|
|
331
|
+
readonly type: "uint64";
|
|
332
|
+
readonly name: "backupEnd";
|
|
333
|
+
}, {
|
|
334
|
+
readonly type: "uint64";
|
|
335
|
+
readonly name: "defaultAt";
|
|
336
|
+
}, {
|
|
337
|
+
readonly type: "uint64";
|
|
338
|
+
readonly name: "appealEnd";
|
|
339
|
+
}, {
|
|
340
|
+
readonly type: "uint64";
|
|
341
|
+
readonly name: "panelEnd";
|
|
342
|
+
}];
|
|
343
|
+
}, {
|
|
344
|
+
readonly name: "AssetNotAllowed";
|
|
345
|
+
readonly type: "error";
|
|
346
|
+
readonly inputs: readonly [];
|
|
347
|
+
}, {
|
|
348
|
+
readonly name: "CreationIsPaused";
|
|
349
|
+
readonly type: "error";
|
|
350
|
+
readonly inputs: readonly [];
|
|
351
|
+
}, {
|
|
352
|
+
readonly name: "InvalidDeadline";
|
|
353
|
+
readonly type: "error";
|
|
354
|
+
readonly inputs: readonly [];
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "InvalidEvidence";
|
|
357
|
+
readonly type: "error";
|
|
358
|
+
readonly inputs: readonly [];
|
|
359
|
+
}, {
|
|
360
|
+
readonly name: "InvalidMilestone";
|
|
361
|
+
readonly type: "error";
|
|
362
|
+
readonly inputs: readonly [];
|
|
363
|
+
}, {
|
|
364
|
+
readonly name: "InvalidRefund";
|
|
365
|
+
readonly type: "error";
|
|
366
|
+
readonly inputs: readonly [];
|
|
367
|
+
}, {
|
|
368
|
+
readonly name: "InvalidSplit";
|
|
369
|
+
readonly type: "error";
|
|
370
|
+
readonly inputs: readonly [];
|
|
371
|
+
}, {
|
|
372
|
+
readonly name: "InvalidTitle";
|
|
373
|
+
readonly type: "error";
|
|
374
|
+
readonly inputs: readonly [];
|
|
375
|
+
}, {
|
|
376
|
+
readonly name: "InvalidVerifier";
|
|
377
|
+
readonly type: "error";
|
|
378
|
+
readonly inputs: readonly [];
|
|
379
|
+
}, {
|
|
380
|
+
readonly name: "InvalidWindow";
|
|
381
|
+
readonly type: "error";
|
|
382
|
+
readonly inputs: readonly [];
|
|
383
|
+
}, {
|
|
384
|
+
readonly name: "NotCreator";
|
|
385
|
+
readonly type: "error";
|
|
386
|
+
readonly inputs: readonly [];
|
|
387
|
+
}, {
|
|
388
|
+
readonly name: "NotOpen";
|
|
389
|
+
readonly type: "error";
|
|
390
|
+
readonly inputs: readonly [];
|
|
391
|
+
}, {
|
|
392
|
+
readonly name: "NotPoster";
|
|
393
|
+
readonly type: "error";
|
|
394
|
+
readonly inputs: readonly [];
|
|
395
|
+
}, {
|
|
396
|
+
readonly name: "NotVerifier";
|
|
397
|
+
readonly type: "error";
|
|
398
|
+
readonly inputs: readonly [];
|
|
399
|
+
}, {
|
|
400
|
+
readonly name: "NothingOwed";
|
|
401
|
+
readonly type: "error";
|
|
402
|
+
readonly inputs: readonly [];
|
|
403
|
+
}, {
|
|
404
|
+
readonly name: "TooEarly";
|
|
405
|
+
readonly type: "error";
|
|
406
|
+
readonly inputs: readonly [];
|
|
407
|
+
}, {
|
|
408
|
+
readonly name: "TransferMismatch";
|
|
409
|
+
readonly type: "error";
|
|
410
|
+
readonly inputs: readonly [];
|
|
411
|
+
}, {
|
|
412
|
+
readonly name: "UnknownDeed";
|
|
413
|
+
readonly type: "error";
|
|
414
|
+
readonly inputs: readonly [];
|
|
415
|
+
}, {
|
|
416
|
+
readonly name: "WindowClosed";
|
|
417
|
+
readonly type: "error";
|
|
418
|
+
readonly inputs: readonly [];
|
|
419
|
+
}];
|
|
420
|
+
export interface JobTerms {
|
|
421
|
+
title: string;
|
|
422
|
+
milestone: string;
|
|
423
|
+
project: Address;
|
|
424
|
+
projectKind: number;
|
|
425
|
+
asset: Address;
|
|
426
|
+
deadline: bigint;
|
|
427
|
+
verifier: Address;
|
|
428
|
+
backupVerifier: Address;
|
|
429
|
+
appealPanel: Address;
|
|
430
|
+
check: Address;
|
|
431
|
+
checkData: Hex;
|
|
432
|
+
refundTo: Address;
|
|
433
|
+
defaultRemainderBps: number;
|
|
434
|
+
refundCapBps: number;
|
|
435
|
+
allowPartial: boolean;
|
|
436
|
+
verifierGrace: number;
|
|
437
|
+
backupGrace: number;
|
|
438
|
+
appealWindow: number;
|
|
439
|
+
panelWindow: number;
|
|
440
|
+
appealBond: bigint;
|
|
441
|
+
verifierFee: bigint;
|
|
442
|
+
refundExcluded: readonly Address[];
|
|
443
|
+
}
|
|
444
|
+
/** What the registry returns for a deed. */
|
|
445
|
+
export interface ChainDeed {
|
|
446
|
+
creator: Address;
|
|
447
|
+
status: number;
|
|
448
|
+
ruling: number;
|
|
449
|
+
remainderBps: number;
|
|
450
|
+
balance: bigint;
|
|
451
|
+
terms: JobTerms;
|
|
452
|
+
}
|
|
453
|
+
export interface OpenJobInput {
|
|
454
|
+
title: string;
|
|
455
|
+
/** What will be delivered and how anyone can tell. Stored on chain; the reviewer judges against it. */
|
|
456
|
+
brief: string;
|
|
457
|
+
/** The wallet that will fund the job and gets the money back if it is rejected or runs out. */
|
|
458
|
+
client: string;
|
|
459
|
+
/** What the client locks, in USDG units (6 decimals). */
|
|
460
|
+
amount: bigint;
|
|
461
|
+
/** When the work is due, unix seconds. */
|
|
462
|
+
deadline: number;
|
|
463
|
+
/** Who accepts or rejects the work: an address, or `council` for Shipped's three-model council. */
|
|
464
|
+
reviewer: string;
|
|
465
|
+
/** Seconds the reviewer has after the deadline. Three days by default. */
|
|
466
|
+
reviewWindow?: number;
|
|
467
|
+
/** Paid to the reviewer from the job when its ruling stands, USDG units. 0.25 USDG at least for the council. */
|
|
468
|
+
reviewerFee?: bigint;
|
|
469
|
+
/** What the worker locks on its own side. It is lost to the client if the job fails. */
|
|
470
|
+
workerBond?: bigint;
|
|
471
|
+
}
|
|
472
|
+
/** What the client agreed to, for `check` and `fund` to compare against what the worker actually opened. */
|
|
473
|
+
export interface JobAgreement {
|
|
474
|
+
amount: bigint;
|
|
475
|
+
/** Every reviewer the client accepts: addresses, or `council`. */
|
|
476
|
+
reviewers: readonly string[];
|
|
477
|
+
worker?: string;
|
|
478
|
+
/** The client. The connected wallet by default. */
|
|
479
|
+
client?: string;
|
|
480
|
+
/** The latest deadline the client accepts, unix seconds. */
|
|
481
|
+
notAfter?: number;
|
|
482
|
+
/** The largest reviewer fee the client accepts, USDG units. A tenth of the amount by default. */
|
|
483
|
+
maxReviewerFee?: bigint;
|
|
484
|
+
/** The least the worker must have locked, USDG units. */
|
|
485
|
+
minWorkerBond?: bigint;
|
|
486
|
+
}
|
|
487
|
+
export interface JobProblem {
|
|
488
|
+
code: string;
|
|
489
|
+
message: string;
|
|
490
|
+
}
|
|
491
|
+
export type JobState = "awaiting_funds" | "in_progress" | "in_review" | "refundable" | "ruled" | "paid" | "partly_paid" | "refunded";
|
|
492
|
+
export interface Job {
|
|
493
|
+
id: string;
|
|
494
|
+
number: number;
|
|
495
|
+
url: string | null;
|
|
496
|
+
title: string;
|
|
497
|
+
brief: string;
|
|
498
|
+
worker: Address;
|
|
499
|
+
client: Address;
|
|
500
|
+
reviewer: Address;
|
|
501
|
+
asset: Address;
|
|
502
|
+
amount: string;
|
|
503
|
+
workerBond: string;
|
|
504
|
+
reviewerFee: string;
|
|
505
|
+
escrow: string;
|
|
506
|
+
funded: boolean;
|
|
507
|
+
deadline: number;
|
|
508
|
+
/** When anyone can refund the client if the reviewer has stayed silent. */
|
|
509
|
+
refundableAt: number;
|
|
510
|
+
state: JobState;
|
|
511
|
+
}
|
|
512
|
+
export interface JobTx {
|
|
513
|
+
id: string;
|
|
514
|
+
tx: Tx;
|
|
515
|
+
}
|
|
516
|
+
/** A decimal USDG string as units. */
|
|
517
|
+
export declare function usdgToUnits(amount: string, what?: string): bigint;
|
|
518
|
+
export declare const jobMilestone: (brief: string, amount: bigint, bond: bigint) => string;
|
|
519
|
+
/** The brief, amount and worker bond from a milestone, or null when the milestone is not a job's. */
|
|
520
|
+
export declare function readJobTag(milestone: string): {
|
|
521
|
+
brief: string;
|
|
522
|
+
amount: bigint;
|
|
523
|
+
bond: bigint;
|
|
524
|
+
} | null;
|
|
525
|
+
/** The registry's bond number on Shipped's site. */
|
|
526
|
+
export declare const bondNumberOf: (id: bigint | number, chainId?: number) => number;
|
|
527
|
+
/** The terms a job opens with. Refuses anything the registry would, before anything is sent. */
|
|
528
|
+
export declare function jobTerms(input: OpenJobInput, { worker, now }: {
|
|
529
|
+
worker: string;
|
|
530
|
+
now: number;
|
|
531
|
+
}): JobTerms;
|
|
532
|
+
/** Every way a job differs from what the client agreed to. An empty list means it is safe to fund. */
|
|
533
|
+
export declare function checkJob(deed: ChainDeed, agreement: JobAgreement, { client, now }: {
|
|
534
|
+
client: string;
|
|
535
|
+
now: number;
|
|
536
|
+
}): JobProblem[];
|
|
537
|
+
export declare function jobStateOf(deed: ChainDeed, refundableAt: number, now: number): JobState;
|
|
538
|
+
export interface JobsDeps {
|
|
539
|
+
reads: PublicClient;
|
|
540
|
+
chainId: number;
|
|
541
|
+
send: (params: {
|
|
542
|
+
address: Address;
|
|
543
|
+
abi: Abi;
|
|
544
|
+
functionName: string;
|
|
545
|
+
args?: unknown[];
|
|
546
|
+
}) => Promise<TransactionReceipt>;
|
|
547
|
+
guarded: <T>(work: () => Promise<T>) => Promise<T>;
|
|
548
|
+
wallet: () => Account;
|
|
549
|
+
toTx: (receipt: TransactionReceipt) => Tx;
|
|
550
|
+
maxFund: bigint;
|
|
551
|
+
registry?: Address;
|
|
552
|
+
}
|
|
553
|
+
export declare function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFund, registry }: JobsDeps): {
|
|
554
|
+
/** One job as the chain has it. */
|
|
555
|
+
get: (jobId: unknown) => Promise<Job>;
|
|
556
|
+
/** Worker: opens the job and locks its own bond, if any. Hand the id to the client to fund. */
|
|
557
|
+
open: (input: OpenJobInput, { maxFund: limit }?: {
|
|
558
|
+
maxFund?: bigint;
|
|
559
|
+
}) => Promise<JobTx>;
|
|
560
|
+
/** Client: every way the job differs from what you agreed to. Spends nothing. */
|
|
561
|
+
check: (jobId: unknown, agreement: JobAgreement) => Promise<{
|
|
562
|
+
ok: boolean;
|
|
563
|
+
problems: JobProblem[];
|
|
564
|
+
}>;
|
|
565
|
+
/** Client: locks the agreed amount, and only if the job passes `check`. */
|
|
566
|
+
fund: (jobId: unknown, agreement: JobAgreement, { maxFund: limit }?: {
|
|
567
|
+
maxFund?: bigint;
|
|
568
|
+
}) => Promise<JobTx & {
|
|
569
|
+
amount: string;
|
|
570
|
+
}>;
|
|
571
|
+
/** Worker or reviewer: points at what was delivered. */
|
|
572
|
+
evidence: (jobId: unknown, uri: string, contentHash?: Hash) => Promise<JobTx>;
|
|
573
|
+
/** Reviewer: the work was delivered. Pays the worker at once. */
|
|
574
|
+
accept: (jobId: unknown, reason?: string) => Promise<JobTx>;
|
|
575
|
+
/** Reviewer: the work was not delivered. Opens at the deadline; refunds the client at once. */
|
|
576
|
+
reject: (jobId: unknown, reason: string) => Promise<JobTx>;
|
|
577
|
+
/** Worker: gives up. The client gets everything the job holds, at once. */
|
|
578
|
+
concede: (jobId: unknown, reason: string) => Promise<JobTx>;
|
|
579
|
+
/** Anyone: the reviewer stayed silent past its window, so the client is refunded. */
|
|
580
|
+
refund: (jobId: unknown) => Promise<JobTx>;
|
|
581
|
+
/** What a wallet can collect in USDG across settled jobs and bonds. */
|
|
582
|
+
owed: (address?: string) => Promise<string>;
|
|
583
|
+
/** Sends this wallet what it can collect. */
|
|
584
|
+
collect: () => Promise<{
|
|
585
|
+
tx: Tx;
|
|
586
|
+
}>;
|
|
587
|
+
};
|
|
588
|
+
export type JobsClient = ReturnType<typeof createJobs>;
|