@wowok/skills 1.3.3 → 2.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.
@@ -124,15 +124,15 @@ graph TD
124
124
  RC["Return Complete<br/>From Receipt: Dual-Sig (threshold=2)<br/>From Non-receipt: Merchant only (threshold=1)"]:::dualsig
125
125
 
126
126
  START --> OC
127
- START --> OR
127
+ OC --> OR
128
128
  OC --> SH
129
129
  SH --> DC
130
- SH --> WO
130
+ DC --> WO
131
131
  SH --> OC2
132
132
  SH --> LO
133
133
 
134
134
  DC --> OC3
135
- DC --> NR
135
+ SH --> NR
136
136
 
137
137
  DC --> RR
138
138
  RR --> RF
@@ -151,6 +151,8 @@ graph TD
151
151
  - **Lost Node**: 20000 compensation
152
152
  - **Shipping Timeout (>2 days)**: 20000 compensation
153
153
 
154
+ > **⚠️ Units Note (BalanceType)**: The reward/compensation amounts above (and the `amount.value` numbers in Step 13) are **raw BalanceType values in the SMALLEST unit** of WOW. WOW has 9 decimals (1 WOW = 10⁹ smallest units), so 10000 = 0.00001 WOW and 20000 = 0.00002 WOW — far below gas cost. Treat them as **symbolic/test values** that keep the flow executable on any balance; for production amounts use either larger smallest-unit values (e.g. `20000000000` = 20 WOW) or the display format (e.g. `"20WOW"`), both accepted by `BalanceTypeSchema`. Note the different semantics of `"sharing": 10000, "mode": "Rate"` in the order_allocators (Step 10): that is **basis points (100.00%)**, not a WOW amount.
155
+
154
156
  ***
155
157
 
156
158
  ## Part 1: Build Order and Rationale
@@ -282,7 +284,7 @@ Understanding the correct order for creating WoWok objects is crucial for a succ
282
284
  | 3 | **Guards** | Service Name | Guards must verify that orders belong to the correct Service. They query Service name and Progress state. |
283
285
  | 4 | **Machine** | Permission, Guards | Machine requires guards for node verification. Guards need Service name which is now available. |
284
286
  | 5 | **Machine Binding** | Service, Machine | Bind Machine to Service before publishing. Once published, Machine cannot be bound. |
285
- | 6 | **Arbitration** | None | Arbitration is independent but needs to be bound to Service. Create before Service update. |
287
+ | 6 | **Arbitration** | Own Permission | Arbitration is independent but needs to be bound to Service. ⚠️ It MUST use a DIFFERENT Permission than the Service — the Service contract asserts `arbitration.permission != service.permission` when binding. Create before Service update. |
286
288
  | 7 | **Service (Update)** | Guards, Arb, Machine | Update Service with order\_allocators, sales, arbitrations, machine binding. Then publish. |
287
289
  | 8 | **Empty Reward** | None | Create empty reward object first. This object is referenced by reward guards for double-claim protection. |
288
290
  | 9 | **Reward Guards** | Reward (by name) | Create reward guards that reference the reward object by name. Guards verify order node + no prior claim. |
@@ -323,9 +325,9 @@ Phase 2b: Treasury Creation
323
325
  Phase 3: Guard Creation (Machine Guards)
324
326
  └── 3. Create Machine Guards (4 guards)
325
327
  ├── machine_merkle_root_v2 (verify string length = 66)
326
- ├── machine_service_order_v2 (verify order service + node)
327
- ├── machine_time_10d_v2 (time >= 10 days)
328
- └── machine_time_2d_v2 (time >= 2 days)
328
+ ├── machine_service_order_v2 (verify order service + node — illustrative variant, not wired into the Machine; see Step 4 note)
329
+ ├── machine_time_10d_v2 (on-chain time >= 10 days on current node)
330
+ └── machine_time_2d_v2 (on-chain time >= 2 days — illustrative variant, not wired into the Machine; see Step 4 note)
329
331
 
330
332
  Phase 3b: Service Guards
331
333
  └── 3b. Create Service Guards (2 guards)
@@ -680,7 +682,7 @@ Create Guards using the Service address. Guards verify order state and service o
680
682
  3. **Project binding** — `logic_equal[query("order.service", obj=order), identifier[2]]`: the submitted Order belongs to `three_body_signature_service_v2`. Suppresses R-C3-05 (cross-project bypass).
681
683
 
682
684
  **Generating the Proof (provider side, before submitting to the forward):**
683
- ```json
685
+ ```text
684
686
  // SDK call: messenger.submitChainProof(env, peerAddress, description?)
685
687
  // - about_address is set to peerAddress (the customer's address)
686
688
  // - pass the order_id in description to associate the Proof with the order
@@ -695,6 +697,8 @@ Create Guards using the Service address. Guards verify order state and service o
695
697
 
696
698
  **Guard 2: machine_time_10d_v2** - Verify 10-day timeout (864000000 ms)
697
699
 
700
+ > **Secure time-lock pattern**: identifier 0 is the **Progress object submitted at runtime (Address)** — the Guard reads its current-node entry timestamp on-chain via `query("progress.current_time")` (GUARDQUERY id 1272). NEVER declare the start time as a caller-submitted U64: a submitter could pass 0 and bypass the lock entirely. The threshold stays a creation-time constant (identifier 1).
701
+
698
702
  ```json
699
703
  {
700
704
  "tool": "onchain_operations",
@@ -705,9 +709,9 @@ Create Guards using the Service address. Guards verify order state and service o
705
709
  "name": "machine_time_10d_v2",
706
710
  "replaceExistName": true
707
711
  },
708
- "description": "Verify time elapsed >= 10 days (864000000 ms)",
712
+ "description": "Verify time elapsed on the current node >= 10 days (864000000 ms): Clock - progress.current_time >= 864000000. The Progress object is submitted at runtime (Address identifier 0); the start time is read on-chain via query 1272, so the caller cannot forge it.",
709
713
  "table": [
710
- {"identifier": 0, "b_submission": true, "value_type": "U64"},
714
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "progress_id"},
711
715
  {"identifier": 1, "b_submission": false, "value_type": "U64", "value": "864000000"}
712
716
  ],
713
717
  "root": {
@@ -717,7 +721,7 @@ Create Guards using the Service address. Guards verify order state and service o
717
721
  "type": "calc_number_subtract",
718
722
  "nodes": [
719
723
  {"type": "context", "context": "Clock"},
720
- {"type": "identifier", "identifier": 0}
724
+ {"type": "query", "query": "progress.current_time", "object": {"identifier": 0}, "parameters": []}
721
725
  ]
722
726
  },
723
727
  {"type": "identifier", "identifier": 1}
@@ -745,9 +749,9 @@ Create Guards using the Service address. Guards verify order state and service o
745
749
  "name": "machine_time_2d_v2",
746
750
  "replaceExistName": true
747
751
  },
748
- "description": "Verify time elapsed >= 2 days (172800000 ms)",
752
+ "description": "Verify time elapsed on the current node >= 2 days (172800000 ms): Clock - progress.current_time >= 172800000. The Progress object is submitted at runtime (Address identifier 0); the start time is read on-chain via query 1272, so the caller cannot forge it.",
749
753
  "table": [
750
- {"identifier": 0, "b_submission": true, "value_type": "U64"},
754
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "progress_id"},
751
755
  {"identifier": 1, "b_submission": false, "value_type": "U64", "value": "172800000"}
752
756
  ],
753
757
  "root": {
@@ -757,7 +761,7 @@ Create Guards using the Service address. Guards verify order state and service o
757
761
  "type": "calc_number_subtract",
758
762
  "nodes": [
759
763
  {"type": "context", "context": "Clock"},
760
- {"type": "identifier", "identifier": 0}
764
+ {"type": "query", "query": "progress.current_time", "object": {"identifier": 0}, "parameters": []}
761
765
  ]
762
766
  },
763
767
  {"type": "identifier", "identifier": 1}
@@ -773,6 +777,8 @@ Create Guards using the Service address. Guards verify order state and service o
773
777
  }
774
778
  ```
775
779
 
780
+ > **⚠️ Not wired into this Machine**: `machine_time_2d_v2` (and `machine_service_order_v2` below) are **illustrative/optional variants — no forward in `myshop_advanced_machine_v2` references them**. The "Shipping Timeout (>2 days) → 20000 compensation" path promised in [Reward Compensation](#reward-compensation) is NOT a Machine transition: the order must **remain at the Shipping node** for the claim to pass, so the 2-day condition is enforced inside the `reward_shipping_timeout_v2` Guard itself (Step 12, same Clock − `progress.current_time` pattern), not by a forward Guard. Keep these Guards for reference or adapt them in your own workflow; this example's flow does not depend on them.
781
+
776
782
  ***
777
783
 
778
784
  **Guard 4: service_merchant_win_v2** - Verify order at merchant win nodes AND order belongs to this service
@@ -1403,7 +1409,8 @@ Create Machine with all nodes and guards in a single operation.
1403
1409
  > {
1404
1410
  > "tool": "machineNode2file",
1405
1411
  > "data": {
1406
- > "object": "myshop_advanced_machine_v2",
1412
+ > "machine": "myshop_advanced_machine_v2",
1413
+ > "file_path": ".trae/tmp/myshop_machine_export.json",
1407
1414
  > "format": "json"
1408
1415
  > }
1409
1416
  > }
@@ -1425,7 +1432,8 @@ Machine must be published before binding to Service.
1425
1432
  "env": {
1426
1433
  "account": "myshop_merchant",
1427
1434
  "network": "mainnet",
1428
- "no_cache": true
1435
+ "no_cache": true,
1436
+ "confirmed": true
1429
1437
  }
1430
1438
  }
1431
1439
  }
@@ -1482,7 +1490,36 @@ Create an Arbitration object as the final on-chain mechanism for protecting user
1482
1490
 
1483
1491
  **IMPORTANT**: Arbitration `voting_guard` must use object format with `op` and `guards` array.
1484
1492
 
1485
- **Prompt**: Create arbitration object "myshop\_arbitration\_v2".
1493
+ #### Step 9.1: Create an Independent Permission for Arbitration
1494
+
1495
+ > **WHY a separate Permission?** The Service contract (`service.move` → `arbitration_add_imp`) asserts `arbitration.permission != self.permission` when an Arbitration is bound to a Service. If the Arbitration shared the Service's Permission (`myshop_perm_v2`), the binding in Step 10 would abort with `E_ARBITRATION_PERMISSION_CONFLICT`. Create a dedicated Permission `myshop_arb_perm_v2` first.
1496
+
1497
+ **Prompt**: Create permission object "myshop\_arb\_perm\_v2".
1498
+
1499
+ ```json
1500
+ {
1501
+ "tool": "onchain_operations",
1502
+ "data": {
1503
+ "operation_type": "permission",
1504
+ "data": {
1505
+ "object": {
1506
+ "name": "myshop_arb_perm_v2",
1507
+ "replaceExistName": true
1508
+ },
1509
+ "description": "Independent Permission for the MyShop Arbitration object. MUST differ from the Service Permission (myshop_perm_v2) — the Service contract asserts arbitration.permission != service.permission on binding."
1510
+ },
1511
+ "env": {
1512
+ "account": "myshop_merchant",
1513
+ "network": "mainnet",
1514
+ "no_cache": true
1515
+ }
1516
+ }
1517
+ }
1518
+ ```
1519
+
1520
+ #### Step 9.2: Create the Arbitration Object
1521
+
1522
+ **Prompt**: Create arbitration object "myshop\_arbitration\_v2" with permission "myshop\_arb\_perm\_v2".
1486
1523
 
1487
1524
  ```json
1488
1525
  {
@@ -1493,7 +1530,7 @@ Create an Arbitration object as the final on-chain mechanism for protecting user
1493
1530
  "object": {
1494
1531
  "name": "myshop_arbitration_v2",
1495
1532
  "replaceExistName": true,
1496
- "permission": "myshop_perm_v2"
1533
+ "permission": "myshop_arb_perm_v2"
1497
1534
  },
1498
1535
  "description": "Arbitration for MyShop Advanced - Final dispute resolution mechanism",
1499
1536
  "voting_guard": {
@@ -1526,14 +1563,14 @@ Create an Arbitration object as the final on-chain mechanism for protecting user
1526
1563
 
1527
1564
  Configure order_allocators to define fund distribution rules, then publish the Service.
1528
1565
 
1529
- > **Pre-Publish Verification (Mandatory)**: Before publishing the Service, verify all bindings are correct: Machine, Arbitration, Rewards, and order_allocators. Once published, all bindings become immutable. Use `query_toolkit` to confirm the Service state:
1566
+ > **Pre-Publish Verification (Mandatory)**: Before publishing the Service, verify all bindings are correct: Machine, Arbitration, and order_allocators. Once published, the Machine and order_allocators become permanently immutable (L1-locked). Use `query_toolkit` to confirm the Service state:
1530
1567
  >
1531
1568
  > ```json
1532
1569
  > {
1533
1570
  > "tool": "query_toolkit",
1534
1571
  > "data": {
1535
- > "query_type": "service",
1536
- > "object": "three_body_signature_service_v2",
1572
+ > "query_type": "onchain_objects",
1573
+ > "objects": ["three_body_signature_service_v2"],
1537
1574
  > "network": "mainnet",
1538
1575
  > "no_cache": true
1539
1576
  > }
@@ -1596,16 +1633,13 @@ Configure order_allocators to define fund distribution rules, then publish the S
1596
1633
  "op": "add",
1597
1634
  "objects": ["myshop_arbitration_v2"]
1598
1635
  },
1599
- "rewards": {
1600
- "op": "add",
1601
- "objects": ["myshop_reward_v2"]
1602
- },
1603
1636
  "publish": true
1604
1637
  },
1605
1638
  "env": {
1606
1639
  "account": "myshop_merchant",
1607
1640
  "network": "mainnet",
1608
- "no_cache": true
1641
+ "no_cache": true,
1642
+ "confirmed": true
1609
1643
  }
1610
1644
  }
1611
1645
  }
@@ -1690,11 +1724,40 @@ Create an empty reward object first. This object will be referenced by reward gu
1690
1724
 
1691
1725
  ***
1692
1726
 
1727
+ ### Step 11b: Bind Reward to Service (Post-Publish)
1728
+
1729
+ The Reward object only exists now, so the `rewards` binding is done here — deliberately AFTER publish. `rewards add` is an **L3 operation** (remains mutable after publish; only remove/clear requires pause + lock), unlike `machine` and `order_allocators` which are L1-locked at publish. This ordering also avoids referencing a not-yet-created object during the Step 10 publish call.
1730
+
1731
+ **Prompt**: Add reward "myshop\_reward\_v2" to service "three\_body\_signature\_service\_v2".
1732
+
1733
+ ```json
1734
+ {
1735
+ "tool": "onchain_operations",
1736
+ "data": {
1737
+ "operation_type": "service",
1738
+ "data": {
1739
+ "object": "three_body_signature_service_v2",
1740
+ "rewards": {
1741
+ "op": "add",
1742
+ "objects": ["myshop_reward_v2"]
1743
+ }
1744
+ },
1745
+ "env": {
1746
+ "account": "myshop_merchant",
1747
+ "network": "mainnet",
1748
+ "no_cache": true
1749
+ }
1750
+ }
1751
+ }
1752
+ ```
1753
+
1754
+ ***
1755
+
1693
1756
  ### Step 12: Create Reward Guards (Optional)
1694
1757
 
1695
1758
  Create guards for reward verification with double-claim protection:
1696
1759
 
1697
- > **Note on `query_reward_record_exists`**: The guard uses `query_reward_record_exists` with `where.storeFromId` to prevent double-claiming. The MCP tool automatically generates an internal identifier (identifier 4, type VecU8) for this query's parameters. You only need to define identifiers 0–3 in the table; the tool handles the rest.
1760
+ > **Note on `query_reward_record_exists`**: The guard uses `query_reward_record_exists` with `where.storeFromId` to prevent double-claiming. The SDK automatically appends an internal table entry (type VecU8, using the **next free identifier**) for this query's parameters you only define the business identifiers in the table (0–3 for Guards 7/8; 0–5 for Guard 9, which adds a time condition); the tool handles the rest.
1698
1761
 
1699
1762
  | # | Guard Name | Purpose | Reward Amount |
1700
1763
  |---|------------|---------|---------------|
@@ -1830,6 +1893,10 @@ Create guards for reward verification with double-claim protection:
1830
1893
 
1831
1894
  **Guard 9: reward_shipping_timeout_v2**
1832
1895
 
1896
+ > **Time condition included**: unlike Guards 7/8, this Guard ALSO verifies the order has been stuck at the Shipping node for ≥ 2 days (172800000 ms) — otherwise the customer could claim "timeout compensation" immediately after shipping. It uses the same secure pattern as Guard 2/3: the Progress object is submitted at runtime (Address identifier 4) and the start time is read on-chain via `query("progress.current_time")` (GUARDQUERY id 1272).
1897
+ >
1898
+ > **Claim submission contract**: claiming via this Guard requires TWO submissions — identifier 0 = Order address (as in Guards 7/8) AND identifier 4 = the order's Progress object address (e.g. `myshop_progress_v2`).
1899
+
1833
1900
  ```json
1834
1901
  {
1835
1902
  "tool": "onchain_operations",
@@ -1840,12 +1907,14 @@ Create guards for reward verification with double-claim protection:
1840
1907
  "name": "reward_shipping_timeout_v2",
1841
1908
  "replaceExistName": true
1842
1909
  },
1843
- "description": "Verify order at Shipping node for timeout compensation, signer must be order owner, order belongs to this service, and not claimed before",
1910
+ "description": "Verify order at Shipping node for timeout compensation: signer must be order owner, order belongs to this service, not claimed before, AND the order has been at the Shipping node for >= 2 days (Clock - progress.current_time >= 172800000 ms, progress submitted as Address identifier 4)",
1844
1911
  "table": [
1845
1912
  {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
1846
1913
  {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Shipping"},
1847
1914
  {"identifier": 2, "b_submission": false, "value_type": "Address", "value": "myshop_reward_v2", "name": "reward_object"},
1848
- {"identifier": 3, "b_submission": false, "value_type": "Address", "value": "three_body_signature_service_v2", "name": "service_address"}
1915
+ {"identifier": 3, "b_submission": false, "value_type": "Address", "value": "three_body_signature_service_v2", "name": "service_address"},
1916
+ {"identifier": 4, "b_submission": true, "value_type": "Address", "name": "progress_id"},
1917
+ {"identifier": 5, "b_submission": false, "value_type": "U64", "value": "172800000", "name": "timeout_ms"}
1849
1918
  ],
1850
1919
  "root": {
1851
1920
  "type": "logic_and",
@@ -1871,6 +1940,19 @@ Create guards for reward verification with double-claim protection:
1871
1940
  {"type": "identifier", "identifier": 3}
1872
1941
  ]
1873
1942
  },
1943
+ {
1944
+ "type": "logic_as_u256_greater_or_equal",
1945
+ "nodes": [
1946
+ {
1947
+ "type": "calc_number_subtract",
1948
+ "nodes": [
1949
+ {"type": "context", "context": "Clock"},
1950
+ {"type": "query", "query": "progress.current_time", "object": {"identifier": 4}, "parameters": []}
1951
+ ]
1952
+ },
1953
+ {"type": "identifier", "identifier": 5}
1954
+ ]
1955
+ },
1874
1956
  {
1875
1957
  "type": "logic_not",
1876
1958
  "node": {
@@ -2040,6 +2122,7 @@ Merchant confirms the order. This step uses permission index 1000 (no Guard subm
2040
2122
  "next_node_name": "Order Confirmed",
2041
2123
  "forward": "Confirm Order"
2042
2124
  },
2125
+ "op": "next",
2043
2126
  "message": "Order confirmed by merchant"
2044
2127
  }
2045
2128
  },
@@ -2072,35 +2155,36 @@ Merchant starts shipping after signature service is completed. The merchant subm
2072
2155
  "next_node_name": "Shipping",
2073
2156
  "forward": "Confirm Signature and Submit Merkle Root"
2074
2157
  },
2158
+ "op": "next",
2075
2159
  "message": "Shipping started - signature completed and Merkle Root submitted"
2076
- },
2077
- "submission": {
2078
- "type": "submission",
2079
- "guard": [
2080
- {
2081
- "object": "machine_merkle_root_v2",
2082
- "impack": true
2083
- }
2084
- ],
2085
- "submission": [
2086
- {
2087
- "guard": "machine_merkle_root_v2",
2088
- "submission": [
2089
- {
2090
- "identifier": 0,
2091
- "b_submission": true,
2092
- "value_type": "String",
2093
- "value": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
2094
- }
2095
- ]
2096
- }
2097
- ]
2098
2160
  }
2099
2161
  },
2100
2162
  "env": {
2101
2163
  "account": "myshop_merchant",
2102
2164
  "network": "mainnet",
2103
2165
  "no_cache": true
2166
+ },
2167
+ "submission": {
2168
+ "type": "submission",
2169
+ "guard": [
2170
+ {
2171
+ "object": "machine_merkle_root_v2",
2172
+ "impack": true
2173
+ }
2174
+ ],
2175
+ "submission": [
2176
+ {
2177
+ "guard": "machine_merkle_root_v2",
2178
+ "submission": [
2179
+ {
2180
+ "identifier": 0,
2181
+ "b_submission": true,
2182
+ "value_type": "String",
2183
+ "value": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
2184
+ }
2185
+ ]
2186
+ }
2187
+ ]
2104
2188
  }
2105
2189
  }
2106
2190
  }
@@ -2128,6 +2212,7 @@ Customer confirms receipt of goods.
2128
2212
  "next_node_name": "Delivery Complete",
2129
2213
  "forward": "Confirm Receipt"
2130
2214
  },
2215
+ "op": "next",
2131
2216
  "message": "Delivery confirmed - goods received"
2132
2217
  }
2133
2218
  },
@@ -2160,6 +2245,7 @@ Alternatively, customer can rate as Wonderful (very satisfied).
2160
2245
  "next_node_name": "Wonderful",
2161
2246
  "forward": "Rate as Wonderful"
2162
2247
  },
2248
+ "op": "next",
2163
2249
  "message": "Rated as Wonderful - very satisfied with the service"
2164
2250
  }
2165
2251
  },
@@ -2187,34 +2273,34 @@ Customer claims Wonderful reward from reward pool.
2187
2273
  "operation_type": "reward",
2188
2274
  "data": {
2189
2275
  "object": "myshop_reward_v2",
2190
- "claim": "reward_wonderful_v2",
2191
- "submission": {
2192
- "type": "submission",
2193
- "guard": [
2194
- {
2195
- "object": "reward_wonderful_v2",
2196
- "impack": true
2197
- }
2198
- ],
2199
- "submission": [
2200
- {
2201
- "guard": "reward_wonderful_v2",
2202
- "submission": [
2203
- {
2204
- "identifier": 0,
2205
- "b_submission": true,
2206
- "value_type": "Address",
2207
- "value": "myshop_order_v2"
2208
- }
2209
- ]
2210
- }
2211
- ]
2212
- }
2276
+ "claim": "reward_wonderful_v2"
2213
2277
  },
2214
2278
  "env": {
2215
2279
  "account": "myshop_customer",
2216
2280
  "network": "mainnet",
2217
2281
  "no_cache": true
2282
+ },
2283
+ "submission": {
2284
+ "type": "submission",
2285
+ "guard": [
2286
+ {
2287
+ "object": "reward_wonderful_v2",
2288
+ "impack": true
2289
+ }
2290
+ ],
2291
+ "submission": [
2292
+ {
2293
+ "guard": "reward_wonderful_v2",
2294
+ "submission": [
2295
+ {
2296
+ "identifier": 0,
2297
+ "b_submission": true,
2298
+ "value_type": "Address",
2299
+ "value": "myshop_order_v2"
2300
+ }
2301
+ ]
2302
+ }
2303
+ ]
2218
2304
  }
2219
2305
  }
2220
2306
  }
@@ -2224,9 +2310,9 @@ Customer claims Wonderful reward from reward pool.
2224
2310
 
2225
2311
  ### Step 7: Order Auto-Complete or Manual Complete
2226
2312
 
2227
- Order can auto-complete after time thresholds or be manually completed.
2313
+ Order can auto-complete after a time threshold or be manually completed by the merchant.
2228
2314
 
2229
- **From Shipping (10 days)**:
2315
+ **Auto-Complete from Shipping (10 days, guard: machine_time_10d_v2)**:
2230
2316
 
2231
2317
  ```json
2232
2318
  {
@@ -2240,42 +2326,44 @@ Order can auto-complete after time thresholds or be manually completed.
2240
2326
  "next_node_name": "Order Complete",
2241
2327
  "forward": "Auto Complete from Shipping"
2242
2328
  },
2243
- "hold": false,
2329
+ "op": "next",
2244
2330
  "message": "Order auto-completed after 10 days"
2245
- },
2246
- "submission": {
2247
- "type": "submission",
2248
- "guard": [
2249
- {
2250
- "object": "machine_time_10d_v2",
2251
- "impack": true
2252
- }
2253
- ],
2254
- "submission": [
2255
- {
2256
- "guard": "machine_time_10d_v2",
2257
- "submission": [
2258
- {
2259
- "identifier": 0,
2260
- "b_submission": true,
2261
- "value_type": "Address",
2262
- "value": "myshop_progress_v2"
2263
- }
2264
- ]
2265
- }
2266
- ]
2267
2331
  }
2268
2332
  },
2269
2333
  "env": {
2270
2334
  "account": "myshop_merchant",
2271
2335
  "network": "mainnet",
2272
2336
  "no_cache": true
2337
+ },
2338
+ "submission": {
2339
+ "type": "submission",
2340
+ "guard": [
2341
+ {
2342
+ "object": "machine_time_10d_v2",
2343
+ "impack": true
2344
+ }
2345
+ ],
2346
+ "submission": [
2347
+ {
2348
+ "guard": "machine_time_10d_v2",
2349
+ "submission": [
2350
+ {
2351
+ "identifier": 0,
2352
+ "b_submission": true,
2353
+ "value_type": "Address",
2354
+ "value": "myshop_progress_v2"
2355
+ }
2356
+ ]
2357
+ }
2358
+ ]
2273
2359
  }
2274
2360
  }
2275
2361
  }
2276
2362
  ```
2277
2363
 
2278
- **From Delivery Complete (2 days)**:
2364
+ **Manual Complete from Delivery Complete (no Guard)**:
2365
+
2366
+ The "Complete Order" forward (Delivery Complete → Order Complete, permissionIndex 1001) has no Guard, so no `submission` is needed.
2279
2367
 
2280
2368
  ```json
2281
2369
  {
@@ -2287,32 +2375,10 @@ Order can auto-complete after time thresholds or be manually completed.
2287
2375
  "operate": {
2288
2376
  "operation": {
2289
2377
  "next_node_name": "Order Complete",
2290
- "forward": "Auto Complete from Delivery"
2378
+ "forward": "Complete Order"
2291
2379
  },
2292
- "hold": false,
2293
- "message": "Order auto-completed after 2 days from delivery"
2294
- },
2295
- "submission": {
2296
- "type": "submission",
2297
- "guard": [
2298
- {
2299
- "object": "machine_time_2d_v2",
2300
- "impack": true
2301
- }
2302
- ],
2303
- "submission": [
2304
- {
2305
- "guard": "machine_time_2d_v2",
2306
- "submission": [
2307
- {
2308
- "identifier": 0,
2309
- "b_submission": true,
2310
- "value_type": "Address",
2311
- "value": "myshop_progress_v2"
2312
- }
2313
- ]
2314
- }
2315
- ]
2380
+ "op": "next",
2381
+ "message": "Order manually completed by merchant after delivery"
2316
2382
  }
2317
2383
  },
2318
2384
  "env": {
@@ -2324,6 +2390,8 @@ Order can auto-complete after time thresholds or be manually completed.
2324
2390
  }
2325
2391
  ```
2326
2392
 
2393
+ > **Note**: There is no "auto-complete from Delivery Complete" forward in this Machine — an earlier 2-day variant referenced a non-existent forward plus the illustrative `machine_time_2d_v2` Guard (see the Step 4 note). From Delivery Complete, the order finishes via "Complete Order" (above), "Rate as Wonderful" (Step 5), or a return path (Step 9).
2394
+
2327
2395
  ***
2328
2396
 
2329
2397
  ### Step 8: Lost Package Handling
@@ -2336,15 +2404,15 @@ If package is lost, customer reports and merchant confirms.
2336
2404
  {
2337
2405
  "tool": "onchain_operations",
2338
2406
  "data": {
2339
- "operation_type": "progress",
2407
+ "operation_type": "order",
2340
2408
  "data": {
2341
- "object": "myshop_progress_v2",
2342
- "operate": {
2409
+ "object": "myshop_order_v2",
2410
+ "progress": {
2343
2411
  "operation": {
2344
2412
  "next_node_name": "Lost",
2345
2413
  "forward": "Report Lost"
2346
2414
  },
2347
- "hold": false,
2415
+ "op": "next",
2348
2416
  "message": "Package reported as lost"
2349
2417
  }
2350
2418
  },
@@ -2371,36 +2439,36 @@ If package is lost, customer reports and merchant confirms.
2371
2439
  "next_node_name": "Lost",
2372
2440
  "forward": "Confirm Lost with Merkle Root"
2373
2441
  },
2374
- "hold": false,
2442
+ "op": "next",
2375
2443
  "message": "Lost confirmed with Merkle Root"
2376
- },
2377
- "submission": {
2378
- "type": "submission",
2379
- "guard": [
2380
- {
2381
- "object": "machine_merkle_root_v2",
2382
- "impack": true
2383
- }
2384
- ],
2385
- "submission": [
2386
- {
2387
- "guard": "machine_merkle_root_v2",
2388
- "submission": [
2389
- {
2390
- "identifier": 0,
2391
- "b_submission": true,
2392
- "value_type": "String",
2393
- "value": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
2394
- }
2395
- ]
2396
- }
2397
- ]
2398
2444
  }
2399
2445
  },
2400
2446
  "env": {
2401
2447
  "account": "myshop_merchant",
2402
2448
  "network": "mainnet",
2403
2449
  "no_cache": true
2450
+ },
2451
+ "submission": {
2452
+ "type": "submission",
2453
+ "guard": [
2454
+ {
2455
+ "object": "machine_merkle_root_v2",
2456
+ "impack": true
2457
+ }
2458
+ ],
2459
+ "submission": [
2460
+ {
2461
+ "guard": "machine_merkle_root_v2",
2462
+ "submission": [
2463
+ {
2464
+ "identifier": 0,
2465
+ "b_submission": true,
2466
+ "value_type": "String",
2467
+ "value": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
2468
+ }
2469
+ ]
2470
+ }
2471
+ ]
2404
2472
  }
2405
2473
  }
2406
2474
  }
@@ -2415,34 +2483,34 @@ If package is lost, customer reports and merchant confirms.
2415
2483
  "operation_type": "reward",
2416
2484
  "data": {
2417
2485
  "object": "myshop_reward_v2",
2418
- "claim": "reward_lost_v2",
2419
- "submission": {
2420
- "type": "submission",
2421
- "guard": [
2422
- {
2423
- "object": "reward_lost_v2",
2424
- "impack": true
2425
- }
2426
- ],
2427
- "submission": [
2428
- {
2429
- "guard": "reward_lost_v2",
2430
- "submission": [
2431
- {
2432
- "identifier": 0,
2433
- "b_submission": true,
2434
- "value_type": "Address",
2435
- "value": "myshop_order_v2"
2436
- }
2437
- ]
2438
- }
2439
- ]
2440
- }
2486
+ "claim": "reward_lost_v2"
2441
2487
  },
2442
2488
  "env": {
2443
2489
  "account": "myshop_customer",
2444
2490
  "network": "mainnet",
2445
2491
  "no_cache": true
2492
+ },
2493
+ "submission": {
2494
+ "type": "submission",
2495
+ "guard": [
2496
+ {
2497
+ "object": "reward_lost_v2",
2498
+ "impack": true
2499
+ }
2500
+ ],
2501
+ "submission": [
2502
+ {
2503
+ "guard": "reward_lost_v2",
2504
+ "submission": [
2505
+ {
2506
+ "identifier": 0,
2507
+ "b_submission": true,
2508
+ "value_type": "Address",
2509
+ "value": "myshop_order_v2"
2510
+ }
2511
+ ]
2512
+ }
2513
+ ]
2446
2514
  }
2447
2515
  }
2448
2516
  }
@@ -2460,15 +2528,15 @@ Customer requests return after delivery confirmation.
2460
2528
  {
2461
2529
  "tool": "onchain_operations",
2462
2530
  "data": {
2463
- "operation_type": "progress",
2531
+ "operation_type": "order",
2464
2532
  "data": {
2465
- "object": "myshop_progress_v2",
2466
- "operate": {
2533
+ "object": "myshop_order_v2",
2534
+ "progress": {
2467
2535
  "operation": {
2468
2536
  "next_node_name": "Receipt Return",
2469
2537
  "forward": "Request Return with Receipt"
2470
2538
  },
2471
- "hold": false,
2539
+ "op": "next",
2472
2540
  "message": "Return requested after delivery"
2473
2541
  }
2474
2542
  },
@@ -2495,36 +2563,36 @@ Customer requests return after delivery confirmation.
2495
2563
  "next_node_name": "Receipt Return",
2496
2564
  "forward": "Confirm Return Address with Merkle Root"
2497
2565
  },
2498
- "hold": false,
2566
+ "op": "next",
2499
2567
  "message": "Return address confirmed with Merkle Root"
2500
- },
2501
- "submission": {
2502
- "type": "submission",
2503
- "guard": [
2504
- {
2505
- "object": "machine_merkle_root_v2",
2506
- "impack": true
2507
- }
2508
- ],
2509
- "submission": [
2510
- {
2511
- "guard": "machine_merkle_root_v2",
2512
- "submission": [
2513
- {
2514
- "identifier": 0,
2515
- "b_submission": true,
2516
- "value_type": "String",
2517
- "value": "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
2518
- }
2519
- ]
2520
- }
2521
- ]
2522
2568
  }
2523
2569
  },
2524
2570
  "env": {
2525
2571
  "account": "myshop_merchant",
2526
2572
  "network": "mainnet",
2527
2573
  "no_cache": true
2574
+ },
2575
+ "submission": {
2576
+ "type": "submission",
2577
+ "guard": [
2578
+ {
2579
+ "object": "machine_merkle_root_v2",
2580
+ "impack": true
2581
+ }
2582
+ ],
2583
+ "submission": [
2584
+ {
2585
+ "guard": "machine_merkle_root_v2",
2586
+ "submission": [
2587
+ {
2588
+ "identifier": 0,
2589
+ "b_submission": true,
2590
+ "value_type": "String",
2591
+ "value": "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
2592
+ }
2593
+ ]
2594
+ }
2595
+ ]
2528
2596
  }
2529
2597
  }
2530
2598
  }
@@ -2536,44 +2604,44 @@ Customer requests return after delivery confirmation.
2536
2604
  {
2537
2605
  "tool": "onchain_operations",
2538
2606
  "data": {
2539
- "operation_type": "progress",
2607
+ "operation_type": "order",
2540
2608
  "data": {
2541
- "object": "myshop_progress_v2",
2542
- "operate": {
2609
+ "object": "myshop_order_v2",
2610
+ "progress": {
2543
2611
  "operation": {
2544
2612
  "next_node_name": "Return Complete",
2545
2613
  "forward": "Submit Return Merkle Root"
2546
2614
  },
2547
- "hold": false,
2615
+ "op": "next",
2548
2616
  "message": "Return shipping Merkle Root submitted"
2549
- },
2550
- "submission": {
2551
- "type": "submission",
2552
- "guard": [
2553
- {
2554
- "object": "machine_merkle_root_v2",
2555
- "impack": true
2556
- }
2557
- ],
2558
- "submission": [
2559
- {
2560
- "guard": "machine_merkle_root_v2",
2561
- "submission": [
2562
- {
2563
- "identifier": 0,
2564
- "b_submission": true,
2565
- "value_type": "String",
2566
- "value": "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
2567
- }
2568
- ]
2569
- }
2570
- ]
2571
2617
  }
2572
2618
  },
2573
2619
  "env": {
2574
2620
  "account": "myshop_customer",
2575
2621
  "network": "mainnet",
2576
2622
  "no_cache": true
2623
+ },
2624
+ "submission": {
2625
+ "type": "submission",
2626
+ "guard": [
2627
+ {
2628
+ "object": "machine_merkle_root_v2",
2629
+ "impack": true
2630
+ }
2631
+ ],
2632
+ "submission": [
2633
+ {
2634
+ "guard": "machine_merkle_root_v2",
2635
+ "submission": [
2636
+ {
2637
+ "identifier": 0,
2638
+ "b_submission": true,
2639
+ "value_type": "String",
2640
+ "value": "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
2641
+ }
2642
+ ]
2643
+ }
2644
+ ]
2577
2645
  }
2578
2646
  }
2579
2647
  }
@@ -2593,7 +2661,7 @@ Customer requests return after delivery confirmation.
2593
2661
  "next_node_name": "Return Complete",
2594
2662
  "forward": "Confirm Return Received"
2595
2663
  },
2596
- "hold": false,
2664
+ "op": "next",
2597
2665
  "message": "Return received and confirmed"
2598
2666
  }
2599
2667
  },
@@ -2624,7 +2692,7 @@ For the Non-receipt Return path, the customer never received the goods and has n
2624
2692
  "next_node_name": "Return Complete",
2625
2693
  "forward": "Confirm Goods Recovered"
2626
2694
  },
2627
- "hold": false,
2695
+ "op": "next",
2628
2696
  "message": "Goods recovered by merchant - non-receipt return complete"
2629
2697
  }
2630
2698
  },
@@ -2657,36 +2725,36 @@ If customer doesn't return within 10 days, merchant can mark as Return Fail.
2657
2725
  "next_node_name": "Return Fail",
2658
2726
  "forward": "Timeout Return Not Received"
2659
2727
  },
2660
- "hold": false,
2728
+ "op": "next",
2661
2729
  "message": "Return failed - timeout"
2662
- },
2663
- "submission": {
2664
- "type": "submission",
2665
- "guard": [
2666
- {
2667
- "object": "machine_time_10d_v2",
2668
- "impack": true
2669
- }
2670
- ],
2671
- "submission": [
2672
- {
2673
- "guard": "machine_time_10d_v2",
2674
- "submission": [
2675
- {
2676
- "identifier": 0,
2677
- "b_submission": true,
2678
- "value_type": "Address",
2679
- "value": "myshop_progress_v2"
2680
- }
2681
- ]
2682
- }
2683
- ]
2684
2730
  }
2685
2731
  },
2686
2732
  "env": {
2687
2733
  "account": "myshop_merchant",
2688
2734
  "network": "mainnet",
2689
2735
  "no_cache": true
2736
+ },
2737
+ "submission": {
2738
+ "type": "submission",
2739
+ "guard": [
2740
+ {
2741
+ "object": "machine_time_10d_v2",
2742
+ "impack": true
2743
+ }
2744
+ ],
2745
+ "submission": [
2746
+ {
2747
+ "guard": "machine_time_10d_v2",
2748
+ "submission": [
2749
+ {
2750
+ "identifier": 0,
2751
+ "b_submission": true,
2752
+ "value_type": "Address",
2753
+ "value": "myshop_progress_v2"
2754
+ }
2755
+ ]
2756
+ }
2757
+ ]
2690
2758
  }
2691
2759
  }
2692
2760
  }
@@ -2709,34 +2777,34 @@ When order reaches Order Complete, Wonderful, or Return Fail, merchant can withd
2709
2777
  "operation_type": "allocation",
2710
2778
  "data": {
2711
2779
  "object": "myshop_allocation_v2",
2712
- "alloc_by_guard": "service_merchant_win_v2",
2713
- "submission": {
2714
- "type": "submission",
2715
- "guard": [
2716
- {
2717
- "object": "service_merchant_win_v2",
2718
- "impack": true
2719
- }
2720
- ],
2721
- "submission": [
2722
- {
2723
- "guard": "service_merchant_win_v2",
2724
- "submission": [
2725
- {
2726
- "identifier": 0,
2727
- "b_submission": true,
2728
- "value_type": "Address",
2729
- "value": "myshop_order_v2"
2730
- }
2731
- ]
2732
- }
2733
- ]
2734
- }
2780
+ "alloc_by_guard": "service_merchant_win_v2"
2735
2781
  },
2736
2782
  "env": {
2737
2783
  "account": "myshop_merchant",
2738
2784
  "network": "mainnet",
2739
2785
  "no_cache": true
2786
+ },
2787
+ "submission": {
2788
+ "type": "submission",
2789
+ "guard": [
2790
+ {
2791
+ "object": "service_merchant_win_v2",
2792
+ "impack": true
2793
+ }
2794
+ ],
2795
+ "submission": [
2796
+ {
2797
+ "guard": "service_merchant_win_v2",
2798
+ "submission": [
2799
+ {
2800
+ "identifier": 0,
2801
+ "b_submission": true,
2802
+ "value_type": "Address",
2803
+ "value": "myshop_order_v2"
2804
+ }
2805
+ ]
2806
+ }
2807
+ ]
2740
2808
  }
2741
2809
  }
2742
2810
  }
@@ -2755,34 +2823,34 @@ When order reaches Lost or Return Complete, customer can withdraw funds.
2755
2823
  "operation_type": "allocation",
2756
2824
  "data": {
2757
2825
  "object": "myshop_allocation_v2",
2758
- "alloc_by_guard": "service_customer_win_v2",
2759
- "submission": {
2760
- "type": "submission",
2761
- "guard": [
2762
- {
2763
- "object": "service_customer_win_v2",
2764
- "impack": true
2765
- }
2766
- ],
2767
- "submission": [
2768
- {
2769
- "guard": "service_customer_win_v2",
2770
- "submission": [
2771
- {
2772
- "identifier": 0,
2773
- "b_submission": true,
2774
- "value_type": "Address",
2775
- "value": "myshop_order_v2"
2776
- }
2777
- ]
2778
- }
2779
- ]
2780
- }
2826
+ "alloc_by_guard": "service_customer_win_v2"
2781
2827
  },
2782
2828
  "env": {
2783
2829
  "account": "myshop_customer",
2784
2830
  "network": "mainnet",
2785
2831
  "no_cache": true
2832
+ },
2833
+ "submission": {
2834
+ "type": "submission",
2835
+ "guard": [
2836
+ {
2837
+ "object": "service_customer_win_v2",
2838
+ "impack": true
2839
+ }
2840
+ ],
2841
+ "submission": [
2842
+ {
2843
+ "guard": "service_customer_win_v2",
2844
+ "submission": [
2845
+ {
2846
+ "identifier": 0,
2847
+ "b_submission": true,
2848
+ "value_type": "Address",
2849
+ "value": "myshop_order_v2"
2850
+ }
2851
+ ]
2852
+ }
2853
+ ]
2786
2854
  }
2787
2855
  }
2788
2856
  }
@@ -2796,7 +2864,7 @@ This advanced e-commerce example demonstrates:
2796
2864
 
2797
2865
  1. **Multi-Path Workflow**: Orders can complete through normal delivery, wonderful rating, or various return paths
2798
2866
  2. **Dual-Signature Returns**: Receipt returns require confirmation from both parties (threshold=2); non-receipt returns require only merchant confirmation of goods recovery (threshold=1)
2799
- 3. **Time-Based Auto-Completion**: Orders auto-complete after time thresholds (10 days from shipping, 2 days from delivery)
2867
+ 3. **Time-Based Auto-Completion**: Orders auto-complete from Shipping after a 10-day threshold (guard-verified); from Delivery Complete the merchant completes manually via the "Complete Order" forward
2800
2868
  4. **Guard-Based Verification**: All state transitions and fund allocations are protected by guards
2801
2869
  5. **Reward Incentive System**: Wonderful ratings receive rewards, lost packages and shipping delays receive compensation
2802
2870
  6. **Arbitration Support**: Service binds to Arbitration object for final on-chain dispute resolution