@agoric/ertp 0.16.3-dev-2b7c650.0 → 0.16.3-mainnet1B-dev-2d6b13f.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-2b7c650.0+2b7c650",
3
+ "version": "0.16.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
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",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "exit 0",
12
- "prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build tsconfig.build.json",
12
+ "prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build jsconfig.build.json",
13
13
  "postpack": "git clean -f '*.d.ts*' src/types.js",
14
14
  "test": "ava",
15
15
  "test:c8": "c8 $C8_OPTIONS ava",
@@ -19,7 +19,7 @@
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"
22
+ "lint:types": "tsc -p jsconfig.json"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -39,22 +39,21 @@
39
39
  },
40
40
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
41
41
  "dependencies": {
42
- "@agoric/assert": "0.6.1-dev-2b7c650.0+2b7c650",
43
- "@agoric/notifier": "0.6.3-dev-2b7c650.0+2b7c650",
44
- "@agoric/store": "0.9.3-dev-2b7c650.0+2b7c650",
45
- "@agoric/vat-data": "0.5.3-dev-2b7c650.0+2b7c650",
46
- "@endo/eventual-send": "^0.17.5",
47
- "@endo/far": "^0.2.21",
48
- "@endo/marshal": "^0.8.8",
49
- "@endo/nat": "^4.1.30",
50
- "@endo/patterns": "^0.2.5",
51
- "@endo/promise-kit": "^0.2.59"
42
+ "@agoric/assert": "0.6.1-mainnet1B-dev-2d6b13f.0+2d6b13f",
43
+ "@agoric/notifier": "0.6.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
44
+ "@agoric/store": "0.9.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
45
+ "@agoric/swingset-vat": "0.32.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
46
+ "@agoric/vat-data": "0.5.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
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"
52
52
  },
53
53
  "devDependencies": {
54
- "@agoric/swingset-vat": "0.32.3-dev-2b7c650.0+2b7c650",
55
- "@endo/bundle-source": "^2.7.0",
56
- "@fast-check/ava": "^1.1.5",
57
- "ava": "^5.3.0",
54
+ "@endo/bundle-source": "2.5.2-upstream-rollup",
55
+ "@fast-check/ava": "^1.1.3",
56
+ "ava": "^5.2.0",
58
57
  "tsd": "^0.28.1"
59
58
  },
60
59
  "files": [
@@ -75,13 +74,10 @@
75
74
  "files": [
76
75
  "test/**/test-*.js"
77
76
  ],
78
- "require": [
79
- "@endo/init/debug.js"
80
- ],
81
77
  "timeout": "5m"
82
78
  },
83
79
  "publishConfig": {
84
80
  "access": "public"
85
81
  },
86
- "gitHead": "2b7c650eaf3b6616cc37afb3ff9ba4d67779835d"
82
+ "gitHead": "2d6b13f85e7f81644f12be02c2ca9344bd056d2f"
87
83
  }
@@ -3,7 +3,7 @@ export namespace AmountMath {
3
3
  export function make<K extends AssetKind>(brand: Brand<K>, allegedValue: AssetValueForKind<K>): Amount<K>;
4
4
  export function coerce<K extends AssetKind>(brand: Brand<K>, allegedAmount: Amount<K>): Amount<K>;
5
5
  export function getValue<K extends AssetKind>(brand: Brand<K>, amount: Amount<K>): AssetValueForKind<K>;
6
- export let makeEmpty: {
6
+ export const makeEmpty: {
7
7
  (brand: Brand<AssetKind>): Amount<"nat">;
8
8
  <K extends AssetKind>(brand: Brand<AssetKind>, assetKind: K): Amount<K>;
9
9
  };
@@ -19,12 +19,7 @@ export namespace AmountMath {
19
19
  /**
20
20
  * Constants for the kinds of assets we support.
21
21
  *
22
- * @type {{
23
- * NAT: 'nat';
24
- * SET: 'set';
25
- * COPY_SET: 'copySet';
26
- * COPY_BAG: 'copyBag';
27
- * }}
22
+ * @type {{ NAT: 'nat', SET: 'set', COPY_SET: 'copySet', COPY_BAG: 'copyBag' }}
28
23
  */
29
24
  export const AssetKind: {
30
25
  NAT: 'nat';
@@ -32,16 +27,20 @@ export const AssetKind: {
32
27
  COPY_SET: 'copySet';
33
28
  COPY_BAG: 'copyBag';
34
29
  };
35
- /** @param {Amount} amount */
30
+ /**
31
+ * @param {Amount} amount
32
+ */
36
33
  export function getAssetKind(amount: Amount): AssetKindForValue<V>;
37
- /** @param {AssetKind} allegedAK */
34
+ /**
35
+ * @param {AssetKind} allegedAK
36
+ */
38
37
  export function assertAssetKind(allegedAK: AssetKind): void;
39
38
  /**
40
- * Returns true if the leftAmount is greater than or equal to the rightAmount.
41
- * The notion of "greater than or equal to" depends on the kind of amount, as
42
- * defined by the MathHelpers. For example, whether rectangle A is greater than
43
- * rectangle B depends on whether rectangle A includes rectangle B as defined by
44
- * the logic in MathHelpers.
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.
45
44
  *
46
45
  * @template {AssetKind} K
47
46
  * @param {Amount<K>} leftAmount
@@ -1 +1 @@
1
- {"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAqHO,uFAEkC;;IAwFjC,0GAKL;IAUO,kGAQP;IASS,wGAAyD;;;;;IAwB9C,uFAOpB;IAQQ,kGAOR;;IAYQ,mIAGR;IAcI,iIAIJ;IAcS,sIAIT;IAUI,8GAMqC;IAUrC,8GAMqC;;AAtW5C;;;;;;;;;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;AA2VH,6BAA6B;AAC7B,qCADY,MAAM,wBAMjB;AA9VD,mCAAmC;AACnC,2CADY,SAAS,QAIpB;AA2ID;;;;;;;;;;;;GAYG;AACH,0HAFa,OAAO,CAKnB"}
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;;;;;;;;;;;;GAYG;AACH,0HAFa,OAAO,CAKnB"}
package/src/amountMath.js CHANGED
@@ -11,12 +11,7 @@ const { quote: q, Fail } = assert;
11
11
  /**
12
12
  * Constants for the kinds of assets we support.
13
13
  *
14
- * @type {{
15
- * NAT: 'nat';
16
- * SET: 'set';
17
- * COPY_SET: 'copySet';
18
- * COPY_BAG: 'copyBag';
19
- * }}
14
+ * @type {{ NAT: 'nat', SET: 'set', COPY_SET: 'copySet', COPY_BAG: 'copyBag' }}
20
15
  */
21
16
  const AssetKind = harden({
22
17
  NAT: 'nat',
@@ -26,7 +21,9 @@ const AssetKind = harden({
26
21
  });
27
22
  const assetKindNames = harden(Object.values(AssetKind).sort());
28
23
 
29
- /** @param {AssetKind} allegedAK */
24
+ /**
25
+ * @param {AssetKind} allegedAK
26
+ */
30
27
  const assertAssetKind = allegedAK => {
31
28
  assetKindNames.includes(allegedAK) ||
32
29
  Fail`The assetKind ${allegedAK} must be one of ${q(assetKindNames)}`;
@@ -34,37 +31,42 @@ const assertAssetKind = allegedAK => {
34
31
  harden(assertAssetKind);
35
32
 
36
33
  /**
37
- * Amounts describe digital assets. From an amount, you can learn the brand of
38
- * digital asset as well as "how much" or "how many". Amounts have two parts: a
39
- * brand (loosely speaking, the type of digital asset) and the value (the answer
40
- * to "how much"). For example, in the phrase "5 bucks", "bucks" takes the role
41
- * of the brand and the value is 5. Amounts can describe fungible and
42
- * non-fungible digital assets. Amounts are pass-by-copy and can be made by and
43
- * sent to anyone.
34
+ * Amounts describe digital assets. From an amount, you can learn the
35
+ * brand of digital asset as well as "how much" or "how many". Amounts
36
+ * have two parts: a brand (loosely speaking, the type of digital
37
+ * asset) and the value (the answer to "how much"). For example, in
38
+ * the phrase "5 bucks", "bucks" takes the role of the brand and the
39
+ * value is 5. Amounts can describe fungible and non-fungible digital
40
+ * assets. Amounts are pass-by-copy and can be made by and sent to
41
+ * anyone.
44
42
  *
45
- * The issuer is the authoritative source of the amount in payments and purses.
46
- * The issuer must be able to do things such as add digital assets to a purse
47
- * and withdraw digital assets from a purse. To do so, it must know how to add
48
- * and subtract digital assets. Rather than hard-coding a particular solution,
49
- * we chose to parameterize the issuer with a collection of polymorphic
50
- * functions, which we call `AmountMath`. These math functions include concepts
43
+ * The issuer is the authoritative source of the amount in payments
44
+ * and purses. The issuer must be able to do things such as add
45
+ * digital assets to a purse and withdraw digital assets from a purse.
46
+ * To do so, it must know how to add and subtract digital assets.
47
+ * Rather than hard-coding a particular solution, we chose to
48
+ * parameterize the issuer with a collection of polymorphic functions,
49
+ * which we call `AmountMath`. These math functions include concepts
51
50
  * like addition, subtraction, and greater than or equal to.
52
51
  *
53
- * We also want to make sure there is no confusion as to what kind of asset we
54
- * are using. Thus, AmountMath includes checks of the `brand`, the unique
55
- * identifier for the type of digital asset. If the wrong brand is used in
56
- * AmountMath, an error is thrown and the operation does not succeed.
52
+ * We also want to make sure there is no confusion as to what kind of
53
+ * asset we are using. Thus, AmountMath includes checks of the
54
+ * `brand`, the unique identifier for the type of digital asset. If
55
+ * the wrong brand is used in AmountMath, an error is thrown and the
56
+ * operation does not succeed.
57
57
  *
58
- * AmountMath uses mathHelpers to do most of the work, but then adds the brand
59
- * to the result. The function `value` gets the value from the amount by
60
- * removing the brand (amount -> value), and the function `make` adds the brand
61
- * to produce an amount (value -> amount). The function `coerce` takes an amount
62
- * and checks it, returning an amount (amount -> amount).
58
+ * AmountMath uses mathHelpers to do most of the work, but then adds
59
+ * the brand to the result. The function `value` gets the value from
60
+ * the amount by removing the brand (amount -> value), and the
61
+ * function `make` adds the brand to produce an amount (value ->
62
+ * amount). The function `coerce` takes an amount and checks it,
63
+ * returning an amount (amount -> amount).
63
64
  *
64
- * Each issuer of digital assets has an associated brand in a one-to-one
65
- * mapping. In untrusted contexts, such as in analyzing payments and amounts, we
66
- * can get the brand and find the issuer which matches the brand. The issuer and
67
- * the brand mutually validate each other.
65
+ * Each issuer of digital assets has an associated brand in a
66
+ * one-to-one mapping. In untrusted contexts, such as in analyzing
67
+ * payments and amounts, we can get the brand and find the issuer
68
+ * which matches the brand. The issuer and the brand mutually validate
69
+ * each other.
68
70
  */
69
71
 
70
72
  const helpers = {
@@ -135,7 +137,7 @@ const optionalBrandCheck = (allegedBrand, brand) => {
135
137
  * @param {Amount<K>} leftAmount
136
138
  * @param {Amount<K>} rightAmount
137
139
  * @param {Brand<K> | undefined} brand
138
- * @returns {MathHelpers<any>}
140
+ * @returns {MathHelpers<*>}
139
141
  */
140
142
  const checkLRAndGetHelpers = (leftAmount, rightAmount, brand = undefined) => {
141
143
  assertRecord(leftAmount, 'leftAmount');
@@ -170,11 +172,11 @@ const coerceLR = (h, leftAmount, rightAmount) => {
170
172
  };
171
173
 
172
174
  /**
173
- * Returns true if the leftAmount is greater than or equal to the rightAmount.
174
- * The notion of "greater than or equal to" depends on the kind of amount, as
175
- * defined by the MathHelpers. For example, whether rectangle A is greater than
176
- * rectangle B depends on whether rectangle A includes rectangle B as defined by
177
- * the logic in MathHelpers.
175
+ * Returns true if the leftAmount is greater than or equal to the
176
+ * rightAmount. The notion of "greater than or equal to" depends
177
+ * on the kind of amount, as defined by the MathHelpers. For example,
178
+ * whether rectangle A is greater than rectangle B depends on whether rectangle
179
+ * A includes rectangle B as defined by the logic in MathHelpers.
178
180
  *
179
181
  * @template {AssetKind} K
180
182
  * @param {Amount<K>} leftAmount
@@ -192,8 +194,9 @@ const isGTE = (leftAmount, rightAmount, brand = undefined) => {
192
194
  *
193
195
  * Amounts are the canonical description of tradable goods. They are manipulated
194
196
  * by issuers and mints, and represent the goods and currency carried by purses
195
- * and payments. They can be used to represent things like currency, stock, and
196
- * the abstract right to participate in a particular exchange.
197
+ * and
198
+ * payments. They can be used to represent things like currency, stock, and the
199
+ * abstract right to participate in a particular exchange.
197
200
  */
198
201
  const AmountMath = {
199
202
  /**
@@ -212,8 +215,8 @@ const AmountMath = {
212
215
  return harden({ brand, value });
213
216
  },
214
217
  /**
215
- * Make sure this amount is valid enough, and return a corresponding valid
216
- * amount if so.
218
+ * Make sure this amount is valid enough, and return a corresponding
219
+ * valid amount if so.
217
220
  *
218
221
  * @template {AssetKind} K
219
222
  * @param {Brand<K>} brand
@@ -239,8 +242,8 @@ const AmountMath = {
239
242
  */
240
243
  getValue: (brand, amount) => AmountMath.coerce(brand, amount).value,
241
244
  /**
242
- * Return the amount representing an empty amount. This is the identity
243
- * element for MathHelpers.add and MatHelpers.subtract.
245
+ * Return the amount representing an empty amount. This is the
246
+ * identity element for MathHelpers.add and MatHelpers.subtract.
244
247
  *
245
248
  * @type {{
246
249
  * (brand: Brand): Amount<'nat'>;
@@ -254,8 +257,8 @@ const AmountMath = {
254
257
  return harden({ brand, value });
255
258
  },
256
259
  /**
257
- * Return the amount representing an empty amount, using another amount as the
258
- * template for the brand and assetKind.
260
+ * Return the amount representing an empty amount, using another
261
+ * amount as the template for the brand and assetKind.
259
262
  *
260
263
  * @template {AssetKind} K
261
264
  * @param {Amount<K>} amount
@@ -286,8 +289,8 @@ const AmountMath = {
286
289
  },
287
290
  isGTE,
288
291
  /**
289
- * Returns true if the leftAmount equals the rightAmount. We assume that if
290
- * isGTE is true in both directions, isEqual is also true
292
+ * Returns true if the leftAmount equals the rightAmount. We assume
293
+ * that if isGTE is true in both directions, isEqual is also true
291
294
  *
292
295
  * @template {AssetKind} K
293
296
  * @param {Amount<K>} leftAmount
@@ -303,8 +306,8 @@ const AmountMath = {
303
306
  * Returns a new amount that is the union of both leftAmount and rightAmount.
304
307
  *
305
308
  * For fungible amount this means adding the values. For other kinds of
306
- * amount, it usually means including all of the elements from both left and
307
- * right.
309
+ * amount, it usually means including all of the elements from both
310
+ * left and right.
308
311
  *
309
312
  * @template {AssetKind} K
310
313
  * @param {Amount<K>} leftAmount
@@ -318,11 +321,12 @@ const AmountMath = {
318
321
  return harden({ brand: leftAmount.brand, value });
319
322
  },
320
323
  /**
321
- * Returns a new amount that is the leftAmount minus the rightAmount (i.e.
322
- * everything in the leftAmount that is not in the rightAmount). If leftAmount
323
- * doesn't include rightAmount (subtraction results in a negative), throw an
324
- * error. Because the left amount must include the right amount, this is NOT
325
- * equivalent to set subtraction.
324
+ * Returns a new amount that is the leftAmount minus the rightAmount
325
+ * (i.e. everything in the leftAmount that is not in the
326
+ * rightAmount). If leftAmount doesn't include rightAmount
327
+ * (subtraction results in a negative), throw an error. Because the
328
+ * left amount must include the right amount, this is NOT equivalent
329
+ * to set subtraction.
326
330
  *
327
331
  * @template {AssetKind} K
328
332
  * @param {Amount<K>} leftAmount
@@ -370,7 +374,9 @@ const AmountMath = {
370
374
  };
371
375
  harden(AmountMath);
372
376
 
373
- /** @param {Amount} amount */
377
+ /**
378
+ * @param {Amount} amount
379
+ */
374
380
  const getAssetKind = amount => {
375
381
  assertRecord(amount, 'amount');
376
382
  const { value } = amount;
@@ -1,6 +1,6 @@
1
- export function prepareIssuerKit<K extends AssetKind>(issuerBaggage: any, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined): IssuerKit<K>;
2
- export function hasIssuer(baggage: any): any;
3
- export function makeDurableIssuerKit<K extends AssetKind>(issuerBaggage: any, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined, { elementShape }?: Partial<{
1
+ export function prepareIssuerKit<K extends AssetKind>(issuerBaggage: MapStore<string, unknown>, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined): IssuerKit<K>;
2
+ export function hasIssuer(baggage: MapStore<string, unknown>): any;
3
+ export function makeDurableIssuerKit<K extends AssetKind>(issuerBaggage: MapStore<string, unknown>, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined, { elementShape }?: Partial<{
4
4
  elementShape: Pattern;
5
5
  }> | undefined): IssuerKit<K>;
6
6
  export function makeIssuerKit<K extends AssetKind = "nat">(name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined, { elementShape }?: Partial<{
@@ -1 +1 @@
1
- {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA2FO,iLAMN;AASM,6CAAsD;AA+BtD,oFAbI,MAAM;kBAhBqB,OAAO;8BAyC5C;AA6BM,iEAbI,MAAM;kBAzDqB,OAAO;8BAqF1C;sBArLW,OAAO,kBAAkB,EAAE,OAAO;;UAKlC,MAAM;eACN,CAAC;iBACD,qBAAqB;kBACrB,OAAO;;kCAwFP,QAAQ;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA2FO,uMAMN;AASM,mEAAsD;AAmCtD,0GAbI,MAAM;kBAnBmB,OAAO;8BA4C1C;AA+BM,iEAbI,MAAM;kBA9DmB,OAAO;8BA0FxC;sBA3LW,OAAO,kBAAkB,EAAE,OAAO;;UAKlC,MAAM;eACN,CAAC;iBACD,qBAAqB;kBACrB,OAAO;;kCAyFR,QAAQ;IAAC,YAAY,EAAE,OAAO,CAAA;CAAC,CAAC"}
package/src/issuerKit.js CHANGED
@@ -25,13 +25,13 @@ import './types-ambient.js';
25
25
  * @template {AssetKind} K
26
26
  * @param {IssuerRecord<K>} issuerRecord
27
27
  * @param {Baggage} issuerBaggage
28
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
29
- * the middle of an atomic action (which btw should never happen), it
30
- * potentially leaves its ledger in a corrupted state. If this function was
31
- * provided, then the failed atomic action will call it, so that some larger
32
- * unit of computation, like the enclosing vat, can be shutdown before
33
- * anything else is corrupted by that corrupted state. See
34
- * https://github.com/Agoric/agoric-sdk/issues/3434
28
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
29
+ * in the middle of an atomic action (which btw should never happen), it
30
+ * potentially leaves its ledger in a corrupted state. If this function was
31
+ * provided, then the failed atomic action will call it, so that some
32
+ * larger unit of computation, like the enclosing vat, can be shutdown
33
+ * before anything else is corrupted by that corrupted state.
34
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
35
35
  * @returns {IssuerKit<K>}
36
36
  */
37
37
  const setupIssuerKit = (
@@ -80,13 +80,13 @@ const INSTANCE_KEY = 'issuer';
80
80
  /**
81
81
  * @template {AssetKind} K
82
82
  * @param {Baggage} issuerBaggage
83
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
84
- * the middle of an atomic action (which btw should never happen), it
85
- * potentially leaves its ledger in a corrupted state. If this function was
86
- * provided, then the failed atomic action will call it, so that some larger
87
- * unit of computation, like the enclosing vat, can be shutdown before
88
- * anything else is corrupted by that corrupted state. See
89
- * https://github.com/Agoric/agoric-sdk/issues/3434
83
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
84
+ * in the middle of an atomic action (which btw should never happen), it
85
+ * potentially leaves its ledger in a corrupted state. If this function was
86
+ * provided, then the failed atomic action will call it, so that some
87
+ * larger unit of computation, like the enclosing vat, can be shutdown
88
+ * before anything else is corrupted by that corrupted state.
89
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
90
90
  * @returns {IssuerKit<K>}
91
91
  */
92
92
  export const prepareIssuerKit = (
@@ -99,39 +99,43 @@ export const prepareIssuerKit = (
99
99
  harden(prepareIssuerKit);
100
100
 
101
101
  /**
102
- * Does baggage already have an issuer from prepareIssuerKit()? That is: does it
103
- * have the relevant keys defined?
102
+ * Does baggage already have an issuer from prepareIssuerKit()?
103
+ * That is: does it have the relevant keys defined?
104
104
  *
105
105
  * @param {Baggage} baggage
106
106
  */
107
107
  export const hasIssuer = baggage => baggage.has(INSTANCE_KEY);
108
108
 
109
- /** @typedef {Partial<{ elementShape: Pattern }>} IssuerOptionsRecord */
109
+ /**
110
+ * @typedef {Partial<{elementShape: Pattern}>} IssuerOptionsRecord
111
+ */
110
112
 
111
113
  /**
112
- * @template {AssetKind} K The name becomes part of the brand in asset
113
- * descriptions. The name is useful for debugging and double-checking
114
- * assumptions, but should not be trusted wrt any external namespace. For
115
- * example, anyone could create a new issuer kit with name 'BTC', but it is
116
- * not bitcoin or even related. It is only the name according to that issuer
117
- * and brand.
114
+ * @template {AssetKind} K
115
+ * The name becomes part of the brand in asset descriptions.
116
+ * The name is useful for debugging and double-checking
117
+ * assumptions, but should not be trusted wrt any external namespace.
118
+ * For example, anyone could create a new issuer kit with name 'BTC', but
119
+ * it is not bitcoin or even related. It is only the name according
120
+ * to that issuer and brand.
118
121
  *
119
- * The assetKind will be used to import a specific mathHelpers from the
120
- * mathHelpers library. For example, natMathHelpers, the default, is used for
121
- * basic fungible tokens.
122
+ * The assetKind will be used to import a specific mathHelpers
123
+ * from the mathHelpers library. For example, natMathHelpers, the
124
+ * default, is used for basic fungible tokens.
125
+ *
126
+ * `displayInfo` gives information to the UI on how to display the amount.
122
127
  *
123
- * `displayInfo` gives information to the UI on how to display the amount.
124
128
  * @param {Baggage} issuerBaggage
125
129
  * @param {string} name
126
- * @param {K} [assetKind]
127
- * @param {AdditionalDisplayInfo} [displayInfo]
128
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
129
- * the middle of an atomic action (which btw should never happen), it
130
- * potentially leaves its ledger in a corrupted state. If this function was
131
- * provided, then the failed atomic action will call it, so that some larger
132
- * unit of computation, like the enclosing vat, can be shutdown before
133
- * anything else is corrupted by that corrupted state. See
134
- * https://github.com/Agoric/agoric-sdk/issues/3434
130
+ * @param {K} [assetKind=AssetKind.NAT]
131
+ * @param {AdditionalDisplayInfo} [displayInfo={}]
132
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
133
+ * in the middle of an atomic action (which btw should never happen), it
134
+ * potentially leaves its ledger in a corrupted state. If this function was
135
+ * provided, then the failed atomic action will call it, so that some
136
+ * larger unit of computation, like the enclosing vat, can be shutdown
137
+ * before anything else is corrupted by that corrupted state.
138
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
135
139
  * @param {IssuerOptionsRecord} [options]
136
140
  * @returns {IssuerKit<K>}
137
141
  */
@@ -151,28 +155,30 @@ export const makeDurableIssuerKit = (
151
155
  harden(makeDurableIssuerKit);
152
156
 
153
157
  /**
154
- * @template {AssetKind} [K='nat'] The name becomes part of the brand in asset
155
- * descriptions. The name is useful for debugging and double-checking
156
- * assumptions, but should not be trusted wrt any external namespace. For
157
- * example, anyone could create a new issuer kit with name 'BTC', but it is
158
- * not bitcoin or even related. It is only the name according to that issuer
159
- * and brand.
158
+ * @template {AssetKind} [K='nat']
159
+ * The name becomes part of the brand in asset descriptions.
160
+ * The name is useful for debugging and double-checking
161
+ * assumptions, but should not be trusted wrt any external namespace.
162
+ * For example, anyone could create a new issuer kit with name 'BTC', but
163
+ * it is not bitcoin or even related. It is only the name according
164
+ * to that issuer and brand.
165
+ *
166
+ * The assetKind will be used to import a specific mathHelpers
167
+ * from the mathHelpers library. For example, natMathHelpers, the
168
+ * default, is used for basic fungible tokens.
160
169
  *
161
- * The assetKind will be used to import a specific mathHelpers from the
162
- * mathHelpers library. For example, natMathHelpers, the default, is used for
163
- * basic fungible tokens.
170
+ * `displayInfo` gives information to the UI on how to display the amount.
164
171
  *
165
- * `displayInfo` gives information to the UI on how to display the amount.
166
172
  * @param {string} name
167
- * @param {K} [assetKind]
168
- * @param {AdditionalDisplayInfo} [displayInfo]
169
- * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in
170
- * the middle of an atomic action (which btw should never happen), it
171
- * potentially leaves its ledger in a corrupted state. If this function was
172
- * provided, then the failed atomic action will call it, so that some larger
173
- * unit of computation, like the enclosing vat, can be shutdown before
174
- * anything else is corrupted by that corrupted state. See
175
- * https://github.com/Agoric/agoric-sdk/issues/3434
173
+ * @param {K} [assetKind='nat']
174
+ * @param {AdditionalDisplayInfo} [displayInfo={}]
175
+ * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
176
+ * in the middle of an atomic action (which btw should never happen), it
177
+ * potentially leaves its ledger in a corrupted state. If this function was
178
+ * provided, then the failed atomic action will call it, so that some
179
+ * larger unit of computation, like the enclosing vat, can be shutdown
180
+ * before anything else is corrupted by that corrupted state.
181
+ * See https://github.com/Agoric/agoric-sdk/issues/3434
176
182
  * @param {IssuerOptionsRecord} [options]
177
183
  * @returns {IssuerKit<K>}
178
184
  */
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AA6BO,0HAHI,OAAO,uBAYjB;AAiBM,gIAHI,OAAO,uBA2BjB;AAgBM,2JAUN;AAgBM,oIAFM,QAAQ,OAAO,EAAE,CAAC,CAoB9B"}
1
+ {"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AA+BO,0HAHI,OAAO,uBAYjB;AAiBM,gIAHI,OAAO,uBA2BjB;AAiBM,2JAUN;AAkBM,oIAFM,QAAQ,OAAO,EAAE,CAAC,CAoB9B"}
@@ -7,17 +7,19 @@ import { AmountMath } from './amountMath.js';
7
7
  const { Fail } = assert;
8
8
 
9
9
  /**
10
- * @file This file contains safer helper function alternatives to the similarly
11
- * named methods on issuer. These are parameterized by a purse used for
12
- * recovering lost payments, which we call a `recoveryPurse`. Any payments
13
- * created by these helper functions are in the recovery set of that
14
- * `recoveryPurse` until otherwise used up.
10
+ * @file
11
+ * This file contains safer helper function alternatives to the
12
+ * similarly named methods on issuer.
13
+ * These are parameterized by a purse used for recovering lost payments, which
14
+ * we call a `recoveryPurse`. Any payments created by these
15
+ * helper functions are in the recovery set of that `recoveryPurse` until
16
+ * otherwise used up.
15
17
  *
16
- * One of these helper functions is less safe in one way: `combine` is not
17
- * failure atomic. If the `combine` helper function fails, some of the input
18
- * payments may have been used up. However, even in that case, no assets would
19
- * be lost. The assets from the used up payments will be in the argument
20
- * `recoveryPurse`.
18
+ * One of these helper functions is less safe in one way:
19
+ * `combine` is not failure atomic. If the `combine` helper function
20
+ * fails, some of the input payments may have been used up. However, even
21
+ * in that case, no assets would be lost. The assets from the used up payments
22
+ * will be in the argument `recoveryPurse`.
21
23
  */
22
24
 
23
25
  /**
@@ -41,11 +43,11 @@ harden(claim);
41
43
 
42
44
  /**
43
45
  * Note: Not failure atomic. But as long as you don't lose the argument
44
- * `recoveryPurse`, no assets are lost. If any of the deposits fail, or the
45
- * total does not match optTotalAmount, some payments may still have been
46
- * deposited. Those assets will be in the argument `recoveryPurse`. All
47
- * undeposited payments will still be in the recovery sets of their purses of
48
- * origin.
46
+ * `recoveryPurse`, no assets are lost.
47
+ * If any of the deposits fail, or the total does not
48
+ * match optTotalAmount, some payments may still have been deposited. Those
49
+ * assets will be in the argument `recoveryPurse`. All undeposited payments
50
+ * will still be in the recovery sets of their purses of origin.
49
51
  *
50
52
  * @template {AssetKind} K
51
53
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -82,10 +84,11 @@ harden(combine);
82
84
 
83
85
  /**
84
86
  * Note: Not failure atomic. But as long as you don't lose the argument
85
- * `recoveryPurse`, no assets are lost. If the amount in `srcPaymentP` is not >=
86
- * `paymentAmountA`, the payment may still be deposited anyway, before failing
87
- * in the subsequent subtract. In that case, those assets will be in the
88
- * argument `recoveryPurse`.
87
+ * `recoveryPurse`, no assets are lost.
88
+ * If the amount in `srcPaymentP` is not >= `paymentAmountA`, the payment may
89
+ * still be deposited anyway, before failing in the subsequent subtract.
90
+ * In that case, those
91
+ * assets will be in the argument `recoveryPurse`.
89
92
  *
90
93
  * @template {AssetKind} K
91
94
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -108,10 +111,12 @@ harden(split);
108
111
 
109
112
  /**
110
113
  * Note: Not failure atomic. But as long as you don't lose the argument
111
- * `recoveryPurse`, no assets are lost. If the amount in `srcPaymentP` is
112
- * exactly the sum of the amounts, the payment may still be deposited anyway,
113
- * before failing in the subsequent equality check. In that case, those assets
114
- * will be in the argument `recoveryPurse`.
114
+ * `recoveryPurse`, no assets are lost.
115
+ * If the amount in `srcPaymentP` is exactly the sum of the amounts,
116
+ * the payment may
117
+ * still be deposited anyway, before failing in the subsequent equality check.
118
+ * In that case, those
119
+ * assets will be in the argument `recoveryPurse`.
115
120
  *
116
121
  * @template {AssetKind} K
117
122
  * @param {ERef<Purse<K>>} recoveryPurse
@@ -1,3 +1,5 @@
1
- /** @type {MathHelpers<CopyBag>} */
1
+ /**
2
+ * @type {MathHelpers<CopyBag>}
3
+ */
2
4
  export const copyBagMathHelpers: MathHelpers<CopyBag>;
3
5
  //# sourceMappingURL=copyBagMathHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B"}
1
+ {"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA;;GAEG;AACH,iCAFU,YAAY,OAAO,CAAC,CAa3B"}
@@ -15,7 +15,9 @@ import '../types-ambient.js';
15
15
  /** @type {CopyBag} */
16
16
  const empty = makeCopyBag([]);
17
17
 
18
- /** @type {MathHelpers<CopyBag>} */
18
+ /**
19
+ * @type {MathHelpers<CopyBag>}
20
+ */
19
21
  export const copyBagMathHelpers = harden({
20
22
  doCoerce: bag => {
21
23
  mustMatch(bag, M.bag(), 'bag of amount');