@avow-finance/spec 0.7.0 → 0.9.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/dist/agent-session.d.ts +8 -0
- package/dist/agent-session.d.ts.map +1 -1
- package/dist/api.d.ts +24 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +8 -2
- package/dist/dependencies.js.map +1 -1
- package/dist/eip712.d.ts +212 -1
- package/dist/eip712.d.ts.map +1 -1
- package/dist/eip712.js +34 -0
- package/dist/eip712.js.map +1 -1
- package/dist/gpu-reservation.d.ts.map +1 -1
- package/dist/gpu-reservation.js +1 -1
- package/dist/gpu-reservation.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/job-session.d.ts +16 -0
- package/dist/job-session.d.ts.map +1 -1
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +1 -1
- package/dist/job.js.map +1 -1
- package/dist/json-fields.d.ts +2 -0
- package/dist/json-fields.d.ts.map +1 -1
- package/dist/json-fields.js +2 -0
- package/dist/json-fields.js.map +1 -1
- package/dist/mailbox.d.ts +77 -104
- package/dist/mailbox.d.ts.map +1 -1
- package/dist/mailbox.js +8 -30
- package/dist/mailbox.js.map +1 -1
- package/dist/negotiation.d.ts +514 -0
- package/dist/negotiation.d.ts.map +1 -0
- package/dist/negotiation.js +490 -0
- package/dist/negotiation.js.map +1 -0
- package/dist/offer-search.d.ts +282 -0
- package/dist/offer-search.d.ts.map +1 -0
- package/dist/offer-search.js +252 -0
- package/dist/offer-search.js.map +1 -0
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +2 -1
- package/dist/openapi.js.map +1 -1
- package/dist/order-wire.d.ts +73 -0
- package/dist/order-wire.d.ts.map +1 -0
- package/dist/order-wire.js +33 -0
- package/dist/order-wire.js.map +1 -0
- package/dist/reasons.d.ts +10 -2
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +10 -2
- package/dist/reasons.js.map +1 -1
- package/dist/sandbox.d.ts +81 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +18 -0
- package/dist/sandbox.js.map +1 -1
- package/dist/service-order.d.ts +747 -0
- package/dist/service-order.d.ts.map +1 -0
- package/dist/service-order.js +182 -0
- package/dist/service-order.js.map +1 -0
- package/dist/service.d.ts +248 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +379 -0
- package/dist/service.js.map +1 -0
- package/dist/session-fields.d.ts +8 -0
- package/dist/session-fields.d.ts.map +1 -1
- package/dist/terms.d.ts.map +1 -1
- package/dist/terms.js +4 -0
- package/dist/terms.js.map +1 -1
- package/dist/test-customer.d.ts +16 -0
- package/dist/test-customer.d.ts.map +1 -1
- package/dist/text.d.ts +5 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +5 -0
- package/dist/text.js.map +1 -0
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -3
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -1
- package/dist/wire.d.ts +312 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +28 -1
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-order.d.ts","sourceRoot":"","sources":["../src/service-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,KAAK,QAAQ,EAAmC,MAAM,cAAc,CAAA;AAC7E,OAAO,EAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAA0C,CAAA;AAOvE,eAAO,MAAM,wBAAwB,+CAEpC,CAAA;AACD,eAAO,MAAM,iBAAiB,wCAAqE,CAAA;AACnG,eAAO,MAAM,iBAAiB,wCAAkE,CAAA;AAChG,eAAO,MAAM,iBAAiB;YAGS,YAAY,EAAE;QACpD,CAAA"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { canonicalJson } from './canonical.js';
|
|
3
|
+
import { bytes32, hexBytes, sameHex as same, u64 } from './json-fields.js';
|
|
4
|
+
import { jobBuyerJson, MAILBOX_INBOX_MAX } from './mailbox.js';
|
|
5
|
+
import { orderStagesJson, readOrNull } from './order-wire.js';
|
|
6
|
+
import { offerVersionId, SERVICE_ACCEPT_WITHIN, SERVICE_CATEGORY, SERVICE_QUANTITY_MAX, serviceOfferProblem, serviceOfferQuote, serviceOfferTerms, serviceOfferVersionJson, } from './service.js';
|
|
7
|
+
import { termsHash } from './terms.js';
|
|
8
|
+
import { orderIdJson } from './test-customer.js';
|
|
9
|
+
import { serviceTermsJson, termsAgreementJson, toWire } from './wire.js';
|
|
10
|
+
/**
|
|
11
|
+
* A service order, which is to carry one booking of a supplier's offer between two businesses'
|
|
12
|
+
* agents through Avow's sandbox mailbox, wherever each agent runs. It takes the four steps a job
|
|
13
|
+
* order takes, each signed by the key that sends it.
|
|
14
|
+
*
|
|
15
|
+
* 1. The buyer's agent sends the offer version it wants, how many units, and the moment the terms
|
|
16
|
+
* are built from. Nothing is reserved.
|
|
17
|
+
* 2. The supplier's agent reads the order from its inbox, checks the version is one it published,
|
|
18
|
+
* and sends the terms `serviceOfferTerms` builds from the order with its signed agreement.
|
|
19
|
+
* 3. The buyer's agent checks the quote against its own order, funds the commitment under its
|
|
20
|
+
* mandate, and tells the mailbox, which reads the reserve on chain.
|
|
21
|
+
* 4. The supplier's agent accepts on chain with its own signing key, and tells the mailbox, which
|
|
22
|
+
* reads the acceptance on chain.
|
|
23
|
+
*
|
|
24
|
+
* A service order has paths and a shape of its own, so a reader that knows only job orders never
|
|
25
|
+
* meets one. This module holds the messages and what each side can check for itself. Avow's
|
|
26
|
+
* testnet sandbox serves the paths.
|
|
27
|
+
*/
|
|
28
|
+
/** How far ahead of a reader's clock an order's build moment may be, in seconds. */
|
|
29
|
+
export const SERVICE_ORDER_CLOCK_SKEW = 60n;
|
|
30
|
+
/**
|
|
31
|
+
* How long before the supplier's deadline to accept an order has to lapse, in seconds. A reserve
|
|
32
|
+
* funded at the order's last moment still leaves the supplier this long to accept it.
|
|
33
|
+
*/
|
|
34
|
+
export const SERVICE_ORDER_ACCEPT_MARGIN = 5n * 60n;
|
|
35
|
+
/**
|
|
36
|
+
* Whether something that stands until `expiry` leaves the supplier its time to accept terms built
|
|
37
|
+
* at `builtAt`. The terms give the supplier `SERVICE_ACCEPT_WITHIN` from the build moment, so a
|
|
38
|
+
* reserve funded at the last moment still leaves it `SERVICE_ORDER_ACCEPT_MARGIN`.
|
|
39
|
+
*/
|
|
40
|
+
export const leavesTimeToAccept = (expiry, builtAt) => expiry + SERVICE_ORDER_ACCEPT_MARGIN <= builtAt + SERVICE_ACCEPT_WITHIN;
|
|
41
|
+
/**
|
|
42
|
+
* Why an order can't be taken at `now`, or null when it can. Its offer has to be one the template
|
|
43
|
+
* takes, in a quantity the offer takes. Its times have to leave the supplier room to accept: the
|
|
44
|
+
* terms give the supplier `SERVICE_ACCEPT_WITHIN` from the build moment, so the order lapses
|
|
45
|
+
* `SERVICE_ORDER_ACCEPT_MARGIN` before that.
|
|
46
|
+
*
|
|
47
|
+
* It can't tell whether the supplier ever published the offer. A buyer can write any offer it
|
|
48
|
+
* likes under a supplier's name, so the supplier checks that with `publishedOffer` before it
|
|
49
|
+
* quotes, and nothing is agreed until it does.
|
|
50
|
+
*/
|
|
51
|
+
export function serviceOrderProblem(order, now) {
|
|
52
|
+
if (order.builtAt > now + SERVICE_ORDER_CLOCK_SKEW)
|
|
53
|
+
return 'message.invalid';
|
|
54
|
+
if (order.expiry <= now)
|
|
55
|
+
return 'message.expired';
|
|
56
|
+
if (order.expiry <= order.builtAt)
|
|
57
|
+
return 'message.invalid';
|
|
58
|
+
if (!leavesTimeToAccept(order.expiry, order.builtAt))
|
|
59
|
+
return 'message.validity_too_long';
|
|
60
|
+
try {
|
|
61
|
+
// Hashing and pricing the offer refuse a version its rules refuse, text that can't be
|
|
62
|
+
// written canonically, and a quantity the version doesn't take.
|
|
63
|
+
offerVersionId(order.offer);
|
|
64
|
+
serviceOfferQuote(order.offer, order.quantity);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return 'terms.template_invalid';
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The version among those a supplier published that an order's offer is, or null when it's none
|
|
73
|
+
* of them. The supplier's agent runs it on every order before it quotes, since the offer in an
|
|
74
|
+
* order is the buyer's copy and the buyer could have written anything.
|
|
75
|
+
*/
|
|
76
|
+
export function publishedOffer(order, published) {
|
|
77
|
+
let ordered;
|
|
78
|
+
try {
|
|
79
|
+
ordered = offerVersionId(order.offer);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return published.find((version) => offerVersionId(version) === ordered) ?? null;
|
|
85
|
+
}
|
|
86
|
+
/** Terms with their arbiter in lower case, as the wire carries an address. */
|
|
87
|
+
const onWire = (terms) => canonicalJson(toWire({
|
|
88
|
+
...terms,
|
|
89
|
+
resolution: {
|
|
90
|
+
...terms.resolution,
|
|
91
|
+
arbiter: terms.resolution.arbiter.toLowerCase(),
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
94
|
+
/**
|
|
95
|
+
* Why a supplier's agreement isn't to these terms for this booking, or null when it is. It has to
|
|
96
|
+
* carry the hash of the terms under the salt given, name the commitment and the supplier, and be
|
|
97
|
+
* for a service. Given the buyer, it has to name the buyer's business and mandate too. It never
|
|
98
|
+
* throws, and it leaves the supplier's signature and the agreement's expiry to its callers.
|
|
99
|
+
*/
|
|
100
|
+
export function serviceAgreementProblem(booking, terms, quote) {
|
|
101
|
+
const { agreement } = quote;
|
|
102
|
+
try {
|
|
103
|
+
if (!same(agreement.termsHash, termsHash(terms, quote.salt)))
|
|
104
|
+
return 'terms.hash_mismatch';
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// A salt the hash refuses or text that can't be written canonically hashes to nothing.
|
|
108
|
+
return 'order.terms_changed';
|
|
109
|
+
}
|
|
110
|
+
if (!same(agreement.commitmentId, booking.commitmentId))
|
|
111
|
+
return 'order.commitment_mismatch';
|
|
112
|
+
if (agreement.category !== SERVICE_CATEGORY)
|
|
113
|
+
return 'terms.category_mismatch';
|
|
114
|
+
if (agreement.supplierBusinessId !== booking.supplier)
|
|
115
|
+
return 'agreement.parties_mismatch';
|
|
116
|
+
if (booking.buyer &&
|
|
117
|
+
(agreement.buyerBusinessId !== booking.buyer.businessId ||
|
|
118
|
+
!same(agreement.mandateHash, booking.buyer.mandateHash))) {
|
|
119
|
+
return 'agreement.parties_mismatch';
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Why a quote doesn't answer its order, or null when it does. The quote's terms have to be the
|
|
125
|
+
* ones `serviceOfferTerms` builds from the order, with nothing moved. Its agreement has to be for
|
|
126
|
+
* a service, name the order's commitment and the offer's supplier, and carry the hash of those
|
|
127
|
+
* terms under the quote's salt. Given the buyer, it has to name the buyer's business and mandate
|
|
128
|
+
* too.
|
|
129
|
+
*
|
|
130
|
+
* It leaves two checks to others. The buyer's agent checks the agreement's expiry and its own
|
|
131
|
+
* authority when it commits, and Avow checks the supplier's signature when it approves the
|
|
132
|
+
* reserve. It never throws, whatever a quote that parsed holds.
|
|
133
|
+
*/
|
|
134
|
+
export function serviceQuoteProblem(order, quote, settlement) {
|
|
135
|
+
try {
|
|
136
|
+
const expected = serviceOfferTerms(order.offer, order.quantity, order.builtAt, settlement);
|
|
137
|
+
if (onWire(expected) !== onWire(quote.terms))
|
|
138
|
+
return 'order.terms_changed';
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// An offer the template refuses or text that can't be written canonically means the quote
|
|
142
|
+
// isn't for these terms.
|
|
143
|
+
return 'order.terms_changed';
|
|
144
|
+
}
|
|
145
|
+
return serviceAgreementProblem({
|
|
146
|
+
commitmentId: order.commitmentId,
|
|
147
|
+
supplier: order.offer.supplier,
|
|
148
|
+
...(order.buyer ? { buyer: order.buyer } : {}),
|
|
149
|
+
}, quote.terms, quote);
|
|
150
|
+
}
|
|
151
|
+
export const serviceOrderRequestJson = z
|
|
152
|
+
.strictObject({
|
|
153
|
+
orderId: orderIdJson,
|
|
154
|
+
commitmentId: bytes32,
|
|
155
|
+
offer: serviceOfferVersionJson,
|
|
156
|
+
quantity: z.number().int().positive().max(SERVICE_QUANTITY_MAX),
|
|
157
|
+
builtAt: u64,
|
|
158
|
+
expiry: u64,
|
|
159
|
+
})
|
|
160
|
+
// An offer the template's rules refuse is refused where the order is read.
|
|
161
|
+
.refine((order) => serviceOfferProblem(order.offer) === null);
|
|
162
|
+
export const serviceQuoteJson = z.strictObject({
|
|
163
|
+
terms: serviceTermsJson,
|
|
164
|
+
salt: bytes32,
|
|
165
|
+
agreement: termsAgreementJson,
|
|
166
|
+
supplierSignature: hexBytes,
|
|
167
|
+
});
|
|
168
|
+
const held = {
|
|
169
|
+
...serviceOrderRequestJson.shape,
|
|
170
|
+
buyer: jobBuyerJson,
|
|
171
|
+
requestedAt: u64,
|
|
172
|
+
};
|
|
173
|
+
export const serviceOrderJson = orderStagesJson(held, serviceQuoteJson);
|
|
174
|
+
/** An order as the mailbox answers it has to carry an offer the template takes, as a request does. */
|
|
175
|
+
const heldOrderJson = serviceOrderJson.refine((order) => serviceOfferProblem(order.offer) === null);
|
|
176
|
+
export const parseServiceOrderRequest = readOrNull(serviceOrderRequestJson);
|
|
177
|
+
export const parseServiceQuote = readOrNull(serviceQuoteJson);
|
|
178
|
+
export const parseServiceOrder = readOrNull(heldOrderJson);
|
|
179
|
+
export const parseServiceInbox = readOrNull(z.strictObject({
|
|
180
|
+
orders: z.array(heldOrderJson).max(MAILBOX_INBOX_MAX),
|
|
181
|
+
}));
|
|
182
|
+
//# sourceMappingURL=service-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-order.js","sourceRoot":"","sources":["../src/service-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAiB,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAmB,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE9E,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EAGpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACxB,MA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
|
|
3
|
+
import type { ReasonCode } from './reasons.js';
|
|
4
|
+
import { type Currency, type TermsOf } from './types.js';
|
|
5
|
+
import type { Parsed } from './wire.js';
|
|
6
|
+
/**
|
|
7
|
+
* A service sold by quantity at a fixed price per unit, delivered by a deadline. Version 1 takes
|
|
8
|
+
* one-off services only. Subscriptions, usage billing and physical shipping aren't services under
|
|
9
|
+
* it, and a supplier that sells them doesn't list them. Its meaning is fixed, and a change of
|
|
10
|
+
* meaning would be `service/2`.
|
|
11
|
+
*
|
|
12
|
+
* The terms book one version of a supplier's offer, which `serviceOfferTerms` turns into terms,
|
|
13
|
+
* and `serviceTermsMatchOffer` says whether terms are exactly the ones that version gives. The
|
|
14
|
+
* buyer's reserve backs only what the buyer owes if it cancels late or isn't there to take
|
|
15
|
+
* delivery. The price is the consideration, which the lock never reads. It's paid by the route and
|
|
16
|
+
* deadline the terms name, and the reserve doesn't secure it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SERVICE: 'service/1';
|
|
19
|
+
/**
|
|
20
|
+
* The mandate category every service booking falls under. A mandate allows services by naming
|
|
21
|
+
* it, and service terms under any other category are refused as `terms.category_mismatch`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SERVICE_CATEGORY: 'service';
|
|
24
|
+
/** The unit a service's price is charged per, one of the quantity the terms name. */
|
|
25
|
+
export declare const SERVICE_UNIT: 'unit';
|
|
26
|
+
/** The longest item name a service names. */
|
|
27
|
+
export declare const SERVICE_NAME_MAX = 120;
|
|
28
|
+
/** The longest summary, or description of delivery evidence, a service names. */
|
|
29
|
+
export declare const SERVICE_TEXT_MAX = 280;
|
|
30
|
+
/** The most units one booking of a service can take. */
|
|
31
|
+
export declare const SERVICE_QUANTITY_MAX = 1000000;
|
|
32
|
+
/**
|
|
33
|
+
* How the buyer pays the price, which the lock never reads. `transfer` is a transfer of the
|
|
34
|
+
* terms' currency to the supplier's payee on the commitment's chain. `invoice` is the supplier
|
|
35
|
+
* billing by its own means, which nothing on chain shows.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PAYMENT_ROUTES: readonly ['transfer', 'invoice'];
|
|
38
|
+
export type PaymentRoute = (typeof PAYMENT_ROUTES)[number];
|
|
39
|
+
/** What a service booking promises: which offer, what and how many, and how it's delivered and paid. */
|
|
40
|
+
export interface ServiceSubject {
|
|
41
|
+
/** The id of the offer version booked, which `offerVersionId` gives. */
|
|
42
|
+
offer: Hex;
|
|
43
|
+
/** What the supplier delivers, with a short name and one sentence on what it is. */
|
|
44
|
+
item: {
|
|
45
|
+
name: string;
|
|
46
|
+
summary: string;
|
|
47
|
+
};
|
|
48
|
+
/** How many units are booked. */
|
|
49
|
+
quantity: number;
|
|
50
|
+
/** When the supplier delivers by, and what counts as evidence that it did. */
|
|
51
|
+
delivery: {
|
|
52
|
+
by: bigint;
|
|
53
|
+
evidence: string;
|
|
54
|
+
};
|
|
55
|
+
/** How the buyer pays the price, and by when. */
|
|
56
|
+
payment: {
|
|
57
|
+
route: PaymentRoute;
|
|
58
|
+
dueBy: bigint;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Service terms, version 2. */
|
|
62
|
+
export type ServiceTerms = TermsOf<ServiceSubject, typeof SERVICE>;
|
|
63
|
+
/** What a service booking states, in micros and unix seconds, before the template builds its terms. */
|
|
64
|
+
export interface ServiceInput {
|
|
65
|
+
offer: Hex;
|
|
66
|
+
item: ServiceSubject['item'];
|
|
67
|
+
quantity: number;
|
|
68
|
+
currency: Currency;
|
|
69
|
+
/** The price of one unit, paid by the payment route. The reserve doesn't secure it. */
|
|
70
|
+
unitPrice: bigint;
|
|
71
|
+
deliverBy: bigint;
|
|
72
|
+
evidence: string;
|
|
73
|
+
payment: ServiceSubject['payment'];
|
|
74
|
+
acceptBy: bigint;
|
|
75
|
+
freeCancelBy: bigint;
|
|
76
|
+
/** The most the supplier can charge when the buyer cancels after free cancellation ends. */
|
|
77
|
+
lateCancellation: bigint;
|
|
78
|
+
/** The most the supplier can charge when the buyer isn't there to take delivery. */
|
|
79
|
+
noShow: bigint;
|
|
80
|
+
chargeDeadline: bigint;
|
|
81
|
+
contestWindow: bigint;
|
|
82
|
+
releaseDate: bigint;
|
|
83
|
+
arbiter: Address;
|
|
84
|
+
day90SupplierShareBps: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Builds service terms. A late cancellation can be charged from the free-cancellation deadline and
|
|
88
|
+
* a no-show from the delivery deadline. A charge set to zero is left out, and the reserve is the
|
|
89
|
+
* largest charge.
|
|
90
|
+
*/
|
|
91
|
+
export declare function serviceTerms(input: ServiceInput): ServiceTerms;
|
|
92
|
+
/**
|
|
93
|
+
* What's wrong with a service's subject on its own, or null when nothing is. The offer is a
|
|
94
|
+
* lower-case 32-byte id, the item has a name and a summary of bounded length, the quantity is a
|
|
95
|
+
* whole number of units from 1 up, delivery names its evidence and a deadline, and payment names a
|
|
96
|
+
* route this version knows and a deadline (`terms.template_invalid`). A subject of any other shape
|
|
97
|
+
* is refused here, so nothing that reads it after this throws.
|
|
98
|
+
*/
|
|
99
|
+
export declare function serviceSubjectProblem(s: ServiceSubject): ReasonCode | null;
|
|
100
|
+
/**
|
|
101
|
+
* The template's own rules, which a reader checks after the core's. The subject passes
|
|
102
|
+
* `serviceSubjectProblem`, and the consideration is a price above zero per unit. The supplier
|
|
103
|
+
* accepts and free cancellation ends by the delivery deadline, which falls by the charge deadline,
|
|
104
|
+
* and payment is due at or after delivery. A late cancellation is chargeable from the
|
|
105
|
+
* free-cancellation deadline, and a no-show from the delivery deadline or later. No other charge
|
|
106
|
+
* applies to a service.
|
|
107
|
+
*/
|
|
108
|
+
export declare function validateService(t: Pick<ServiceTerms, 'subject' | 'consideration' | 'remedies'>): ReasonCode | null;
|
|
109
|
+
/** What a service's price comes to for the quantity booked, in micros. */
|
|
110
|
+
export declare const servicePrice: (t: Pick<ServiceTerms, 'subject' | 'consideration'>) => bigint;
|
|
111
|
+
/** How long a supplier has to accept a service booking, in seconds. */
|
|
112
|
+
export declare const SERVICE_ACCEPT_WITHIN: bigint;
|
|
113
|
+
/** How long after the delivery deadline a supplier can report a charge, in seconds. */
|
|
114
|
+
export declare const SERVICE_CHARGE_AFTER: bigint;
|
|
115
|
+
/**
|
|
116
|
+
* A supplier's rules for booking one of its services, which it approves when it publishes the
|
|
117
|
+
* offer. Every time counts from the moment the terms are built.
|
|
118
|
+
*/
|
|
119
|
+
export interface ServiceRules {
|
|
120
|
+
/** What counts as evidence that the supplier delivered. */
|
|
121
|
+
evidence: string;
|
|
122
|
+
/** How long after booking the supplier delivers by, in seconds, at least `SERVICE_ACCEPT_WITHIN`. */
|
|
123
|
+
leadTime: bigint;
|
|
124
|
+
/** The most units one booking takes. */
|
|
125
|
+
maxPerBooking: number;
|
|
126
|
+
/**
|
|
127
|
+
* How many bookings the supplier takes in a day. The terms don't carry it, so whoever accepts
|
|
128
|
+
* bookings for the supplier counts against it.
|
|
129
|
+
*/
|
|
130
|
+
dailyCapacity: number;
|
|
131
|
+
/**
|
|
132
|
+
* How long after booking the buyer can cancel at no charge, in seconds. Zero, so no booking is
|
|
133
|
+
* free to cancel, or from `SERVICE_ACCEPT_WITHIN` to the lead time, so the window outlasts the
|
|
134
|
+
* supplier's time to accept.
|
|
135
|
+
*/
|
|
136
|
+
freeCancelWindow: bigint;
|
|
137
|
+
/** What a late cancellation can cost, as a share of the price in basis points. */
|
|
138
|
+
lateCancellationBps: number;
|
|
139
|
+
/** What not being there to take delivery can cost, as a share of the price in basis points. */
|
|
140
|
+
noShowBps: number;
|
|
141
|
+
/** How the buyer pays, and how long after the delivery deadline payment is due, in seconds. */
|
|
142
|
+
payment: {
|
|
143
|
+
route: PaymentRoute;
|
|
144
|
+
dueAfterDelivery: bigint;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* One version of a supplier's offer of a service: what it sells, at what price, under which of its
|
|
149
|
+
* rules. A version never changes. A new price or a change to the rules is a new version, with a
|
|
150
|
+
* new id, so a booking always names exactly what its buyer saw.
|
|
151
|
+
*/
|
|
152
|
+
export interface ServiceOfferVersion {
|
|
153
|
+
/** The supplier's business id. */
|
|
154
|
+
supplier: string;
|
|
155
|
+
item: ServiceSubject['item'];
|
|
156
|
+
currency: Currency;
|
|
157
|
+
/** The price of one unit, in micros. */
|
|
158
|
+
unitPrice: bigint;
|
|
159
|
+
rules: ServiceRules;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* What's wrong with an offer version, in words for the person setting it, or null when nothing
|
|
163
|
+
* is. The supplier and item are named, the price is above zero, the lead time leaves the supplier
|
|
164
|
+
* its time to accept, free cancellation is off or outlasts that time and ends by delivery, a
|
|
165
|
+
* booking takes 1 to `SERVICE_QUANTITY_MAX` units, capacity is at least one booking a day, each
|
|
166
|
+
* charge is a share from 0 to 100%, and at least one is above zero, since a reserve with nothing to
|
|
167
|
+
* charge backs nothing. Every field has its declared type, so a version that passes hashes one way
|
|
168
|
+
* only.
|
|
169
|
+
*/
|
|
170
|
+
export declare function serviceOfferProblem(v: ServiceOfferVersion): string | null;
|
|
171
|
+
/** An offer version as JSON, with amounts and times as decimal strings and nothing else in it. */
|
|
172
|
+
export declare const serviceOfferVersionJson: z.ZodObject<{
|
|
173
|
+
supplier: z.ZodString;
|
|
174
|
+
item: z.ZodObject<{
|
|
175
|
+
name: z.ZodString;
|
|
176
|
+
summary: z.ZodString;
|
|
177
|
+
}, z.core.$strict>;
|
|
178
|
+
currency: z.ZodEnum<{
|
|
179
|
+
USD: "USD";
|
|
180
|
+
}>;
|
|
181
|
+
unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
182
|
+
rules: z.ZodObject<{
|
|
183
|
+
evidence: z.ZodString;
|
|
184
|
+
leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
185
|
+
maxPerBooking: z.ZodNumber;
|
|
186
|
+
dailyCapacity: z.ZodNumber;
|
|
187
|
+
freeCancelWindow: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
188
|
+
lateCancellationBps: z.ZodNumber;
|
|
189
|
+
noShowBps: z.ZodNumber;
|
|
190
|
+
payment: z.ZodObject<{
|
|
191
|
+
route: z.ZodEnum<{
|
|
192
|
+
invoice: "invoice";
|
|
193
|
+
transfer: "transfer";
|
|
194
|
+
}>;
|
|
195
|
+
dueAfterDelivery: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
196
|
+
}, z.core.$strict>;
|
|
197
|
+
}, z.core.$strict>;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
/** Reads an offer version from JSON, refusing one `serviceOfferProblem` finds anything wrong with. */
|
|
200
|
+
export declare function parseServiceOfferVersion(json: unknown): Parsed<ServiceOfferVersion>;
|
|
201
|
+
/**
|
|
202
|
+
* An offer version's id: keccak256 of the ABI encoding of `avow:offer:service/1` and the
|
|
203
|
+
* version's canonical JSON as a string. It hashes exactly the fields a version has, so the same
|
|
204
|
+
* version always has the same id, and it throws for a version `serviceOfferProblem` refuses rather
|
|
205
|
+
* than give one an id.
|
|
206
|
+
*/
|
|
207
|
+
export declare function offerVersionId(version: ServiceOfferVersion): Hex;
|
|
208
|
+
/** What booking a number of units of an offer version costs, in micros. */
|
|
209
|
+
export interface ServiceOfferQuote {
|
|
210
|
+
/** The whole price, the unit price times the quantity, paid by the payment route. */
|
|
211
|
+
total: bigint;
|
|
212
|
+
/** What a late cancellation can cost, the version's share of the whole price. */
|
|
213
|
+
lateCancellation: bigint;
|
|
214
|
+
/** What not being there to take delivery can cost, the version's share of the whole price. */
|
|
215
|
+
noShow: bigint;
|
|
216
|
+
/** The reserve the booking takes, the larger of the two charges. */
|
|
217
|
+
reserve: bigint;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* What booking `quantity` units of an offer version costs. A search prices an offer with it and
|
|
221
|
+
* `serviceOfferTerms` builds terms from it, so the price an agent is shown is the price it books.
|
|
222
|
+
* Throws for a version `serviceOfferProblem` refuses, a quantity the version doesn't take, or a
|
|
223
|
+
* price so small that every charge rounds to zero.
|
|
224
|
+
*/
|
|
225
|
+
export declare function serviceOfferQuote(version: ServiceOfferVersion, quantity: number): ServiceOfferQuote;
|
|
226
|
+
/**
|
|
227
|
+
* The service terms for booking `quantity` units of an offer version at `now`. Delivery is due the
|
|
228
|
+
* lead time after `now`, free cancellation lasts the version's window from `now`, and the supplier
|
|
229
|
+
* accepts within `SERVICE_ACCEPT_WITHIN`. A late cancellation and a no-show cost their shares of the
|
|
230
|
+
* whole price, charges can be reported until `SERVICE_CHARGE_AFTER` past the delivery deadline,
|
|
231
|
+
* when the reserve comes back, and the contest window is ten minutes. Payment is due the version's
|
|
232
|
+
* interval after the delivery deadline. The arbiter and the day-90 share are the deployment's,
|
|
233
|
+
* which Avow's approvals name. Throws for a version `serviceOfferProblem` refuses, a quantity the
|
|
234
|
+
* version doesn't take, or a price so small that every charge rounds to zero.
|
|
235
|
+
*/
|
|
236
|
+
export declare function serviceOfferTerms(version: ServiceOfferVersion, quantity: number, now: bigint, settlement: {
|
|
237
|
+
arbiter: Address;
|
|
238
|
+
day90SupplierShareBps: number;
|
|
239
|
+
}): ServiceTerms;
|
|
240
|
+
/**
|
|
241
|
+
* Whether service terms are exactly the ones `serviceOfferTerms` builds from this version for
|
|
242
|
+
* their quantity, at the moment their delivery deadline implies, under their own arbiter and
|
|
243
|
+
* day-90 share. A booking that passes names the version's id and carries its item, price,
|
|
244
|
+
* evidence, payment, deadlines and charges unchanged, so a supplier or Avow can tell the price a
|
|
245
|
+
* buyer signed is the version's price.
|
|
246
|
+
*/
|
|
247
|
+
export declare function serviceTermsMatchOffer(terms: ServiceTerms, version: ServiceOfferVersion): boolean;
|
|
248
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAuB,KAAK,GAAG,E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