@agoric/ertp 0.16.3-dev-22cbeb1.0 → 0.16.3-dev-284e2db.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.
@@ -8,14 +8,13 @@ const { Fail } = assert;
8
8
  const empty = 0n;
9
9
 
10
10
  /**
11
- * Fungible digital assets use the natMathHelpers to manage balances -
12
- * the operations are merely arithmetic on natural, non-negative
13
- * numbers.
11
+ * Fungible digital assets use the natMathHelpers to manage balances - the
12
+ * operations are merely arithmetic on natural, non-negative numbers.
14
13
  *
15
- * Natural numbers are used for fungible erights such as money because
16
- * rounding issues make floats problematic. All operations should be
17
- * done with the smallest whole unit such that the `natMathHelpers` never
18
- * deals with fractional parts.
14
+ * Natural numbers are used for fungible erights such as money because rounding
15
+ * issues make floats problematic. All operations should be done with the
16
+ * smallest whole unit such that the `natMathHelpers` never deals with
17
+ * fractional parts.
19
18
  *
20
19
  * @type {MathHelpers<NatValue>}
21
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAoFO,0GAPI,MAAM,2DAGN,OAAO,6GA+UjB;sBA9Ya,OAAO,kBAAkB,EAAE,OAAO"}
1
+ {"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAoFO,0GAPI,MAAM,2DAGN,OAAO,6GA2UjB;sBA1Ya,OAAO,kBAAkB,EAAE,OAAO"}
@@ -70,8 +70,8 @@ const amountShapeFromElementShape = (brand, assetKind, elementShape) => {
70
70
  };
71
71
 
72
72
  /**
73
- * Make the paymentLedger, the source of truth for the balances of
74
- * payments. All minting and transfer authority originates here.
73
+ * Make the paymentLedger, the source of truth for the balances of payments. All
74
+ * minting and transfer authority originates here.
75
75
  *
76
76
  * @template {AssetKind} K
77
77
  * @param {Baggage} issuerBaggage
@@ -146,22 +146,21 @@ export const preparePaymentLedger = (
146
146
  );
147
147
 
148
148
  /**
149
- * A withdrawn live payment is associated with the recovery set of
150
- * the purse it was withdrawn from. Let's call these "recoverable"
151
- * payments. All recoverable payments are live, but not all live
152
- * payments are recoverable. We do the bookkeeping for payment recovery
153
- * with this weakmap from recoverable payments to the recovery set they are
154
- * in.
155
- * A bunch of interesting invariants here:
156
- * * Every payment that is a key in the outer `paymentRecoverySets`
157
- * weakMap is also in the recovery set indexed by that payment.
158
- * * Implied by the above but worth stating: the payment is only
159
- * in at most one recovery set.
160
- * * A recovery set only contains such payments.
161
- * * Every purse is associated with exactly one recovery set unique to
162
- * it.
163
- * * A purse's recovery set only contains payments withdrawn from
164
- * that purse and not yet consumed.
149
+ * A withdrawn live payment is associated with the recovery set of the purse
150
+ * it was withdrawn from. Let's call these "recoverable" payments. All
151
+ * recoverable payments are live, but not all live payments are recoverable.
152
+ * We do the bookkeeping for payment recovery with this weakmap from
153
+ * recoverable payments to the recovery set they are in. A bunch of
154
+ * interesting invariants here:
155
+ *
156
+ * - Every payment that is a key in the outer `paymentRecoverySets` weakMap is
157
+ * also in the recovery set indexed by that payment.
158
+ * - Implied by the above but worth stating: the payment is only in at most one
159
+ * recovery set.
160
+ * - A recovery set only contains such payments.
161
+ * - Every purse is associated with exactly one recovery set unique to it.
162
+ * - A purse's recovery set only contains payments withdrawn from that purse and
163
+ * not yet consumed.
165
164
  *
166
165
  * @type {WeakMapStore<Payment, SetStore<Payment>>}
167
166
  */
@@ -172,8 +171,7 @@ export const preparePaymentLedger = (
172
171
 
173
172
  /**
174
173
  * To maintain the invariants listed in the `paymentRecoverySets` comment,
175
- * `initPayment` should contain the only
176
- * call to `paymentLedger.init`.
174
+ * `initPayment` should contain the only call to `paymentLedger.init`.
177
175
  *
178
176
  * @param {Payment} payment
179
177
  * @param {Amount} amount
@@ -189,8 +187,7 @@ export const preparePaymentLedger = (
189
187
 
190
188
  /**
191
189
  * To maintain the invariants listed in the `paymentRecoverySets` comment,
192
- * `deletePayment` should contain the only
193
- * call to `paymentLedger.delete`.
190
+ * `deletePayment` should contain the only call to `paymentLedger.delete`.
194
191
  *
195
192
  * @param {Payment} payment
196
193
  */
@@ -203,19 +200,18 @@ export const preparePaymentLedger = (
203
200
  }
204
201
  };
205
202
 
206
- /** @type {(left: Amount, right: Amount) => Amount } */
203
+ /** @type {(left: Amount, right: Amount) => Amount} */
207
204
  const add = (left, right) => AmountMath.add(left, right, brand);
208
- /** @type {(left: Amount, right: Amount) => Amount } */
205
+ /** @type {(left: Amount, right: Amount) => Amount} */
209
206
  const subtract = (left, right) => AmountMath.subtract(left, right, brand);
210
207
  /** @type {(allegedAmount: Amount) => Amount} */
211
208
  const coerce = allegedAmount => AmountMath.coerce(brand, allegedAmount);
212
- /** @type {(left: Amount, right: Amount) => boolean } */
209
+ /** @type {(left: Amount, right: Amount) => boolean} */
213
210
 
214
211
  /**
215
- * Methods like deposit() have an optional second parameter
216
- * `optAmountShape`
217
- * which, if present, is supposed to match the balance of the
218
- * payment. This helper function does that check.
212
+ * Methods like deposit() have an optional second parameter `optAmountShape`
213
+ * which, if present, is supposed to match the balance of the payment. This
214
+ * helper function does that check.
219
215
  *
220
216
  * Note: `optAmountShape` is user-supplied with no previous validation.
221
217
  *
@@ -243,10 +239,10 @@ export const preparePaymentLedger = (
243
239
  /**
244
240
  * Used by the purse code to implement purse.deposit
245
241
  *
246
- * @param {Amount} currentBalance - the current balance of the purse
247
- * before a deposit
248
- * @param {(newPurseBalance: Amount) => void} updatePurseBalance -
249
- * commit the purse balance
242
+ * @param {Amount} currentBalance - the current balance of the purse before a
243
+ * deposit
244
+ * @param {(newPurseBalance: Amount) => void} updatePurseBalance - commit the
245
+ * purse balance
250
246
  * @param {Payment} srcPayment
251
247
  * @param {Pattern} [optAmountShape]
252
248
  * @returns {Amount}
@@ -282,10 +278,10 @@ export const preparePaymentLedger = (
282
278
  /**
283
279
  * Used by the purse code to implement purse.withdraw
284
280
  *
285
- * @param {Amount} currentBalance - the current balance of the purse
286
- * before a withdrawal
287
- * @param {(newPurseBalance: Amount) => void} updatePurseBalance -
288
- * commit the purse balance
281
+ * @param {Amount} currentBalance - the current balance of the purse before a
282
+ * withdrawal
283
+ * @param {(newPurseBalance: Amount) => void} updatePurseBalance - commit the
284
+ * purse balance
289
285
  * @param {Amount} amount - the amount to be withdrawn
290
286
  * @param {SetStore<Payment>} recoverySet
291
287
  * @returns {Payment}
@@ -378,9 +374,9 @@ export const preparePaymentLedger = (
378
374
  /**
379
375
  * Provides for the recovery of newly minted but not-yet-deposited payments.
380
376
  *
381
- * Because the `mintRecoveryPurse` is placed in baggage, even if the
382
- * caller of `makeIssuerKit` drops it on the floor, it can still be
383
- * recovered in an emergency upgrade.
377
+ * Because the `mintRecoveryPurse` is placed in baggage, even if the caller of
378
+ * `makeIssuerKit` drops it on the floor, it can still be recovered in an
379
+ * emergency upgrade.
384
380
  *
385
381
  * @type {Purse<K>}
386
382
  */
@@ -27,14 +27,44 @@ export namespace IssuerKitShape {
27
27
  export { IssuerShape as issuer };
28
28
  export { DisplayInfoShape as displayInfo };
29
29
  }
30
- export const BrandI: import("@endo/patterns").InterfaceGuard;
30
+ export const BrandI: import("@endo/patterns").InterfaceGuard<{
31
+ isMyIssuer: any;
32
+ getAllegedName: any;
33
+ getDisplayInfo: any;
34
+ getAmountShape: any;
35
+ }>;
31
36
  export function makeIssuerInterfaces(brandShape?: Pattern, assetKindShape?: Pattern, amountShape?: Pattern): {
32
- IssuerI: import("@endo/patterns").InterfaceGuard;
33
- MintI: import("@endo/patterns").InterfaceGuard;
34
- PaymentI: import("@endo/patterns").InterfaceGuard;
37
+ IssuerI: import("@endo/patterns").InterfaceGuard<{
38
+ getBrand: any;
39
+ getAllegedName: any;
40
+ getAssetKind: any;
41
+ getDisplayInfo: any;
42
+ makeEmptyPurse: any;
43
+ isLive: any;
44
+ getAmountOf: any;
45
+ burn: any;
46
+ }>;
47
+ MintI: import("@endo/patterns").InterfaceGuard<{
48
+ getIssuer: any;
49
+ mintPayment: any;
50
+ }>;
51
+ PaymentI: import("@endo/patterns").InterfaceGuard<{
52
+ getAllegedBrand: any;
53
+ }>;
35
54
  PurseIKit: {
36
- purse: import("@endo/patterns").InterfaceGuard;
37
- depositFacet: import("@endo/patterns").InterfaceGuard;
55
+ purse: import("@endo/patterns").InterfaceGuard<{
56
+ getAllegedBrand: any;
57
+ getCurrentAmount: any;
58
+ getCurrentAmountNotifier: any;
59
+ deposit: any;
60
+ getDepositFacet: any;
61
+ withdraw: any;
62
+ getRecoverySet: any;
63
+ recoverAll: any;
64
+ }>;
65
+ depositFacet: import("@endo/patterns").InterfaceGuard<{
66
+ receive: any;
67
+ }>;
38
68
  };
39
69
  };
40
70
  declare const AmountValueShape: import("@endo/patterns").Matcher;
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,0DAA+C;AAC/C,2DAAiD;AACjD,4DAAmD;AACnD,0DAA+C;AAC/C,iEAA6D;AAC7D,6DAAqD;AACrD,yDAA6C;;;;;;;;;AAqFtC,kCAHI,WAAW,mBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAYjE,kCAHI,WAAW,qBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAIxE,8CAA+C;AAE/C,8DAAuE;AAEvE,gEAaE;;;;;;;;AAYF,6DAKG;AAOI,kDAJI,OAAO,mBACP,OAAO,gBACP,OAAO;;;;;;;;EAkEjB;AAlKD,iEAKE"}
1
+ {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,0DAA+C;AAC/C,2DAAiD;AACjD,4DAAmD;AACnD,0DAA+C;AAC/C,iEAA6D;AAC7D,6DAAqD;AACrD,yDAA6C;;;;;;;;;AA+EtC,kCAHI,WAAW,mBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAYjE,kCAHI,WAAW,qBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAIxE,8CAA+C;AAE/C,8DAAuE;AAEvE,gEAaE;;;;;;;;AAYF;;;;;GAKG;AAOI,kDAJI,OAAO,mBACP,OAAO,gBACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEjB;AAlKD,iEAKE"}
package/src/typeGuards.js CHANGED
@@ -11,62 +11,56 @@ export const NotifierShape = M.remotable('Notifier');
11
11
  export const MintShape = M.remotable('Mint');
12
12
 
13
13
  /**
14
- * When the AmountValue of an Amount fits the NatValueShape, i.e., when it is
15
- * a non-negative bigint, then it represents that many units of the
16
- * fungible asset represented by that amount. The brand of that amount
17
- * should indeed represent a kind of asset consisting of a countable
18
- * set of fungible units.
14
+ * When the AmountValue of an Amount fits the NatValueShape, i.e., when it is a
15
+ * non-negative bigint, then it represents that many units of the fungible asset
16
+ * represented by that amount. The brand of that amount should indeed represent
17
+ * a kind of asset consisting of a countable set of fungible units.
19
18
  */
20
19
  const NatValueShape = M.nat();
21
20
 
22
21
  /**
23
22
  * When the AmountValue of an Amount fits the CopySetValueShape, i.e., when it
24
- * is a CopySet, then it represents the set of those
25
- * keys, where each key represents some individual non-fungible
26
- * item, like a concert ticket, from the non-fungible asset class
27
- * represented by that amount's brand. The amount itself represents
28
- * the set of these items, as opposed to any of the other items
29
- * from the same asset class.
23
+ * is a CopySet, then it represents the set of those keys, where each key
24
+ * represents some individual non-fungible item, like a concert ticket, from the
25
+ * non-fungible asset class represented by that amount's brand. The amount
26
+ * itself represents the set of these items, as opposed to any of the other
27
+ * items from the same asset class.
30
28
  *
31
- * If a given value class represents concert tickets, it seems bizarre
32
- * that we can form amounts of any key. The hard constraint is that
33
- * the code that holds the mint for that asset class---the one associated
34
- * with that brand, only mints the items representing the real units
35
- * of that asset class as defined by it. Anyone else can put together
36
- * an amount expressing, for example, that they "want" some items that
37
- * will never be minted. That want will never be satisfied.
38
- * "You can't always get..."
29
+ * If a given value class represents concert tickets, it seems bizarre that we
30
+ * can form amounts of any key. The hard constraint is that the code that holds
31
+ * the mint for that asset class---the one associated with that brand, only
32
+ * mints the items representing the real units of that asset class as defined by
33
+ * it. Anyone else can put together an amount expressing, for example, that they
34
+ * "want" some items that will never be minted. That want will never be
35
+ * satisfied. "You can't always get..."
39
36
  */
40
37
  const CopySetValueShape = M.set();
41
38
 
42
39
  /**
43
- * When the AmountValue of an Amount fits the SetValueShape, i.e., when it
44
- * is a CopyArray of passable Keys. This representation is deprecated.
40
+ * When the AmountValue of an Amount fits the SetValueShape, i.e., when it is a
41
+ * CopyArray of passable Keys. This representation is deprecated.
45
42
  *
46
43
  * @deprecated Please change from using array-based SetValues to CopySet-based
47
- * CopySetValues.
44
+ * CopySetValues.
48
45
  */
49
46
  const SetValueShape = M.arrayOf(M.key());
50
47
 
51
48
  /**
52
49
  * When the AmountValue of an Amount fits the CopyBagValueShape, i.e., when it
53
- * is a CopyBag, then it represents the bag (multiset) of those
54
- * keys, where each key represents some individual semi-fungible
55
- * item, like a concert ticket, from the semi-fungible asset class
56
- * represented by that amount's brand. The number of times that key
57
- * appears in the bag is the number of fungible units of that key.
58
- * The amount itself represents
59
- * the bag of these items, as opposed to any of the other items
60
- * from the same asset class.
50
+ * is a CopyBag, then it represents the bag (multiset) of those keys, where each
51
+ * key represents some individual semi-fungible item, like a concert ticket,
52
+ * from the semi-fungible asset class represented by that amount's brand. The
53
+ * number of times that key appears in the bag is the number of fungible units
54
+ * of that key. The amount itself represents the bag of these items, as opposed
55
+ * to any of the other items from the same asset class.
61
56
  *
62
- * If a given value class represents concert tickets, it seems bizarre
63
- * that we can form amounts of any key. The hard constraint is that
64
- * the code that holds the mint for that asset class---the one associated
65
- * with that brand, only mints the items representing the real units
66
- * of that asset class as defined by it. Anyone else can put together
67
- * an amount expressing, for example, that they "want" some items that
68
- * will never be minted. That want will never be satisfied.
69
- * "You can't always get..."
57
+ * If a given value class represents concert tickets, it seems bizarre that we
58
+ * can form amounts of any key. The hard constraint is that the code that holds
59
+ * the mint for that asset class---the one associated with that brand, only
60
+ * mints the items representing the real units of that asset class as defined by
61
+ * it. Anyone else can put together an amount expressing, for example, that they
62
+ * "want" some items that will never be minted. That want will never be
63
+ * satisfied. "You can't always get..."
70
64
  */
71
65
  const CopyBagValueShape = M.bag();
72
66
 
@@ -106,11 +100,11 @@ export const isCopySetValue = value => matches(value, CopySetValueShape);
106
100
  harden(isCopySetValue);
107
101
 
108
102
  /**
109
- * Returns true if value is a pass by copy array structure. Does not
110
- * check for duplicates. To check for duplicates, use setMathHelpers.coerce.
103
+ * Returns true if value is a pass by copy array structure. Does not check for
104
+ * duplicates. To check for duplicates, use setMathHelpers.coerce.
111
105
  *
112
106
  * @deprecated Please change from using array-based SetValues to CopySet-based
113
- * CopySetValues.
107
+ * CopySetValues.
114
108
  * @param {AmountValue} value
115
109
  * @returns {value is SetValue}
116
110
  */