@hyperscale0/hsx 5.4.1 → 5.5.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 CHANGED
@@ -1,3 +1,13 @@
1
+ # HSX 5.5.0
2
+
3
+ Std money moves declare posted economic purposes. Fee legs and recipient choices
4
+ retain separate purposes. Paid earnings and payout refunds retain their original
5
+ transfer identity. Supports UDL pass-through money.
6
+
7
+ # HSX 5.4.2
8
+
9
+ Follows UDL 4.6.0: an action's `availability` carries `blockers` with a code and a plain reason instead of one code; an adapter that is not set up reads as `setup_required`. Tests updated. No compiler behaviour changed.
10
+
1
11
  # HSX 5.4.1
2
12
 
3
13
  Documentation only. The newcomer path now starts from a rental deposit
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAeL,KAAK,WAAW,EAOjB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAIL,KAAK,UAAU,EAKf,KAAK,IAAI,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CACpC;AACD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AACD,MAAM,WAAW,oBAAoB;IAC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AAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AACD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;CAClE;AACD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,SAAS,CAAC,EAAE;QACV,QAAQ,EAAE,WAAW,CAAC;QACtB,YAAY,EAAE,eAAe,CAAC;QAC9B,SAAS,EAAE,qBAAqB,EAAE,CAAC;KACpC,CAAC;CACH;AAqTD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAmrGf"}
@@ -1677,6 +1677,77 @@ export function compile(source, options = {}) {
1677
1677
  const key = parts.has("key")
1678
1678
  ? String(data(parts.get("key")))
1679
1679
  : `move${index + 1}`;
1680
+ const lowerEconomics = (economicsExpr) => {
1681
+ if (economicsExpr) {
1682
+ const resolved = resolve(economicsExpr);
1683
+ if (resolved.kind === "name" &&
1684
+ resolved.value === "unclassified")
1685
+ return undefined;
1686
+ const choices = entries(asBlock(resolve(economicsExpr)));
1687
+ if (choices.has("recipient")) {
1688
+ for (const term of choices.keys())
1689
+ if (!["recipient", "company", "participant"].includes(term))
1690
+ fail(economicsExpr, `unknown economics choice ${term}`, "use recipient, company and participant");
1691
+ const recipient = String(data(choices.get("recipient")));
1692
+ if (!isParty(recipient) ||
1693
+ !choices.has("company") ||
1694
+ !choices.has("participant"))
1695
+ fail(economicsExpr, "economics choice needs a bound recipient and both branches", "declare recipient, company and participant");
1696
+ const company = recipient === "operator" ||
1697
+ recipient === "programOperator" ||
1698
+ document.parties[recipient]?.role === "program_operator";
1699
+ return lowerEconomics(choices.get(company ? "company" : "participant"));
1700
+ }
1701
+ }
1702
+ const economicsParts = economicsExpr
1703
+ ? entries(asBlock(resolve(economicsExpr)))
1704
+ : undefined;
1705
+ if (economicsParts) {
1706
+ for (const term of economicsParts.keys())
1707
+ if (!["purpose", "sourceParty", "reversalOf"].includes(term))
1708
+ fail(economicsExpr, `unknown economics term ${term}`, "use purpose, sourceParty or reversalOf");
1709
+ }
1710
+ const purpose = economicsParts?.get("purpose");
1711
+ const sourceParty = economicsParts?.get("sourceParty");
1712
+ if (economicsParts && (!purpose || !sourceParty))
1713
+ fail(economicsExpr, "economics needs purpose and sourceParty", "declare both economics fields");
1714
+ const purposeName = purpose ? String(data(purpose)) : undefined;
1715
+ if (purposeName &&
1716
+ ![
1717
+ "earning",
1718
+ "principal",
1719
+ "participant_payout",
1720
+ "internal",
1721
+ "prepaid_credit",
1722
+ "pass_through",
1723
+ ].includes(purposeName))
1724
+ fail(purpose, `unknown economic purpose ${purposeName}`, "choose a declared economic purpose");
1725
+ const sourcePartyName = sourceParty
1726
+ ? String(data(sourceParty))
1727
+ : undefined;
1728
+ if (sourcePartyName && !isParty(sourcePartyName))
1729
+ fail(sourceParty, `unknown source party ${sourcePartyName}`, "bind an authored party");
1730
+ return economicsParts
1731
+ ? {
1732
+ purpose: purposeName,
1733
+ sourceParty: sourcePartyName,
1734
+ ...(economicsParts.has("reversalOf")
1735
+ ? {
1736
+ reversalOf: path(economicsParts.get("reversalOf")),
1737
+ }
1738
+ : {}),
1739
+ }
1740
+ : undefined;
1741
+ };
1742
+ const economicsExpr = parts.get("economics");
1743
+ const feeEconomics = parts.has("fee") && economicsExpr
1744
+ ? entries(asBlock(resolve(economicsExpr)))
1745
+ : undefined;
1746
+ if (feeEconomics)
1747
+ for (const term of feeEconomics.keys())
1748
+ if (!["payee", "fee", "tax"].includes(term))
1749
+ fail(economicsExpr, `unknown fee economics leg ${term}`, "declare payee, fee or tax economics separately");
1750
+ const economics = lowerEconomics(feeEconomics ? feeEconomics.get("payee") : economicsExpr);
1680
1751
  if (op === "internal_transfer.create" ||
1681
1752
  op === "internal_transfer.reserve") {
1682
1753
  const amount = parts.get("amount"), from = parts.get("from"), to = parts.get("to");
@@ -1738,6 +1809,7 @@ export function compile(source, options = {}) {
1738
1809
  a.moves.push({
1739
1810
  key: `${key}_${index + 1}`,
1740
1811
  operation: "internal_transfer.create",
1812
+ ...(economics ? { economics } : {}),
1741
1813
  amount: piece,
1742
1814
  from: path(from),
1743
1815
  to: `party.${recipient.value}`,
@@ -1752,6 +1824,7 @@ export function compile(source, options = {}) {
1752
1824
  const transfer = {
1753
1825
  key,
1754
1826
  operation: op,
1827
+ ...(economics ? { economics } : {}),
1755
1828
  ...(parts.has("capture")
1756
1829
  ? { capture: String(data(parts.get("capture"))) }
1757
1830
  : {}),
@@ -1851,6 +1924,9 @@ export function compile(source, options = {}) {
1851
1924
  });
1852
1925
  a.moves.push({
1853
1926
  key: key + "Fee",
1927
+ ...(feeEconomics?.has("fee")
1928
+ ? { economics: lowerEconomics(feeEconomics.get("fee")) }
1929
+ : {}),
1854
1930
  operation: "internal_transfer.create",
1855
1931
  amount: charge,
1856
1932
  from: transfer.from,
@@ -1859,6 +1935,9 @@ export function compile(source, options = {}) {
1859
1935
  if (vat)
1860
1936
  a.moves.push({
1861
1937
  key: key + "Tax",
1938
+ ...(feeEconomics?.has("tax")
1939
+ ? { economics: lowerEconomics(feeEconomics.get("tax")) }
1940
+ : {}),
1862
1941
  operation: "internal_transfer.create",
1863
1942
  amount: vat,
1864
1943
  from: transfer.from,
@@ -1871,6 +1950,7 @@ export function compile(source, options = {}) {
1871
1950
  a.moves.push({
1872
1951
  key,
1873
1952
  operation: op,
1953
+ ...(economics ? { economics } : {}),
1874
1954
  transfer: path(parts.get("transfer")),
1875
1955
  ...(parts.has("capture")
1876
1956
  ? { capture: String(data(parts.get("capture"))) }