@hyperscale0/hsx 1.0.0-beta.1 → 1.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 +58 -9
- package/LICENSING.md +3 -3
- package/README.md +39 -149
- package/TRADEMARKS.md +4 -4
- package/bin/hsx.ts +2 -0
- package/dist/bin/hsx.js +2 -0
- package/dist/bin/hsx.js.map +1 -1
- package/dist/src/ast.d.ts +135 -10
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +24 -0
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +4 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +172 -16
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +42 -7
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +82 -16
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +78 -0
- package/dist/src/cost.d.ts.map +1 -0
- package/dist/src/cost.js +369 -0
- package/dist/src/cost.js.map +1 -0
- package/dist/src/diagnostics.d.ts +11 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +420 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/emit.d.ts +34 -0
- package/dist/src/emit.d.ts.map +1 -0
- package/dist/src/emit.js +137 -0
- package/dist/src/emit.js.map +1 -0
- package/dist/src/entry-overrides.d.ts +17 -3
- package/dist/src/entry-overrides.d.ts.map +1 -1
- package/dist/src/entry-overrides.js +180 -35
- package/dist/src/entry-overrides.js.map +1 -1
- package/dist/src/format.d.ts +10 -0
- package/dist/src/format.d.ts.map +1 -0
- package/dist/src/format.js +183 -0
- package/dist/src/format.js.map +1 -0
- package/dist/src/index.d.ts +11 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/ir.d.ts +66 -0
- package/dist/src/ir.d.ts.map +1 -0
- package/dist/src/ir.js +15 -0
- package/dist/src/ir.js.map +1 -0
- package/dist/src/lex.d.ts +9 -1
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +50 -4
- package/dist/src/lex.js.map +1 -1
- package/dist/src/limits.d.ts +2 -3
- package/dist/src/limits.d.ts.map +1 -1
- package/dist/src/limits.js +2 -3
- package/dist/src/limits.js.map +1 -1
- package/dist/src/lsp/server.d.ts +32 -0
- package/dist/src/lsp/server.d.ts.map +1 -0
- package/dist/src/lsp/server.js +391 -0
- package/dist/src/lsp/server.js.map +1 -0
- package/dist/src/modules.d.ts +38 -0
- package/dist/src/modules.d.ts.map +1 -0
- package/dist/src/modules.js +368 -0
- package/dist/src/modules.js.map +1 -0
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +590 -17
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts +2 -0
- package/dist/src/std-bundle.d.ts.map +1 -0
- package/dist/src/std-bundle.js +88 -0
- package/dist/src/std-bundle.js.map +1 -0
- package/dist/src/std-library.d.ts +5 -0
- package/dist/src/std-library.d.ts.map +1 -0
- package/dist/src/std-library.js +9 -0
- package/dist/src/std-library.js.map +1 -0
- package/dist/src/typecheck.d.ts +8 -0
- package/dist/src/typecheck.d.ts.map +1 -0
- package/dist/src/typecheck.js +2958 -0
- package/dist/src/typecheck.js.map +1 -0
- package/dist/src/version.d.ts +4 -15
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +4 -15
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +26 -0
- package/docs/guide/01-first-program.md +24 -0
- package/docs/guide/02-money.md +25 -0
- package/docs/guide/03-instruments.md +22 -0
- package/docs/guide/04-lifecycles.md +25 -0
- package/docs/guide/05-fees-and-splits.md +45 -0
- package/docs/guide/06-schedules.md +22 -0
- package/docs/guide/07-composition.md +46 -0
- package/docs/guide/08-writing-a-module.md +26 -0
- package/docs/guide/09-cost.md +24 -0
- package/docs/guide/10-diagnostics.md +27 -0
- package/docs/llms-full.txt +1739 -0
- package/docs/llms.txt +45 -0
- package/docs/playground.md +54 -0
- package/docs/reference/cli.md +35 -0
- package/docs/reference/diagnostics.md +619 -0
- package/docs/reference/grammar.md +39 -0
- package/docs/reference/std/advance.md +35 -0
- package/docs/reference/std/cancellable_booking.md +35 -0
- package/docs/reference/std/captured_payment.md +43 -0
- package/docs/reference/std/conditional_disbursement.md +33 -0
- package/docs/reference/std/credit_facility.md +35 -0
- package/docs/reference/std/held_payment.md +64 -0
- package/docs/reference/std/instant_transfer.md +30 -0
- package/docs/reference/std/metered.md +27 -0
- package/docs/reference/std/pooled_split.md +26 -0
- package/docs/reference/std/premium_forward.md +39 -0
- package/docs/reference/std/reconciled_payout.md +33 -0
- package/docs/reference/std/recurring_collection.md +25 -0
- package/docs/reference/std/rotating_pool.md +42 -0
- package/docs/reference/std/scheduled.md +51 -0
- package/docs/reference/std/security_deposit.md +46 -0
- package/docs/reference/std/settlement_batch.md +42 -0
- package/docs/reference/std/swap.md +46 -0
- package/docs/reference/std/threshold_pool.md +47 -0
- package/docs/reference/std/weighted_distribution.md +39 -0
- package/docs/reference/types.md +20 -0
- package/docs/reference/udl-output.md +13 -0
- package/docs/sessions/2026-09-02-two-instruments.hsx +21 -0
- package/docs/sessions/2026-09-02-two-instruments.md +41 -0
- package/examples/01-first-program/README.md +45 -0
- package/examples/01-first-program/tip-jar.hsx +17 -0
- package/examples/02-imports-and-archetypes/README.md +96 -0
- package/examples/02-imports-and-archetypes/photo-booth.hsx +37 -0
- package/examples/03-diagnostics/README.md +68 -0
- package/examples/03-diagnostics/corner-shop-fixed.hsx +22 -0
- package/examples/03-diagnostics/corner-shop.hsx +19 -0
- package/examples/04-complete-product/README.md +84 -0
- package/examples/04-complete-product/study-hall.hsx +67 -0
- package/examples/05-watch-club/README.md +9 -0
- package/examples/05-watch-club/watch-club.hsx +124 -0
- package/examples/README.md +18 -0
- package/examples/advance/README.md +3 -0
- package/examples/advance/advance.hsx +13 -0
- package/examples/advance/advance.udl +339 -0
- package/examples/cancellable_booking/README.md +3 -0
- package/examples/cancellable_booking/cancellable_booking.hsx +14 -0
- package/examples/cancellable_booking/cancellable_booking.udl +391 -0
- package/examples/captured_payment/README.md +3 -0
- package/examples/captured_payment/captured_payment.hsx +21 -0
- package/examples/captured_payment/captured_payment.udl +677 -0
- package/examples/conditional_disbursement/README.md +3 -0
- package/examples/conditional_disbursement/conditional_disbursement.hsx +17 -0
- package/examples/conditional_disbursement/conditional_disbursement.udl +412 -0
- package/examples/cost-table.json +386 -0
- package/examples/credit_facility/README.md +3 -0
- package/examples/credit_facility/credit_facility.hsx +27 -0
- package/examples/credit_facility/credit_facility.udl +1373 -0
- package/examples/held_payment/README.md +3 -0
- package/examples/held_payment/held_payment.hsx +13 -0
- package/examples/held_payment/held_payment.udl +507 -0
- package/examples/instant_transfer/README.md +3 -0
- package/examples/instant_transfer/instant_transfer.hsx +16 -0
- package/examples/instant_transfer/instant_transfer.udl +364 -0
- package/examples/metered/README.md +3 -0
- package/examples/metered/metered.hsx +13 -0
- package/examples/metered/metered.udl +247 -0
- package/examples/pooled_split/README.md +3 -0
- package/examples/pooled_split/pooled_split.hsx +15 -0
- package/examples/pooled_split/pooled_split.udl +425 -0
- package/examples/premium_forward/README.md +3 -0
- package/examples/premium_forward/premium_forward.hsx +19 -0
- package/examples/premium_forward/premium_forward.udl +594 -0
- package/examples/reconciled_payout/README.md +3 -0
- package/examples/reconciled_payout/reconciled_payout.hsx +13 -0
- package/examples/reconciled_payout/reconciled_payout.udl +303 -0
- package/examples/recurring_collection/README.md +3 -0
- package/examples/recurring_collection/recurring_collection.hsx +21 -0
- package/examples/recurring_collection/recurring_collection.udl +1130 -0
- package/examples/rotating_pool/README.md +3 -0
- package/examples/rotating_pool/rotating_pool.hsx +18 -0
- package/examples/rotating_pool/rotating_pool.udl +4352 -0
- package/examples/scheduled/README.md +3 -0
- package/examples/scheduled/scheduled.hsx +12 -0
- package/examples/scheduled/scheduled.udl +335 -0
- package/examples/security_deposit/README.md +3 -0
- package/examples/security_deposit/security_deposit.hsx +21 -0
- package/examples/security_deposit/security_deposit.udl +293 -0
- package/examples/settlement_batch/README.md +3 -0
- package/examples/settlement_batch/settlement_batch.hsx +19 -0
- package/examples/settlement_batch/settlement_batch.udl +753 -0
- package/examples/swap/README.md +3 -0
- package/examples/swap/swap.hsx +19 -0
- package/examples/swap/swap.udl +876 -0
- package/examples/threshold_pool/README.md +3 -0
- package/examples/threshold_pool/threshold_pool.hsx +16 -0
- package/examples/threshold_pool/threshold_pool.udl +667 -0
- package/examples/weighted_distribution/README.md +3 -0
- package/examples/weighted_distribution/weighted_distribution.hsx +20 -0
- package/examples/weighted_distribution/weighted_distribution.udl +337 -0
- package/package.json +27 -6
- package/skills/hsx/SKILL.md +483 -0
- package/src/ast.ts +193 -9
- package/src/cli.ts +191 -20
- package/src/compile.ts +160 -23
- package/src/cost.ts +579 -0
- package/src/diagnostics.ts +442 -0
- package/src/emit.ts +201 -0
- package/src/entry-overrides.ts +263 -48
- package/src/format.ts +261 -0
- package/src/index.ts +34 -4
- package/src/ir.ts +99 -0
- package/src/lex.ts +59 -4
- package/src/limits.ts +2 -3
- package/src/lsp/server.ts +460 -0
- package/src/modules.ts +446 -0
- package/src/parse.ts +655 -21
- package/src/std-bundle.ts +91 -0
- package/src/std-library.ts +12 -0
- package/src/typecheck.ts +3876 -0
- package/src/version.ts +4 -16
- package/std/SEMANTICS.md +130 -0
- package/std/settlements/advance.hsx +177 -0
- package/std/settlements/cancellable_booking.hsx +87 -0
- package/std/settlements/captured_payment.hsx +144 -0
- package/std/settlements/conditional_disbursement.hsx +185 -0
- package/std/settlements/credit_facility.hsx +167 -0
- package/std/settlements/held_payment.hsx +578 -0
- package/std/settlements/index.hsx +3 -0
- package/std/settlements/instant_transfer.hsx +190 -0
- package/std/settlements/metered.hsx +67 -0
- package/std/settlements/pooled_split.hsx +68 -0
- package/std/settlements/premium_forward.hsx +257 -0
- package/std/settlements/reconciled_payout.hsx +77 -0
- package/std/settlements/recurring_collection.hsx +27 -0
- package/std/settlements/rotating_pool.hsx +252 -0
- package/std/settlements/scheduled.hsx +641 -0
- package/std/settlements/security_deposit.hsx +166 -0
- package/std/settlements/settlement_batch.hsx +122 -0
- package/std/settlements/swap.hsx +1114 -0
- package/std/settlements/threshold_pool.hsx +221 -0
- package/std/settlements/weighted_distribution.hsx +141 -0
- package/dist/src/archetypes.d.ts +0 -17
- package/dist/src/archetypes.d.ts.map +0 -1
- package/dist/src/archetypes.js +0 -327
- package/dist/src/archetypes.js.map +0 -1
- package/dist/src/check.d.ts +0 -12
- package/dist/src/check.d.ts.map +0 -1
- package/dist/src/check.js +0 -1910
- package/dist/src/check.js.map +0 -1
- package/dist/src/lower.d.ts +0 -146
- package/dist/src/lower.d.ts.map +0 -1
- package/dist/src/lower.js +0 -4570
- package/dist/src/lower.js.map +0 -1
- package/dist/src/model.d.ts +0 -467
- package/dist/src/model.d.ts.map +0 -1
- package/dist/src/model.js +0 -15
- package/dist/src/model.js.map +0 -1
- package/spec/hsx-ir.schema.json +0 -920
- package/src/archetypes.ts +0 -340
- package/src/check.ts +0 -2938
- package/src/lower.ts +0 -5416
- package/src/model.ts +0 -519
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
program held_payment_example "Held payment example"
|
|
2
|
+
import { held_payment } from "std/settlements"
|
|
3
|
+
party buyer: person
|
|
4
|
+
party seller: business
|
|
5
|
+
settlement sale = held_payment {
|
|
6
|
+
payer: buyer
|
|
7
|
+
payee: seller
|
|
8
|
+
amount: price: money(SAR)
|
|
9
|
+
fees { buyer: 1% }
|
|
10
|
+
on_cancel(funded) { buyer: 100% }
|
|
11
|
+
release: port confirm_delivery | at(releaseDueAt)
|
|
12
|
+
}
|
|
13
|
+
port confirm_delivery { allowed: [buyer] }
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
{
|
|
2
|
+
"instruments": [
|
|
3
|
+
{
|
|
4
|
+
"actionOrder": [
|
|
5
|
+
"create",
|
|
6
|
+
"fund_piece_1",
|
|
7
|
+
"confirm_delivery",
|
|
8
|
+
"release_on_deadline",
|
|
9
|
+
"cancel",
|
|
10
|
+
"abandon"
|
|
11
|
+
],
|
|
12
|
+
"actions": {
|
|
13
|
+
"abandon": {
|
|
14
|
+
"agentDescription": "Close a sale that was never funded. The escrow account must be empty, so this refuses once any piece is in it. It moves no money and the settlement ends here with no way back.",
|
|
15
|
+
"moves": [],
|
|
16
|
+
"publicAction": "abandonSale",
|
|
17
|
+
"requiresDrainedAccount": {
|
|
18
|
+
"path": "refs.escrowAccountId"
|
|
19
|
+
},
|
|
20
|
+
"steps": [],
|
|
21
|
+
"summary": "Abandon the settlement before any money is held"
|
|
22
|
+
},
|
|
23
|
+
"cancel": {
|
|
24
|
+
"agentDescription": "Cancel the sale and start returning the held money to the buyer. It must be funded and not yet released. Cancellation is final, and a cancelled settlement never releases. Where the product sets a release deadline, this call is refused once that date passes.",
|
|
25
|
+
"deadline": {
|
|
26
|
+
"field": "releaseDueAt"
|
|
27
|
+
},
|
|
28
|
+
"effects": {
|
|
29
|
+
"moves": [
|
|
30
|
+
{
|
|
31
|
+
"signature": "moves.transfer.internal",
|
|
32
|
+
"source": "moves[0]"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"schedules": [
|
|
36
|
+
{
|
|
37
|
+
"signature": "schedules.deadline",
|
|
38
|
+
"source": "deadline"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"moves": [
|
|
43
|
+
{
|
|
44
|
+
"bind": {
|
|
45
|
+
"amount": {
|
|
46
|
+
"from": "instance",
|
|
47
|
+
"path": "fields.price"
|
|
48
|
+
},
|
|
49
|
+
"currency": {
|
|
50
|
+
"from": "instance",
|
|
51
|
+
"path": "fields.currency"
|
|
52
|
+
},
|
|
53
|
+
"destinationAccountId": {
|
|
54
|
+
"from": "instance",
|
|
55
|
+
"path": "fields.buyerAccountId"
|
|
56
|
+
},
|
|
57
|
+
"metadata.instrumentId": {
|
|
58
|
+
"from": "const",
|
|
59
|
+
"value": "sale"
|
|
60
|
+
},
|
|
61
|
+
"metadata.instrumentInstanceId": {
|
|
62
|
+
"from": "instance",
|
|
63
|
+
"path": "instrumentInstanceId"
|
|
64
|
+
},
|
|
65
|
+
"metadata.phase": {
|
|
66
|
+
"from": "const",
|
|
67
|
+
"value": "cancel"
|
|
68
|
+
},
|
|
69
|
+
"productId": {
|
|
70
|
+
"from": "instance",
|
|
71
|
+
"path": "productId"
|
|
72
|
+
},
|
|
73
|
+
"sourceAccountId": {
|
|
74
|
+
"from": "instance",
|
|
75
|
+
"path": "refs.escrowAccountId"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"capture": {
|
|
79
|
+
"cancelTransferTransferId": "transferId"
|
|
80
|
+
},
|
|
81
|
+
"key": "transfer",
|
|
82
|
+
"operation": "internal_transfer.create"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"publicAction": "cancelSale",
|
|
86
|
+
"steps": [],
|
|
87
|
+
"summary": "Cancel the settlement and start the unwind"
|
|
88
|
+
},
|
|
89
|
+
"confirm_delivery": {
|
|
90
|
+
"agentDescription": "Confirm confirm_delivery and start paying the held money out of escrow. The sale must be funded first, and the caller must be buyer. Where the product requires a decision reference, supply it here. Money leaves escrow on this call and does not come back.",
|
|
91
|
+
"deadline": {
|
|
92
|
+
"field": "releaseDueAt"
|
|
93
|
+
},
|
|
94
|
+
"effects": {
|
|
95
|
+
"decides": [
|
|
96
|
+
{
|
|
97
|
+
"signature": "decides.tenant_port",
|
|
98
|
+
"source": "port"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"moves": [
|
|
102
|
+
{
|
|
103
|
+
"signature": "moves.transfer.internal",
|
|
104
|
+
"source": "moves[0]"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"schedules": [
|
|
108
|
+
{
|
|
109
|
+
"signature": "schedules.deadline",
|
|
110
|
+
"source": "deadline"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"moves": [
|
|
115
|
+
{
|
|
116
|
+
"bind": {
|
|
117
|
+
"amount": {
|
|
118
|
+
"from": "instance",
|
|
119
|
+
"path": "fields.price"
|
|
120
|
+
},
|
|
121
|
+
"currency": {
|
|
122
|
+
"from": "instance",
|
|
123
|
+
"path": "fields.currency"
|
|
124
|
+
},
|
|
125
|
+
"destinationAccountId": {
|
|
126
|
+
"from": "instance",
|
|
127
|
+
"path": "fields.sellerAccountId"
|
|
128
|
+
},
|
|
129
|
+
"metadata.instrumentId": {
|
|
130
|
+
"from": "const",
|
|
131
|
+
"value": "sale"
|
|
132
|
+
},
|
|
133
|
+
"metadata.instrumentInstanceId": {
|
|
134
|
+
"from": "instance",
|
|
135
|
+
"path": "instrumentInstanceId"
|
|
136
|
+
},
|
|
137
|
+
"metadata.phase": {
|
|
138
|
+
"from": "const",
|
|
139
|
+
"value": "confirm_delivery"
|
|
140
|
+
},
|
|
141
|
+
"productId": {
|
|
142
|
+
"from": "instance",
|
|
143
|
+
"path": "productId"
|
|
144
|
+
},
|
|
145
|
+
"sourceAccountId": {
|
|
146
|
+
"from": "instance",
|
|
147
|
+
"path": "refs.escrowAccountId"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"capture": {
|
|
151
|
+
"confirmDeliveryTransferTransferId": "transferId"
|
|
152
|
+
},
|
|
153
|
+
"key": "transfer",
|
|
154
|
+
"operation": "internal_transfer.create"
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"port": {
|
|
158
|
+
"allowedParties": [
|
|
159
|
+
"payer"
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"publicAction": "confirmDeliverySale",
|
|
163
|
+
"steps": [],
|
|
164
|
+
"summary": "Confirm through confirm_delivery and start the release payout"
|
|
165
|
+
},
|
|
166
|
+
"create": {
|
|
167
|
+
"agentDescription": "Open the sale and provision the escrow account that holds the funds. This is the first call, and every funding and release action moves money through that account. It does not move the held amount itself.",
|
|
168
|
+
"moves": [],
|
|
169
|
+
"publicAction": "createSale",
|
|
170
|
+
"steps": [
|
|
171
|
+
{
|
|
172
|
+
"bind": {
|
|
173
|
+
"currency": {
|
|
174
|
+
"from": "instance",
|
|
175
|
+
"path": "fields.currency"
|
|
176
|
+
},
|
|
177
|
+
"owner.id": {
|
|
178
|
+
"from": "instance",
|
|
179
|
+
"path": "productId"
|
|
180
|
+
},
|
|
181
|
+
"owner.type": {
|
|
182
|
+
"from": "const",
|
|
183
|
+
"value": "product"
|
|
184
|
+
},
|
|
185
|
+
"productId": {
|
|
186
|
+
"from": "instance",
|
|
187
|
+
"path": "productId"
|
|
188
|
+
},
|
|
189
|
+
"role": {
|
|
190
|
+
"from": "const",
|
|
191
|
+
"value": "product_escrow"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"capture": {
|
|
195
|
+
"escrowAccountId": "accountId"
|
|
196
|
+
},
|
|
197
|
+
"operation": "account.escrow.provision"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"summary": "Create a sale settlement"
|
|
201
|
+
},
|
|
202
|
+
"fund_piece_1": {
|
|
203
|
+
"agentDescription": "Move the buyer's money into this settlement's escrow. Call it after create and before any release. It debits the buyer for real, and where the product charges a payer-side fee that fee is taken on top in the same call. Only a later release or unwind moves the money again.",
|
|
204
|
+
"effects": {
|
|
205
|
+
"moves": [
|
|
206
|
+
{
|
|
207
|
+
"signature": "moves.collection.pay_in",
|
|
208
|
+
"source": "moves[0]"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"signature": "moves.transfer.internal",
|
|
212
|
+
"source": "moves[1]"
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"moves": [
|
|
217
|
+
{
|
|
218
|
+
"bind": {
|
|
219
|
+
"amount": {
|
|
220
|
+
"from": "instance",
|
|
221
|
+
"path": "fields.price"
|
|
222
|
+
},
|
|
223
|
+
"currency": {
|
|
224
|
+
"from": "instance",
|
|
225
|
+
"path": "fields.currency"
|
|
226
|
+
},
|
|
227
|
+
"destinationAccountId": {
|
|
228
|
+
"from": "instance",
|
|
229
|
+
"path": "refs.escrowAccountId"
|
|
230
|
+
},
|
|
231
|
+
"metadata.instrumentId": {
|
|
232
|
+
"from": "const",
|
|
233
|
+
"value": "sale"
|
|
234
|
+
},
|
|
235
|
+
"metadata.instrumentInstanceId": {
|
|
236
|
+
"from": "instance",
|
|
237
|
+
"path": "instrumentInstanceId"
|
|
238
|
+
},
|
|
239
|
+
"metadata.phase": {
|
|
240
|
+
"from": "const",
|
|
241
|
+
"value": "fund_piece_1"
|
|
242
|
+
},
|
|
243
|
+
"productId": {
|
|
244
|
+
"from": "instance",
|
|
245
|
+
"path": "productId"
|
|
246
|
+
},
|
|
247
|
+
"sourceAccountId": {
|
|
248
|
+
"from": "instance",
|
|
249
|
+
"path": "fields.buyerAccountId"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"capture": {
|
|
253
|
+
"fundPiece1TransferTransferId": "transferId"
|
|
254
|
+
},
|
|
255
|
+
"key": "transfer",
|
|
256
|
+
"operation": "internal_transfer.create"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"bind": {
|
|
260
|
+
"amount": {
|
|
261
|
+
"from": "instance",
|
|
262
|
+
"path": "fields.serviceFeeAmount"
|
|
263
|
+
},
|
|
264
|
+
"currency": {
|
|
265
|
+
"from": "instance",
|
|
266
|
+
"path": "fields.currency"
|
|
267
|
+
},
|
|
268
|
+
"destinationAccountId": {
|
|
269
|
+
"from": "instance",
|
|
270
|
+
"path": "fields.platformAccountId"
|
|
271
|
+
},
|
|
272
|
+
"metadata.instrumentId": {
|
|
273
|
+
"from": "const",
|
|
274
|
+
"value": "sale"
|
|
275
|
+
},
|
|
276
|
+
"metadata.instrumentInstanceId": {
|
|
277
|
+
"from": "instance",
|
|
278
|
+
"path": "instrumentInstanceId"
|
|
279
|
+
},
|
|
280
|
+
"metadata.phase": {
|
|
281
|
+
"from": "const",
|
|
282
|
+
"value": "fund_piece_1"
|
|
283
|
+
},
|
|
284
|
+
"productId": {
|
|
285
|
+
"from": "instance",
|
|
286
|
+
"path": "productId"
|
|
287
|
+
},
|
|
288
|
+
"sourceAccountId": {
|
|
289
|
+
"from": "instance",
|
|
290
|
+
"path": "fields.buyerAccountId"
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
"capture": {
|
|
294
|
+
"fundPiece1ServiceFeeTransferId": "transferId"
|
|
295
|
+
},
|
|
296
|
+
"key": "service_fee",
|
|
297
|
+
"operation": "internal_transfer.create"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
"publicAction": "fundPiece1Sale",
|
|
301
|
+
"steps": [],
|
|
302
|
+
"summary": "Fund piece 1 of the held amount into escrow"
|
|
303
|
+
},
|
|
304
|
+
"release_on_deadline": {
|
|
305
|
+
"due": {
|
|
306
|
+
"field": "releaseDueAt"
|
|
307
|
+
},
|
|
308
|
+
"effects": {
|
|
309
|
+
"moves": [
|
|
310
|
+
{
|
|
311
|
+
"signature": "moves.transfer.internal",
|
|
312
|
+
"source": "moves[0]"
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
"schedules": [
|
|
316
|
+
{
|
|
317
|
+
"signature": "schedules.due",
|
|
318
|
+
"source": "due"
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
"moves": [
|
|
323
|
+
{
|
|
324
|
+
"bind": {
|
|
325
|
+
"amount": {
|
|
326
|
+
"from": "instance",
|
|
327
|
+
"path": "fields.price"
|
|
328
|
+
},
|
|
329
|
+
"currency": {
|
|
330
|
+
"from": "instance",
|
|
331
|
+
"path": "fields.currency"
|
|
332
|
+
},
|
|
333
|
+
"destinationAccountId": {
|
|
334
|
+
"from": "instance",
|
|
335
|
+
"path": "fields.sellerAccountId"
|
|
336
|
+
},
|
|
337
|
+
"metadata.instrumentId": {
|
|
338
|
+
"from": "const",
|
|
339
|
+
"value": "sale"
|
|
340
|
+
},
|
|
341
|
+
"metadata.instrumentInstanceId": {
|
|
342
|
+
"from": "instance",
|
|
343
|
+
"path": "instrumentInstanceId"
|
|
344
|
+
},
|
|
345
|
+
"metadata.phase": {
|
|
346
|
+
"from": "const",
|
|
347
|
+
"value": "release_on_deadline"
|
|
348
|
+
},
|
|
349
|
+
"productId": {
|
|
350
|
+
"from": "instance",
|
|
351
|
+
"path": "productId"
|
|
352
|
+
},
|
|
353
|
+
"sourceAccountId": {
|
|
354
|
+
"from": "instance",
|
|
355
|
+
"path": "refs.escrowAccountId"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"capture": {
|
|
359
|
+
"releaseOnDeadlineTransferTransferId": "transferId"
|
|
360
|
+
},
|
|
361
|
+
"key": "transfer",
|
|
362
|
+
"operation": "internal_transfer.create"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"steps": [],
|
|
366
|
+
"summary": "Release to the seller when releaseDueAt arrives undecided"
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
"agentDescription": "Reach for sale when the buyer must commit money up front and nobody is paid until confirm_delivery fires. Funding moves price into this settlement's own escrow account, where it stays until a release or an unwind pays it out. A straight-through payment with no custody step is a different shape.",
|
|
370
|
+
"description": "Held payment: the buyer funds price into this settlement's own escrow; buyer confirms through confirm_delivery to release",
|
|
371
|
+
"feeRules": [
|
|
372
|
+
{
|
|
373
|
+
"amountField": "serviceFeeAmount",
|
|
374
|
+
"baseField": "price",
|
|
375
|
+
"bearerField": "buyerAccountId",
|
|
376
|
+
"position": "on_top",
|
|
377
|
+
"rule": {
|
|
378
|
+
"bps": 100,
|
|
379
|
+
"kind": "bps"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
],
|
|
383
|
+
"fields": {
|
|
384
|
+
"buyerAccountId": {
|
|
385
|
+
"description": "The buyer account",
|
|
386
|
+
"pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
|
|
387
|
+
"type": "string",
|
|
388
|
+
"x-hyperscale-reference-filter": {
|
|
389
|
+
"column": "role",
|
|
390
|
+
"values": [
|
|
391
|
+
"customer_balance"
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"currency": {
|
|
396
|
+
"description": "ISO 4217 currency code",
|
|
397
|
+
"maxLength": 3,
|
|
398
|
+
"minLength": 3,
|
|
399
|
+
"pattern": "^[A-Z]{3}$",
|
|
400
|
+
"type": "string"
|
|
401
|
+
},
|
|
402
|
+
"platformAccountId": {
|
|
403
|
+
"description": "The product fee collection account",
|
|
404
|
+
"pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
|
|
405
|
+
"type": "string",
|
|
406
|
+
"x-hyperscale-fee-collection-port": true,
|
|
407
|
+
"x-hyperscale-reference-filter": {
|
|
408
|
+
"column": "role",
|
|
409
|
+
"values": [
|
|
410
|
+
"customer_balance",
|
|
411
|
+
"product_revenue"
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
"price": {
|
|
416
|
+
"description": "The held amount in SAR minor units, funded and paid out whole",
|
|
417
|
+
"pattern": "^[1-9][0-9]{0,17}$",
|
|
418
|
+
"type": "string"
|
|
419
|
+
},
|
|
420
|
+
"releaseDueAt": {
|
|
421
|
+
"description": "The date an undecided hold releases to the seller on; confirm_delivery and cancellation decide only before it",
|
|
422
|
+
"format": "hyperscale-date-time",
|
|
423
|
+
"type": "string"
|
|
424
|
+
},
|
|
425
|
+
"sellerAccountId": {
|
|
426
|
+
"description": "The seller account",
|
|
427
|
+
"pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
|
|
428
|
+
"type": "string",
|
|
429
|
+
"x-hyperscale-reference-filter": {
|
|
430
|
+
"column": "role",
|
|
431
|
+
"values": [
|
|
432
|
+
"customer_balance"
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
"serviceFeeAmount": {
|
|
437
|
+
"description": "Machine-owned 1% service fee computed from price; charged on top at funding",
|
|
438
|
+
"pattern": "^[1-9][0-9]{0,17}$",
|
|
439
|
+
"type": "string"
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
"id": "sale",
|
|
443
|
+
"idPrefix": "sale",
|
|
444
|
+
"lifecycle": {
|
|
445
|
+
"initial": "created",
|
|
446
|
+
"states": [
|
|
447
|
+
"created",
|
|
448
|
+
"funded",
|
|
449
|
+
"released",
|
|
450
|
+
"cancelled",
|
|
451
|
+
"abandoned"
|
|
452
|
+
],
|
|
453
|
+
"transitions": {
|
|
454
|
+
"abandon": {
|
|
455
|
+
"from": [
|
|
456
|
+
"created"
|
|
457
|
+
],
|
|
458
|
+
"to": "abandoned"
|
|
459
|
+
},
|
|
460
|
+
"cancel": {
|
|
461
|
+
"from": [
|
|
462
|
+
"funded"
|
|
463
|
+
],
|
|
464
|
+
"to": "cancelled"
|
|
465
|
+
},
|
|
466
|
+
"confirm_delivery": {
|
|
467
|
+
"from": [
|
|
468
|
+
"funded"
|
|
469
|
+
],
|
|
470
|
+
"to": "released"
|
|
471
|
+
},
|
|
472
|
+
"fund_piece_1": {
|
|
473
|
+
"from": [
|
|
474
|
+
"created"
|
|
475
|
+
],
|
|
476
|
+
"to": "funded"
|
|
477
|
+
},
|
|
478
|
+
"release_on_deadline": {
|
|
479
|
+
"from": [
|
|
480
|
+
"funded"
|
|
481
|
+
],
|
|
482
|
+
"to": "released"
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"parties": {
|
|
487
|
+
"beneficiary": "sellerAccountId",
|
|
488
|
+
"payer": "buyerAccountId"
|
|
489
|
+
},
|
|
490
|
+
"required": [
|
|
491
|
+
"buyerAccountId",
|
|
492
|
+
"sellerAccountId",
|
|
493
|
+
"platformAccountId",
|
|
494
|
+
"price",
|
|
495
|
+
"releaseDueAt",
|
|
496
|
+
"currency"
|
|
497
|
+
],
|
|
498
|
+
"summary": "Escrow-held payment from buyer to seller",
|
|
499
|
+
"title": "Sale"
|
|
500
|
+
}
|
|
501
|
+
],
|
|
502
|
+
"product": "held_payment_example",
|
|
503
|
+
"subjects": [],
|
|
504
|
+
"title": "Held payment example",
|
|
505
|
+
"udl": 1,
|
|
506
|
+
"version": 1
|
|
507
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
program instant_transfer_example "Instant transfer example"
|
|
2
|
+
import { instant_transfer } from "std/settlements"
|
|
3
|
+
party customer: person
|
|
4
|
+
party merchant: business
|
|
5
|
+
settlement transfer = instant_transfer {
|
|
6
|
+
payer: customer
|
|
7
|
+
payee: merchant
|
|
8
|
+
amount: transferAmount: money(SAR)
|
|
9
|
+
fees {
|
|
10
|
+
customer: checkoutFee: money(SAR)
|
|
11
|
+
merchant {
|
|
12
|
+
tier { from: 0, to: 10000, fee: 1% }
|
|
13
|
+
tier { from: 10000, fee: highValueFee: money(SAR) }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|