@agoric/ertp 0.16.3-dev-ecf2d8e.0 → 0.16.3-other-dev-70beeb7.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/CHANGELOG.md +743 -0
- package/package.json +17 -21
- package/src/amountMath.d.ts +13 -14
- package/src/amountMath.d.ts.map +1 -1
- package/src/amountMath.js +63 -57
- package/src/issuerKit.d.ts +3 -3
- package/src/issuerKit.d.ts.map +1 -1
- package/src/issuerKit.js +61 -55
- package/src/legacy-payment-helpers.d.ts.map +1 -1
- package/src/legacy-payment-helpers.js +28 -23
- package/src/mathHelpers/copyBagMathHelpers.d.ts +3 -1
- package/src/mathHelpers/copyBagMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/copyBagMathHelpers.js +3 -1
- package/src/mathHelpers/copySetMathHelpers.d.ts +3 -1
- package/src/mathHelpers/copySetMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/copySetMathHelpers.js +3 -1
- package/src/mathHelpers/natMathHelpers.d.ts +7 -6
- package/src/mathHelpers/natMathHelpers.d.ts.map +1 -1
- package/src/mathHelpers/natMathHelpers.js +7 -6
- package/src/payment.d.ts +1 -3
- package/src/payment.d.ts.map +1 -1
- package/src/payment.js +0 -5
- package/src/paymentLedger.d.ts +1 -1
- package/src/paymentLedger.d.ts.map +1 -1
- package/src/paymentLedger.js +40 -36
- package/src/typeGuards.d.ts +6 -36
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +43 -37
- package/src/types-ambient.d.ts +174 -178
- package/src/types-ambient.d.ts.map +1 -1
- package/src/types-ambient.js +280 -217
- package/src/types.d.ts +174 -178
- package/src/types.d.ts.map +1 -1
- package/src/types.js +280 -217
package/src/types.d.ts
CHANGED
|
@@ -1,87 +1,86 @@
|
|
|
1
|
-
export type CopyBag<K extends unknown = any> = import('@endo/patterns').CopyBag<K>;
|
|
2
1
|
/**
|
|
3
|
-
* Amounts are descriptions of digital assets,
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
2
|
+
* Amounts are descriptions of digital assets, answering the questions
|
|
3
|
+
* "how much" and "of what kind". Amounts are values labeled with a brand.
|
|
4
|
+
* AmountMath executes the logic of how amounts are changed when digital
|
|
5
|
+
* assets are merged, separated, or otherwise manipulated. For
|
|
6
|
+
* example, a deposit of 2 bucks into a purse that already has 3 bucks
|
|
7
|
+
* gives a new purse balance of 5 bucks. An empty purse has 0 bucks. AmountMath
|
|
8
|
+
* relies heavily on polymorphic MathHelpers, which manipulate the unbranded
|
|
9
|
+
* portion.
|
|
11
10
|
*/
|
|
12
11
|
export type Amount<K extends AssetKind = AssetKind> = {
|
|
13
12
|
brand: Brand<K>;
|
|
14
13
|
value: AssetValueForKind<K>;
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
|
-
* An
|
|
18
|
-
*
|
|
19
|
-
* shared.
|
|
16
|
+
* An `AmountValue` describes a set or quantity of assets that can be owned or
|
|
17
|
+
* shared.
|
|
20
18
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* A fungible `AmountValue` uses a non-negative bigint to represent a quantity
|
|
20
|
+
* of that many assets.
|
|
23
21
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* A non-fungible `AmountValue` uses an array or CopySet of `Key`s to represent
|
|
23
|
+
* a set of whatever asset each key represents. A `Key` is a passable value
|
|
24
|
+
* that can be used as an element in a set (SetStore or CopySet) or as the
|
|
25
|
+
* key in a map (MapStore or CopyMap).
|
|
28
26
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* `SetValue` is for the deprecated set representation, using an array directly
|
|
28
|
+
* to represent the array of its elements. `CopySet` is the proper
|
|
29
|
+
* representation using a CopySet.
|
|
32
30
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
31
|
+
* A semi-fungible `CopyBag` is represented as a
|
|
32
|
+
* `CopyBag` of `Key` objects. "Bag" is synonymous with MultiSet, where an
|
|
33
|
+
* element of a bag can be present once or more times, i.e., some positive
|
|
34
|
+
* bigint number of times, representing that quantity of the asset represented
|
|
35
|
+
* by that key.
|
|
37
36
|
*/
|
|
38
37
|
export type AmountValue = NatValue | any[] | CopySet | CopyBag;
|
|
39
38
|
/**
|
|
40
|
-
* See doc-comment
|
|
41
|
-
* for `AmountValue`.
|
|
39
|
+
* See doc-comment for `AmountValue`.
|
|
42
40
|
*/
|
|
43
41
|
export type AssetKind = 'nat' | 'set' | 'copySet' | 'copyBag';
|
|
44
42
|
export type AssetValueForKind<K extends AssetKind> = K extends 'nat' ? NatValue : K extends 'set' ? any[] : K extends 'copySet' ? CopySet : K extends 'copyBag' ? CopyBag : never;
|
|
45
43
|
export type AssetKindForValue<V extends AmountValue> = V extends NatValue ? 'nat' : V extends any[] ? 'set' : V extends CopySet ? 'copySet' : V extends CopyBag ? 'copyBag' : never;
|
|
46
44
|
export type DisplayInfo<K extends AssetKind = AssetKind> = {
|
|
47
45
|
/**
|
|
48
|
-
* Tells the display software how
|
|
49
|
-
* decimal places to move the decimal over to the left, or in
|
|
50
|
-
* which position corresponds to whole numbers. We
|
|
51
|
-
* assets to be represented in integers, in
|
|
52
|
-
* be represented in mill, a
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
46
|
+
* Tells the display software how
|
|
47
|
+
* many decimal places to move the decimal over to the left, or in
|
|
48
|
+
* other words, which position corresponds to whole numbers. We
|
|
49
|
+
* require fungible digital assets to be represented in integers, in
|
|
50
|
+
* the smallest unit (i.e. USD might be represented in mill, a
|
|
51
|
+
* thousandth of a dollar. In that case, `decimalPlaces` would be
|
|
52
|
+
* 3.) This property is optional, and for non-fungible digital
|
|
53
|
+
* assets, should not be specified. The decimalPlaces property
|
|
54
|
+
* should be used for *display purposes only*. Any other use is an
|
|
56
55
|
* anti-pattern.
|
|
57
56
|
*/
|
|
58
57
|
decimalPlaces?: number | undefined;
|
|
59
58
|
/**
|
|
60
|
-
* - the kind of asset, either
|
|
61
|
-
*
|
|
59
|
+
* - the kind of asset, either
|
|
60
|
+
* AssetKind.NAT (fungible) or
|
|
61
|
+
* AssetKind.SET or AssetKind.COPY_SET (non-fungible)
|
|
62
62
|
*/
|
|
63
63
|
assetKind: K;
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
* The brand identifies the kind of issuer, and has a
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
* The brand identifies the kind of issuer, and has a function to get the
|
|
67
|
+
* alleged name for the kind of asset described. The alleged name (such
|
|
68
|
+
* as 'BTC' or 'moola') is provided by the maker of the issuer and should
|
|
69
|
+
* not be trusted as accurate.
|
|
70
70
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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
75
|
*/
|
|
76
76
|
export type Brand<K extends AssetKind = AssetKind> = {
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* Should be used with `issuer.getBrand` to ensure an issuer and brand match.
|
|
79
79
|
*/
|
|
80
80
|
isMyIssuer: (allegedIssuer: ERef<Issuer>) => Promise<boolean>;
|
|
81
81
|
getAllegedName: () => string;
|
|
82
82
|
/**
|
|
83
|
-
* Give information to UI on how
|
|
84
|
-
* to display the amount.
|
|
83
|
+
* Give information to UI on how to display the amount.
|
|
85
84
|
*/
|
|
86
85
|
getDisplayInfo: () => DisplayInfo<K>;
|
|
87
86
|
getAmountShape: () => Pattern;
|
|
@@ -89,91 +88,100 @@ export type Brand<K extends AssetKind = AssetKind> = {
|
|
|
89
88
|
/**
|
|
90
89
|
* Return true if the payment continues to exist.
|
|
91
90
|
*
|
|
92
|
-
*
|
|
91
|
+
* If the payment is a promise, the operation will proceed upon
|
|
92
|
+
* resolution.
|
|
93
93
|
*/
|
|
94
94
|
export type IssuerIsLive = (payment: ERef<Payment>) => Promise<boolean>;
|
|
95
95
|
/**
|
|
96
|
-
* Get the amount of digital assets in the payment.
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* Get the amount of digital assets in the payment. Because the
|
|
97
|
+
* payment is not trusted, we cannot call a method on it directly, and
|
|
98
|
+
* must use the issuer instead.
|
|
99
99
|
*
|
|
100
|
-
*
|
|
100
|
+
* If the payment is a promise, the operation will proceed upon
|
|
101
|
+
* resolution.
|
|
101
102
|
*/
|
|
102
103
|
export type IssuerGetAmountOf<K extends AssetKind> = (payment: ERef<Payment>) => Promise<Amount<K>>;
|
|
103
104
|
/**
|
|
104
|
-
* Burn all of the digital assets in the
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* Burn all of the digital assets in the
|
|
106
|
+
* payment. `optAmount` is optional. If `optAmount` is present, the
|
|
107
|
+
* code will insist that the amount of the digital assets in the
|
|
108
|
+
* payment is equal to `optAmount`, to prevent sending the wrong
|
|
109
|
+
* payment and other confusion.
|
|
108
110
|
*
|
|
109
|
-
*
|
|
111
|
+
* If the payment is a promise, the operation will proceed upon
|
|
112
|
+
* resolution.
|
|
110
113
|
*/
|
|
111
114
|
export type IssuerBurn = (payment: ERef<Payment>, optAmountShape?: Pattern) => Promise<Amount>;
|
|
112
115
|
/**
|
|
113
|
-
* Transfer all digital assets from the payment to a new
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
116
|
+
* Transfer all digital assets from the payment to a new payment and
|
|
117
|
+
* delete the original. `optAmount` is optional. If `optAmount` is
|
|
118
|
+
* present, the code will insist that the amount of digital assets in
|
|
119
|
+
* the payment is equal to `optAmount`, to prevent sending the wrong
|
|
120
|
+
* payment and other confusion.
|
|
118
121
|
*
|
|
119
|
-
*
|
|
122
|
+
* If the payment is a promise, the operation will proceed upon
|
|
123
|
+
* resolution.
|
|
120
124
|
*/
|
|
121
125
|
export type IssuerClaim<K extends AssetKind> = (payment: ERef<Payment<K>>, optAmountShape?: Pattern) => Promise<Payment<K>>;
|
|
122
126
|
/**
|
|
123
127
|
* Combine multiple payments into one payment.
|
|
124
128
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
129
|
+
* If any of the payments is a promise, the operation will proceed
|
|
130
|
+
* upon resolution.
|
|
127
131
|
*/
|
|
128
132
|
export type IssuerCombine<K extends AssetKind> = (paymentsArray: ERef<Payment<K>>[], optTotalAmount?: Amount<K> | undefined) => Promise<Payment<K>>;
|
|
129
133
|
/**
|
|
130
|
-
* Split a single payment into two payments,
|
|
131
|
-
*
|
|
134
|
+
* Split a single payment into two payments,
|
|
135
|
+
* A and B, according to the paymentAmountA passed in.
|
|
132
136
|
*
|
|
133
|
-
*
|
|
137
|
+
* If the payment is a promise, the operation will proceed upon
|
|
138
|
+
* resolution.
|
|
134
139
|
*/
|
|
135
140
|
export type IssuerSplit<K extends AssetKind> = (payment: ERef<Payment<K>>, paymentAmountA: Amount<K>) => Promise<Payment<K>[]>;
|
|
136
141
|
/**
|
|
137
|
-
* Split a single payment into many payments,
|
|
138
|
-
*
|
|
142
|
+
* Split a single payment into many payments, according to the amounts
|
|
143
|
+
* passed in.
|
|
139
144
|
*
|
|
140
|
-
*
|
|
145
|
+
* If the payment is a promise, the operation will proceed upon
|
|
146
|
+
* resolution.
|
|
141
147
|
*/
|
|
142
148
|
export type IssuerSplitMany = (payment: ERef<Payment>, amounts: Amount[]) => Promise<Payment[]>;
|
|
143
149
|
/**
|
|
144
|
-
* The issuer cannot mint a new amount, but it can
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
+
* The issuer cannot mint a new amount, but it can create empty purses
|
|
151
|
+
* and payments. The issuer can also transform payments (splitting
|
|
152
|
+
* payments, combining payments, burning payments, and claiming
|
|
153
|
+
* payments exclusively). The issuer should be gotten from a trusted
|
|
154
|
+
* source and then relied upon as the decider of whether an untrusted
|
|
155
|
+
* payment is valid.
|
|
150
156
|
*/
|
|
151
157
|
export type Issuer<K extends AssetKind = AssetKind> = {
|
|
152
158
|
/**
|
|
153
|
-
* Get the Brand for this Issuer. The
|
|
154
|
-
* indicates the type of digital asset and is shared by the
|
|
155
|
-
* and any purses and payments of this particular
|
|
156
|
-
* closely held, so this function should not be
|
|
157
|
-
* alone. Fake digital assets and amount
|
|
159
|
+
* Get the Brand for this Issuer. The
|
|
160
|
+
* Brand indicates the type of digital asset and is shared by the
|
|
161
|
+
* mint, the issuer, and any purses and payments of this particular
|
|
162
|
+
* kind. The brand is not closely held, so this function should not be
|
|
163
|
+
* trusted to identify an issuer alone. Fake digital assets and amount
|
|
164
|
+
* can use another issuer's brand.
|
|
158
165
|
*/
|
|
159
166
|
getBrand: () => Brand<K>;
|
|
160
167
|
/**
|
|
161
|
-
* Get the allegedName for
|
|
162
|
-
* mint/issuer
|
|
168
|
+
* Get the allegedName for
|
|
169
|
+
* this mint/issuer
|
|
163
170
|
*/
|
|
164
171
|
getAllegedName: () => string;
|
|
165
172
|
/**
|
|
166
|
-
* Get the kind of
|
|
167
|
-
* this Issuer.
|
|
173
|
+
* Get the kind of
|
|
174
|
+
* MathHelpers used by this Issuer.
|
|
168
175
|
*/
|
|
169
176
|
getAssetKind: () => AssetKind;
|
|
170
177
|
/**
|
|
171
|
-
* Give information to UI
|
|
172
|
-
* to display amounts for this issuer.
|
|
178
|
+
* Give information to UI
|
|
179
|
+
* on how to display amounts for this issuer.
|
|
173
180
|
*/
|
|
174
181
|
getDisplayInfo: () => DisplayInfo<K>;
|
|
175
182
|
/**
|
|
176
|
-
* Make an empty purse of this
|
|
183
|
+
* Make an empty purse of this
|
|
184
|
+
* brand.
|
|
177
185
|
*/
|
|
178
186
|
makeEmptyPurse: () => Purse<K>;
|
|
179
187
|
isLive: IssuerIsLive;
|
|
@@ -195,14 +203,15 @@ export type IssuerKit<K extends AssetKind = AssetKind> = {
|
|
|
195
203
|
};
|
|
196
204
|
export type AdditionalDisplayInfo = {
|
|
197
205
|
/**
|
|
198
|
-
* Tells the display software how
|
|
199
|
-
* decimal places to move the decimal over to the left, or in
|
|
200
|
-
* which position corresponds to whole numbers. We
|
|
201
|
-
* assets to be represented in integers, in
|
|
202
|
-
* be represented in mill, a
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
+
* Tells the display software how
|
|
207
|
+
* many decimal places to move the decimal over to the left, or in
|
|
208
|
+
* other words, which position corresponds to whole numbers. We
|
|
209
|
+
* require fungible digital assets to be represented in integers, in
|
|
210
|
+
* the smallest unit (i.e. USD might be represented in mill, a
|
|
211
|
+
* thousandth of a dollar. In that case, `decimalPlaces` would be
|
|
212
|
+
* 3.) This property is optional, and for non-fungible digital
|
|
213
|
+
* assets, should not be specified. The decimalPlaces property
|
|
214
|
+
* should be used for *display purposes only*. Any other use is an
|
|
206
215
|
* anti-pattern.
|
|
207
216
|
*/
|
|
208
217
|
decimalPlaces?: number | undefined;
|
|
@@ -210,8 +219,8 @@ export type AdditionalDisplayInfo = {
|
|
|
210
219
|
};
|
|
211
220
|
export type ShutdownWithFailure = import('@agoric/swingset-vat').ShutdownWithFailure;
|
|
212
221
|
/**
|
|
213
|
-
* Holding a Mint carries the right to issue new digital
|
|
214
|
-
*
|
|
222
|
+
* Holding a Mint carries the right to issue new digital assets. These
|
|
223
|
+
* assets all have the same kind, which is called a Brand.
|
|
215
224
|
*/
|
|
216
225
|
export type Mint<K extends AssetKind = AssetKind> = {
|
|
217
226
|
/**
|
|
@@ -219,18 +228,16 @@ export type Mint<K extends AssetKind = AssetKind> = {
|
|
|
219
228
|
*/
|
|
220
229
|
getIssuer: () => Issuer<K>;
|
|
221
230
|
/**
|
|
222
|
-
* Creates a new
|
|
223
|
-
* Payment containing newly minted amount.
|
|
231
|
+
* Creates a new Payment containing newly minted amount.
|
|
224
232
|
*/
|
|
225
233
|
mintPayment: (newAmount: Amount<K>) => Payment<K>;
|
|
226
234
|
};
|
|
227
235
|
export type DepositFacetReceive = (payment: Payment, optAmountShape?: Pattern) => Amount;
|
|
228
236
|
export type DepositFacet = {
|
|
229
237
|
/**
|
|
230
|
-
* Deposit all the contents of payment
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* payment, throw an error.
|
|
238
|
+
* Deposit all the contents of payment into the purse that made this facet,
|
|
239
|
+
* returning the amount. If the optional argument `optAmount` does not equal the
|
|
240
|
+
* amount of digital assets in the payment, throw an error.
|
|
234
241
|
*
|
|
235
242
|
* If payment is a promise, throw an error.
|
|
236
243
|
*/
|
|
@@ -238,125 +245,116 @@ export type DepositFacet = {
|
|
|
238
245
|
};
|
|
239
246
|
export type PurseDeposit<K extends AssetKind> = (payment: Payment<K>, optAmountShape?: Pattern) => Amount<K>;
|
|
240
247
|
/**
|
|
241
|
-
* Purses hold amount of digital assets of the same
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* deposit() and withdraw().
|
|
248
|
+
* Purses hold amount of digital assets of the same brand, but unlike Payments,
|
|
249
|
+
* they are not meant to be sent to others. To transfer digital assets, a
|
|
250
|
+
* Payment should be withdrawn from a Purse. The amount of digital
|
|
251
|
+
* assets in a purse can change through the action of deposit() and withdraw().
|
|
246
252
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
253
|
+
* The primary use for Purses and Payments is for currency-like and goods-like
|
|
254
|
+
* digital assets, but they can also be used to represent other kinds of rights,
|
|
255
|
+
* such as the right to participate in a particular contract.
|
|
250
256
|
*/
|
|
251
257
|
export type Purse<K extends AssetKind = AssetKind> = {
|
|
252
258
|
/**
|
|
253
|
-
* Get the alleged Brand for this
|
|
254
|
-
* Purse
|
|
259
|
+
* Get the alleged Brand for this Purse
|
|
255
260
|
*/
|
|
256
261
|
getAllegedBrand: () => Brand<K>;
|
|
257
262
|
/**
|
|
258
|
-
* Get the amount contained in this
|
|
259
|
-
* purse.
|
|
263
|
+
* Get the amount contained in this purse.
|
|
260
264
|
*/
|
|
261
265
|
getCurrentAmount: () => Amount<K>;
|
|
262
266
|
/**
|
|
263
|
-
* Get a lossy
|
|
264
|
-
* notifier for changes to this purse's balance.
|
|
267
|
+
* Get a lossy notifier for changes to this purse's balance.
|
|
265
268
|
*/
|
|
266
269
|
getCurrentAmountNotifier: () => LatestTopic<Amount<K>>;
|
|
267
270
|
/**
|
|
268
|
-
* Deposit all the contents of payment into
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
+
* Deposit all the contents of payment into this purse, returning the
|
|
272
|
+
* amount. If the optional argument `optAmount` does not equal the
|
|
273
|
+
* amount of digital assets in the payment, throw an error.
|
|
271
274
|
*
|
|
272
275
|
* If payment is a promise, throw an error.
|
|
273
276
|
*/
|
|
274
277
|
deposit: PurseDeposit<K>;
|
|
275
278
|
/**
|
|
276
|
-
* Return an object whose
|
|
277
|
-
* `receive` method deposits to the current Purse.
|
|
279
|
+
* Return an object whose `receive` method deposits to the current Purse.
|
|
278
280
|
*/
|
|
279
281
|
getDepositFacet: () => DepositFacet;
|
|
280
282
|
/**
|
|
281
|
-
* Withdraw amount from
|
|
282
|
-
* this purse into a new Payment.
|
|
283
|
+
* Withdraw amount from this purse into a new Payment.
|
|
283
284
|
*/
|
|
284
285
|
withdraw: (amount: Amount<K>) => Payment<K>;
|
|
285
286
|
/**
|
|
286
|
-
* The set of payments
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* fails.
|
|
287
|
+
* The set of payments withdrawn from this purse that are still live. These
|
|
288
|
+
* are the payments that can still be recovered in emergencies by, for example,
|
|
289
|
+
* depositing into this purse. Such a deposit action is like canceling an
|
|
290
|
+
* outstanding check because you're tired of waiting for it. Once your
|
|
291
|
+
* cancellation is acknowledged, you can spend the assets at stake on other
|
|
292
|
+
* things. Afterwards, if the recipient of the original check finally gets
|
|
293
|
+
* around to depositing it, their deposit fails.
|
|
294
294
|
*/
|
|
295
295
|
getRecoverySet: () => CopySet<Payment<K>>;
|
|
296
296
|
/**
|
|
297
|
-
* For use in emergencies, such as coming
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* of assets recovered.
|
|
297
|
+
* For use in emergencies, such as coming back from a traumatic crash and
|
|
298
|
+
* upgrade. This deposits all the payments in this purse's recovery set
|
|
299
|
+
* into the purse itself, returning the total amount of assets recovered.
|
|
301
300
|
*/
|
|
302
301
|
recoverAll: () => Amount<K>;
|
|
303
302
|
};
|
|
304
303
|
/**
|
|
305
|
-
* Payments hold amount of digital assets of the same
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
304
|
+
* Payments hold amount of digital assets of the same brand in transit. Payments
|
|
305
|
+
* can be deposited in purses, split into multiple payments, combined, and
|
|
306
|
+
* claimed (getting an exclusive payment). Payments are linear, meaning
|
|
307
|
+
* that either a payment has the same amount of digital assets it
|
|
308
|
+
* started with, or it is used up entirely. It is impossible to partially use a
|
|
309
|
+
* payment.
|
|
311
310
|
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
311
|
+
* Payments are often received from other actors and therefore should
|
|
312
|
+
* not be trusted themselves. To get the amount of digital assets in a payment,
|
|
313
|
+
* use the trusted issuer: issuer.getAmountOf(payment),
|
|
315
314
|
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
315
|
+
* Payments can be converted to Purses by getting a trusted issuer and
|
|
316
|
+
* calling `issuer.makeEmptyPurse()` to create a purse, then
|
|
317
|
+
* `purse.deposit(payment)`.
|
|
319
318
|
*/
|
|
320
319
|
export type Payment<K extends AssetKind = AssetKind> = {
|
|
321
320
|
/**
|
|
322
|
-
* Get the allegedBrand, indicating
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
321
|
+
* Get the allegedBrand, indicating the type of digital asset this
|
|
322
|
+
* payment purports to be, and which issuer to use. Because payments
|
|
323
|
+
* are not trusted, any method calls on payments should be treated
|
|
324
|
+
* with suspicion and verified elsewhere.
|
|
326
325
|
*/
|
|
327
326
|
getAllegedBrand: () => Brand<K>;
|
|
328
327
|
};
|
|
329
328
|
/**
|
|
330
|
-
* All of the difference in how digital asset
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
329
|
+
* All of the difference in how digital asset amount are manipulated can be
|
|
330
|
+
* reduced to the behavior of the math on values. We extract this
|
|
331
|
+
* custom logic into mathHelpers. MathHelpers are about value
|
|
332
|
+
* arithmetic, whereas AmountMath is about amounts, which are the
|
|
333
|
+
* values labeled with a brand. AmountMath use mathHelpers to do their value
|
|
334
|
+
* arithmetic, and then brand the results, making a new amount.
|
|
336
335
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
336
|
+
* The MathHelpers are designed to be called only from AmountMath, and so
|
|
337
|
+
* all methods but coerce can assume their inputs are valid. They only
|
|
338
|
+
* need to do output validation, and only when there is a possibility of
|
|
339
|
+
* invalid output.
|
|
340
340
|
*/
|
|
341
341
|
export type MathHelpers<V extends AmountValue> = {
|
|
342
342
|
/**
|
|
343
|
-
* Check the kind of this value and
|
|
344
|
-
*
|
|
343
|
+
* Check the kind of this value and throw if it is not the
|
|
344
|
+
* expected kind.
|
|
345
345
|
*/
|
|
346
346
|
doCoerce: (allegedValue: V) => V;
|
|
347
347
|
/**
|
|
348
|
-
* Get the representation for the identity
|
|
349
|
-
*
|
|
348
|
+
* Get the representation for the identity element (often 0 or an
|
|
349
|
+
* empty array)
|
|
350
350
|
*/
|
|
351
351
|
doMakeEmpty: () => V;
|
|
352
352
|
/**
|
|
353
|
-
* Is the value the identity
|
|
354
|
-
* element?
|
|
353
|
+
* Is the value the identity element?
|
|
355
354
|
*/
|
|
356
355
|
doIsEmpty: (value: V) => boolean;
|
|
357
356
|
/**
|
|
358
|
-
* Is the left greater than
|
|
359
|
-
* or equal to the right?
|
|
357
|
+
* Is the left greater than or equal to the right?
|
|
360
358
|
*/
|
|
361
359
|
doIsGTE: (left: V, right: V) => boolean;
|
|
362
360
|
/**
|
|
@@ -364,17 +362,15 @@ export type MathHelpers<V extends AmountValue> = {
|
|
|
364
362
|
*/
|
|
365
363
|
doIsEqual: (left: V, right: V) => boolean;
|
|
366
364
|
/**
|
|
367
|
-
* Return the left combined with the
|
|
368
|
-
* right.
|
|
365
|
+
* Return the left combined with the right.
|
|
369
366
|
*/
|
|
370
367
|
doAdd: (left: V, right: V) => V;
|
|
371
368
|
/**
|
|
372
|
-
* Return what remains after
|
|
373
|
-
*
|
|
374
|
-
* left, we throw an error.
|
|
369
|
+
* Return what remains after removing the right from the left. If
|
|
370
|
+
* something in the right was not in the left, we throw an error.
|
|
375
371
|
*/
|
|
376
372
|
doSubtract: (left: V, right: V) => V;
|
|
377
373
|
};
|
|
378
374
|
export type NatValue = bigint;
|
|
379
|
-
export type SetValue = Key
|
|
375
|
+
export type SetValue = Array<Key>;
|
|
380
376
|
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;;;;;;;;;WAiBc,MAAM,CAAC,CAAC;WACR,kBAAkB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;0BAIrB,QAAQ,WAAc,OAAO,GAAG,OAAO;;;;wBAwBvC,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS;qDAOrC,CAAC,SAAS,KAAK,GAAG,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