@agoric/ertp 0.16.3-dev-22cbeb1.0 → 0.16.3-dev-284e2db.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 +13 -13
- 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 +36 -6
- 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
|
@@ -8,14 +8,13 @@ const { Fail } = assert;
|
|
|
8
8
|
const empty = 0n;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Fungible digital assets use the natMathHelpers to manage balances -
|
|
12
|
-
*
|
|
13
|
-
* numbers.
|
|
11
|
+
* Fungible digital assets use the natMathHelpers to manage balances - the
|
|
12
|
+
* operations are merely arithmetic on natural, non-negative numbers.
|
|
14
13
|
*
|
|
15
|
-
* Natural numbers are used for fungible erights such as money because
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Natural numbers are used for fungible erights such as money because rounding
|
|
15
|
+
* issues make floats problematic. All operations should be done with the
|
|
16
|
+
* smallest whole unit such that the `natMathHelpers` never deals with
|
|
17
|
+
* fractional parts.
|
|
19
18
|
*
|
|
20
19
|
* @type {MathHelpers<NatValue>}
|
|
21
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAoFO,0GAPI,MAAM,2DAGN,OAAO,
|
|
1
|
+
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAoFO,0GAPI,MAAM,2DAGN,OAAO,6GA2UjB;sBA1Ya,OAAO,kBAAkB,EAAE,OAAO"}
|
package/src/paymentLedger.js
CHANGED
|
@@ -70,8 +70,8 @@ const amountShapeFromElementShape = (brand, assetKind, elementShape) => {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Make the paymentLedger, the source of truth for the balances of
|
|
74
|
-
*
|
|
73
|
+
* Make the paymentLedger, the source of truth for the balances of payments. All
|
|
74
|
+
* minting and transfer authority originates here.
|
|
75
75
|
*
|
|
76
76
|
* @template {AssetKind} K
|
|
77
77
|
* @param {Baggage} issuerBaggage
|
|
@@ -146,22 +146,21 @@ export const preparePaymentLedger = (
|
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
* A withdrawn live payment is associated with the recovery set of
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* that purse and not yet consumed.
|
|
149
|
+
* A withdrawn live payment is associated with the recovery set of the purse
|
|
150
|
+
* it was withdrawn from. Let's call these "recoverable" payments. All
|
|
151
|
+
* recoverable payments are live, but not all live payments are recoverable.
|
|
152
|
+
* We do the bookkeeping for payment recovery with this weakmap from
|
|
153
|
+
* recoverable payments to the recovery set they are in. A bunch of
|
|
154
|
+
* interesting invariants here:
|
|
155
|
+
*
|
|
156
|
+
* - Every payment that is a key in the outer `paymentRecoverySets` weakMap is
|
|
157
|
+
* also in the recovery set indexed by that payment.
|
|
158
|
+
* - Implied by the above but worth stating: the payment is only in at most one
|
|
159
|
+
* recovery set.
|
|
160
|
+
* - A recovery set only contains such payments.
|
|
161
|
+
* - Every purse is associated with exactly one recovery set unique to it.
|
|
162
|
+
* - A purse's recovery set only contains payments withdrawn from that purse and
|
|
163
|
+
* not yet consumed.
|
|
165
164
|
*
|
|
166
165
|
* @type {WeakMapStore<Payment, SetStore<Payment>>}
|
|
167
166
|
*/
|
|
@@ -172,8 +171,7 @@ export const preparePaymentLedger = (
|
|
|
172
171
|
|
|
173
172
|
/**
|
|
174
173
|
* To maintain the invariants listed in the `paymentRecoverySets` comment,
|
|
175
|
-
* `initPayment` should contain the only
|
|
176
|
-
* call to `paymentLedger.init`.
|
|
174
|
+
* `initPayment` should contain the only call to `paymentLedger.init`.
|
|
177
175
|
*
|
|
178
176
|
* @param {Payment} payment
|
|
179
177
|
* @param {Amount} amount
|
|
@@ -189,8 +187,7 @@ export const preparePaymentLedger = (
|
|
|
189
187
|
|
|
190
188
|
/**
|
|
191
189
|
* To maintain the invariants listed in the `paymentRecoverySets` comment,
|
|
192
|
-
* `deletePayment` should contain the only
|
|
193
|
-
* call to `paymentLedger.delete`.
|
|
190
|
+
* `deletePayment` should contain the only call to `paymentLedger.delete`.
|
|
194
191
|
*
|
|
195
192
|
* @param {Payment} payment
|
|
196
193
|
*/
|
|
@@ -203,19 +200,18 @@ export const preparePaymentLedger = (
|
|
|
203
200
|
}
|
|
204
201
|
};
|
|
205
202
|
|
|
206
|
-
/** @type {(left: Amount, right: Amount) => Amount
|
|
203
|
+
/** @type {(left: Amount, right: Amount) => Amount} */
|
|
207
204
|
const add = (left, right) => AmountMath.add(left, right, brand);
|
|
208
|
-
/** @type {(left: Amount, right: Amount) => Amount
|
|
205
|
+
/** @type {(left: Amount, right: Amount) => Amount} */
|
|
209
206
|
const subtract = (left, right) => AmountMath.subtract(left, right, brand);
|
|
210
207
|
/** @type {(allegedAmount: Amount) => Amount} */
|
|
211
208
|
const coerce = allegedAmount => AmountMath.coerce(brand, allegedAmount);
|
|
212
|
-
/** @type {(left: Amount, right: Amount) => boolean
|
|
209
|
+
/** @type {(left: Amount, right: Amount) => boolean} */
|
|
213
210
|
|
|
214
211
|
/**
|
|
215
|
-
* Methods like deposit() have an optional second parameter
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* payment. This helper function does that check.
|
|
212
|
+
* Methods like deposit() have an optional second parameter `optAmountShape`
|
|
213
|
+
* which, if present, is supposed to match the balance of the payment. This
|
|
214
|
+
* helper function does that check.
|
|
219
215
|
*
|
|
220
216
|
* Note: `optAmountShape` is user-supplied with no previous validation.
|
|
221
217
|
*
|
|
@@ -243,10 +239,10 @@ export const preparePaymentLedger = (
|
|
|
243
239
|
/**
|
|
244
240
|
* Used by the purse code to implement purse.deposit
|
|
245
241
|
*
|
|
246
|
-
* @param {Amount} currentBalance - the current balance of the purse
|
|
247
|
-
*
|
|
248
|
-
* @param {(newPurseBalance: Amount) => void} updatePurseBalance -
|
|
249
|
-
*
|
|
242
|
+
* @param {Amount} currentBalance - the current balance of the purse before a
|
|
243
|
+
* deposit
|
|
244
|
+
* @param {(newPurseBalance: Amount) => void} updatePurseBalance - commit the
|
|
245
|
+
* purse balance
|
|
250
246
|
* @param {Payment} srcPayment
|
|
251
247
|
* @param {Pattern} [optAmountShape]
|
|
252
248
|
* @returns {Amount}
|
|
@@ -282,10 +278,10 @@ export const preparePaymentLedger = (
|
|
|
282
278
|
/**
|
|
283
279
|
* Used by the purse code to implement purse.withdraw
|
|
284
280
|
*
|
|
285
|
-
* @param {Amount} currentBalance - the current balance of the purse
|
|
286
|
-
*
|
|
287
|
-
* @param {(newPurseBalance: Amount) => void} updatePurseBalance -
|
|
288
|
-
*
|
|
281
|
+
* @param {Amount} currentBalance - the current balance of the purse before a
|
|
282
|
+
* withdrawal
|
|
283
|
+
* @param {(newPurseBalance: Amount) => void} updatePurseBalance - commit the
|
|
284
|
+
* purse balance
|
|
289
285
|
* @param {Amount} amount - the amount to be withdrawn
|
|
290
286
|
* @param {SetStore<Payment>} recoverySet
|
|
291
287
|
* @returns {Payment}
|
|
@@ -378,9 +374,9 @@ export const preparePaymentLedger = (
|
|
|
378
374
|
/**
|
|
379
375
|
* Provides for the recovery of newly minted but not-yet-deposited payments.
|
|
380
376
|
*
|
|
381
|
-
* Because the `mintRecoveryPurse` is placed in baggage, even if the
|
|
382
|
-
*
|
|
383
|
-
*
|
|
377
|
+
* Because the `mintRecoveryPurse` is placed in baggage, even if the caller of
|
|
378
|
+
* `makeIssuerKit` drops it on the floor, it can still be recovered in an
|
|
379
|
+
* emergency upgrade.
|
|
384
380
|
*
|
|
385
381
|
* @type {Purse<K>}
|
|
386
382
|
*/
|
package/src/typeGuards.d.ts
CHANGED
|
@@ -27,14 +27,44 @@ export namespace IssuerKitShape {
|
|
|
27
27
|
export { IssuerShape as issuer };
|
|
28
28
|
export { DisplayInfoShape as displayInfo };
|
|
29
29
|
}
|
|
30
|
-
export const BrandI: import("@endo/patterns").InterfaceGuard
|
|
30
|
+
export const BrandI: import("@endo/patterns").InterfaceGuard<{
|
|
31
|
+
isMyIssuer: any;
|
|
32
|
+
getAllegedName: any;
|
|
33
|
+
getDisplayInfo: any;
|
|
34
|
+
getAmountShape: any;
|
|
35
|
+
}>;
|
|
31
36
|
export function makeIssuerInterfaces(brandShape?: Pattern, assetKindShape?: Pattern, amountShape?: Pattern): {
|
|
32
|
-
IssuerI: import("@endo/patterns").InterfaceGuard
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
IssuerI: import("@endo/patterns").InterfaceGuard<{
|
|
38
|
+
getBrand: any;
|
|
39
|
+
getAllegedName: any;
|
|
40
|
+
getAssetKind: any;
|
|
41
|
+
getDisplayInfo: any;
|
|
42
|
+
makeEmptyPurse: any;
|
|
43
|
+
isLive: any;
|
|
44
|
+
getAmountOf: any;
|
|
45
|
+
burn: any;
|
|
46
|
+
}>;
|
|
47
|
+
MintI: import("@endo/patterns").InterfaceGuard<{
|
|
48
|
+
getIssuer: any;
|
|
49
|
+
mintPayment: any;
|
|
50
|
+
}>;
|
|
51
|
+
PaymentI: import("@endo/patterns").InterfaceGuard<{
|
|
52
|
+
getAllegedBrand: any;
|
|
53
|
+
}>;
|
|
35
54
|
PurseIKit: {
|
|
36
|
-
purse: import("@endo/patterns").InterfaceGuard
|
|
37
|
-
|
|
55
|
+
purse: import("@endo/patterns").InterfaceGuard<{
|
|
56
|
+
getAllegedBrand: any;
|
|
57
|
+
getCurrentAmount: any;
|
|
58
|
+
getCurrentAmountNotifier: any;
|
|
59
|
+
deposit: any;
|
|
60
|
+
getDepositFacet: any;
|
|
61
|
+
withdraw: any;
|
|
62
|
+
getRecoverySet: any;
|
|
63
|
+
recoverAll: any;
|
|
64
|
+
}>;
|
|
65
|
+
depositFacet: import("@endo/patterns").InterfaceGuard<{
|
|
66
|
+
receive: any;
|
|
67
|
+
}>;
|
|
38
68
|
};
|
|
39
69
|
};
|
|
40
70
|
declare const AmountValueShape: import("@endo/patterns").Matcher;
|
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,0DAA+C;AAC/C,2DAAiD;AACjD,4DAAmD;AACnD,0DAA+C;AAC/C,iEAA6D;AAC7D,6DAAqD;AACrD,yDAA6C;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,0DAA+C;AAC/C,2DAAiD;AACjD,4DAAmD;AACnD,0DAA+C;AAC/C,iEAA6D;AAC7D,6DAAqD;AACrD,yDAA6C;;;;;;;;;AA+EtC,kCAHI,WAAW,mBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAYjE,kCAHI,WAAW,qBAG0C;AASzD,sCAHI,WAAW,yBAGkD;AAIxE,8CAA+C;AAE/C,8DAAuE;AAEvE,gEAaE;;;;;;;;AAYF;;;;;GAKG;AAOI,kDAJI,OAAO,mBACP,OAAO,gBACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEjB;AAlKD,iEAKE"}
|
package/src/typeGuards.js
CHANGED
|
@@ -11,62 +11,56 @@ export const NotifierShape = M.remotable('Notifier');
|
|
|
11
11
|
export const MintShape = M.remotable('Mint');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* When the AmountValue of an Amount fits the NatValueShape, i.e., when it is
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* set of fungible units.
|
|
14
|
+
* When the AmountValue of an Amount fits the NatValueShape, i.e., when it is a
|
|
15
|
+
* non-negative bigint, then it represents that many units of the fungible asset
|
|
16
|
+
* represented by that amount. The brand of that amount should indeed represent
|
|
17
|
+
* a kind of asset consisting of a countable set of fungible units.
|
|
19
18
|
*/
|
|
20
19
|
const NatValueShape = M.nat();
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* When the AmountValue of an Amount fits the CopySetValueShape, i.e., when it
|
|
24
|
-
* is a CopySet, then it represents the set of those
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* from the same asset class.
|
|
23
|
+
* is a CopySet, then it represents the set of those keys, where each key
|
|
24
|
+
* represents some individual non-fungible item, like a concert ticket, from the
|
|
25
|
+
* non-fungible asset class represented by that amount's brand. The amount
|
|
26
|
+
* itself represents the set of these items, as opposed to any of the other
|
|
27
|
+
* items from the same asset class.
|
|
30
28
|
*
|
|
31
|
-
* If a given value class represents concert tickets, it seems bizarre
|
|
32
|
-
*
|
|
33
|
-
* the
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* "You can't always get..."
|
|
29
|
+
* If a given value class represents concert tickets, it seems bizarre that we
|
|
30
|
+
* can form amounts of any key. The hard constraint is that the code that holds
|
|
31
|
+
* the mint for that asset class---the one associated with that brand, only
|
|
32
|
+
* mints the items representing the real units of that asset class as defined by
|
|
33
|
+
* it. Anyone else can put together an amount expressing, for example, that they
|
|
34
|
+
* "want" some items that will never be minted. That want will never be
|
|
35
|
+
* satisfied. "You can't always get..."
|
|
39
36
|
*/
|
|
40
37
|
const CopySetValueShape = M.set();
|
|
41
38
|
|
|
42
39
|
/**
|
|
43
|
-
* When the AmountValue of an Amount fits the SetValueShape, i.e., when it
|
|
44
|
-
*
|
|
40
|
+
* When the AmountValue of an Amount fits the SetValueShape, i.e., when it is a
|
|
41
|
+
* CopyArray of passable Keys. This representation is deprecated.
|
|
45
42
|
*
|
|
46
43
|
* @deprecated Please change from using array-based SetValues to CopySet-based
|
|
47
|
-
*
|
|
44
|
+
* CopySetValues.
|
|
48
45
|
*/
|
|
49
46
|
const SetValueShape = M.arrayOf(M.key());
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* When the AmountValue of an Amount fits the CopyBagValueShape, i.e., when it
|
|
53
|
-
* is a CopyBag, then it represents the bag (multiset) of those
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* the bag of these items, as opposed to any of the other items
|
|
60
|
-
* from the same asset class.
|
|
50
|
+
* is a CopyBag, then it represents the bag (multiset) of those keys, where each
|
|
51
|
+
* key represents some individual semi-fungible item, like a concert ticket,
|
|
52
|
+
* from the semi-fungible asset class represented by that amount's brand. The
|
|
53
|
+
* number of times that key appears in the bag is the number of fungible units
|
|
54
|
+
* of that key. The amount itself represents the bag of these items, as opposed
|
|
55
|
+
* to any of the other items from the same asset class.
|
|
61
56
|
*
|
|
62
|
-
* If a given value class represents concert tickets, it seems bizarre
|
|
63
|
-
*
|
|
64
|
-
* the
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* "You can't always get..."
|
|
57
|
+
* If a given value class represents concert tickets, it seems bizarre that we
|
|
58
|
+
* can form amounts of any key. The hard constraint is that the code that holds
|
|
59
|
+
* the mint for that asset class---the one associated with that brand, only
|
|
60
|
+
* mints the items representing the real units of that asset class as defined by
|
|
61
|
+
* it. Anyone else can put together an amount expressing, for example, that they
|
|
62
|
+
* "want" some items that will never be minted. That want will never be
|
|
63
|
+
* satisfied. "You can't always get..."
|
|
70
64
|
*/
|
|
71
65
|
const CopyBagValueShape = M.bag();
|
|
72
66
|
|
|
@@ -106,11 +100,11 @@ export const isCopySetValue = value => matches(value, CopySetValueShape);
|
|
|
106
100
|
harden(isCopySetValue);
|
|
107
101
|
|
|
108
102
|
/**
|
|
109
|
-
* Returns true if value is a pass by copy array structure. Does not
|
|
110
|
-
*
|
|
103
|
+
* Returns true if value is a pass by copy array structure. Does not check for
|
|
104
|
+
* duplicates. To check for duplicates, use setMathHelpers.coerce.
|
|
111
105
|
*
|
|
112
106
|
* @deprecated Please change from using array-based SetValues to CopySet-based
|
|
113
|
-
*
|
|
107
|
+
* CopySetValues.
|
|
114
108
|
* @param {AmountValue} value
|
|
115
109
|
* @returns {value is SetValue}
|
|
116
110
|
*/
|