@agoric/ertp 0.16.3-dev-727e4af.0 → 0.16.3-dev-96c9ff5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/ertp",
3
- "version": "0.16.3-dev-727e4af.0+727e4af",
3
+ "version": "0.16.3-dev-96c9ff5.0+96c9ff5",
4
4
  "description": "Electronic Rights Transfer Protocol (ERTP). A smart contract framework for exchanging electronic rights",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -39,21 +39,21 @@
39
39
  },
40
40
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
41
41
  "dependencies": {
42
- "@agoric/assert": "0.6.1-dev-727e4af.0+727e4af",
43
- "@agoric/notifier": "0.6.3-dev-727e4af.0+727e4af",
44
- "@agoric/store": "0.9.3-dev-727e4af.0+727e4af",
45
- "@agoric/vat-data": "0.5.3-dev-727e4af.0+727e4af",
46
- "@agoric/zone": "0.2.3-dev-727e4af.0+727e4af",
47
- "@endo/eventual-send": "^1.2.1",
48
- "@endo/far": "^1.1.1",
49
- "@endo/marshal": "^1.4.1",
50
- "@endo/nat": "^5.0.6",
51
- "@endo/patterns": "^1.3.1",
52
- "@endo/promise-kit": "^1.1.1"
42
+ "@agoric/assert": "0.6.1-dev-96c9ff5.0+96c9ff5",
43
+ "@agoric/notifier": "0.6.3-dev-96c9ff5.0+96c9ff5",
44
+ "@agoric/store": "0.9.3-dev-96c9ff5.0+96c9ff5",
45
+ "@agoric/vat-data": "0.5.3-dev-96c9ff5.0+96c9ff5",
46
+ "@agoric/zone": "0.2.3-dev-96c9ff5.0+96c9ff5",
47
+ "@endo/eventual-send": "^1.2.2",
48
+ "@endo/far": "^1.1.2",
49
+ "@endo/marshal": "^1.5.0",
50
+ "@endo/nat": "^5.0.7",
51
+ "@endo/patterns": "^1.4.0",
52
+ "@endo/promise-kit": "^1.1.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@agoric/swingset-vat": "0.32.3-dev-727e4af.0+727e4af",
56
- "@endo/bundle-source": "^3.2.2",
55
+ "@agoric/swingset-vat": "0.32.3-dev-96c9ff5.0+96c9ff5",
56
+ "@endo/bundle-source": "^3.2.3",
57
57
  "@fast-check/ava": "^1.1.5",
58
58
  "ava": "^5.3.0",
59
59
  "tsd": "^0.30.7"
@@ -86,7 +86,7 @@
86
86
  "access": "public"
87
87
  },
88
88
  "typeCoverage": {
89
- "atLeast": 90.62
89
+ "atLeast": 91.21
90
90
  },
91
- "gitHead": "727e4af514a8e92f400dd1671a788c5d3cbe1b8a"
91
+ "gitHead": "96c9ff577fe14cebeb5a38543ba7f8598ffcd0c7"
92
92
  }
@@ -1,22 +1,21 @@
1
- export function assertValueGetHelpers<V extends AmountValue>(value: V): MathHelpers<V>;
2
- import type { AmountValue } from './types.js';
1
+ export function assertValueGetHelpers<V>(value: V): MathHelpers<V>;
3
2
  import type { MathHelpers } from './types.js';
4
3
  export namespace AmountMath {
5
- export function make<K extends AssetKind>(brand: Brand<K>, allegedValue: AssetValueForKind<K>): Amount<K>;
6
- export function coerce<K extends AssetKind>(brand: Brand<K>, allegedAmount: Amount<K>): Amount<K>;
7
- export function getValue<K extends AssetKind>(brand: Brand<K>, amount: Amount<K>): AssetValueForKind<K>;
4
+ export function make<B extends Brand, V extends bigint | CopySet | SetValue | CopyBag>(brand: B, allegedValue: V): B extends Brand<"nat"> ? NatAmount : V extends bigint ? NatAmount : V extends CopySet ? CopySetAmount<V["payload"][0]> : V extends CopyBag ? CopyBagAmount<V["payload"][0][0]> : V extends SetValue ? SetAmount<V[0]> : never;
5
+ export function coerce<A extends Amount>(brand: Brand, allegedAmount: A): A;
6
+ export function getValue<A extends Amount>(brand: Brand, amount: A): A["value"];
8
7
  export let makeEmpty: {
9
- (brand: Brand): Amount<"nat">;
10
- <K extends AssetKind>(brand: Brand, assetKind: K): Amount<K>;
8
+ (brand: Brand): NatAmount;
9
+ <K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
11
10
  };
12
- export function makeEmptyFromAmount<K extends AssetKind>(amount: Amount<K>): Amount<K>;
11
+ export function makeEmptyFromAmount<A extends Amount>(amount: A): A;
13
12
  export function isEmpty(amount: Amount, brand?: Brand | undefined): boolean;
14
13
  export { isGTE };
15
- export function isEqual<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
16
- export function add<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
17
- export function subtract<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
18
- export function min<K extends AssetKind>(x: Amount<K>, y: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
19
- export function max<K extends AssetKind>(x: Amount<K>, y: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
14
+ export function isEqual<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand | undefined): boolean;
15
+ export function add<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand | undefined): A;
16
+ export function subtract<L extends Amount, R extends Amount>(leftAmount: L, rightAmount: R, brand?: Brand | undefined): L extends R ? L : never;
17
+ export function min<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
18
+ export function max<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
20
19
  }
21
20
  /**
22
21
  * Constants for the kinds of assets we support.
@@ -36,11 +35,17 @@ export const AssetKind: {
36
35
  };
37
36
  import type { AssetKind } from './types.js';
38
37
  /** @param {Amount} amount */
39
- export function getAssetKind(amount: Amount): AssetKindForValue<V>;
38
+ export function getAssetKind(amount: Amount): "copySet" | "set" | "nat" | "copyBag";
40
39
  /** @param {AssetKind} allegedAK */
41
40
  export function assertAssetKind(allegedAK: AssetKind): void;
42
41
  import type { Brand } from './types.js';
43
- import type { AssetValueForKind } from './types.js';
42
+ import type { CopySet } from '@endo/patterns';
43
+ import type { SetValue } from './types.js';
44
+ import type { CopyBag } from '@endo/patterns';
45
+ import type { NatAmount } from './types.js';
46
+ import type { CopySetAmount } from './types.js';
47
+ import type { CopyBagAmount } from './types.js';
48
+ import type { SetAmount } from './types.js';
44
49
  import type { Amount } from './types.js';
45
50
  /**
46
51
  * Returns true if the leftAmount is greater than or equal to the rightAmount.
@@ -56,6 +61,5 @@ import type { Amount } from './types.js';
56
61
  * @returns {boolean}
57
62
  */
58
63
  declare function isGTE<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
59
- import type { AssetKindForValue } from './types.js';
60
64
  export {};
61
65
  //# sourceMappingURL=amountMath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAuHO,sCAFkB,CAAC,6BAAD,CAAC,AADd,kBAK6B;iCAjHmE,YAAY;iCAAZ,YAAY;;IAyMhH,qBAJuB,CAAC,oFAS7B;IAUO,uBAHU,CAAC,0EAWlB;IASS,yBAHQ,CAAC,8EAGgD;;;SAOf,CAAC,6CAAD,CAAC;;IAiBhC,oCAHH,CAAC,kDAUlB;IAQQ,4EAOR;;IAYQ,wBAJS,CAAC,0GAOlB;IAcI,oBAJa,CAAC,4GAQlB;IAcS,yBAJQ,CAAC,4GAQlB;IAUI,oBAJa,CAAC,yFAUyB;IAUvC,oBAJa,CAAC,yFAUyB;;AAtW9C;;;;;;;;;GASG;AACH,wBAPU;IACT,GAAO,EAAE,KAAK,CAAC;IACf,GAAO,EAAE,KAAK,CAAC;IACf,QAAY,EAAE,SAAS,CAAC;IACxB,QAAY,EAAE,SAAS,CAAC;CACrB,CAOD;+BAnByG,YAAY;AA8WxH,6BAA6B;AAC7B,mEAKC;AA9VD,mCAAmC;AACnC,2CADY,SAAS,QAIpB;2BA1B2G,YAAY;uCAAZ,YAAY;4BAAZ,YAAY;AAqKxH;;;;;;;;;;;;GAYG;AACH,uBAJkB,CAAC,kGAEN,OAAO,CAKnB;uCArL2G,YAAY"}
1
+ {"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAmHO,sCAFkB,CAAC,SAAD,CAAC,AADd,kBAK6B;iCA3G0I,YAAY;;IAiNvL,qBAdK,CAAC,gBACD,CAAC,uDADD,CAAC,gBACD,CAAC,iOAmBX;IAUO,uBAHG,CAAC,8CAAD,CAAC,KAYX;IASS,yBAHC,CAAC,uCAAD,CAAC,cAGuD;;;SAOZ,CAAC,gDAAD,CAAC;;IAkBnC,oCAHV,CAAC,yBAAD,CAAC,KASX;IAQQ,4EAOR;;IAYQ,wBAJE,CAAC,6BAAD,CAAC,AADA,eACD,CAAC,sCAOX;IAcI,oBAJM,CAAC,6BAAD,CAAC,AADA,eACD,CAAC,gCASX;IAeS,yBALC,CAAC,iBACD,CAAC,6BADD,CAAC,eACD,CAAC,sDASX;IAUI,oBAJM,CAAC,oBAAD,CAAC,AADA,KACD,CAAC,gCAUgC;IAUvC,oBAJM,CAAC,oBAAD,CAAC,AADA,KACD,CAAC,gCAUgC;;AAlX9C;;;;;;;;;GASG;AACH,wBAPU;IACT,GAAO,EAAE,KAAK,CAAC;IACf,GAAO,EAAE,KAAK,CAAC;IACf,QAAY,EAAE,SAAS,CAAC;IACxB,QAAY,EAAE,SAAS,CAAC;CACrB,CAOD;+BApBgL,YAAY;AA2X/L,6BAA6B;AAC7B,oFAIC;AAzWD,mCAAmC;AACnC,2CADY,SAAS,QAIpB;2BA3BkL,YAAY;6BAD5J,gBAAgB;8BACgI,YAAY;6BAD5J,gBAAgB;+BACgI,YAAY;mCAAZ,YAAY;mCAAZ,YAAY;+BAAZ,YAAY;4BAAZ,YAAY;AA+J/L;;;;;;;;;;;;GAYG;AACH,uBAJkB,CAAC,kGAEN,OAAO,CAKnB"}
package/src/amountMath.js CHANGED
@@ -6,7 +6,10 @@ import { setMathHelpers } from './mathHelpers/setMathHelpers.js';
6
6
  import { copySetMathHelpers } from './mathHelpers/copySetMathHelpers.js';
7
7
  import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';
8
8
 
9
- /** @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, MathHelpers} from './types.js' */
9
+ /**
10
+ * @import {CopyBag, CopySet} from '@endo/patterns';
11
+ * @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
12
+ */
10
13
 
11
14
  const { quote: q, Fail } = assert;
12
15
 
@@ -76,26 +79,19 @@ const helpers = {
76
79
  copyBag: copyBagMathHelpers,
77
80
  };
78
81
 
79
- /**
80
- * @template {AmountValue} V
81
- * @type {(value: V) => AssetKindForValue<V>}
82
- */
82
+ /** @type {(value: unknown) => 'nat' | 'set' | 'copySet' | 'copyBag'} } */
83
83
  const assertValueGetAssetKind = value => {
84
84
  const passStyle = passStyleOf(value);
85
85
  if (passStyle === 'bigint') {
86
- // @ts-expect-error cast
87
86
  return 'nat';
88
87
  }
89
88
  if (passStyle === 'copyArray') {
90
- // @ts-expect-error cast
91
89
  return 'set';
92
90
  }
93
91
  if (matches(value, M.set())) {
94
- // @ts-expect-error cast
95
92
  return 'copySet';
96
93
  }
97
94
  if (matches(value, M.bag())) {
98
- // @ts-expect-error cast
99
95
  return 'copyBag';
100
96
  }
101
97
  // TODO This isn't quite the right error message, in case valuePassStyle
@@ -113,7 +109,7 @@ const assertValueGetAssetKind = value => {
113
109
  *
114
110
  * Made available only for testing, but it is harmless for other uses.
115
111
  *
116
- * @template {AmountValue} V
112
+ * @template V
117
113
  * @param {V} value
118
114
  * @returns {MathHelpers<V>}
119
115
  */
@@ -198,29 +194,44 @@ const isGTE = (leftAmount, rightAmount, brand = undefined) => {
198
194
  * the abstract right to participate in a particular exchange.
199
195
  */
200
196
  const AmountMath = {
197
+ // TODO use overloading to handle when Brand has an AssetKind and when it doesn't.
198
+ // a AmountForValue utility could help DRY those cases.
201
199
  /**
202
200
  * Make an amount from a value by adding the brand.
203
201
  *
204
- * @template {AssetKind} K
205
- * @param {Brand<K>} brand
206
- * @param {AssetValueForKind<K>} allegedValue
207
- * @returns {Amount<K>}
202
+ * Does not verify that the Brand's AssetKind matches the value's.
203
+ *
204
+ * @template {Brand} B
205
+ * @template {NatValue | CopySet | CopyBag | SetValue} V
206
+ * @param {B} brand
207
+ * @param {V} allegedValue
208
+ * @returns {B extends Brand<'nat'>
209
+ * ? NatAmount
210
+ * : V extends NatValue
211
+ * ? NatAmount
212
+ * : V extends CopySet
213
+ * ? CopySetAmount<V['payload'][0]>
214
+ * : V extends CopyBag
215
+ * ? CopyBagAmount<V['payload'][0][0]>
216
+ * : V extends SetValue
217
+ * ? SetAmount<V[0]>
218
+ * : never}
208
219
  */
209
- // allegedValue has a conditional expression for type widening, to prevent V being bound to a a literal like 1n
210
220
  make: (brand, allegedValue) => {
211
221
  assertRemotable(brand, 'brand');
212
222
  const h = assertValueGetHelpers(allegedValue);
213
223
  const value = h.doCoerce(allegedValue);
224
+ // @ts-expect-error cast
214
225
  return harden({ brand, value });
215
226
  },
216
227
  /**
217
228
  * Make sure this amount is valid enough, and return a corresponding valid
218
229
  * amount if so.
219
230
  *
220
- * @template {AssetKind} K
221
- * @param {Brand<K>} brand
222
- * @param {Amount<K>} allegedAmount
223
- * @returns {Amount<K>}
231
+ * @template {Amount} A
232
+ * @param {Brand} brand
233
+ * @param {A} allegedAmount
234
+ * @returns {A}
224
235
  */
225
236
  coerce: (brand, allegedAmount) => {
226
237
  assertRemotable(brand, 'brand');
@@ -229,15 +240,16 @@ const AmountMath = {
229
240
  brand === allegedBrand ||
230
241
  Fail`The brand in the allegedAmount ${allegedAmount} in 'coerce' didn't match the specified brand ${brand}.`;
231
242
  // Will throw on inappropriate value
243
+ // @ts-expect-error cast
232
244
  return AmountMath.make(brand, allegedValue);
233
245
  },
234
246
  /**
235
247
  * Extract and return the value.
236
248
  *
237
- * @template {AssetKind} K
238
- * @param {Brand<K>} brand
239
- * @param {Amount<K>} amount
240
- * @returns {AssetValueForKind<K>}
249
+ * @template {Amount} A
250
+ * @param {Brand} brand
251
+ * @param {A} amount
252
+ * @returns {A['value']}
241
253
  */
242
254
  getValue: (brand, amount) => AmountMath.coerce(brand, amount).value,
243
255
  /**
@@ -246,29 +258,29 @@ const AmountMath = {
246
258
  *
247
259
  * @type {{
248
260
  * (brand: Brand): Amount<'nat'>;
249
- * <K extends AssetKind>(brand: Brand, assetKind: K): Amount<K>;
261
+ * <K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
250
262
  * }}
251
263
  */
252
264
  makeEmpty: (brand, assetKind = /** @type {const} */ ('nat')) => {
253
265
  assertRemotable(brand, 'brand');
254
266
  assertAssetKind(assetKind);
255
267
  const value = helpers[assetKind].doMakeEmpty();
268
+ // @ts-expect-error XXX narrowing from function overload
256
269
  return harden({ brand, value });
257
270
  },
258
271
  /**
259
272
  * Return the amount representing an empty amount, using another amount as the
260
273
  * template for the brand and assetKind.
261
274
  *
262
- * @template {AssetKind} K
263
- * @param {Amount<K>} amount
264
- * @returns {Amount<K>}
275
+ * @template {Amount} A
276
+ * @param {A} amount
277
+ * @returns {A}
265
278
  */
266
279
  makeEmptyFromAmount: amount => {
267
280
  assertRecord(amount, 'amount');
268
281
  const { brand, value } = amount;
269
- // @ts-expect-error cast
270
282
  const assetKind = assertValueGetAssetKind(value);
271
- // @ts-expect-error cast (ignore b/c erroring in CI but not my IDE)
283
+ // @ts-expect-error different subtype
272
284
  return AmountMath.makeEmpty(brand, assetKind);
273
285
  },
274
286
  /**
@@ -291,10 +303,10 @@ const AmountMath = {
291
303
  * Returns true if the leftAmount equals the rightAmount. We assume that if
292
304
  * isGTE is true in both directions, isEqual is also true
293
305
  *
294
- * @template {AssetKind} K
295
- * @param {Amount<K>} leftAmount
296
- * @param {Amount<K>} rightAmount
297
- * @param {Brand<K>} [brand]
306
+ * @template {Amount} A
307
+ * @param {A} leftAmount
308
+ * @param {A} rightAmount
309
+ * @param {Brand} [brand]
298
310
  * @returns {boolean}
299
311
  */
300
312
  isEqual: (leftAmount, rightAmount, brand = undefined) => {
@@ -308,15 +320,16 @@ const AmountMath = {
308
320
  * amount, it usually means including all of the elements from both left and
309
321
  * right.
310
322
  *
311
- * @template {AssetKind} K
312
- * @param {Amount<K>} leftAmount
313
- * @param {Amount<K>} rightAmount
314
- * @param {Brand<K>} [brand]
315
- * @returns {Amount<K>}
323
+ * @template {Amount} A
324
+ * @param {A} leftAmount
325
+ * @param {A} rightAmount
326
+ * @param {Brand} [brand]
327
+ * @returns {A}
316
328
  */
317
329
  add: (leftAmount, rightAmount, brand = undefined) => {
318
330
  const h = checkLRAndGetHelpers(leftAmount, rightAmount, brand);
319
331
  const value = h.doAdd(...coerceLR(h, leftAmount, rightAmount));
332
+ // @ts-expect-error different subtype
320
333
  return harden({ brand: leftAmount.brand, value });
321
334
  },
322
335
  /**
@@ -326,25 +339,27 @@ const AmountMath = {
326
339
  * error. Because the left amount must include the right amount, this is NOT
327
340
  * equivalent to set subtraction.
328
341
  *
329
- * @template {AssetKind} K
330
- * @param {Amount<K>} leftAmount
331
- * @param {Amount<K>} rightAmount
332
- * @param {Brand<K>} [brand]
333
- * @returns {Amount<K>}
342
+ * @template {Amount} L
343
+ * @template {Amount} R
344
+ * @param {L} leftAmount
345
+ * @param {R} rightAmount
346
+ * @param {Brand} [brand]
347
+ * @returns {L extends R ? L : never}
334
348
  */
335
349
  subtract: (leftAmount, rightAmount, brand = undefined) => {
336
350
  const h = checkLRAndGetHelpers(leftAmount, rightAmount, brand);
337
351
  const value = h.doSubtract(...coerceLR(h, leftAmount, rightAmount));
352
+ // @ts-expect-error different subtype
338
353
  return harden({ brand: leftAmount.brand, value });
339
354
  },
340
355
  /**
341
356
  * Returns the min value between x and y using isGTE
342
357
  *
343
- * @template {AssetKind} K
344
- * @param {Amount<K>} x
345
- * @param {Amount<K>} y
346
- * @param {Brand<K>} [brand]
347
- * @returns {Amount<K>}
358
+ * @template {Amount} A
359
+ * @param {A} x
360
+ * @param {A} y
361
+ * @param {Brand} [brand]
362
+ * @returns {A}
348
363
  */
349
364
  min: (x, y, brand = undefined) =>
350
365
  // eslint-disable-next-line no-nested-ternary
@@ -356,11 +371,11 @@ const AmountMath = {
356
371
  /**
357
372
  * Returns the max value between x and y using isGTE
358
373
  *
359
- * @template {AssetKind} K
360
- * @param {Amount<K>} x
361
- * @param {Amount<K>} y
362
- * @param {Brand<K>} [brand]
363
- * @returns {Amount<K>}
374
+ * @template {Amount} A
375
+ * @param {A} x
376
+ * @param {A} y
377
+ * @param {Brand} [brand]
378
+ * @returns {A}
364
379
  */
365
380
  max: (x, y, brand = undefined) =>
366
381
  // eslint-disable-next-line no-nested-ternary
@@ -376,7 +391,6 @@ harden(AmountMath);
376
391
  const getAssetKind = amount => {
377
392
  assertRecord(amount, 'amount');
378
393
  const { value } = amount;
379
- // @ts-expect-error cast (ignore b/c erroring in CI but not my IDE)
380
394
  return assertValueGetAssetKind(value);
381
395
  };
382
396
  harden(getAssetKind);
@@ -11,7 +11,7 @@ export function prepareIssuerKit<K extends import("./types.js").AssetKind>(issue
11
11
  export function makeIssuerKit<K extends import("./types.js").AssetKind = "nat">(name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: ShutdownWithFailure | undefined, { elementShape, recoverySetsOption }?: Partial<{
12
12
  elementShape: Pattern;
13
13
  recoverySetsOption: RecoverySetsOption;
14
- }> | undefined): IssuerKit<K>;
14
+ }> | undefined): IssuerKit<K, any>;
15
15
  export type IssuerRecord<K extends import("./types.js").AssetKind> = {
16
16
  name: string;
17
17
  assetKind: K;
@@ -1 +1 @@
1
- {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAFgB,CAAC,wDAVb,OAAO,kBAAkB,EAAE,OAAO,+HAyC5C;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAtBE,OAAO;;8BA4DzB;AAiCM,iCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAhFE,OAAO;;8BAkIzB;AAqCM,8BAFgB,CAAC,uDAXb,MAAM;kBA1JE,OAAO;;8BAsLvB;yBAtUW,CAAC;UADD,MAAM;eACN,CAAC;;kBAED,OAAO;;;;;;;;;;;;;;;;;mBA8IF,OAAO;;;yCAtJa,sBAAsB;wCAD0B,YAAY;+BAAZ,YAAY;2CAAZ,YAAY"}
1
+ {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAFgB,CAAC,wDAVb,OAAO,kBAAkB,EAAE,OAAO,+HAyC5C;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAtBE,OAAO;;8BA4DzB;AAiCM,iCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAhFE,OAAO;;8BAkIzB;AAqCM,8BAFgB,CAAC,uDAXb,MAAM;kBA1JE,OAAO;;mCAsLvB;yBAtUW,CAAC;UADD,MAAM;eACN,CAAC;;kBAED,OAAO;;;;;;;;;;;;;;;;;mBA8IF,OAAO;;;yCAtJa,sBAAsB;wCAD0B,YAAY;+BAAZ,YAAY;2CAAZ,YAAY"}
package/src/issuerKit.js CHANGED
@@ -325,7 +325,7 @@ harden(prepareIssuerKit);
325
325
  * anything else is corrupted by that corrupted state. See
326
326
  * https://github.com/Agoric/agoric-sdk/issues/3434
327
327
  * @param {IssuerOptionsRecord} [options]
328
- * @returns {IssuerKit<K>}
328
+ * @returns {IssuerKit<K, any>}
329
329
  */
330
330
  export const makeIssuerKit = (
331
331
  name,
@@ -1,10 +1,10 @@
1
- export function claim<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, optAmountShape?: Pattern): Promise<Payment<K>>;
1
+ export function claim<P extends Payment>(recoveryPurse: ERef<Purse>, srcPaymentP: ERef<P>, optAmountShape?: Pattern): Promise<P>;
2
2
  export function combine<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentsPs: ERef<Payment<K>>[], optTotalAmount?: Pattern): Promise<Payment<K>>;
3
3
  export function split<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, paymentAmountA: Amount<K>): Promise<Payment<K>[]>;
4
4
  export function splitMany<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, amounts: Amount<K>[]): Promise<Payment[]>;
5
- import type { AssetKind } from './types.js';
5
+ import type { Payment } from './types.js';
6
6
  import type { Purse } from './types.js';
7
7
  import type { ERef } from '@endo/far';
8
- import type { Payment } from './types.js';
8
+ import type { AssetKind } from './types.js';
9
9
  import type { Amount } from './types.js';
10
10
  //# sourceMappingURL=legacy-payment-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AAkCO,sBAFsB,CAAC,mGADnB,OAAO,uBAYjB;AAiBM,wBAFsB,CAAC,uGADnB,OAAO,uBA2BjB;AAgBM,sBAFsB,CAAC,oIAY7B;AAgBM,0BAHW,CAAC,4HAqBlB;+BAxI0F,YAAY;2BAAZ,YAAY;0BADhF,WAAW;6BACyD,YAAY;4BAAZ,YAAY"}
1
+ {"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AAkCO,sBAFc,CAAC,qFADX,OAAO,GACL,OAAO,CAAC,CAAC,CAAC,CAYtB;AAiBM,wBAFsB,CAAC,uGADnB,OAAO,uBA2BjB;AAgBM,sBAFsB,CAAC,oIAY7B;AAgBM,0BAHW,CAAC,4HAqBlB;6BAzI0F,YAAY;2BAAZ,YAAY;0BADhF,WAAW;+BACyD,YAAY;4BAAZ,YAAY"}
@@ -26,11 +26,11 @@ const { Fail } = assert;
26
26
  */
27
27
 
28
28
  /**
29
- * @template {AssetKind} K
30
- * @param {ERef<Purse<K>>} recoveryPurse
31
- * @param {ERef<Payment<K>>} srcPaymentP
29
+ * @template {Payment} P
30
+ * @param {ERef<Purse>} recoveryPurse
31
+ * @param {ERef<P>} srcPaymentP
32
32
  * @param {Pattern} [optAmountShape]
33
- * @returns {Promise<Payment<K>>}
33
+ * @returns {Promise<P>}
34
34
  */
35
35
  export const claim = async (
36
36
  recoveryPurse,
@@ -38,6 +38,7 @@ export const claim = async (
38
38
  optAmountShape = undefined,
39
39
  ) => {
40
40
  const srcPayment = await srcPaymentP;
41
+ // @ts-expect-error XXX could be instantiated with a different subtype
41
42
  return E.when(E(recoveryPurse).deposit(srcPayment, optAmountShape), amount =>
42
43
  E(recoveryPurse).withdraw(amount),
43
44
  );
@@ -1,4 +1,4 @@
1
1
  /** @type {MathHelpers<import('@endo/patterns').CopyBag>} */
2
- export const copyBagMathHelpers: MathHelpers<import("@endo/patterns").CopyBag<any>>;
2
+ export const copyBagMathHelpers: MathHelpers<import("@endo/patterns").CopyBag<import("@endo/patterns").Key>>;
3
3
  import type { MathHelpers } from '../types.js';
4
4
  //# sourceMappingURL=copyBagMathHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAkBA,4DAA4D;AAC5D,oFAWG;iCAjB4B,aAAa"}
1
+ {"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAkBA,4DAA4D;AAC5D,6GAWG;iCAjB4B,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAqFO,qCAFoB,CAAC,gCAPjB,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,aAMU,CAAC,AALhB,6CAED,OAAO,qHA6UjB;+BA9YwH,YAAY;iCAAZ,YAAY;wCAAZ,YAAY;yCAC/F,sBAAsB;mCAD6D,YAAY"}
1
+ {"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAsFO,qCAFoB,CAAC,gCAPjB,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,aAMU,CAAC,AALhB,6CAED,OAAO,qHA4TjB;+BA9XwH,YAAY;iCAAZ,YAAY;wCAAZ,YAAY;yCAC/F,sBAAsB;mCAD6D,YAAY"}
@@ -15,6 +15,7 @@ import { BrandI, makeIssuerInterfaces } from './typeGuards.js';
15
15
  /**
16
16
  * @import {Amount, AssetKind, DisplayInfo, PaymentLedger, Payment, Brand, RecoverySetsOption, Purse, Issuer, Mint} from './types.js'
17
17
  * @import {ShutdownWithFailure} from '@agoric/swingset-vat'
18
+ * @import {Key} from '@endo/patterns';
18
19
  */
19
20
 
20
21
  const { details: X, quote: q, Fail } = assert;
@@ -93,11 +94,7 @@ export const preparePaymentLedger = (
93
94
  optShutdownWithFailure = undefined,
94
95
  ) => {
95
96
  /** @type {Brand<K>} */
96
- // Should be
97
- // at-ts-expect-error XXX callWhen
98
- // but ran into the usual disagreement between local lint and CI
99
-
100
- // @ts-expect-error
97
+ // @ts-expect-error XXX callWhen
101
98
  const brand = issuerZone.exo(`${name} brand`, BrandI, {
102
99
  isMyIssuer(allegedIssuer) {
103
100
  // BrandI delays calling this method until `allegedIssuer` is a Remotable
@@ -299,7 +296,7 @@ export const preparePaymentLedger = (
299
296
  };
300
297
 
301
298
  /** @type {() => Purse<K>} */
302
- // @ts-expect-error type parameter confusion
299
+ // @ts-expect-error XXX amount kinds
303
300
  const makeEmptyPurse = preparePurseKind(
304
301
  issuerZone,
305
302
  name,
@@ -315,11 +312,7 @@ export const preparePaymentLedger = (
315
312
  );
316
313
 
317
314
  /** @type {Issuer<K>} */
318
- // Should be
319
- // at-ts-expect-error cast due to callWhen discrepancy
320
- // but ran into the usual disagreement between local lint and CI
321
-
322
- // @ts-expect-error
315
+ // @ts-expect-error XXX callWhen
323
316
  const issuer = issuerZone.exo(`${name} issuer`, IssuerI, {
324
317
  getBrand() {
325
318
  return brand;
@@ -374,11 +367,6 @@ export const preparePaymentLedger = (
374
367
  * `makeIssuerKit` drops it on the floor, it can still be recovered in an
375
368
  * emergency upgrade.
376
369
  */
377
- // Should be
378
- // at-ts-expect-error checked cast
379
- // but ran into the usual disagreement between local lint and IDE lint.
380
- // Don't know yet about lint under CI.
381
-
382
370
  const mintRecoveryPurse = /** @type {Purse<K>} */ (
383
371
  issuerZone.makeOnce('mintRecoveryPurse', () => makeEmptyPurse())
384
372
  );
@@ -389,10 +377,6 @@ export const preparePaymentLedger = (
389
377
  return issuer;
390
378
  },
391
379
  mintPayment(newAmount) {
392
- // Should be
393
- // at-ts-expect-error checked cast
394
- // but ran into the usual disagreement between local lint and CI
395
-
396
380
  newAmount = coerce(newAmount);
397
381
  mustMatch(newAmount, amountShape, 'minted amount');
398
382
  // `rawPayment` is not associated with any recovery set, and
package/src/purse.d.ts CHANGED
@@ -7,18 +7,17 @@ export function preparePurseKind(issuerZone: import("@agoric/zone").Zone, name:
7
7
  }, recoverySetsState: RecoverySetsOption, paymentRecoverySets: globalThis.WeakMapStore<Payment, globalThis.SetStore<Payment>>): () => import("@endo/exo").Guarded<{
8
8
  deposit(srcPayment: any, optAmountShape?: undefined): any;
9
9
  withdraw(amount: any): any;
10
- getCurrentAmount(): Amount<AssetKind>;
10
+ getCurrentAmount(): import("./types.js").NatAmount | import("./types.js").CopySetAmount<import("@endo/patterns").Key> | import("./types.js").SetAmount<import("@endo/patterns").Key> | import("./types.js").CopyBagAmount<import("@endo/patterns").Key>;
11
11
  getCurrentAmountNotifier(): import("@agoric/notifier").Notifier<any>;
12
12
  getAllegedBrand(): Brand;
13
13
  getDepositFacet(): import("@endo/exo").Guarded<{
14
14
  receive(...args: any[]): any;
15
15
  }>;
16
- getRecoverySet(): import("@endo/patterns").CopySet<Payment>;
17
- recoverAll(): Amount<AssetKind>;
16
+ getRecoverySet(): import("@endo/patterns").CopySet<any>;
17
+ recoverAll(): import("./types.js").NatAmount | import("./types.js").CopySetAmount<import("@endo/patterns").Key> | import("./types.js").SetAmount<import("@endo/patterns").Key> | import("./types.js").CopyBagAmount<import("@endo/patterns").Key>;
18
18
  }>;
19
19
  import type { AssetKind } from './types.js';
20
20
  import type { Brand } from './types.js';
21
21
  import type { RecoverySetsOption } from './types.js';
22
22
  import type { Payment } from './types.js';
23
- import type { Amount } from './types.js';
24
23
  //# sourceMappingURL=purse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AA4BO,6CAfI,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,iDAGN;IACV,KAAS,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,YAAgB,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC5D,gBACO;IACV,eAAmB,EAAE,GAAG,CAAC;IACzB,gBAAoB,EAAE,GAAG,CAAC;CACvB;;;;;;;;;;;GA8JH;+BAjLwG,YAAY;2BAAZ,YAAY;wCAAZ,YAAY;6BAAZ,YAAY;4BAAZ,YAAY"}
1
+ {"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AA4BO,6CAfI,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,iDAGN;IACV,KAAS,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,YAAgB,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC5D,gBACO;IACV,eAAmB,EAAE,GAAG,CAAC;IACzB,gBAAoB,EAAE,GAAG,CAAC;CACvB;;;;;;;;;;;GA8JH;+BAjLwG,YAAY;2BAAZ,YAAY;wCAAZ,YAAY;6BAAZ,YAAY"}