@agoric/ertp 0.16.3-dev-ae21a7e.0 → 0.16.3-dev-afcbcd7.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 +11 -8
- package/src/types-ambient.js +0 -46
- package/src/types.js +0 -46
- package/src/amountMath.d.ts +0 -54
- package/src/amountMath.d.ts.map +0 -1
- package/src/displayInfo.d.ts +0 -2
- package/src/displayInfo.d.ts.map +0 -1
- package/src/index.d.ts +0 -4
- package/src/index.d.ts.map +0 -1
- package/src/issuerKit.d.ts +0 -19
- package/src/issuerKit.d.ts.map +0 -1
- package/src/legacy-payment-helpers.d.ts +0 -5
- package/src/legacy-payment-helpers.d.ts.map +0 -1
- package/src/mathHelpers/copyBagMathHelpers.d.ts +0 -3
- package/src/mathHelpers/copyBagMathHelpers.d.ts.map +0 -1
- package/src/mathHelpers/copySetMathHelpers.d.ts +0 -3
- package/src/mathHelpers/copySetMathHelpers.d.ts.map +0 -1
- package/src/mathHelpers/natMathHelpers.d.ts +0 -13
- package/src/mathHelpers/natMathHelpers.d.ts.map +0 -1
- package/src/mathHelpers/setMathHelpers.d.ts +0 -6
- package/src/mathHelpers/setMathHelpers.d.ts.map +0 -1
- package/src/payment.d.ts +0 -5
- package/src/payment.d.ts.map +0 -1
- package/src/paymentLedger.d.ts +0 -3
- package/src/paymentLedger.d.ts.map +0 -1
- package/src/purse.d.ts +0 -13
- package/src/purse.d.ts.map +0 -1
- package/src/transientNotifier.d.ts +0 -5
- package/src/transientNotifier.d.ts.map +0 -1
- package/src/typeGuards.d.ts +0 -72
- package/src/typeGuards.d.ts.map +0 -1
- package/src/types-ambient.d.ts +0 -380
- package/src/types-ambient.d.ts.map +0 -1
- package/src/types.d.ts +0 -380
- package/src/types.d.ts.map +0 -1
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-afcbcd7.0+afcbcd7",
|
|
4
4
|
"description": "Electronic Rights Transfer Protocol (ERTP). A smart contract framework for exchanging electronic rights",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
|
-
"prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build tsconfig.build.json",
|
|
12
|
+
"prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build --clean tsconfig.build.json",
|
|
13
13
|
"postpack": "git clean -f '*.d.ts*' src/types.js",
|
|
14
14
|
"test": "ava",
|
|
15
15
|
"test:c8": "c8 $C8_OPTIONS ava",
|
|
@@ -39,10 +39,10 @@
|
|
|
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-
|
|
42
|
+
"@agoric/assert": "0.6.1-dev-afcbcd7.0+afcbcd7",
|
|
43
|
+
"@agoric/notifier": "0.6.3-dev-afcbcd7.0+afcbcd7",
|
|
44
|
+
"@agoric/store": "0.9.3-dev-afcbcd7.0+afcbcd7",
|
|
45
|
+
"@agoric/vat-data": "0.5.3-dev-afcbcd7.0+afcbcd7",
|
|
46
46
|
"@endo/eventual-send": "^0.17.5",
|
|
47
47
|
"@endo/far": "^0.2.21",
|
|
48
48
|
"@endo/marshal": "^0.8.8",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@endo/promise-kit": "^0.2.59"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
54
|
+
"@agoric/swingset-vat": "0.32.3-dev-afcbcd7.0+afcbcd7",
|
|
55
55
|
"@endo/bundle-source": "^2.7.0",
|
|
56
56
|
"@fast-check/ava": "^1.1.5",
|
|
57
57
|
"ava": "^5.3.0",
|
|
@@ -83,5 +83,8 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"
|
|
86
|
+
"typeCoverage": {
|
|
87
|
+
"atLeast": 90.37
|
|
88
|
+
},
|
|
89
|
+
"gitHead": "afcbcd727d7c9a4c6330d619c7846c9963b1e25a"
|
|
87
90
|
}
|
package/src/types-ambient.js
CHANGED
|
@@ -142,52 +142,6 @@
|
|
|
142
142
|
* @returns {Promise<Amount>}
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
|
-
/**
|
|
146
|
-
* @template {AssetKind} K
|
|
147
|
-
* @callback IssuerClaim Transfer all digital assets from the payment to a new
|
|
148
|
-
* payment and delete the original. `optAmount` is optional. If `optAmount` is
|
|
149
|
-
* present, the code will insist that the amount of digital assets in the
|
|
150
|
-
* payment is equal to `optAmount`, to prevent sending the wrong payment and
|
|
151
|
-
* other confusion.
|
|
152
|
-
*
|
|
153
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
154
|
-
* @param {ERef<Payment<K>>} payment
|
|
155
|
-
* @param {Pattern} [optAmountShape]
|
|
156
|
-
* @returns {Promise<Payment<K>>}
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* @template {AssetKind} K
|
|
161
|
-
* @callback IssuerCombine Combine multiple payments into one payment.
|
|
162
|
-
*
|
|
163
|
-
* If any of the payments is a promise, the operation will proceed upon
|
|
164
|
-
* resolution.
|
|
165
|
-
* @param {ERef<Payment<K>>[]} paymentsArray
|
|
166
|
-
* @param {Amount<K>} [optTotalAmount]
|
|
167
|
-
* @returns {Promise<Payment<K>>}
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @template {AssetKind} K
|
|
172
|
-
* @callback IssuerSplit Split a single payment into two payments, A and B,
|
|
173
|
-
* according to the paymentAmountA passed in.
|
|
174
|
-
*
|
|
175
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
176
|
-
* @param {ERef<Payment<K>>} payment
|
|
177
|
-
* @param {Amount<K>} paymentAmountA
|
|
178
|
-
* @returns {Promise<Payment<K>[]>}
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @callback IssuerSplitMany Split a single payment into many payments,
|
|
183
|
-
* according to the amounts passed in.
|
|
184
|
-
*
|
|
185
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
186
|
-
* @param {ERef<Payment>} payment
|
|
187
|
-
* @param {Amount[]} amounts
|
|
188
|
-
* @returns {Promise<Payment[]>}
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
145
|
/**
|
|
192
146
|
* @template {AssetKind} [K=AssetKind]
|
|
193
147
|
* @typedef {object} Issuer The issuer cannot mint a new amount, but it can
|
package/src/types.js
CHANGED
|
@@ -143,52 +143,6 @@ export {};
|
|
|
143
143
|
* @returns {Promise<Amount>}
|
|
144
144
|
*/
|
|
145
145
|
|
|
146
|
-
/**
|
|
147
|
-
* @template {AssetKind} K
|
|
148
|
-
* @callback IssuerClaim Transfer all digital assets from the payment to a new
|
|
149
|
-
* payment and delete the original. `optAmount` is optional. If `optAmount` is
|
|
150
|
-
* present, the code will insist that the amount of digital assets in the
|
|
151
|
-
* payment is equal to `optAmount`, to prevent sending the wrong payment and
|
|
152
|
-
* other confusion.
|
|
153
|
-
*
|
|
154
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
155
|
-
* @param {ERef<Payment<K>>} payment
|
|
156
|
-
* @param {Pattern} [optAmountShape]
|
|
157
|
-
* @returns {Promise<Payment<K>>}
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @template {AssetKind} K
|
|
162
|
-
* @callback IssuerCombine Combine multiple payments into one payment.
|
|
163
|
-
*
|
|
164
|
-
* If any of the payments is a promise, the operation will proceed upon
|
|
165
|
-
* resolution.
|
|
166
|
-
* @param {ERef<Payment<K>>[]} paymentsArray
|
|
167
|
-
* @param {Amount<K>} [optTotalAmount]
|
|
168
|
-
* @returns {Promise<Payment<K>>}
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @template {AssetKind} K
|
|
173
|
-
* @callback IssuerSplit Split a single payment into two payments, A and B,
|
|
174
|
-
* according to the paymentAmountA passed in.
|
|
175
|
-
*
|
|
176
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
177
|
-
* @param {ERef<Payment<K>>} payment
|
|
178
|
-
* @param {Amount<K>} paymentAmountA
|
|
179
|
-
* @returns {Promise<Payment<K>[]>}
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @callback IssuerSplitMany Split a single payment into many payments,
|
|
184
|
-
* according to the amounts passed in.
|
|
185
|
-
*
|
|
186
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
187
|
-
* @param {ERef<Payment>} payment
|
|
188
|
-
* @param {Amount[]} amounts
|
|
189
|
-
* @returns {Promise<Payment[]>}
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
146
|
/**
|
|
193
147
|
* @template {AssetKind} [K=AssetKind]
|
|
194
148
|
* @typedef {object} Issuer The issuer cannot mint a new amount, but it can
|
package/src/amountMath.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export function assertValueGetHelpers<V extends AmountValue>(value: V): MathHelpers<V>;
|
|
2
|
-
export namespace AmountMath {
|
|
3
|
-
export function make<K extends AssetKind>(brand: Brand<K>, allegedValue: AssetValueForKind<K>): Amount<K>;
|
|
4
|
-
export function coerce<K extends AssetKind>(brand: Brand<K>, allegedAmount: Amount<K>): Amount<K>;
|
|
5
|
-
export function getValue<K extends AssetKind>(brand: Brand<K>, amount: Amount<K>): AssetValueForKind<K>;
|
|
6
|
-
export let makeEmpty: {
|
|
7
|
-
(brand: Brand<AssetKind>): Amount<"nat">;
|
|
8
|
-
<K extends AssetKind>(brand: Brand<AssetKind>, assetKind: K): Amount<K>;
|
|
9
|
-
};
|
|
10
|
-
export function makeEmptyFromAmount<K extends AssetKind>(amount: Amount<K>): Amount<K>;
|
|
11
|
-
export function isEmpty(amount: Amount<AssetKind>, brand?: Brand<AssetKind> | undefined): boolean;
|
|
12
|
-
export { isGTE };
|
|
13
|
-
export function isEqual<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
|
|
14
|
-
export function add<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
|
|
15
|
-
export function subtract<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
|
|
16
|
-
export function min<K extends AssetKind>(x: Amount<K>, y: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
|
|
17
|
-
export function max<K extends AssetKind>(x: Amount<K>, y: Amount<K>, brand?: Brand<K> | undefined): Amount<K>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Constants for the kinds of assets we support.
|
|
21
|
-
*
|
|
22
|
-
* @type {{
|
|
23
|
-
* NAT: 'nat';
|
|
24
|
-
* SET: 'set';
|
|
25
|
-
* COPY_SET: 'copySet';
|
|
26
|
-
* COPY_BAG: 'copyBag';
|
|
27
|
-
* }}
|
|
28
|
-
*/
|
|
29
|
-
export const AssetKind: {
|
|
30
|
-
NAT: 'nat';
|
|
31
|
-
SET: 'set';
|
|
32
|
-
COPY_SET: 'copySet';
|
|
33
|
-
COPY_BAG: 'copyBag';
|
|
34
|
-
};
|
|
35
|
-
/** @param {Amount} amount */
|
|
36
|
-
export function getAssetKind(amount: Amount): AssetKindForValue<V>;
|
|
37
|
-
/** @param {AssetKind} allegedAK */
|
|
38
|
-
export function assertAssetKind(allegedAK: AssetKind): void;
|
|
39
|
-
/**
|
|
40
|
-
* Returns true if the leftAmount is greater than or equal to the rightAmount.
|
|
41
|
-
* The notion of "greater than or equal to" depends on the kind of amount, as
|
|
42
|
-
* defined by the MathHelpers. For example, whether rectangle A is greater than
|
|
43
|
-
* rectangle B depends on whether rectangle A includes rectangle B as defined by
|
|
44
|
-
* the logic in MathHelpers.
|
|
45
|
-
*
|
|
46
|
-
* @template {AssetKind} K
|
|
47
|
-
* @param {Amount<K>} leftAmount
|
|
48
|
-
* @param {Amount<K>} rightAmount
|
|
49
|
-
* @param {Brand<K>} [brand]
|
|
50
|
-
* @returns {boolean}
|
|
51
|
-
*/
|
|
52
|
-
declare function isGTE<K extends AssetKind>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand?: Brand<K> | undefined): boolean;
|
|
53
|
-
export {};
|
|
54
|
-
//# sourceMappingURL=amountMath.d.ts.map
|
package/src/amountMath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amountMath.d.ts","sourceRoot":"","sources":["amountMath.js"],"names":[],"mappings":"AAqHO,uFAEkC;;IAwFjC,0GAKL;IAUO,kGAQP;IASS,wGAAyD;;;;;IAwB9C,uFAOpB;IAQQ,kGAOR;;IAYQ,mIAGR;IAcI,iIAIJ;IAcS,sIAIT;IAUI,8GAMqC;IAUrC,8GAMqC;;AAtW5C;;;;;;;;;GASG;AACH,wBAPU;IACT,GAAO,EAAE,KAAK,CAAC;IACf,GAAO,EAAE,KAAK,CAAC;IACf,QAAY,EAAE,SAAS,CAAC;IACxB,QAAY,EAAE,SAAS,CAAC;CACrB,CAOD;AA2VH,6BAA6B;AAC7B,qCADY,MAAM,wBAMjB;AA9VD,mCAAmC;AACnC,2CADY,SAAS,QAIpB;AA2ID;;;;;;;;;;;;GAYG;AACH,0HAFa,OAAO,CAKnB"}
|
package/src/displayInfo.d.ts
DELETED
package/src/displayInfo.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"displayInfo.d.ts","sourceRoot":"","sources":["displayInfo.js"],"names":[],"mappings":"AAYO,sDAJI,qBAAqB,aACrB,SAAS,GACP,WAAW,CAiBvB"}
|
package/src/index.d.ts
DELETED
package/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
package/src/issuerKit.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function prepareIssuerKit<K extends AssetKind>(issuerBaggage: any, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined): IssuerKit<K>;
|
|
2
|
-
export function hasIssuer(baggage: any): any;
|
|
3
|
-
export function makeDurableIssuerKit<K extends AssetKind>(issuerBaggage: any, name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined, { elementShape }?: Partial<{
|
|
4
|
-
elementShape: Pattern;
|
|
5
|
-
}> | undefined): IssuerKit<K>;
|
|
6
|
-
export function makeIssuerKit<K extends AssetKind = "nat">(name: string, assetKind?: K | undefined, displayInfo?: AdditionalDisplayInfo | undefined, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined, { elementShape }?: Partial<{
|
|
7
|
-
elementShape: Pattern;
|
|
8
|
-
}> | undefined): IssuerKit<K>;
|
|
9
|
-
export type Baggage = import('@agoric/vat-data').Baggage;
|
|
10
|
-
export type IssuerRecord<K extends AssetKind> = {
|
|
11
|
-
name: string;
|
|
12
|
-
assetKind: K;
|
|
13
|
-
displayInfo: AdditionalDisplayInfo;
|
|
14
|
-
elementShape: Pattern;
|
|
15
|
-
};
|
|
16
|
-
export type IssuerOptionsRecord = Partial<{
|
|
17
|
-
elementShape: Pattern;
|
|
18
|
-
}>;
|
|
19
|
-
//# sourceMappingURL=issuerKit.d.ts.map
|
package/src/issuerKit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issuerKit.d.ts","sourceRoot":"","sources":["issuerKit.js"],"names":[],"mappings":"AA2FO,iLAMN;AASM,6CAAsD;AA+BtD,oFAbI,MAAM;kBAhBqB,OAAO;8BAyC5C;AA6BM,iEAbI,MAAM;kBAzDqB,OAAO;8BAqF1C;sBArLW,OAAO,kBAAkB,EAAE,OAAO;;UAKlC,MAAM;eACN,CAAC;iBACD,qBAAqB;kBACrB,OAAO;;kCAwFP,QAAQ;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function claim<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentP: ERef<Payment<K>>, optAmountShape?: Pattern): Promise<Payment<K>>;
|
|
2
|
-
export function combine<K extends AssetKind>(recoveryPurse: ERef<Purse<K>>, srcPaymentsPs: ERef<Payment<K>>[], optTotalAmount?: Pattern): Promise<Payment<K>>;
|
|
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
|
-
//# sourceMappingURL=legacy-payment-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-payment-helpers.d.ts","sourceRoot":"","sources":["legacy-payment-helpers.js"],"names":[],"mappings":"AA6BO,0HAHI,OAAO,uBAYjB;AAiBM,gIAHI,OAAO,uBA2BjB;AAgBM,2JAUN;AAgBM,oIAFM,QAAQ,OAAO,EAAE,CAAC,CAoB9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copyBagMathHelpers.d.ts","sourceRoot":"","sources":["copyBagMathHelpers.js"],"names":[],"mappings":"AAiBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copySetMathHelpers.d.ts","sourceRoot":"","sources":["copySetMathHelpers.js"],"names":[],"mappings":"AAiBA,mCAAmC;AACnC,iCADW,YAAY,OAAO,CAAC,CAY5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=natMathHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"natMathHelpers.d.ts","sourceRoot":"","sources":["natMathHelpers.js"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,6BAFU,YAAY,QAAQ,CAAC,CAgB5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setMathHelpers.d.ts","sourceRoot":"","sources":["setMathHelpers.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,6BAFU,qBAAqB,CAkB5B"}
|
package/src/payment.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function preparePaymentKind<K extends AssetKind>(issuerBaggage: any, name: string, brand: Brand<K>, PaymentI: InterfaceGuard): () => Payment<K>;
|
|
2
|
-
export type MethodGuard = import('@endo/patterns').MethodGuard;
|
|
3
|
-
export type InterfaceGuard<T extends Record<string | symbol, import("@endo/patterns").MethodGuard> = Record<string | symbol, import("@endo/patterns").MethodGuard>> = import('@endo/patterns').InterfaceGuard<T>;
|
|
4
|
-
export type Baggage = import('@agoric/vat-data').Baggage;
|
|
5
|
-
//# sourceMappingURL=payment.d.ts.map
|
package/src/payment.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["payment.js"],"names":[],"mappings":"AAoBO,kFALI,MAAM,6BAEN,cAAc,oBAgBxB;0BA5Ba,OAAO,gBAAgB,EAAE,WAAW;sKAGrC,OAAO,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;sBAEzC,OAAO,kBAAkB,EAAE,OAAO"}
|
package/src/paymentLedger.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export function preparePaymentLedger<K extends AssetKind>(issuerBaggage: any, name: string, assetKind: K, displayInfo: DisplayInfo<K>, elementShape: Pattern, optShutdownWithFailure?: import("@agoric/swingset-vat").ShutdownWithFailure | undefined): PaymentLedger<K>;
|
|
2
|
-
export type Baggage = import('@agoric/vat-data').Baggage;
|
|
3
|
-
//# sourceMappingURL=paymentLedger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paymentLedger.d.ts","sourceRoot":"","sources":["paymentLedger.js"],"names":[],"mappings":"AAoFO,oFAPI,MAAM,2DAGN,OAAO,6GA2UjB;sBA1Ya,OAAO,kBAAkB,EAAE,OAAO"}
|
package/src/purse.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function preparePurseKind(issuerBaggage: any, name: any, assetKind: any, brand: any, PurseIKit: any, purseMethods: any): () => {
|
|
2
|
-
deposit(srcPayment: any, optAmountShape?: undefined): any;
|
|
3
|
-
withdraw(amount: any): any;
|
|
4
|
-
getCurrentAmount(): Amount<any>;
|
|
5
|
-
getCurrentAmountNotifier(): Notifier<any>;
|
|
6
|
-
getAllegedBrand(): any;
|
|
7
|
-
getDepositFacet(): {
|
|
8
|
-
receive(...args: any[]): any;
|
|
9
|
-
};
|
|
10
|
-
getRecoverySet(): CopySet<Payment<AssetKind>>;
|
|
11
|
-
recoverAll(): Amount<any>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=purse.d.ts.map
|
package/src/purse.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"purse.d.ts","sourceRoot":"","sources":["purse.js"],"names":[],"mappings":"AAOO;;;;;;;;;;;EAkHN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transientNotifier.d.ts","sourceRoot":"","sources":["transientNotifier.js"],"names":[],"mappings":"AAQO;;;EAoBN"}
|
package/src/typeGuards.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export const BrandShape: import("@endo/patterns").Matcher;
|
|
2
|
-
export const IssuerShape: import("@endo/patterns").Matcher;
|
|
3
|
-
export const PaymentShape: import("@endo/patterns").Matcher;
|
|
4
|
-
export const PurseShape: import("@endo/patterns").Matcher;
|
|
5
|
-
export const DepositFacetShape: import("@endo/patterns").Matcher;
|
|
6
|
-
export const NotifierShape: import("@endo/patterns").Matcher;
|
|
7
|
-
export const MintShape: import("@endo/patterns").Matcher;
|
|
8
|
-
export namespace AmountShape {
|
|
9
|
-
export { BrandShape as brand };
|
|
10
|
-
export { AmountValueShape as value };
|
|
11
|
-
}
|
|
12
|
-
export namespace RatioShape {
|
|
13
|
-
export { AmountShape as numerator };
|
|
14
|
-
export { AmountShape as denominator };
|
|
15
|
-
}
|
|
16
|
-
export function isNatValue(value: AmountValue): value is bigint;
|
|
17
|
-
export function isCopySetValue(value: AmountValue): value is CopySet<any>;
|
|
18
|
-
export function isSetValue(value: AmountValue): value is SetValue;
|
|
19
|
-
export function isCopyBagValue(value: AmountValue): value is CopyBag<any>;
|
|
20
|
-
export const MAX_ABSOLUTE_DECIMAL_PLACES: 100;
|
|
21
|
-
export const AssetKindShape: import("@endo/patterns").Matcher;
|
|
22
|
-
export const DisplayInfoShape: import("@endo/patterns").Matcher;
|
|
23
|
-
export namespace IssuerKitShape {
|
|
24
|
-
export { BrandShape as brand };
|
|
25
|
-
export { MintShape as mint };
|
|
26
|
-
export { PurseShape as mintRecoveryPurse };
|
|
27
|
-
export { IssuerShape as issuer };
|
|
28
|
-
export { DisplayInfoShape as displayInfo };
|
|
29
|
-
}
|
|
30
|
-
export const BrandI: import("@endo/patterns").InterfaceGuard<{
|
|
31
|
-
isMyIssuer: import("@endo/patterns").MethodGuard;
|
|
32
|
-
getAllegedName: import("@endo/patterns").MethodGuard;
|
|
33
|
-
getDisplayInfo: import("@endo/patterns").MethodGuard;
|
|
34
|
-
getAmountShape: import("@endo/patterns").MethodGuard;
|
|
35
|
-
}>;
|
|
36
|
-
export function makeIssuerInterfaces(brandShape?: Pattern, assetKindShape?: Pattern, amountShape?: Pattern): {
|
|
37
|
-
IssuerI: import("@endo/patterns").InterfaceGuard<{
|
|
38
|
-
getBrand: import("@endo/patterns").MethodGuard;
|
|
39
|
-
getAllegedName: import("@endo/patterns").MethodGuard;
|
|
40
|
-
getAssetKind: import("@endo/patterns").MethodGuard;
|
|
41
|
-
getDisplayInfo: import("@endo/patterns").MethodGuard;
|
|
42
|
-
makeEmptyPurse: import("@endo/patterns").MethodGuard;
|
|
43
|
-
isLive: import("@endo/patterns").MethodGuard;
|
|
44
|
-
getAmountOf: import("@endo/patterns").MethodGuard;
|
|
45
|
-
burn: import("@endo/patterns").MethodGuard;
|
|
46
|
-
}>;
|
|
47
|
-
MintI: import("@endo/patterns").InterfaceGuard<{
|
|
48
|
-
getIssuer: import("@endo/patterns").MethodGuard;
|
|
49
|
-
mintPayment: import("@endo/patterns").MethodGuard;
|
|
50
|
-
}>;
|
|
51
|
-
PaymentI: import("@endo/patterns").InterfaceGuard<{
|
|
52
|
-
getAllegedBrand: import("@endo/patterns").MethodGuard;
|
|
53
|
-
}>;
|
|
54
|
-
PurseIKit: {
|
|
55
|
-
purse: import("@endo/patterns").InterfaceGuard<{
|
|
56
|
-
getAllegedBrand: import("@endo/patterns").MethodGuard;
|
|
57
|
-
getCurrentAmount: import("@endo/patterns").MethodGuard;
|
|
58
|
-
getCurrentAmountNotifier: import("@endo/patterns").MethodGuard;
|
|
59
|
-
deposit: import("@endo/patterns").MethodGuard;
|
|
60
|
-
getDepositFacet: import("@endo/patterns").MethodGuard;
|
|
61
|
-
withdraw: import("@endo/patterns").MethodGuard;
|
|
62
|
-
getRecoverySet: import("@endo/patterns").MethodGuard;
|
|
63
|
-
recoverAll: import("@endo/patterns").MethodGuard;
|
|
64
|
-
}>;
|
|
65
|
-
depositFacet: import("@endo/patterns").InterfaceGuard<{
|
|
66
|
-
receive: any;
|
|
67
|
-
}>;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
declare const AmountValueShape: import("@endo/patterns").Matcher;
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=typeGuards.d.ts.map
|
package/src/typeGuards.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/types-ambient.d.ts
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
type CopyBag<K extends unknown = any> = import('@endo/patterns').CopyBag<K>;
|
|
2
|
-
/**
|
|
3
|
-
* Amounts are descriptions of digital assets,
|
|
4
|
-
* answering the questions "how much" and "of what kind". Amounts are values
|
|
5
|
-
* labeled with a brand. AmountMath executes the logic of how amounts are
|
|
6
|
-
* changed when digital assets are merged, separated, or otherwise
|
|
7
|
-
* manipulated. For example, a deposit of 2 bucks into a purse that already
|
|
8
|
-
* has 3 bucks gives a new purse balance of 5 bucks. An empty purse has 0
|
|
9
|
-
* bucks. AmountMath relies heavily on polymorphic MathHelpers, which
|
|
10
|
-
* manipulate the unbranded portion.
|
|
11
|
-
*/
|
|
12
|
-
type Amount<K extends AssetKind = AssetKind> = {
|
|
13
|
-
brand: Brand<K>;
|
|
14
|
-
value: AssetValueForKind<K>;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* An
|
|
18
|
-
* `AmountValue` describes a set or quantity of assets that can be owned or
|
|
19
|
-
* shared.
|
|
20
|
-
*
|
|
21
|
-
* A fungible `AmountValue` uses a non-negative bigint to represent a quantity
|
|
22
|
-
* of that many assets.
|
|
23
|
-
*
|
|
24
|
-
* A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
|
|
25
|
-
* a set of whatever asset each key represents. A `Key` is a passable value
|
|
26
|
-
* that can be used as an element in a set (SetStore or CopySet) or as the key
|
|
27
|
-
* in a map (MapStore or CopyMap).
|
|
28
|
-
*
|
|
29
|
-
* `SetValue` is for the deprecated set representation, using an array directly
|
|
30
|
-
* to represent the array of its elements. `CopySet` is the proper
|
|
31
|
-
* representation using a CopySet.
|
|
32
|
-
*
|
|
33
|
-
* A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
|
|
34
|
-
* "Bag" is synonymous with MultiSet, where an element of a bag can be present
|
|
35
|
-
* once or more times, i.e., some positive bigint number of times,
|
|
36
|
-
* representing that quantity of the asset represented by that key.
|
|
37
|
-
*/
|
|
38
|
-
type AmountValue = NatValue | any[] | CopySet | CopyBag;
|
|
39
|
-
/**
|
|
40
|
-
* See doc-comment
|
|
41
|
-
* for `AmountValue`.
|
|
42
|
-
*/
|
|
43
|
-
type AssetKind = 'nat' | 'set' | 'copySet' | 'copyBag';
|
|
44
|
-
type AssetValueForKind<K extends AssetKind> = K extends 'nat' ? NatValue : K extends 'set' ? any[] : K extends 'copySet' ? CopySet : K extends 'copyBag' ? CopyBag : never;
|
|
45
|
-
type AssetKindForValue<V extends AmountValue> = V extends NatValue ? 'nat' : V extends any[] ? 'set' : V extends CopySet ? 'copySet' : V extends CopyBag ? 'copyBag' : never;
|
|
46
|
-
type DisplayInfo<K extends AssetKind = AssetKind> = {
|
|
47
|
-
/**
|
|
48
|
-
* Tells the display software how many
|
|
49
|
-
* decimal places to move the decimal over to the left, or in other words,
|
|
50
|
-
* which position corresponds to whole numbers. We require fungible digital
|
|
51
|
-
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
52
|
-
* be represented in mill, a thousandth of a dollar. In that case,
|
|
53
|
-
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
54
|
-
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
55
|
-
* property should be used for _display purposes only_. Any other use is an
|
|
56
|
-
* anti-pattern.
|
|
57
|
-
*/
|
|
58
|
-
decimalPlaces?: number | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* - the kind of asset, either AssetKind.NAT (fungible)
|
|
61
|
-
* or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
|
|
62
|
-
*/
|
|
63
|
-
assetKind: K;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* The brand identifies the kind of issuer, and has a
|
|
67
|
-
* function to get the alleged name for the kind of asset described. The
|
|
68
|
-
* alleged name (such as 'BTC' or 'moola') is provided by the maker of the
|
|
69
|
-
* issuer and should not be trusted as accurate.
|
|
70
|
-
*
|
|
71
|
-
* Every amount created by a particular AmountMath will share the same brand,
|
|
72
|
-
* but recipients cannot rely on the brand to verify that a purported amount
|
|
73
|
-
* represents the issuer they intended, since the same brand can be reused by
|
|
74
|
-
* a misbehaving issuer.
|
|
75
|
-
*/
|
|
76
|
-
type Brand<K extends AssetKind = AssetKind> = {
|
|
77
|
-
/**
|
|
78
|
-
* Should be used with `issuer.getBrand` to ensure an issuer and brand match.
|
|
79
|
-
*/
|
|
80
|
-
isMyIssuer: (allegedIssuer: ERef<Issuer>) => Promise<boolean>;
|
|
81
|
-
getAllegedName: () => string;
|
|
82
|
-
/**
|
|
83
|
-
* Give information to UI on how
|
|
84
|
-
* to display the amount.
|
|
85
|
-
*/
|
|
86
|
-
getDisplayInfo: () => DisplayInfo<K>;
|
|
87
|
-
getAmountShape: () => Pattern;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Return true if the payment continues to exist.
|
|
91
|
-
*
|
|
92
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
93
|
-
*/
|
|
94
|
-
type IssuerIsLive = (payment: ERef<Payment>) => Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Get the amount of digital assets in the payment.
|
|
97
|
-
* Because the payment is not trusted, we cannot call a method on it directly,
|
|
98
|
-
* and must use the issuer instead.
|
|
99
|
-
*
|
|
100
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
101
|
-
*/
|
|
102
|
-
type IssuerGetAmountOf<K extends AssetKind> = (payment: ERef<Payment>) => Promise<Amount<K>>;
|
|
103
|
-
/**
|
|
104
|
-
* Burn all of the digital assets in the payment.
|
|
105
|
-
* `optAmount` is optional. If `optAmount` is present, the code will insist
|
|
106
|
-
* that the amount of the digital assets in the payment is equal to
|
|
107
|
-
* `optAmount`, to prevent sending the wrong payment and other confusion.
|
|
108
|
-
*
|
|
109
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
110
|
-
*/
|
|
111
|
-
type IssuerBurn = (payment: ERef<Payment>, optAmountShape?: Pattern) => Promise<Amount>;
|
|
112
|
-
/**
|
|
113
|
-
* Transfer all digital assets from the payment to a new
|
|
114
|
-
* payment and delete the original. `optAmount` is optional. If `optAmount` is
|
|
115
|
-
* present, the code will insist that the amount of digital assets in the
|
|
116
|
-
* payment is equal to `optAmount`, to prevent sending the wrong payment and
|
|
117
|
-
* other confusion.
|
|
118
|
-
*
|
|
119
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
120
|
-
*/
|
|
121
|
-
type IssuerClaim<K extends AssetKind> = (payment: ERef<Payment<K>>, optAmountShape?: Pattern) => Promise<Payment<K>>;
|
|
122
|
-
/**
|
|
123
|
-
* Combine multiple payments into one payment.
|
|
124
|
-
*
|
|
125
|
-
* If any of the payments is a promise, the operation will proceed upon
|
|
126
|
-
* resolution.
|
|
127
|
-
*/
|
|
128
|
-
type IssuerCombine<K extends AssetKind> = (paymentsArray: ERef<Payment<K>>[], optTotalAmount?: Amount<K> | undefined) => Promise<Payment<K>>;
|
|
129
|
-
/**
|
|
130
|
-
* Split a single payment into two payments, A and B,
|
|
131
|
-
* according to the paymentAmountA passed in.
|
|
132
|
-
*
|
|
133
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
134
|
-
*/
|
|
135
|
-
type IssuerSplit<K extends AssetKind> = (payment: ERef<Payment<K>>, paymentAmountA: Amount<K>) => Promise<Payment<K>[]>;
|
|
136
|
-
/**
|
|
137
|
-
* Split a single payment into many payments,
|
|
138
|
-
* according to the amounts passed in.
|
|
139
|
-
*
|
|
140
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
141
|
-
*/
|
|
142
|
-
type IssuerSplitMany = (payment: ERef<Payment>, amounts: Amount[]) => Promise<Payment[]>;
|
|
143
|
-
/**
|
|
144
|
-
* The issuer cannot mint a new amount, but it can
|
|
145
|
-
* create empty purses and payments. The issuer can also transform payments
|
|
146
|
-
* (splitting payments, combining payments, burning payments, and claiming
|
|
147
|
-
* payments exclusively). The issuer should be gotten from a trusted source
|
|
148
|
-
* and then relied upon as the decider of whether an untrusted payment is
|
|
149
|
-
* valid.
|
|
150
|
-
*/
|
|
151
|
-
type Issuer<K extends AssetKind = AssetKind> = {
|
|
152
|
-
/**
|
|
153
|
-
* Get the Brand for this Issuer. The Brand
|
|
154
|
-
* indicates the type of digital asset and is shared by the mint, the issuer,
|
|
155
|
-
* and any purses and payments of this particular kind. The brand is not
|
|
156
|
-
* closely held, so this function should not be trusted to identify an issuer
|
|
157
|
-
* alone. Fake digital assets and amount can use another issuer's brand.
|
|
158
|
-
*/
|
|
159
|
-
getBrand: () => Brand<K>;
|
|
160
|
-
/**
|
|
161
|
-
* Get the allegedName for this
|
|
162
|
-
* mint/issuer
|
|
163
|
-
*/
|
|
164
|
-
getAllegedName: () => string;
|
|
165
|
-
/**
|
|
166
|
-
* Get the kind of MathHelpers used by
|
|
167
|
-
* this Issuer.
|
|
168
|
-
*/
|
|
169
|
-
getAssetKind: () => AssetKind;
|
|
170
|
-
/**
|
|
171
|
-
* Give information to UI on how
|
|
172
|
-
* to display amounts for this issuer.
|
|
173
|
-
*/
|
|
174
|
-
getDisplayInfo: () => DisplayInfo<K>;
|
|
175
|
-
/**
|
|
176
|
-
* Make an empty purse of this brand.
|
|
177
|
-
*/
|
|
178
|
-
makeEmptyPurse: () => Purse<K>;
|
|
179
|
-
isLive: IssuerIsLive;
|
|
180
|
-
getAmountOf: IssuerGetAmountOf<K>;
|
|
181
|
-
burn: IssuerBurn;
|
|
182
|
-
};
|
|
183
|
-
type PaymentLedger<K extends AssetKind = AssetKind> = {
|
|
184
|
-
mint: Mint<K>;
|
|
185
|
-
mintRecoveryPurse: Purse<K>;
|
|
186
|
-
issuer: Issuer<K>;
|
|
187
|
-
brand: Brand<K>;
|
|
188
|
-
};
|
|
189
|
-
type IssuerKit<K extends AssetKind = AssetKind> = {
|
|
190
|
-
mint: Mint<K>;
|
|
191
|
-
mintRecoveryPurse: Purse<K>;
|
|
192
|
-
issuer: Issuer<K>;
|
|
193
|
-
brand: Brand<K>;
|
|
194
|
-
displayInfo: DisplayInfo;
|
|
195
|
-
};
|
|
196
|
-
type AdditionalDisplayInfo = {
|
|
197
|
-
/**
|
|
198
|
-
* Tells the display software how many
|
|
199
|
-
* decimal places to move the decimal over to the left, or in other words,
|
|
200
|
-
* which position corresponds to whole numbers. We require fungible digital
|
|
201
|
-
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
202
|
-
* be represented in mill, a thousandth of a dollar. In that case,
|
|
203
|
-
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
204
|
-
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
205
|
-
* property should be used for _display purposes only_. Any other use is an
|
|
206
|
-
* anti-pattern.
|
|
207
|
-
*/
|
|
208
|
-
decimalPlaces?: number | undefined;
|
|
209
|
-
assetKind?: AssetKind | undefined;
|
|
210
|
-
};
|
|
211
|
-
type ShutdownWithFailure = import('@agoric/swingset-vat').ShutdownWithFailure;
|
|
212
|
-
/**
|
|
213
|
-
* Holding a Mint carries the right to issue new digital
|
|
214
|
-
* assets. These assets all have the same kind, which is called a Brand.
|
|
215
|
-
*/
|
|
216
|
-
type Mint<K extends AssetKind = AssetKind> = {
|
|
217
|
-
/**
|
|
218
|
-
* Gets the Issuer for this mint.
|
|
219
|
-
*/
|
|
220
|
-
getIssuer: () => Issuer<K>;
|
|
221
|
-
/**
|
|
222
|
-
* Creates a new
|
|
223
|
-
* Payment containing newly minted amount.
|
|
224
|
-
*/
|
|
225
|
-
mintPayment: (newAmount: Amount<K>) => Payment<K>;
|
|
226
|
-
};
|
|
227
|
-
type DepositFacetReceive = (payment: Payment, optAmountShape?: Pattern) => Amount;
|
|
228
|
-
type DepositFacet = {
|
|
229
|
-
/**
|
|
230
|
-
* Deposit all the contents of payment
|
|
231
|
-
* into the purse that made this facet, returning the amount. If the optional
|
|
232
|
-
* argument `optAmount` does not equal the amount of digital assets in the
|
|
233
|
-
* payment, throw an error.
|
|
234
|
-
*
|
|
235
|
-
* If payment is a promise, throw an error.
|
|
236
|
-
*/
|
|
237
|
-
receive: DepositFacetReceive;
|
|
238
|
-
};
|
|
239
|
-
type PurseDeposit<K extends AssetKind> = (payment: Payment<K>, optAmountShape?: Pattern) => Amount<K>;
|
|
240
|
-
/**
|
|
241
|
-
* Purses hold amount of digital assets of the same
|
|
242
|
-
* brand, but unlike Payments, they are not meant to be sent to others. To
|
|
243
|
-
* transfer digital assets, a Payment should be withdrawn from a Purse. The
|
|
244
|
-
* amount of digital assets in a purse can change through the action of
|
|
245
|
-
* deposit() and withdraw().
|
|
246
|
-
*
|
|
247
|
-
* The primary use for Purses and Payments is for currency-like and goods-like
|
|
248
|
-
* digital assets, but they can also be used to represent other kinds of
|
|
249
|
-
* rights, such as the right to participate in a particular contract.
|
|
250
|
-
*/
|
|
251
|
-
type Purse<K extends AssetKind = AssetKind> = {
|
|
252
|
-
/**
|
|
253
|
-
* Get the alleged Brand for this
|
|
254
|
-
* Purse
|
|
255
|
-
*/
|
|
256
|
-
getAllegedBrand: () => Brand<K>;
|
|
257
|
-
/**
|
|
258
|
-
* Get the amount contained in this
|
|
259
|
-
* purse.
|
|
260
|
-
*/
|
|
261
|
-
getCurrentAmount: () => Amount<K>;
|
|
262
|
-
/**
|
|
263
|
-
* Get a lossy
|
|
264
|
-
* notifier for changes to this purse's balance.
|
|
265
|
-
*/
|
|
266
|
-
getCurrentAmountNotifier: () => LatestTopic<Amount<K>>;
|
|
267
|
-
/**
|
|
268
|
-
* Deposit all the contents of payment into
|
|
269
|
-
* this purse, returning the amount. If the optional argument `optAmount` does
|
|
270
|
-
* not equal the amount of digital assets in the payment, throw an error.
|
|
271
|
-
*
|
|
272
|
-
* If payment is a promise, throw an error.
|
|
273
|
-
*/
|
|
274
|
-
deposit: PurseDeposit<K>;
|
|
275
|
-
/**
|
|
276
|
-
* Return an object whose
|
|
277
|
-
* `receive` method deposits to the current Purse.
|
|
278
|
-
*/
|
|
279
|
-
getDepositFacet: () => DepositFacet;
|
|
280
|
-
/**
|
|
281
|
-
* Withdraw amount from
|
|
282
|
-
* this purse into a new Payment.
|
|
283
|
-
*/
|
|
284
|
-
withdraw: (amount: Amount<K>) => Payment<K>;
|
|
285
|
-
/**
|
|
286
|
-
* The set of payments
|
|
287
|
-
* withdrawn from this purse that are still live. These are the payments that
|
|
288
|
-
* can still be recovered in emergencies by, for example, depositing into this
|
|
289
|
-
* purse. Such a deposit action is like canceling an outstanding check because
|
|
290
|
-
* you're tired of waiting for it. Once your cancellation is acknowledged, you
|
|
291
|
-
* can spend the assets at stake on other things. Afterwards, if the recipient
|
|
292
|
-
* of the original check finally gets around to depositing it, their deposit
|
|
293
|
-
* fails.
|
|
294
|
-
*/
|
|
295
|
-
getRecoverySet: () => CopySet<Payment<K>>;
|
|
296
|
-
/**
|
|
297
|
-
* For use in emergencies, such as coming
|
|
298
|
-
* back from a traumatic crash and upgrade. This deposits all the payments in
|
|
299
|
-
* this purse's recovery set into the purse itself, returning the total amount
|
|
300
|
-
* of assets recovered.
|
|
301
|
-
*/
|
|
302
|
-
recoverAll: () => Amount<K>;
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Payments hold amount of digital assets of the same
|
|
306
|
-
* brand in transit. Payments can be deposited in purses, split into multiple
|
|
307
|
-
* payments, combined, and claimed (getting an exclusive payment). Payments
|
|
308
|
-
* are linear, meaning that either a payment has the same amount of digital
|
|
309
|
-
* assets it started with, or it is used up entirely. It is impossible to
|
|
310
|
-
* partially use a payment.
|
|
311
|
-
*
|
|
312
|
-
* Payments are often received from other actors and therefore should not be
|
|
313
|
-
* trusted themselves. To get the amount of digital assets in a payment, use
|
|
314
|
-
* the trusted issuer: issuer.getAmountOf(payment),
|
|
315
|
-
*
|
|
316
|
-
* Payments can be converted to Purses by getting a trusted issuer and calling
|
|
317
|
-
* `issuer.makeEmptyPurse()` to create a purse, then
|
|
318
|
-
* `purse.deposit(payment)`.
|
|
319
|
-
*/
|
|
320
|
-
type Payment<K extends AssetKind = AssetKind> = {
|
|
321
|
-
/**
|
|
322
|
-
* Get the allegedBrand, indicating
|
|
323
|
-
* the type of digital asset this payment purports to be, and which issuer to
|
|
324
|
-
* use. Because payments are not trusted, any method calls on payments should
|
|
325
|
-
* be treated with suspicion and verified elsewhere.
|
|
326
|
-
*/
|
|
327
|
-
getAllegedBrand: () => Brand<K>;
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* All of the difference in how digital asset
|
|
331
|
-
* amount are manipulated can be reduced to the behavior of the math on
|
|
332
|
-
* values. We extract this custom logic into mathHelpers. MathHelpers are
|
|
333
|
-
* about value arithmetic, whereas AmountMath is about amounts, which are the
|
|
334
|
-
* values labeled with a brand. AmountMath use mathHelpers to do their value
|
|
335
|
-
* arithmetic, and then brand the results, making a new amount.
|
|
336
|
-
*
|
|
337
|
-
* The MathHelpers are designed to be called only from AmountMath, and so all
|
|
338
|
-
* methods but coerce can assume their inputs are valid. They only need to do
|
|
339
|
-
* output validation, and only when there is a possibility of invalid output.
|
|
340
|
-
*/
|
|
341
|
-
type MathHelpers<V extends AmountValue> = {
|
|
342
|
-
/**
|
|
343
|
-
* Check the kind of this value and
|
|
344
|
-
* throw if it is not the expected kind.
|
|
345
|
-
*/
|
|
346
|
-
doCoerce: (allegedValue: V) => V;
|
|
347
|
-
/**
|
|
348
|
-
* Get the representation for the identity
|
|
349
|
-
* element (often 0 or an empty array)
|
|
350
|
-
*/
|
|
351
|
-
doMakeEmpty: () => V;
|
|
352
|
-
/**
|
|
353
|
-
* Is the value the identity
|
|
354
|
-
* element?
|
|
355
|
-
*/
|
|
356
|
-
doIsEmpty: (value: V) => boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Is the left greater than
|
|
359
|
-
* or equal to the right?
|
|
360
|
-
*/
|
|
361
|
-
doIsGTE: (left: V, right: V) => boolean;
|
|
362
|
-
/**
|
|
363
|
-
* Does left equal right?
|
|
364
|
-
*/
|
|
365
|
-
doIsEqual: (left: V, right: V) => boolean;
|
|
366
|
-
/**
|
|
367
|
-
* Return the left combined with the
|
|
368
|
-
* right.
|
|
369
|
-
*/
|
|
370
|
-
doAdd: (left: V, right: V) => V;
|
|
371
|
-
/**
|
|
372
|
-
* Return what remains after
|
|
373
|
-
* removing the right from the left. If something in the right was not in the
|
|
374
|
-
* left, we throw an error.
|
|
375
|
-
*/
|
|
376
|
-
doSubtract: (left: V, right: V) => V;
|
|
377
|
-
};
|
|
378
|
-
type NatValue = bigint;
|
|
379
|
-
type SetValue = Key[];
|
|
380
|
-
//# sourceMappingURL=types-ambient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-ambient.d.ts","sourceRoot":"","sources":["types-ambient.js"],"names":[],"mappings":"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"}
|
package/src/types.d.ts
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
export type CopyBag<K extends unknown = any> = import('@endo/patterns').CopyBag<K>;
|
|
2
|
-
/**
|
|
3
|
-
* Amounts are descriptions of digital assets,
|
|
4
|
-
* answering the questions "how much" and "of what kind". Amounts are values
|
|
5
|
-
* labeled with a brand. AmountMath executes the logic of how amounts are
|
|
6
|
-
* changed when digital assets are merged, separated, or otherwise
|
|
7
|
-
* manipulated. For example, a deposit of 2 bucks into a purse that already
|
|
8
|
-
* has 3 bucks gives a new purse balance of 5 bucks. An empty purse has 0
|
|
9
|
-
* bucks. AmountMath relies heavily on polymorphic MathHelpers, which
|
|
10
|
-
* manipulate the unbranded portion.
|
|
11
|
-
*/
|
|
12
|
-
export type Amount<K extends AssetKind = AssetKind> = {
|
|
13
|
-
brand: Brand<K>;
|
|
14
|
-
value: AssetValueForKind<K>;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* An
|
|
18
|
-
* `AmountValue` describes a set or quantity of assets that can be owned or
|
|
19
|
-
* shared.
|
|
20
|
-
*
|
|
21
|
-
* A fungible `AmountValue` uses a non-negative bigint to represent a quantity
|
|
22
|
-
* of that many assets.
|
|
23
|
-
*
|
|
24
|
-
* A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
|
|
25
|
-
* a set of whatever asset each key represents. A `Key` is a passable value
|
|
26
|
-
* that can be used as an element in a set (SetStore or CopySet) or as the key
|
|
27
|
-
* in a map (MapStore or CopyMap).
|
|
28
|
-
*
|
|
29
|
-
* `SetValue` is for the deprecated set representation, using an array directly
|
|
30
|
-
* to represent the array of its elements. `CopySet` is the proper
|
|
31
|
-
* representation using a CopySet.
|
|
32
|
-
*
|
|
33
|
-
* A semi-fungible `CopyBag` is represented as a `CopyBag` of `Key` objects.
|
|
34
|
-
* "Bag" is synonymous with MultiSet, where an element of a bag can be present
|
|
35
|
-
* once or more times, i.e., some positive bigint number of times,
|
|
36
|
-
* representing that quantity of the asset represented by that key.
|
|
37
|
-
*/
|
|
38
|
-
export type AmountValue = NatValue | any[] | CopySet | CopyBag;
|
|
39
|
-
/**
|
|
40
|
-
* See doc-comment
|
|
41
|
-
* for `AmountValue`.
|
|
42
|
-
*/
|
|
43
|
-
export type AssetKind = 'nat' | 'set' | 'copySet' | 'copyBag';
|
|
44
|
-
export type AssetValueForKind<K extends AssetKind> = K extends 'nat' ? NatValue : K extends 'set' ? any[] : K extends 'copySet' ? CopySet : K extends 'copyBag' ? CopyBag : never;
|
|
45
|
-
export type AssetKindForValue<V extends AmountValue> = V extends NatValue ? 'nat' : V extends any[] ? 'set' : V extends CopySet ? 'copySet' : V extends CopyBag ? 'copyBag' : never;
|
|
46
|
-
export type DisplayInfo<K extends AssetKind = AssetKind> = {
|
|
47
|
-
/**
|
|
48
|
-
* Tells the display software how many
|
|
49
|
-
* decimal places to move the decimal over to the left, or in other words,
|
|
50
|
-
* which position corresponds to whole numbers. We require fungible digital
|
|
51
|
-
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
52
|
-
* be represented in mill, a thousandth of a dollar. In that case,
|
|
53
|
-
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
54
|
-
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
55
|
-
* property should be used for _display purposes only_. Any other use is an
|
|
56
|
-
* anti-pattern.
|
|
57
|
-
*/
|
|
58
|
-
decimalPlaces?: number | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* - the kind of asset, either AssetKind.NAT (fungible)
|
|
61
|
-
* or AssetKind.SET or AssetKind.COPY_SET (non-fungible)
|
|
62
|
-
*/
|
|
63
|
-
assetKind: K;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* The brand identifies the kind of issuer, and has a
|
|
67
|
-
* function to get the alleged name for the kind of asset described. The
|
|
68
|
-
* alleged name (such as 'BTC' or 'moola') is provided by the maker of the
|
|
69
|
-
* issuer and should not be trusted as accurate.
|
|
70
|
-
*
|
|
71
|
-
* Every amount created by a particular AmountMath will share the same brand,
|
|
72
|
-
* but recipients cannot rely on the brand to verify that a purported amount
|
|
73
|
-
* represents the issuer they intended, since the same brand can be reused by
|
|
74
|
-
* a misbehaving issuer.
|
|
75
|
-
*/
|
|
76
|
-
export type Brand<K extends AssetKind = AssetKind> = {
|
|
77
|
-
/**
|
|
78
|
-
* Should be used with `issuer.getBrand` to ensure an issuer and brand match.
|
|
79
|
-
*/
|
|
80
|
-
isMyIssuer: (allegedIssuer: ERef<Issuer>) => Promise<boolean>;
|
|
81
|
-
getAllegedName: () => string;
|
|
82
|
-
/**
|
|
83
|
-
* Give information to UI on how
|
|
84
|
-
* to display the amount.
|
|
85
|
-
*/
|
|
86
|
-
getDisplayInfo: () => DisplayInfo<K>;
|
|
87
|
-
getAmountShape: () => Pattern;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Return true if the payment continues to exist.
|
|
91
|
-
*
|
|
92
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
93
|
-
*/
|
|
94
|
-
export type IssuerIsLive = (payment: ERef<Payment>) => Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Get the amount of digital assets in the payment.
|
|
97
|
-
* Because the payment is not trusted, we cannot call a method on it directly,
|
|
98
|
-
* and must use the issuer instead.
|
|
99
|
-
*
|
|
100
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
101
|
-
*/
|
|
102
|
-
export type IssuerGetAmountOf<K extends AssetKind> = (payment: ERef<Payment>) => Promise<Amount<K>>;
|
|
103
|
-
/**
|
|
104
|
-
* Burn all of the digital assets in the payment.
|
|
105
|
-
* `optAmount` is optional. If `optAmount` is present, the code will insist
|
|
106
|
-
* that the amount of the digital assets in the payment is equal to
|
|
107
|
-
* `optAmount`, to prevent sending the wrong payment and other confusion.
|
|
108
|
-
*
|
|
109
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
110
|
-
*/
|
|
111
|
-
export type IssuerBurn = (payment: ERef<Payment>, optAmountShape?: Pattern) => Promise<Amount>;
|
|
112
|
-
/**
|
|
113
|
-
* Transfer all digital assets from the payment to a new
|
|
114
|
-
* payment and delete the original. `optAmount` is optional. If `optAmount` is
|
|
115
|
-
* present, the code will insist that the amount of digital assets in the
|
|
116
|
-
* payment is equal to `optAmount`, to prevent sending the wrong payment and
|
|
117
|
-
* other confusion.
|
|
118
|
-
*
|
|
119
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
120
|
-
*/
|
|
121
|
-
export type IssuerClaim<K extends AssetKind> = (payment: ERef<Payment<K>>, optAmountShape?: Pattern) => Promise<Payment<K>>;
|
|
122
|
-
/**
|
|
123
|
-
* Combine multiple payments into one payment.
|
|
124
|
-
*
|
|
125
|
-
* If any of the payments is a promise, the operation will proceed upon
|
|
126
|
-
* resolution.
|
|
127
|
-
*/
|
|
128
|
-
export type IssuerCombine<K extends AssetKind> = (paymentsArray: ERef<Payment<K>>[], optTotalAmount?: Amount<K> | undefined) => Promise<Payment<K>>;
|
|
129
|
-
/**
|
|
130
|
-
* Split a single payment into two payments, A and B,
|
|
131
|
-
* according to the paymentAmountA passed in.
|
|
132
|
-
*
|
|
133
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
134
|
-
*/
|
|
135
|
-
export type IssuerSplit<K extends AssetKind> = (payment: ERef<Payment<K>>, paymentAmountA: Amount<K>) => Promise<Payment<K>[]>;
|
|
136
|
-
/**
|
|
137
|
-
* Split a single payment into many payments,
|
|
138
|
-
* according to the amounts passed in.
|
|
139
|
-
*
|
|
140
|
-
* If the payment is a promise, the operation will proceed upon resolution.
|
|
141
|
-
*/
|
|
142
|
-
export type IssuerSplitMany = (payment: ERef<Payment>, amounts: Amount[]) => Promise<Payment[]>;
|
|
143
|
-
/**
|
|
144
|
-
* The issuer cannot mint a new amount, but it can
|
|
145
|
-
* create empty purses and payments. The issuer can also transform payments
|
|
146
|
-
* (splitting payments, combining payments, burning payments, and claiming
|
|
147
|
-
* payments exclusively). The issuer should be gotten from a trusted source
|
|
148
|
-
* and then relied upon as the decider of whether an untrusted payment is
|
|
149
|
-
* valid.
|
|
150
|
-
*/
|
|
151
|
-
export type Issuer<K extends AssetKind = AssetKind> = {
|
|
152
|
-
/**
|
|
153
|
-
* Get the Brand for this Issuer. The Brand
|
|
154
|
-
* indicates the type of digital asset and is shared by the mint, the issuer,
|
|
155
|
-
* and any purses and payments of this particular kind. The brand is not
|
|
156
|
-
* closely held, so this function should not be trusted to identify an issuer
|
|
157
|
-
* alone. Fake digital assets and amount can use another issuer's brand.
|
|
158
|
-
*/
|
|
159
|
-
getBrand: () => Brand<K>;
|
|
160
|
-
/**
|
|
161
|
-
* Get the allegedName for this
|
|
162
|
-
* mint/issuer
|
|
163
|
-
*/
|
|
164
|
-
getAllegedName: () => string;
|
|
165
|
-
/**
|
|
166
|
-
* Get the kind of MathHelpers used by
|
|
167
|
-
* this Issuer.
|
|
168
|
-
*/
|
|
169
|
-
getAssetKind: () => AssetKind;
|
|
170
|
-
/**
|
|
171
|
-
* Give information to UI on how
|
|
172
|
-
* to display amounts for this issuer.
|
|
173
|
-
*/
|
|
174
|
-
getDisplayInfo: () => DisplayInfo<K>;
|
|
175
|
-
/**
|
|
176
|
-
* Make an empty purse of this brand.
|
|
177
|
-
*/
|
|
178
|
-
makeEmptyPurse: () => Purse<K>;
|
|
179
|
-
isLive: IssuerIsLive;
|
|
180
|
-
getAmountOf: IssuerGetAmountOf<K>;
|
|
181
|
-
burn: IssuerBurn;
|
|
182
|
-
};
|
|
183
|
-
export type PaymentLedger<K extends AssetKind = AssetKind> = {
|
|
184
|
-
mint: Mint<K>;
|
|
185
|
-
mintRecoveryPurse: Purse<K>;
|
|
186
|
-
issuer: Issuer<K>;
|
|
187
|
-
brand: Brand<K>;
|
|
188
|
-
};
|
|
189
|
-
export type IssuerKit<K extends AssetKind = AssetKind> = {
|
|
190
|
-
mint: Mint<K>;
|
|
191
|
-
mintRecoveryPurse: Purse<K>;
|
|
192
|
-
issuer: Issuer<K>;
|
|
193
|
-
brand: Brand<K>;
|
|
194
|
-
displayInfo: DisplayInfo;
|
|
195
|
-
};
|
|
196
|
-
export type AdditionalDisplayInfo = {
|
|
197
|
-
/**
|
|
198
|
-
* Tells the display software how many
|
|
199
|
-
* decimal places to move the decimal over to the left, or in other words,
|
|
200
|
-
* which position corresponds to whole numbers. We require fungible digital
|
|
201
|
-
* assets to be represented in integers, in the smallest unit (i.e. USD might
|
|
202
|
-
* be represented in mill, a thousandth of a dollar. In that case,
|
|
203
|
-
* `decimalPlaces` would be 3.) This property is optional, and for
|
|
204
|
-
* non-fungible digital assets, should not be specified. The decimalPlaces
|
|
205
|
-
* property should be used for _display purposes only_. Any other use is an
|
|
206
|
-
* anti-pattern.
|
|
207
|
-
*/
|
|
208
|
-
decimalPlaces?: number | undefined;
|
|
209
|
-
assetKind?: AssetKind | undefined;
|
|
210
|
-
};
|
|
211
|
-
export type ShutdownWithFailure = import('@agoric/swingset-vat').ShutdownWithFailure;
|
|
212
|
-
/**
|
|
213
|
-
* Holding a Mint carries the right to issue new digital
|
|
214
|
-
* assets. These assets all have the same kind, which is called a Brand.
|
|
215
|
-
*/
|
|
216
|
-
export type Mint<K extends AssetKind = AssetKind> = {
|
|
217
|
-
/**
|
|
218
|
-
* Gets the Issuer for this mint.
|
|
219
|
-
*/
|
|
220
|
-
getIssuer: () => Issuer<K>;
|
|
221
|
-
/**
|
|
222
|
-
* Creates a new
|
|
223
|
-
* Payment containing newly minted amount.
|
|
224
|
-
*/
|
|
225
|
-
mintPayment: (newAmount: Amount<K>) => Payment<K>;
|
|
226
|
-
};
|
|
227
|
-
export type DepositFacetReceive = (payment: Payment, optAmountShape?: Pattern) => Amount;
|
|
228
|
-
export type DepositFacet = {
|
|
229
|
-
/**
|
|
230
|
-
* Deposit all the contents of payment
|
|
231
|
-
* into the purse that made this facet, returning the amount. If the optional
|
|
232
|
-
* argument `optAmount` does not equal the amount of digital assets in the
|
|
233
|
-
* payment, throw an error.
|
|
234
|
-
*
|
|
235
|
-
* If payment is a promise, throw an error.
|
|
236
|
-
*/
|
|
237
|
-
receive: DepositFacetReceive;
|
|
238
|
-
};
|
|
239
|
-
export type PurseDeposit<K extends AssetKind> = (payment: Payment<K>, optAmountShape?: Pattern) => Amount<K>;
|
|
240
|
-
/**
|
|
241
|
-
* Purses hold amount of digital assets of the same
|
|
242
|
-
* brand, but unlike Payments, they are not meant to be sent to others. To
|
|
243
|
-
* transfer digital assets, a Payment should be withdrawn from a Purse. The
|
|
244
|
-
* amount of digital assets in a purse can change through the action of
|
|
245
|
-
* deposit() and withdraw().
|
|
246
|
-
*
|
|
247
|
-
* The primary use for Purses and Payments is for currency-like and goods-like
|
|
248
|
-
* digital assets, but they can also be used to represent other kinds of
|
|
249
|
-
* rights, such as the right to participate in a particular contract.
|
|
250
|
-
*/
|
|
251
|
-
export type Purse<K extends AssetKind = AssetKind> = {
|
|
252
|
-
/**
|
|
253
|
-
* Get the alleged Brand for this
|
|
254
|
-
* Purse
|
|
255
|
-
*/
|
|
256
|
-
getAllegedBrand: () => Brand<K>;
|
|
257
|
-
/**
|
|
258
|
-
* Get the amount contained in this
|
|
259
|
-
* purse.
|
|
260
|
-
*/
|
|
261
|
-
getCurrentAmount: () => Amount<K>;
|
|
262
|
-
/**
|
|
263
|
-
* Get a lossy
|
|
264
|
-
* notifier for changes to this purse's balance.
|
|
265
|
-
*/
|
|
266
|
-
getCurrentAmountNotifier: () => LatestTopic<Amount<K>>;
|
|
267
|
-
/**
|
|
268
|
-
* Deposit all the contents of payment into
|
|
269
|
-
* this purse, returning the amount. If the optional argument `optAmount` does
|
|
270
|
-
* not equal the amount of digital assets in the payment, throw an error.
|
|
271
|
-
*
|
|
272
|
-
* If payment is a promise, throw an error.
|
|
273
|
-
*/
|
|
274
|
-
deposit: PurseDeposit<K>;
|
|
275
|
-
/**
|
|
276
|
-
* Return an object whose
|
|
277
|
-
* `receive` method deposits to the current Purse.
|
|
278
|
-
*/
|
|
279
|
-
getDepositFacet: () => DepositFacet;
|
|
280
|
-
/**
|
|
281
|
-
* Withdraw amount from
|
|
282
|
-
* this purse into a new Payment.
|
|
283
|
-
*/
|
|
284
|
-
withdraw: (amount: Amount<K>) => Payment<K>;
|
|
285
|
-
/**
|
|
286
|
-
* The set of payments
|
|
287
|
-
* withdrawn from this purse that are still live. These are the payments that
|
|
288
|
-
* can still be recovered in emergencies by, for example, depositing into this
|
|
289
|
-
* purse. Such a deposit action is like canceling an outstanding check because
|
|
290
|
-
* you're tired of waiting for it. Once your cancellation is acknowledged, you
|
|
291
|
-
* can spend the assets at stake on other things. Afterwards, if the recipient
|
|
292
|
-
* of the original check finally gets around to depositing it, their deposit
|
|
293
|
-
* fails.
|
|
294
|
-
*/
|
|
295
|
-
getRecoverySet: () => CopySet<Payment<K>>;
|
|
296
|
-
/**
|
|
297
|
-
* For use in emergencies, such as coming
|
|
298
|
-
* back from a traumatic crash and upgrade. This deposits all the payments in
|
|
299
|
-
* this purse's recovery set into the purse itself, returning the total amount
|
|
300
|
-
* of assets recovered.
|
|
301
|
-
*/
|
|
302
|
-
recoverAll: () => Amount<K>;
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Payments hold amount of digital assets of the same
|
|
306
|
-
* brand in transit. Payments can be deposited in purses, split into multiple
|
|
307
|
-
* payments, combined, and claimed (getting an exclusive payment). Payments
|
|
308
|
-
* are linear, meaning that either a payment has the same amount of digital
|
|
309
|
-
* assets it started with, or it is used up entirely. It is impossible to
|
|
310
|
-
* partially use a payment.
|
|
311
|
-
*
|
|
312
|
-
* Payments are often received from other actors and therefore should not be
|
|
313
|
-
* trusted themselves. To get the amount of digital assets in a payment, use
|
|
314
|
-
* the trusted issuer: issuer.getAmountOf(payment),
|
|
315
|
-
*
|
|
316
|
-
* Payments can be converted to Purses by getting a trusted issuer and calling
|
|
317
|
-
* `issuer.makeEmptyPurse()` to create a purse, then
|
|
318
|
-
* `purse.deposit(payment)`.
|
|
319
|
-
*/
|
|
320
|
-
export type Payment<K extends AssetKind = AssetKind> = {
|
|
321
|
-
/**
|
|
322
|
-
* Get the allegedBrand, indicating
|
|
323
|
-
* the type of digital asset this payment purports to be, and which issuer to
|
|
324
|
-
* use. Because payments are not trusted, any method calls on payments should
|
|
325
|
-
* be treated with suspicion and verified elsewhere.
|
|
326
|
-
*/
|
|
327
|
-
getAllegedBrand: () => Brand<K>;
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* All of the difference in how digital asset
|
|
331
|
-
* amount are manipulated can be reduced to the behavior of the math on
|
|
332
|
-
* values. We extract this custom logic into mathHelpers. MathHelpers are
|
|
333
|
-
* about value arithmetic, whereas AmountMath is about amounts, which are the
|
|
334
|
-
* values labeled with a brand. AmountMath use mathHelpers to do their value
|
|
335
|
-
* arithmetic, and then brand the results, making a new amount.
|
|
336
|
-
*
|
|
337
|
-
* The MathHelpers are designed to be called only from AmountMath, and so all
|
|
338
|
-
* methods but coerce can assume their inputs are valid. They only need to do
|
|
339
|
-
* output validation, and only when there is a possibility of invalid output.
|
|
340
|
-
*/
|
|
341
|
-
export type MathHelpers<V extends AmountValue> = {
|
|
342
|
-
/**
|
|
343
|
-
* Check the kind of this value and
|
|
344
|
-
* throw if it is not the expected kind.
|
|
345
|
-
*/
|
|
346
|
-
doCoerce: (allegedValue: V) => V;
|
|
347
|
-
/**
|
|
348
|
-
* Get the representation for the identity
|
|
349
|
-
* element (often 0 or an empty array)
|
|
350
|
-
*/
|
|
351
|
-
doMakeEmpty: () => V;
|
|
352
|
-
/**
|
|
353
|
-
* Is the value the identity
|
|
354
|
-
* element?
|
|
355
|
-
*/
|
|
356
|
-
doIsEmpty: (value: V) => boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Is the left greater than
|
|
359
|
-
* or equal to the right?
|
|
360
|
-
*/
|
|
361
|
-
doIsGTE: (left: V, right: V) => boolean;
|
|
362
|
-
/**
|
|
363
|
-
* Does left equal right?
|
|
364
|
-
*/
|
|
365
|
-
doIsEqual: (left: V, right: V) => boolean;
|
|
366
|
-
/**
|
|
367
|
-
* Return the left combined with the
|
|
368
|
-
* right.
|
|
369
|
-
*/
|
|
370
|
-
doAdd: (left: V, right: V) => V;
|
|
371
|
-
/**
|
|
372
|
-
* Return what remains after
|
|
373
|
-
* removing the right from the left. If something in the right was not in the
|
|
374
|
-
* left, we throw an error.
|
|
375
|
-
*/
|
|
376
|
-
doSubtract: (left: V, right: V) => V;
|
|
377
|
-
};
|
|
378
|
-
export type NatValue = bigint;
|
|
379
|
-
export type SetValue = Key[];
|
|
380
|
-
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"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"}
|