@agoric/ertp 0.16.3-u17.0 → 0.16.3-u18.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-u17.0",
3
+ "version": "0.16.3-u18.0",
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",
@@ -10,11 +10,11 @@
10
10
  "scripts": {
11
11
  "build": "exit 0",
12
12
  "prepack": "tsc --build tsconfig.build.json",
13
- "postpack": "git clean -f '*.d.ts*'",
13
+ "postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'",
14
14
  "test": "ava",
15
15
  "test:c8": "c8 $C8_OPTIONS ava",
16
- "test:xs": "yarn test:xs-unit && yarn test:xs-worker",
17
- "test:xs-unit": "ava-xs",
16
+ "test:xs": "yarn test:xs-worker",
17
+ "test:xs-unit": "exit 0",
18
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:*",
@@ -39,21 +39,21 @@
39
39
  },
40
40
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
41
41
  "dependencies": {
42
- "@agoric/notifier": "^0.7.0-u17.0",
43
- "@agoric/store": "^0.9.3-u17.0",
44
- "@agoric/vat-data": "^0.5.3-u17.0",
45
- "@agoric/zone": "^0.3.0-u17.0",
46
- "@endo/errors": "^1.2.5",
47
- "@endo/eventual-send": "^1.2.5",
48
- "@endo/far": "^1.1.5",
49
- "@endo/marshal": "^1.5.3",
50
- "@endo/nat": "^5.0.10",
51
- "@endo/patterns": "^1.4.3",
52
- "@endo/promise-kit": "^1.1.5"
42
+ "@agoric/notifier": "^0.7.0-u18.0",
43
+ "@agoric/store": "^0.9.3-u18.0",
44
+ "@agoric/vat-data": "^0.5.3-u18.0",
45
+ "@agoric/zone": "^0.3.0-u18.0",
46
+ "@endo/errors": "^1.2.7",
47
+ "@endo/eventual-send": "^1.2.7",
48
+ "@endo/far": "^1.1.8",
49
+ "@endo/marshal": "^1.6.1",
50
+ "@endo/nat": "^5.0.12",
51
+ "@endo/patterns": "^1.4.6",
52
+ "@endo/promise-kit": "^1.1.7"
53
53
  },
54
54
  "devDependencies": {
55
- "@agoric/swingset-vat": "^0.33.0-u17.0",
56
- "@endo/bundle-source": "^3.4.0",
55
+ "@agoric/swingset-vat": "^0.33.0-u18.0",
56
+ "@endo/bundle-source": "^3.4.2",
57
57
  "@fast-check/ava": "^1.1.5",
58
58
  "ava": "^5.3.0",
59
59
  "tsd": "^0.31.1"
@@ -64,15 +64,6 @@
64
64
  "exported.js",
65
65
  "exported.d.ts"
66
66
  ],
67
- "ava-xs": {
68
- "exclude": [
69
- "swingsetTests",
70
- "# fast-check unsupported",
71
- "test/unitTests/amountProperties.test.js",
72
- "test/unitTests/inputValidation.test.js",
73
- "test/unitTests/issuerObj.test.js"
74
- ]
75
- },
76
67
  "ava": {
77
68
  "files": [
78
69
  "test/**/*.test.*"
@@ -88,5 +79,5 @@
88
79
  "typeCoverage": {
89
80
  "atLeast": 91.23
90
81
  },
91
- "gitHead": "515c4c0efccfc91b97da30037c10fc4b076851e2"
82
+ "gitHead": "c22e7250188bbdb07bc021dffdb88af0309a7aa8"
92
83
  }
@@ -1,5 +1,15 @@
1
+ /**
2
+ * Constants for the kinds of assets we support.
3
+ */
4
+ export type AssetKind = (typeof AssetKind)[keyof typeof AssetKind];
5
+ export namespace AssetKind {
6
+ let NAT: "nat";
7
+ let SET: "set";
8
+ let COPY_SET: "copySet";
9
+ let COPY_BAG: "copyBag";
10
+ }
11
+ export function assertAssetKind(allegedAK: AssetKind): void;
1
12
  export function assertValueGetHelpers<V>(value: V): MathHelpers<V>;
2
- import type { MathHelpers } from './types.js';
3
13
  export namespace AmountMath {
4
14
  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
15
  export function coerce<A extends Amount>(brand: Brand, allegedAmount: A): A;
@@ -17,31 +27,8 @@ export namespace AmountMath {
17
27
  export function min<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
18
28
  export function max<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
19
29
  }
20
- /**
21
- * @import {CopyBag, CopySet} from '@endo/patterns';
22
- * @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
23
- */
24
- /**
25
- * Constants for the kinds of assets we support.
26
- *
27
- * @type {{
28
- * NAT: 'nat';
29
- * SET: 'set';
30
- * COPY_SET: 'copySet';
31
- * COPY_BAG: 'copyBag';
32
- * }}
33
- */
34
- export const AssetKind: {
35
- NAT: "nat";
36
- SET: "set";
37
- COPY_SET: "copySet";
38
- COPY_BAG: "copyBag";
39
- };
40
- import type { AssetKind } from './types.js';
41
- /** @param {Amount} amount */
42
30
  export function getAssetKind(amount: Amount): "copySet" | "set" | "nat" | "copyBag";
43
- /** @param {AssetKind} allegedAK */
44
- export function assertAssetKind(allegedAK: AssetKind): void;
31
+ import type { MathHelpers } from './types.js';
45
32
  import type { Brand } from './types.js';
46
33
  import type { NatValue } from './types.js';
47
34
  import type { CopySet } from '@endo/patterns';
@@ -1 +1 @@
1
- {"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAkHO,sCAJM,CAAC,SACH,CAAC,GACC,YAAY,CAAC,CAAC,CAIc;iCAzG0I,YAAY;;IA+MvL,qBAhBe,CAAC,SAAT,KAAO,E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;GAYG;AACH,uBANyB,CAAC,SAAZ,SAAU,cACb,OAAO,CAAC,CAAC,eACT,OAAO,CAAC,CAAC,iCAEP,OAAO,CAKnB"}
package/src/amountMath.js CHANGED
@@ -9,29 +9,26 @@ import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';
9
9
 
10
10
  /**
11
11
  * @import {CopyBag, CopySet} from '@endo/patterns';
12
- * @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
12
+ * @import {Amount, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
13
13
  */
14
14
 
15
+ // NB: AssetKind is both a constant for enumerated values and a type for those values.
15
16
  /**
16
17
  * Constants for the kinds of assets we support.
17
18
  *
18
- * @type {{
19
- * NAT: 'nat';
20
- * SET: 'set';
21
- * COPY_SET: 'copySet';
22
- * COPY_BAG: 'copyBag';
23
- * }}
19
+ * @enum {(typeof AssetKind)[keyof typeof AssetKind]}
24
20
  */
25
- const AssetKind = harden({
21
+ export const AssetKind = /** @type {const} */ ({
26
22
  NAT: 'nat',
27
23
  SET: 'set',
28
24
  COPY_SET: 'copySet',
29
25
  COPY_BAG: 'copyBag',
30
26
  });
27
+ harden(AssetKind);
31
28
  const assetKindNames = harden(Object.values(AssetKind).sort());
32
29
 
33
30
  /** @param {AssetKind} allegedAK */
34
- const assertAssetKind = allegedAK => {
31
+ export const assertAssetKind = allegedAK => {
35
32
  assetKindNames.includes(allegedAK) ||
36
33
  Fail`The assetKind ${allegedAK} must be one of ${q(assetKindNames)}`;
37
34
  };
@@ -192,7 +189,7 @@ const isGTE = (leftAmount, rightAmount, brand = undefined) => {
192
189
  * and payments. They can be used to represent things like currency, stock, and
193
190
  * the abstract right to participate in a particular exchange.
194
191
  */
195
- const AmountMath = {
192
+ export const AmountMath = {
196
193
  // TODO use overloading to handle when Brand has an AssetKind and when it doesn't.
197
194
  // a AmountForValue utility could help DRY those cases.
198
195
  /**
@@ -387,11 +384,9 @@ const AmountMath = {
387
384
  harden(AmountMath);
388
385
 
389
386
  /** @param {Amount} amount */
390
- const getAssetKind = amount => {
387
+ export const getAssetKind = amount => {
391
388
  assertRecord(amount, 'amount');
392
389
  const { value } = amount;
393
390
  return assertValueGetAssetKind(value);
394
391
  };
395
392
  harden(getAssetKind);
396
-
397
- export { AmountMath, AssetKind, getAssetKind, assertAssetKind };
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./amountMath.js";
2
2
  export * from "./issuerKit.js";
3
3
  export * from "./typeGuards.js";
4
+ export * from "./types-index.js";
4
5
  //# sourceMappingURL=index.d.ts.map
package/src/index.js CHANGED
@@ -11,3 +11,6 @@ export * from './typeGuards.js';
11
11
  *
12
12
  * @import {Baggage} from '@agoric/vat-data'
13
13
  */
14
+
15
+ // eslint-disable-next-line import/export
16
+ export * from './types-index.js';
@@ -1,18 +1,18 @@
1
- export function upgradeIssuerKit<K extends import("./types.js").AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, optShutdownWithFailure?: ShutdownWithFailure | undefined, recoverySetsOption?: RecoverySetsOption | undefined): IssuerKit<K>;
1
+ export function upgradeIssuerKit<K extends AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, optShutdownWithFailure?: ShutdownWithFailure | undefined, recoverySetsOption?: RecoverySetsOption | undefined): IssuerKit<K>;
2
2
  export function hasIssuer(baggage: import("@agoric/vat-data").Baggage): boolean;
3
- export function makeDurableIssuerKit<K extends import("./types.js").AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: ShutdownWithFailure | undefined, { elementShape, recoverySetsOption }?: Partial<{
3
+ export function makeDurableIssuerKit<K extends AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: ShutdownWithFailure | undefined, { elementShape, recoverySetsOption }?: Partial<{
4
4
  elementShape: Pattern;
5
5
  recoverySetsOption: RecoverySetsOption;
6
6
  }> | undefined): IssuerKit<K>;
7
- export function prepareIssuerKit<K extends import("./types.js").AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: ShutdownWithFailure | undefined, options?: Partial<{
7
+ export function prepareIssuerKit<K extends AssetKind>(issuerBaggage: import("@agoric/vat-data").Baggage, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: ShutdownWithFailure | undefined, options?: Partial<{
8
8
  elementShape: Pattern;
9
9
  recoverySetsOption: RecoverySetsOption;
10
10
  }> | undefined): IssuerKit<K>;
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<{
11
+ export function makeIssuerKit<K extends 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
14
  }> | undefined): IssuerKit<K, any>;
15
- export type IssuerRecord<K extends import("./types.js").AssetKind> = {
15
+ export type IssuerRecord<K extends AssetKind> = {
16
16
  name: string;
17
17
  assetKind: K;
18
18
  displayInfo: AdditionalDisplayInfo;
@@ -36,6 +36,7 @@ export type IssuerOptionsRecord = Partial<{
36
36
  elementShape: Pattern;
37
37
  recoverySetsOption: RecoverySetsOption;
38
38
  }>;
39
+ import { AssetKind } from './amountMath.js';
39
40
  import type { ShutdownWithFailure } from '@agoric/swingset-vat';
40
41
  import type { RecoverySetsOption } from './types.js';
41
42
  import type { IssuerKit } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAbkB,CAAC,SAAb,8BAAW,iBACb,OAAO,kBAAkB,EAAE,OAAO,kHAUhC,UAAU,CAAC,CAAC,CA4BxB;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCA1BkB,CAAC,SAAb,8BAAW,iBAYb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAtBE,OAAO;wBACD,kBAAkB;iBAgC9B,UAAU,CAAC,CAAC,CA2BxB;AAiCM,iCA1BkB,CAAC,SAAb,8BAAW,iBAYb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAhFE,OAAO;wBACD,kBAAkB;iBA0F9B,UAAU,CAAC,CAAC,CAuCxB;AAqCM,8BAzBmB,CAAC,SAAd,8BAAW,gBAYb,MAAM;kBA1JE,OAAO;wBACD,kBAAkB;iBAoK9B,UAAU,CAAC,EAAE,GAAG,CAAC,CAiB3B;yBAtUsB,CAAC,SAAb,8BAAW;UAEV,MAAM;eACN,CAAC;iBACD,qBAAqB;kBACrB,OAAO;;;;;;;;;;;;;;;;kCA0IR,OAAO,CAAC;IACpB,YAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAsB,EAAE,kBAAkB,CAAC;CACxC,CAAC;yCArJkC,sBAAsB;wCAD0B,YAAY;+BAAZ,YAAY;2CAAZ,YAAY"}
1
+ {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAbkB,CAAC,SAAZ,SAAU,iBACb,OAAO,kBAAkB,EAAE,OAAO,kHAUhC,UAAU,CAAC,CAAC,CA4BxB;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCA1BkB,CAAC,SAAZ,SAAU,iBAYb,OA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":[],"mappings":"AA2BO,6CAfI,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,aACN,SAAS,SACT,KAAK,aACL;IACN,KAAK,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACpD,YAAY,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC5D,gBACO;IACN,eAAe,EAAE,GAAG,CAAC;IACrB,gBAAgB,EAAE,GAAG,CAAC;CACvB,qBACO,kBAAkB,uBAClB,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;;;;;;;;;;;GA4JlD;+BA/KwG,YAAY;2BAAZ,YAAY;wCAAZ,YAAY;6BAAZ,YAAY"}
@@ -0,0 +1,2 @@
1
+ // Export all the types this package provides
2
+ export type * from './types.js';
@@ -0,0 +1,2 @@
1
+ // Empty JS file to correspond with its .d.ts twin
2
+ export {};
package/src/types.d.ts CHANGED
@@ -1,17 +1,23 @@
1
+ import type { LatestTopic } from '@agoric/notifier';
2
+ import type { ERef } from '@endo/far';
3
+ import type { RemotableObject } from '@endo/pass-style';
4
+ import type { CopyBag, CopySet, Key, Pattern } from '@endo/patterns';
5
+ import type { AssetKind } from './amountMath.js';
6
+ export type { AssetKind } from './amountMath.js';
1
7
  export type NatAmount = {
2
- brand: Brand<"nat">;
8
+ brand: Brand<'nat'>;
3
9
  value: bigint;
4
10
  };
5
11
  export type SetAmount<K extends Key> = {
6
- brand: Brand<"set">;
12
+ brand: Brand<'set'>;
7
13
  value: K[];
8
14
  };
9
15
  export type CopySetAmount<K extends Key> = {
10
- brand: Brand<"copySet">;
16
+ brand: Brand<'copySet'>;
11
17
  value: CopySet<K>;
12
18
  };
13
19
  export type CopyBagAmount<K extends Key> = {
14
- brand: Brand<"copyBag">;
20
+ brand: Brand<'copyBag'>;
15
21
  value: CopyBag<K>;
16
22
  };
17
23
  export type AnyAmount = {
@@ -27,7 +33,7 @@ export type AnyAmount = {
27
33
  * balance of 5 bucks. An empty purse has 0 bucks. AmountMath relies heavily
28
34
  * on polymorphic MathHelpers, which manipulate the unbranded portion.
29
35
  */
30
- export type Amount<K extends AssetKind = AssetKind, M extends Key = Key> = K extends "nat" ? NatAmount : K extends "set" ? SetAmount<M> : K extends "copySet" ? CopySetAmount<M> : K extends "copyBag" ? CopyBagAmount<M> : AnyAmount;
36
+ export type Amount<K extends AssetKind = AssetKind, M extends Key = Key> = K extends 'nat' ? NatAmount : K extends 'set' ? SetAmount<M> : K extends 'copySet' ? CopySetAmount<M> : K extends 'copyBag' ? CopyBagAmount<M> : AnyAmount;
31
37
  /**
32
38
  * An `AmountValue` describes a set or quantity of assets that can be owned or
33
39
  * shared.
@@ -49,14 +55,14 @@ export type Amount<K extends AssetKind = AssetKind, M extends Key = Key> = K ext
49
55
  * once or more times, i.e., some positive bigint number of times,
50
56
  * representing that quantity of the asset represented by that key.
51
57
  */
52
- export type AmountValue = NatValue | SetValue | CopySet | import("@endo/patterns").CopyBag;
58
+ export type AmountValue = NatValue | SetValue | CopySet | import('@endo/patterns').CopyBag;
53
59
  /**
54
60
  * See doc-comment
55
61
  * for `AmountValue`.
56
62
  */
57
- export type AssetKind = "nat" | "set" | "copySet" | "copyBag";
58
- export type AssetValueForKind<K extends AssetKind, M extends Key = Key> = K extends "nat" ? NatValue : K extends "set" ? SetValue<M> : K extends "copySet" ? CopySet<M> : K extends "copyBag" ? CopyBag<M> : never;
59
- export type AssetKindForValue<V extends AmountValue> = V extends NatValue ? "nat" : V extends SetValue ? "set" : V extends CopySet ? "copySet" : V extends import("@endo/patterns").CopyBag ? "copyBag" : never;
63
+ export type AssetValueForKind<K extends AssetKind, M extends Key = Key> = K extends 'nat' ? NatValue : K extends 'set' ? SetValue<M> : K extends 'copySet' ? CopySet<M> : K extends 'copyBag' ? CopyBag<M> : never;
64
+ export type AssetKindForValue<V extends AmountValue> = V extends NatValue ? 'nat' : V extends SetValue ? 'set' : V extends CopySet ? 'copySet' : V extends import('@endo/patterns').CopyBag ? 'copyBag' : never;
65
+ /** @deprecated */
60
66
  export type DisplayInfo<K extends AssetKind = AssetKind> = {
61
67
  /**
62
68
  * Tells the display software how many
@@ -82,10 +88,7 @@ export type BrandMethods<K extends AssetKind> = {
82
88
  */
83
89
  isMyIssuer: (allegedIssuer: ERef<Issuer<K>>) => Promise<boolean>;
84
90
  getAllegedName: () => string;
85
- /**
86
- * Give information to UI on how
87
- * to display the amount.
88
- */
91
+ /** @deprecated look up in boardAux */
89
92
  getDisplayInfo: () => DisplayInfo<K>;
90
93
  getAmountShape: () => Pattern;
91
94
  };
@@ -153,10 +156,7 @@ export type IssuerMethods<K extends AssetKind, M extends Key> = {
153
156
  * Issuer.
154
157
  */
155
158
  getAssetKind: () => K;
156
- /**
157
- * Give information to UI on how
158
- * to display amounts for this issuer.
159
- */
159
+ /** @deprecated look up in boardAux */
160
160
  getDisplayInfo: () => DisplayInfo<K>;
161
161
  /**
162
162
  * Make an empty purse of this
@@ -242,7 +242,7 @@ export type Mint<K extends AssetKind = AssetKind, M extends Key = Key> = {
242
242
  * transition is needed, it can likely be supported in a future upgrade. File an
243
243
  * issue on github and explain what you need and why.
244
244
  */
245
- export type RecoverySetsOption = "hasRecoverySets" | "noRecoverySets";
245
+ export type RecoverySetsOption = 'hasRecoverySets' | 'noRecoverySets';
246
246
  export type DepositFacetReceive = (payment: Payment, optAmountShape?: Pattern) => Amount;
247
247
  export type DepositFacet = {
248
248
  /**
@@ -403,9 +403,4 @@ export type MathHelpers<V extends AmountValue> = {
403
403
  };
404
404
  export type NatValue = bigint;
405
405
  export type SetValue<K extends Key = Key> = K[];
406
- import type { Key } from '@endo/patterns';
407
- import type { CopySet } from '@endo/patterns';
408
- import type { CopyBag } from '@endo/patterns';
409
- import type { RemotableObject } from '@endo/pass-style';
410
- import type { LatestTopic } from '@agoric/notifier';
411
406
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types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AAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAC1C;;;OAGG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IAChC;;;;OAIG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CACtC,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC"}
package/src/types.ts ADDED
@@ -0,0 +1,466 @@
1
+ /* eslint-disable no-use-before-define */
2
+ import type { LatestTopic } from '@agoric/notifier';
3
+ import type { ERef } from '@endo/far';
4
+ import type { RemotableObject } from '@endo/pass-style';
5
+ import type { CopyBag, CopySet, Key, Pattern } from '@endo/patterns';
6
+ import type { AssetKind } from './amountMath.js';
7
+
8
+ export type { AssetKind } from './amountMath.js';
9
+
10
+ export type NatAmount = {
11
+ brand: Brand<'nat'>;
12
+ value: bigint;
13
+ };
14
+ export type SetAmount<K extends Key> = {
15
+ brand: Brand<'set'>;
16
+ value: K[];
17
+ };
18
+ export type CopySetAmount<K extends Key> = {
19
+ brand: Brand<'copySet'>;
20
+ value: CopySet<K>;
21
+ };
22
+ export type CopyBagAmount<K extends Key> = {
23
+ brand: Brand<'copyBag'>;
24
+ value: CopyBag<K>;
25
+ };
26
+ export type AnyAmount = {
27
+ brand: Brand<any>;
28
+ value: any;
29
+ };
30
+ /**
31
+ * Amounts are descriptions of digital assets, answering the questions "how
32
+ * much" and "of what kind". Amounts are values labeled with a brand.
33
+ * AmountMath executes the logic of how amounts are changed when digital
34
+ * assets are merged, separated, or otherwise manipulated. For example, a
35
+ * deposit of 2 bucks into a purse that already has 3 bucks gives a new purse
36
+ * balance of 5 bucks. An empty purse has 0 bucks. AmountMath relies heavily
37
+ * on polymorphic MathHelpers, which manipulate the unbranded portion.
38
+ */
39
+ export type Amount<
40
+ K extends AssetKind = AssetKind,
41
+ M extends Key = Key,
42
+ > = K extends 'nat'
43
+ ? NatAmount
44
+ : K extends 'set'
45
+ ? SetAmount<M>
46
+ : K extends 'copySet'
47
+ ? CopySetAmount<M>
48
+ : K extends 'copyBag'
49
+ ? CopyBagAmount<M>
50
+ : AnyAmount;
51
+ /**
52
+ * An `AmountValue` describes a set or quantity of assets that can be owned or
53
+ * shared.
54
+ *
55
+ * A fungible `AmountValue` uses a non-negative bigint to represent a quantity
56
+ * of that many assets.
57
+ *
58
+ * A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
59
+ * a set of whatever asset each key represents. A `Key` is a passable value
60
+ * that can be used as an element in a set (SetStore or CopySet) or as the key
61
+ * in a map (MapStore or CopyMap).
62
+ *
63
+ * `SetValue` is for the deprecated set representation, using an array directly
64
+ * to represent the array of its elements. `CopySet` is the proper
65
+ * representation using a CopySet.
66
+ *
67
+ * A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
68
+ * "Bag" is synonymous with MultiSet, where an element of a bag can be present
69
+ * once or more times, i.e., some positive bigint number of times,
70
+ * representing that quantity of the asset represented by that key.
71
+ */
72
+ export type AmountValue =
73
+ | NatValue
74
+ | SetValue
75
+ | CopySet
76
+ | import('@endo/patterns').CopyBag;
77
+ /**
78
+ * See doc-comment
79
+ * for `AmountValue`.
80
+ */
81
+ export type AssetValueForKind<
82
+ K extends AssetKind,
83
+ M extends Key = Key,
84
+ > = K extends 'nat'
85
+ ? NatValue
86
+ : K extends 'set'
87
+ ? SetValue<M>
88
+ : K extends 'copySet'
89
+ ? CopySet<M>
90
+ : K extends 'copyBag'
91
+ ? CopyBag<M>
92
+ : never;
93
+ export type AssetKindForValue<V extends AmountValue> = V extends NatValue
94
+ ? 'nat'
95
+ : V extends SetValue
96
+ ? 'set'
97
+ : V extends CopySet
98
+ ? 'copySet'
99
+ : V extends import('@endo/patterns').CopyBag
100
+ ? 'copyBag'
101
+ : never;
102
+ /** @deprecated */
103
+ export type DisplayInfo<K extends AssetKind = AssetKind> = {
104
+ /**
105
+ * Tells the display software how many
106
+ * decimal places to move the decimal over to the left, or in other words,
107
+ * which position corresponds to whole numbers. We require fungible digital
108
+ * assets to be represented in integers, in the smallest unit (i.e. USD might
109
+ * be represented in mill, a thousandth of a dollar. In that case,
110
+ * `decimalPlaces` would be 3.) This property is optional, and for
111
+ * non-fungible digital assets, should not be specified. The decimalPlaces
112
+ * property should be used for _display purposes only_. Any other use is an
113
+ * anti-pattern.
114
+ */
115
+ decimalPlaces?: number | undefined;
116
+ /**
117
+ * - the kind of asset, either AssetKind.NAT (fungible)
118
+ * or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
119
+ */
120
+ assetKind: K;
121
+ };
122
+ export type BrandMethods<K extends AssetKind> = {
123
+ /**
124
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
125
+ */
126
+ isMyIssuer: (allegedIssuer: ERef<Issuer<K>>) => Promise<boolean>;
127
+ getAllegedName: () => string;
128
+ /** @deprecated look up in boardAux */
129
+ getDisplayInfo: () => DisplayInfo<K>;
130
+ getAmountShape: () => Pattern;
131
+ };
132
+ /**
133
+ * The brand identifies the
134
+ * kind of issuer, and has a function to get the alleged name for the kind of
135
+ * asset described. The alleged name (such as 'BTC' or 'moola') is provided by
136
+ * the maker of the issuer and should not be trusted as accurate.
137
+ *
138
+ * Every amount created by a particular issuer will share the same brand, but
139
+ * recipients cannot rely on the brand to verify that a purported amount
140
+ * represents the issuer they intended, since the same brand can be reused by
141
+ * a misbehaving issuer.
142
+ */
143
+ export type Brand<K extends AssetKind = AssetKind> = RemotableObject &
144
+ BrandMethods<K>;
145
+ /**
146
+ * Return true if the payment continues to exist.
147
+ *
148
+ * If the payment is a promise, the operation will proceed upon fulfillment.
149
+ */
150
+ export type IssuerIsLive = (payment: ERef<Payment>) => Promise<boolean>;
151
+ /**
152
+ * Get the amount of digital assets in the payment.
153
+ * Because the payment is not trusted, we cannot call a method on it directly,
154
+ * and must use the issuer instead.
155
+ *
156
+ * If the payment is a promise, the operation will proceed upon fulfillment.
157
+ */
158
+ export type IssuerGetAmountOf<K extends AssetKind, M extends Key = Key> = (
159
+ payment: ERef<Payment<K, M>>,
160
+ ) => Promise<Amount<K, M>>;
161
+ /**
162
+ * Burn all of the digital assets in the payment.
163
+ * `optAmountShape` is optional. If the `optAmountShape` pattern is present,
164
+ * the amount of the digital assets in the payment must match
165
+ * `optAmountShape`, to prevent sending the wrong payment and other
166
+ * confusion.
167
+ *
168
+ * If the payment is a promise, the operation will proceed upon fulfillment.
169
+ *
170
+ * As always with optional `Pattern` arguments, keep in mind that technically
171
+ * the value `undefined` itself is a valid `Key` and therefore a valid
172
+ * `Pattern`. But in optional pattern position, a top level `undefined` will
173
+ * be interpreted as absence. If you want to express a `Pattern` that will
174
+ * match only `undefined`, use `M.undefined()` instead.
175
+ */
176
+ export type IssuerBurn = (
177
+ payment: ERef<Payment>,
178
+ optAmountShape?: Pattern,
179
+ ) => Promise<Amount>;
180
+ /**
181
+ * Work around JSDoc union handling
182
+ */
183
+ export type IssuerMethods<K extends AssetKind, M extends Key> = {
184
+ /**
185
+ * Get the Brand for this Issuer. The Brand
186
+ * indicates the type of digital asset and is shared by the mint, the issuer,
187
+ * and any purses and payments of this particular kind. The brand is not
188
+ * closely held, so this function should not be trusted to identify an issuer
189
+ * alone. Fake digital assets and amount can use another issuer's brand.
190
+ */
191
+ getBrand: () => Brand<K>;
192
+ /**
193
+ * Get the allegedName for this
194
+ * mint/issuer
195
+ */
196
+ getAllegedName: () => string;
197
+ /**
198
+ * Get the kind of MathHelpers used by this
199
+ * Issuer.
200
+ */
201
+ getAssetKind: () => K;
202
+ /** @deprecated look up in boardAux */
203
+ getDisplayInfo: () => DisplayInfo<K>;
204
+ /**
205
+ * Make an empty purse of this
206
+ * brand.
207
+ */
208
+ makeEmptyPurse: () => Purse<K, M>;
209
+ isLive: IssuerIsLive;
210
+ getAmountOf: IssuerGetAmountOf<K, M>;
211
+ burn: IssuerBurn;
212
+ };
213
+ /**
214
+ * The issuer cannot
215
+ * mint a new amount, but it can create empty purses and payments. The issuer
216
+ * can also transform payments (splitting payments, combining payments,
217
+ * burning payments, and claiming payments exclusively). The issuer should be
218
+ * gotten from a trusted source and then relied upon as the decider of whether
219
+ * an untrusted payment is valid.
220
+ */
221
+ export type Issuer<
222
+ K extends AssetKind = AssetKind,
223
+ M extends Key = Key,
224
+ > = RemotableObject & IssuerMethods<K, M>;
225
+ export type PaymentLedger<K extends AssetKind = AssetKind> = {
226
+ mint: Mint<K>;
227
+ /**
228
+ * Externally useful only if this issuer
229
+ * uses recovery sets. Can be used to get the recovery set associated with
230
+ * minted payments that are still live.
231
+ */
232
+ mintRecoveryPurse: Purse<K>;
233
+ issuer: Issuer<K>;
234
+ brand: Brand<K>;
235
+ };
236
+ export type IssuerKit<K extends AssetKind = AssetKind, M extends Key = Key> = {
237
+ mint: Mint<K, M>;
238
+ /**
239
+ * Externally useful only if this
240
+ * issuer uses recovery sets. Can be used to get the recovery set associated
241
+ * with minted payments that are still live.
242
+ */
243
+ mintRecoveryPurse: Purse<K, M>;
244
+ issuer: Issuer<K, M>;
245
+ brand: Brand<K>;
246
+ displayInfo: DisplayInfo;
247
+ };
248
+ export type AdditionalDisplayInfo = {
249
+ /**
250
+ * Tells the display software how many
251
+ * decimal places to move the decimal over to the left, or in other words,
252
+ * which position corresponds to whole numbers. We require fungible digital
253
+ * assets to be represented in integers, in the smallest unit (i.e. USD might
254
+ * be represented in mill, a thousandth of a dollar. In that case,
255
+ * `decimalPlaces` would be 3.) This property is optional, and for
256
+ * non-fungible digital assets, should not be specified. The decimalPlaces
257
+ * property should be used for _display purposes only_. Any other use is an
258
+ * anti-pattern.
259
+ */
260
+ decimalPlaces?: number | undefined;
261
+ assetKind?: AssetKind | undefined;
262
+ };
263
+ /**
264
+ * Holding a Mint carries the right to issue new digital
265
+ * assets. These assets all have the same kind, which is called a Brand.
266
+ */
267
+ export type Mint<K extends AssetKind = AssetKind, M extends Key = Key> = {
268
+ /**
269
+ * Gets the Issuer for this mint.
270
+ */
271
+ getIssuer: () => Issuer<K, M>;
272
+ /**
273
+ * Creates a new
274
+ * Payment containing newly minted amount.
275
+ */
276
+ mintPayment: (newAmount: Amount<K>) => Payment<K, M>;
277
+ };
278
+ /**
279
+ * Issuers first became durable with mandatory recovery sets. Later they were
280
+ * made optional, but there is no support for converting from one state to the
281
+ * other. Thus, absence of a `RecoverySetsOption` state is equivalent to
282
+ * `'hasRecoverySets'`. In the absence of a `recoverySetsOption` parameter,
283
+ * upgradeIssuerKit defaults to the predecessor's `RecoverySetsOption` state, or
284
+ * `'hasRecoverySets'` if none.
285
+ *
286
+ * At this time, issuers started in one of the states (`'noRecoverySets'`, or
287
+ * `'hasRecoverySets'`) cannot be converted to the other on upgrade. If this
288
+ * transition is needed, it can likely be supported in a future upgrade. File an
289
+ * issue on github and explain what you need and why.
290
+ */
291
+ export type RecoverySetsOption = 'hasRecoverySets' | 'noRecoverySets';
292
+ export type DepositFacetReceive = (
293
+ payment: Payment,
294
+ optAmountShape?: Pattern,
295
+ ) => Amount;
296
+ export type DepositFacet = {
297
+ /**
298
+ * Deposit all the contents of payment
299
+ * into the purse that made this facet, returning the amount. If the optional
300
+ * argument `optAmount` does not equal the amount of digital assets in the
301
+ * payment, throw an error.
302
+ *
303
+ * If payment is a promise, throw an error.
304
+ */
305
+ receive: DepositFacetReceive;
306
+ };
307
+ /**
308
+ * Purses hold amount of
309
+ * digital assets of the same brand, but unlike Payments, they are not meant
310
+ * to be sent to others. To transfer digital assets, a Payment should be
311
+ * withdrawn from a Purse. The amount of digital assets in a purse can change
312
+ * through the action of deposit() and withdraw().
313
+ */
314
+ export type Purse<
315
+ K extends AssetKind = AssetKind,
316
+ M extends Key = Key,
317
+ > = RemotableObject & PurseMethods<K, M>;
318
+ /**
319
+ * The primary use for Purses and Payments is for
320
+ * currency-like and goods-like digital assets, but they can also be used to
321
+ * represent other kinds of rights, such as the right to participate in a
322
+ * particular contract.
323
+ */
324
+ export type PurseMethods<
325
+ K extends AssetKind = AssetKind,
326
+ M extends Key = Key,
327
+ > = {
328
+ /**
329
+ * Get the alleged Brand for this
330
+ * Purse
331
+ */
332
+ getAllegedBrand: () => Brand<K>;
333
+ /**
334
+ * Get the amount contained in
335
+ * this purse.
336
+ */
337
+ getCurrentAmount: () => Amount<K, M>;
338
+ /**
339
+ * Get a
340
+ * lossy notifier for changes to this purse's balance.
341
+ */
342
+ getCurrentAmountNotifier: () => LatestTopic<Amount<K, M>>;
343
+ /**
344
+ * Deposit all the contents of payment into this purse, returning the amount. If
345
+ * the optional argument `optAmount` does not equal the amount of digital
346
+ * assets in the payment, throw an error.
347
+ *
348
+ * If payment is a promise, throw an error.
349
+ */
350
+ deposit: <P extends Payment<K, M>>(
351
+ payment: P,
352
+ optAmountShape?: Pattern,
353
+ ) => P extends Payment<K, M> ? Amount<K, M> : never;
354
+ /**
355
+ * Return an object whose
356
+ * `receive` method deposits to the current Purse.
357
+ */
358
+ getDepositFacet: () => DepositFacet;
359
+ /**
360
+ * Withdraw amount
361
+ * from this purse into a new Payment.
362
+ */
363
+ withdraw: (amount: Amount<K, M>) => Payment<K, M>;
364
+ /**
365
+ * The set of payments
366
+ * withdrawn from this purse that are still live. These are the payments that
367
+ * can still be recovered in emergencies by, for example, depositing into this
368
+ * purse. Such a deposit action is like canceling an outstanding check because
369
+ * you're tired of waiting for it. Once your cancellation is acknowledged, you
370
+ * can spend the assets at stake on other things. Afterwards, if the recipient
371
+ * of the original check finally gets around to depositing it, their deposit
372
+ * fails.
373
+ *
374
+ * Returns an empty set if this issuer does not support recovery sets.
375
+ */
376
+ getRecoverySet: () => CopySet<Payment<K, M>>;
377
+ /**
378
+ * For use in emergencies, such as
379
+ * coming back from a traumatic crash and upgrade. This deposits all the
380
+ * payments in this purse's recovery set into the purse itself, returning the
381
+ * total amount of assets recovered.
382
+ *
383
+ * Returns an empty amount if this issuer does not support recovery sets.
384
+ */
385
+ recoverAll: () => Amount<K, M>;
386
+ };
387
+ /**
388
+ * Payments hold amount
389
+ * of digital assets of the same brand in transit. Payments can be deposited
390
+ * in purses, split into multiple payments, combined, and claimed (getting an
391
+ * exclusive payment). Payments are linear, meaning that either a payment has
392
+ * the same amount of digital assets it started with, or it is used up
393
+ * entirely. It is impossible to partially use a payment.
394
+ *
395
+ * Payments are often received from other actors and therefore should not be
396
+ * trusted themselves. To get the amount of digital assets in a payment, use
397
+ * the trusted issuer: issuer.getAmountOf(payment),
398
+ *
399
+ * Payments can be converted to Purses by getting a trusted issuer and calling
400
+ * `issuer.makeEmptyPurse()` to create a purse, then
401
+ * `purse.deposit(payment)`.
402
+ */
403
+ export type Payment<
404
+ K extends AssetKind = AssetKind,
405
+ M extends Key = Key,
406
+ > = RemotableObject & PaymentMethods<K>;
407
+ export type PaymentMethods<K extends AssetKind = AssetKind> = {
408
+ /**
409
+ * Get the allegedBrand, indicating
410
+ * the type of digital asset this payment purports to be, and which issuer to
411
+ * use. Because payments are not trusted, any method calls on payments should
412
+ * be treated with suspicion and verified elsewhere.
413
+ */
414
+ getAllegedBrand: () => Brand<K>;
415
+ };
416
+ /**
417
+ * All of the difference in how digital asset
418
+ * amount are manipulated can be reduced to the behavior of the math on
419
+ * values. We extract this custom logic into mathHelpers. MathHelpers are
420
+ * about value arithmetic, whereas AmountMath is about amounts, which are the
421
+ * values labeled with a brand. AmountMath use mathHelpers to do their value
422
+ * arithmetic, and then brand the results, making a new amount.
423
+ *
424
+ * The MathHelpers are designed to be called only from AmountMath, and so all
425
+ * methods but coerce can assume their inputs are valid. They only need to do
426
+ * output validation, and only when there is a possibility of invalid output.
427
+ */
428
+ export type MathHelpers<V extends AmountValue> = {
429
+ /**
430
+ * Check the kind of this value and
431
+ * throw if it is not the expected kind.
432
+ */
433
+ doCoerce: (allegedValue: V) => V;
434
+ /**
435
+ * Get the representation for the identity
436
+ * element (often 0 or an empty array)
437
+ */
438
+ doMakeEmpty: () => V;
439
+ /**
440
+ * Is the value the identity
441
+ * element?
442
+ */
443
+ doIsEmpty: (value: V) => boolean;
444
+ /**
445
+ * Is the left greater than
446
+ * or equal to the right?
447
+ */
448
+ doIsGTE: (left: V, right: V) => boolean;
449
+ /**
450
+ * Does left equal right?
451
+ */
452
+ doIsEqual: (left: V, right: V) => boolean;
453
+ /**
454
+ * Return the left combined with the
455
+ * right.
456
+ */
457
+ doAdd: (left: V, right: V) => V;
458
+ /**
459
+ * Return what remains after
460
+ * removing the right from the left. If something in the right was not in the
461
+ * left, we throw an error.
462
+ */
463
+ doSubtract: (left: V, right: V) => V;
464
+ };
465
+ export type NatValue = bigint;
466
+ export type SetValue<K extends Key = Key> = K[];
package/src/types.js DELETED
@@ -1,420 +0,0 @@
1
- // @jessie-check
2
-
3
- // Ensure this is a module.
4
- export {};
5
-
6
- /// <reference types="ses" />
7
- /**
8
- * @import {Passable, RemotableObject} from '@endo/pass-style';
9
- * @import {CopyBag, CopySet, Key} from '@endo/patterns';
10
- * @import {LatestTopic, NotifierRecord} from '@agoric/notifier';
11
- */
12
-
13
- /** @typedef {{ brand: Brand<'nat'>; value: bigint }} NatAmount */
14
- /**
15
- * @template {Key} K
16
- * @typedef {{ brand: Brand<'set'>; value: K[] }} SetAmount
17
- */
18
- /**
19
- * @template {Key} K
20
- * @typedef {{ brand: Brand<'copySet'>; value: CopySet<K> }} CopySetAmount
21
- */
22
- /**
23
- * @template {Key} K
24
- * @typedef {{ brand: Brand<'copyBag'>; value: CopyBag<K> }} CopyBagAmount
25
- */
26
- /** @typedef {{ brand: Brand<any>; value: any }} AnyAmount */
27
-
28
- /**
29
- * @template {AssetKind} [K=AssetKind]
30
- * @template {Key} [M=Key]
31
- * @typedef {K extends 'nat'
32
- * ? NatAmount
33
- * : K extends 'set'
34
- * ? SetAmount<M>
35
- * : K extends 'copySet'
36
- * ? CopySetAmount<M>
37
- * : K extends 'copyBag'
38
- * ? CopyBagAmount<M>
39
- * : AnyAmount} Amount
40
- * Amounts are descriptions of digital assets, answering the questions "how
41
- * much" and "of what kind". Amounts are values labeled with a brand.
42
- * AmountMath executes the logic of how amounts are changed when digital
43
- * assets are merged, separated, or otherwise manipulated. For example, a
44
- * deposit of 2 bucks into a purse that already has 3 bucks gives a new purse
45
- * balance of 5 bucks. An empty purse has 0 bucks. AmountMath relies heavily
46
- * on polymorphic MathHelpers, which manipulate the unbranded portion.
47
- */
48
-
49
- /**
50
- * @typedef {NatValue | SetValue | CopySet | import('@endo/patterns').CopyBag} AmountValue
51
- * An `AmountValue` describes a set or quantity of assets that can be owned or
52
- * shared.
53
- *
54
- * A fungible `AmountValue` uses a non-negative bigint to represent a quantity
55
- * of that many assets.
56
- *
57
- * A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
58
- * a set of whatever asset each key represents. A `Key` is a passable value
59
- * that can be used as an element in a set (SetStore or CopySet) or as the key
60
- * in a map (MapStore or CopyMap).
61
- *
62
- * `SetValue` is for the deprecated set representation, using an array directly
63
- * to represent the array of its elements. `CopySet` is the proper
64
- * representation using a CopySet.
65
- *
66
- * A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
67
- * "Bag" is synonymous with MultiSet, where an element of a bag can be present
68
- * once or more times, i.e., some positive bigint number of times,
69
- * representing that quantity of the asset represented by that key.
70
- */
71
-
72
- /**
73
- * @typedef {'nat' | 'set' | 'copySet' | 'copyBag'} AssetKind See doc-comment
74
- * for `AmountValue`.
75
- */
76
-
77
- /**
78
- * @template {AssetKind} K
79
- * @template {Key} [M=Key] member kind, for Amounts that have member values
80
- * @typedef {K extends 'nat'
81
- * ? NatValue
82
- * : K extends 'set'
83
- * ? SetValue<M>
84
- * : K extends 'copySet'
85
- * ? CopySet<M>
86
- * : K extends 'copyBag'
87
- * ? CopyBag<M>
88
- * : never} AssetValueForKind
89
- */
90
-
91
- /**
92
- * @template {AmountValue} V
93
- * @typedef {V extends NatValue
94
- * ? 'nat'
95
- * : V extends SetValue
96
- * ? 'set'
97
- * : V extends CopySet
98
- * ? 'copySet'
99
- * : V extends import('@endo/patterns').CopyBag
100
- * ? 'copyBag'
101
- * : never} AssetKindForValue
102
- */
103
-
104
- /**
105
- * @template {AssetKind} [K=AssetKind]
106
- * @typedef {object} DisplayInfo
107
- * @property {number} [decimalPlaces] Tells the display software how many
108
- * decimal places to move the decimal over to the left, or in other words,
109
- * which position corresponds to whole numbers. We require fungible digital
110
- * assets to be represented in integers, in the smallest unit (i.e. USD might
111
- * be represented in mill, a thousandth of a dollar. In that case,
112
- * `decimalPlaces` would be 3.) This property is optional, and for
113
- * non-fungible digital assets, should not be specified. The decimalPlaces
114
- * property should be used for _display purposes only_. Any other use is an
115
- * anti-pattern.
116
- * @property {K} assetKind - the kind of asset, either AssetKind.NAT (fungible)
117
- * or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
118
- */
119
-
120
- // XXX hack around JSDoc union handling
121
- /**
122
- * @template {AssetKind} K
123
- * @typedef {object} BrandMethods
124
- * @property {(allegedIssuer: ERef<Issuer<K>>) => Promise<boolean>} isMyIssuer
125
- * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
126
- * @property {() => string} getAllegedName
127
- * @property {() => DisplayInfo<K>} getDisplayInfo Give information to UI on how
128
- * to display the amount.
129
- * @property {() => Pattern} getAmountShape
130
- */
131
-
132
- /**
133
- * @template {AssetKind} [K=AssetKind]
134
- * @typedef {RemotableObject & BrandMethods<K>} Brand The brand identifies the
135
- * kind of issuer, and has a function to get the alleged name for the kind of
136
- * asset described. The alleged name (such as 'BTC' or 'moola') is provided by
137
- * the maker of the issuer and should not be trusted as accurate.
138
- *
139
- * Every amount created by a particular issuer will share the same brand, but
140
- * recipients cannot rely on the brand to verify that a purported amount
141
- * represents the issuer they intended, since the same brand can be reused by
142
- * a misbehaving issuer.
143
- */
144
-
145
- // /////////////////////////// Issuer //////////////////////////////////////////
146
-
147
- /**
148
- * @callback IssuerIsLive Return true if the payment continues to exist.
149
- *
150
- * If the payment is a promise, the operation will proceed upon fulfillment.
151
- * @param {ERef<Payment>} payment
152
- * @returns {Promise<boolean>}
153
- */
154
- /**
155
- * @template {AssetKind} K
156
- * @template {Key} [M=Key] member kind, for Amounts that have member values
157
- * @callback IssuerGetAmountOf Get the amount of digital assets in the payment.
158
- * Because the payment is not trusted, we cannot call a method on it directly,
159
- * and must use the issuer instead.
160
- *
161
- * If the payment is a promise, the operation will proceed upon fulfillment.
162
- * @param {ERef<Payment<K, M>>} payment
163
- * @returns {Promise<Amount<K, M>>}
164
- */
165
-
166
- /**
167
- * @callback IssuerBurn Burn all of the digital assets in the payment.
168
- * `optAmountShape` is optional. If the `optAmountShape` pattern is present,
169
- * the amount of the digital assets in the payment must match
170
- * `optAmountShape`, to prevent sending the wrong payment and other
171
- * confusion.
172
- *
173
- * If the payment is a promise, the operation will proceed upon fulfillment.
174
- *
175
- * As always with optional `Pattern` arguments, keep in mind that technically
176
- * the value `undefined` itself is a valid `Key` and therefore a valid
177
- * `Pattern`. But in optional pattern position, a top level `undefined` will
178
- * be interpreted as absence. If you want to express a `Pattern` that will
179
- * match only `undefined`, use `M.undefined()` instead.
180
- * @param {ERef<Payment>} payment
181
- * @param {Pattern} [optAmountShape]
182
- * @returns {Promise<Amount>}
183
- */
184
-
185
- /**
186
- * @template {AssetKind} K
187
- * @template {Key} M
188
- * @typedef {object} IssuerMethods Work around JSDoc union handling
189
- * @property {() => Brand<K>} getBrand Get the Brand for this Issuer. The Brand
190
- * indicates the type of digital asset and is shared by the mint, the issuer,
191
- * and any purses and payments of this particular kind. The brand is not
192
- * closely held, so this function should not be trusted to identify an issuer
193
- * alone. Fake digital assets and amount can use another issuer's brand.
194
- * @property {() => string} getAllegedName Get the allegedName for this
195
- * mint/issuer
196
- * @property {() => K} getAssetKind Get the kind of MathHelpers used by this
197
- * Issuer.
198
- * @property {() => DisplayInfo<K>} getDisplayInfo Give information to UI on how
199
- * to display amounts for this issuer.
200
- * @property {() => Purse<K, M>} makeEmptyPurse Make an empty purse of this
201
- * brand.
202
- * @property {IssuerIsLive} isLive
203
- * @property {IssuerGetAmountOf<K, M>} getAmountOf
204
- * @property {IssuerBurn} burn
205
- */
206
-
207
- /**
208
- * @template {AssetKind} [K=AssetKind]
209
- * @template {Key} [M=Key] member kind, for Amounts that have member values
210
- * @typedef {RemotableObject & IssuerMethods<K, M>} Issuer The issuer cannot
211
- * mint a new amount, but it can create empty purses and payments. The issuer
212
- * can also transform payments (splitting payments, combining payments,
213
- * burning payments, and claiming payments exclusively). The issuer should be
214
- * gotten from a trusted source and then relied upon as the decider of whether
215
- * an untrusted payment is valid.
216
- */
217
-
218
- /**
219
- * @template {AssetKind} [K=AssetKind]
220
- * @typedef {object} PaymentLedger
221
- * @property {Mint<K>} mint
222
- * @property {Purse<K>} mintRecoveryPurse Externally useful only if this issuer
223
- * uses recovery sets. Can be used to get the recovery set associated with
224
- * minted payments that are still live.
225
- * @property {Issuer<K>} issuer
226
- * @property {Brand<K>} brand
227
- */
228
-
229
- /**
230
- * @template {AssetKind} [K=AssetKind]
231
- * @template {Key} [M=Key] member kind, for Amounts that have member values
232
- * @typedef {object} IssuerKit
233
- * @property {Mint<K, M>} mint
234
- * @property {Purse<K, M>} mintRecoveryPurse Externally useful only if this
235
- * issuer uses recovery sets. Can be used to get the recovery set associated
236
- * with minted payments that are still live.
237
- * @property {Issuer<K, M>} issuer
238
- * @property {Brand<K>} brand
239
- * @property {DisplayInfo} displayInfo
240
- */
241
-
242
- /**
243
- * @typedef {object} AdditionalDisplayInfo
244
- * @property {number} [decimalPlaces] Tells the display software how many
245
- * decimal places to move the decimal over to the left, or in other words,
246
- * which position corresponds to whole numbers. We require fungible digital
247
- * assets to be represented in integers, in the smallest unit (i.e. USD might
248
- * be represented in mill, a thousandth of a dollar. In that case,
249
- * `decimalPlaces` would be 3.) This property is optional, and for
250
- * non-fungible digital assets, should not be specified. The decimalPlaces
251
- * property should be used for _display purposes only_. Any other use is an
252
- * anti-pattern.
253
- * @property {AssetKind} [assetKind]
254
- */
255
-
256
- /**
257
- * @template {AssetKind} [K=AssetKind]
258
- * @template {Key} [M=Key] member kind, for Amounts that have member values
259
- * @typedef {object} Mint Holding a Mint carries the right to issue new digital
260
- * assets. These assets all have the same kind, which is called a Brand.
261
- * @property {() => Issuer<K, M>} getIssuer Gets the Issuer for this mint.
262
- * @property {(newAmount: Amount<K>) => Payment<K, M>} mintPayment Creates a new
263
- * Payment containing newly minted amount.
264
- */
265
-
266
- // /////////////////////////// Purse / Payment /////////////////////////////////
267
-
268
- /**
269
- * Issuers first became durable with mandatory recovery sets. Later they were
270
- * made optional, but there is no support for converting from one state to the
271
- * other. Thus, absence of a `RecoverySetsOption` state is equivalent to
272
- * `'hasRecoverySets'`. In the absence of a `recoverySetsOption` parameter,
273
- * upgradeIssuerKit defaults to the predecessor's `RecoverySetsOption` state, or
274
- * `'hasRecoverySets'` if none.
275
- *
276
- * At this time, issuers started in one of the states (`'noRecoverySets'`, or
277
- * `'hasRecoverySets'`) cannot be converted to the other on upgrade. If this
278
- * transition is needed, it can likely be supported in a future upgrade. File an
279
- * issue on github and explain what you need and why.
280
- *
281
- * @typedef {'hasRecoverySets' | 'noRecoverySets'} RecoverySetsOption
282
- */
283
-
284
- // /////////////////////////// Purse / Payment /////////////////////////////////
285
-
286
- /**
287
- * @callback DepositFacetReceive
288
- * @param {Payment} payment
289
- * @param {Pattern} [optAmountShape]
290
- * @returns {Amount}
291
- */
292
-
293
- /**
294
- * @typedef {object} DepositFacet
295
- * @property {DepositFacetReceive} receive Deposit all the contents of payment
296
- * into the purse that made this facet, returning the amount. If the optional
297
- * argument `optAmount` does not equal the amount of digital assets in the
298
- * payment, throw an error.
299
- *
300
- * If payment is a promise, throw an error.
301
- */
302
-
303
- /**
304
- * @template {AssetKind} [K=AssetKind]
305
- * @template {Key} [M=Key] member kind, for Amounts that have member values
306
- * @typedef {RemotableObject & PurseMethods<K, M>} Purse Purses hold amount of
307
- * digital assets of the same brand, but unlike Payments, they are not meant
308
- * to be sent to others. To transfer digital assets, a Payment should be
309
- * withdrawn from a Purse. The amount of digital assets in a purse can change
310
- * through the action of deposit() and withdraw().
311
- */
312
-
313
- /**
314
- * @template {AssetKind} [K=AssetKind]
315
- * @template {Key} [M=Key] member kind, for Amounts that have member values
316
- * @typedef {object} PurseMethods The primary use for Purses and Payments is for
317
- * currency-like and goods-like digital assets, but they can also be used to
318
- * represent other kinds of rights, such as the right to participate in a
319
- * particular contract.
320
- * @property {() => Brand<K>} getAllegedBrand Get the alleged Brand for this
321
- * Purse
322
- * @property {() => Amount<K, M>} getCurrentAmount Get the amount contained in
323
- * this purse.
324
- * @property {() => LatestTopic<Amount<K, M>>} getCurrentAmountNotifier Get a
325
- * lossy notifier for changes to this purse's balance.
326
- * @property {<P extends Payment<K, M>>(
327
- * payment: P,
328
- * optAmountShape?: Pattern,
329
- * ) => P extends Payment<K, M> ? Amount<K, M> : never} deposit
330
- * Deposit all the contents of payment into this purse, returning the amount. If
331
- * the optional argument `optAmount` does not equal the amount of digital
332
- * assets in the payment, throw an error.
333
- *
334
- * If payment is a promise, throw an error.
335
- * @property {() => DepositFacet} getDepositFacet Return an object whose
336
- * `receive` method deposits to the current Purse.
337
- * @property {(amount: Amount<K, M>) => Payment<K, M>} withdraw Withdraw amount
338
- * from this purse into a new Payment.
339
- * @property {() => CopySet<Payment<K, M>>} getRecoverySet The set of payments
340
- * withdrawn from this purse that are still live. These are the payments that
341
- * can still be recovered in emergencies by, for example, depositing into this
342
- * purse. Such a deposit action is like canceling an outstanding check because
343
- * you're tired of waiting for it. Once your cancellation is acknowledged, you
344
- * can spend the assets at stake on other things. Afterwards, if the recipient
345
- * of the original check finally gets around to depositing it, their deposit
346
- * fails.
347
- *
348
- * Returns an empty set if this issuer does not support recovery sets.
349
- * @property {() => Amount<K, M>} recoverAll For use in emergencies, such as
350
- * coming back from a traumatic crash and upgrade. This deposits all the
351
- * payments in this purse's recovery set into the purse itself, returning the
352
- * total amount of assets recovered.
353
- *
354
- * Returns an empty amount if this issuer does not support recovery sets.
355
- */
356
-
357
- /**
358
- * @template {AssetKind} [K=AssetKind]
359
- * @template {Key} [M=Key] member kind, for Amounts that have member values
360
- * @typedef {RemotableObject & PaymentMethods<K>} Payment Payments hold amount
361
- * of digital assets of the same brand in transit. Payments can be deposited
362
- * in purses, split into multiple payments, combined, and claimed (getting an
363
- * exclusive payment). Payments are linear, meaning that either a payment has
364
- * the same amount of digital assets it started with, or it is used up
365
- * entirely. It is impossible to partially use a payment.
366
- *
367
- * Payments are often received from other actors and therefore should not be
368
- * trusted themselves. To get the amount of digital assets in a payment, use
369
- * the trusted issuer: issuer.getAmountOf(payment),
370
- *
371
- * Payments can be converted to Purses by getting a trusted issuer and calling
372
- * `issuer.makeEmptyPurse()` to create a purse, then
373
- * `purse.deposit(payment)`.
374
- */
375
-
376
- /**
377
- * @template {AssetKind} [K=AssetKind]
378
- * @typedef {object} PaymentMethods
379
- * @property {() => Brand<K>} getAllegedBrand Get the allegedBrand, indicating
380
- * the type of digital asset this payment purports to be, and which issuer to
381
- * use. Because payments are not trusted, any method calls on payments should
382
- * be treated with suspicion and verified elsewhere.
383
- */
384
-
385
- // /////////////////////////// MathHelpers /////////////////////////////////////
386
-
387
- /**
388
- * @template {AmountValue} V
389
- * @typedef {object} MathHelpers All of the difference in how digital asset
390
- * amount are manipulated can be reduced to the behavior of the math on
391
- * values. We extract this custom logic into mathHelpers. MathHelpers are
392
- * about value arithmetic, whereas AmountMath is about amounts, which are the
393
- * values labeled with a brand. AmountMath use mathHelpers to do their value
394
- * arithmetic, and then brand the results, making a new amount.
395
- *
396
- * The MathHelpers are designed to be called only from AmountMath, and so all
397
- * methods but coerce can assume their inputs are valid. They only need to do
398
- * output validation, and only when there is a possibility of invalid output.
399
- * @property {(allegedValue: V) => V} doCoerce Check the kind of this value and
400
- * throw if it is not the expected kind.
401
- * @property {() => V} doMakeEmpty Get the representation for the identity
402
- * element (often 0 or an empty array)
403
- * @property {(value: V) => boolean} doIsEmpty Is the value the identity
404
- * element?
405
- * @property {(left: V, right: V) => boolean} doIsGTE Is the left greater than
406
- * or equal to the right?
407
- * @property {(left: V, right: V) => boolean} doIsEqual Does left equal right?
408
- * @property {(left: V, right: V) => V} doAdd Return the left combined with the
409
- * right.
410
- * @property {(left: V, right: V) => V} doSubtract Return what remains after
411
- * removing the right from the left. If something in the right was not in the
412
- * left, we throw an error.
413
- */
414
-
415
- /** @typedef {bigint} NatValue */
416
-
417
- /**
418
- * @template {Key} [K=Key]
419
- * @typedef {K[]} SetValue
420
- */