@hyperscale0/hsx 4.0.1 → 4.1.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/std/travel.hsx CHANGED
@@ -10,7 +10,7 @@ instrument package(price: money, supplier_cost: money, departure: date) {
10
10
  action close { from: published, to: closed, actor: clock, due: { at: self.departure } }
11
11
  }
12
12
 
13
- instrument booking(package: ref<travel.package>, buyer: party, supplier: party, approval: approval = programOperator, cover: ref<insurance.cover>, deposit: percent = 30%, balance_before: duration = 14d, confirm_within: duration = 24h, tax: percent = 15%, early_before: duration = 30d, middle_before: duration = 15d, middle_penalty: percent = 10%, late_penalty: percent = 30%) {
13
+ instrument booking(package: ref<travel.package>, buyer: party, supplier: party, operator: party = programOperator, cover: ref<insurance.cover>, deposit: percent = 30%, balance_before: duration = 14d, confirm_within: duration = 24h, tax: percent = 15%, early_before: duration = 30d, middle_before: duration = 15d, middle_penalty: percent = 10%, late_penalty: percent = 30%) {
14
14
  constraints { early_before: greater_than(middle_before) }
15
15
  summary: "A deposited booking with three cancellation bands and confirmation."
16
16
  fields {
@@ -44,9 +44,8 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
44
44
  moves self.balance from buyer to self.held
45
45
  }
46
46
  action confirm {
47
- from: paid, to: completed
47
+ from: paid, to: completed, actor: { party: operator }
48
48
  due: { at: self.package.departure }, deadline: { at: self.confirmBy }
49
- requires approval by approval protectedRequest self differentFromInitiator true
50
49
  moves self.supplierCost from self.held to supplier
51
50
  moves self.tax from self.held to programTax
52
51
  moves self.operatorNet from self.held to programOperator
@@ -56,11 +55,11 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
56
55
  moves self.price from self.held to buyer
57
56
  }
58
57
  action cancel_early {
59
- from: [deposit_paid, paid], to: cancelled, deadline: { at: self.earlyAt }
58
+ from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, deadline: { at: self.earlyAt }
60
59
  moves self.held.balance from self.held to buyer
61
60
  }
62
61
  action cancel_middle {
63
- from: [deposit_paid, paid], to: cancelled, due: { at: self.earlyAt }, deadline: { at: self.lateAt }
62
+ from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, due: { at: self.earlyAt }, deadline: { at: self.lateAt }
64
63
  calculate: [
65
64
  { target: refund, op: "subtract", base: { field: self.held.balance }, subtract: [{ field: self.deposit }] }
66
65
  { target: retainedMargin, op: "subtract", base: { field: self.deposit }, subtract: [{ field: self.middlePenalty }] }
@@ -73,7 +72,7 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
73
72
  moves self.retainedNet from self.held to programOperator
74
73
  }
75
74
  action cancel_late {
76
- from: [deposit_paid, paid], to: cancelled, actor: caller, due: { at: self.lateAt }
75
+ from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, due: { at: self.lateAt }
77
76
  calculate: [
78
77
  { target: retainedMargin, op: "subtract", base: { field: self.held.balance }, subtract: [{ field: self.latePenalty }] }
79
78
  { target: retainedTax, op: "rate", base: { field: self.retainedMargin }, bps: { literal: tax }, rounding: "floor" }
package/std/wallet.hsx CHANGED
@@ -30,12 +30,12 @@ instrument spend(wallet: ref<wallet.balance>, payee: party) {
30
30
  requires self.amount <= self.wallet.spendLimit
31
31
  }
32
32
  action reserve {
33
- from: pending, to: reserved
33
+ from: pending, to: reserved, actor: { party: payee }
34
34
  requires self.wallet in [active]
35
35
  deadline: { at: self.expiresAt }
36
36
  moves reserve self.amount from self.wallet.held to payee capture "reservation"
37
37
  }
38
- action pay { from: reserved, to: paid, moves post self.reservation }
39
- action cancel { from: reserved, to: cancelled, moves void self.reservation }
38
+ action pay { from: reserved, to: paid, actor: { party: payee }, moves post self.reservation }
39
+ action cancel { from: reserved, to: cancelled, actor: { party: payee }, moves void self.reservation }
40
40
  action expire { from: reserved, to: expired, actor: clock, due: { at: self.expiresAt }, moves void self.reservation }
41
41
  }
package/std/approvals.hsx DELETED
@@ -1,17 +0,0 @@
1
- header approvals
2
-
3
- instrument decision(for: ref, approved_by: approval, action: text = "approve", protected_request: text = "self.target") {
4
- summary: "One authenticated decision bound to an immutable target and expiry."
5
- fields { target: ref<for>, expiresAt: date }
6
- lifecycle { states: [pending, approved, declined, expired], initial: pending }
7
- action create {}
8
- action approve {
9
- from: pending, to: approved, actor: { party: approved_by }, deadline: { at: self.expiresAt }
10
- approval: { protectedRequest: protected_request, target: self.target, action: action, party: approved_by, expires: self.expiresAt, input: "material", decision: "approved" }
11
- }
12
- action decline {
13
- from: pending, to: declined, actor: { party: approved_by }, deadline: { at: self.expiresAt }
14
- approval: { protectedRequest: protected_request, target: self.target, action: action, party: approved_by, expires: self.expiresAt, input: "material", decision: "declined" }
15
- }
16
- action expire { from: pending, to: expired, actor: clock, due: { at: self.expiresAt } }
17
- }