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