You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: differences-with-machine.md
+67-5Lines changed: 67 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ _Note_: dividing by 0 is a runtime error.
122
122
123
123
### New function: `overdraft :: (account, asset) -> monetary`
124
124
125
-
> flag: `experimental-overdraft-function`
125
+
> flag: `experimental-overdraft-function` (available from 0.0.15)
126
126
127
127
Returns the account's overdraft amount as a positive value (or zero if the account didn't have a negative overdraft)
128
128
@@ -144,7 +144,7 @@ send [COIN *] (
144
144
145
145
### New function: `get_asset :: monetary -> asset`
146
146
147
-
> flag: `experimental-get-asset-function`
147
+
> flag: `experimental-get-asset-function` (available from 0.0.16)
148
148
149
149
Get the asset of the given monetary. For example:
150
150
@@ -157,7 +157,7 @@ vars {
157
157
158
158
### New function: `get_amount :: monetary -> number`
159
159
160
-
> flag: `experimental-get-amount-function`
160
+
> flag: `experimental-get-amount-function` (available from 0.0.16)
161
161
162
162
Get the amount of the given monetary. For example:
163
163
@@ -170,7 +170,7 @@ vars {
170
170
171
171
### Account interpolation syntax
172
172
173
-
> flag: `experimental-account-interpolation`
173
+
> flag: `experimental-account-interpolation` (available from 0.0.15)
174
174
175
175
You can now interpolate variables inside account literals:
176
176
@@ -187,7 +187,7 @@ Creating invalid account names (e.g. by interpolating string like `"!"`) will ra
187
187
188
188
### Mid-script function call
189
189
190
-
> flag: `experimental-mid-script-function-call`
190
+
> flag: `experimental-mid-script-function-call` (available from 0.0.15)
191
191
192
192
The values that initiate vars can now be any kind of expression, not just function calls:
193
193
@@ -313,3 +313,65 @@ send [USD/2 150] (
313
313
}
314
314
)
315
315
```
316
+
317
+
### Colored assets
318
+
319
+
> flag: `experimental-asset-colors` (available from 0.0.17)
320
+
321
+
This functionality allows to deal with semi-fungible assets. While this is already possible, by using conventions like `JPMUSD` and `STRIPEUSD`, there is no way for a statement to deal simultaneously with two different assets.
322
+
We therefore introduce a restriction operator that you can use on account on source positions to specify what sub-asset to pull from the balance. An asset `ASSET/n` marked with the "X" color will be represented in the store (for example, the ledger's database) as the `ASSET_X/n` asset.
323
+
324
+
In practice, the operator looks like this:
325
+
326
+
```
327
+
send [USD/2 100] (
328
+
source = @alice \ "STRIPE"
329
+
destination = @dest
330
+
)
331
+
```
332
+
333
+
This will emit the following postings (by checking `@alice`'s `USD_STRIPE/2` balance):
334
+
335
+
```
336
+
[
337
+
{
338
+
source: "alice",
339
+
destination: "dest",
340
+
asset: "USD_STRIPE/2",
341
+
amount: 100,
342
+
}
343
+
]
344
+
```
345
+
346
+
A restricted account can nested as usual:
347
+
348
+
```
349
+
send [USD/2 100] (
350
+
source = oneof {
351
+
@alice \ "STRIPE"
352
+
@alice \ "PAYPAL"
353
+
@alice \ "ADYEN"
354
+
}
355
+
destination = @dest
356
+
)
357
+
```
358
+
359
+
Colors are represented as string, therefore you use any expression that evaluates to string, including variables:
360
+
361
+
```
362
+
vars {
363
+
string $col
364
+
}
365
+
366
+
send [USD/2 100] (
367
+
source = @alice \ $col
368
+
destination = @dest
369
+
)
370
+
```
371
+
372
+
The empty string (`""`) represents no color. Therefore, those two sources are exactly the same:
373
+
374
+
-`@account \ ""`
375
+
-`@account`
376
+
377
+
In that case, we'll not remap the asset by using the `_` postfix.
0 commit comments