@hyperscale0/hsx 2.4.1 → 3.0.1

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.
Files changed (249) hide show
  1. package/CHANGELOG.md +4 -406
  2. package/README.md +3 -92
  3. package/dist/src/ast.d.ts +99 -310
  4. package/dist/src/ast.d.ts.map +1 -1
  5. package/dist/src/ast.js +16 -69
  6. package/dist/src/ast.js.map +1 -1
  7. package/dist/src/cli.d.ts +6 -19
  8. package/dist/src/cli.d.ts.map +1 -1
  9. package/dist/src/cli.js +77 -315
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/compile.d.ts +23 -73
  12. package/dist/src/compile.d.ts.map +1 -1
  13. package/dist/src/compile.js +1113 -148
  14. package/dist/src/compile.js.map +1 -1
  15. package/dist/src/cost.d.ts +8 -77
  16. package/dist/src/cost.d.ts.map +1 -1
  17. package/dist/src/cost.js +13 -422
  18. package/dist/src/cost.js.map +1 -1
  19. package/dist/src/format.d.ts +8 -7
  20. package/dist/src/format.d.ts.map +1 -1
  21. package/dist/src/format.js +9 -175
  22. package/dist/src/format.js.map +1 -1
  23. package/dist/src/headers.d.ts +35 -0
  24. package/dist/src/headers.d.ts.map +1 -0
  25. package/dist/src/headers.js +108 -0
  26. package/dist/src/headers.js.map +1 -0
  27. package/dist/src/index.d.ts +6 -12
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +4 -9
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lex.d.ts +8 -28
  32. package/dist/src/lex.d.ts.map +1 -1
  33. package/dist/src/lex.js +88 -146
  34. package/dist/src/lex.js.map +1 -1
  35. package/dist/src/parse.d.ts +4 -17
  36. package/dist/src/parse.d.ts.map +1 -1
  37. package/dist/src/parse.js +402 -1040
  38. package/dist/src/parse.js.map +1 -1
  39. package/dist/src/std-bundle.d.ts.map +1 -1
  40. package/dist/src/std-bundle.js +12 -20
  41. package/dist/src/std-bundle.js.map +1 -1
  42. package/dist/src/std-library.d.ts +1 -1
  43. package/dist/src/std-library.d.ts.map +1 -1
  44. package/dist/src/std-library.js +1 -5
  45. package/dist/src/std-library.js.map +1 -1
  46. package/dist/src/tunables.d.ts +7 -0
  47. package/dist/src/tunables.d.ts.map +1 -0
  48. package/dist/src/tunables.js +26 -0
  49. package/dist/src/tunables.js.map +1 -0
  50. package/dist/src/version.d.ts +2 -4
  51. package/dist/src/version.d.ts.map +1 -1
  52. package/dist/src/version.js +2 -4
  53. package/dist/src/version.js.map +1 -1
  54. package/docs/README.md +179 -41
  55. package/docs/headers.md +44 -0
  56. package/examples/cost-table.json +99 -751
  57. package/examples/library.hsx +59 -0
  58. package/package.json +9 -17
  59. package/src/ast.ts +82 -441
  60. package/src/cli.ts +78 -362
  61. package/src/compile.ts +1535 -247
  62. package/src/cost.ts +28 -671
  63. package/src/format.ts +12 -256
  64. package/src/headers.ts +126 -0
  65. package/src/index.ts +7 -39
  66. package/src/lex.ts +99 -195
  67. package/src/parse.ts +403 -1209
  68. package/src/std-bundle.ts +12 -20
  69. package/src/std-library.ts +2 -7
  70. package/src/tunables.ts +31 -0
  71. package/src/version.ts +2 -5
  72. package/std/approvals.hsx +17 -0
  73. package/std/cards.hsx +63 -0
  74. package/std/collections.hsx +31 -0
  75. package/std/escrow.hsx +43 -0
  76. package/std/financing.hsx +372 -0
  77. package/std/insurance.hsx +59 -0
  78. package/std/lending.hsx +115 -0
  79. package/std/marketplace.hsx +24 -0
  80. package/std/money.hsx +195 -0
  81. package/std/savings.hsx +44 -0
  82. package/std/travel.hsx +98 -0
  83. package/std/wallet.hsx +41 -0
  84. package/dist/src/diagnostics.d.ts +0 -13
  85. package/dist/src/diagnostics.d.ts.map +0 -1
  86. package/dist/src/diagnostics.js +0 -587
  87. package/dist/src/diagnostics.js.map +0 -1
  88. package/dist/src/emit.d.ts +0 -51
  89. package/dist/src/emit.d.ts.map +0 -1
  90. package/dist/src/emit.js +0 -192
  91. package/dist/src/emit.js.map +0 -1
  92. package/dist/src/entry-overrides.d.ts +0 -58
  93. package/dist/src/entry-overrides.d.ts.map +0 -1
  94. package/dist/src/entry-overrides.js +0 -284
  95. package/dist/src/entry-overrides.js.map +0 -1
  96. package/dist/src/ir.d.ts +0 -73
  97. package/dist/src/ir.d.ts.map +0 -1
  98. package/dist/src/ir.js +0 -15
  99. package/dist/src/ir.js.map +0 -1
  100. package/dist/src/limits.d.ts +0 -23
  101. package/dist/src/limits.d.ts.map +0 -1
  102. package/dist/src/limits.js +0 -23
  103. package/dist/src/limits.js.map +0 -1
  104. package/dist/src/lsp/server.d.ts +0 -32
  105. package/dist/src/lsp/server.d.ts.map +0 -1
  106. package/dist/src/lsp/server.js +0 -391
  107. package/dist/src/lsp/server.js.map +0 -1
  108. package/dist/src/modules.d.ts +0 -38
  109. package/dist/src/modules.d.ts.map +0 -1
  110. package/dist/src/modules.js +0 -372
  111. package/dist/src/modules.js.map +0 -1
  112. package/dist/src/typecheck.d.ts +0 -8
  113. package/dist/src/typecheck.d.ts.map +0 -1
  114. package/dist/src/typecheck.js +0 -4160
  115. package/dist/src/typecheck.js.map +0 -1
  116. package/docs/guide/01-first-program.md +0 -24
  117. package/docs/guide/02-money.md +0 -25
  118. package/docs/guide/03-instruments.md +0 -93
  119. package/docs/guide/04-lifecycles.md +0 -40
  120. package/docs/guide/05-fees-and-splits.md +0 -45
  121. package/docs/guide/06-schedules.md +0 -26
  122. package/docs/guide/07-composition.md +0 -52
  123. package/docs/guide/08-writing-a-module.md +0 -85
  124. package/docs/guide/09-cost.md +0 -24
  125. package/docs/guide/10-diagnostics.md +0 -27
  126. package/docs/llms-full.txt +0 -3684
  127. package/docs/llms.txt +0 -44
  128. package/docs/piece-plans.md +0 -120
  129. package/docs/playground.md +0 -55
  130. package/docs/reference/cli.md +0 -36
  131. package/docs/reference/diagnostics.md +0 -901
  132. package/docs/reference/grammar.md +0 -38
  133. package/docs/reference/std/advance.md +0 -112
  134. package/docs/reference/std/cancellable_booking.md +0 -159
  135. package/docs/reference/std/captured_payment.md +0 -115
  136. package/docs/reference/std/conditional_disbursement.md +0 -101
  137. package/docs/reference/std/credit_facility.md +0 -108
  138. package/docs/reference/std/held_payment.md +0 -173
  139. package/docs/reference/std/instant_transfer.md +0 -97
  140. package/docs/reference/std/metered.md +0 -89
  141. package/docs/reference/std/pooled_split.md +0 -95
  142. package/docs/reference/std/premium_forward.md +0 -119
  143. package/docs/reference/std/reconciled_payout.md +0 -103
  144. package/docs/reference/std/rotating_pool.md +0 -130
  145. package/docs/reference/std/scheduled.md +0 -136
  146. package/docs/reference/std/security_deposit.md +0 -138
  147. package/docs/reference/std/settlement_batch.md +0 -123
  148. package/docs/reference/std/swap.md +0 -133
  149. package/docs/reference/std/threshold_pool.md +0 -138
  150. package/docs/reference/std/weighted_distribution.md +0 -135
  151. package/docs/reference/types.md +0 -61
  152. package/docs/reference/udl-output.md +0 -13
  153. package/examples/01-first-program/README.md +0 -45
  154. package/examples/01-first-program/tip-jar.hsx +0 -17
  155. package/examples/02-imports-and-modules/README.md +0 -96
  156. package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
  157. package/examples/03-diagnostics/README.md +0 -68
  158. package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
  159. package/examples/03-diagnostics/corner-shop.hsx +0 -19
  160. package/examples/04-complete-product/README.md +0 -84
  161. package/examples/04-complete-product/study-hall.hsx +0 -67
  162. package/examples/05-authored-instrument/README.md +0 -5
  163. package/examples/05-authored-instrument/payment.hsx +0 -37
  164. package/examples/05-watch-club/README.md +0 -6
  165. package/examples/05-watch-club/watch-club.hsx +0 -123
  166. package/examples/README.md +0 -48
  167. package/examples/advance/README.md +0 -3
  168. package/examples/advance/advance.hsx +0 -13
  169. package/examples/advance/advance.udl +0 -367
  170. package/examples/cancellable_booking/README.md +0 -3
  171. package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
  172. package/examples/cancellable_booking/cancellable_booking.udl +0 -413
  173. package/examples/captured_payment/README.md +0 -3
  174. package/examples/captured_payment/captured_payment.hsx +0 -17
  175. package/examples/captured_payment/captured_payment.udl +0 -686
  176. package/examples/conditional_disbursement/README.md +0 -3
  177. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
  178. package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
  179. package/examples/credit_facility/README.md +0 -3
  180. package/examples/credit_facility/credit_facility.hsx +0 -24
  181. package/examples/credit_facility/credit_facility.udl +0 -1396
  182. package/examples/held_payment/README.md +0 -3
  183. package/examples/held_payment/held_payment.hsx +0 -13
  184. package/examples/held_payment/held_payment.udl +0 -569
  185. package/examples/instant_transfer/README.md +0 -3
  186. package/examples/instant_transfer/instant_transfer.hsx +0 -16
  187. package/examples/instant_transfer/instant_transfer.udl +0 -376
  188. package/examples/metered/README.md +0 -3
  189. package/examples/metered/metered.hsx +0 -13
  190. package/examples/metered/metered.udl +0 -253
  191. package/examples/pooled_split/README.md +0 -3
  192. package/examples/pooled_split/pooled_split.hsx +0 -15
  193. package/examples/pooled_split/pooled_split.udl +0 -432
  194. package/examples/premium_forward/README.md +0 -3
  195. package/examples/premium_forward/premium_forward.hsx +0 -19
  196. package/examples/premium_forward/premium_forward.udl +0 -604
  197. package/examples/reconciled_payout/README.md +0 -3
  198. package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
  199. package/examples/reconciled_payout/reconciled_payout.udl +0 -312
  200. package/examples/rotating_pool/README.md +0 -3
  201. package/examples/rotating_pool/rotating_pool.hsx +0 -18
  202. package/examples/rotating_pool/rotating_pool.udl +0 -4370
  203. package/examples/scheduled/README.md +0 -3
  204. package/examples/scheduled/scheduled.hsx +0 -12
  205. package/examples/scheduled/scheduled.udl +0 -355
  206. package/examples/security_deposit/README.md +0 -3
  207. package/examples/security_deposit/security_deposit.hsx +0 -21
  208. package/examples/security_deposit/security_deposit.udl +0 -320
  209. package/examples/settlement_batch/README.md +0 -3
  210. package/examples/settlement_batch/settlement_batch.hsx +0 -19
  211. package/examples/settlement_batch/settlement_batch.udl +0 -757
  212. package/examples/swap/README.md +0 -3
  213. package/examples/swap/swap.hsx +0 -19
  214. package/examples/swap/swap.udl +0 -892
  215. package/examples/threshold_pool/README.md +0 -3
  216. package/examples/threshold_pool/threshold_pool.hsx +0 -16
  217. package/examples/threshold_pool/threshold_pool.udl +0 -680
  218. package/examples/weighted_distribution/README.md +0 -3
  219. package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
  220. package/examples/weighted_distribution/weighted_distribution.udl +0 -348
  221. package/skills/hsx/SKILL.md +0 -449
  222. package/src/diagnostics.ts +0 -620
  223. package/src/emit.ts +0 -282
  224. package/src/entry-overrides.ts +0 -428
  225. package/src/ir.ts +0 -113
  226. package/src/limits.ts +0 -22
  227. package/src/lsp/server.ts +0 -460
  228. package/src/modules.ts +0 -452
  229. package/src/typecheck.ts +0 -5515
  230. package/std/SEMANTICS.md +0 -44
  231. package/std/money_flows/advance.hsx +0 -235
  232. package/std/money_flows/cancellable_booking.hsx +0 -402
  233. package/std/money_flows/captured_payment.hsx +0 -220
  234. package/std/money_flows/conditional_disbursement.hsx +0 -226
  235. package/std/money_flows/credit_facility.hsx +0 -214
  236. package/std/money_flows/held_payment.hsx +0 -812
  237. package/std/money_flows/index.hsx +0 -4
  238. package/std/money_flows/instant_transfer.hsx +0 -231
  239. package/std/money_flows/metered.hsx +0 -104
  240. package/std/money_flows/pooled_split.hsx +0 -109
  241. package/std/money_flows/premium_forward.hsx +0 -307
  242. package/std/money_flows/reconciled_payout.hsx +0 -119
  243. package/std/money_flows/rotating_pool.hsx +0 -305
  244. package/std/money_flows/scheduled.hsx +0 -599
  245. package/std/money_flows/security_deposit.hsx +0 -248
  246. package/std/money_flows/settlement_batch.hsx +0 -173
  247. package/std/money_flows/swap.hsx +0 -1192
  248. package/std/money_flows/threshold_pool.hsx +0 -307
  249. package/std/money_flows/weighted_distribution.hsx +0 -237
@@ -1,3 +0,0 @@
1
- # held_payment
2
-
3
- This example applies the `held_payment` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,13 +0,0 @@
1
- program held_payment_example "Held payment example"
2
- import { held_payment } from "std/money_flows"
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] }
@@ -1,569 +0,0 @@
1
- {
2
- "instruments": [
3
- {
4
- "actionOrder": [
5
- "create",
6
- "fund_piece_1",
7
- "confirm_delivery",
8
- "release_on_deadline",
9
- "cancel",
10
- "abandon",
11
- "dispute",
12
- "resume"
13
- ],
14
- "actions": {
15
- "abandon": {
16
- "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.",
17
- "moves": [],
18
- "publicAction": "abandonSale",
19
- "requiresDrainedAccount": {
20
- "path": "refs.escrowAccountId"
21
- },
22
- "steps": [],
23
- "summary": "Abandon the settlement before any money is held"
24
- },
25
- "cancel": {
26
- "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.",
27
- "deadline": {
28
- "field": "releaseDueAt"
29
- },
30
- "effects": {
31
- "moves": [
32
- {
33
- "signature": "moves.transfer.internal",
34
- "source": "moves[0]"
35
- }
36
- ],
37
- "schedules": [
38
- {
39
- "signature": "schedules.deadline",
40
- "source": "deadline"
41
- }
42
- ]
43
- },
44
- "moves": [
45
- {
46
- "bind": {
47
- "amount": {
48
- "from": "instance",
49
- "path": "fields.price"
50
- },
51
- "currency": {
52
- "from": "const",
53
- "value": "SAR"
54
- },
55
- "destinationAccountId": {
56
- "from": "instance",
57
- "path": "fields.buyerAccountId"
58
- },
59
- "metadata.instrumentId": {
60
- "from": "const",
61
- "value": "sale"
62
- },
63
- "metadata.instrumentInstanceId": {
64
- "from": "instance",
65
- "path": "instrumentInstanceId"
66
- },
67
- "metadata.phase": {
68
- "from": "const",
69
- "value": "cancel"
70
- },
71
- "productId": {
72
- "from": "instance",
73
- "path": "productId"
74
- },
75
- "sourceAccountId": {
76
- "from": "instance",
77
- "path": "refs.escrowAccountId"
78
- }
79
- },
80
- "capture": {
81
- "cancelTransferTransferId": "transferId"
82
- },
83
- "key": "transfer",
84
- "operation": "internal_transfer.create"
85
- }
86
- ],
87
- "publicAction": "cancelSale",
88
- "steps": [],
89
- "summary": "Cancel the settlement and start the unwind"
90
- },
91
- "confirm_delivery": {
92
- "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.",
93
- "deadline": {
94
- "field": "releaseDueAt"
95
- },
96
- "effects": {
97
- "decides": [
98
- {
99
- "signature": "decides.tenant_port",
100
- "source": "port"
101
- }
102
- ],
103
- "moves": [
104
- {
105
- "signature": "moves.transfer.internal",
106
- "source": "moves[0]"
107
- }
108
- ],
109
- "schedules": [
110
- {
111
- "signature": "schedules.deadline",
112
- "source": "deadline"
113
- }
114
- ]
115
- },
116
- "moves": [
117
- {
118
- "bind": {
119
- "amount": {
120
- "from": "instance",
121
- "path": "fields.price"
122
- },
123
- "currency": {
124
- "from": "const",
125
- "value": "SAR"
126
- },
127
- "destinationAccountId": {
128
- "from": "instance",
129
- "path": "fields.sellerAccountId"
130
- },
131
- "metadata.instrumentId": {
132
- "from": "const",
133
- "value": "sale"
134
- },
135
- "metadata.instrumentInstanceId": {
136
- "from": "instance",
137
- "path": "instrumentInstanceId"
138
- },
139
- "metadata.phase": {
140
- "from": "const",
141
- "value": "confirm_delivery"
142
- },
143
- "productId": {
144
- "from": "instance",
145
- "path": "productId"
146
- },
147
- "sourceAccountId": {
148
- "from": "instance",
149
- "path": "refs.escrowAccountId"
150
- }
151
- },
152
- "capture": {
153
- "confirmDeliveryTransferTransferId": "transferId"
154
- },
155
- "key": "transfer",
156
- "operation": "internal_transfer.create"
157
- }
158
- ],
159
- "port": {
160
- "allowedParties": [
161
- "payer"
162
- ]
163
- },
164
- "publicAction": "confirmDeliverySale",
165
- "sandboxFailurePoint": "release",
166
- "steps": [],
167
- "summary": "Confirm through confirm_delivery and start the release payout"
168
- },
169
- "create": {
170
- "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.",
171
- "moves": [],
172
- "publicAction": "createSale",
173
- "steps": [
174
- {
175
- "bind": {
176
- "currency": {
177
- "from": "const",
178
- "value": "SAR"
179
- },
180
- "owner.id": {
181
- "from": "instance",
182
- "path": "productId"
183
- },
184
- "owner.type": {
185
- "from": "const",
186
- "value": "product"
187
- },
188
- "productId": {
189
- "from": "instance",
190
- "path": "productId"
191
- },
192
- "role": {
193
- "from": "const",
194
- "value": "product_escrow"
195
- }
196
- },
197
- "capture": {
198
- "escrowAccountId": "accountId"
199
- },
200
- "operation": "account.escrow.provision"
201
- }
202
- ],
203
- "summary": "Create a sale settlement"
204
- },
205
- "dispute": {
206
- "agentDescription": "Freeze a funded sale so neither release nor refund can run until the parties settle the disagreement. No money moves and the whole balance stays put. Only a funded sale disputes.",
207
- "deadline": {
208
- "field": "releaseDueAt"
209
- },
210
- "description": "Freezes funded sale, preserving the entire balance while the parties decide what happens next.",
211
- "effects": {
212
- "schedules": [
213
- {
214
- "signature": "schedules.deadline",
215
- "source": "deadline"
216
- }
217
- ]
218
- },
219
- "moves": [],
220
- "publicAction": "disputeSale",
221
- "steps": [],
222
- "summary": "Dispute a sale settlement"
223
- },
224
- "fund_piece_1": {
225
- "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.",
226
- "effects": {
227
- "moves": [
228
- {
229
- "signature": "moves.collection.pay_in",
230
- "source": "moves[0]"
231
- },
232
- {
233
- "signature": "moves.transfer.internal",
234
- "source": "moves[1]"
235
- }
236
- ]
237
- },
238
- "moves": [
239
- {
240
- "bind": {
241
- "amount": {
242
- "from": "instance",
243
- "path": "fields.price"
244
- },
245
- "currency": {
246
- "from": "const",
247
- "value": "SAR"
248
- },
249
- "destinationAccountId": {
250
- "from": "instance",
251
- "path": "refs.escrowAccountId"
252
- },
253
- "metadata.instrumentId": {
254
- "from": "const",
255
- "value": "sale"
256
- },
257
- "metadata.instrumentInstanceId": {
258
- "from": "instance",
259
- "path": "instrumentInstanceId"
260
- },
261
- "metadata.phase": {
262
- "from": "const",
263
- "value": "fund_piece_1"
264
- },
265
- "productId": {
266
- "from": "instance",
267
- "path": "productId"
268
- },
269
- "sourceAccountId": {
270
- "from": "instance",
271
- "path": "fields.buyerAccountId"
272
- }
273
- },
274
- "capture": {
275
- "fundPiece1TransferTransferId": "transferId"
276
- },
277
- "key": "transfer",
278
- "operation": "internal_transfer.create"
279
- },
280
- {
281
- "bind": {
282
- "amount": {
283
- "from": "instance",
284
- "path": "fields.serviceFeeAmount"
285
- },
286
- "currency": {
287
- "from": "const",
288
- "value": "SAR"
289
- },
290
- "destinationAccountId": {
291
- "from": "instance",
292
- "path": "fields.platformAccountId"
293
- },
294
- "metadata.instrumentId": {
295
- "from": "const",
296
- "value": "sale"
297
- },
298
- "metadata.instrumentInstanceId": {
299
- "from": "instance",
300
- "path": "instrumentInstanceId"
301
- },
302
- "metadata.phase": {
303
- "from": "const",
304
- "value": "fund_piece_1"
305
- },
306
- "productId": {
307
- "from": "instance",
308
- "path": "productId"
309
- },
310
- "sourceAccountId": {
311
- "from": "instance",
312
- "path": "fields.buyerAccountId"
313
- }
314
- },
315
- "capture": {
316
- "fundPiece1ServiceFeeTransferId": "transferId"
317
- },
318
- "key": "service_fee",
319
- "operation": "internal_transfer.create"
320
- }
321
- ],
322
- "publicAction": "fundPiece1Sale",
323
- "sandboxFailurePoint": "funding",
324
- "steps": [],
325
- "summary": "Fund piece 1 of the held amount into escrow"
326
- },
327
- "release_on_deadline": {
328
- "due": {
329
- "field": "releaseDueAt"
330
- },
331
- "effects": {
332
- "moves": [
333
- {
334
- "signature": "moves.transfer.internal",
335
- "source": "moves[0]"
336
- }
337
- ],
338
- "schedules": [
339
- {
340
- "signature": "schedules.due",
341
- "source": "due"
342
- }
343
- ]
344
- },
345
- "moves": [
346
- {
347
- "bind": {
348
- "amount": {
349
- "from": "instance",
350
- "path": "fields.price"
351
- },
352
- "currency": {
353
- "from": "const",
354
- "value": "SAR"
355
- },
356
- "destinationAccountId": {
357
- "from": "instance",
358
- "path": "fields.sellerAccountId"
359
- },
360
- "metadata.instrumentId": {
361
- "from": "const",
362
- "value": "sale"
363
- },
364
- "metadata.instrumentInstanceId": {
365
- "from": "instance",
366
- "path": "instrumentInstanceId"
367
- },
368
- "metadata.phase": {
369
- "from": "const",
370
- "value": "release_on_deadline"
371
- },
372
- "productId": {
373
- "from": "instance",
374
- "path": "productId"
375
- },
376
- "sourceAccountId": {
377
- "from": "instance",
378
- "path": "refs.escrowAccountId"
379
- }
380
- },
381
- "capture": {
382
- "releaseOnDeadlineTransferTransferId": "transferId"
383
- },
384
- "key": "transfer",
385
- "operation": "internal_transfer.create"
386
- }
387
- ],
388
- "steps": [],
389
- "summary": "Release to the seller when releaseDueAt arrives undecided"
390
- },
391
- "resume": {
392
- "agentDescription": "Lift the dispute hold and put the sale back where it was, funded and ready to release. No money moves and the balance was never touched. Only a disputed sale resumes. Use this when the parties settled without a refund.",
393
- "description": "Ends the dispute hold without moving money and returns the fully funded sale to its first milestone.",
394
- "moves": [],
395
- "publicAction": "resumeSale",
396
- "steps": [],
397
- "summary": "Resume a sale settlement"
398
- }
399
- },
400
- "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.",
401
- "description": "Held payment: the buyer funds price into this settlement's own escrow; buyer confirms through confirm_delivery to release",
402
- "feeRules": [
403
- {
404
- "amountField": "serviceFeeAmount",
405
- "baseField": "price",
406
- "bearerField": "buyerAccountId",
407
- "position": "on_top",
408
- "rule": {
409
- "bps": 100,
410
- "kind": "bps"
411
- }
412
- }
413
- ],
414
- "fields": {
415
- "buyerAccountId": {
416
- "description": "The buyer account",
417
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
418
- "type": "string",
419
- "x-hyperscale-reference-filter": {
420
- "column": "role",
421
- "values": [
422
- "customer_balance"
423
- ]
424
- }
425
- },
426
- "currency": {
427
- "description": "ISO 4217 currency code",
428
- "maxLength": 3,
429
- "minLength": 3,
430
- "pattern": "^[A-Z]{3}$",
431
- "type": "string"
432
- },
433
- "platformAccountId": {
434
- "description": "The product fee collection account",
435
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
436
- "type": "string",
437
- "x-hyperscale-fee-collection-port": true,
438
- "x-hyperscale-reference-filter": {
439
- "column": "role",
440
- "values": [
441
- "customer_balance",
442
- "product_revenue"
443
- ]
444
- }
445
- },
446
- "price": {
447
- "description": "The held amount in SAR minor units, funded and paid out whole",
448
- "pattern": "^[1-9][0-9]{0,17}$",
449
- "type": "string",
450
- "x-hyperscale-currency": "SAR"
451
- },
452
- "releaseDueAt": {
453
- "description": "The date an undecided hold releases to the seller on; confirm_delivery and cancellation decide only before it",
454
- "format": "hyperscale-date-time",
455
- "type": "string"
456
- },
457
- "sellerAccountId": {
458
- "description": "The seller account",
459
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
460
- "type": "string",
461
- "x-hyperscale-reference-filter": {
462
- "column": "role",
463
- "values": [
464
- "customer_balance"
465
- ]
466
- }
467
- },
468
- "serviceFeeAmount": {
469
- "description": "Machine-owned 1% service fee computed from price; charged on top at funding",
470
- "pattern": "^[1-9][0-9]{0,17}$",
471
- "type": "string",
472
- "x-hyperscale-currency": "SAR"
473
- }
474
- },
475
- "id": "sale",
476
- "idPrefix": "sale",
477
- "lifecycle": {
478
- "initial": "created",
479
- "states": [
480
- "created",
481
- "funded",
482
- "disputed",
483
- "released",
484
- "cancelled",
485
- "abandoned"
486
- ],
487
- "transitions": {
488
- "abandon": {
489
- "from": [
490
- "created"
491
- ],
492
- "to": "abandoned"
493
- },
494
- "cancel": {
495
- "from": [
496
- "funded"
497
- ],
498
- "to": "cancelled"
499
- },
500
- "confirm_delivery": {
501
- "from": [
502
- "funded"
503
- ],
504
- "to": "released"
505
- },
506
- "dispute": {
507
- "from": [
508
- "funded"
509
- ],
510
- "to": "disputed"
511
- },
512
- "fund_piece_1": {
513
- "from": [
514
- "created"
515
- ],
516
- "to": "funded"
517
- },
518
- "release_on_deadline": {
519
- "from": [
520
- "funded"
521
- ],
522
- "to": "released"
523
- },
524
- "resume": {
525
- "from": [
526
- "disputed"
527
- ],
528
- "to": "funded"
529
- }
530
- }
531
- },
532
- "parties": {
533
- "beneficiary": "sellerAccountId",
534
- "payer": "buyerAccountId"
535
- },
536
- "required": [
537
- "buyerAccountId",
538
- "sellerAccountId",
539
- "platformAccountId",
540
- "price",
541
- "releaseDueAt",
542
- "currency"
543
- ],
544
- "summary": "Escrow-held payment from buyer to seller",
545
- "templateBinding": {
546
- "id": "held_payment",
547
- "parameters": {
548
- "cancelChargeBps": false,
549
- "cancelOfferLife": false,
550
- "derivedAmount": false,
551
- "idPrefixOverride": false,
552
- "privateActions": false,
553
- "reference": false,
554
- "releaseAction": false,
555
- "releaseTo": false,
556
- "upstream": false,
557
- "wholeAmount": false,
558
- "wholeFee": false
559
- }
560
- },
561
- "title": "Sale"
562
- }
563
- ],
564
- "product": "held_payment_example",
565
- "subjects": [],
566
- "title": "Held payment example",
567
- "udl": 1,
568
- "version": 1
569
- }
@@ -1,3 +0,0 @@
1
- # instant_transfer
2
-
3
- This example applies the `instant_transfer` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,16 +0,0 @@
1
- program instant_transfer_example "Instant transfer example"
2
- import { instant_transfer } from "std/money_flows"
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
- }