@agoric/ertp 0.16.3-dev-857e650.0 → 0.16.3-dev-fb922d3.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 +7 -7
- package/src/amountMath.d.ts +13 -12
- package/src/amountMath.d.ts.map +1 -1
- package/src/amountMath.js +57 -63
- package/src/issuerKit.d.ts.map +1 -1
- package/src/issuerKit.js +51 -57
- package/src/legacy-payment-helpers.d.ts.map +1 -1
- package/src/legacy-payment-helpers.js +23 -28
- package/src/mathHelpers/copyBagMathHelpers.d.ts +1 -3
- package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/copyBagMathHelpers.js +1 -3
- package/src/mathHelpers/copySetMathHelpers.d.ts +1 -3
- package/src/mathHelpers/copySetMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/copySetMathHelpers.js +1 -3
- package/src/mathHelpers/natMathHelpers.d.ts +6 -7
- package/src/mathHelpers/natMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/natMathHelpers.js +6 -7
- package/src/paymentLedger.d.ts.map +1 -1
- package/src/paymentLedger.js +36 -40
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +35 -41
- package/src/types-ambient.d.ts +177 -174
- package/src/types-ambient.d.ts.map +1 -1
- package/src/types-ambient.js +212 -280
- package/src/types.d.ts +177 -174
- package/src/types.d.ts.map +1 -1
- package/src/types.js +212 -280
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/ertp",
|
|
3
|
-
"version": "0.16.3-dev-
|
|
3
|
+
"version": "0.16.3-dev-fb922d3.0+fb922d3",
|
|
4
4
|
"description": "Electronic Rights Transfer Protocol (ERTP). A smart contract framework for exchanging electronic rights",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@agoric/assert": "0.6.1-dev-
|
|
43
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
44
|
-
"@agoric/store": "0.9.3-dev-
|
|
45
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
46
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
42
|
+
"@agoric/assert": "0.6.1-dev-fb922d3.0+fb922d3",
|
|
43
|
+
"@agoric/notifier": "0.6.3-dev-fb922d3.0+fb922d3",
|
|
44
|
+
"@agoric/store": "0.9.3-dev-fb922d3.0+fb922d3",
|
|
45
|
+
"@agoric/swingset-vat": "0.32.3-dev-fb922d3.0+fb922d3",
|
|
46
|
+
"@agoric/vat-data": "0.5.3-dev-fb922d3.0+fb922d3",
|
|
47
47
|
"@endo/eventual-send": "^0.17.3",
|
|
48
48
|
"@endo/far": "^0.2.19",
|
|
49
49
|
"@endo/marshal": "^0.8.6",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "fb922d3aeddd390919a015a76d5f4e035e6f0240"
|
|
83
83
|
}
|
package/src/amountMath.d.ts
CHANGED
|
@@ -19,7 +19,12 @@ export namespace AmountMath {
|
|
|
19
19
|
/**
|
|
20
20
|
* Constants for the kinds of assets we support.
|
|
21
21
|
*
|
|
22
|
-
* @type {{
|
|
22
|
+
* @type {{
|
|
23
|
+
* NAT: 'nat';
|
|
24
|
+
* SET: 'set';
|
|
25
|
+
* COPY_SET: 'copySet';
|
|
26
|
+
* COPY_BAG: 'copyBag';
|
|
27
|
+
* }}
|
|
23
28
|
*/
|
|
24
29
|
export const AssetKind: {
|
|
25
30
|
NAT: 'nat';
|
|
@@ -27,20 +32,16 @@ export const AssetKind: {
|
|
|
27
32
|
COPY_SET: 'copySet';
|
|
28
33
|
COPY_BAG: 'copyBag';
|
|
29
34
|
};
|
|
30
|
-
/**
|
|
31
|
-
* @param {Amount} amount
|
|
32
|
-
*/
|
|
35
|
+
/** @param {Amount} amount */
|
|
33
36
|
export function getAssetKind(amount: Amount): AssetKindForValue<V>;
|
|
34
|
-
/**
|
|
35
|
-
* @param {AssetKind} allegedAK
|
|
36
|
-
*/
|
|
37
|
+
/** @param {AssetKind} allegedAK */
|
|
37
38
|
export function assertAssetKind(allegedAK: AssetKind): void;
|
|
38
39
|
/**
|
|
39
|
-
* Returns true if the leftAmount is greater than or equal to the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* whether rectangle A
|
|
43
|
-
*
|
|
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.
|
|
44
45
|
*
|
|
45
46
|
* @template {AssetKind} K
|
|
46
47
|
* @param {Amount<K>} leftAmount
|
package/src/amountMath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"
|
|
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"}
|
package/src/amountMath.js
CHANGED
|
@@ -11,7 +11,12 @@ const { quote: q, Fail } = assert;
|
|
|
11
11
|
/**
|
|
12
12
|
* Constants for the kinds of assets we support.
|
|
13
13
|
*
|
|
14
|
-
* @type {{
|
|
14
|
+
* @type {{
|
|
15
|
+
* NAT: 'nat';
|
|
16
|
+
* SET: 'set';
|
|
17
|
+
* COPY_SET: 'copySet';
|
|
18
|
+
* COPY_BAG: 'copyBag';
|
|
19
|
+
* }}
|
|
15
20
|
*/
|
|
16
21
|
const AssetKind = harden({
|
|
17
22
|
NAT: 'nat',
|
|
@@ -21,9 +26,7 @@ const AssetKind = harden({
|
|
|
21
26
|
});
|
|
22
27
|
const assetKindNames = harden(Object.values(AssetKind).sort());
|
|
23
28
|
|
|
24
|
-
/**
|
|
25
|
-
* @param {AssetKind} allegedAK
|
|
26
|
-
*/
|
|
29
|
+
/** @param {AssetKind} allegedAK */
|
|
27
30
|
const assertAssetKind = allegedAK => {
|
|
28
31
|
assetKindNames.includes(allegedAK) ||
|
|
29
32
|
Fail`The assetKind ${allegedAK} must be one of ${q(assetKindNames)}`;
|
|
@@ -31,42 +34,37 @@ const assertAssetKind = allegedAK => {
|
|
|
31
34
|
harden(assertAssetKind);
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
|
-
* Amounts describe digital assets. From an amount, you can learn the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* the
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* anyone.
|
|
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.
|
|
42
44
|
*
|
|
43
|
-
* The issuer is the authoritative source of the amount in payments
|
|
44
|
-
*
|
|
45
|
-
* digital assets
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* which we call `AmountMath`. These math functions include concepts
|
|
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
|
|
50
51
|
* like addition, subtraction, and greater than or equal to.
|
|
51
52
|
*
|
|
52
|
-
* We also want to make sure there is no confusion as to what kind of
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* operation does not succeed.
|
|
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.
|
|
57
57
|
*
|
|
58
|
-
* AmountMath uses mathHelpers to do most of the work, but then adds
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* returning an amount (amount -> amount).
|
|
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).
|
|
64
63
|
*
|
|
65
|
-
* Each issuer of digital assets has an associated brand in a
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* each other.
|
|
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.
|
|
70
68
|
*/
|
|
71
69
|
|
|
72
70
|
const helpers = {
|
|
@@ -137,7 +135,7 @@ const optionalBrandCheck = (allegedBrand, brand) => {
|
|
|
137
135
|
* @param {Amount<K>} leftAmount
|
|
138
136
|
* @param {Amount<K>} rightAmount
|
|
139
137
|
* @param {Brand<K> | undefined} brand
|
|
140
|
-
* @returns {MathHelpers
|
|
138
|
+
* @returns {MathHelpers<any>}
|
|
141
139
|
*/
|
|
142
140
|
const checkLRAndGetHelpers = (leftAmount, rightAmount, brand = undefined) => {
|
|
143
141
|
assertRecord(leftAmount, 'leftAmount');
|
|
@@ -172,11 +170,11 @@ const coerceLR = (h, leftAmount, rightAmount) => {
|
|
|
172
170
|
};
|
|
173
171
|
|
|
174
172
|
/**
|
|
175
|
-
* Returns true if the leftAmount is greater than or equal to the
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* whether rectangle A
|
|
179
|
-
*
|
|
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.
|
|
180
178
|
*
|
|
181
179
|
* @template {AssetKind} K
|
|
182
180
|
* @param {Amount<K>} leftAmount
|
|
@@ -194,9 +192,8 @@ const isGTE = (leftAmount, rightAmount, brand = undefined) => {
|
|
|
194
192
|
*
|
|
195
193
|
* Amounts are the canonical description of tradable goods. They are manipulated
|
|
196
194
|
* by issuers and mints, and represent the goods and currency carried by purses
|
|
197
|
-
* and
|
|
198
|
-
*
|
|
199
|
-
* abstract right to participate in a particular exchange.
|
|
195
|
+
* and payments. They can be used to represent things like currency, stock, and
|
|
196
|
+
* the abstract right to participate in a particular exchange.
|
|
200
197
|
*/
|
|
201
198
|
const AmountMath = {
|
|
202
199
|
/**
|
|
@@ -215,8 +212,8 @@ const AmountMath = {
|
|
|
215
212
|
return harden({ brand, value });
|
|
216
213
|
},
|
|
217
214
|
/**
|
|
218
|
-
* Make sure this amount is valid enough, and return a corresponding
|
|
219
|
-
*
|
|
215
|
+
* Make sure this amount is valid enough, and return a corresponding valid
|
|
216
|
+
* amount if so.
|
|
220
217
|
*
|
|
221
218
|
* @template {AssetKind} K
|
|
222
219
|
* @param {Brand<K>} brand
|
|
@@ -242,8 +239,8 @@ const AmountMath = {
|
|
|
242
239
|
*/
|
|
243
240
|
getValue: (brand, amount) => AmountMath.coerce(brand, amount).value,
|
|
244
241
|
/**
|
|
245
|
-
* Return the amount representing an empty amount. This is the
|
|
246
|
-
*
|
|
242
|
+
* Return the amount representing an empty amount. This is the identity
|
|
243
|
+
* element for MathHelpers.add and MatHelpers.subtract.
|
|
247
244
|
*
|
|
248
245
|
* @type {{
|
|
249
246
|
* (brand: Brand): Amount<'nat'>;
|
|
@@ -257,8 +254,8 @@ const AmountMath = {
|
|
|
257
254
|
return harden({ brand, value });
|
|
258
255
|
},
|
|
259
256
|
/**
|
|
260
|
-
* Return the amount representing an empty amount, using another
|
|
261
|
-
*
|
|
257
|
+
* Return the amount representing an empty amount, using another amount as the
|
|
258
|
+
* template for the brand and assetKind.
|
|
262
259
|
*
|
|
263
260
|
* @template {AssetKind} K
|
|
264
261
|
* @param {Amount<K>} amount
|
|
@@ -289,8 +286,8 @@ const AmountMath = {
|
|
|
289
286
|
},
|
|
290
287
|
isGTE,
|
|
291
288
|
/**
|
|
292
|
-
* Returns true if the leftAmount equals the rightAmount. We assume
|
|
293
|
-
*
|
|
289
|
+
* Returns true if the leftAmount equals the rightAmount. We assume that if
|
|
290
|
+
* isGTE is true in both directions, isEqual is also true
|
|
294
291
|
*
|
|
295
292
|
* @template {AssetKind} K
|
|
296
293
|
* @param {Amount<K>} leftAmount
|
|
@@ -306,8 +303,8 @@ const AmountMath = {
|
|
|
306
303
|
* Returns a new amount that is the union of both leftAmount and rightAmount.
|
|
307
304
|
*
|
|
308
305
|
* For fungible amount this means adding the values. For other kinds of
|
|
309
|
-
* amount, it usually means including all of the elements from both
|
|
310
|
-
*
|
|
306
|
+
* amount, it usually means including all of the elements from both left and
|
|
307
|
+
* right.
|
|
311
308
|
*
|
|
312
309
|
* @template {AssetKind} K
|
|
313
310
|
* @param {Amount<K>} leftAmount
|
|
@@ -321,12 +318,11 @@ const AmountMath = {
|
|
|
321
318
|
return harden({ brand: leftAmount.brand, value });
|
|
322
319
|
},
|
|
323
320
|
/**
|
|
324
|
-
* Returns a new amount that is the leftAmount minus the rightAmount
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* to set subtraction.
|
|
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.
|
|
330
326
|
*
|
|
331
327
|
* @template {AssetKind} K
|
|
332
328
|
* @param {Amount<K>} leftAmount
|
|
@@ -374,9 +370,7 @@ const AmountMath = {
|
|
|
374
370
|
};
|
|
375
371
|
harden(AmountMath);
|
|
376
372
|
|
|
377
|
-
/**
|
|
378
|
-
* @param {Amount} amount
|
|
379
|
-
*/
|
|
373
|
+
/** @param {Amount} amount */
|
|
380
374
|
const getAssetKind = amount => {
|
|
381
375
|
assertRecord(amount, 'amount');
|
|
382
376
|
const { value } = amount;
|
package/src/issuerKit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA2FO,uMAMN;AASM,mEAAsD;
|
|
1
|
+
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA2FO,uMAMN;AASM,mEAAsD;AA+BtD,0GAbI,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"}
|
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
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
|
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
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
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
|
|
90
90
|
* @returns {IssuerKit<K>}
|
|
91
91
|
*/
|
|
92
92
|
export const prepareIssuerKit = (
|
|
@@ -99,43 +99,39 @@ export const prepareIssuerKit = (
|
|
|
99
99
|
harden(prepareIssuerKit);
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* Does baggage already have an issuer from prepareIssuerKit()?
|
|
103
|
-
*
|
|
102
|
+
* Does baggage already have an issuer from prepareIssuerKit()? That is: does it
|
|
103
|
+
* 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
|
-
/**
|
|
110
|
-
* @typedef {Partial<{elementShape: Pattern}>} IssuerOptionsRecord
|
|
111
|
-
*/
|
|
109
|
+
/** @typedef {Partial<{ elementShape: Pattern }>} IssuerOptionsRecord */
|
|
112
110
|
|
|
113
111
|
/**
|
|
114
|
-
* @template {AssetKind} K
|
|
115
|
-
* The name
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* to that issuer and brand.
|
|
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.
|
|
121
118
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* `displayInfo` gives information to the UI on how to display the amount.
|
|
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.
|
|
127
122
|
*
|
|
123
|
+
* `displayInfo` gives information to the UI on how to display the amount.
|
|
128
124
|
* @param {Baggage} issuerBaggage
|
|
129
125
|
* @param {string} name
|
|
130
126
|
* @param {K} [assetKind=AssetKind.NAT]
|
|
131
127
|
* @param {AdditionalDisplayInfo} [displayInfo={}]
|
|
132
|
-
* @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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
|
|
139
135
|
* @param {IssuerOptionsRecord} [options]
|
|
140
136
|
* @returns {IssuerKit<K>}
|
|
141
137
|
*/
|
|
@@ -155,30 +151,28 @@ export const makeDurableIssuerKit = (
|
|
|
155
151
|
harden(makeDurableIssuerKit);
|
|
156
152
|
|
|
157
153
|
/**
|
|
158
|
-
* @template {AssetKind} [K='nat']
|
|
159
|
-
* The name
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
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.
|
|
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.
|
|
169
160
|
*
|
|
170
|
-
*
|
|
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.
|
|
171
164
|
*
|
|
165
|
+
* `displayInfo` gives information to the UI on how to display the amount.
|
|
172
166
|
* @param {string} name
|
|
173
167
|
* @param {K} [assetKind='nat']
|
|
174
168
|
* @param {AdditionalDisplayInfo} [displayInfo={}]
|
|
175
|
-
* @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
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
|
|
182
176
|
* @param {IssuerOptionsRecord} [options]
|
|
183
177
|
* @returns {IssuerKit<K>}
|
|
184
178
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -7,19 +7,17 @@ import { AmountMath } from './amountMath.js';
|
|
|
7
7
|
const { Fail } = assert;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @file
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* helper functions are in the recovery set of that `recoveryPurse` until
|
|
16
|
-
* otherwise used up.
|
|
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.
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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`.
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -43,11 +41,11 @@ harden(claim);
|
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* Note: Not failure atomic. But as long as you don't lose the argument
|
|
46
|
-
* `recoveryPurse`, no assets are lost.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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.
|
|
51
49
|
*
|
|
52
50
|
* @template {AssetKind} K
|
|
53
51
|
* @param {ERef<Purse<K>>} recoveryPurse
|
|
@@ -84,11 +82,10 @@ harden(combine);
|
|
|
84
82
|
|
|
85
83
|
/**
|
|
86
84
|
* Note: Not failure atomic. But as long as you don't lose the argument
|
|
87
|
-
* `recoveryPurse`, no assets are lost.
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* assets will be in the argument `recoveryPurse`.
|
|
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`.
|
|
92
89
|
*
|
|
93
90
|
* @template {AssetKind} K
|
|
94
91
|
* @param {ERef<Purse<K>>} recoveryPurse
|
|
@@ -111,12 +108,10 @@ harden(split);
|
|
|
111
108
|
|
|
112
109
|
/**
|
|
113
110
|
* Note: Not failure atomic. But as long as you don't lose the argument
|
|
114
|
-
* `recoveryPurse`, no assets are lost.
|
|
115
|
-
*
|
|
116
|
-
* the
|
|
117
|
-
*
|
|
118
|
-
* In that case, those
|
|
119
|
-
* assets will be in the argument `recoveryPurse`.
|
|
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`.
|
|
120
115
|
*
|
|
121
116
|
* @template {AssetKind} K
|
|
122
117
|
* @param {ERef<Purse<K>>} recoveryPurse
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA
|
|
1
|
+
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B"}
|
|
@@ -15,9 +15,7 @@ import '../types-ambient.js';
|
|
|
15
15
|
/** @type {CopyBag} */
|
|
16
16
|
const empty = makeCopyBag([]);
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* @type {MathHelpers<CopyBag>}
|
|
20
|
-
*/
|
|
18
|
+
/** @type {MathHelpers<CopyBag>} */
|
|
21
19
|
export const copyBagMathHelpers = harden({
|
|
22
20
|
doCoerce: bag => {
|
|
23
21
|
mustMatch(bag, M.bag(), 'bag of amount');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copySetMathHelpers.d.ts","sourceRoot":"","sources":["copySetMathHelpers.js"],"names":[],"mappings":"AAiBA
|
|
1
|
+
{"version":3,"file":"copySetMathHelpers.d.ts","sourceRoot":"","sources":["copySetMathHelpers.js"],"names":[],"mappings":"AAiBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B"}
|
|
@@ -15,9 +15,7 @@ import '../types-ambient.js';
|
|
|
15
15
|
/** @type {CopySet} */
|
|
16
16
|
const empty = makeCopySet([]);
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* @type {MathHelpers<CopySet>}
|
|
20
|
-
*/
|
|
18
|
+
/** @type {MathHelpers<CopySet>} */
|
|
21
19
|
export const copySetMathHelpers = harden({
|
|
22
20
|
doCoerce: set => {
|
|
23
21
|
mustMatch(set, M.set(), 'set of amount');
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Fungible digital assets use the natMathHelpers to manage balances -
|
|
3
|
-
*
|
|
4
|
-
* numbers.
|
|
2
|
+
* Fungible digital assets use the natMathHelpers to manage balances - the
|
|
3
|
+
* operations are merely arithmetic on natural, non-negative numbers.
|
|
5
4
|
*
|
|
6
|
-
* Natural numbers are used for fungible erights such as money because
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Natural numbers are used for fungible erights such as money because rounding
|
|
6
|
+
* issues make floats problematic. All operations should be done with the
|
|
7
|
+
* smallest whole unit such that the `natMathHelpers` never deals with
|
|
8
|
+
* fractional parts.
|
|
10
9
|
*
|
|
11
10
|
* @type {MathHelpers<NatValue>}
|
|
12
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"natMathHelpers.d.ts","sourceRoot":"","sources":["natMathHelpers.js"],"names":[],"mappings":"AASA
|
|
1
|
+
{"version":3,"file":"natMathHelpers.d.ts","sourceRoot":"","sources":["natMathHelpers.js"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,6BAFU,YAAY,QAAQ,CAAC,CAgB5B"}
|