@agoric/ertp 0.16.3-u14.0 → 0.16.3-u16.1

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 (53) hide show
  1. package/exported.d.ts +37 -0
  2. package/exported.js +2 -1
  3. package/package.json +35 -26
  4. package/src/amountMath.d.ts +44 -31
  5. package/src/amountMath.d.ts.map +1 -1
  6. package/src/amountMath.js +130 -120
  7. package/src/amountStore.d.ts +9 -0
  8. package/src/amountStore.d.ts.map +1 -0
  9. package/src/amountStore.js +34 -0
  10. package/src/displayInfo.d.ts +3 -0
  11. package/src/displayInfo.d.ts.map +1 -1
  12. package/src/displayInfo.js +2 -0
  13. package/src/index.js +8 -0
  14. package/src/issuerKit.d.ts +30 -6
  15. package/src/issuerKit.d.ts.map +1 -1
  16. package/src/issuerKit.js +218 -76
  17. package/src/legacy-payment-helpers.d.ts +6 -1
  18. package/src/legacy-payment-helpers.d.ts.map +1 -1
  19. package/src/legacy-payment-helpers.js +33 -32
  20. package/src/mathHelpers/copyBagMathHelpers.d.ts +3 -4
  21. package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -1
  22. package/src/mathHelpers/copyBagMathHelpers.js +4 -5
  23. package/src/mathHelpers/copySetMathHelpers.d.ts +3 -3
  24. package/src/mathHelpers/copySetMathHelpers.d.ts.map +1 -1
  25. package/src/mathHelpers/copySetMathHelpers.js +6 -4
  26. package/src/mathHelpers/natMathHelpers.d.ts +8 -7
  27. package/src/mathHelpers/natMathHelpers.d.ts.map +1 -1
  28. package/src/mathHelpers/natMathHelpers.js +7 -8
  29. package/src/mathHelpers/setMathHelpers.d.ts +2 -0
  30. package/src/mathHelpers/setMathHelpers.d.ts.map +1 -1
  31. package/src/mathHelpers/setMathHelpers.js +2 -1
  32. package/src/payment.d.ts +4 -2
  33. package/src/payment.d.ts.map +1 -1
  34. package/src/payment.js +6 -7
  35. package/src/paymentLedger.d.ts +6 -2
  36. package/src/paymentLedger.d.ts.map +1 -1
  37. package/src/paymentLedger.js +71 -90
  38. package/src/purse.d.ts +19 -9
  39. package/src/purse.d.ts.map +1 -1
  40. package/src/purse.js +86 -25
  41. package/src/transientNotifier.d.ts +1 -1
  42. package/src/transientNotifier.d.ts.map +1 -1
  43. package/src/transientNotifier.js +5 -0
  44. package/src/typeGuards.d.ts +41 -9
  45. package/src/typeGuards.d.ts.map +1 -1
  46. package/src/typeGuards.js +38 -43
  47. package/src/types.d.ts +250 -215
  48. package/src/types.d.ts.map +1 -1
  49. package/src/types.js +305 -326
  50. package/CHANGELOG.md +0 -775
  51. package/src/types-ambient.d.ts +0 -376
  52. package/src/types-ambient.d.ts.map +0 -1
  53. package/src/types-ambient.js +0 -440
package/exported.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */
2
+ /** @see {@link /docs/typescript.md} */
3
+ /* eslint-disable -- doesn't understand .d.ts */
4
+
5
+ import '@agoric/notifier/exported.js';
6
+
7
+ import {
8
+ Amount as _Amount,
9
+ Brand as _Brand,
10
+ Issuer as _Issuer,
11
+ IssuerKit as _IssuerKit,
12
+ Mint as _Mint,
13
+ AssetKind as _AssetKind,
14
+ SetValue as _SetValue,
15
+ NatValue as _NatValue,
16
+ DisplayInfo as _DisplayInfo,
17
+ AdditionalDisplayInfo as _AdditionalDisplayInfo,
18
+ Payment as _Payment,
19
+ Purse as _Purse,
20
+ } from './src/types.js';
21
+ declare global {
22
+ // @ts-ignore TS2666: Exports and export assignments are not permitted in module augmentations.
23
+ export {
24
+ _Amount as Amount,
25
+ _Brand as Brand,
26
+ _Issuer as Issuer,
27
+ _IssuerKit as IssuerKit,
28
+ _Mint as Mint,
29
+ _AssetKind as AssetKind,
30
+ _SetValue as SetValue,
31
+ _NatValue as NatValue,
32
+ _DisplayInfo as DisplayInfo,
33
+ _AdditionalDisplayInfo as AdditionalDisplayInfo,
34
+ _Payment as Payment,
35
+ _Purse as Purse,
36
+ };
37
+ }
package/exported.js CHANGED
@@ -1 +1,2 @@
1
- import './src/types-ambient.js';
1
+ // Dummy file for .d.ts twin to declare ambients
2
+ export {};
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@agoric/ertp",
3
- "version": "0.16.3-u14.0",
3
+ "version": "0.16.3-u16.1",
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",
7
7
  "engines": {
8
- "node": ">=14.15.0"
8
+ "node": "^18.12 || ^20.9"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "exit 0",
12
- "prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build jsconfig.build.json",
13
- "postpack": "git clean -f '*.d.ts*' src/types.js",
12
+ "prepack": "tsc --build tsconfig.build.json",
13
+ "postpack": "git clean -f '*.d.ts*'",
14
14
  "test": "ava",
15
15
  "test:c8": "c8 $C8_OPTIONS ava",
16
16
  "test:xs": "yarn test:xs-unit && yarn test:xs-worker",
17
17
  "test:xs-unit": "ava-xs",
18
- "test:xs-worker": "SWINGSET_WORKER_TYPE=xs-worker ava -c 2 'test/swingsetTests/**/test-*.js'",
18
+ "test:xs-worker": "SWINGSET_WORKER_TYPE=xs-worker ava -c 2 test/swingsetTests",
19
19
  "lint-fix": "yarn lint:eslint --fix",
20
20
  "lint": "run-s --continue-on-error lint:*",
21
21
  "lint:eslint": "eslint .",
22
- "lint:types": "tsc -p jsconfig.json"
22
+ "lint:types": "tsc"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -39,45 +39,54 @@
39
39
  },
40
40
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
41
41
  "dependencies": {
42
- "@agoric/assert": "^0.6.1-u11wf.0",
43
- "@agoric/notifier": "^0.6.3-u14.0",
44
- "@agoric/store": "^0.9.3-u14.0",
45
- "@agoric/swingset-vat": "^0.32.3-u14.0",
46
- "@agoric/vat-data": "^0.5.3-u14.0",
47
- "@endo/eventual-send": "0.17.2",
48
- "@endo/far": "0.2.18",
49
- "@endo/marshal": "0.8.5",
50
- "@endo/nat": "4.1.27",
51
- "@endo/promise-kit": "0.2.56"
42
+ "@agoric/assert": "^0.6.1-u16.0",
43
+ "@agoric/notifier": "^0.7.0-u16.1",
44
+ "@agoric/store": "^0.9.3-u16.0",
45
+ "@agoric/vat-data": "^0.5.3-u16.1",
46
+ "@agoric/zone": "^0.3.0-u16.1",
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"
52
53
  },
53
54
  "devDependencies": {
54
- "@endo/bundle-source": "2.5.2-upstream-rollup",
55
- "@fast-check/ava": "^1.1.3",
56
- "ava": "^5.2.0",
57
- "tsd": "^0.28.1"
55
+ "@agoric/swingset-vat": "^0.33.0-u16.1",
56
+ "@endo/bundle-source": "^3.2.3",
57
+ "@fast-check/ava": "^1.1.5",
58
+ "ava": "^5.3.0",
59
+ "tsd": "^0.30.7"
58
60
  },
59
61
  "files": [
60
62
  "src",
61
63
  "NEWS.md",
62
- "exported.js"
64
+ "exported.js",
65
+ "exported.d.ts"
63
66
  ],
64
67
  "ava-xs": {
65
68
  "exclude": [
66
69
  "swingsetTests",
67
70
  "# fast-check unsupported",
68
- "test/unitTests/test-amountProperties.js",
69
- "test/unitTests/test-inputValidation.js",
70
- "test/unitTests/test-issuerObj.js"
71
+ "test/unitTests/amountProperties.test.js",
72
+ "test/unitTests/inputValidation.test.js",
73
+ "test/unitTests/issuerObj.test.js"
71
74
  ]
72
75
  },
73
76
  "ava": {
74
77
  "files": [
75
- "test/**/test-*.js"
78
+ "test/**/*.test.*"
79
+ ],
80
+ "require": [
81
+ "@endo/init/debug.js"
76
82
  ],
77
83
  "timeout": "5m"
78
84
  },
79
85
  "publishConfig": {
80
86
  "access": "public"
81
87
  },
82
- "gitHead": "b3a6f3374cb3bddab39fc6d6f426429cae6c29c6"
88
+ "typeCoverage": {
89
+ "atLeast": 91.22
90
+ },
91
+ "gitHead": "2eaeab90b4015e355faea534c1c933351d25b1b9"
83
92
  }
@@ -1,46 +1,59 @@
1
- export function assertValueGetHelpers<V extends AmountValue>(value: V): MathHelpers<V>;
1
+ export function assertValueGetHelpers<V>(value: V): MathHelpers<V>;
2
+ import type { MathHelpers } from './types.js';
2
3
  export namespace AmountMath {
3
- export function make<K extends AssetKind>(brand: Brand<K>, allegedValue: AssetValueForKind<K>): Amount<K>;
4
- export function coerce<K extends AssetKind>(brand: Brand<K>, allegedAmount: Amount<K>): Amount<K>;
5
- export function getValue<K extends AssetKind>(brand: Brand<K>, amount: Amount<K>): AssetValueForKind<K>;
6
- export const makeEmpty: {
7
- (brand: Brand<AssetKind>): Amount<"nat">;
8
- <K extends AssetKind>(brand: Brand<AssetKind>, assetKind: K): Amount<K>;
4
+ export function make<B extends Brand, V extends NatValue | CopySet | CopyBag | SetValue>(brand: B, allegedValue: V): B extends Brand<"nat"> ? NatAmount : V extends NatValue ? 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"];
7
+ export let makeEmpty: {
8
+ (brand: Brand): Amount<"nat">;
9
+ <K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
9
10
  };
10
- export function makeEmptyFromAmount<K extends AssetKind>(amount: Amount<K>): Amount<K>;
11
- export function isEmpty(amount: Amount<AssetKind>, brand?: Brand<AssetKind> | undefined): boolean;
11
+ export function makeEmptyFromAmount<A extends Amount>(amount: A): A;
12
+ export function isEmpty(amount: Amount, brand?: Brand | undefined): boolean;
12
13
  export { isGTE };
13
- export function isEqual<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
14
- export function add<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
15
- export function subtract<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
16
- export function min<K extends AssetKind>(x: Amount<K>, y: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
17
- 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;
18
19
  }
19
20
  /**
20
21
  * Constants for the kinds of assets we support.
21
22
  *
22
- * @type {{ NAT: 'nat', SET: 'set', COPY_SET: 'copySet', COPY_BAG: 'copyBag' }}
23
+ * @type {{
24
+ * NAT: 'nat';
25
+ * SET: 'set';
26
+ * COPY_SET: 'copySet';
27
+ * COPY_BAG: 'copyBag';
28
+ * }}
23
29
  */
24
30
  export const AssetKind: {
25
- NAT: 'nat';
26
- SET: 'set';
27
- COPY_SET: 'copySet';
28
- COPY_BAG: 'copyBag';
31
+ NAT: "nat";
32
+ SET: "set";
33
+ COPY_SET: "copySet";
34
+ COPY_BAG: "copyBag";
29
35
  };
30
- /**
31
- * @param {Amount} amount
32
- */
33
- export function getAssetKind(amount: Amount): AssetKindForValue<V>;
34
- /**
35
- * @param {AssetKind} allegedAK
36
- */
36
+ import type { AssetKind } from './types.js';
37
+ /** @param {Amount} amount */
38
+ export function getAssetKind(amount: Amount): "copySet" | "set" | "nat" | "copyBag";
39
+ /** @param {AssetKind} allegedAK */
37
40
  export function assertAssetKind(allegedAK: AssetKind): void;
41
+ import type { Brand } from './types.js';
42
+ import type { NatValue } from './types.js';
43
+ import type { CopySet } from '@endo/patterns';
44
+ import type { CopyBag } from '@endo/patterns';
45
+ import type { SetValue } from './types.js';
46
+ import type { NatAmount } from './types.js';
47
+ import type { CopySetAmount } from './types.js';
48
+ import type { CopyBagAmount } from './types.js';
49
+ import type { SetAmount } from './types.js';
50
+ import type { Amount } from './types.js';
38
51
  /**
39
- * Returns true if the leftAmount is greater than or equal to the
40
- * rightAmount. The notion of "greater than or equal to" depends
41
- * on the kind of amount, as defined by the MathHelpers. For example,
42
- * whether rectangle A is greater than rectangle B depends on whether rectangle
43
- * A includes rectangle B as defined by the logic in MathHelpers.
52
+ * Returns true if the leftAmount is greater than or equal to the rightAmount.
53
+ * The notion of "greater than or equal to" depends on the kind of amount, as
54
+ * defined by the MathHelpers. For example, whether rectangle A is greater than
55
+ * rectangle B depends on whether rectangle A includes rectangle B as defined by
56
+ * the logic in MathHelpers.
44
57
  *
45
58
  * @template {AssetKind} K
46
59
  * @param {Amount<K>} leftAmount
@@ -1 +1 @@
1
- {"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAuHO,uFAEkC;;IAyFjC,0GAKL;IAUO,kGAQP;IASS,wGAAyD;;;;;IAwB9C,uFAOpB;IAQQ,kGAOR;;IAYQ,mIAGR;IAcI,iIAIJ;IAeS,sIAIT;IAUI,8GAMqC;IAUrC,8GAMqC;;AA1W5C;;;;GAIG;AACH,wBAFU;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,CAO3E;AAoWH;;GAEG;AACH,qCAFW,MAAM,wBAOhB;AAzWD;;GAEG;AACH,2CAFW,SAAS,QAKnB;AAgJD;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