@agoric/ertp 0.16.3-dev-5dc325b.0 → 0.16.3-getting-started-dev-d127d1d.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +759 -0
  2. package/package.json +17 -24
  3. package/src/amountMath.d.ts +53 -0
  4. package/src/amountMath.d.ts.map +1 -0
  5. package/src/amountMath.js +63 -57
  6. package/src/displayInfo.d.ts +2 -0
  7. package/src/displayInfo.d.ts.map +1 -0
  8. package/src/index.d.ts +4 -0
  9. package/src/index.d.ts.map +1 -0
  10. package/src/issuerKit.d.ts +19 -0
  11. package/src/issuerKit.d.ts.map +1 -0
  12. package/src/issuerKit.js +59 -145
  13. package/src/legacy-payment-helpers.d.ts +5 -0
  14. package/src/legacy-payment-helpers.d.ts.map +1 -0
  15. package/src/legacy-payment-helpers.js +28 -23
  16. package/src/mathHelpers/copyBagMathHelpers.d.ts +5 -0
  17. package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -0
  18. package/src/mathHelpers/copyBagMathHelpers.js +3 -1
  19. package/src/mathHelpers/copySetMathHelpers.d.ts +5 -0
  20. package/src/mathHelpers/copySetMathHelpers.d.ts.map +1 -0
  21. package/src/mathHelpers/copySetMathHelpers.js +3 -1
  22. package/src/mathHelpers/natMathHelpers.d.ts +14 -0
  23. package/src/mathHelpers/natMathHelpers.d.ts.map +1 -0
  24. package/src/mathHelpers/natMathHelpers.js +7 -6
  25. package/src/mathHelpers/setMathHelpers.d.ts +6 -0
  26. package/src/mathHelpers/setMathHelpers.d.ts.map +1 -0
  27. package/src/payment.d.ts +3 -0
  28. package/src/payment.d.ts.map +1 -0
  29. package/src/payment.js +0 -5
  30. package/src/paymentLedger.d.ts +3 -0
  31. package/src/paymentLedger.d.ts.map +1 -0
  32. package/src/paymentLedger.js +40 -38
  33. package/src/purse.d.ts +13 -0
  34. package/src/purse.d.ts.map +1 -0
  35. package/src/purse.js +0 -18
  36. package/src/transientNotifier.d.ts +5 -0
  37. package/src/transientNotifier.d.ts.map +1 -0
  38. package/src/typeGuards.d.ts +42 -0
  39. package/src/typeGuards.d.ts.map +1 -0
  40. package/src/typeGuards.js +43 -37
  41. package/src/types-ambient.d.ts +376 -0
  42. package/src/types-ambient.d.ts.map +1 -0
  43. package/src/types-ambient.js +314 -218
  44. package/src/types.d.ts +376 -0
  45. package/src/types.d.ts.map +1 -0
  46. package/src/types.js +314 -218
package/src/issuerKit.js CHANGED
@@ -10,8 +10,6 @@ import { preparePaymentLedger } from './paymentLedger.js';
10
10
 
11
11
  import './types-ambient.js';
12
12
 
13
- // TODO Why does TypeScript lose the `MapStore` typing of `Baggage` here, even
14
- // though it knows the correct type at the exporting `@agoric/vat-data`
15
13
  /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
16
14
 
17
15
  /**
@@ -24,18 +22,16 @@ import './types-ambient.js';
24
22
  */
25
23
 
26
24
  /**
27
- * Used _only_ internally, to make a new issuerKit or to revive an old one.
28
- *
29
25
  * @template {AssetKind} K
30
26
  * @param {IssuerRecord<K>} issuerRecord
31
27
  * @param {Baggage} issuerBaggage
32
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
33
- * the middle of an atomic action (which btw should never happen), it
34
- * potentially leaves its ledger in a corrupted state. If this function was
35
- * provided, then the failed atomic action will call it, so that some larger
36
- * unit of computation, like the enclosing vat, can be shutdown before
37
- * anything else is corrupted by that corrupted state. See
38
- * https://github.com/Agoric/agoric-sdk/issues/3434
28
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
29
+ * in the middle of an atomic action (which btw should never happen), it
30
+ * potentially leaves its ledger in a corrupted state. If this function was
31
+ * provided, then the failed atomic action will call it, so that some
32
+ * larger unit of computation, like the enclosing vat, can be shutdown
33
+ * before anything else is corrupted by that corrupted state.
34
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
39
35
  * @returns {IssuerKit<K>}
40
36
  */
41
37
  const setupIssuerKit = (
@@ -82,77 +78,64 @@ harden(setupIssuerKit);
82
78
  const INSTANCE_KEY = 'issuer';
83
79
 
84
80
  /**
85
- * Used _only_ to upgrade a predecessor issuerKit. Use `makeDurableIssuerKit` to
86
- * make a new one.
87
- *
88
81
  * @template {AssetKind} K
89
82
  * @param {Baggage} issuerBaggage
90
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
91
- * the middle of an atomic action (which btw should never happen), it
92
- * potentially leaves its ledger in a corrupted state. If this function was
93
- * provided, then the failed atomic action will call it, so that some larger
94
- * unit of computation, like the enclosing vat, can be shutdown before
95
- * anything else is corrupted by that corrupted state. See
96
- * https://github.com/Agoric/agoric-sdk/issues/3434
83
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
84
+ * in the middle of an atomic action (which btw should never happen), it
85
+ * potentially leaves its ledger in a corrupted state. If this function was
86
+ * provided, then the failed atomic action will call it, so that some
87
+ * larger unit of computation, like the enclosing vat, can be shutdown
88
+ * before anything else is corrupted by that corrupted state.
89
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
97
90
  * @returns {IssuerKit<K>}
98
91
  */
99
- export const upgradeIssuerKit = (
92
+ export const prepareIssuerKit = (
100
93
  issuerBaggage,
101
94
  optShutdownWithFailure = undefined,
102
95
  ) => {
103
96
  const issuerRecord = issuerBaggage.get(INSTANCE_KEY);
104
97
  return setupIssuerKit(issuerRecord, issuerBaggage, optShutdownWithFailure);
105
98
  };
106
- harden(upgradeIssuerKit);
99
+ harden(prepareIssuerKit);
107
100
 
108
101
  /**
109
- * Does baggage already have an issuerKit?
102
+ * Does baggage already have an issuer from prepareIssuerKit()?
103
+ * That is: does it have the relevant keys defined?
110
104
  *
111
105
  * @param {Baggage} baggage
112
106
  */
113
107
  export const hasIssuer = baggage => baggage.has(INSTANCE_KEY);
114
108
 
115
109
  /**
116
- * `elementShape`, may only be present for collection-style amounts. If present,
117
- * it is a `Pattern` that every element of this issuerKits's amounts must
118
- * satisfy. For example, the Zoe Invitation issuerKit uses an elementShape
119
- * describing the invitation details for an individual invitation. An invitation
120
- * purse or payment has an amount that can only be a set of these. (Though
121
- * typically, the amount of an invitation payment is a singleton set. Such a
122
- * payment is often referred to in the singular as "an invitation".)
123
- *
124
- * @typedef {Partial<{
125
- * elementShape: Pattern;
126
- * }>} IssuerOptionsRecord
110
+ * @typedef {Partial<{elementShape: Pattern}>} IssuerOptionsRecord
127
111
  */
128
112
 
129
113
  /**
130
- * Used _only_ to make a _new_ durable issuer, i.e., the initial incarnation of
131
- * that issuer.
114
+ * @template {AssetKind} K
115
+ * The name becomes part of the brand in asset descriptions.
116
+ * The name is useful for debugging and double-checking
117
+ * assumptions, but should not be trusted wrt any external namespace.
118
+ * For example, anyone could create a new issuer kit with name 'BTC', but
119
+ * it is not bitcoin or even related. It is only the name according
120
+ * to that issuer and brand.
132
121
  *
133
- * @template {AssetKind} K The name becomes part of the brand in asset
134
- * descriptions. The name is useful for debugging and double-checking
135
- * assumptions, but should not be trusted wrt any external namespace. For
136
- * example, anyone could create a new issuer kit with name 'BTC', but it is
137
- * not bitcoin or even related. It is only the name according to that issuer
138
- * and brand.
122
+ * The assetKind will be used to import a specific mathHelpers
123
+ * from the mathHelpers library. For example, natMathHelpers, the
124
+ * default, is used for basic fungible tokens.
139
125
  *
140
- * The assetKind will be used to import a specific mathHelpers from the
141
- * mathHelpers library. For example, natMathHelpers, the default, is used for
142
- * basic fungible tokens.
126
+ * `displayInfo` gives information to the UI on how to display the amount.
143
127
  *
144
- * `displayInfo` gives information to the UI on how to display the amount.
145
128
  * @param {Baggage} issuerBaggage
146
129
  * @param {string} name
147
- * @param {K} [assetKind]
148
- * @param {AdditionalDisplayInfo} [displayInfo]
149
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
150
- * the middle of an atomic action (which btw should never happen), it
151
- * potentially leaves its ledger in a corrupted state. If this function was
152
- * provided, then the failed atomic action will call it, so that some larger
153
- * unit of computation, like the enclosing vat, can be shutdown before
154
- * anything else is corrupted by that corrupted state. See
155
- * https://github.com/Agoric/agoric-sdk/issues/3434
130
+ * @param {K} [assetKind=AssetKind.NAT]
131
+ * @param {AdditionalDisplayInfo} [displayInfo={}]
132
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
133
+ * in the middle of an atomic action (which btw should never happen), it
134
+ * potentially leaves its ledger in a corrupted state. If this function was
135
+ * provided, then the failed atomic action will call it, so that some
136
+ * larger unit of computation, like the enclosing vat, can be shutdown
137
+ * before anything else is corrupted by that corrupted state.
138
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
156
139
  * @param {IssuerOptionsRecord} [options]
157
140
  * @returns {IssuerKit<K>}
158
141
  */
@@ -172,99 +155,30 @@ export const makeDurableIssuerKit = (
172
155
  harden(makeDurableIssuerKit);
173
156
 
174
157
  /**
175
- * Used to either revive a predecessor issuerKit, or to make a new durable one
176
- * if it is absent, and to place it in baggage for the next successor.
177
- *
178
- * @template {AssetKind} K The name becomes part of the brand in asset
179
- * descriptions. The name is useful for debugging and double-checking
180
- * assumptions, but should not be trusted wrt any external namespace. For
181
- * example, anyone could create a new issuer kit with name 'BTC', but it is
182
- * not bitcoin or even related. It is only the name according to that issuer
183
- * and brand.
184
- *
185
- * The assetKind will be used to import a specific mathHelpers from the
186
- * mathHelpers library. For example, natMathHelpers, the default, is used for
187
- * basic fungible tokens.
188
- *
189
- * `displayInfo` gives information to the UI on how to display the amount.
190
- * @param {Baggage} issuerBaggage
191
- * @param {string} name
192
- * @param {K} [assetKind]
193
- * @param {AdditionalDisplayInfo} [displayInfo]
194
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
195
- * the middle of an atomic action (which btw should never happen), it
196
- * potentially leaves its ledger in a corrupted state. If this function was
197
- * provided, then the failed atomic action will call it, so that some larger
198
- * unit of computation, like the enclosing vat, can be shutdown before
199
- * anything else is corrupted by that corrupted state. See
200
- * https://github.com/Agoric/agoric-sdk/issues/3434
201
- * @param {IssuerOptionsRecord} [options]
202
- * @returns {IssuerKit<K>}
203
- */
204
- export const prepareIssuerKit = (
205
- issuerBaggage,
206
- name,
207
- // @ts-expect-error K could be instantiated with a different subtype of AssetKind
208
- assetKind = AssetKind.NAT,
209
- displayInfo = harden({}),
210
- optShutdownWithFailure = undefined,
211
- options = {},
212
- ) => {
213
- if (hasIssuer(issuerBaggage)) {
214
- const { elementShape: _ = undefined } = options;
215
- const issuerKit = upgradeIssuerKit(issuerBaggage, optShutdownWithFailure);
216
-
217
- // TODO check consistency with name, assetKind, displayInfo, elementShape.
218
- // Consistency either means that these are the same, or that they differ
219
- // in a direction we are prepared to upgrade.
220
-
221
- // @ts-expect-error Type parameter confusion.
222
- return issuerKit;
223
- } else {
224
- const issuerKit = makeDurableIssuerKit(
225
- issuerBaggage,
226
- name,
227
- assetKind,
228
- displayInfo,
229
- optShutdownWithFailure,
230
- options,
231
- );
232
- return issuerKit;
233
- }
234
- };
235
- harden(prepareIssuerKit);
236
-
237
- /**
238
- * Used _only_ to make a new issuerKit that is effectively non-durable. This is
239
- * currently done by making a durable one in a baggage not reachable from
240
- * anywhere. TODO Once rebuilt on zones, this should instead just build on the
241
- * virtual zone. See https://github.com/Agoric/agoric-sdk/pull/7116
242
- *
243
- * Currently used for testing only. Should probably continue to be used for
244
- * testing only.
158
+ * @template {AssetKind} [K='nat']
159
+ * The name becomes part of the brand in asset descriptions.
160
+ * The name is useful for debugging and double-checking
161
+ * assumptions, but should not be trusted wrt any external namespace.
162
+ * For example, anyone could create a new issuer kit with name 'BTC', but
163
+ * it is not bitcoin or even related. It is only the name according
164
+ * to that issuer and brand.
245
165
  *
246
- * @template {AssetKind} [K='nat'] The name becomes part of the brand in asset
247
- * descriptions. The name is useful for debugging and double-checking
248
- * assumptions, but should not be trusted wrt any external namespace. For
249
- * example, anyone could create a new issuer kit with name 'BTC', but it is
250
- * not bitcoin or even related. It is only the name according to that issuer
251
- * and brand.
166
+ * The assetKind will be used to import a specific mathHelpers
167
+ * from the mathHelpers library. For example, natMathHelpers, the
168
+ * default, is used for basic fungible tokens.
252
169
  *
253
- * The assetKind will be used to import a specific mathHelpers from the
254
- * mathHelpers library. For example, natMathHelpers, the default, is used for
255
- * basic fungible tokens.
170
+ * `displayInfo` gives information to the UI on how to display the amount.
256
171
  *
257
- * `displayInfo` gives information to the UI on how to display the amount.
258
172
  * @param {string} name
259
- * @param {K} [assetKind]
260
- * @param {AdditionalDisplayInfo} [displayInfo]
261
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
262
- * the middle of an atomic action (which btw should never happen), it
263
- * potentially leaves its ledger in a corrupted state. If this function was
264
- * provided, then the failed atomic action will call it, so that some larger
265
- * unit of computation, like the enclosing vat, can be shutdown before
266
- * anything else is corrupted by that corrupted state. See
267
- * https://github.com/Agoric/agoric-sdk/issues/3434
173
+ * @param {K} [assetKind='nat']
174
+ * @param {AdditionalDisplayInfo} [displayInfo={}]
175
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
176
+ * in the middle of an atomic action (which btw should never happen), it
177
+ * potentially leaves its ledger in a corrupted state. If this function was
178
+ * provided, then the failed atomic action will call it, so that some
179
+ * larger unit of computation, like the enclosing vat, can be shutdown
180
+ * before anything else is corrupted by that corrupted state.
181
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
268
182
  * @param {IssuerOptionsRecord} [options]
269
183
  * @returns {IssuerKit<K>}
270
184
  */
@@ -0,0 +1,5 @@
1
+ export function claim<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, optAmountShape?: Pattern): Promise<Payment<K>>;
2
+ export function combine<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentsPs: ERef<Payment<K>>[], optTotalAmount?: Pattern): Promise<Payment<K>>;
3
+ export function split<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, paymentAmountA: Amount<K>): Promise<Payment<K>[]>;
4
+ export function splitMany<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, amounts: Amount<K>[]): Promise<Payment[]>;
5
+ //# sourceMappingURL=legacy-payment-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AA+BO,0HAHI,OAAO,uBAYjB;AAiBM,gIAHI,OAAO,uBA2BjB;AAiBM,2JAUN;AAkBM,oIAFM,QAAQ,OAAO,EAAE,CAAC,CAoB9B"}
@@ -7,17 +7,19 @@ import { AmountMath } from './amountMath.js';
7
7
  const { Fail } = assert;
8
8
 
9
9
  /**
10
- * @file This file contains safer helper function alternatives to the similarly
11
- * named methods on issuer. These are parameterized by a purse used for
12
- * recovering lost payments, which we call a `recoveryPurse`. Any payments
13
- * created by these helper functions are in the recovery set of that
14
- * `recoveryPurse` until otherwise used up.
10
+ * @file
11
+ * This file contains safer helper function alternatives to the
12
+ * similarly named methods on issuer.
13
+ * These are parameterized by a purse used for recovering lost payments, which
14
+ * we call a `recoveryPurse`. Any payments created by these
15
+ * helper functions are in the recovery set of that `recoveryPurse` until
16
+ * otherwise used up.
15
17
  *
16
- * One of these helper functions is less safe in one way: `combine` is not
17
- * failure atomic. If the `combine` helper function fails, some of the input
18
- * payments may have been used up. However, even in that case, no assets would
19
- * be lost. The assets from the used up payments will be in the argument
20
- * `recoveryPurse`.
18
+ * One of these helper functions is less safe in one way:
19
+ * `combine` is not failure atomic. If the `combine` helper function
20
+ * fails, some of the input payments may have been used up. However, even
21
+ * in that case, no assets would be lost. The assets from the used up payments
22
+ * will be in the argument `recoveryPurse`.
21
23
  */
22
24
 
23
25
  /**
@@ -41,11 +43,11 @@ harden(claim);
41
43
 
42
44
  /**
43
45
  * Note: Not failure atomic. But as long as you don't lose the argument
44
- * `recoveryPurse`, no assets are lost. If any of the deposits fail, or the
45
- * total does not match optTotalAmount, some payments may still have been
46
- * deposited. Those assets will be in the argument `recoveryPurse`. All
47
- * undeposited payments will still be in the recovery sets of their purses of
48
- * origin.
46
+ * `recoveryPurse`, no assets are lost.
47
+ * If any of the deposits fail, or the total does not
48
+ * match optTotalAmount, some payments may still have been deposited. Those
49
+ * assets will be in the argument `recoveryPurse`. All undeposited payments
50
+ * will still be in the recovery sets of their purses of origin.
49
51
  *
50
52
  * @template {AssetKind} K
51
53
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -82,10 +84,11 @@ harden(combine);
82
84
 
83
85
  /**
84
86
  * Note: Not failure atomic. But as long as you don't lose the argument
85
- * `recoveryPurse`, no assets are lost. If the amount in `srcPaymentP` is not >=
86
- * `paymentAmountA`, the payment may still be deposited anyway, before failing
87
- * in the subsequent subtract. In that case, those assets will be in the
88
- * argument `recoveryPurse`.
87
+ * `recoveryPurse`, no assets are lost.
88
+ * If the amount in `srcPaymentP` is not >= `paymentAmountA`, the payment may
89
+ * still be deposited anyway, before failing in the subsequent subtract.
90
+ * In that case, those
91
+ * assets will be in the argument `recoveryPurse`.
89
92
  *
90
93
  * @template {AssetKind} K
91
94
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -108,10 +111,12 @@ harden(split);
108
111
 
109
112
  /**
110
113
  * Note: Not failure atomic. But as long as you don't lose the argument
111
- * `recoveryPurse`, no assets are lost. If the amount in `srcPaymentP` is
112
- * exactly the sum of the amounts, the payment may still be deposited anyway,
113
- * before failing in the subsequent equality check. In that case, those assets
114
- * will be in the argument `recoveryPurse`.
114
+ * `recoveryPurse`, no assets are lost.
115
+ * If the amount in `srcPaymentP` is exactly the sum of the amounts,
116
+ * the payment may
117
+ * still be deposited anyway, before failing in the subsequent equality check.
118
+ * In that case, those
119
+ * assets will be in the argument `recoveryPurse`.
115
120
  *
116
121
  * @template {AssetKind} K
117
122
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {MathHelpers<CopyBag>}
3
+ */
4
+ export const copyBagMathHelpers: MathHelpers<CopyBag>;
5
+ //# sourceMappingURL=copyBagMathHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA;;GAEG;AACH,iCAFU,YAAY,OAAO,CAAC,CAa3B"}
@@ -15,7 +15,9 @@ import '../types-ambient.js';
15
15
  /** @type {CopyBag} */
16
16
  const empty = makeCopyBag([]);
17
17
 
18
- /** @type {MathHelpers<CopyBag>} */
18
+ /**
19
+ * @type {MathHelpers<CopyBag>}
20
+ */
19
21
  export const copyBagMathHelpers = harden({
20
22
  doCoerce: bag => {
21
23
  mustMatch(bag, M.bag(), 'bag of amount');
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {MathHelpers<CopySet>}
3
+ */
4
+ export const copySetMathHelpers: MathHelpers<CopySet>;
5
+ //# sourceMappingURL=copySetMathHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copySetMathHelpers.d.ts","sourceRoot":"","sources":["copySetMathHelpers.js"],"names":[],"mappings":"AAiBA;;GAEG;AACH,iCAFU,YAAY,OAAO,CAAC,CAa3B"}
@@ -15,7 +15,9 @@ import '../types-ambient.js';
15
15
  /** @type {CopySet} */
16
16
  const empty = makeCopySet([]);
17
17
 
18
- /** @type {MathHelpers<CopySet>} */
18
+ /**
19
+ * @type {MathHelpers<CopySet>}
20
+ */
19
21
  export const copySetMathHelpers = harden({
20
22
  doCoerce: set => {
21
23
  mustMatch(set, M.set(), 'set of amount');
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Fungible digital assets use the natMathHelpers to manage balances -
3
+ * the operations are merely arithmetic on natural, non-negative
4
+ * numbers.
5
+ *
6
+ * Natural numbers are used for fungible erights such as money because
7
+ * rounding issues make floats problematic. All operations should be
8
+ * done with the smallest whole unit such that the `natMathHelpers` never
9
+ * deals with fractional parts.
10
+ *
11
+ * @type {MathHelpers<NatValue>}
12
+ */
13
+ export const natMathHelpers: MathHelpers<NatValue>;
14
+ //# sourceMappingURL=natMathHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"natMathHelpers.d.ts","sourceRoot":"","sources":["natMathHelpers.js"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AACH,6BAFU,YAAY,QAAQ,CAAC,CAgB5B"}
@@ -8,13 +8,14 @@ const { Fail } = assert;
8
8
  const empty = 0n;
9
9
 
10
10
  /**
11
- * Fungible digital assets use the natMathHelpers to manage balances - the
12
- * operations are merely arithmetic on natural, non-negative numbers.
11
+ * Fungible digital assets use the natMathHelpers to manage balances -
12
+ * the operations are merely arithmetic on natural, non-negative
13
+ * numbers.
13
14
  *
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.
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.
18
19
  *
19
20
  * @type {MathHelpers<NatValue>}
20
21
  */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @deprecated Replace array-based SetMath with CopySet-based CopySetMath
3
+ * @type {MathHelpers<SetValue>}
4
+ */
5
+ export const setMathHelpers: MathHelpers<SetValue>;
6
+ //# sourceMappingURL=setMathHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setMathHelpers.d.ts","sourceRoot":"","sources":["setMathHelpers.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,6BAFU,qBAAqB,CAkB5B"}
@@ -0,0 +1,3 @@
1
+ export function preparePaymentKind<K extends AssetKind>(issuerBaggage: MapStore<string, unknown>, name: string, brand: Brand<K>, PaymentI: InterfaceGuard): () => Payment<K>;
2
+ export type Baggage = import('@agoric/vat-data').Baggage;
3
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["payment.js"],"names":[],"mappings":"AAeO,wGALI,MAAM,6BAEN,cAAc,oBAgBxB;sBAvBa,OAAO,kBAAkB,EAAE,OAAO"}
package/src/payment.js CHANGED
@@ -3,11 +3,6 @@
3
3
  import { initEmpty } from '@agoric/store';
4
4
  import { prepareExoClass } from '@agoric/vat-data';
5
5
 
6
- /** @typedef {import('@endo/patterns').MethodGuard} MethodGuard */
7
- /**
8
- * @template {Record<string | symbol, MethodGuard>} [T=Record<string | symbol, MethodGuard>]
9
- * @typedef {import('@endo/patterns').InterfaceGuard<T>} InterfaceGuard
10
- */
11
6
  /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
12
7
 
13
8
  /**
@@ -0,0 +1,3 @@
1
+ export function preparePaymentLedger<K extends AssetKind>(issuerBaggage: MapStore<string, unknown>, name: string, assetKind: K, displayInfo: DisplayInfo<K>, elementShape: Pattern, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined): PaymentLedger<K>;
2
+ export type Baggage = import('@agoric/vat-data').Baggage;
3
+ //# sourceMappingURL=paymentLedger.d.ts.map
@@ -0,0 +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"}
@@ -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 payments. All
74
- * minting and transfer authority originates here.
73
+ * Make the paymentLedger, the source of truth for the balances of
74
+ * payments. All minting and transfer authority originates here.
75
75
  *
76
76
  * @template {AssetKind} K
77
77
  * @param {Baggage} issuerBaggage
@@ -146,21 +146,22 @@ export const preparePaymentLedger = (
146
146
  );
147
147
 
148
148
  /**
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.
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.
164
165
  *
165
166
  * @type {WeakMapStore<Payment, SetStore<Payment>>}
166
167
  */
@@ -171,7 +172,8 @@ export const preparePaymentLedger = (
171
172
 
172
173
  /**
173
174
  * To maintain the invariants listed in the `paymentRecoverySets` comment,
174
- * `initPayment` should contain the only call to `paymentLedger.init`.
175
+ * `initPayment` should contain the only
176
+ * call to `paymentLedger.init`.
175
177
  *
176
178
  * @param {Payment} payment
177
179
  * @param {Amount} amount
@@ -187,7 +189,8 @@ export const preparePaymentLedger = (
187
189
 
188
190
  /**
189
191
  * To maintain the invariants listed in the `paymentRecoverySets` comment,
190
- * `deletePayment` should contain the only call to `paymentLedger.delete`.
192
+ * `deletePayment` should contain the only
193
+ * call to `paymentLedger.delete`.
191
194
  *
192
195
  * @param {Payment} payment
193
196
  */
@@ -200,18 +203,19 @@ export const preparePaymentLedger = (
200
203
  }
201
204
  };
202
205
 
203
- /** @type {(left: Amount, right: Amount) => Amount} */
206
+ /** @type {(left: Amount, right: Amount) => Amount } */
204
207
  const add = (left, right) => AmountMath.add(left, right, brand);
205
- /** @type {(left: Amount, right: Amount) => Amount} */
208
+ /** @type {(left: Amount, right: Amount) => Amount } */
206
209
  const subtract = (left, right) => AmountMath.subtract(left, right, brand);
207
210
  /** @type {(allegedAmount: Amount) => Amount} */
208
211
  const coerce = allegedAmount => AmountMath.coerce(brand, allegedAmount);
209
- /** @type {(left: Amount, right: Amount) => boolean} */
212
+ /** @type {(left: Amount, right: Amount) => boolean } */
210
213
 
211
214
  /**
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.
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.
215
219
  *
216
220
  * Note: `optAmountShape` is user-supplied with no previous validation.
217
221
  *
@@ -239,10 +243,10 @@ export const preparePaymentLedger = (
239
243
  /**
240
244
  * Used by the purse code to implement purse.deposit
241
245
  *
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
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
246
250
  * @param {Payment} srcPayment
247
251
  * @param {Pattern} [optAmountShape]
248
252
  * @returns {Amount}
@@ -278,10 +282,10 @@ export const preparePaymentLedger = (
278
282
  /**
279
283
  * Used by the purse code to implement purse.withdraw
280
284
  *
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
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
285
289
  * @param {Amount} amount - the amount to be withdrawn
286
290
  * @param {SetStore<Payment>} recoverySet
287
291
  * @returns {Payment}
@@ -310,8 +314,6 @@ export const preparePaymentLedger = (
310
314
  return payment;
311
315
  };
312
316
 
313
- /** @type {() => Purse<K>} */
314
- // @ts-expect-error type parameter confusion
315
317
  const makeEmptyPurse = preparePurseKind(
316
318
  issuerBaggage,
317
319
  name,
@@ -376,9 +378,9 @@ export const preparePaymentLedger = (
376
378
  /**
377
379
  * Provides for the recovery of newly minted but not-yet-deposited payments.
378
380
  *
379
- * Because the `mintRecoveryPurse` is placed in baggage, even if the caller of
380
- * `makeIssuerKit` drops it on the floor, it can still be recovered in an
381
- * emergency upgrade.
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.
382
384
  *
383
385
  * @type {Purse<K>}
384
386
  */