@agoric/ertp 0.18.0-u23.0 → 0.18.0-u23.1
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 +6 -6
- package/src/amountMath.d.ts +61 -0
- package/src/amountMath.d.ts.map +1 -0
- package/src/amountStore.d.ts +9 -0
- package/src/amountStore.d.ts.map +1 -0
- package/src/displayInfo.d.ts +5 -0
- package/src/displayInfo.d.ts.map +1 -0
- package/src/index.d.ts +5 -0
- package/src/index.d.ts.map +1 -0
- package/src/issuerKit.d.ts +39 -0
- package/src/issuerKit.d.ts.map +1 -0
- package/src/legacy-payment-helpers.d.ts +12 -0
- package/src/legacy-payment-helpers.d.ts.map +1 -0
- package/src/mathHelpers/copyBagMathHelpers.d.ts +5 -0
- package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -0
- package/src/mathHelpers/copySetMathHelpers.d.ts +5 -0
- package/src/mathHelpers/copySetMathHelpers.d.ts.map +1 -0
- package/src/mathHelpers/natMathHelpers.d.ts +15 -0
- package/src/mathHelpers/natMathHelpers.d.ts.map +1 -0
- package/src/mathHelpers/setMathHelpers.d.ts +8 -0
- package/src/mathHelpers/setMathHelpers.d.ts.map +1 -0
- package/src/payment.d.ts +7 -0
- package/src/payment.d.ts.map +1 -0
- package/src/paymentLedger.d.ts +9 -0
- package/src/paymentLedger.d.ts.map +1 -0
- package/src/purse.d.ts +27 -0
- package/src/purse.d.ts.map +1 -0
- package/src/ratio.d.ts +48 -0
- package/src/ratio.d.ts.map +1 -0
- package/src/safeMath.d.ts +11 -0
- package/src/safeMath.d.ts.map +1 -0
- package/src/transientNotifier.d.ts +5 -0
- package/src/transientNotifier.d.ts.map +1 -0
- package/src/typeGuards.d.ts +96 -0
- package/src/typeGuards.d.ts.map +1 -0
- package/src/types.d.ts +410 -0
- package/src/types.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/ertp",
|
|
3
|
-
"version": "0.18.0-u23.
|
|
3
|
+
"version": "0.18.0-u23.1",
|
|
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,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@agoric/notifier": "0.8.0-u23.
|
|
42
|
+
"@agoric/notifier": "0.8.0-u23.1",
|
|
43
43
|
"@agoric/store": "0.11.0-u23.0",
|
|
44
|
-
"@agoric/vat-data": "0.7.0-u23.
|
|
45
|
-
"@agoric/zone": "0.4.0-u23.
|
|
44
|
+
"@agoric/vat-data": "0.7.0-u23.1",
|
|
45
|
+
"@agoric/zone": "0.4.0-u23.1",
|
|
46
46
|
"@endo/errors": "^1.2.13",
|
|
47
47
|
"@endo/eventual-send": "^1.3.4",
|
|
48
48
|
"@endo/far": "^1.1.14",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@endo/promise-kit": "^1.1.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@agoric/swingset-vat": "0.34.0-u23.
|
|
55
|
+
"@agoric/swingset-vat": "0.34.0-u23.1",
|
|
56
56
|
"@endo/bundle-source": "^4.1.2",
|
|
57
57
|
"@fast-check/ava": "^1.1.5",
|
|
58
58
|
"ava": "^6.4.1",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"typeCoverage": {
|
|
78
78
|
"atLeast": 92.99
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "6a6343510742fef366aa7b4a31a862f9ef409656"
|
|
81
81
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for the kinds of assets we support.
|
|
3
|
+
*/
|
|
4
|
+
export type AssetKind = (typeof AssetKind)[keyof typeof AssetKind];
|
|
5
|
+
export namespace AssetKind {
|
|
6
|
+
let NAT: "nat";
|
|
7
|
+
let SET: "set";
|
|
8
|
+
let COPY_SET: "copySet";
|
|
9
|
+
let COPY_BAG: "copyBag";
|
|
10
|
+
}
|
|
11
|
+
export function assertAssetKind(allegedAK: AssetKind): void;
|
|
12
|
+
export function assertValueGetHelpers<V extends AmountValue>(value: V): MathHelpers<V>;
|
|
13
|
+
export namespace AmountMath {
|
|
14
|
+
export function make<B extends Brand<any>, V extends NatValue | CopySet | CopyBag | SetValue>(brand: B, allegedValue: V): B extends Brand<"nat"> ? NatAmount : V extends NatValue ? NatAmount : V extends CopySet ? CopySetAmount<V["payload"][0]> : V extends CopyBag ? CopyBagAmount<V["payload"][0][0]> : V extends SetValue ? SetAmount<V[0]> : never;
|
|
15
|
+
export function coerce<A extends Amount>(brand: Brand, allegedAmount: A): A;
|
|
16
|
+
export function getValue<A extends Amount>(brand: Brand, amount: A): A["value"];
|
|
17
|
+
export let makeEmpty: {
|
|
18
|
+
(brand: Brand): Amount<"nat">;
|
|
19
|
+
<K extends AssetKind>(brand: Brand<K>, assetKind: K): Amount<K>;
|
|
20
|
+
};
|
|
21
|
+
export function makeEmptyFromAmount<A extends Amount>(amount: A): A;
|
|
22
|
+
export function isEmpty(amount: Amount, brand?: Brand): boolean;
|
|
23
|
+
export { isGTE };
|
|
24
|
+
export function isEqual<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand): boolean;
|
|
25
|
+
export let add: {
|
|
26
|
+
<A extends CopyBag, B extends CopyBag>(leftAmount: CopyBagAmount<A>, rightAmount: CopyBagAmount<B>, brand?: Brand): CopyBagAmount<A | B>;
|
|
27
|
+
<A extends Amount>(leftAmount: A, rightAmount: A, brand?: Brand): A;
|
|
28
|
+
};
|
|
29
|
+
export function subtract<L extends Amount, R extends Amount>(leftAmount: L, rightAmount: R, brand?: Brand): L extends R ? L : never;
|
|
30
|
+
export function min<A extends Amount>(x: A, y: A, brand?: Brand): A;
|
|
31
|
+
export function max<A extends Amount>(x: A, y: A, brand?: Brand): A;
|
|
32
|
+
}
|
|
33
|
+
export function getAssetKind(amount: Amount): "copySet" | "set" | "copyBag" | "nat";
|
|
34
|
+
import type { AmountValue } from './types.js';
|
|
35
|
+
import type { MathHelpers } from './types.js';
|
|
36
|
+
import type { Brand } from './types.js';
|
|
37
|
+
import type { NatValue } from './types.js';
|
|
38
|
+
import type { CopySet } from '@endo/patterns';
|
|
39
|
+
import type { CopyBag } from '@endo/patterns';
|
|
40
|
+
import type { SetValue } from './types.js';
|
|
41
|
+
import type { NatAmount } from './types.js';
|
|
42
|
+
import type { CopySetAmount } from './types.js';
|
|
43
|
+
import type { CopyBagAmount } from './types.js';
|
|
44
|
+
import type { SetAmount } from './types.js';
|
|
45
|
+
import type { Amount } from './types.js';
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if the leftAmount is greater than or equal to the rightAmount.
|
|
48
|
+
* The notion of "greater than or equal to" depends on the kind of amount, as
|
|
49
|
+
* defined by the MathHelpers. For example, whether rectangle A is greater than
|
|
50
|
+
* rectangle B depends on whether rectangle A includes rectangle B as defined by
|
|
51
|
+
* the logic in MathHelpers.
|
|
52
|
+
*
|
|
53
|
+
* @template {AssetKind} K
|
|
54
|
+
* @param {Amount<K>} leftAmount
|
|
55
|
+
* @param {Amount<K>} rightAmount
|
|
56
|
+
* @param {Brand<K>} [brand]
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
declare function isGTE<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K>): boolean;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=amountMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":";;;wBAkBU,CAAC,OAAO,SAAS,EAAE,MAAM,OAAO,SAAS,CAAC;;;;;;;AAY7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AC5B,WAAW,EAAE,cAAc,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE,KAAK,GACZ,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAK,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;KACrE;IAqBM,yBAPY,CAAC,SAAV,MAAQ,EACC,CAAC,SAAV,MAAQ,cACV,CAAC,eACD,CAAC,UACD,KAAK,GACH,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAOnC;IAUI,oBANiB,CAAC,SAAV,MAAQ,KACV,CAAC,KACD,CAAC,UACD,KAAK,GACH,CAAC,CAO8B;IAUvC,oBANiB,CAAC,SAAV,MAAQ,KACV,CAAC,KACD,CAAC,UACD,KAAK,GACH,CAAC,CAO8B;;AAKvC,qCADK,MAAM,yCAKjB;iCA7XoJ,YAAY;iCAAZ,YAAY;2BAAZ,YAAY;8BAAZ,YAAY;6BAD9H,gBAAgB;6BAAhB,gBAAgB;8BACkG,YAAY;+BAAZ,YAAY;mCAAZ,YAAY;mCAAZ,YAAY;+BAAZ,YAAY;4BAAZ,YAAY;AA4JjK;;;;;;;;;;;;GAYG;AACH,uBANyB,CAAC,SAAZ,SAAU,cACb,OAAO,CAAC,CAAC,eACT,OAAO,CAAC,CAAC,UACT,MAAM,CAAC,CAAC,GACN,OAAO,CAKnB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function makeAmountStore<K extends AssetKind = AssetKind>(state: object, key: string): AmountStore<K>;
|
|
2
|
+
export type AmountStore<K extends AssetKind = AssetKind> = {
|
|
3
|
+
getAmount: () => Amount<K>;
|
|
4
|
+
increment: (delta: Amount<K>) => void;
|
|
5
|
+
decrement: (delta: Amount<K>) => boolean;
|
|
6
|
+
};
|
|
7
|
+
import type { AssetKind } from './types.js';
|
|
8
|
+
import type { Amount } from './types.js';
|
|
9
|
+
//# sourceMappingURL=amountStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amountStore.d.ts","sourceRoot":"","sources":["amountStore.js"],"names":[],"mappings":"AAkBO,gCALmB,CAAC,SAAd,SAAW,qBACb,MAAM,OACN,MAAM,GACJ,WAAW,CAAC,CAAC,CAAC,CAgB1B;wBA3ByB,CAAC,SAAd,SAAW;eAEV,MAAM,OAAO,CAAC,CAAC;eACf,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI;eAC1B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO;;+BAPN,YAAY;4BAAZ,YAAY"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function coerceDisplayInfo(allegedDisplayInfo: AdditionalDisplayInfo, assetKind: AssetKind): DisplayInfo;
|
|
2
|
+
import type { AdditionalDisplayInfo } from './types.js';
|
|
3
|
+
import type { AssetKind } from './types.js';
|
|
4
|
+
import type { DisplayInfo } from './types.js';
|
|
5
|
+
//# sourceMappingURL=displayInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"displayInfo.d.ts","sourceRoot":"","sources":["displayInfo.js"],"names":[],"mappings":"AAYO,sDAJI,qBAAqB,aACrB,SAAS,GACP,WAAW,CAiBvB;2CAtBgE,YAAY;+BAAZ,YAAY;iCAAZ,YAAY"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function upgradeIssuerKit<K extends AssetKind>(issuerBaggage: Baggage, optShutdownWithFailure?: ShutdownWithFailure, recoverySetsOption?: RecoverySetsOption): IssuerKit<K>;
|
|
2
|
+
export function hasIssuer(baggage: Baggage): boolean;
|
|
3
|
+
export function makeDurableIssuerKit<K extends AssetKind>(issuerBaggage: Baggage, name: string, assetKind?: K, displayInfo?: AdditionalDisplayInfo, optShutdownWithFailure?: ShutdownWithFailure, { elementShape, recoverySetsOption }?: IssuerOptionsRecord): IssuerKit<K>;
|
|
4
|
+
export function prepareIssuerKit<O extends IssuerOptionsRecord, K extends AssetKind>(issuerBaggage: Baggage, name: string, assetKind?: K, displayInfo?: AdditionalDisplayInfo, optShutdownWithFailure?: ShutdownWithFailure, options?: O): O["elementShape"] extends TypedPattern<infer T extends Key> ? IssuerKit<K, T> : IssuerKit<K>;
|
|
5
|
+
export function makeIssuerKit<K extends AssetKind = "nat", O extends IssuerOptionsRecord = {}>(name: string, assetKind?: K, displayInfo?: AdditionalDisplayInfo, optShutdownWithFailure?: ShutdownWithFailure, { elementShape, recoverySetsOption }?: O): O["elementShape"] extends TypedPattern<infer T extends Key> ? IssuerKit<K, T> : IssuerKit<K>;
|
|
6
|
+
export type IssuerRecord<K extends AssetKind> = {
|
|
7
|
+
name: string;
|
|
8
|
+
assetKind: K;
|
|
9
|
+
displayInfo: AdditionalDisplayInfo;
|
|
10
|
+
elementShape: Pattern;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* `elementShape`, may only be present for collection-style amounts. If present,
|
|
14
|
+
* it is a `Pattern` that every element of this issuerKits's amounts must
|
|
15
|
+
* satisfy. For example, the Zoe Invitation issuerKit uses an elementShape
|
|
16
|
+
* describing the invitation details for an individual invitation. An invitation
|
|
17
|
+
* purse or payment has an amount that can only be a set of these. (Though
|
|
18
|
+
* typically, the amount of an invitation payment is a singleton set. Such a
|
|
19
|
+
* payment is often referred to in the singular as "an invitation".)
|
|
20
|
+
*
|
|
21
|
+
* `recoverySetsOption` added in upgrade. Note that `IssuerOptionsRecord` is
|
|
22
|
+
* never stored, so we never need to worry about inheriting one from a
|
|
23
|
+
* predecessor predating the introduction of recovery sets. See
|
|
24
|
+
* `RecoverySetsOption` for defaulting behavior.
|
|
25
|
+
*/
|
|
26
|
+
export type IssuerOptionsRecord = Partial<{
|
|
27
|
+
elementShape: Pattern;
|
|
28
|
+
recoverySetsOption: RecoverySetsOption;
|
|
29
|
+
}>;
|
|
30
|
+
import { AssetKind } from './amountMath.js';
|
|
31
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
32
|
+
import type { ShutdownWithFailure } from '@agoric/swingset-vat';
|
|
33
|
+
import type { RecoverySetsOption } from './types.js';
|
|
34
|
+
import type { IssuerKit } from './types.js';
|
|
35
|
+
import type { AdditionalDisplayInfo } from './types.js';
|
|
36
|
+
import type { Key } from '@endo/patterns';
|
|
37
|
+
import type { TypedPattern } from '@agoric/internal';
|
|
38
|
+
import type { Pattern } from '@endo/patterns';
|
|
39
|
+
//# sourceMappingURL=issuerKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AAgHO,iCAbkB,CAAC,SAAZ,SAAU,iBACb,OAAO,2BACP,mBAAmB,uBAOnB,kBAAkB,GAEhB,UAAU,CAAC,CAAC,CA4BxB;AAQM,mCAFI,OAAO,WAE2C;AAoDtD,qCA1BkB,CAAC,SAAZ,SAAU,iBAYb,OAAO,QACP,MAAM,cACN,CAAC,gBACD,qBAAqB,2BACrB,mBAAmB,yCAOnB,mBAAmB,GACjB,UAAU,CAAC,CAAC,CA2BxB;AAoCM,iCA7B4B,CAAC,SAAtB,mBAAoB,EACT,CAAC,SAAZ,SAAU,iBAYb,OAAO,QACP,MAAM,cACN,CAAC,gBACD,qBAAqB,2BACrB,mBAAmB,YAOnB,CAAC,GACC,CAAC,CAAC,cAAc,CAAC,SAAS,aAAa,MAAM,CAAC,SAAS,GAAG,CAAC,GAC/D,UAAU,CAAC,EAAE,CAAC,CAAC,GACf,UAAU,CAAC,CAAC,CAyCpB;AAqCM,8BAzBmB,CAAC,SAAb,SAAU,UACY,CAAC,SAAvB,mBAAoB,aACvB,MAAM,cAMN,CAAC,gBAGD,qBAAqB,2BAErB,mBAAmB,yCAOnB,CAAC,GACC,CAAC,CAAC,cAAc,CAAC,SAAS,aAAa,MAAM,CAAC,SAAS,GAAG,CAAC,GAC/D,UAAU,CAAC,EAAE,CAAC,CAAC,GACf,UAAU,CAAC,CAAC,CAmBlB;yBA7UsB,CAAC,SAAZ,SAAU;UAEV,MAAM;eACN,CAAC;iBACD,qBAAqB;kBACrB,OAAO;;;;;;;;;;;;;;;;kCA0IR,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;0BAhKsC,iBAAiB;6BASlC,kBAAkB;yCAFN,sBAAsB;wCAG0B,YAAY;+BAAZ,YAAY;2CAAZ,YAAY;yBALnE,gBAAgB;kCAGhB,kBAAkB;6BAHlB,gBAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function claim<K extends AssetKind, T extends Key>(recoveryPurse: ERef<Purse<K, T>>, srcPaymentP: ERef<Payment<K, T>>, optAmountShape?: Pattern): Promise<Payment<K, T>>;
|
|
2
|
+
export function combine<K extends AssetKind, T extends Key>(recoveryPurse: ERef<Purse<K, T>>, srcPaymentsPs: ERef<Payment<K, T>>[], optTotalAmount?: Pattern): Promise<Payment<K, T>>;
|
|
3
|
+
export function split<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, paymentAmountA: Amount<K>): Promise<Payment<K>[]>;
|
|
4
|
+
export function splitMany<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, amounts: Amount<K>[]): Promise<Payment[]>;
|
|
5
|
+
import type { AssetKind } from './types.js';
|
|
6
|
+
import type { Key } from '@endo/patterns';
|
|
7
|
+
import type { Purse } from './types.js';
|
|
8
|
+
import type { ERef } from '@endo/far';
|
|
9
|
+
import type { Payment } from './types.js';
|
|
10
|
+
import type { Pattern } from '@endo/patterns';
|
|
11
|
+
import type { Amount } from './types.js';
|
|
12
|
+
//# sourceMappingURL=legacy-payment-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AAiCO,sBAPkB,CAAC,SAAb,SAAW,EACL,CAAC,SAAP,GAAK,iBACP,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,eACjB,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,mBACnB,OAAO,GACL,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAWlC;AAkBM,wBAPkB,CAAC,SAAb,SAAW,EACL,CAAC,SAAP,GAAK,iBACP,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,iBACjB,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,mBACrB,OAAO,GACL,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CA8BlC;AAgBM,sBANkB,CAAC,SAAb,SAAW,iBACb,KAAK,MAAM,CAAC,CAAC,CAAC,eACd,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAChB,OAAO,CAAC,CAAC,GACP,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAYjC;AAgBM,0BANkB,CAAC,SAAb,SAAW,iBACb,KAAK,MAAM,CAAC,CAAC,CAAC,eACd,KAAK,QAAQ,CAAC,CAAC,CAAC,WAChB,OAAO,CAAC,CAAC,EAAE,GACT,OAAO,CAAC,OAAO,EAAE,CAAC,CAoB9B;+BA5ImD,YAAY;yBADjC,gBAAgB;2BACK,YAAY;0BAFzC,WAAW;6BAEkB,YAAY;6BADjC,gBAAgB;4BACK,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAmBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B;6BAlBuB,gBAAgB;iCADZ,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copySetMathHelpers.d.ts","sourceRoot":"","sources":["copySetMathHelpers.js"],"names":[],"mappings":"AAmBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B;6BAlBuB,gBAAgB;iCADZ,aAAa"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fungible digital assets use the natMathHelpers to manage balances - the
|
|
3
|
+
* operations are merely arithmetic on natural, non-negative numbers.
|
|
4
|
+
*
|
|
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.
|
|
9
|
+
*
|
|
10
|
+
* @type {MathHelpers<NatValue>}
|
|
11
|
+
*/
|
|
12
|
+
export const natMathHelpers: MathHelpers<NatValue>;
|
|
13
|
+
import type { NatValue } from '../types.js';
|
|
14
|
+
import type { MathHelpers } from '../types.js';
|
|
15
|
+
//# sourceMappingURL=natMathHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"natMathHelpers.d.ts","sourceRoot":"","sources":["natMathHelpers.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,6BAFU,YAAY,QAAQ,CAAC,CAgB5B;8BA7BsC,aAAa;iCAAb,aAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Replace array-based SetMath with CopySet-based CopySetMath
|
|
3
|
+
* @type {MathHelpers<SetValue>}
|
|
4
|
+
*/
|
|
5
|
+
export const setMathHelpers: MathHelpers<SetValue>;
|
|
6
|
+
import type { SetValue } from '../types.js';
|
|
7
|
+
import type { MathHelpers } from '../types.js';
|
|
8
|
+
//# sourceMappingURL=setMathHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setMathHelpers.d.ts","sourceRoot":"","sources":["setMathHelpers.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,6BAFU,YAAY,QAAQ,CAAC,CAkB5B;8BA3BsC,aAAa;iCAAb,aAAa"}
|
package/src/payment.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function preparePaymentKind<K extends AssetKind>(issuerZone: Zone, name: string, brand: Brand<K>, PaymentI: InterfaceGuard<any>): () => Payment<K, any>;
|
|
2
|
+
import type { AssetKind } from './types.js';
|
|
3
|
+
import type { Zone } from '@agoric/zone';
|
|
4
|
+
import type { Brand } from './types.js';
|
|
5
|
+
import type { InterfaceGuard } from '@endo/patterns';
|
|
6
|
+
import type { Payment } from './types.js';
|
|
7
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["payment.js"],"names":[],"mappings":"AAiBO,mCAPkB,CAAC,SAAb,SAAW,cACb,IAAI,QACJ,MAAM,SACN,MAAM,CAAC,CAAC,YACR,eAAe,GAAG,CAAC,GACjB,MAAM,QAAQ,CAAC,EAAE,GAAG,CAAC,CAejC;+BA3B2C,YAAY;0BACjC,cAAc;2BADO,YAAY;oCAEvB,gBAAgB;6BAFL,YAAY"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function preparePaymentLedger<K extends AssetKind>(issuerZone: Zone, name: string, assetKind: K, displayInfo: DisplayInfo<K>, elementShape: Pattern, recoverySetsState: RecoverySetsOption, optShutdownWithFailure?: ShutdownWithFailure): PaymentLedger<K>;
|
|
2
|
+
import type { AssetKind } from './types.js';
|
|
3
|
+
import type { Zone } from '@agoric/base-zone';
|
|
4
|
+
import type { DisplayInfo } from './types.js';
|
|
5
|
+
import type { Pattern } from '@endo/patterns';
|
|
6
|
+
import type { RecoverySetsOption } from './types.js';
|
|
7
|
+
import type { ShutdownWithFailure } from '@agoric/swingset-vat';
|
|
8
|
+
import type { PaymentLedger } from './types.js';
|
|
9
|
+
//# sourceMappingURL=paymentLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAqFO,qCAVkB,CAAC,SAAb,SAAW,cACb,IAAI,QACJ,MAAM,aACN,CAAC,eACD,YAAY,CAAC,CAAC,gBACd,OAAO,qBACP,kBAAkB,2BAClB,mBAAmB,GACjB,cAAc,CAAC,CAAC,CAyT5B;+BA9XwH,YAAY;0BAJ9G,mBAAmB;iCAI+E,YAAY;6BALtG,gBAAgB;wCAK0E,YAAY;yCAF/F,sBAAsB;mCAE6D,YAAY"}
|
package/src/purse.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function preparePurseKind(issuerZone: Zone, name: string, assetKind: AssetKind, brand: Brand, PurseIKit: {
|
|
2
|
+
purse: InterfaceGuard<any>;
|
|
3
|
+
depositFacet: InterfaceGuard<any>;
|
|
4
|
+
}, purseMethods: {
|
|
5
|
+
depositInternal: any;
|
|
6
|
+
withdrawInternal: any;
|
|
7
|
+
}, recoverySetsState: RecoverySetsOption, paymentRecoverySets: WeakMapStore<Payment, SetStore<Payment>>): () => import("@endo/exo").Guarded<{
|
|
8
|
+
deposit(srcPayment: any, optAmountShape?: undefined): any;
|
|
9
|
+
withdraw(amount: any): any;
|
|
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
|
+
getCurrentAmountNotifier(): import("@agoric/notifier").Notifier<any>;
|
|
12
|
+
getAllegedBrand(): Brand;
|
|
13
|
+
getDepositFacet(): import("@endo/exo").Guarded<{
|
|
14
|
+
receive(...args: any[]): any;
|
|
15
|
+
}>;
|
|
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
|
+
}>;
|
|
19
|
+
import type { Zone } from '@agoric/zone';
|
|
20
|
+
import type { AssetKind } from './types.js';
|
|
21
|
+
import type { Brand } from './types.js';
|
|
22
|
+
import type { InterfaceGuard } from '@endo/patterns';
|
|
23
|
+
import type { RecoverySetsOption } from './types.js';
|
|
24
|
+
import type { Payment } from './types.js';
|
|
25
|
+
import type { SetStore } from '@agoric/store';
|
|
26
|
+
import type { WeakMapStore } from '@agoric/store';
|
|
27
|
+
//# sourceMappingURL=purse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AAiCO,6CAfI,IAAI,QACJ,MAAM,aACN,SAAS,SACT,KAAK,aACL;IACN,KAAK,EAAE,eAAe,GAAG,CAAC,CAAC;IAC3B,YAAY,EAAE,eAAe,GAAG,CAAC,CAAC;CACnC,gBACO;IACN,eAAe,EAAE,GAAG,CAAC;IACrB,gBAAgB,EAAE,GAAG,CAAC;CACvB,qBACO,kBAAkB,uBAClB,aAAa,OAAO,EAAE,SAAS,OAAO,CAAC,CAAC;;;;;;;;;;;GA4JlD;0BAnLsB,cAAc;+BAD2B,YAAY;2BAAZ,YAAY;oCAE3C,gBAAgB;wCAFe,YAAY;6BAAZ,YAAY;8BAIjD,eAAe;kCADX,eAAe"}
|
package/src/ratio.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function assertIsRatio(ratio: any): void;
|
|
2
|
+
export function makeRatio(numerator: bigint, numeratorBrand: Brand, denominator?: bigint, denominatorBrand?: Brand): Ratio;
|
|
3
|
+
export function makeRatioFromAmounts(numeratorAmount: Amount, denominatorAmount: Amount): Ratio;
|
|
4
|
+
/** @type {ScaleAmount} */
|
|
5
|
+
export const floorMultiplyBy: ScaleAmount;
|
|
6
|
+
/** @type {ScaleAmount} */
|
|
7
|
+
export const ceilMultiplyBy: ScaleAmount;
|
|
8
|
+
/** @type {ScaleAmount} */
|
|
9
|
+
export const multiplyBy: ScaleAmount;
|
|
10
|
+
/**
|
|
11
|
+
* Divide the amount by the ratio, truncating the remainder.
|
|
12
|
+
*
|
|
13
|
+
* @type {ScaleAmount}
|
|
14
|
+
*/
|
|
15
|
+
export const floorDivideBy: ScaleAmount;
|
|
16
|
+
/**
|
|
17
|
+
* Divide the amount by the ratio, rounding up the remainder.
|
|
18
|
+
*
|
|
19
|
+
* @type {ScaleAmount}
|
|
20
|
+
*/
|
|
21
|
+
export const ceilDivideBy: ScaleAmount;
|
|
22
|
+
/**
|
|
23
|
+
* Divide the amount by the ratio, rounding to nearest with ties to even (aka
|
|
24
|
+
* Banker's Rounding) as in IEEE 754 default rounding.
|
|
25
|
+
*
|
|
26
|
+
* @type {ScaleAmount}
|
|
27
|
+
*/
|
|
28
|
+
export const divideBy: ScaleAmount;
|
|
29
|
+
export function invertRatio(ratio: Ratio): Ratio;
|
|
30
|
+
export function addRatios(left: Ratio, right: Ratio): Ratio;
|
|
31
|
+
export function subtractRatios(left: Ratio, right: Ratio): Ratio;
|
|
32
|
+
export function multiplyRatios(left: Ratio, right: Ratio): Ratio;
|
|
33
|
+
export function oneMinus(ratio: Ratio): Ratio;
|
|
34
|
+
export function ratioGTE(left: Ratio, right: Ratio): boolean;
|
|
35
|
+
export function ratiosSame(left: Ratio, right: Ratio): boolean;
|
|
36
|
+
export function quantize(ratio: Ratio, newDen: bigint): Ratio;
|
|
37
|
+
export function parseRatio(numeric: ParsableNumber, numeratorBrand: Brand<"nat">, denominatorBrand?: Brand<"nat">): Ratio;
|
|
38
|
+
export function assertParsableNumber(specimen: unknown): asserts specimen is ParsableNumber;
|
|
39
|
+
export function ratioToNumber(ratio: Ratio): number;
|
|
40
|
+
export type Ratio = {
|
|
41
|
+
numerator: Amount<"nat">;
|
|
42
|
+
denominator: Amount<"nat">;
|
|
43
|
+
};
|
|
44
|
+
export type ScaleAmount = (amount: Amount<"nat">, ratio: Ratio) => Amount<"nat">;
|
|
45
|
+
export type ParsableNumber = bigint | number | string;
|
|
46
|
+
import type { Brand } from '@agoric/ertp';
|
|
47
|
+
import type { Amount } from '@agoric/ertp';
|
|
48
|
+
//# sourceMappingURL=ratio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ratio.d.ts","sourceRoot":"","sources":["ratio.js"],"names":[],"mappings":"AAwDO,gDAcN;AASM,qCANI,MAAM,kBACN,KAAK,gBACL,MAAM,qBACN,KAAK,GACH,KAAK,CAejB;AAOM,sDAJI,MAAM,qBACN,MAAM,GACJ,KAAK,CAYjB;AA2BD,0BAA0B;AAC1B,8BADW,WAAW,CAGpB;AAEF,0BAA0B;AAC1B,6BADW,WAAW,CAGpB;AAEF,0BAA0B;AAC1B,yBADW,WAAW,CAGpB;AA2BF;;;;GAIG;AACH,4BAFU,WAAW,CAInB;AAEF;;;;GAIG;AACH,2BAFU,WAAW,CAInB;AAEF;;;;;GAKG;AACH,uBAFU,WAAW,CAInB;AAMK,mCAHI,KAAK,GACH,KAAK,CAWjB;AAOM,gCAJI,KAAK,SACL,KAAK,GACH,KAAK,CAwBjB;AAOM,qCAJI,KAAK,SACL,KAAK,GACH,KAAK,CAmBjB;AAOM,qCAJI,KAAK,SACL,KAAK,GACH,KAAK,CA8BjB;AAQM,gCAHI,KAAK,GACH,KAAK,CAcjB;AAOM,+BAJI,KAAK,SACL,KAAK,GACH,OAAO,CAkBnB;AAUM,iCAJI,KAAK,SACL,KAAK,GACH,OAAO,CAOnB;AAWM,gCAJI,KAAK,UACL,MAAM,GACJ,KAAK,CAiBjB;AAaM,oCALI,cAAc,kBACd,MAAM,KAAK,CAAC,qBACZ,MAAM,KAAK,CAAC,GACV,KAAK,CAmBjB;AAMM,+CAHI,OAAO,GACL,QAAQ,QAAQ,IAAI,cAAc,CAK9C;AAQM,qCAHI,KAAK,GACH,MAAM,CAMlB;;eAxaa,OAAO,KAAK,CAAC;iBACb,OAAO,KAAK,CAAC;;mCAKhB,OAAO,KAAK,CAAC,SACb,KAAK,KACH,OAAO,KAAK,CAAC;6BAgXZ,MAAM,GAAG,MAAM,GAAG,MAAM;2BAhYkB,cAAc;4BAAd,cAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export namespace natSafeMath {
|
|
2
|
+
let add: NatOp;
|
|
3
|
+
let subtract: NatOp;
|
|
4
|
+
let multiply: NatOp;
|
|
5
|
+
let floorDivide: NatOp;
|
|
6
|
+
let ceilDivide: NatOp;
|
|
7
|
+
let bankersDivide: NatOp;
|
|
8
|
+
let isGTE: (x: number | bigint, y: number | bigint) => boolean;
|
|
9
|
+
}
|
|
10
|
+
export type NatOp = (x: number | bigint, y: number | bigint) => bigint;
|
|
11
|
+
//# sourceMappingURL=safeMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeMath.d.ts","sourceRoot":"","sources":["safeMath.js"],"names":[],"mappings":";aAYa,KAAK;kBAGL,KAAK;kBAEL,KAAK;qBAEL,KAAK;oBAEL,KAAK;uBASN,KAAK;eAiBJ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO;;oBA7ClD,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transientNotifier.d.ts","sourceRoot":"","sources":["transientNotifier.js"],"names":[],"mappings":"AAYO;;;EAoBN"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {AmountValue, Ratio} from './types.js'
|
|
3
|
+
* @import {TypedPattern} from '@agoric/internal'
|
|
4
|
+
* @import {CopyBag, CopySet, Pattern} from '@endo/patterns';
|
|
5
|
+
* @import {NatValue, SetValue} from './types.js';
|
|
6
|
+
*/
|
|
7
|
+
export const BrandShape: import("@endo/patterns").Matcher;
|
|
8
|
+
export const IssuerShape: import("@endo/patterns").Matcher;
|
|
9
|
+
export const PaymentShape: import("@endo/patterns").Matcher;
|
|
10
|
+
export const PurseShape: import("@endo/patterns").Matcher;
|
|
11
|
+
export const DepositFacetShape: import("@endo/patterns").Matcher;
|
|
12
|
+
export const NotifierShape: import("@endo/patterns").Matcher;
|
|
13
|
+
export const MintShape: import("@endo/patterns").Matcher;
|
|
14
|
+
export namespace AmountShape {
|
|
15
|
+
export { BrandShape as brand };
|
|
16
|
+
export { AmountValueShape as value };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* To be used to guard an amount pattern argument, i.e., an argument which is a
|
|
20
|
+
* pattern that can be used to test amounts. Since amounts are keys, anywhere an
|
|
21
|
+
* amount pattern is expected, an amount can be provided and will match only
|
|
22
|
+
* that concrete amount, i.e., amounts that are `keyEQ` to that amount.
|
|
23
|
+
*
|
|
24
|
+
* The `AmountShape` guard above is an amount pattern. But not all amount
|
|
25
|
+
* patterns are like `AmountShape`. For example, `M.any()` is a valid amount
|
|
26
|
+
* pattern that will admit any amount, but is does not resemble the
|
|
27
|
+
* `AmountShape` pattern above.
|
|
28
|
+
*/
|
|
29
|
+
export const AmountPatternShape: import("@endo/patterns").Matcher;
|
|
30
|
+
/** @type {TypedPattern<Ratio>} */
|
|
31
|
+
export const RatioShape: TypedPattern<Ratio>;
|
|
32
|
+
export function isNatValue(value: AmountValue): value is NatValue;
|
|
33
|
+
export function isCopySetValue(value: AmountValue): value is CopySet;
|
|
34
|
+
export function isSetValue(value: AmountValue): value is SetValue;
|
|
35
|
+
export function isCopyBagValue(value: AmountValue): value is CopyBag;
|
|
36
|
+
export const MAX_ABSOLUTE_DECIMAL_PLACES: 100;
|
|
37
|
+
export const AssetKindShape: import("@endo/patterns").Matcher;
|
|
38
|
+
export const DisplayInfoShape: import("@endo/patterns").Matcher;
|
|
39
|
+
export namespace IssuerKitShape {
|
|
40
|
+
export { BrandShape as brand };
|
|
41
|
+
export { MintShape as mint };
|
|
42
|
+
export { PurseShape as mintRecoveryPurse };
|
|
43
|
+
export { IssuerShape as issuer };
|
|
44
|
+
export { DisplayInfoShape as displayInfo };
|
|
45
|
+
}
|
|
46
|
+
export const BrandI: import("@endo/patterns").InterfaceGuard<{
|
|
47
|
+
isMyIssuer: import("@endo/patterns").MethodGuard;
|
|
48
|
+
getAllegedName: import("@endo/patterns").MethodGuard;
|
|
49
|
+
getDisplayInfo: import("@endo/patterns").MethodGuard;
|
|
50
|
+
getAmountShape: import("@endo/patterns").MethodGuard;
|
|
51
|
+
}>;
|
|
52
|
+
export function makeIssuerInterfaces(brandShape?: Pattern, assetKindShape?: Pattern, amountShape?: Pattern): {
|
|
53
|
+
IssuerI: import("@endo/patterns").InterfaceGuard<{
|
|
54
|
+
getBrand: import("@endo/patterns").MethodGuard;
|
|
55
|
+
getAllegedName: import("@endo/patterns").MethodGuard;
|
|
56
|
+
getAssetKind: import("@endo/patterns").MethodGuard;
|
|
57
|
+
getDisplayInfo: import("@endo/patterns").MethodGuard;
|
|
58
|
+
makeEmptyPurse: import("@endo/patterns").MethodGuard;
|
|
59
|
+
isLive: import("@endo/patterns").MethodGuard;
|
|
60
|
+
getAmountOf: import("@endo/patterns").MethodGuard;
|
|
61
|
+
burn: import("@endo/patterns").MethodGuard;
|
|
62
|
+
}>;
|
|
63
|
+
MintI: import("@endo/patterns").InterfaceGuard<{
|
|
64
|
+
getIssuer: import("@endo/patterns").MethodGuard;
|
|
65
|
+
mintPayment: import("@endo/patterns").MethodGuard;
|
|
66
|
+
}>;
|
|
67
|
+
PaymentI: import("@endo/patterns").InterfaceGuard<{
|
|
68
|
+
getAllegedBrand: import("@endo/patterns").MethodGuard;
|
|
69
|
+
}>;
|
|
70
|
+
PurseIKit: {
|
|
71
|
+
purse: import("@endo/patterns").InterfaceGuard<{
|
|
72
|
+
getAllegedBrand: import("@endo/patterns").MethodGuard;
|
|
73
|
+
getCurrentAmount: import("@endo/patterns").MethodGuard;
|
|
74
|
+
getCurrentAmountNotifier: import("@endo/patterns").MethodGuard;
|
|
75
|
+
deposit: import("@endo/patterns").MethodGuard;
|
|
76
|
+
getDepositFacet: import("@endo/patterns").MethodGuard;
|
|
77
|
+
withdraw: import("@endo/patterns").MethodGuard;
|
|
78
|
+
getRecoverySet: import("@endo/patterns").MethodGuard;
|
|
79
|
+
recoverAll: import("@endo/patterns").MethodGuard;
|
|
80
|
+
}>;
|
|
81
|
+
depositFacet: import("@endo/patterns").InterfaceGuard<{
|
|
82
|
+
receive: import("@endo/patterns").MethodGuard;
|
|
83
|
+
}>;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare const AmountValueShape: import("@endo/patterns").Matcher;
|
|
87
|
+
import type { Ratio } from './types.js';
|
|
88
|
+
import type { TypedPattern } from '@agoric/internal';
|
|
89
|
+
import type { AmountValue } from './types.js';
|
|
90
|
+
import type { NatValue } from './types.js';
|
|
91
|
+
import type { CopySet } from '@endo/patterns';
|
|
92
|
+
import type { SetValue } from './types.js';
|
|
93
|
+
import type { CopyBag } from '@endo/patterns';
|
|
94
|
+
import type { Pattern } from '@endo/patterns';
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,0DAA+C;AAC/C,2DAAiD;AACjD,4DAAmD;AACnD,0DAA+C;AAC/C,iEAA6D;AAC7D,6DAAqD;AACrD,yDAA6C;;;;;AAkE7C;;;;;;;;;;GAUG;AACH,kEAA8C;AAE9C,kCAAkC;AAClC,yBADW,aAAa,KAAK,CAAC,CACiD;AASxE,kCAHI,WAAW,GACT,KAAK,IAAI,QAAQ,CAEkC;AASzD,sCAHI,WAAW,GACT,KAAK,IAAI,OAAO,CAE2C;AAYjE,kCAHI,WAAW,GACT,KAAK,IAAI,QAAQ,CAEkC;AASzD,sCAHI,WAAW,GACT,KAAK,IAAI,OAAO,CAE2C;AAIxE,0CAA2C,GAAG,CAAC;AAE/C,8DAAuE;AAEvE,gEAaE;;;;;;;;AAaF;;;;;GAKG;AAOI,kDAJI,OAAO,mBACP,OAAO,gBACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqEjB;AAhLD,iEAKE;2BAzEmC,YAAY;kCAClB,kBAAkB;iCADZ,YAAY;8BAGZ,YAAY;6BADL,gBAAgB;8BACvB,YAAY;6BADL,gBAAgB;6BAAhB,gBAAgB"}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import type { LatestTopic } from '@agoric/notifier';
|
|
2
|
+
import type { ERef } from '@endo/far';
|
|
3
|
+
import type { RemotableObject } from '@endo/pass-style';
|
|
4
|
+
import type { CopyBag, CopySet, Key, Pattern } from '@endo/patterns';
|
|
5
|
+
import type { TypeTag } from '@agoric/internal/src/tagged.js';
|
|
6
|
+
import type { AssetKind } from './amountMath.js';
|
|
7
|
+
export type { AssetKind } from './amountMath.js';
|
|
8
|
+
export type NatAmount = {
|
|
9
|
+
brand: Brand<'nat'>;
|
|
10
|
+
value: bigint;
|
|
11
|
+
};
|
|
12
|
+
export type SetAmount<K extends Key> = {
|
|
13
|
+
brand: Brand<'set'>;
|
|
14
|
+
value: K[];
|
|
15
|
+
};
|
|
16
|
+
export type CopySetAmount<K extends Key> = {
|
|
17
|
+
brand: Brand<'copySet'>;
|
|
18
|
+
value: CopySet<K>;
|
|
19
|
+
};
|
|
20
|
+
export type CopyBagAmount<K extends Key> = {
|
|
21
|
+
brand: Brand<'copyBag'>;
|
|
22
|
+
value: CopyBag<K>;
|
|
23
|
+
};
|
|
24
|
+
export type AnyAmount = {
|
|
25
|
+
brand: Brand<any>;
|
|
26
|
+
value: any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Amounts are descriptions of digital assets, answering the questions "how
|
|
30
|
+
* much" and "of what kind". Amounts are values labeled with a brand.
|
|
31
|
+
* AmountMath executes the logic of how amounts are changed when digital
|
|
32
|
+
* assets are merged, separated, or otherwise manipulated. For example, a
|
|
33
|
+
* deposit of 2 bucks into a purse that already has 3 bucks gives a new purse
|
|
34
|
+
* balance of 5 bucks. An empty purse has 0 bucks. AmountMath relies heavily
|
|
35
|
+
* on polymorphic MathHelpers, which manipulate the unbranded portion.
|
|
36
|
+
*/
|
|
37
|
+
export type Amount<K extends AssetKind = AssetKind, M extends Key = Key> = K extends 'nat' ? NatAmount : K extends 'set' ? SetAmount<M> : K extends 'copySet' ? CopySetAmount<M> : K extends 'copyBag' ? CopyBagAmount<M> : AnyAmount;
|
|
38
|
+
/**
|
|
39
|
+
* An `AmountValue` describes a set or quantity of assets that can be owned or
|
|
40
|
+
* shared.
|
|
41
|
+
*
|
|
42
|
+
* A fungible `AmountValue` uses a non-negative bigint to represent a quantity
|
|
43
|
+
* of that many assets.
|
|
44
|
+
*
|
|
45
|
+
* A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
|
|
46
|
+
* a set of whatever asset each key represents. A `Key` is a passable value
|
|
47
|
+
* that can be used as an element in a set (SetStore or CopySet) or as the key
|
|
48
|
+
* in a map (MapStore or CopyMap).
|
|
49
|
+
*
|
|
50
|
+
* `SetValue` is for the deprecated set representation, using an array directly
|
|
51
|
+
* to represent the array of its elements. `CopySet` is the proper
|
|
52
|
+
* representation using a CopySet.
|
|
53
|
+
*
|
|
54
|
+
* A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
|
|
55
|
+
* "Bag" is synonymous with MultiSet, where an element of a bag can be present
|
|
56
|
+
* once or more times, i.e., some positive bigint number of times,
|
|
57
|
+
* representing that quantity of the asset represented by that key.
|
|
58
|
+
*/
|
|
59
|
+
export type AmountValue = NatValue | SetValue | CopySet | import('@endo/patterns').CopyBag;
|
|
60
|
+
/**
|
|
61
|
+
* See doc-comment
|
|
62
|
+
* for `AmountValue`.
|
|
63
|
+
*/
|
|
64
|
+
export type AssetValueForKind<K extends AssetKind, M extends Key = Key> = K extends 'nat' ? NatValue : K extends 'set' ? SetValue<M> : K extends 'copySet' ? CopySet<M> : K extends 'copyBag' ? CopyBag<M> : never;
|
|
65
|
+
export type AssetKindForValue<V extends AmountValue> = V extends NatValue ? 'nat' : V extends SetValue ? 'set' : V extends CopySet ? 'copySet' : V extends import('@endo/patterns').CopyBag ? 'copyBag' : never;
|
|
66
|
+
export type Ratio = {
|
|
67
|
+
numerator: Amount<'nat'>;
|
|
68
|
+
denominator: Amount<'nat'>;
|
|
69
|
+
};
|
|
70
|
+
/** @deprecated */
|
|
71
|
+
export type DisplayInfo<K extends AssetKind = AssetKind> = {
|
|
72
|
+
/**
|
|
73
|
+
* Tells the display software how many
|
|
74
|
+
* decimal places to move the decimal over to the left, or in other words,
|
|
75
|
+
* which position corresponds to whole numbers. We require fungible digital
|
|
76
|
+
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
77
|
+
* be represented in mill, a thousandth of a dollar. In that case,
|
|
78
|
+
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
79
|
+
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
80
|
+
* property should be used for _display purposes only_. Any other use is an
|
|
81
|
+
* anti-pattern.
|
|
82
|
+
*/
|
|
83
|
+
decimalPlaces?: number | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* - the kind of asset, either AssetKind.NAT (fungible)
|
|
86
|
+
* or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
|
|
87
|
+
*/
|
|
88
|
+
assetKind: K;
|
|
89
|
+
};
|
|
90
|
+
export type BrandMethods<K extends AssetKind> = {
|
|
91
|
+
/**
|
|
92
|
+
* Should be used with `issuer.getBrand` to ensure an issuer and brand match.
|
|
93
|
+
*/
|
|
94
|
+
isMyIssuer: (allegedIssuer: ERef<Issuer<K>>) => Promise<boolean>;
|
|
95
|
+
getAllegedName: () => string;
|
|
96
|
+
/** @deprecated look up in boardAux */
|
|
97
|
+
getDisplayInfo: () => DisplayInfo<K>;
|
|
98
|
+
getAmountShape: () => Pattern;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The brand identifies the
|
|
102
|
+
* kind of issuer, and has a function to get the alleged name for the kind of
|
|
103
|
+
* asset described. The alleged name (such as 'BTC' or 'moola') is provided by
|
|
104
|
+
* the maker of the issuer and should not be trusted as accurate.
|
|
105
|
+
*
|
|
106
|
+
* Every amount created by a particular issuer will share the same brand, but
|
|
107
|
+
* recipients cannot rely on the brand to verify that a purported amount
|
|
108
|
+
* represents the issuer they intended, since the same brand can be reused by
|
|
109
|
+
* a misbehaving issuer.
|
|
110
|
+
*/
|
|
111
|
+
export type Brand<K extends AssetKind = AssetKind> = RemotableObject & BrandMethods<K>;
|
|
112
|
+
/**
|
|
113
|
+
* Return true if the payment continues to exist.
|
|
114
|
+
*
|
|
115
|
+
* If the payment is a promise, the operation will proceed upon fulfillment.
|
|
116
|
+
*/
|
|
117
|
+
export type IssuerIsLive = (payment: ERef<Payment>) => Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Get the amount of digital assets in the payment.
|
|
120
|
+
* Because the payment is not trusted, we cannot call a method on it directly,
|
|
121
|
+
* and must use the issuer instead.
|
|
122
|
+
*
|
|
123
|
+
* If the payment is a promise, the operation will proceed upon fulfillment.
|
|
124
|
+
*/
|
|
125
|
+
export type IssuerGetAmountOf<K extends AssetKind, M extends Key = Key> = (payment: ERef<Payment<K, M>>) => Promise<Amount<K, M>>;
|
|
126
|
+
/**
|
|
127
|
+
* Burn all of the digital assets in the payment.
|
|
128
|
+
* `optAmountShape` is optional. If the `optAmountShape` pattern is present,
|
|
129
|
+
* the amount of the digital assets in the payment must match
|
|
130
|
+
* `optAmountShape`, to prevent sending the wrong payment and other
|
|
131
|
+
* confusion.
|
|
132
|
+
*
|
|
133
|
+
* If the payment is a promise, the operation will proceed upon fulfillment.
|
|
134
|
+
*
|
|
135
|
+
* As always with optional `Pattern` arguments, keep in mind that technically
|
|
136
|
+
* the value `undefined` itself is a valid `Key` and therefore a valid
|
|
137
|
+
* `Pattern`. But in optional pattern position, a top level `undefined` will
|
|
138
|
+
* be interpreted as absence. If you want to express a `Pattern` that will
|
|
139
|
+
* match only `undefined`, use `M.undefined()` instead.
|
|
140
|
+
*/
|
|
141
|
+
export type IssuerBurn = (payment: ERef<Payment>, optAmountShape?: Pattern) => Promise<Amount>;
|
|
142
|
+
/**
|
|
143
|
+
* Work around JSDoc union handling
|
|
144
|
+
*/
|
|
145
|
+
export type IssuerMethods<K extends AssetKind, M extends Key> = {
|
|
146
|
+
/**
|
|
147
|
+
* Get the Brand for this Issuer. The Brand
|
|
148
|
+
* indicates the type of digital asset and is shared by the mint, the issuer,
|
|
149
|
+
* and any purses and payments of this particular kind. The brand is not
|
|
150
|
+
* closely held, so this function should not be trusted to identify an issuer
|
|
151
|
+
* alone. Fake digital assets and amount can use another issuer's brand.
|
|
152
|
+
*/
|
|
153
|
+
getBrand: () => Brand<K>;
|
|
154
|
+
/**
|
|
155
|
+
* Get the allegedName for this
|
|
156
|
+
* mint/issuer
|
|
157
|
+
*/
|
|
158
|
+
getAllegedName: () => string;
|
|
159
|
+
/**
|
|
160
|
+
* Get the kind of MathHelpers used by this
|
|
161
|
+
* Issuer.
|
|
162
|
+
*/
|
|
163
|
+
getAssetKind: () => K;
|
|
164
|
+
/** @deprecated look up in boardAux */
|
|
165
|
+
getDisplayInfo: () => DisplayInfo<K>;
|
|
166
|
+
/**
|
|
167
|
+
* Make an empty purse of this
|
|
168
|
+
* brand.
|
|
169
|
+
*/
|
|
170
|
+
makeEmptyPurse: () => Purse<K, M>;
|
|
171
|
+
isLive: IssuerIsLive;
|
|
172
|
+
getAmountOf: IssuerGetAmountOf<K, M>;
|
|
173
|
+
burn: IssuerBurn;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The issuer cannot
|
|
177
|
+
* mint a new amount, but it can create empty purses and payments. The issuer
|
|
178
|
+
* can also transform payments (splitting payments, combining payments,
|
|
179
|
+
* burning payments, and claiming payments exclusively). The issuer should be
|
|
180
|
+
* gotten from a trusted source and then relied upon as the decider of whether
|
|
181
|
+
* an untrusted payment is valid.
|
|
182
|
+
*/
|
|
183
|
+
export type Issuer<K extends AssetKind = AssetKind, M extends Key = Key> = RemotableObject & IssuerMethods<K, M>;
|
|
184
|
+
export type PaymentLedger<K extends AssetKind = AssetKind> = {
|
|
185
|
+
mint: Mint<K>;
|
|
186
|
+
/**
|
|
187
|
+
* Externally useful only if this issuer
|
|
188
|
+
* uses recovery sets. Can be used to get the recovery set associated with
|
|
189
|
+
* minted payments that are still live.
|
|
190
|
+
*/
|
|
191
|
+
mintRecoveryPurse: Purse<K>;
|
|
192
|
+
issuer: Issuer<K>;
|
|
193
|
+
brand: Brand<K>;
|
|
194
|
+
};
|
|
195
|
+
export type IssuerKit<K extends AssetKind = AssetKind, M extends Key = Key> = {
|
|
196
|
+
mint: Mint<K, M>;
|
|
197
|
+
/**
|
|
198
|
+
* Externally useful only if this
|
|
199
|
+
* issuer uses recovery sets. Can be used to get the recovery set associated
|
|
200
|
+
* with minted payments that are still live.
|
|
201
|
+
*/
|
|
202
|
+
mintRecoveryPurse: Purse<K, M>;
|
|
203
|
+
issuer: Issuer<K, M>;
|
|
204
|
+
brand: Brand<K>;
|
|
205
|
+
displayInfo: DisplayInfo;
|
|
206
|
+
};
|
|
207
|
+
export type AdditionalDisplayInfo = {
|
|
208
|
+
/**
|
|
209
|
+
* Tells the display software how many
|
|
210
|
+
* decimal places to move the decimal over to the left, or in other words,
|
|
211
|
+
* which position corresponds to whole numbers. We require fungible digital
|
|
212
|
+
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
213
|
+
* be represented in mill, a thousandth of a dollar. In that case,
|
|
214
|
+
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
215
|
+
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
216
|
+
* property should be used for _display purposes only_. Any other use is an
|
|
217
|
+
* anti-pattern.
|
|
218
|
+
*/
|
|
219
|
+
decimalPlaces?: number | undefined;
|
|
220
|
+
assetKind?: AssetKind | undefined;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Holding a Mint carries the right to issue new digital
|
|
224
|
+
* assets. These assets all have the same kind, which is called a Brand.
|
|
225
|
+
*/
|
|
226
|
+
export type Mint<K extends AssetKind = AssetKind, M extends Key = Key> = {
|
|
227
|
+
/**
|
|
228
|
+
* Gets the Issuer for this mint.
|
|
229
|
+
*/
|
|
230
|
+
getIssuer: () => Issuer<K, M>;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a new
|
|
233
|
+
* Payment containing newly minted amount.
|
|
234
|
+
*/
|
|
235
|
+
mintPayment: (newAmount: Amount<K>) => Payment<K, M>;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Issuers first became durable with mandatory recovery sets. Later they were
|
|
239
|
+
* made optional, but there is no support for converting from one state to the
|
|
240
|
+
* other. Thus, absence of a `RecoverySetsOption` state is equivalent to
|
|
241
|
+
* `'hasRecoverySets'`. In the absence of a `recoverySetsOption` parameter,
|
|
242
|
+
* upgradeIssuerKit defaults to the predecessor's `RecoverySetsOption` state, or
|
|
243
|
+
* `'hasRecoverySets'` if none.
|
|
244
|
+
*
|
|
245
|
+
* At this time, issuers started in one of the states (`'noRecoverySets'`, or
|
|
246
|
+
* `'hasRecoverySets'`) cannot be converted to the other on upgrade. If this
|
|
247
|
+
* transition is needed, it can likely be supported in a future upgrade. File an
|
|
248
|
+
* issue on github and explain what you need and why.
|
|
249
|
+
*/
|
|
250
|
+
export type RecoverySetsOption = 'hasRecoverySets' | 'noRecoverySets';
|
|
251
|
+
export type DepositFacetReceive = (payment: Payment, optAmountShape?: Pattern) => Amount;
|
|
252
|
+
export type DepositFacet = {
|
|
253
|
+
/**
|
|
254
|
+
* Deposit all the contents of payment
|
|
255
|
+
* into the purse that made this facet, returning the amount. If the optional
|
|
256
|
+
* argument `optAmount` does not equal the amount of digital assets in the
|
|
257
|
+
* payment, throw an error.
|
|
258
|
+
*
|
|
259
|
+
* If payment is a promise, throw an error.
|
|
260
|
+
*/
|
|
261
|
+
receive: DepositFacetReceive;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Purses hold amount of
|
|
265
|
+
* digital assets of the same brand, but unlike Payments, they are not meant
|
|
266
|
+
* to be sent to others. To transfer digital assets, a Payment should be
|
|
267
|
+
* withdrawn from a Purse. The amount of digital assets in a purse can change
|
|
268
|
+
* through the action of deposit() and withdraw().
|
|
269
|
+
*/
|
|
270
|
+
export type Purse<K extends AssetKind = AssetKind, M extends Key = Key> = RemotableObject & PurseMethods<K, M>;
|
|
271
|
+
/**
|
|
272
|
+
* The primary use for Purses and Payments is for
|
|
273
|
+
* currency-like and goods-like digital assets, but they can also be used to
|
|
274
|
+
* represent other kinds of rights, such as the right to participate in a
|
|
275
|
+
* particular contract.
|
|
276
|
+
*/
|
|
277
|
+
export type PurseMethods<K extends AssetKind = AssetKind, M extends Key = Key> = {
|
|
278
|
+
/**
|
|
279
|
+
* Get the alleged Brand for this
|
|
280
|
+
* Purse
|
|
281
|
+
*/
|
|
282
|
+
getAllegedBrand: () => Brand<K>;
|
|
283
|
+
/**
|
|
284
|
+
* Get the amount contained in
|
|
285
|
+
* this purse.
|
|
286
|
+
*/
|
|
287
|
+
getCurrentAmount: () => Amount<K, M>;
|
|
288
|
+
/**
|
|
289
|
+
* Get a
|
|
290
|
+
* lossy notifier for changes to this purse's balance.
|
|
291
|
+
*/
|
|
292
|
+
getCurrentAmountNotifier: () => LatestTopic<Amount<K, M>>;
|
|
293
|
+
/**
|
|
294
|
+
* Deposit all the contents of payment into this purse, returning the amount. If
|
|
295
|
+
* the optional argument `optAmount` does not equal the amount of digital
|
|
296
|
+
* assets in the payment, throw an error.
|
|
297
|
+
*
|
|
298
|
+
* If payment is a promise, throw an error.
|
|
299
|
+
*/
|
|
300
|
+
deposit: <P extends Payment<K, M>>(payment: P, optAmountShape?: Pattern) => P extends Payment<K, M> ? Amount<K, M> : never;
|
|
301
|
+
/**
|
|
302
|
+
* Return an object whose
|
|
303
|
+
* `receive` method deposits to the current Purse.
|
|
304
|
+
*/
|
|
305
|
+
getDepositFacet: () => DepositFacet;
|
|
306
|
+
/**
|
|
307
|
+
* Withdraw amount
|
|
308
|
+
* from this purse into a new Payment.
|
|
309
|
+
*/
|
|
310
|
+
withdraw: (amount: Amount<K, M>) => Payment<K, M>;
|
|
311
|
+
/**
|
|
312
|
+
* The set of payments
|
|
313
|
+
* withdrawn from this purse that are still live. These are the payments that
|
|
314
|
+
* can still be recovered in emergencies by, for example, depositing into this
|
|
315
|
+
* purse. Such a deposit action is like canceling an outstanding check because
|
|
316
|
+
* you're tired of waiting for it. Once your cancellation is acknowledged, you
|
|
317
|
+
* can spend the assets at stake on other things. Afterwards, if the recipient
|
|
318
|
+
* of the original check finally gets around to depositing it, their deposit
|
|
319
|
+
* fails.
|
|
320
|
+
*
|
|
321
|
+
* Returns an empty set if this issuer does not support recovery sets.
|
|
322
|
+
*/
|
|
323
|
+
getRecoverySet: () => CopySet<Payment<K, M>>;
|
|
324
|
+
/**
|
|
325
|
+
* For use in emergencies, such as
|
|
326
|
+
* coming back from a traumatic crash and upgrade. This deposits all the
|
|
327
|
+
* payments in this purse's recovery set into the purse itself, returning the
|
|
328
|
+
* total amount of assets recovered.
|
|
329
|
+
*
|
|
330
|
+
* Returns an empty amount if this issuer does not support recovery sets.
|
|
331
|
+
*/
|
|
332
|
+
recoverAll: () => Amount<K, M>;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Payments hold amount
|
|
336
|
+
* of digital assets of the same brand in transit. Payments can be deposited
|
|
337
|
+
* in purses, split into multiple payments, combined, and claimed (getting an
|
|
338
|
+
* exclusive payment). Payments are linear, meaning that either a payment has
|
|
339
|
+
* the same amount of digital assets it started with, or it is used up
|
|
340
|
+
* entirely. It is impossible to partially use a payment.
|
|
341
|
+
*
|
|
342
|
+
* Payments are often received from other actors and therefore should not be
|
|
343
|
+
* trusted themselves. To get the amount of digital assets in a payment, use
|
|
344
|
+
* the trusted issuer: issuer.getAmountOf(payment),
|
|
345
|
+
*
|
|
346
|
+
* Payments can be converted to Purses by getting a trusted issuer and calling
|
|
347
|
+
* `issuer.makeEmptyPurse()` to create a purse, then
|
|
348
|
+
* `purse.deposit(payment)`.
|
|
349
|
+
*/
|
|
350
|
+
export type Payment<K extends AssetKind = AssetKind, M extends Key = Key> = RemotableObject & TypeTag<{
|
|
351
|
+
/**
|
|
352
|
+
* Get the allegedBrand, indicating
|
|
353
|
+
* the type of digital asset this payment purports to be, and which issuer to
|
|
354
|
+
* use. Because payments are not trusted, any method calls on payments should
|
|
355
|
+
* be treated with suspicion and verified elsewhere.
|
|
356
|
+
*/
|
|
357
|
+
getAllegedBrand: () => Brand<K>;
|
|
358
|
+
}, 'Set-like value type', M>;
|
|
359
|
+
/**
|
|
360
|
+
* All of the difference in how digital asset
|
|
361
|
+
* amount are manipulated can be reduced to the behavior of the math on
|
|
362
|
+
* values. We extract this custom logic into mathHelpers. MathHelpers are
|
|
363
|
+
* about value arithmetic, whereas AmountMath is about amounts, which are the
|
|
364
|
+
* values labeled with a brand. AmountMath use mathHelpers to do their value
|
|
365
|
+
* arithmetic, and then brand the results, making a new amount.
|
|
366
|
+
*
|
|
367
|
+
* The MathHelpers are designed to be called only from AmountMath, and so all
|
|
368
|
+
* methods but coerce can assume their inputs are valid. They only need to do
|
|
369
|
+
* output validation, and only when there is a possibility of invalid output.
|
|
370
|
+
*/
|
|
371
|
+
export type MathHelpers<V extends AmountValue> = {
|
|
372
|
+
/**
|
|
373
|
+
* Check the kind of this value and
|
|
374
|
+
* throw if it is not the expected kind.
|
|
375
|
+
*/
|
|
376
|
+
doCoerce: (allegedValue: V) => V;
|
|
377
|
+
/**
|
|
378
|
+
* Get the representation for the identity
|
|
379
|
+
* element (often 0 or an empty array)
|
|
380
|
+
*/
|
|
381
|
+
doMakeEmpty: () => V;
|
|
382
|
+
/**
|
|
383
|
+
* Is the value the identity
|
|
384
|
+
* element?
|
|
385
|
+
*/
|
|
386
|
+
doIsEmpty: (value: V) => boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Is the left greater than
|
|
389
|
+
* or equal to the right?
|
|
390
|
+
*/
|
|
391
|
+
doIsGTE: (left: V, right: V) => boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Does left equal right?
|
|
394
|
+
*/
|
|
395
|
+
doIsEqual: (left: V, right: V) => boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Return the left combined with the
|
|
398
|
+
* right.
|
|
399
|
+
*/
|
|
400
|
+
doAdd: (left: V, right: V) => V;
|
|
401
|
+
/**
|
|
402
|
+
* Return what remains after
|
|
403
|
+
* removing the right from the left. If something in the right was not in the
|
|
404
|
+
* left, we throw an error.
|
|
405
|
+
*/
|
|
406
|
+
doSubtract: (left: V, right: V) => V;
|
|
407
|
+
};
|
|
408
|
+
export type NatValue = bigint;
|
|
409
|
+
export type SetValue<K extends Key = Key> = K[];
|
|
410
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCA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