@agoric/ertp 0.16.3-dev-727e4af.0 → 0.16.3-dev-96c9ff5.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 +16 -16
- package/src/amountMath.d.ts +20 -16
- package/src/amountMath.d.ts.map +1 -1
- package/src/amountMath.js +68 -54
- package/src/issuerKit.d.ts +1 -1
- package/src/issuerKit.d.ts.map +1 -1
- package/src/issuerKit.js +1 -1
- package/src/legacy-payment-helpers.d.ts +3 -3
- package/src/legacy-payment-helpers.d.ts.map +1 -1
- package/src/legacy-payment-helpers.js +5 -4
- package/src/mathHelpers/copyBagMathHelpers.d.ts +1 -1
- package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -1
- package/src/paymentLedger.d.ts.map +1 -1
- package/src/paymentLedger.js +4 -20
- package/src/purse.d.ts +3 -4
- package/src/purse.d.ts.map +1 -1
- package/src/types.d.ts +121 -94
- package/src/types.d.ts.map +1 -1
- package/src/types.js +132 -81
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-96c9ff5.0+96c9ff5",
|
|
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,21 +39,21 @@
|
|
|
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/vat-data": "0.5.3-dev-
|
|
46
|
-
"@agoric/zone": "0.2.3-dev-
|
|
47
|
-
"@endo/eventual-send": "^1.2.
|
|
48
|
-
"@endo/far": "^1.1.
|
|
49
|
-
"@endo/marshal": "^1.
|
|
50
|
-
"@endo/nat": "^5.0.
|
|
51
|
-
"@endo/patterns": "^1.
|
|
52
|
-
"@endo/promise-kit": "^1.1.
|
|
42
|
+
"@agoric/assert": "0.6.1-dev-96c9ff5.0+96c9ff5",
|
|
43
|
+
"@agoric/notifier": "0.6.3-dev-96c9ff5.0+96c9ff5",
|
|
44
|
+
"@agoric/store": "0.9.3-dev-96c9ff5.0+96c9ff5",
|
|
45
|
+
"@agoric/vat-data": "0.5.3-dev-96c9ff5.0+96c9ff5",
|
|
46
|
+
"@agoric/zone": "0.2.3-dev-96c9ff5.0+96c9ff5",
|
|
47
|
+
"@endo/eventual-send": "^1.2.2",
|
|
48
|
+
"@endo/far": "^1.1.2",
|
|
49
|
+
"@endo/marshal": "^1.5.0",
|
|
50
|
+
"@endo/nat": "^5.0.7",
|
|
51
|
+
"@endo/patterns": "^1.4.0",
|
|
52
|
+
"@endo/promise-kit": "^1.1.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
56
|
-
"@endo/bundle-source": "^3.2.
|
|
55
|
+
"@agoric/swingset-vat": "0.32.3-dev-96c9ff5.0+96c9ff5",
|
|
56
|
+
"@endo/bundle-source": "^3.2.3",
|
|
57
57
|
"@fast-check/ava": "^1.1.5",
|
|
58
58
|
"ava": "^5.3.0",
|
|
59
59
|
"tsd": "^0.30.7"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
88
|
"typeCoverage": {
|
|
89
|
-
"atLeast":
|
|
89
|
+
"atLeast": 91.21
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "96c9ff577fe14cebeb5a38543ba7f8598ffcd0c7"
|
|
92
92
|
}
|
package/src/amountMath.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
export function assertValueGetHelpers<V
|
|
2
|
-
import type { AmountValue } from './types.js';
|
|
1
|
+
export function assertValueGetHelpers<V>(value: V): MathHelpers<V>;
|
|
3
2
|
import type { MathHelpers } from './types.js';
|
|
4
3
|
export namespace AmountMath {
|
|
5
|
-
export function make<
|
|
6
|
-
export function coerce<
|
|
7
|
-
export function getValue<
|
|
4
|
+
export function make<B extends Brand, V extends bigint | CopySet | SetValue | CopyBag>(brand: B, allegedValue: V): B extends Brand<"nat"> ? NatAmount : V extends bigint ? NatAmount : V extends CopySet ? CopySetAmount<V["payload"][0]> : V extends CopyBag ? CopyBagAmount<V["payload"][0][0]> : V extends SetValue ? SetAmount<V[0]> : never;
|
|
5
|
+
export function coerce<A extends Amount>(brand: Brand, allegedAmount: A): A;
|
|
6
|
+
export function getValue<A extends Amount>(brand: Brand, amount: A): A["value"];
|
|
8
7
|
export let makeEmpty: {
|
|
9
|
-
(brand: Brand):
|
|
10
|
-
<K extends AssetKind>(brand: Brand
|
|
8
|
+
(brand: Brand): NatAmount;
|
|
9
|
+
<K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
|
|
11
10
|
};
|
|
12
|
-
export function makeEmptyFromAmount<
|
|
11
|
+
export function makeEmptyFromAmount<A extends Amount>(amount: A): A;
|
|
13
12
|
export function isEmpty(amount: Amount, brand?: Brand | undefined): boolean;
|
|
14
13
|
export { isGTE };
|
|
15
|
-
export function isEqual<
|
|
16
|
-
export function add<
|
|
17
|
-
export function subtract<
|
|
18
|
-
export function min<
|
|
19
|
-
export function max<
|
|
14
|
+
export function isEqual<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand | undefined): boolean;
|
|
15
|
+
export function add<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand | undefined): A;
|
|
16
|
+
export function subtract<L extends Amount, R extends Amount>(leftAmount: L, rightAmount: R, brand?: Brand | undefined): L extends R ? L : never;
|
|
17
|
+
export function min<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
|
|
18
|
+
export function max<A extends Amount>(x: A, y: A, brand?: Brand | undefined): A;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Constants for the kinds of assets we support.
|
|
@@ -36,11 +35,17 @@ export const AssetKind: {
|
|
|
36
35
|
};
|
|
37
36
|
import type { AssetKind } from './types.js';
|
|
38
37
|
/** @param {Amount} amount */
|
|
39
|
-
export function getAssetKind(amount: Amount):
|
|
38
|
+
export function getAssetKind(amount: Amount): "copySet" | "set" | "nat" | "copyBag";
|
|
40
39
|
/** @param {AssetKind} allegedAK */
|
|
41
40
|
export function assertAssetKind(allegedAK: AssetKind): void;
|
|
42
41
|
import type { Brand } from './types.js';
|
|
43
|
-
import type {
|
|
42
|
+
import type { CopySet } from '@endo/patterns';
|
|
43
|
+
import type { SetValue } from './types.js';
|
|
44
|
+
import type { CopyBag } from '@endo/patterns';
|
|
45
|
+
import type { NatAmount } from './types.js';
|
|
46
|
+
import type { CopySetAmount } from './types.js';
|
|
47
|
+
import type { CopyBagAmount } from './types.js';
|
|
48
|
+
import type { SetAmount } from './types.js';
|
|
44
49
|
import type { Amount } from './types.js';
|
|
45
50
|
/**
|
|
46
51
|
* Returns true if the leftAmount is greater than or equal to the rightAmount.
|
|
@@ -56,6 +61,5 @@ import type { Amount } from './types.js';
|
|
|
56
61
|
* @returns {boolean}
|
|
57
62
|
*/
|
|
58
63
|
declare function isGTE<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
|
|
59
|
-
import type { AssetKindForValue } from './types.js';
|
|
60
64
|
export {};
|
|
61
65
|
//# sourceMappingURL=amountMath.d.ts.map
|
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":"AAmHO,sCAFkB,CAAC,SAAD,CAAC,AADd,kBAK6B;iCA3G0I,YAAY;;IAiNvL,qBAdK,CAAC,gBACD,CAAC,uDADD,CAAC,gBACD,CAAC,iOAmBX;IAUO,uBAHG,CAAC,8CAAD,CAAC,KAYX;IASS,yBAHC,CAAC,uCAAD,CAAC,cAGuD;;;SAOZ,CAAC,gDAAD,CAAC;;IAkBnC,oCAHV,CAAC,yBAAD,CAAC,KASX;IAQQ,4EAOR;;IAYQ,wBAJE,CAAC,6BAAD,CAAC,AADA,eACD,CAAC,sCAOX;IAcI,oBAJM,CAAC,6BAAD,CAAC,AADA,eACD,CAAC,gCASX;IAeS,yBALC,CAAC,iBACD,CAAC,6BADD,CAAC,eACD,CAAC,sDASX;IAUI,oBAJM,CAAC,oBAAD,CAAC,AADA,KACD,CAAC,gCAUgC;IAUvC,oBAJM,CAAC,oBAAD,CAAC,AADA,KACD,CAAC,gCAUgC;;AAlX9C;;;;;;;;;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;+BApBgL,YAAY;AA2X/L,6BAA6B;AAC7B,oFAIC;AAzWD,mCAAmC;AACnC,2CADY,SAAS,QAIpB;2BA3BkL,YAAY;6BAD5J,gBAAgB;8BACgI,YAAY;6BAD5J,gBAAgB;+BACgI,YAAY;mCAAZ,YAAY;mCAAZ,YAAY;+BAAZ,YAAY;4BAAZ,YAAY;AA+J/L;;;;;;;;;;;;GAYG;AACH,uBAJkB,CAAC,kGAEN,OAAO,CAKnB"}
|
package/src/amountMath.js
CHANGED
|
@@ -6,7 +6,10 @@ import { setMathHelpers } from './mathHelpers/setMathHelpers.js';
|
|
|
6
6
|
import { copySetMathHelpers } from './mathHelpers/copySetMathHelpers.js';
|
|
7
7
|
import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @import {CopyBag, CopySet} from '@endo/patterns';
|
|
11
|
+
* @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
|
|
12
|
+
*/
|
|
10
13
|
|
|
11
14
|
const { quote: q, Fail } = assert;
|
|
12
15
|
|
|
@@ -76,26 +79,19 @@ const helpers = {
|
|
|
76
79
|
copyBag: copyBagMathHelpers,
|
|
77
80
|
};
|
|
78
81
|
|
|
79
|
-
/**
|
|
80
|
-
* @template {AmountValue} V
|
|
81
|
-
* @type {(value: V) => AssetKindForValue<V>}
|
|
82
|
-
*/
|
|
82
|
+
/** @type {(value: unknown) => 'nat' | 'set' | 'copySet' | 'copyBag'} } */
|
|
83
83
|
const assertValueGetAssetKind = value => {
|
|
84
84
|
const passStyle = passStyleOf(value);
|
|
85
85
|
if (passStyle === 'bigint') {
|
|
86
|
-
// @ts-expect-error cast
|
|
87
86
|
return 'nat';
|
|
88
87
|
}
|
|
89
88
|
if (passStyle === 'copyArray') {
|
|
90
|
-
// @ts-expect-error cast
|
|
91
89
|
return 'set';
|
|
92
90
|
}
|
|
93
91
|
if (matches(value, M.set())) {
|
|
94
|
-
// @ts-expect-error cast
|
|
95
92
|
return 'copySet';
|
|
96
93
|
}
|
|
97
94
|
if (matches(value, M.bag())) {
|
|
98
|
-
// @ts-expect-error cast
|
|
99
95
|
return 'copyBag';
|
|
100
96
|
}
|
|
101
97
|
// TODO This isn't quite the right error message, in case valuePassStyle
|
|
@@ -113,7 +109,7 @@ const assertValueGetAssetKind = value => {
|
|
|
113
109
|
*
|
|
114
110
|
* Made available only for testing, but it is harmless for other uses.
|
|
115
111
|
*
|
|
116
|
-
* @template
|
|
112
|
+
* @template V
|
|
117
113
|
* @param {V} value
|
|
118
114
|
* @returns {MathHelpers<V>}
|
|
119
115
|
*/
|
|
@@ -198,29 +194,44 @@ const isGTE = (leftAmount, rightAmount, brand = undefined) => {
|
|
|
198
194
|
* the abstract right to participate in a particular exchange.
|
|
199
195
|
*/
|
|
200
196
|
const AmountMath = {
|
|
197
|
+
// TODO use overloading to handle when Brand has an AssetKind and when it doesn't.
|
|
198
|
+
// a AmountForValue utility could help DRY those cases.
|
|
201
199
|
/**
|
|
202
200
|
* Make an amount from a value by adding the brand.
|
|
203
201
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
207
|
-
* @
|
|
202
|
+
* Does not verify that the Brand's AssetKind matches the value's.
|
|
203
|
+
*
|
|
204
|
+
* @template {Brand} B
|
|
205
|
+
* @template {NatValue | CopySet | CopyBag | SetValue} V
|
|
206
|
+
* @param {B} brand
|
|
207
|
+
* @param {V} allegedValue
|
|
208
|
+
* @returns {B extends Brand<'nat'>
|
|
209
|
+
* ? NatAmount
|
|
210
|
+
* : V extends NatValue
|
|
211
|
+
* ? NatAmount
|
|
212
|
+
* : V extends CopySet
|
|
213
|
+
* ? CopySetAmount<V['payload'][0]>
|
|
214
|
+
* : V extends CopyBag
|
|
215
|
+
* ? CopyBagAmount<V['payload'][0][0]>
|
|
216
|
+
* : V extends SetValue
|
|
217
|
+
* ? SetAmount<V[0]>
|
|
218
|
+
* : never}
|
|
208
219
|
*/
|
|
209
|
-
// allegedValue has a conditional expression for type widening, to prevent V being bound to a a literal like 1n
|
|
210
220
|
make: (brand, allegedValue) => {
|
|
211
221
|
assertRemotable(brand, 'brand');
|
|
212
222
|
const h = assertValueGetHelpers(allegedValue);
|
|
213
223
|
const value = h.doCoerce(allegedValue);
|
|
224
|
+
// @ts-expect-error cast
|
|
214
225
|
return harden({ brand, value });
|
|
215
226
|
},
|
|
216
227
|
/**
|
|
217
228
|
* Make sure this amount is valid enough, and return a corresponding valid
|
|
218
229
|
* amount if so.
|
|
219
230
|
*
|
|
220
|
-
* @template {
|
|
221
|
-
* @param {Brand
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {
|
|
231
|
+
* @template {Amount} A
|
|
232
|
+
* @param {Brand} brand
|
|
233
|
+
* @param {A} allegedAmount
|
|
234
|
+
* @returns {A}
|
|
224
235
|
*/
|
|
225
236
|
coerce: (brand, allegedAmount) => {
|
|
226
237
|
assertRemotable(brand, 'brand');
|
|
@@ -229,15 +240,16 @@ const AmountMath = {
|
|
|
229
240
|
brand === allegedBrand ||
|
|
230
241
|
Fail`The brand in the allegedAmount ${allegedAmount} in 'coerce' didn't match the specified brand ${brand}.`;
|
|
231
242
|
// Will throw on inappropriate value
|
|
243
|
+
// @ts-expect-error cast
|
|
232
244
|
return AmountMath.make(brand, allegedValue);
|
|
233
245
|
},
|
|
234
246
|
/**
|
|
235
247
|
* Extract and return the value.
|
|
236
248
|
*
|
|
237
|
-
* @template {
|
|
238
|
-
* @param {Brand
|
|
239
|
-
* @param {
|
|
240
|
-
* @returns {
|
|
249
|
+
* @template {Amount} A
|
|
250
|
+
* @param {Brand} brand
|
|
251
|
+
* @param {A} amount
|
|
252
|
+
* @returns {A['value']}
|
|
241
253
|
*/
|
|
242
254
|
getValue: (brand, amount) => AmountMath.coerce(brand, amount).value,
|
|
243
255
|
/**
|
|
@@ -246,29 +258,29 @@ const AmountMath = {
|
|
|
246
258
|
*
|
|
247
259
|
* @type {{
|
|
248
260
|
* (brand: Brand): Amount<'nat'>;
|
|
249
|
-
* <K extends AssetKind>(brand: Brand
|
|
261
|
+
* <K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
|
|
250
262
|
* }}
|
|
251
263
|
*/
|
|
252
264
|
makeEmpty: (brand, assetKind = /** @type {const} */ ('nat')) => {
|
|
253
265
|
assertRemotable(brand, 'brand');
|
|
254
266
|
assertAssetKind(assetKind);
|
|
255
267
|
const value = helpers[assetKind].doMakeEmpty();
|
|
268
|
+
// @ts-expect-error XXX narrowing from function overload
|
|
256
269
|
return harden({ brand, value });
|
|
257
270
|
},
|
|
258
271
|
/**
|
|
259
272
|
* Return the amount representing an empty amount, using another amount as the
|
|
260
273
|
* template for the brand and assetKind.
|
|
261
274
|
*
|
|
262
|
-
* @template {
|
|
263
|
-
* @param {
|
|
264
|
-
* @returns {
|
|
275
|
+
* @template {Amount} A
|
|
276
|
+
* @param {A} amount
|
|
277
|
+
* @returns {A}
|
|
265
278
|
*/
|
|
266
279
|
makeEmptyFromAmount: amount => {
|
|
267
280
|
assertRecord(amount, 'amount');
|
|
268
281
|
const { brand, value } = amount;
|
|
269
|
-
// @ts-expect-error cast
|
|
270
282
|
const assetKind = assertValueGetAssetKind(value);
|
|
271
|
-
// @ts-expect-error
|
|
283
|
+
// @ts-expect-error different subtype
|
|
272
284
|
return AmountMath.makeEmpty(brand, assetKind);
|
|
273
285
|
},
|
|
274
286
|
/**
|
|
@@ -291,10 +303,10 @@ const AmountMath = {
|
|
|
291
303
|
* Returns true if the leftAmount equals the rightAmount. We assume that if
|
|
292
304
|
* isGTE is true in both directions, isEqual is also true
|
|
293
305
|
*
|
|
294
|
-
* @template {
|
|
295
|
-
* @param {
|
|
296
|
-
* @param {
|
|
297
|
-
* @param {Brand
|
|
306
|
+
* @template {Amount} A
|
|
307
|
+
* @param {A} leftAmount
|
|
308
|
+
* @param {A} rightAmount
|
|
309
|
+
* @param {Brand} [brand]
|
|
298
310
|
* @returns {boolean}
|
|
299
311
|
*/
|
|
300
312
|
isEqual: (leftAmount, rightAmount, brand = undefined) => {
|
|
@@ -308,15 +320,16 @@ const AmountMath = {
|
|
|
308
320
|
* amount, it usually means including all of the elements from both left and
|
|
309
321
|
* right.
|
|
310
322
|
*
|
|
311
|
-
* @template {
|
|
312
|
-
* @param {
|
|
313
|
-
* @param {
|
|
314
|
-
* @param {Brand
|
|
315
|
-
* @returns {
|
|
323
|
+
* @template {Amount} A
|
|
324
|
+
* @param {A} leftAmount
|
|
325
|
+
* @param {A} rightAmount
|
|
326
|
+
* @param {Brand} [brand]
|
|
327
|
+
* @returns {A}
|
|
316
328
|
*/
|
|
317
329
|
add: (leftAmount, rightAmount, brand = undefined) => {
|
|
318
330
|
const h = checkLRAndGetHelpers(leftAmount, rightAmount, brand);
|
|
319
331
|
const value = h.doAdd(...coerceLR(h, leftAmount, rightAmount));
|
|
332
|
+
// @ts-expect-error different subtype
|
|
320
333
|
return harden({ brand: leftAmount.brand, value });
|
|
321
334
|
},
|
|
322
335
|
/**
|
|
@@ -326,25 +339,27 @@ const AmountMath = {
|
|
|
326
339
|
* error. Because the left amount must include the right amount, this is NOT
|
|
327
340
|
* equivalent to set subtraction.
|
|
328
341
|
*
|
|
329
|
-
* @template {
|
|
330
|
-
* @
|
|
331
|
-
* @param {
|
|
332
|
-
* @param {
|
|
333
|
-
* @
|
|
342
|
+
* @template {Amount} L
|
|
343
|
+
* @template {Amount} R
|
|
344
|
+
* @param {L} leftAmount
|
|
345
|
+
* @param {R} rightAmount
|
|
346
|
+
* @param {Brand} [brand]
|
|
347
|
+
* @returns {L extends R ? L : never}
|
|
334
348
|
*/
|
|
335
349
|
subtract: (leftAmount, rightAmount, brand = undefined) => {
|
|
336
350
|
const h = checkLRAndGetHelpers(leftAmount, rightAmount, brand);
|
|
337
351
|
const value = h.doSubtract(...coerceLR(h, leftAmount, rightAmount));
|
|
352
|
+
// @ts-expect-error different subtype
|
|
338
353
|
return harden({ brand: leftAmount.brand, value });
|
|
339
354
|
},
|
|
340
355
|
/**
|
|
341
356
|
* Returns the min value between x and y using isGTE
|
|
342
357
|
*
|
|
343
|
-
* @template {
|
|
344
|
-
* @param {
|
|
345
|
-
* @param {
|
|
346
|
-
* @param {Brand
|
|
347
|
-
* @returns {
|
|
358
|
+
* @template {Amount} A
|
|
359
|
+
* @param {A} x
|
|
360
|
+
* @param {A} y
|
|
361
|
+
* @param {Brand} [brand]
|
|
362
|
+
* @returns {A}
|
|
348
363
|
*/
|
|
349
364
|
min: (x, y, brand = undefined) =>
|
|
350
365
|
// eslint-disable-next-line no-nested-ternary
|
|
@@ -356,11 +371,11 @@ const AmountMath = {
|
|
|
356
371
|
/**
|
|
357
372
|
* Returns the max value between x and y using isGTE
|
|
358
373
|
*
|
|
359
|
-
* @template {
|
|
360
|
-
* @param {
|
|
361
|
-
* @param {
|
|
362
|
-
* @param {Brand
|
|
363
|
-
* @returns {
|
|
374
|
+
* @template {Amount} A
|
|
375
|
+
* @param {A} x
|
|
376
|
+
* @param {A} y
|
|
377
|
+
* @param {Brand} [brand]
|
|
378
|
+
* @returns {A}
|
|
364
379
|
*/
|
|
365
380
|
max: (x, y, brand = undefined) =>
|
|
366
381
|
// eslint-disable-next-line no-nested-ternary
|
|
@@ -376,7 +391,6 @@ harden(AmountMath);
|
|
|
376
391
|
const getAssetKind = amount => {
|
|
377
392
|
assertRecord(amount, 'amount');
|
|
378
393
|
const { value } = amount;
|
|
379
|
-
// @ts-expect-error cast (ignore b/c erroring in CI but not my IDE)
|
|
380
394
|
return assertValueGetAssetKind(value);
|
|
381
395
|
};
|
|
382
396
|
harden(getAssetKind);
|
package/src/issuerKit.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function prepareIssuerKit<K extends import("./types.js").AssetKind>(issue
|
|
|
11
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<{
|
|
12
12
|
elementShape: Pattern;
|
|
13
13
|
recoverySetsOption: RecoverySetsOption;
|
|
14
|
-
}> | undefined): IssuerKit<K>;
|
|
14
|
+
}> | undefined): IssuerKit<K, any>;
|
|
15
15
|
export type IssuerRecord<K extends import("./types.js").AssetKind> = {
|
|
16
16
|
name: string;
|
|
17
17
|
assetKind: K;
|
package/src/issuerKit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAFgB,CAAC,wDAVb,OAAO,kBAAkB,EAAE,OAAO,+HAyC5C;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAtBE,OAAO;;8BA4DzB;AAiCM,iCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAhFE,OAAO;;8BAkIzB;AAqCM,8BAFgB,CAAC,uDAXb,MAAM;kBA1JE,OAAO;;
|
|
1
|
+
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA4GO,iCAFgB,CAAC,wDAVb,OAAO,kBAAkB,EAAE,OAAO,+HAyC5C;AAQM,mCAFI,OAAO,kBAAkB,EAAE,OAAO,WAEgB;AAoDtD,qCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAtBE,OAAO;;8BA4DzB;AAiCM,iCAFgB,CAAC,wDAZb,OAAO,kBAAkB,EAAE,OAAO,QAClC,MAAM;kBAhFE,OAAO;;8BAkIzB;AAqCM,8BAFgB,CAAC,uDAXb,MAAM;kBA1JE,OAAO;;mCAsLvB;yBAtUW,CAAC;UADD,MAAM;eACN,CAAC;;kBAED,OAAO;;;;;;;;;;;;;;;;;mBA8IF,OAAO;;;yCAtJa,sBAAsB;wCAD0B,YAAY;+BAAZ,YAAY;2CAAZ,YAAY"}
|
package/src/issuerKit.js
CHANGED
|
@@ -325,7 +325,7 @@ harden(prepareIssuerKit);
|
|
|
325
325
|
* anything else is corrupted by that corrupted state. See
|
|
326
326
|
* https://github.com/Agoric/agoric-sdk/issues/3434
|
|
327
327
|
* @param {IssuerOptionsRecord} [options]
|
|
328
|
-
* @returns {IssuerKit<K>}
|
|
328
|
+
* @returns {IssuerKit<K, any>}
|
|
329
329
|
*/
|
|
330
330
|
export const makeIssuerKit = (
|
|
331
331
|
name,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function claim<
|
|
1
|
+
export function claim<P extends Payment>(recoveryPurse: ERef<Purse>, srcPaymentP: ERef<P>, optAmountShape?: Pattern): Promise<P>;
|
|
2
2
|
export function combine<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentsPs: ERef<Payment<K>>[], optTotalAmount?: Pattern): Promise<Payment<K>>;
|
|
3
3
|
export function split<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, paymentAmountA: Amount<K>): Promise<Payment<K>[]>;
|
|
4
4
|
export function splitMany<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, amounts: Amount<K>[]): Promise<Payment[]>;
|
|
5
|
-
import type {
|
|
5
|
+
import type { Payment } from './types.js';
|
|
6
6
|
import type { Purse } from './types.js';
|
|
7
7
|
import type { ERef } from '@endo/far';
|
|
8
|
-
import type {
|
|
8
|
+
import type { AssetKind } from './types.js';
|
|
9
9
|
import type { Amount } from './types.js';
|
|
10
10
|
//# sourceMappingURL=legacy-payment-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AAkCO,
|
|
1
|
+
{"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AAkCO,sBAFc,CAAC,qFADX,OAAO,GACL,OAAO,CAAC,CAAC,CAAC,CAYtB;AAiBM,wBAFsB,CAAC,uGADnB,OAAO,uBA2BjB;AAgBM,sBAFsB,CAAC,oIAY7B;AAgBM,0BAHW,CAAC,4HAqBlB;6BAzI0F,YAAY;2BAAZ,YAAY;0BADhF,WAAW;+BACyD,YAAY;4BAAZ,YAAY"}
|
|
@@ -26,11 +26,11 @@ const { Fail } = assert;
|
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @template {
|
|
30
|
-
* @param {ERef<Purse
|
|
31
|
-
* @param {ERef<
|
|
29
|
+
* @template {Payment} P
|
|
30
|
+
* @param {ERef<Purse>} recoveryPurse
|
|
31
|
+
* @param {ERef<P>} srcPaymentP
|
|
32
32
|
* @param {Pattern} [optAmountShape]
|
|
33
|
-
* @returns {Promise<
|
|
33
|
+
* @returns {Promise<P>}
|
|
34
34
|
*/
|
|
35
35
|
export const claim = async (
|
|
36
36
|
recoveryPurse,
|
|
@@ -38,6 +38,7 @@ export const claim = async (
|
|
|
38
38
|
optAmountShape = undefined,
|
|
39
39
|
) => {
|
|
40
40
|
const srcPayment = await srcPaymentP;
|
|
41
|
+
// @ts-expect-error XXX could be instantiated with a different subtype
|
|
41
42
|
return E.when(E(recoveryPurse).deposit(srcPayment, optAmountShape), amount =>
|
|
42
43
|
E(recoveryPurse).withdraw(amount),
|
|
43
44
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** @type {MathHelpers<import('@endo/patterns').CopyBag>} */
|
|
2
|
-
export const copyBagMathHelpers: MathHelpers<import("@endo/patterns").CopyBag<
|
|
2
|
+
export const copyBagMathHelpers: MathHelpers<import("@endo/patterns").CopyBag<import("@endo/patterns").Key>>;
|
|
3
3
|
import type { MathHelpers } from '../types.js';
|
|
4
4
|
//# sourceMappingURL=copyBagMathHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAkBA,4DAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAkBA,4DAA4D;AAC5D,6GAWG;iCAjB4B,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAsFO,qCAFoB,CAAC,gCAPjB,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,aAMU,CAAC,AALhB,6CAED,OAAO,qHA4TjB;+BA9XwH,YAAY;iCAAZ,YAAY;wCAAZ,YAAY;yCAC/F,sBAAsB;mCAD6D,YAAY"}
|
package/src/paymentLedger.js
CHANGED
|
@@ -15,6 +15,7 @@ import { BrandI, makeIssuerInterfaces } from './typeGuards.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* @import {Amount, AssetKind, DisplayInfo, PaymentLedger, Payment, Brand, RecoverySetsOption, Purse, Issuer, Mint} from './types.js'
|
|
17
17
|
* @import {ShutdownWithFailure} from '@agoric/swingset-vat'
|
|
18
|
+
* @import {Key} from '@endo/patterns';
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
const { details: X, quote: q, Fail } = assert;
|
|
@@ -93,11 +94,7 @@ export const preparePaymentLedger = (
|
|
|
93
94
|
optShutdownWithFailure = undefined,
|
|
94
95
|
) => {
|
|
95
96
|
/** @type {Brand<K>} */
|
|
96
|
-
//
|
|
97
|
-
// at-ts-expect-error XXX callWhen
|
|
98
|
-
// but ran into the usual disagreement between local lint and CI
|
|
99
|
-
|
|
100
|
-
// @ts-expect-error
|
|
97
|
+
// @ts-expect-error XXX callWhen
|
|
101
98
|
const brand = issuerZone.exo(`${name} brand`, BrandI, {
|
|
102
99
|
isMyIssuer(allegedIssuer) {
|
|
103
100
|
// BrandI delays calling this method until `allegedIssuer` is a Remotable
|
|
@@ -299,7 +296,7 @@ export const preparePaymentLedger = (
|
|
|
299
296
|
};
|
|
300
297
|
|
|
301
298
|
/** @type {() => Purse<K>} */
|
|
302
|
-
// @ts-expect-error
|
|
299
|
+
// @ts-expect-error XXX amount kinds
|
|
303
300
|
const makeEmptyPurse = preparePurseKind(
|
|
304
301
|
issuerZone,
|
|
305
302
|
name,
|
|
@@ -315,11 +312,7 @@ export const preparePaymentLedger = (
|
|
|
315
312
|
);
|
|
316
313
|
|
|
317
314
|
/** @type {Issuer<K>} */
|
|
318
|
-
//
|
|
319
|
-
// at-ts-expect-error cast due to callWhen discrepancy
|
|
320
|
-
// but ran into the usual disagreement between local lint and CI
|
|
321
|
-
|
|
322
|
-
// @ts-expect-error
|
|
315
|
+
// @ts-expect-error XXX callWhen
|
|
323
316
|
const issuer = issuerZone.exo(`${name} issuer`, IssuerI, {
|
|
324
317
|
getBrand() {
|
|
325
318
|
return brand;
|
|
@@ -374,11 +367,6 @@ export const preparePaymentLedger = (
|
|
|
374
367
|
* `makeIssuerKit` drops it on the floor, it can still be recovered in an
|
|
375
368
|
* emergency upgrade.
|
|
376
369
|
*/
|
|
377
|
-
// Should be
|
|
378
|
-
// at-ts-expect-error checked cast
|
|
379
|
-
// but ran into the usual disagreement between local lint and IDE lint.
|
|
380
|
-
// Don't know yet about lint under CI.
|
|
381
|
-
|
|
382
370
|
const mintRecoveryPurse = /** @type {Purse<K>} */ (
|
|
383
371
|
issuerZone.makeOnce('mintRecoveryPurse', () => makeEmptyPurse())
|
|
384
372
|
);
|
|
@@ -389,10 +377,6 @@ export const preparePaymentLedger = (
|
|
|
389
377
|
return issuer;
|
|
390
378
|
},
|
|
391
379
|
mintPayment(newAmount) {
|
|
392
|
-
// Should be
|
|
393
|
-
// at-ts-expect-error checked cast
|
|
394
|
-
// but ran into the usual disagreement between local lint and CI
|
|
395
|
-
|
|
396
380
|
newAmount = coerce(newAmount);
|
|
397
381
|
mustMatch(newAmount, amountShape, 'minted amount');
|
|
398
382
|
// `rawPayment` is not associated with any recovery set, and
|
package/src/purse.d.ts
CHANGED
|
@@ -7,18 +7,17 @@ export function preparePurseKind(issuerZone: import("@agoric/zone").Zone, name:
|
|
|
7
7
|
}, recoverySetsState: RecoverySetsOption, paymentRecoverySets: globalThis.WeakMapStore<Payment, globalThis.SetStore<Payment>>): () => import("@endo/exo").Guarded<{
|
|
8
8
|
deposit(srcPayment: any, optAmountShape?: undefined): any;
|
|
9
9
|
withdraw(amount: any): any;
|
|
10
|
-
getCurrentAmount():
|
|
10
|
+
getCurrentAmount(): import("./types.js").NatAmount | import("./types.js").CopySetAmount<import("@endo/patterns").Key> | import("./types.js").SetAmount<import("@endo/patterns").Key> | import("./types.js").CopyBagAmount<import("@endo/patterns").Key>;
|
|
11
11
|
getCurrentAmountNotifier(): import("@agoric/notifier").Notifier<any>;
|
|
12
12
|
getAllegedBrand(): Brand;
|
|
13
13
|
getDepositFacet(): import("@endo/exo").Guarded<{
|
|
14
14
|
receive(...args: any[]): any;
|
|
15
15
|
}>;
|
|
16
|
-
getRecoverySet(): import("@endo/patterns").CopySet<
|
|
17
|
-
recoverAll():
|
|
16
|
+
getRecoverySet(): import("@endo/patterns").CopySet<any>;
|
|
17
|
+
recoverAll(): import("./types.js").NatAmount | import("./types.js").CopySetAmount<import("@endo/patterns").Key> | import("./types.js").SetAmount<import("@endo/patterns").Key> | import("./types.js").CopyBagAmount<import("@endo/patterns").Key>;
|
|
18
18
|
}>;
|
|
19
19
|
import type { AssetKind } from './types.js';
|
|
20
20
|
import type { Brand } from './types.js';
|
|
21
21
|
import type { RecoverySetsOption } from './types.js';
|
|
22
22
|
import type { Payment } from './types.js';
|
|
23
|
-
import type { Amount } from './types.js';
|
|
24
23
|
//# sourceMappingURL=purse.d.ts.map
|
package/src/purse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AA4BO,6CAfI,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,iDAGN;IACV,KAAS,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,YAAgB,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC5D,gBACO;IACV,eAAmB,EAAE,GAAG,CAAC;IACzB,gBAAoB,EAAE,GAAG,CAAC;CACvB;;;;;;;;;;;GA8JH;+BAjLwG,YAAY;2BAAZ,YAAY;wCAAZ,YAAY;6BAAZ,YAAY
|
|
1
|
+
{"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AA4BO,6CAfI,OAAO,cAAc,EAAE,IAAI,QAC3B,MAAM,iDAGN;IACV,KAAS,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,YAAgB,EAAE,OAAO,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC5D,gBACO;IACV,eAAmB,EAAE,GAAG,CAAC;IACzB,gBAAoB,EAAE,GAAG,CAAC;CACvB;;;;;;;;;;;GA8JH;+BAjLwG,YAAY;2BAAZ,YAAY;wCAAZ,YAAY;6BAAZ,YAAY"}
|