@hyperscale0/hsx 2.4.0 → 3.0.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 +2 -400
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +76 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +77 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4131
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5381
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# 4 · A complete product
|
|
2
|
-
|
|
3
|
-
[`study-hall.hsx`](./study-hall.hsx) is a tutoring marketplace: three
|
|
4
|
-
settlements, three different jobs, one program.
|
|
5
|
-
|
|
6
|
-
```bash
|
|
7
|
-
hsx check study-hall.hsx
|
|
8
|
-
hsx build study-hall.hsx --out ir.json
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
| Settlement | Brick | What it does |
|
|
12
|
-
| -------------- | ------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
13
|
-
| `lesson` | `held_payment` | Holds the student's payment until the tutor confirms the lesson, or until the stored end date arrives. |
|
|
14
|
-
| `kit_deposit` | `security_deposit` | Reserves the equipment deposit on the student's own account. Claimed on damage, returned intact. |
|
|
15
|
-
| `tutor_payout` | `pooled_split` | Splits the weekly pool 55/45 between the two tutors, remainder to the lead. |
|
|
16
|
-
|
|
17
|
-
## A deposit is not a payment
|
|
18
|
-
|
|
19
|
-
```hsx
|
|
20
|
-
settlement kit_deposit = security_deposit {
|
|
21
|
-
payer: student
|
|
22
|
-
holder: tutor
|
|
23
|
-
amount: kitDeposit: money(SAR)
|
|
24
|
-
claim: port assess_kit
|
|
25
|
-
return: port release_kit
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The money never leaves the student's account. A deposit is a **reservation**:
|
|
30
|
-
placed as a hold, then either posted to the holder (`claim`) or voided back to
|
|
31
|
-
the payer (`return`). That is why one settlement needs two ports and why they
|
|
32
|
-
must be different ones. Two exits, two decisions, and the hold pairing law
|
|
33
|
-
accounts for the full amount on both.
|
|
34
|
-
|
|
35
|
-
## Nobody answering is an answer
|
|
36
|
-
|
|
37
|
-
```hsx
|
|
38
|
-
release: port confirm_lesson | at(lessonEndsAt)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`| at(<date field>)` gives the release a stored date to fall back on. If
|
|
42
|
-
nobody answers the port, the date releases the money to the tutor.
|
|
43
|
-
|
|
44
|
-
This is the one place HSX lets a deadline decide money, and it is deliberately
|
|
45
|
-
not symmetric: inaction resolves in the direction the parties already agreed
|
|
46
|
-
on, rather than stranding the payment in escrow forever. Only `held_payment`'s
|
|
47
|
-
`release` accepts it. Every other port must be answered.
|
|
48
|
-
|
|
49
|
-
## The remainder has an owner
|
|
50
|
-
|
|
51
|
-
```hsx
|
|
52
|
-
split { lead_tutor: 55%, tutor: 45%, remainder_to: lead_tutor }
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Percentages of an integer amount of minor units almost never divide evenly.
|
|
56
|
-
Every piece is floored, and the leftover minor units go somewhere explicit:
|
|
57
|
-
`remainder_to` names which recipient carries them, and without it the first
|
|
58
|
-
share does. Nobody's fraction of a halala goes missing, and nobody's is
|
|
59
|
-
invented.
|
|
60
|
-
|
|
61
|
-
A pool needs at least two recipients, and the funder cannot be one of them. A
|
|
62
|
-
pool that distributes to one person is a transfer, and there is an module
|
|
63
|
-
for that.
|
|
64
|
-
|
|
65
|
-
## What it compiles to
|
|
66
|
-
|
|
67
|
-
Three instruments, `lesson`, `kit_deposit`, and `tutor_payout`, plus nine money events:
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
lesson_fund
|
|
71
|
-
lesson_release_tutor
|
|
72
|
-
lesson_release_platform
|
|
73
|
-
lesson_abandon
|
|
74
|
-
kit_deposit_hold_1
|
|
75
|
-
tutor_payout_pool_1
|
|
76
|
-
tutor_payout_pool_2
|
|
77
|
-
tutor_payout_payout_1
|
|
78
|
-
tutor_payout_payout_2
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
One program carries at most **20** money events (`MONEY_EVENT_BUDGET`). This
|
|
82
|
-
one uses nine. Every installment anchor, fee leg, cancellation leg, and
|
|
83
|
-
abandonment refund counts one, so the budget is the real ceiling on how much
|
|
84
|
-
company fits in a single file. Past it, split the product.
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// A complete small product: a tutoring marketplace.
|
|
2
|
-
//
|
|
3
|
-
// Three settlements, three different jobs:
|
|
4
|
-
//
|
|
5
|
-
// lesson a student's payment is held until the tutor confirms the
|
|
6
|
-
// lesson happened; the platform's 8% comes out of the payout
|
|
7
|
-
// kit_deposit the tutor's equipment deposit is a reservation on the
|
|
8
|
-
// student's own account, claimed on damage or returned intact
|
|
9
|
-
// tutor_payout the marketplace's weekly pool, split between the two tutors
|
|
10
|
-
// who ran the sessions, with the remainder going to the lead
|
|
11
|
-
//
|
|
12
|
-
// Everything a caller can decide goes through a port, and every port names
|
|
13
|
-
// exactly who may answer it.
|
|
14
|
-
|
|
15
|
-
program study_hall "Study hall"
|
|
16
|
-
|
|
17
|
-
import { held_payment, security_deposit, pooled_split } from "std/money_flows"
|
|
18
|
-
|
|
19
|
-
party student: person
|
|
20
|
-
party tutor: business
|
|
21
|
-
party lead_tutor: business
|
|
22
|
-
party school: business
|
|
23
|
-
|
|
24
|
-
asset lesson_kit: good { title_transfer: on_platform }
|
|
25
|
-
|
|
26
|
-
settlement lesson = held_payment {
|
|
27
|
-
payer: student
|
|
28
|
-
payee: tutor
|
|
29
|
-
amount: lessonFee: money(SAR)
|
|
30
|
-
fees { tutor: 8% }
|
|
31
|
-
release: port confirm_lesson | at(lessonEndsAt)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
settlement kit_deposit = security_deposit {
|
|
35
|
-
payer: student
|
|
36
|
-
holder: tutor
|
|
37
|
-
amount: kitDeposit: money(SAR)
|
|
38
|
-
claim: port assess_kit
|
|
39
|
-
return: port release_kit
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
settlement tutor_payout = pooled_split {
|
|
43
|
-
payer: school
|
|
44
|
-
amount: weeklyPool: money(SAR)
|
|
45
|
-
payout_due: payoutDate
|
|
46
|
-
split { lead_tutor: 55%, tutor: 45%, remainder_to: lead_tutor }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// The tutor confirms the lesson happened. If nobody answers, `at(lessonEndsAt)`
|
|
50
|
-
// releases the money to the tutor on the stored date: inaction resolves in the
|
|
51
|
-
// direction the parties already agreed on, instead of stranding the payment.
|
|
52
|
-
port confirm_lesson {
|
|
53
|
-
allowed: [tutor]
|
|
54
|
-
shape {
|
|
55
|
-
kitId: id(lesson_kit)
|
|
56
|
-
lessonNotes: text
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
port assess_kit {
|
|
61
|
-
allowed: [tutor]
|
|
62
|
-
shape { damageReport: text }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
port release_kit {
|
|
66
|
-
allowed: [tutor]
|
|
67
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Authored payment
|
|
2
|
-
|
|
3
|
-
`payment.hsx` declares a payment with a bound internal transfer. The [module guide](../../docs/guide/08-writing-a-module.md#an-authored-action-that-moves-money) contains the same program. The docs builder compares the bytes and compiles it with the packaged cost table.
|
|
4
|
-
|
|
5
|
-
From the full repository root, run `bun open/hsx/bin/hsx.ts check open/hsx/examples/05-authored-instrument/payment.hsx`.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
program authored_payment "Authored payment"
|
|
2
|
-
|
|
3
|
-
instrument payment {
|
|
4
|
-
agent_description: "Collect a stored payment once from its payer."
|
|
5
|
-
title: "Payment"
|
|
6
|
-
summary: "A payment with fixed payer and payee accounts"
|
|
7
|
-
fields {
|
|
8
|
-
payerAccountId: account<SAR>;
|
|
9
|
-
payeeAccountId: account<SAR>;
|
|
10
|
-
amount: money<SAR>;
|
|
11
|
-
}
|
|
12
|
-
parties { payer: payerAccountId; beneficiary: payeeAccountId; }
|
|
13
|
-
lifecycle {
|
|
14
|
-
states pending paid;
|
|
15
|
-
initial pending;
|
|
16
|
-
on pay: pending -> paid;
|
|
17
|
-
}
|
|
18
|
-
action create {
|
|
19
|
-
agent_description: "Open a pending payment without moving money."
|
|
20
|
-
steps: [];
|
|
21
|
-
moves: [];
|
|
22
|
-
}
|
|
23
|
-
action pay {
|
|
24
|
-
agent_description: "Move the stored amount from payer to payee."
|
|
25
|
-
steps: [];
|
|
26
|
-
moves: [{
|
|
27
|
-
bind: {
|
|
28
|
-
amount: { from: "instance", path: "fields.amount" }
|
|
29
|
-
currency: { from: "const", value: "SAR" }
|
|
30
|
-
sourceAccountId: { from: "instance", path: "fields.payerAccountId" }
|
|
31
|
-
destinationAccountId: { from: "instance", path: "fields.payeeAccountId" }
|
|
32
|
-
}
|
|
33
|
-
key: "payment_transfer"
|
|
34
|
-
operation: "internal_transfer.create"
|
|
35
|
-
}];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# Watch club
|
|
2
|
-
|
|
3
|
-
This reference program joins the algebra needed for one club product. It keeps
|
|
4
|
-
each watch attached to explicit sale, deposit, and trade rules. Membership due
|
|
5
|
-
dates open periods, while callers still author every money action. Seller
|
|
6
|
-
payouts close through stored provider evidence.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// A watch club whose money rules remain explicit from member checkout through
|
|
2
|
-
// seller payout. Each item owns its sale, deposit, and trade lifecycle. The
|
|
3
|
-
// club membership schedule opens periods but never moves money on a timeout.
|
|
4
|
-
|
|
5
|
-
program watch_club "Watch club"
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
security_deposit,
|
|
9
|
-
instant_transfer,
|
|
10
|
-
scheduled,
|
|
11
|
-
settlement_batch,
|
|
12
|
-
swap
|
|
13
|
-
} from "std/money_flows"
|
|
14
|
-
|
|
15
|
-
party member: person
|
|
16
|
-
party seller: business
|
|
17
|
-
party club: business
|
|
18
|
-
party payout_destination: business
|
|
19
|
-
|
|
20
|
-
asset watch: good { title_transfer: on_platform }
|
|
21
|
-
|
|
22
|
-
settlement purchase = instant_transfer {
|
|
23
|
-
payer: member
|
|
24
|
-
payee: seller
|
|
25
|
-
amount: purchasePrice: money(SAR)
|
|
26
|
-
fees {
|
|
27
|
-
member: checkoutFee: money(SAR)
|
|
28
|
-
seller {
|
|
29
|
-
tier {
|
|
30
|
-
from: 0
|
|
31
|
-
to: 10000
|
|
32
|
-
fee: 1%
|
|
33
|
-
}
|
|
34
|
-
tier {
|
|
35
|
-
from: 10000
|
|
36
|
-
fee: highValueFee: money(SAR)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
settlement inspection_deposit = security_deposit {
|
|
43
|
-
payer: member
|
|
44
|
-
holder: seller
|
|
45
|
-
amount: depositAmount: money(SAR)
|
|
46
|
-
claim: port assess_watch
|
|
47
|
-
claim_amount: decided {
|
|
48
|
-
field: damageAmount
|
|
49
|
-
bound: depositAmount
|
|
50
|
-
remainder: return
|
|
51
|
-
}
|
|
52
|
-
return: port return_deposit
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
settlement membership = scheduled {
|
|
56
|
-
mode: obligation
|
|
57
|
-
payer: member
|
|
58
|
-
payee: club
|
|
59
|
-
debtor: member
|
|
60
|
-
amount: monthlyFee: money(SAR)
|
|
61
|
-
every: P1M
|
|
62
|
-
first_due: firstPeriodAt
|
|
63
|
-
until: port cancel_membership
|
|
64
|
-
month_end: clamp_to_last_day
|
|
65
|
-
period_liability: one_open
|
|
66
|
-
termination_drain: cancel_membership
|
|
67
|
-
mandate: port collect_membership
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
settlement member_trade = swap {
|
|
71
|
-
between: [member, seller]
|
|
72
|
-
amounts {
|
|
73
|
-
member: memberPays: money(SAR)
|
|
74
|
-
seller: sellerPays: money(SAR)
|
|
75
|
-
}
|
|
76
|
-
fees {
|
|
77
|
-
member: memberTradeFee: money(SAR)
|
|
78
|
-
seller: sellerTradeFee: money(SAR)
|
|
79
|
-
}
|
|
80
|
-
release: port confirm_trade
|
|
81
|
-
dispute: port resolve_trade within P14D
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
settlement seller_payout = settlement_batch {
|
|
85
|
-
settlement_account: club
|
|
86
|
-
source_capture_refs: captureReference
|
|
87
|
-
fee_entries: feeReference
|
|
88
|
-
external_reversal_offsets: externalReversalReference
|
|
89
|
-
close_trigger: closeAt
|
|
90
|
-
payout_destination: payout_destination
|
|
91
|
-
negative_position: reject
|
|
92
|
-
payout_acknowledgement: port acknowledge_payout
|
|
93
|
-
payout_beneficiary_ref: payoutBeneficiaryId
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
port assess_watch {
|
|
97
|
-
allowed: [seller]
|
|
98
|
-
shape {
|
|
99
|
-
damageAmount: money(SAR)
|
|
100
|
-
evidence: text
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
port return_deposit { allowed: [seller] }
|
|
105
|
-
|
|
106
|
-
port collect_membership {
|
|
107
|
-
allowed: [member]
|
|
108
|
-
shape { evidenceReference: text }
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
port cancel_membership {
|
|
112
|
-
allowed: [member]
|
|
113
|
-
shape { reason: text }
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
port confirm_trade { allowed: [member, seller] }
|
|
117
|
-
|
|
118
|
-
port resolve_trade { allowed: [member, seller] }
|
|
119
|
-
|
|
120
|
-
port acknowledge_payout {
|
|
121
|
-
allowed: [payout_destination]
|
|
122
|
-
shape { acknowledgementReference: text }
|
|
123
|
-
}
|
package/examples/README.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Examples
|
|
2
|
-
|
|
3
|
-
Each money flow has its own directory with an HSX program, a
|
|
4
|
-
short lesson, and pinned canonical UDL bytes. The test suite reads the module
|
|
5
|
-
list from `std/money_flows`, compiles every program, and compares each emitted
|
|
6
|
-
document byte for byte.
|
|
7
|
-
|
|
8
|
-
The numbered examples provide end-to-end walkthroughs:
|
|
9
|
-
|
|
10
|
-
- [01 · Your first program](01-first-program/README.md)
|
|
11
|
-
- [02 · Imports and modules](02-imports-and-modules/README.md)
|
|
12
|
-
- [03 · Diagnostics](03-diagnostics/README.md)
|
|
13
|
-
- [04 · Complete product](04-complete-product/README.md)
|
|
14
|
-
- [05 · Watch club](05-watch-club/README.md)
|
|
15
|
-
|
|
16
|
-
## Money flows
|
|
17
|
-
|
|
18
|
-
Each money flow has a runnable example directory:
|
|
19
|
-
|
|
20
|
-
- [advance](advance/README.md)
|
|
21
|
-
- [cancellable_booking](cancellable_booking/README.md)
|
|
22
|
-
- [captured_payment](captured_payment/README.md)
|
|
23
|
-
- [conditional_disbursement](conditional_disbursement/README.md)
|
|
24
|
-
- [credit_facility](credit_facility/README.md)
|
|
25
|
-
- [held_payment](held_payment/README.md)
|
|
26
|
-
- [instant_transfer](instant_transfer/README.md)
|
|
27
|
-
- [metered](metered/README.md)
|
|
28
|
-
- [pooled_split](pooled_split/README.md)
|
|
29
|
-
- [premium_forward](premium_forward/README.md)
|
|
30
|
-
- [reconciled_payout](reconciled_payout/README.md)
|
|
31
|
-
- [rotating_pool](rotating_pool/README.md)
|
|
32
|
-
- [scheduled](scheduled/README.md)
|
|
33
|
-
- [security_deposit](security_deposit/README.md)
|
|
34
|
-
- [settlement_batch](settlement_batch/README.md)
|
|
35
|
-
- [swap](swap/README.md)
|
|
36
|
-
- [threshold_pool](threshold_pool/README.md)
|
|
37
|
-
- [weighted_distribution](weighted_distribution/README.md)
|
|
38
|
-
|
|
39
|
-
## Running an example
|
|
40
|
-
|
|
41
|
-
Run an example with the installed CLI:
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
hsx check examples/instant_transfer/instant_transfer.hsx
|
|
45
|
-
hsx build examples/instant_transfer/instant_transfer.hsx --out program.udl
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Every company and person in these files is invented.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
program advance_example "Advance example"
|
|
2
|
-
import { advance } from "std/money_flows"
|
|
3
|
-
party funder: business
|
|
4
|
-
party recipient: business
|
|
5
|
-
settlement advance_payment = advance {
|
|
6
|
-
funder: funder
|
|
7
|
-
to: recipient
|
|
8
|
-
amount: principal: money(SAR)
|
|
9
|
-
fee: 2.5%
|
|
10
|
-
count: 2
|
|
11
|
-
every: P30D
|
|
12
|
-
first_due: firstDueAt
|
|
13
|
-
}
|