@avow-finance/spec 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +119 -2
- package/dist/agent-connect.d.ts +90 -0
- package/dist/agent-connect.d.ts.map +1 -0
- package/dist/agent-connect.js +102 -0
- package/dist/agent-connect.js.map +1 -0
- package/dist/agent-session.d.ts +791 -0
- package/dist/agent-session.d.ts.map +1 -0
- package/dist/agent-session.js +176 -0
- package/dist/agent-session.js.map +1 -0
- package/dist/ap2.d.ts +79 -0
- package/dist/ap2.d.ts.map +1 -0
- package/dist/ap2.js +151 -0
- package/dist/ap2.js.map +1 -0
- package/dist/api-request.d.ts +144 -0
- package/dist/api-request.d.ts.map +1 -0
- package/dist/api-request.js +246 -0
- package/dist/api-request.js.map +1 -0
- package/dist/api.d.ts +288 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +332 -0
- package/dist/api.js.map +1 -0
- package/dist/canonical.d.ts +22 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +66 -0
- package/dist/canonical.js.map +1 -0
- package/dist/commitment-card.d.ts +78 -0
- package/dist/commitment-card.d.ts.map +1 -0
- package/dist/commitment-card.js +224 -0
- package/dist/commitment-card.js.map +1 -0
- package/dist/commitment.d.ts +185 -0
- package/dist/commitment.d.ts.map +1 -0
- package/dist/commitment.js +148 -0
- package/dist/commitment.js.map +1 -0
- package/dist/compute-offers.d.ts +128 -0
- package/dist/compute-offers.d.ts.map +1 -0
- package/dist/compute-offers.js +111 -0
- package/dist/compute-offers.js.map +1 -0
- package/dist/contest.d.ts +88 -0
- package/dist/contest.d.ts.map +1 -0
- package/dist/contest.js +131 -0
- package/dist/contest.js.map +1 -0
- package/dist/demo.d.ts +69 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +152 -0
- package/dist/demo.js.map +1 -0
- package/dist/dependencies.d.ts +308 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +133 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/eip712.d.ts +1569 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +550 -0
- package/dist/eip712.js.map +1 -0
- package/dist/elided-terms.d.ts +37 -0
- package/dist/elided-terms.d.ts.map +1 -0
- package/dist/elided-terms.js +48 -0
- package/dist/elided-terms.js.map +1 -0
- package/dist/erc8183.d.ts +78 -0
- package/dist/erc8183.d.ts.map +1 -0
- package/dist/erc8183.js +88 -0
- package/dist/erc8183.js.map +1 -0
- package/dist/facts.d.ts +70 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +33 -0
- package/dist/facts.js.map +1 -0
- package/dist/gpu-reservation.d.ts +79 -0
- package/dist/gpu-reservation.d.ts.map +1 -0
- package/dist/gpu-reservation.js +135 -0
- package/dist/gpu-reservation.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/job-session.d.ts +981 -0
- package/dist/job-session.d.ts.map +1 -0
- package/dist/job-session.js +170 -0
- package/dist/job-session.js.map +1 -0
- package/dist/job-verification.d.ts +244 -0
- package/dist/job-verification.d.ts.map +1 -0
- package/dist/job-verification.js +89 -0
- package/dist/job-verification.js.map +1 -0
- package/dist/job-wording.d.ts +48 -0
- package/dist/job-wording.d.ts.map +1 -0
- package/dist/job-wording.js +134 -0
- package/dist/job-wording.js.map +1 -0
- package/dist/job.d.ts +117 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +166 -0
- package/dist/job.js.map +1 -0
- package/dist/json-fields.d.ts +13 -0
- package/dist/json-fields.d.ts.map +1 -0
- package/dist/json-fields.js +30 -0
- package/dist/json-fields.js.map +1 -0
- package/dist/keychain.d.ts +51 -0
- package/dist/keychain.d.ts.map +1 -0
- package/dist/keychain.js +133 -0
- package/dist/keychain.js.map +1 -0
- package/dist/mailbox.d.ts +1650 -0
- package/dist/mailbox.d.ts.map +1 -0
- package/dist/mailbox.js +87 -0
- package/dist/mailbox.js.map +1 -0
- package/dist/mandate.d.ts +53 -0
- package/dist/mandate.d.ts.map +1 -0
- package/dist/mandate.js +97 -0
- package/dist/mandate.js.map +1 -0
- package/dist/networks.d.ts +18 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +24 -0
- package/dist/networks.js.map +1 -0
- package/dist/profiles.d.ts +31 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +33 -0
- package/dist/profiles.js.map +1 -0
- package/dist/rail.d.ts +48 -0
- package/dist/rail.d.ts.map +1 -0
- package/dist/rail.js +28 -0
- package/dist/rail.js.map +1 -0
- package/dist/reasons.d.ts +173 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +174 -0
- package/dist/reasons.js.map +1 -0
- package/dist/reference-link.d.ts +23 -0
- package/dist/reference-link.d.ts.map +1 -0
- package/dist/reference-link.js +56 -0
- package/dist/reference-link.js.map +1 -0
- package/dist/references.d.ts +125 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +108 -0
- package/dist/references.js.map +1 -0
- package/dist/replay.d.ts +30 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +27 -0
- package/dist/replay.js.map +1 -0
- package/dist/sandbox-registration.d.ts +200 -0
- package/dist/sandbox-registration.d.ts.map +1 -0
- package/dist/sandbox-registration.js +172 -0
- package/dist/sandbox-registration.js.map +1 -0
- package/dist/sandbox.d.ts +3478 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +316 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/session-fields.d.ts +203 -0
- package/dist/session-fields.d.ts.map +1 -0
- package/dist/session-fields.js +43 -0
- package/dist/session-fields.js.map +1 -0
- package/dist/supplier-adapter.d.ts +65 -0
- package/dist/supplier-adapter.d.ts.map +1 -0
- package/dist/supplier-adapter.js +91 -0
- package/dist/supplier-adapter.js.map +1 -0
- package/dist/terms-v1.d.ts +74 -0
- package/dist/terms-v1.d.ts.map +1 -0
- package/dist/terms-v1.js +156 -0
- package/dist/terms-v1.js.map +1 -0
- package/dist/terms.d.ts +341 -0
- package/dist/terms.d.ts.map +1 -0
- package/dist/terms.js +715 -0
- package/dist/terms.js.map +1 -0
- package/dist/test-customer.d.ts +1525 -0
- package/dist/test-customer.d.ts.map +1 -0
- package/dist/test-customer.js +260 -0
- package/dist/test-customer.js.map +1 -0
- package/dist/types.d.ts +272 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +51 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +66 -0
- package/dist/version.js.map +1 -0
- package/dist/wire.d.ts +2698 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +678 -0
- package/dist/wire.js.map +1 -0
- package/package.json +37 -3
- package/vectors/api-request-v1.json +53 -0
- package/vectors/contest-statement-v1.json +42 -0
- package/vectors/terms-v2.json +398 -0
- package/vectors/terms-v3.json +2103 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-session.d.ts","sourceRoot":"","sources":["../src/job-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAgB,KAAK,UAAU,EAAmB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAiHpB,CAAA;AAEV,gFAAgF;AAChF,eAAO,MAAM,eAAe,mYAkBoB,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { checkedDependencyJson, dependencyIndexJson, MAX_DEPENDENCIES, pinnedBlockJson, } from './dependencies.js';
|
|
3
|
+
import { CHARGE_KINDS, RELEASE_REASONS } from './eip712.js';
|
|
4
|
+
import { bytes32, u64, u256 } from './json-fields.js';
|
|
5
|
+
import { commitmentReferenceJson, } from './references.js';
|
|
6
|
+
import { agentSourceJson, reasonCodeJson, runJson } from './session-fields.js';
|
|
7
|
+
import { customerRefusalJson, deliveryReportJson, jobCustomerJson, jobRequirementJson, orderIdJson, } from './test-customer.js';
|
|
8
|
+
import { jobSubjectJson, paymentReferenceJson } from './wire.js';
|
|
9
|
+
/**
|
|
10
|
+
* Who refused the customer's commitment on the developer's side. `service` is the developer's own
|
|
11
|
+
* check, which the job process runs for its service. `avow` is Avow's API declining to authorize
|
|
12
|
+
* the commitment for the developer's business, as for a reserve it doesn't see funded. `relay` and
|
|
13
|
+
* `lock` refused the acceptance on its way to the customer's lock.
|
|
14
|
+
*/
|
|
15
|
+
export const COMMITMENT_REFUSAL_LAYERS = ['service', 'avow', 'relay', 'lock'];
|
|
16
|
+
/**
|
|
17
|
+
* How long a business waits after a customer's cancellation before it reports the charge, in
|
|
18
|
+
* seconds. Avow confirms a late-cancellation charge from its own record of the cancellation, and
|
|
19
|
+
* only when that record shows the cancellation clearly before the report, on Avow's clock and on
|
|
20
|
+
* the chain's. A report filed sooner goes to a ruling.
|
|
21
|
+
*/
|
|
22
|
+
export const REPORT_AFTER_CANCELLATION = 45n;
|
|
23
|
+
/**
|
|
24
|
+
* Why a reported charge waits for a ruling. `contested` is the customer's contest of a confirmed
|
|
25
|
+
* charge, `referred` is Avow sending the report to a ruling since its records don't support it, and
|
|
26
|
+
* `unanswered` is a report Avow didn't answer before its deadline.
|
|
27
|
+
*/
|
|
28
|
+
export const CHARGE_PAUSE_CAUSES = ['contested', 'referred', 'unanswered'];
|
|
29
|
+
const base = { run: runJson, source: agentSourceJson, orderId: orderIdJson };
|
|
30
|
+
const checks = z.array(checkedDependencyJson).max(MAX_DEPENDENCIES);
|
|
31
|
+
const chargeKind = z.enum(Object.keys(CHARGE_KINDS));
|
|
32
|
+
const releaseReason = z.enum(Object.keys(RELEASE_REASONS));
|
|
33
|
+
/** Each job event's JSON form, which the session's event schema takes alongside its own. */
|
|
34
|
+
export const JOB_EVENT_SCHEMAS = [
|
|
35
|
+
z.strictObject({
|
|
36
|
+
...base,
|
|
37
|
+
type: z.literal('job_order_received'),
|
|
38
|
+
customer: jobCustomerJson,
|
|
39
|
+
work: jobSubjectJson.shape.work,
|
|
40
|
+
price: u256,
|
|
41
|
+
deliverBy: u64,
|
|
42
|
+
requirement: jobRequirementJson,
|
|
43
|
+
}),
|
|
44
|
+
z.strictObject({
|
|
45
|
+
...base,
|
|
46
|
+
type: z.literal('job_compute_secured'),
|
|
47
|
+
reference: commitmentReferenceJson,
|
|
48
|
+
supplier: z.string().min(1).max(100),
|
|
49
|
+
amount: u256,
|
|
50
|
+
freeCancelBy: u64,
|
|
51
|
+
releaseDate: u64,
|
|
52
|
+
}),
|
|
53
|
+
z.strictObject({
|
|
54
|
+
...base,
|
|
55
|
+
type: z.literal('job_quote_sent'),
|
|
56
|
+
termsHash: bytes32,
|
|
57
|
+
compute: commitmentReferenceJson.nullable(),
|
|
58
|
+
price: u256,
|
|
59
|
+
}),
|
|
60
|
+
z.strictObject({ ...base, type: z.literal('job_customer_verifying') }),
|
|
61
|
+
z.strictObject({ ...base, type: z.literal('job_customer_verified'), checks }),
|
|
62
|
+
z.strictObject({
|
|
63
|
+
...base,
|
|
64
|
+
type: z.literal('job_customer_refused'),
|
|
65
|
+
refusal: customerRefusalJson,
|
|
66
|
+
}),
|
|
67
|
+
z.strictObject({
|
|
68
|
+
...base,
|
|
69
|
+
type: z.literal('job_commitment_checked'),
|
|
70
|
+
reference: commitmentReferenceJson,
|
|
71
|
+
amount: u256,
|
|
72
|
+
charges: z
|
|
73
|
+
.array(z.strictObject({ kind: chargeKind, amount: u256 }))
|
|
74
|
+
.min(1)
|
|
75
|
+
.max(4),
|
|
76
|
+
releaseDate: u64,
|
|
77
|
+
checks,
|
|
78
|
+
acceptedIn: z.strictObject({ transactionHash: bytes32, blockNumber: u64 }).nullable(),
|
|
79
|
+
}),
|
|
80
|
+
z.strictObject({
|
|
81
|
+
...base,
|
|
82
|
+
type: z.literal('job_commitment_refused'),
|
|
83
|
+
code: reasonCodeJson,
|
|
84
|
+
layer: z.enum(COMMITMENT_REFUSAL_LAYERS),
|
|
85
|
+
block: pinnedBlockJson.nullable(),
|
|
86
|
+
index: dependencyIndexJson,
|
|
87
|
+
}),
|
|
88
|
+
z.strictObject({
|
|
89
|
+
...base,
|
|
90
|
+
type: z.literal('job_work_started'),
|
|
91
|
+
reference: commitmentReferenceJson,
|
|
92
|
+
}),
|
|
93
|
+
z.strictObject({
|
|
94
|
+
...base,
|
|
95
|
+
type: z.literal('job_delivered'),
|
|
96
|
+
reference: commitmentReferenceJson,
|
|
97
|
+
result: deliveryReportJson.shape.result,
|
|
98
|
+
}),
|
|
99
|
+
z.strictObject({ ...base, type: z.literal('job_paid'), payment: paymentReferenceJson }),
|
|
100
|
+
z.strictObject({
|
|
101
|
+
...base,
|
|
102
|
+
type: z.literal('job_customer_cancelled'),
|
|
103
|
+
reference: commitmentReferenceJson,
|
|
104
|
+
cancelledAt: u64,
|
|
105
|
+
}),
|
|
106
|
+
z.strictObject({
|
|
107
|
+
...base,
|
|
108
|
+
type: z.literal('job_charge_reported'),
|
|
109
|
+
reference: commitmentReferenceJson,
|
|
110
|
+
kind: chargeKind,
|
|
111
|
+
amount: u256,
|
|
112
|
+
reportNumber: z.number().int().min(1).max(2),
|
|
113
|
+
transactionHash: bytes32,
|
|
114
|
+
}),
|
|
115
|
+
z.strictObject({
|
|
116
|
+
...base,
|
|
117
|
+
type: z.literal('job_charge_confirmed'),
|
|
118
|
+
reference: commitmentReferenceJson,
|
|
119
|
+
amount: u256,
|
|
120
|
+
contestableUntil: u64,
|
|
121
|
+
}),
|
|
122
|
+
z.strictObject({
|
|
123
|
+
...base,
|
|
124
|
+
type: z.literal('job_charge_paused'),
|
|
125
|
+
reference: commitmentReferenceJson,
|
|
126
|
+
cause: z.enum(CHARGE_PAUSE_CAUSES),
|
|
127
|
+
}),
|
|
128
|
+
z.strictObject({
|
|
129
|
+
...base,
|
|
130
|
+
type: z.literal('job_charge_paid'),
|
|
131
|
+
reference: commitmentReferenceJson,
|
|
132
|
+
amount: u256,
|
|
133
|
+
}),
|
|
134
|
+
z.strictObject({
|
|
135
|
+
...base,
|
|
136
|
+
type: z.literal('job_reserve_released'),
|
|
137
|
+
role: z.enum(['job', 'compute']),
|
|
138
|
+
reference: commitmentReferenceJson,
|
|
139
|
+
release: z.discriminatedUnion('way', [
|
|
140
|
+
z.strictObject({ way: z.literal('consent'), reason: releaseReason }),
|
|
141
|
+
z.strictObject({ way: z.literal('free_cancellation') }),
|
|
142
|
+
z.strictObject({ way: z.literal('release_date') }),
|
|
143
|
+
z.strictObject({ way: z.literal('unaccepted') }),
|
|
144
|
+
]),
|
|
145
|
+
transactionHash: bytes32,
|
|
146
|
+
}),
|
|
147
|
+
];
|
|
148
|
+
/** Every job event type, in the order a job that runs to the end posts them. */
|
|
149
|
+
export const JOB_EVENT_TYPES = [
|
|
150
|
+
'job_order_received',
|
|
151
|
+
'job_compute_secured',
|
|
152
|
+
'job_quote_sent',
|
|
153
|
+
'job_customer_verifying',
|
|
154
|
+
'job_customer_verified',
|
|
155
|
+
'job_customer_refused',
|
|
156
|
+
'job_commitment_checked',
|
|
157
|
+
'job_commitment_refused',
|
|
158
|
+
'job_work_started',
|
|
159
|
+
'job_delivered',
|
|
160
|
+
'job_paid',
|
|
161
|
+
'job_customer_cancelled',
|
|
162
|
+
'job_charge_reported',
|
|
163
|
+
'job_charge_confirmed',
|
|
164
|
+
'job_charge_paused',
|
|
165
|
+
'job_charge_paid',
|
|
166
|
+
'job_reserve_released',
|
|
167
|
+
];
|
|
168
|
+
const _sameTypes = true;
|
|
169
|
+
void _sameTypes;
|
|
170
|
+
//# sourceMappingURL=job-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-session.js","sourceRoot":"","sources":["../src/job-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAEL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAEhB,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,YAAY,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G,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;YACpE,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACvD,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;SACjD,CAAC;QACF,eAAe,EAAE,OAAO;KACzB,CAAC;CACM,CAAA;AAEV,gFAAgF;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,oBAAoB;IACpB,qBAAqB;IACrB,gBAAgB;IAChB,wBAAwB;IACxB,uBAAuB;IACvB,sBAAsB;IACtB,wBAAwB;IACxB,wBAAwB;IACxB,kBAAkB;IAClB,eAAe;IACf,UAAU;IACV,wBAAwB;IACxB,qBAAqB;IACrB,sBAAsB;IACtB,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;CACwB,CAAA;AAIhD,MAAM,UAAU,GAEY,IAAI,CAAA;AAChC,KAAK,UAAU,CAAA"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type Dependencies } from './dependencies.js';
|
|
4
|
+
import { type ChainedJobTerms, JOB, type JobDependencyCheck } from './job.js';
|
|
5
|
+
import type { ReasonCode } from './reasons.js';
|
|
6
|
+
import { type CommitmentReference } from './references.js';
|
|
7
|
+
import { type ChainedTermsHeader, type TermsSection } from './terms.js';
|
|
8
|
+
import { type Parsed } from './wire.js';
|
|
9
|
+
/**
|
|
10
|
+
* What a link to verify a job carries, so a browser can see which booking the job relies on. A
|
|
11
|
+
* commitment reference alone names only the job's terms hash. This adds the terms' header, the
|
|
12
|
+
* dependencies section in clear with that section's own salt, and every other section's hash. The
|
|
13
|
+
* browser recomputes the terms hash from these, matches it against the reference and the lock's,
|
|
14
|
+
* and reads the booking the dependencies section names at a block it pins.
|
|
15
|
+
*
|
|
16
|
+
* Only the dependencies section is shown. Each section's salt comes from the terms' salt, and one
|
|
17
|
+
* section's salt reveals neither the terms' salt nor any other section. So the link doesn't show
|
|
18
|
+
* the job's subject, with its work, compute and deadline, or its price. Once the job is paid, the
|
|
19
|
+
* payment transfer shows the price, since its memo is the commitment id. The lock already shows
|
|
20
|
+
* anyone what it enforces for the job: the reserve, each charge's cap and the moment it becomes
|
|
21
|
+
* chargeable, the deadlines, the contest window and the release date. Free cancellation ends when
|
|
22
|
+
* work starts, so the lock shows the start too.
|
|
23
|
+
*/
|
|
24
|
+
export interface JobVerification {
|
|
25
|
+
kind: 'job';
|
|
26
|
+
/** The job commitment, on the buyer side of the customer's lock. */
|
|
27
|
+
commitment: CommitmentReference;
|
|
28
|
+
header: ChainedTermsHeader & {
|
|
29
|
+
template: typeof JOB;
|
|
30
|
+
dependencyCheck: JobDependencyCheck;
|
|
31
|
+
};
|
|
32
|
+
dependencies: Dependencies;
|
|
33
|
+
/** The dependencies section's own salt. */
|
|
34
|
+
dependenciesSalt: Hex;
|
|
35
|
+
/** The hash of each of the other five sections, under its own salt. */
|
|
36
|
+
sectionHashes: Record<TermsSection, Hex>;
|
|
37
|
+
}
|
|
38
|
+
export declare const jobVerificationJson: z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"job">;
|
|
40
|
+
commitment: z.ZodObject<{
|
|
41
|
+
kind: z.ZodLiteral<"commitment">;
|
|
42
|
+
chainId: z.ZodNumber;
|
|
43
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
44
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
45
|
+
side: z.ZodEnum<{
|
|
46
|
+
buyer: "buyer";
|
|
47
|
+
supplier: "supplier";
|
|
48
|
+
}>;
|
|
49
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
header: z.ZodObject<{
|
|
52
|
+
version: z.ZodLiteral<3>;
|
|
53
|
+
template: z.ZodLiteral<"job/1">;
|
|
54
|
+
currency: z.ZodEnum<{
|
|
55
|
+
USD: "USD";
|
|
56
|
+
}>;
|
|
57
|
+
amountDecimals: z.ZodLiteral<6>;
|
|
58
|
+
dependencyCheck: z.ZodEnum<{
|
|
59
|
+
buyer: "buyer";
|
|
60
|
+
}>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
dependencies: z.ZodUnion<readonly [z.ZodTuple<[z.ZodObject<{
|
|
63
|
+
on: z.ZodObject<{
|
|
64
|
+
kind: z.ZodLiteral<"commitment">;
|
|
65
|
+
chainId: z.ZodNumber;
|
|
66
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
67
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
68
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
69
|
+
side: z.ZodLiteral<"buyer">;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
condition: z.ZodEnum<{
|
|
72
|
+
accepted: "accepted";
|
|
73
|
+
}>;
|
|
74
|
+
disclosed: z.ZodEnum<{
|
|
75
|
+
subject: "subject";
|
|
76
|
+
}>;
|
|
77
|
+
}, z.core.$strict>], null>, z.ZodTuple<[z.ZodObject<{
|
|
78
|
+
on: z.ZodObject<{
|
|
79
|
+
kind: z.ZodLiteral<"commitment">;
|
|
80
|
+
chainId: z.ZodNumber;
|
|
81
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
82
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
83
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
84
|
+
side: z.ZodLiteral<"buyer">;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
condition: z.ZodEnum<{
|
|
87
|
+
accepted: "accepted";
|
|
88
|
+
}>;
|
|
89
|
+
disclosed: z.ZodEnum<{
|
|
90
|
+
subject: "subject";
|
|
91
|
+
}>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
on: z.ZodObject<{
|
|
94
|
+
kind: z.ZodLiteral<"commitment">;
|
|
95
|
+
chainId: z.ZodNumber;
|
|
96
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
97
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
98
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
99
|
+
side: z.ZodLiteral<"buyer">;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
condition: z.ZodEnum<{
|
|
102
|
+
accepted: "accepted";
|
|
103
|
+
}>;
|
|
104
|
+
disclosed: z.ZodEnum<{
|
|
105
|
+
subject: "subject";
|
|
106
|
+
}>;
|
|
107
|
+
}, z.core.$strict>], null>, z.ZodTuple<[z.ZodObject<{
|
|
108
|
+
on: z.ZodObject<{
|
|
109
|
+
kind: z.ZodLiteral<"commitment">;
|
|
110
|
+
chainId: z.ZodNumber;
|
|
111
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
112
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
113
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
114
|
+
side: z.ZodLiteral<"buyer">;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
condition: z.ZodEnum<{
|
|
117
|
+
accepted: "accepted";
|
|
118
|
+
}>;
|
|
119
|
+
disclosed: z.ZodEnum<{
|
|
120
|
+
subject: "subject";
|
|
121
|
+
}>;
|
|
122
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
123
|
+
on: z.ZodObject<{
|
|
124
|
+
kind: z.ZodLiteral<"commitment">;
|
|
125
|
+
chainId: z.ZodNumber;
|
|
126
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
127
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
128
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
129
|
+
side: z.ZodLiteral<"buyer">;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
condition: z.ZodEnum<{
|
|
132
|
+
accepted: "accepted";
|
|
133
|
+
}>;
|
|
134
|
+
disclosed: z.ZodEnum<{
|
|
135
|
+
subject: "subject";
|
|
136
|
+
}>;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
on: z.ZodObject<{
|
|
139
|
+
kind: z.ZodLiteral<"commitment">;
|
|
140
|
+
chainId: z.ZodNumber;
|
|
141
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
142
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
143
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
144
|
+
side: z.ZodLiteral<"buyer">;
|
|
145
|
+
}, z.core.$strict>;
|
|
146
|
+
condition: z.ZodEnum<{
|
|
147
|
+
accepted: "accepted";
|
|
148
|
+
}>;
|
|
149
|
+
disclosed: z.ZodEnum<{
|
|
150
|
+
subject: "subject";
|
|
151
|
+
}>;
|
|
152
|
+
}, z.core.$strict>], null>, z.ZodTuple<[z.ZodObject<{
|
|
153
|
+
on: z.ZodObject<{
|
|
154
|
+
kind: z.ZodLiteral<"commitment">;
|
|
155
|
+
chainId: z.ZodNumber;
|
|
156
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
157
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
158
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
159
|
+
side: z.ZodLiteral<"buyer">;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
condition: z.ZodEnum<{
|
|
162
|
+
accepted: "accepted";
|
|
163
|
+
}>;
|
|
164
|
+
disclosed: z.ZodEnum<{
|
|
165
|
+
subject: "subject";
|
|
166
|
+
}>;
|
|
167
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
168
|
+
on: z.ZodObject<{
|
|
169
|
+
kind: z.ZodLiteral<"commitment">;
|
|
170
|
+
chainId: z.ZodNumber;
|
|
171
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
172
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
173
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
174
|
+
side: z.ZodLiteral<"buyer">;
|
|
175
|
+
}, z.core.$strict>;
|
|
176
|
+
condition: z.ZodEnum<{
|
|
177
|
+
accepted: "accepted";
|
|
178
|
+
}>;
|
|
179
|
+
disclosed: z.ZodEnum<{
|
|
180
|
+
subject: "subject";
|
|
181
|
+
}>;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
on: z.ZodObject<{
|
|
184
|
+
kind: z.ZodLiteral<"commitment">;
|
|
185
|
+
chainId: z.ZodNumber;
|
|
186
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
187
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
188
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
189
|
+
side: z.ZodLiteral<"buyer">;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
condition: z.ZodEnum<{
|
|
192
|
+
accepted: "accepted";
|
|
193
|
+
}>;
|
|
194
|
+
disclosed: z.ZodEnum<{
|
|
195
|
+
subject: "subject";
|
|
196
|
+
}>;
|
|
197
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
198
|
+
on: z.ZodObject<{
|
|
199
|
+
kind: z.ZodLiteral<"commitment">;
|
|
200
|
+
chainId: z.ZodNumber;
|
|
201
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
202
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
203
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
204
|
+
side: z.ZodLiteral<"buyer">;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
condition: z.ZodEnum<{
|
|
207
|
+
accepted: "accepted";
|
|
208
|
+
}>;
|
|
209
|
+
disclosed: z.ZodEnum<{
|
|
210
|
+
subject: "subject";
|
|
211
|
+
}>;
|
|
212
|
+
}, z.core.$strict>], null>]>;
|
|
213
|
+
dependenciesSalt: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
214
|
+
sectionHashes: z.ZodObject<{
|
|
215
|
+
subject: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
216
|
+
consideration: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
217
|
+
remedies: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
218
|
+
resolution: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
219
|
+
backing: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
220
|
+
}, z.core.$strict>;
|
|
221
|
+
}, z.core.$strict>;
|
|
222
|
+
/**
|
|
223
|
+
* What a link to verify a job carries, from the job's terms in full and their salt. Throws when the
|
|
224
|
+
* reference doesn't name these terms' hash, so a link never names one job's commitment with
|
|
225
|
+
* another's terms.
|
|
226
|
+
*/
|
|
227
|
+
export declare function jobVerificationOf(terms: ChainedJobTerms, salt: Hex, commitment: CommitmentReference): JobVerification;
|
|
228
|
+
/** The terms hash a job's link works out from what it carries. */
|
|
229
|
+
export declare function jobVerificationTermsHash(v: JobVerification): Hex;
|
|
230
|
+
/**
|
|
231
|
+
* Checks that what a job's link carries works out to the terms hash its reference names, and
|
|
232
|
+
* returns `terms.hash_mismatch` when it doesn't, or null. The reference's terms hash still has to
|
|
233
|
+
* match the one the lock holds for that commitment, which only a read of the lock shows.
|
|
234
|
+
*/
|
|
235
|
+
export declare function jobVerificationProblem(v: JobVerification): ReasonCode | null;
|
|
236
|
+
/** What a job's link carries as one URL-safe token, for a link such as `#verify=<token>`. */
|
|
237
|
+
export declare function encodeJobVerification(v: JobVerification): string;
|
|
238
|
+
/**
|
|
239
|
+
* Reads what a job's link carries. A token from `encodeCommitmentReference` reads as invalid here,
|
|
240
|
+
* and the `kind` of the JSON tells the two apart. It reads only the form, and
|
|
241
|
+
* `jobVerificationProblem` checks the hashes.
|
|
242
|
+
*/
|
|
243
|
+
export declare function decodeJobVerification(token: string): Parsed<JobVerification>;
|
|
244
|
+
//# sourceMappingURL=job-verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-verification.d.ts","sourceRoot":"","sources":["../src/job-verification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,KAAK,eAAe,EAAE,GAAG,EAAE,KAAK,kBAAkB,E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I,CAI5E;AAED,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAIhE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,CAO5E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { dependenciesJson } from './dependencies.js';
|
|
3
|
+
import { JOB } from './job.js';
|
|
4
|
+
import { bytes32 } from './json-fields.js';
|
|
5
|
+
import { decodeLinkToken, encodeLinkToken } from './reference-link.js';
|
|
6
|
+
import { commitmentReferenceJson } from './references.js';
|
|
7
|
+
import { chainedTermsHashFromSections, sectionHash, sectionHashes, sectionSalt, TERMS_SECTIONS, termsHash, termsHeader, } from './terms.js';
|
|
8
|
+
import { AMOUNT_DECIMALS, CHAINED_TERMS_VERSION, CURRENCIES, DEPENDENCY_CHECKS_ALLOWED, } from './types.js';
|
|
9
|
+
import { toWire } from './wire.js';
|
|
10
|
+
/** The longest token `decodeJobVerification` reads, room for four bookings relied on. */
|
|
11
|
+
const MAX_TOKEN = 6144;
|
|
12
|
+
export const jobVerificationJson = z.strictObject({
|
|
13
|
+
kind: z.literal('job'),
|
|
14
|
+
commitment: commitmentReferenceJson,
|
|
15
|
+
header: z.strictObject({
|
|
16
|
+
version: z.literal(CHAINED_TERMS_VERSION),
|
|
17
|
+
template: z.literal(JOB),
|
|
18
|
+
currency: z.enum(CURRENCIES),
|
|
19
|
+
amountDecimals: z.literal(AMOUNT_DECIMALS),
|
|
20
|
+
dependencyCheck: z.enum(DEPENDENCY_CHECKS_ALLOWED[JOB]),
|
|
21
|
+
}),
|
|
22
|
+
dependencies: dependenciesJson,
|
|
23
|
+
dependenciesSalt: bytes32,
|
|
24
|
+
sectionHashes: z.strictObject({
|
|
25
|
+
subject: bytes32,
|
|
26
|
+
consideration: bytes32,
|
|
27
|
+
remedies: bytes32,
|
|
28
|
+
resolution: bytes32,
|
|
29
|
+
backing: bytes32,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* What a link to verify a job carries, from the job's terms in full and their salt. Throws when the
|
|
34
|
+
* reference doesn't name these terms' hash, so a link never names one job's commitment with
|
|
35
|
+
* another's terms.
|
|
36
|
+
*/
|
|
37
|
+
export function jobVerificationOf(terms, salt, commitment) {
|
|
38
|
+
if (termsHash(terms, salt).toLowerCase() !== commitment.termsHash.toLowerCase()) {
|
|
39
|
+
throw new RangeError("The reference doesn't name these terms' hash");
|
|
40
|
+
}
|
|
41
|
+
const hashes = sectionHashes(terms, salt);
|
|
42
|
+
return {
|
|
43
|
+
kind: 'job',
|
|
44
|
+
commitment: { ...commitment },
|
|
45
|
+
header: termsHeader(terms),
|
|
46
|
+
dependencies: terms.dependencies,
|
|
47
|
+
dependenciesSalt: sectionSalt(salt, 'dependencies'),
|
|
48
|
+
sectionHashes: Object.fromEntries(TERMS_SECTIONS.map((s) => [s, hashes[s]])),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** The terms hash a job's link works out from what it carries. */
|
|
52
|
+
export function jobVerificationTermsHash(v) {
|
|
53
|
+
return chainedTermsHashFromSections(v.header, {
|
|
54
|
+
...v.sectionHashes,
|
|
55
|
+
dependencies: sectionHash('dependencies', v.dependencies, v.dependenciesSalt),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks that what a job's link carries works out to the terms hash its reference names, and
|
|
60
|
+
* returns `terms.hash_mismatch` when it doesn't, or null. The reference's terms hash still has to
|
|
61
|
+
* match the one the lock holds for that commitment, which only a read of the lock shows.
|
|
62
|
+
*/
|
|
63
|
+
export function jobVerificationProblem(v) {
|
|
64
|
+
return jobVerificationTermsHash(v).toLowerCase() === v.commitment.termsHash.toLowerCase()
|
|
65
|
+
? null
|
|
66
|
+
: 'terms.hash_mismatch';
|
|
67
|
+
}
|
|
68
|
+
/** What a job's link carries as one URL-safe token, for a link such as `#verify=<token>`. */
|
|
69
|
+
export function encodeJobVerification(v) {
|
|
70
|
+
const parsed = jobVerificationJson.safeParse(toWire(v));
|
|
71
|
+
if (!parsed.success)
|
|
72
|
+
throw new RangeError("That isn't a job's verification");
|
|
73
|
+
return encodeLinkToken(parsed.data);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reads what a job's link carries. A token from `encodeCommitmentReference` reads as invalid here,
|
|
77
|
+
* and the `kind` of the JSON tells the two apart. It reads only the form, and
|
|
78
|
+
* `jobVerificationProblem` checks the hashes.
|
|
79
|
+
*/
|
|
80
|
+
export function decodeJobVerification(token) {
|
|
81
|
+
const decoded = decodeLinkToken(token, MAX_TOKEN);
|
|
82
|
+
if (!decoded)
|
|
83
|
+
return { ok: false, reason: 'message.invalid' };
|
|
84
|
+
const parsed = jobVerificationJson.safeParse(decoded.json);
|
|
85
|
+
return parsed.success
|
|
86
|
+
? { ok: true, value: parsed.data }
|
|
87
|
+
: { ok: false, reason: 'message.invalid' };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=job-verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-verification.js","sourceRoot":"","sources":["../src/job-verification.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAqB,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAwB,GAAG,EAA2B,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,EAA4B,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAEL,4BAA4B,EAC5B,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EAEd,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAA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UAAU,qBAAqB,CAAC,KAAa;IACjD,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1D,OAAO,MAAM,CAAC,OAAO;QACnB,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAuB,EAAE;QACrD,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PinnedBlock } from './dependencies.js';
|
|
2
|
+
import type { JobCharge, JobEvent } from './job-session.js';
|
|
3
|
+
/**
|
|
4
|
+
* The words a job's terminal and its screen both say, so the two never tell the story
|
|
5
|
+
* differently. Every statement matches a check that ran, and a check's statement names the block
|
|
6
|
+
* it read and says nothing beyond it.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The decisive moment. The customer made its reserve, the developer's code checked it, and the
|
|
10
|
+
* customer accepted only after it verified the compute booking. Work waits for the job's start,
|
|
11
|
+
* when the customer's free cancellation ends.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DECISIVE_SENTENCE = "Your code verified the customer's commitment and checked its reserve. The customer accepted after verifying your compute booking. Work starts when the customer's free cancellation ends.";
|
|
14
|
+
/**
|
|
15
|
+
* The decisive sentence when the lock already showed the acceptance an earlier attempt sent. This
|
|
16
|
+
* run read the commitment, its reserve and the compute booking again, and it didn't ask Avow for
|
|
17
|
+
* its authorization again, so the sentence says the acceptance rests on the earlier attempt.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RECOVERED_DECISIVE_SENTENCE = "Your code verified the customer's commitment and checked its reserve. The acceptance on the customer's lock came from an earlier attempt's checks. The customer accepted after verifying your compute booking. Work starts when the customer's free cancellation ends.";
|
|
20
|
+
/** What a compute booking proves, and what it doesn't. */
|
|
21
|
+
export declare const COMPUTE_PROVES = "Your compute booking proves a required input is committed. It doesn't prove your agent will finish the job.";
|
|
22
|
+
/** The two reserves stay apart. */
|
|
23
|
+
export declare const SEPARATE_RESERVES = "The customer's reserve backs the job, and your reserve backs the compute. Naming a booking moves no money and compensates nobody automatically. Nothing backs your own delivery promise with money in v1.";
|
|
24
|
+
/** What a check of a booking relied on proves. */
|
|
25
|
+
export declare const CHECK_BOUNDARY = "Each check proves the state at the block it read. Nothing makes the steps atomic, and nothing in Avow stops your business cancelling its compute after the customer accepted.";
|
|
26
|
+
/** What holds when the compute goes away after the customer accepted. */
|
|
27
|
+
export declare const AFTER_ACCEPTANCE = "If your compute is cancelled or fails after the customer accepted, the job commitment stands, and your business still answers to the customer under the job's own terms. It finds other capacity or releases the job with the reason supplier failed.";
|
|
28
|
+
/** What's simulated and what's real, said in one plain line wherever the work appears. */
|
|
29
|
+
export declare const SIMULATED_LINE = "The GPUs and the training are simulated. Every commitment, reserve, check and payment is a real testnet operation.";
|
|
30
|
+
/** The first challenge, which the prescribed edit answers. */
|
|
31
|
+
export declare const REFUSAL_CHALLENGE = "Remove the compute booking. Would the customer still accept?";
|
|
32
|
+
/** The file and the flag beside the one line that books the compute. */
|
|
33
|
+
export declare const REFUSAL_EDIT: {
|
|
34
|
+
readonly file: 'service.ts';
|
|
35
|
+
readonly flag: 'bookCompute';
|
|
36
|
+
};
|
|
37
|
+
/** How to make the prescribed refusal. */
|
|
38
|
+
export declare const REFUSAL_INSTRUCTION: string;
|
|
39
|
+
/**
|
|
40
|
+
* What the customer's reserve backs. It backs only what the job's terms let the developer charge
|
|
41
|
+
* if the customer walks away, and never the price, which arrives as its own transfer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function reserveLine(charges: readonly JobCharge[]): string;
|
|
44
|
+
/** A block as a statement names it. */
|
|
45
|
+
export declare const atBlock: (block: Pick<PinnedBlock, 'number'>) => string;
|
|
46
|
+
/** The one sentence the terminal prints and the screen shows for a job's event. */
|
|
47
|
+
export declare function jobEventSentence(event: JobEvent): string;
|
|
48
|
+
//# sourceMappingURL=job-wording.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-wording.d.ts","sourceRoot":"","sources":["../src/job-wording.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAGV,SAAS,EACT,QAAQ,EAET,MAAM,kBAAkB,CAAA;AAKzB;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,8LAC+J,CAAA;AAE7L;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,2QACkO,CAAA;AAE1Q,0DAA0D;AAC1D,eAAO,MAAM,cAAc,gHACoF,CAAA;AAE/G,mCAAmC;AACnC,eAAO,MAAM,iBAAiB,8MAC+K,CAAA;AAE7M,kDAAkD;AAClD,eAAO,MAAM,cAAc,kLACsJ,CAAA;AAEjL,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,0PAC4N,CAAA;AAEzP,0FAA0F;AAC1F,eAAO,MAAM,cAAc,uHAC2F,CAAA;AAEtH,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,iEAAiE,CAAA;AAE/F,wEAAwE;AACxE,eAAO,MAAM,YAAY;aAAK,IAAI,EAAE,YAAY;aAAE,IAAI,EAAE,aAAa;CAAW,CAAA;AAEhF,0CAA0C;AAC1C,eAAO,MAAM,mBAAmB,QAAuJ,CAAA;AASvL;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAGjE;AAED,uCAAuC;AACvC,eAAO,MAAM,OAAO,UAAW,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,WAA+B,CAAA;AA8CzF,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CA2CxD"}
|