Skip to content

Commit 9d7ea1a

Browse files
authored
docs: Added docs to readme (#65)
1 parent 414766a commit 9d7ea1a

1 file changed

Lines changed: 67 additions & 5 deletions

File tree

differences-with-machine.md

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ _Note_: dividing by 0 is a runtime error.
122122

123123
### New function: `overdraft :: (account, asset) -> monetary`
124124

125-
> flag: `experimental-overdraft-function`
125+
> flag: `experimental-overdraft-function` (available from 0.0.15)
126126
127127
Returns the account's overdraft amount as a positive value (or zero if the account didn't have a negative overdraft)
128128

@@ -144,7 +144,7 @@ send [COIN *] (
144144

145145
### New function: `get_asset :: monetary -> asset`
146146

147-
> flag: `experimental-get-asset-function`
147+
> flag: `experimental-get-asset-function` (available from 0.0.16)
148148
149149
Get the asset of the given monetary. For example:
150150

@@ -157,7 +157,7 @@ vars {
157157

158158
### New function: `get_amount :: monetary -> number`
159159

160-
> flag: `experimental-get-amount-function`
160+
> flag: `experimental-get-amount-function` (available from 0.0.16)
161161
162162
Get the amount of the given monetary. For example:
163163

@@ -170,7 +170,7 @@ vars {
170170

171171
### Account interpolation syntax
172172

173-
> flag: `experimental-account-interpolation`
173+
> flag: `experimental-account-interpolation` (available from 0.0.15)
174174
175175
You can now interpolate variables inside account literals:
176176

@@ -187,7 +187,7 @@ Creating invalid account names (e.g. by interpolating string like `"!"`) will ra
187187

188188
### Mid-script function call
189189

190-
> flag: `experimental-mid-script-function-call`
190+
> flag: `experimental-mid-script-function-call` (available from 0.0.15)
191191
192192
The values that initiate vars can now be any kind of expression, not just function calls:
193193

@@ -313,3 +313,65 @@ send [USD/2 150] (
313313
}
314314
)
315315
```
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

Comments
 (0)