@agoric/ertp 0.16.3-dev-857e650.0 → 0.16.3-dev-fb922d3.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.
@@ -4,148 +4,134 @@
4
4
 
5
5
  /**
6
6
  * @template {AssetKind} [K=AssetKind]
7
- * @typedef {object} Amount
8
- * Amounts are descriptions of digital assets, answering the questions
9
- * "how much" and "of what kind". Amounts are values labeled with a brand.
10
- * AmountMath executes the logic of how amounts are changed when digital
11
- * assets are merged, separated, or otherwise manipulated. For
12
- * example, a deposit of 2 bucks into a purse that already has 3 bucks
13
- * gives a new purse balance of 5 bucks. An empty purse has 0 bucks. AmountMath
14
- * relies heavily on polymorphic MathHelpers, which manipulate the unbranded
15
- * portion.
16
- *
7
+ * @typedef {object} Amount Amounts are descriptions of digital assets,
8
+ * answering the questions "how much" and "of what kind". Amounts are values
9
+ * labeled with a brand. AmountMath executes the logic of how amounts are
10
+ * changed when digital assets are merged, separated, or otherwise
11
+ * manipulated. For example, a deposit of 2 bucks into a purse that already
12
+ * has 3 bucks gives a new purse balance of 5 bucks. An empty purse has 0
13
+ * bucks. AmountMath relies heavily on polymorphic MathHelpers, which
14
+ * manipulate the unbranded portion.
17
15
  * @property {Brand<K>} brand
18
16
  * @property {AssetValueForKind<K>} value
19
17
  */
20
18
 
21
19
  /**
22
- * @typedef {NatValue | SetValue | CopySet | CopyBag} AmountValue
23
- * An `AmountValue` describes a set or quantity of assets that can be owned or
24
- * shared.
25
- *
26
- * A fungible `AmountValue` uses a non-negative bigint to represent a quantity
27
- * of that many assets.
28
- *
29
- * A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
30
- * a set of whatever asset each key represents. A `Key` is a passable value
31
- * that can be used as an element in a set (SetStore or CopySet) or as the
32
- * key in a map (MapStore or CopyMap).
33
- *
34
- * `SetValue` is for the deprecated set representation, using an array directly
35
- * to represent the array of its elements. `CopySet` is the proper
36
- * representation using a CopySet.
37
- *
38
- * A semi-fungible `CopyBag` is represented as a
39
- * `CopyBag` of `Key` objects. "Bag" is synonymous with MultiSet, where an
40
- * element of a bag can be present once or more times, i.e., some positive
41
- * bigint number of times, representing that quantity of the asset represented
42
- * by that key.
20
+ * @typedef {NatValue | SetValue | CopySet | CopyBag} AmountValue An
21
+ * `AmountValue` describes a set or quantity of assets that can be owned or
22
+ * shared.
23
+ *
24
+ * A fungible `AmountValue` uses a non-negative bigint to represent a quantity
25
+ * of that many assets.
26
+ *
27
+ * A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
28
+ * a set of whatever asset each key represents. A `Key` is a passable value
29
+ * that can be used as an element in a set (SetStore or CopySet) or as the key
30
+ * in a map (MapStore or CopyMap).
31
+ *
32
+ * `SetValue` is for the deprecated set representation, using an array directly
33
+ * to represent the array of its elements. `CopySet` is the proper
34
+ * representation using a CopySet.
35
+ *
36
+ * A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
37
+ * "Bag" is synonymous with MultiSet, where an element of a bag can be present
38
+ * once or more times, i.e., some positive bigint number of times,
39
+ * representing that quantity of the asset represented by that key.
43
40
  */
44
41
 
45
42
  /**
46
- * @typedef {'nat' | 'set' | 'copySet' | 'copyBag' } AssetKind
47
- *
48
- * See doc-comment for `AmountValue`.
43
+ * @typedef {'nat' | 'set' | 'copySet' | 'copyBag'} AssetKind See doc-comment
44
+ * for `AmountValue`.
49
45
  */
50
46
 
51
47
  /**
52
48
  * @template {AssetKind} K
53
- * @typedef {K extends 'nat' ? NatValue :
54
- * K extends 'set' ? SetValue :
55
- * K extends 'copySet' ? CopySet:
56
- * K extends 'copyBag' ? CopyBag :
57
- * never
58
- * } AssetValueForKind
49
+ * @typedef {K extends 'nat'
50
+ * ? NatValue
51
+ * : K extends 'set'
52
+ * ? SetValue
53
+ * : K extends 'copySet'
54
+ * ? CopySet
55
+ * : K extends 'copyBag'
56
+ * ? CopyBag
57
+ * : never} AssetValueForKind
59
58
  */
60
59
 
61
60
  /**
62
61
  * @template {AmountValue} V
63
- * @typedef {V extends NatValue ? 'nat' :
64
- * V extends SetValue ? 'set' :
65
- * V extends CopySet ? 'copySet' :
66
- * V extends CopyBag ? 'copyBag' :
67
- * never} AssetKindForValue
62
+ * @typedef {V extends NatValue
63
+ * ? 'nat'
64
+ * : V extends SetValue
65
+ * ? 'set'
66
+ * : V extends CopySet
67
+ * ? 'copySet'
68
+ * : V extends CopyBag
69
+ * ? 'copyBag'
70
+ * : never} AssetKindForValue
68
71
  */
69
72
 
70
73
  /**
71
74
  * @template {AssetKind} [K=AssetKind]
72
75
  * @typedef {object} DisplayInfo
73
- * @property {number} [decimalPlaces] Tells the display software how
74
- * many decimal places to move the decimal over to the left, or in
75
- * other words, which position corresponds to whole numbers. We
76
- * require fungible digital assets to be represented in integers, in
77
- * the smallest unit (i.e. USD might be represented in mill, a
78
- * thousandth of a dollar. In that case, `decimalPlaces` would be
79
- * 3.) This property is optional, and for non-fungible digital
80
- * assets, should not be specified. The decimalPlaces property
81
- * should be used for *display purposes only*. Any other use is an
76
+ * @property {number} [decimalPlaces] Tells the display software how many
77
+ * decimal places to move the decimal over to the left, or in other words,
78
+ * which position corresponds to whole numbers. We require fungible digital
79
+ * assets to be represented in integers, in the smallest unit (i.e. USD might
80
+ * be represented in mill, a thousandth of a dollar. In that case,
81
+ * `decimalPlaces` would be 3.) This property is optional, and for
82
+ * non-fungible digital assets, should not be specified. The decimalPlaces
83
+ * property should be used for _display purposes only_. Any other use is an
82
84
  * anti-pattern.
83
- * @property {K} assetKind - the kind of asset, either
84
- * AssetKind.NAT (fungible) or
85
- * AssetKind.SET or AssetKind.COPY_SET (non-fungible)
85
+ * @property {K} assetKind - the kind of asset, either AssetKind.NAT (fungible)
86
+ * or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
86
87
  */
87
88
 
88
89
  /**
89
90
  * @template {AssetKind} [K=AssetKind]
90
- * @typedef {object} Brand
91
- * The brand identifies the kind of issuer, and has a function to get the
92
- * alleged name for the kind of asset described. The alleged name (such
93
- * as 'BTC' or 'moola') is provided by the maker of the issuer and should
94
- * not be trusted as accurate.
95
- *
96
- * Every amount created by a particular AmountMath will share the same brand,
97
- * but recipients cannot rely on the brand to verify that a purported amount
98
- * represents the issuer they intended, since the same brand can be reused by
99
- * a misbehaving issuer.
100
- *
91
+ * @typedef {object} Brand The brand identifies the kind of issuer, and has a
92
+ * function to get the alleged name for the kind of asset described. The
93
+ * alleged name (such as 'BTC' or 'moola') is provided by the maker of the
94
+ * issuer and should not be trusted as accurate.
95
+ *
96
+ * Every amount created by a particular AmountMath will share the same brand,
97
+ * but recipients cannot rely on the brand to verify that a purported amount
98
+ * represents the issuer they intended, since the same brand can be reused by
99
+ * a misbehaving issuer.
101
100
  * @property {(allegedIssuer: ERef<Issuer>) => Promise<boolean>} isMyIssuer
102
- * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
101
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
103
102
  * @property {() => string} getAllegedName
104
- * @property {() => DisplayInfo<K>} getDisplayInfo
105
- * Give information to UI on how to display the amount.
103
+ * @property {() => DisplayInfo<K>} getDisplayInfo Give information to UI on how
104
+ * to display the amount.
106
105
  * @property {() => Pattern} getAmountShape
107
106
  */
108
107
 
109
108
  // /////////////////////////// Issuer //////////////////////////////////////////
110
109
 
111
110
  /**
112
- * @callback IssuerIsLive
113
- *
114
- * Return true if the payment continues to exist.
115
- *
116
- * If the payment is a promise, the operation will proceed upon
117
- * resolution.
111
+ * @callback IssuerIsLive Return true if the payment continues to exist.
118
112
  *
113
+ * If the payment is a promise, the operation will proceed upon resolution.
119
114
  * @param {ERef<Payment>} payment
120
115
  * @returns {Promise<boolean>}
121
116
  */
122
117
  /**
123
118
  * @template {AssetKind} K
124
- * @callback IssuerGetAmountOf
125
- *
126
- * Get the amount of digital assets in the payment. Because the
127
- * payment is not trusted, we cannot call a method on it directly, and
128
- * must use the issuer instead.
129
- *
130
- * If the payment is a promise, the operation will proceed upon
131
- * resolution.
119
+ * @callback IssuerGetAmountOf Get the amount of digital assets in the payment.
120
+ * Because the payment is not trusted, we cannot call a method on it directly,
121
+ * and must use the issuer instead.
132
122
  *
123
+ * If the payment is a promise, the operation will proceed upon resolution.
133
124
  * @param {ERef<Payment>} payment
134
125
  * @returns {Promise<Amount<K>>}
135
126
  */
136
127
 
137
128
  /**
138
- * @callback IssuerBurn
139
- *
140
- * Burn all of the digital assets in the
141
- * payment. `optAmount` is optional. If `optAmount` is present, the
142
- * code will insist that the amount of the digital assets in the
143
- * payment is equal to `optAmount`, to prevent sending the wrong
144
- * payment and other confusion.
145
- *
146
- * If the payment is a promise, the operation will proceed upon
147
- * resolution.
129
+ * @callback IssuerBurn Burn all of the digital assets in the payment.
130
+ * `optAmount` is optional. If `optAmount` is present, the code will insist
131
+ * that the amount of the digital assets in the payment is equal to
132
+ * `optAmount`, to prevent sending the wrong payment and other confusion.
148
133
  *
134
+ * If the payment is a promise, the operation will proceed upon resolution.
149
135
  * @param {ERef<Payment>} payment
150
136
  * @param {Pattern} [optAmountShape]
151
137
  * @returns {Promise<Amount>}
@@ -153,17 +139,13 @@
153
139
 
154
140
  /**
155
141
  * @template {AssetKind} K
156
- * @callback IssuerClaim
157
- *
158
- * Transfer all digital assets from the payment to a new payment and
159
- * delete the original. `optAmount` is optional. If `optAmount` is
160
- * present, the code will insist that the amount of digital assets in
161
- * the payment is equal to `optAmount`, to prevent sending the wrong
162
- * payment and other confusion.
163
- *
164
- * If the payment is a promise, the operation will proceed upon
165
- * resolution.
142
+ * @callback IssuerClaim Transfer all digital assets from the payment to a new
143
+ * payment and delete the original. `optAmount` is optional. If `optAmount` is
144
+ * present, the code will insist that the amount of digital assets in the
145
+ * payment is equal to `optAmount`, to prevent sending the wrong payment and
146
+ * other confusion.
166
147
  *
148
+ * If the payment is a promise, the operation will proceed upon resolution.
167
149
  * @param {ERef<Payment<K>>} payment
168
150
  * @param {Pattern} [optAmountShape]
169
151
  * @returns {Promise<Payment<K>>}
@@ -171,13 +153,10 @@
171
153
 
172
154
  /**
173
155
  * @template {AssetKind} K
174
- * @callback IssuerCombine
175
- *
176
- * Combine multiple payments into one payment.
177
- *
178
- * If any of the payments is a promise, the operation will proceed
179
- * upon resolution.
156
+ * @callback IssuerCombine Combine multiple payments into one payment.
180
157
  *
158
+ * If any of the payments is a promise, the operation will proceed upon
159
+ * resolution.
181
160
  * @param {ERef<Payment<K>>[]} paymentsArray
182
161
  * @param {Amount<K>} [optTotalAmount]
183
162
  * @returns {Promise<Payment<K>>}
@@ -185,28 +164,20 @@
185
164
 
186
165
  /**
187
166
  * @template {AssetKind} K
188
- * @callback IssuerSplit
189
- *
190
- * Split a single payment into two payments,
191
- * A and B, according to the paymentAmountA passed in.
192
- *
193
- * If the payment is a promise, the operation will proceed upon
194
- * resolution.
167
+ * @callback IssuerSplit Split a single payment into two payments, A and B,
168
+ * according to the paymentAmountA passed in.
195
169
  *
170
+ * If the payment is a promise, the operation will proceed upon resolution.
196
171
  * @param {ERef<Payment<K>>} payment
197
172
  * @param {Amount<K>} paymentAmountA
198
173
  * @returns {Promise<Payment<K>[]>}
199
174
  */
200
175
 
201
176
  /**
202
- * @callback IssuerSplitMany
203
- *
204
- * Split a single payment into many payments, according to the amounts
205
- * passed in.
206
- *
207
- * If the payment is a promise, the operation will proceed upon
208
- * resolution.
177
+ * @callback IssuerSplitMany Split a single payment into many payments,
178
+ * according to the amounts passed in.
209
179
  *
180
+ * If the payment is a promise, the operation will proceed upon resolution.
210
181
  * @param {ERef<Payment>} payment
211
182
  * @param {Amount[]} amounts
212
183
  * @returns {Promise<Payment[]>}
@@ -214,30 +185,24 @@
214
185
 
215
186
  /**
216
187
  * @template {AssetKind} [K=AssetKind]
217
- * @typedef {object} Issuer
218
- *
219
- * The issuer cannot mint a new amount, but it can create empty purses
220
- * and payments. The issuer can also transform payments (splitting
221
- * payments, combining payments, burning payments, and claiming
222
- * payments exclusively). The issuer should be gotten from a trusted
223
- * source and then relied upon as the decider of whether an untrusted
224
- * payment is valid.
225
- *
226
- * @property {() => Brand<K>} getBrand Get the Brand for this Issuer. The
227
- * Brand indicates the type of digital asset and is shared by the
228
- * mint, the issuer, and any purses and payments of this particular
229
- * kind. The brand is not closely held, so this function should not be
230
- * trusted to identify an issuer alone. Fake digital assets and amount
231
- * can use another issuer's brand.
232
- *
233
- * @property {() => string} getAllegedName Get the allegedName for
234
- * this mint/issuer
235
- * @property {() => AssetKind} getAssetKind Get the kind of
236
- * MathHelpers used by this Issuer.
237
- * @property {() => DisplayInfo<K>} getDisplayInfo Give information to UI
238
- * on how to display amounts for this issuer.
239
- * @property {() => Purse<K>} makeEmptyPurse Make an empty purse of this
240
- * brand.
188
+ * @typedef {object} Issuer The issuer cannot mint a new amount, but it can
189
+ * create empty purses and payments. The issuer can also transform payments
190
+ * (splitting payments, combining payments, burning payments, and claiming
191
+ * payments exclusively). The issuer should be gotten from a trusted source
192
+ * and then relied upon as the decider of whether an untrusted payment is
193
+ * valid.
194
+ * @property {() => Brand<K>} getBrand Get the Brand for this Issuer. The Brand
195
+ * indicates the type of digital asset and is shared by the mint, the issuer,
196
+ * and any purses and payments of this particular kind. The brand is not
197
+ * closely held, so this function should not be trusted to identify an issuer
198
+ * alone. Fake digital assets and amount can use another issuer's brand.
199
+ * @property {() => string} getAllegedName Get the allegedName for this
200
+ * mint/issuer
201
+ * @property {() => AssetKind} getAssetKind Get the kind of MathHelpers used by
202
+ * this Issuer.
203
+ * @property {() => DisplayInfo<K>} getDisplayInfo Give information to UI on how
204
+ * to display amounts for this issuer.
205
+ * @property {() => Purse<K>} makeEmptyPurse Make an empty purse of this brand.
241
206
  * @property {IssuerIsLive} isLive
242
207
  * @property {IssuerGetAmountOf<K>} getAmountOf
243
208
  * @property {IssuerBurn} burn
@@ -264,33 +229,27 @@
264
229
 
265
230
  /**
266
231
  * @typedef {object} AdditionalDisplayInfo
267
- *
268
- * @property {number} [decimalPlaces] Tells the display software how
269
- * many decimal places to move the decimal over to the left, or in
270
- * other words, which position corresponds to whole numbers. We
271
- * require fungible digital assets to be represented in integers, in
272
- * the smallest unit (i.e. USD might be represented in mill, a
273
- * thousandth of a dollar. In that case, `decimalPlaces` would be
274
- * 3.) This property is optional, and for non-fungible digital
275
- * assets, should not be specified. The decimalPlaces property
276
- * should be used for *display purposes only*. Any other use is an
232
+ * @property {number} [decimalPlaces] Tells the display software how many
233
+ * decimal places to move the decimal over to the left, or in other words,
234
+ * which position corresponds to whole numbers. We require fungible digital
235
+ * assets to be represented in integers, in the smallest unit (i.e. USD might
236
+ * be represented in mill, a thousandth of a dollar. In that case,
237
+ * `decimalPlaces` would be 3.) This property is optional, and for
238
+ * non-fungible digital assets, should not be specified. The decimalPlaces
239
+ * property should be used for _display purposes only_. Any other use is an
277
240
  * anti-pattern.
278
241
  * @property {AssetKind} [assetKind]
279
242
  */
280
243
 
281
- /**
282
- * @typedef {import('@agoric/swingset-vat').ShutdownWithFailure} ShutdownWithFailure
283
- */
244
+ /** @typedef {import('@agoric/swingset-vat').ShutdownWithFailure} ShutdownWithFailure */
284
245
 
285
246
  /**
286
247
  * @template {AssetKind} [K=AssetKind]
287
- * @typedef {object} Mint
288
- * Holding a Mint carries the right to issue new digital assets. These
289
- * assets all have the same kind, which is called a Brand.
290
- *
248
+ * @typedef {object} Mint Holding a Mint carries the right to issue new digital
249
+ * assets. These assets all have the same kind, which is called a Brand.
291
250
  * @property {() => Issuer<K>} getIssuer Gets the Issuer for this mint.
292
- * @property {(newAmount: Amount<K>) => Payment<K>} mintPayment
293
- * Creates a new Payment containing newly minted amount.
251
+ * @property {(newAmount: Amount<K>) => Payment<K>} mintPayment Creates a new
252
+ * Payment containing newly minted amount.
294
253
  */
295
254
 
296
255
  /**
@@ -302,12 +261,12 @@
302
261
 
303
262
  /**
304
263
  * @typedef {object} DepositFacet
305
- * @property {DepositFacetReceive} receive
306
- * Deposit all the contents of payment into the purse that made this facet,
307
- * returning the amount. If the optional argument `optAmount` does not equal the
308
- * amount of digital assets in the payment, throw an error.
264
+ * @property {DepositFacetReceive} receive Deposit all the contents of payment
265
+ * into the purse that made this facet, returning the amount. If the optional
266
+ * argument `optAmount` does not equal the amount of digital assets in the
267
+ * payment, throw an error.
309
268
  *
310
- * If payment is a promise, throw an error.
269
+ * If payment is a promise, throw an error.
311
270
  */
312
271
 
313
272
  /**
@@ -320,121 +279,94 @@
320
279
 
321
280
  /**
322
281
  * @template {AssetKind} [K=AssetKind]
323
- * @typedef {object} Purse
324
- * Purses hold amount of digital assets of the same brand, but unlike Payments,
325
- * they are not meant to be sent to others. To transfer digital assets, a
326
- * Payment should be withdrawn from a Purse. The amount of digital
327
- * assets in a purse can change through the action of deposit() and withdraw().
328
- *
329
- * The primary use for Purses and Payments is for currency-like and goods-like
330
- * digital assets, but they can also be used to represent other kinds of rights,
331
- * such as the right to participate in a particular contract.
332
- *
333
- * @property {() => Brand<K>} getAllegedBrand Get the alleged Brand for this Purse
334
- *
335
- * @property {() => Amount<K>} getCurrentAmount
336
- * Get the amount contained in this purse.
337
- *
338
- * @property {() => LatestTopic<Amount<K>>} getCurrentAmountNotifier
339
- * Get a lossy notifier for changes to this purse's balance.
340
- *
341
- * @property {PurseDeposit<K>} deposit
342
- * Deposit all the contents of payment into this purse, returning the
343
- * amount. If the optional argument `optAmount` does not equal the
344
- * amount of digital assets in the payment, throw an error.
345
- *
346
- * If payment is a promise, throw an error.
347
- *
348
- * @property {() => DepositFacet} getDepositFacet
349
- * Return an object whose `receive` method deposits to the current Purse.
350
- *
351
- * @property {(amount: Amount<K>) => Payment<K>} withdraw
352
- * Withdraw amount from this purse into a new Payment.
353
- *
354
- * @property {() => CopySet<Payment<K>>} getRecoverySet
355
- * The set of payments withdrawn from this purse that are still live. These
356
- * are the payments that can still be recovered in emergencies by, for example,
357
- * depositing into this purse. Such a deposit action is like canceling an
358
- * outstanding check because you're tired of waiting for it. Once your
359
- * cancellation is acknowledged, you can spend the assets at stake on other
360
- * things. Afterwards, if the recipient of the original check finally gets
361
- * around to depositing it, their deposit fails.
362
- *
363
- * @property {() => Amount<K>} recoverAll
364
- * For use in emergencies, such as coming back from a traumatic crash and
365
- * upgrade. This deposits all the payments in this purse's recovery set
366
- * into the purse itself, returning the total amount of assets recovered.
282
+ * @typedef {object} Purse Purses hold amount of digital assets of the same
283
+ * brand, but unlike Payments, they are not meant to be sent to others. To
284
+ * transfer digital assets, a Payment should be withdrawn from a Purse. The
285
+ * amount of digital assets in a purse can change through the action of
286
+ * deposit() and withdraw().
287
+ *
288
+ * The primary use for Purses and Payments is for currency-like and goods-like
289
+ * digital assets, but they can also be used to represent other kinds of
290
+ * rights, such as the right to participate in a particular contract.
291
+ * @property {() => Brand<K>} getAllegedBrand Get the alleged Brand for this
292
+ * Purse
293
+ * @property {() => Amount<K>} getCurrentAmount Get the amount contained in this
294
+ * purse.
295
+ * @property {() => LatestTopic<Amount<K>>} getCurrentAmountNotifier Get a lossy
296
+ * notifier for changes to this purse's balance.
297
+ * @property {PurseDeposit<K>} deposit Deposit all the contents of payment into
298
+ * this purse, returning the amount. If the optional argument `optAmount` does
299
+ * not equal the amount of digital assets in the payment, throw an error.
300
+ *
301
+ * If payment is a promise, throw an error.
302
+ * @property {() => DepositFacet} getDepositFacet Return an object whose
303
+ * `receive` method deposits to the current Purse.
304
+ * @property {(amount: Amount<K>) => Payment<K>} withdraw Withdraw amount from
305
+ * this purse into a new Payment.
306
+ * @property {() => CopySet<Payment<K>>} getRecoverySet The set of payments
307
+ * withdrawn from this purse that are still live. These are the payments that
308
+ * can still be recovered in emergencies by, for example, depositing into this
309
+ * purse. Such a deposit action is like canceling an outstanding check because
310
+ * you're tired of waiting for it. Once your cancellation is acknowledged, you
311
+ * can spend the assets at stake on other things. Afterwards, if the recipient
312
+ * of the original check finally gets around to depositing it, their deposit
313
+ * fails.
314
+ * @property {() => Amount<K>} recoverAll For use in emergencies, such as coming
315
+ * back from a traumatic crash and upgrade. This deposits all the payments in
316
+ * this purse's recovery set into the purse itself, returning the total amount
317
+ * of assets recovered.
367
318
  */
368
319
 
369
320
  /**
370
321
  * @template {AssetKind} [K=AssetKind]
371
- * @typedef {object} Payment
372
- * Payments hold amount of digital assets of the same brand in transit. Payments
373
- * can be deposited in purses, split into multiple payments, combined, and
374
- * claimed (getting an exclusive payment). Payments are linear, meaning
375
- * that either a payment has the same amount of digital assets it
376
- * started with, or it is used up entirely. It is impossible to partially use a
377
- * payment.
378
- *
379
- * Payments are often received from other actors and therefore should
380
- * not be trusted themselves. To get the amount of digital assets in a payment,
381
- * use the trusted issuer: issuer.getAmountOf(payment),
382
- *
383
- * Payments can be converted to Purses by getting a trusted issuer and
384
- * calling `issuer.makeEmptyPurse()` to create a purse, then
385
- * `purse.deposit(payment)`.
386
- *
387
- * @property {() => Brand<K>} getAllegedBrand
388
- * Get the allegedBrand, indicating the type of digital asset this
389
- * payment purports to be, and which issuer to use. Because payments
390
- * are not trusted, any method calls on payments should be treated
391
- * with suspicion and verified elsewhere.
322
+ * @typedef {object} Payment Payments hold amount of digital assets of the same
323
+ * brand in transit. Payments can be deposited in purses, split into multiple
324
+ * payments, combined, and claimed (getting an exclusive payment). Payments
325
+ * are linear, meaning that either a payment has the same amount of digital
326
+ * assets it started with, or it is used up entirely. It is impossible to
327
+ * partially use a payment.
328
+ *
329
+ * Payments are often received from other actors and therefore should not be
330
+ * trusted themselves. To get the amount of digital assets in a payment, use
331
+ * the trusted issuer: issuer.getAmountOf(payment),
332
+ *
333
+ * Payments can be converted to Purses by getting a trusted issuer and calling
334
+ * `issuer.makeEmptyPurse()` to create a purse, then
335
+ * `purse.deposit(payment)`.
336
+ * @property {() => Brand<K>} getAllegedBrand Get the allegedBrand, indicating
337
+ * the type of digital asset this payment purports to be, and which issuer to
338
+ * use. Because payments are not trusted, any method calls on payments should
339
+ * be treated with suspicion and verified elsewhere.
392
340
  */
393
341
 
394
342
  /**
395
343
  * @template {AmountValue} V
396
- * @typedef {object} MathHelpers
397
- * All of the difference in how digital asset amount are manipulated can be
398
- * reduced to the behavior of the math on values. We extract this
399
- * custom logic into mathHelpers. MathHelpers are about value
400
- * arithmetic, whereas AmountMath is about amounts, which are the
401
- * values labeled with a brand. AmountMath use mathHelpers to do their value
402
- * arithmetic, and then brand the results, making a new amount.
403
- *
404
- * The MathHelpers are designed to be called only from AmountMath, and so
405
- * all methods but coerce can assume their inputs are valid. They only
406
- * need to do output validation, and only when there is a possibility of
407
- * invalid output.
408
- *
409
- * @property {(allegedValue: V) => V} doCoerce
410
- * Check the kind of this value and throw if it is not the
411
- * expected kind.
412
- *
413
- * @property {() => V} doMakeEmpty
414
- * Get the representation for the identity element (often 0 or an
415
- * empty array)
416
- *
417
- * @property {(value: V) => boolean} doIsEmpty
418
- * Is the value the identity element?
419
- *
420
- * @property {(left: V, right: V) => boolean} doIsGTE
421
- * Is the left greater than or equal to the right?
422
- *
423
- * @property {(left: V, right: V) => boolean} doIsEqual
424
- * Does left equal right?
425
- *
426
- * @property {(left: V, right: V) => V} doAdd
427
- * Return the left combined with the right.
428
- *
429
- * @property {(left: V, right: V) => V} doSubtract
430
- * Return what remains after removing the right from the left. If
431
- * something in the right was not in the left, we throw an error.
344
+ * @typedef {object} MathHelpers All of the difference in how digital asset
345
+ * amount are manipulated can be reduced to the behavior of the math on
346
+ * values. We extract this custom logic into mathHelpers. MathHelpers are
347
+ * about value arithmetic, whereas AmountMath is about amounts, which are the
348
+ * values labeled with a brand. AmountMath use mathHelpers to do their value
349
+ * arithmetic, and then brand the results, making a new amount.
350
+ *
351
+ * The MathHelpers are designed to be called only from AmountMath, and so all
352
+ * methods but coerce can assume their inputs are valid. They only need to do
353
+ * output validation, and only when there is a possibility of invalid output.
354
+ * @property {(allegedValue: V) => V} doCoerce Check the kind of this value and
355
+ * throw if it is not the expected kind.
356
+ * @property {() => V} doMakeEmpty Get the representation for the identity
357
+ * element (often 0 or an empty array)
358
+ * @property {(value: V) => boolean} doIsEmpty Is the value the identity
359
+ * element?
360
+ * @property {(left: V, right: V) => boolean} doIsGTE Is the left greater than
361
+ * or equal to the right?
362
+ * @property {(left: V, right: V) => boolean} doIsEqual Does left equal right?
363
+ * @property {(left: V, right: V) => V} doAdd Return the left combined with the
364
+ * right.
365
+ * @property {(left: V, right: V) => V} doSubtract Return what remains after
366
+ * removing the right from the left. If something in the right was not in the
367
+ * left, we throw an error.
432
368
  */
433
369
 
434
- /**
435
- * @typedef {bigint} NatValue
436
- */
370
+ /** @typedef {bigint} NatValue */
437
371
 
438
- /**
439
- * @typedef {Array<Key>} SetValue
440
- */
372
+ /** @typedef {Key[]} SetValue */