@wowok/agent-mcp 2.2.13 → 2.2.14

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 (126) hide show
  1. package/dist/index.js +42 -98
  2. package/dist/schema-query/index.d.ts +29 -0
  3. package/dist/schema-query/index.js +149 -0
  4. package/dist/schemas/account_operation.schema.json +255 -0
  5. package/dist/schemas/guard2file.schema.json +71 -0
  6. package/dist/schemas/index.json +139 -0
  7. package/dist/schemas/local_info_operation.schema.json +142 -0
  8. package/dist/schemas/local_mark_operation.schema.json +119 -0
  9. package/dist/schemas/machineNode2file.schema.json +71 -0
  10. package/dist/schemas/messenger_operation.schema.json +1393 -0
  11. package/dist/schemas/onchain_events.schema.json +113 -0
  12. package/dist/schemas/onchain_operations.schema.json +376 -0
  13. package/dist/schemas/onchain_operations_allocation.schema.json +914 -0
  14. package/dist/schemas/onchain_operations_arbitration.schema.json +1166 -0
  15. package/dist/schemas/onchain_operations_contact.schema.json +853 -0
  16. package/dist/schemas/onchain_operations_demand.schema.json +984 -0
  17. package/dist/schemas/onchain_operations_gen_passport.schema.json +1141 -0
  18. package/dist/schemas/onchain_operations_guard.schema.json +713 -0
  19. package/dist/schemas/onchain_operations_machine.schema.json +1347 -0
  20. package/dist/schemas/onchain_operations_order.schema.json +830 -0
  21. package/dist/schemas/onchain_operations_payment.schema.json +717 -0
  22. package/dist/schemas/onchain_operations_permission.schema.json +1088 -0
  23. package/dist/schemas/onchain_operations_personal.schema.json +1282 -0
  24. package/dist/schemas/onchain_operations_progress.schema.json +751 -0
  25. package/dist/schemas/onchain_operations_repository.schema.json +1572 -0
  26. package/dist/schemas/onchain_operations_reward.schema.json +955 -0
  27. package/dist/schemas/onchain_operations_service.schema.json +1411 -0
  28. package/dist/schemas/onchain_operations_treasury.schema.json +1155 -0
  29. package/dist/schemas/onchain_table_data.schema.json +35 -0
  30. package/dist/schemas/operations/guard.json +163 -0
  31. package/dist/schemas/operations/permission.json +22 -0
  32. package/dist/schemas/query_toolkit.schema.json +32 -0
  33. package/dist/schemas/schema_query.schema.json +33 -0
  34. package/dist/schemas/wip_file.schema.json +27 -0
  35. package/dist/schemas/wowok_buildin_info.schema.json +487 -0
  36. package/package.json +7 -5
  37. package/dist/docs/index.d.ts +0 -3
  38. package/dist/docs/index.js +0 -2
  39. package/dist/docs/loader.d.ts +0 -12
  40. package/dist/docs/loader.js +0 -177
  41. package/dist/docs/search.d.ts +0 -17
  42. package/dist/docs/search.js +0 -325
  43. package/dist/docs/types.d.ts +0 -55
  44. package/dist/docs/types.js +0 -1
  45. package/docs/README.md +0 -249
  46. package/docs/WIP.md +0 -388
  47. package/docs/WTS.md +0 -536
  48. package/docs/docs/account.md +0 -914
  49. package/docs/docs/allocation.md +0 -635
  50. package/docs/docs/arbitration.md +0 -1804
  51. package/docs/docs/arbitration_state_machine.md +0 -270
  52. package/docs/docs/contact.md +0 -709
  53. package/docs/docs/demand.md +0 -948
  54. package/docs/docs/guard.md +0 -1465
  55. package/docs/docs/localinfo.md +0 -432
  56. package/docs/docs/localmark.md +0 -583
  57. package/docs/docs/machine.md +0 -2490
  58. package/docs/docs/messenger.md +0 -2098
  59. package/docs/docs/onchain_events.md +0 -267
  60. package/docs/docs/order.md +0 -1001
  61. package/docs/docs/payment.md +0 -512
  62. package/docs/docs/permission.md +0 -1438
  63. package/docs/docs/personal.md +0 -742
  64. package/docs/docs/progress.md +0 -1748
  65. package/docs/docs/query.md +0 -467
  66. package/docs/docs/repository.md +0 -1043
  67. package/docs/docs/reward.md +0 -833
  68. package/docs/docs/service.md +0 -2130
  69. package/docs/docs/stage-01-introduction.md +0 -243
  70. package/docs/docs/stage-02-trust.md +0 -302
  71. package/docs/docs/stage-03-collaboration.md +0 -337
  72. package/docs/docs/stage-04-transaction.md +0 -277
  73. package/docs/docs/stage-05-business.md +0 -151
  74. package/docs/docs/stage-06-personal.md +0 -203
  75. package/docs/docs/stage-07-query.md +0 -572
  76. package/docs/docs/stage-08-examples.md +0 -184
  77. package/docs/docs/treasury.md +0 -1149
  78. package/docs/docs/wowok_buildin_info.md +0 -740
  79. package/docs/examples/Insurance/Insurance.md +0 -594
  80. package/docs/examples/Insurance/Insurance_TestResults.md +0 -481
  81. package/docs/examples/Insurance/insurance_complete_guard_v1.json +0 -50
  82. package/docs/examples/MyShop/MyShop.md +0 -1353
  83. package/docs/examples/MyShop/MyShop_TestResults.md +0 -1003
  84. package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +0 -1898
  85. package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
  86. package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
  87. package/docs/examples/MyShop_Advanced/machine_nodes.json +0 -222
  88. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +0 -776
  89. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
  90. package/docs/examples/Travel/Travel.md +0 -1157
  91. package/docs/examples/Travel/Travel_TestResults.md +0 -743
  92. package/docs/examples/Travel/calc-weather-timestamps.js +0 -8
  93. package/docs/examples/Travel/travel_machine_v2_export.json +0 -104
  94. package/docs/examples/Travel/weather_check_guard_v1.json +0 -51
  95. package/docs/skills/WOWOK.md +0 -650
  96. package/docs/skills/onchain_operations/_common.md +0 -406
  97. package/docs/skills/onchain_operations/_index.md +0 -196
  98. package/docs/skills/onchain_operations/allocation.md +0 -28
  99. package/docs/skills/onchain_operations/arbitration.md +0 -106
  100. package/docs/skills/onchain_operations/contact.md +0 -40
  101. package/docs/skills/onchain_operations/demand.md +0 -53
  102. package/docs/skills/onchain_operations/gen_passport.md +0 -23
  103. package/docs/skills/onchain_operations/guard.md +0 -56
  104. package/docs/skills/onchain_operations/machine.md +0 -89
  105. package/docs/skills/onchain_operations/order.md +0 -56
  106. package/docs/skills/onchain_operations/payment.md +0 -24
  107. package/docs/skills/onchain_operations/permission.md +0 -68
  108. package/docs/skills/onchain_operations/personal.md +0 -58
  109. package/docs/skills/onchain_operations/progress.md +0 -38
  110. package/docs/skills/onchain_operations/repository.md +0 -70
  111. package/docs/skills/onchain_operations/reward.md +0 -38
  112. package/docs/skills/onchain_operations/service.md +0 -78
  113. package/docs/skills/onchain_operations/treasury.md +0 -68
  114. package/docs/skills/schema-account_operation.md +0 -402
  115. package/docs/skills/schema-guard2file.md +0 -153
  116. package/docs/skills/schema-local_info_operation.md +0 -160
  117. package/docs/skills/schema-local_mark_operation.md +0 -148
  118. package/docs/skills/schema-machineNode2file.md +0 -155
  119. package/docs/skills/schema-messenger_operation.md +0 -547
  120. package/docs/skills/schema-onchain_events.md +0 -201
  121. package/docs/skills/schema-onchain_table_data.md +0 -334
  122. package/docs/skills/schema-query_toolkit.md +0 -395
  123. package/docs/skills/schema-wip_file.md +0 -240
  124. package/docs/skills/schema-wowok_buildin_info.md +0 -296
  125. package/docs/wip-examples/three_body.html +0 -57
  126. package/docs/wip-examples/three_body.wip +0 -30
@@ -1,1898 +0,0 @@
1
- # MyShop Advanced E-Commerce Example
2
-
3
- An advanced e-commerce example demonstrating escrow with multiple order fund allocation modes, multi-party allocation, arbitration with voting guards, and WIP-based product verification.
4
-
5
- > **View Actual Execution Results**:
6
- > - **Merchant System Setup**: See [MyShop\_Advanced\_MerchantSystem\_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for service construction test results
7
- > - **Customer Order Flow**: See [MyShop\_Advanced\_OrderFlow\_TestResults.md](MyShop_Advanced_OrderFlow_TestResults.md) for order testing results
8
-
9
- ***
10
-
11
- ## Core Requirements & Features
12
-
13
- | Requirement | Description | Implementation |
14
- | ------------------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
15
- | **WIP-Verified Product** | Single product with WIP file hash verification | `three_body.wip` integrated into Service sales |
16
- | **Milestone-Based Workflow** | Order progress tracked through Machine workflow nodes | Multi-path workflow with delivery confirmation, wonderful rating, and return handling |
17
- | **Simplified Fund Allocation** | Clear fund distribution model with reward incentives | 100% to merchant on completion/wonderful, 100% to customer on lost/return |
18
- | **Reward System** | Incentive mechanism for excellent service and lost compensation | Reward pool with guard-based verification |
19
- | **Messenger-Based Logistics** | Privacy-preserving shipping info exchange via Messenger + Merkle Root | Tracking numbers shared privately; only Merkle Root submitted on-chain |
20
- | **Multi-Path Returns** | Support for non-receipt return, receipt return, and lost package handling | Different return paths based on delivery status |
21
-
22
- ### Key Design Decisions
23
-
24
- 1. **Single Product Model**: Only one WIP-verified product to simplify the example while demonstrating full capabilities
25
- 2. **Privacy-Preserving Logistics**: Merchant handles logistics independently using any logistics provider. Tracking numbers are shared privately via Messenger (not on-chain), with only Merkle Root submitted on-chain as proof of communication
26
- 3. **Reward Incentive Model**: Additional reward pool for excellent service (Wonderful reward) and compensation for lost packages
27
- 4. **Multi-Path Workflow**: Order can complete through normal delivery, wonderful rating, or various return paths
28
- 5. **Dual-Signature Returns**: Return processes require both customer and merchant confirmation (threshold=2)
29
-
30
- ### Important Design Principle: "Who Completes the Key Action, Who Submits the Proof"
31
-
32
- To ensure accountability and prevent disputes, the party who completes the critical action must submit the on-chain proof:
33
-
34
- - **Merchant Shipping**: Merchant receives customer's shipping address via Messenger and sends back tracking number → **Merchant submits Merkle Root** proving communication completed
35
- - **Customer Return**: Customer sends return tracking number to merchant via Messenger → **Customer submits Merkle Root** proving communication completed
36
- - **Lost Confirmation**: Both parties confirm lost package through dual-signature mechanism
37
-
38
- This principle ensures that the party responsible for the action bears the responsibility of recording it on-chain, creating a clear audit trail for potential arbitration.
39
-
40
- ***
41
-
42
- ## Overview
43
-
44
- This advanced example demonstrates an enterprise-grade e-commerce system with:
45
-
46
- - **Single WIP-Verified Product**: One product listing ("The Three-Body Problem + Author Signature") with WIP file verification
47
- - **Multi-Path Workflow**: Order progress with delivery confirmation, wonderful rating, lost handling, and multiple return paths
48
- - **Dual-Signature Returns**: Return processes require confirmation from both customer and merchant
49
- - **Reward Incentive System**: Reward pool for excellent service and compensation for lost packages
50
- - **Time-Based Auto-Completion**: Orders auto-complete after time thresholds
51
-
52
- ***
53
-
54
- ## Architecture
55
-
56
- ### System Components
57
-
58
- ```
59
- ┌─────────────────────────────────────────────────────────────────────────────┐
60
- │ MyShop Advanced E-Commerce System │
61
- ├─────────────────────────────────────────────────────────────────────────────┤
62
- │ │
63
- │ ┌─────────────────────────┐ ┌─────────────────────────┐ │
64
- │ │ Merchant System │ │ Customer System │ │
65
- │ ├─────────────────────────┤ ├─────────────────────────┤ │
66
- │ │ • Permission │ │ • Place Order │ │
67
- │ │ • Machine (Milestone) │ │ • Track Progress │ │
68
- │ │ • Service (WIP Catalog) │◄──►│ • Confirm Delivery │ │
69
- │ │ • Allocation (Escrow) │ │ • Rate Wonderful │ │
70
- │ │ • Guards (Verification) │ │ • Request Return │ │
71
- │ │ • Reward Pool │ │ • Submit Arbitration │ │
72
- │ └─────────────────────────┘ └─────────────────────────┘ │
73
- │ │
74
- │ Fund Flow: Merchant + Reward Pool (Incentives) │
75
- │ │
76
- └─────────────────────────────────────────────────────────────────────────────┘
77
- ```
78
-
79
- ### Order Workflow (Multi-Path Milestone-Based)
80
-
81
- ```mermaid
82
- graph TD
83
- classDef initial fill:#e1f5ff,stroke:#3399ff,stroke-width:2px;
84
- classDef merchant fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
85
- classDef customer fill:#d4edda,stroke:#28a745,stroke-width:2px;
86
- classDef dualsig fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
87
- classDef start fill:#999,stroke:#666,stroke-width:2px;
88
-
89
- START(( )):::start
90
-
91
- OC["Order Confirmed (Merchant)"]:::initial
92
- OR["Order Cancel (Merchant)"]:::initial
93
-
94
- SH["Shipping (Merchant)"]:::merchant
95
-
96
- DC["Delivery Complete (Customer)"]:::customer
97
- WO["Wonderful (Customer)"]:::customer
98
- OC2["Order Complete (Merchant)<br/>Time >= 10 days"]:::merchant
99
- LO["Lost (Dual-Sig)<br/>Threshold = 2"]:::dualsig
100
-
101
- OC3["Order Complete (Merchant)"]:::merchant
102
- NR["Non-receipt Return (Dual-Sig)<br/>Threshold = 2"]:::dualsig
103
-
104
- RR["Receipt Return (Dual-Sig)<br/>Threshold = 2"]:::dualsig
105
- RF["Return Fail (Merchant)<br/>Time >= 10 days"]:::merchant
106
- RC["Return Complete (Dual-Sig)<br/>Threshold = 2"]:::dualsig
107
-
108
- START --> OC
109
- START --> OR
110
- OC --> SH
111
- SH --> DC
112
- SH --> WO
113
- SH --> OC2
114
- SH --> LO
115
-
116
- DC --> OC3
117
- DC --> NR
118
-
119
- DC --> RR
120
- RR --> RF
121
- RR --> RC
122
- NR --> RC
123
- ```
124
-
125
- #### Fund Allocation
126
-
127
- - **Merchant 100%**: Order Complete | Wonderful | Return Fail
128
- - **Customer 100%**: Lost | Return Complete
129
-
130
- #### Reward Compensation
131
-
132
- - **Wonderful Node**: 10000 reward
133
- - **Lost Node**: 20000 compensation
134
- - **Shipping Timeout (>2 days)**: 20000 compensation
135
-
136
- ***
137
-
138
- ## Part 1: Build Order and Rationale
139
-
140
- Understanding the correct order for creating WoWok objects is crucial for a successful deployment. This section explains the dependency chain and why objects must be created in a specific sequence.
141
-
142
- ### Object Dependency Graph
143
-
144
- ```
145
- ┌─────────────────────────────────────────────────────────────────────────────┐
146
- │ Object Creation Dependencies │
147
- ├─────────────────────────────────────────────────────────────────────────────┤
148
- │ │
149
- │ Phase 1: Foundation │
150
- │ ═══════════════════════════ │
151
- │ │
152
- │ ┌─────────────────┐ ┌─────────────────┐ │
153
- │ │ Permission │ │ Accounts │ │
154
- │ │ (myshop_perm_ │ │ (myshop_merchant│ │
155
- │ │ v2) │ │ myshop_customer)│ │
156
- │ └────────┬────────┘ └─────────────────┘ │
157
- │ │ │
158
- │ ▼ │
159
- │ ┌─────────────────┐ │
160
- │ │ Add Permission │◄─── Grant indexes 1000, 1001 to merchant │
161
- │ │ Indexes │ Required for Machine operations │
162
- │ └────────┬────────┘ │
163
- │ │ │
164
- │ ▼ │
165
- │ ┌─────────────────┐ │
166
- │ │ Service │◄─── Requires: Permission │
167
- │ │(three_body_sig │ Publish: FALSE (get name first) │
168
- │ │ _service_v2) │ │
169
- │ └────────┬────────┘ │
170
- │ │ │
171
- │ ▼ │
172
- │ Phase 2: Guard Creation │
173
- │ ═══════════════════════ │
174
- │ │
175
- │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
176
- │ │ machine_merkle_ │ │ machine_service_│ │ machine_time_ │ │
177
- │ │ root_v2 │ │ order_v2 │ │ 10d_v2 │ │
178
- │ └─────────────────┘ └────────┬────────┘ └─────────────────┘ │
179
- │ │ │
180
- │ ▼ │
181
- │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
182
- │ │ service_merchant│ │ service_customer│ │ machine_time_2d │ │
183
- │ │ _win_v2 │ │ _win_v2 │ │ _v2 │ │
184
- │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
185
- │ │
186
- │ Phase 2b: Reward Guards │
187
- │ ═══════════════════════ │
188
- │ │
189
- │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
190
- │ │ reward_wonderful│ │ reward_lost │ │ reward_shipping │ │
191
- │ │ _v2 │ │ _v2 │ │ _timeout_v2 │ │
192
- │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
193
- │ │
194
- │ Phase 3: Machine Creation │
195
- │ ═══════════════════════════════ │
196
- │ │
197
- │ ┌─────────────────┐ │
198
- │ │ Machine │◄─── Requires: Permission + Guards │
199
- │ │(myshop_advanced │ All nodes with guards for verification │
200
- │ │ _machine_v2) │ │
201
- │ └────────┬────────┘ │
202
- │ │ │
203
- │ ▼ │
204
- │ Phase 4: Machine Binding │
205
- │ ═══════════════════════════════ │
206
- │ │
207
- │ ┌─────────────────┐ │
208
- │ │ Bind Machine │◄─── Requires: Service + Machine │
209
- │ │ to Service │ Must be done before publishing Service │
210
- │ └────────┬────────┘ │
211
- │ │ │
212
- │ ▼ │
213
- │ Phase 5: Arbitration Creation │
214
- │ ═══════════════════════════════ │
215
- │ │
216
- │ ┌─────────────────┐ │
217
- │ │ Arbitration │◄─── Independent, but needs Service binding │
218
- │ │myshop_arbitration│ │
219
- │ │ _v2 │ │
220
- │ └────────┬────────┘ │
221
- │ │ │
222
- │ ▼ │
223
- │ Phase 6: Service Configuration │
224
- │ ════════════════════════════════ │
225
- │ │
226
- │ ┌─────────────────┐ │
227
- │ │ Update Service │◄─── Add: order_allocators, sales, arbitrations │
228
- │ │ and Publish │ Requires: All Guards, Arbitration │
229
- │ └─────────────────┘ │
230
- │ │
231
- │ Phase 7: Reward Pool │
232
- │ ═════════════════════ │
233
- │ │
234
- │ ┌─────────────────┐ │
235
- │ │ Reward │◄─── Requires: Service (for guard verification) │
236
- │ │myshop_reward_v2 │ Add: reward_guards for Wonderful/Lost/Timeout │
237
- │ └─────────────────┘ │
238
- │ │
239
- └─────────────────────────────────────────────────────────────────────────────┘
240
- ```
241
-
242
- ### Why This Order Matters
243
-
244
- | Phase | Object | Dependencies | Reason |
245
- | ----- | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------- |
246
- | 1 | **Permission** | None | Permission is the foundation. Machine and Service both reference a permission object for access control. |
247
- | 1b | **Permission Indexes** | Permission | Grant permission indexes 1000 and 1001 to merchant. Required for Machine node operations. |
248
- | 2 | **Service (Empty)** | Permission | Create Service without publishing first to obtain its name. This name is used in Guard verification. |
249
- | 3 | **Guards** | Service Name | Guards must verify that orders belong to the correct Service. They query Service name and Progress state. |
250
- | 4 | **Machine** | Permission, Guards | Machine requires guards for node verification. Guards need Service name which is now available. |
251
- | 5 | **Machine Binding** | Service, Machine | Bind Machine to Service before publishing. Once published, Machine cannot be bound. |
252
- | 6 | **Arbitration** | None | Arbitration is independent but needs to be bound to Service. Create before Service update. |
253
- | 7 | **Service (Update)** | Guards, Arb, Machine | Update Service with order\_allocators, sales, arbitrations, machine binding. Then publish. |
254
- | 8 | **Reward** | Service, Guards | Reward pool needs Service name in guards for claim verification. Create after Service is available. |
255
-
256
- ### Key Design Decisions
257
-
258
- 1. **Permission First**: Every major object (Machine, Service) requires a permission object. Create this first.
259
- 2. **Permission Indexes**: Grant permission indexes 1000 and 1001 to merchant account. These are used in Machine node forwards.
260
- 3. **Service Before Guards**: Create Service without publishing to get its name. Guards use Service name to verify orders belong to the correct service.
261
- 4. **Guards Before Machine**: Machine nodes reference guards for verification. Create all guards first, then create Machine with guard references.
262
- 5. **Machine Binding Before Publish**: Bind Machine to Service before publishing. Once published, Machine cannot be bound.
263
- 6. **Arbitration Before Service Update**: Arbitration must be created before Service update so it can be bound to Service.
264
- 6. **Service Publishing Last**: Only publish Service after all guards, machine, and arbitration are ready.
265
- 7. **Reward Last**: Reward references Service address in guards for claim verification. Create after Service is available.
266
-
267
- ### Simplified Build Sequence
268
-
269
- ```
270
- Phase 1: Foundation
271
- └── 1. Create Permission (myshop_permission_v2)
272
- └── Add permission indexes (1000 for Order Confirmed/Cancel, 1001 for other operations)
273
-
274
- Phase 2: Service Creation
275
- └── 2. Create Service (three_body_signature_service_v2)
276
- ├── Publish: FALSE
277
- └── Record the Service address for Guard creation
278
-
279
- Phase 3: Guard Creation (Machine Guards)
280
- └── 3. Create Machine Guards (4 guards)
281
- ├── machine_merkle_root_v2 (verify string length = 64)
282
- ├── machine_service_order_v2 (verify order service + node)
283
- ├── machine_time_10d_v2 (time >= 10 days)
284
- └── machine_time_2d_v2 (time >= 2 days)
285
-
286
- Phase 3b: Service Guards
287
- └── 3b. Create Service Guards (2 guards)
288
- ├── service_merchant_win_v2 (verify node in [Order Complete, Wonderful, Return Fail])
289
- └── service_customer_win_v2 (verify node in [Lost, Return Complete])
290
-
291
- Phase 4: Machine Creation
292
- └── 4. Create Machine (myshop_advanced_machine_v2)
293
- └── Add all nodes with guards (Order Confirmed, Order Cancel, Shipping,
294
- Delivery Complete, Wonderful, Order Complete, Lost,
295
- Non-receipt Return, Receipt Return, Return Fail, Return Complete)
296
-
297
- Phase 5: Machine Binding
298
- └── 5. Bind Machine to Service
299
- └── Must be done before publishing Service
300
-
301
- Phase 6: Arbitration Creation
302
- └── 6. Create Arbitration (myshop_arbitration_v2)
303
- └── Final dispute resolution mechanism
304
-
305
- Phase 7: Service Configuration
306
- └── 7. Update and Publish Service
307
- ├── Add order_allocators (service_merchant_win_v2, service_customer_win_v2)
308
- ├── Add sales (Three-Body Problem product)
309
- ├── Add arbitrations binding
310
- └── Publish service
311
-
312
- Phase 8: Reward Pool
313
- └── 8. Create Reward (myshop_reward_v2)
314
- ├── Deposit initial balance
315
- ├── Create reward_guards (reward_wonderful_v2, reward_lost_v2, reward_shipping_timeout_v2)
316
- └── Add reward_guards (Wonderful: 10000, Lost: 20000, Shipping Timeout: 30000)
317
- ```
318
-
319
- ***
320
-
321
- ## Part 2: Merchant System Setup
322
-
323
- ### Prerequisites
324
-
325
- Reuse existing accounts from basic MyShop:
326
-
327
- - Account: `myshop_merchant` (store owner)
328
- - Account: `myshop_customer` (customer)
329
-
330
- Ensure both accounts have sufficient testnet WOW tokens.
331
-
332
- ***
333
-
334
- ### Step 1: Create Permission Object
335
-
336
- Create a new permission object for the advanced shop.
337
-
338
- **Prompt**: Create permission object "myshop\_permission\_v2".
339
-
340
- ```json
341
- {
342
- "operation_type": "permission",
343
- "data": {
344
- "object": {
345
- "name": "myshop_permission_v2",
346
- "replaceExistName": true
347
- },
348
- "description": "Permission object for MyShop Advanced e-commerce system"
349
- },
350
- "env": {
351
- "account": "myshop_merchant",
352
- "network": "testnet"
353
- }
354
- }
355
- ```
356
-
357
- ***
358
-
359
- ### Step 2: Add Custom Permissions
360
-
361
- Add custom permission indexes for advanced operations.
362
-
363
- **Permission Index 1010**: Order Confirmed + Order Cancel (Merchant operations for order confirmation/cancellation)
364
-
365
- ```json
366
- {
367
- "operation_type": "permission",
368
- "data": {
369
- "object": "myshop_permission_v2",
370
- "remark": {
371
- "op": "set",
372
- "index": 1010,
373
- "remark": "Order Confirmed and Order Cancel - Merchant confirms or cancels order with Merkle Root"
374
- },
375
- "table": {
376
- "op": "add perm by index",
377
- "index": 1010,
378
- "entity": {
379
- "entities": [{"name_or_address": "myshop_merchant"}]
380
- }
381
- }
382
- },
383
- "env": {
384
- "account": "myshop_merchant",
385
- "network": "testnet"
386
- }
387
- }
388
- ```
389
-
390
- **Permission Index 1011**: Shipping + Order Complete (Merchant logistics operations)
391
-
392
- ```json
393
- {
394
- "operation_type": "permission",
395
- "data": {
396
- "object": "myshop_permission_v2",
397
- "remark": {
398
- "op": "set",
399
- "index": 1011,
400
- "remark": "Shipping and Order Complete - Merchant logistics operations with Merkle Root"
401
- },
402
- "table": {
403
- "op": "add perm by index",
404
- "index": 1011,
405
- "entity": {
406
- "entities": [{"name_or_address": "myshop_merchant"}]
407
- }
408
- }
409
- },
410
- "env": {
411
- "account": "myshop_merchant",
412
- "network": "testnet"
413
- }
414
- }
415
- ```
416
-
417
- **Permission Index 1012**: Delivery Complete (Customer confirms receipt)
418
-
419
- ```json
420
- {
421
- "operation_type": "permission",
422
- "data": {
423
- "object": "myshop_permission_v2",
424
- "remark": {
425
- "op": "set",
426
- "index": 1012,
427
- "remark": "Delivery Complete - Customer confirms receipt"
428
- },
429
- "table": {
430
- "op": "add perm by index",
431
- "index": 1012,
432
- "entity": {
433
- "entities": [{"name_or_address": "myshop_customer"}]
434
- }
435
- }
436
- },
437
- "env": {
438
- "account": "myshop_merchant",
439
- "network": "testnet"
440
- }
441
- }
442
- ```
443
-
444
- **Permission Index 1013**: Wonderful (Customer rates wonderful)
445
-
446
- ```json
447
- {
448
- "operation_type": "permission",
449
- "data": {
450
- "object": "myshop_permission_v2",
451
- "remark": {
452
- "op": "set",
453
- "index": 1013,
454
- "remark": "Wonderful - Customer rates order as wonderful"
455
- },
456
- "table": {
457
- "op": "add perm by index",
458
- "index": 1013,
459
- "entity": {
460
- "entities": [{"name_or_address": "myshop_customer"}]
461
- }
462
- }
463
- },
464
- "env": {
465
- "account": "myshop_merchant",
466
- "network": "testnet"
467
- }
468
- }
469
- ```
470
-
471
- **Permission Index 1014**: Lost (Customer reports lost, Merchant confirms)
472
-
473
- ```json
474
- {
475
- "operation_type": "permission",
476
- "data": {
477
- "object": "myshop_permission_v2",
478
- "remark": {
479
- "op": "set",
480
- "index": 1014,
481
- "remark": "Lost - Customer reports lost, Merchant confirms"
482
- },
483
- "table": {
484
- "op": "add perm by index",
485
- "index": 1014,
486
- "entity": {
487
- "entities": [{"name_or_address": "myshop_customer"}]
488
- }
489
- }
490
- },
491
- "env": {
492
- "account": "myshop_merchant",
493
- "network": "testnet"
494
- }
495
- }
496
- ```
497
-
498
- **Permission Index 1015**: Non-receipt Return (Customer requests return before receipt)
499
-
500
- ```json
501
- {
502
- "operation_type": "permission",
503
- "data": {
504
- "object": "myshop_permission_v2",
505
- "remark": {
506
- "op": "set",
507
- "index": 1015,
508
- "remark": "Non-receipt Return - Customer requests return before receipt"
509
- },
510
- "table": {
511
- "op": "add perm by index",
512
- "index": 1015,
513
- "entity": {
514
- "entities": [{"name_or_address": "myshop_customer"}]
515
- }
516
- }
517
- },
518
- "env": {
519
- "account": "myshop_merchant",
520
- "network": "testnet"
521
- }
522
- }
523
- ```
524
-
525
- **Permission Index 1016**: Receipt Return (Customer requests return after receipt)
526
-
527
- ```json
528
- {
529
- "operation_type": "permission",
530
- "data": {
531
- "object": "myshop_permission_v2",
532
- "remark": {
533
- "op": "set",
534
- "index": 1016,
535
- "remark": "Receipt Return - Customer requests return after receipt"
536
- },
537
- "table": {
538
- "op": "add perm by index",
539
- "index": 1016,
540
- "entity": {
541
- "entities": [{"name_or_address": "myshop_customer"}]
542
- }
543
- }
544
- },
545
- "env": {
546
- "account": "myshop_merchant",
547
- "network": "testnet"
548
- }
549
- }
550
- ```
551
-
552
- **Permission Index 1017**: Return Complete (Merchant confirms return received)
553
-
554
- ```json
555
- {
556
- "operation_type": "permission",
557
- "data": {
558
- "object": "myshop_permission_v2",
559
- "remark": {
560
- "op": "set",
561
- "index": 1017,
562
- "remark": "Return Complete - Merchant confirms return received"
563
- },
564
- "table": {
565
- "op": "add perm by index",
566
- "index": 1017,
567
- "entity": {
568
- "entities": [{"name_or_address": "myshop_merchant"}]
569
- }
570
- }
571
- },
572
- "env": {
573
- "account": "myshop_merchant",
574
- "network": "testnet"
575
- }
576
- }
577
- ```
578
-
579
- ***
580
-
581
- ### Step 3: Create Service (Unpublished)
582
-
583
- Create the Service without publishing to obtain its address for Guard creation.
584
-
585
- **Prompt**: Create Service "three\_body\_signature\_service\_v2" with permission "myshop\_permission\_v2", do not publish.
586
-
587
- ```json
588
- {
589
- "operation_type": "service",
590
- "data": {
591
- "object": {
592
- "name": "three_body_signature_service_v2",
593
- "permission": "myshop_permission_v2"
594
- },
595
- "description": "Three-Body Problem Signature Edition - Limited collector's item with WIP verification",
596
- "publish": false
597
- },
598
- "env": {
599
- "account": "myshop_merchant",
600
- "network": "testnet"
601
- }
602
- }
603
- ```
604
-
605
- **Record the Service address** - it will be needed for Guard creation.
606
-
607
- ***
608
-
609
- ### Step 4: Create Guards (4 Guards for Machine)
610
-
611
- Create 4 Guards using the Service address. Guards verify order state and service ownership.
612
-
613
- **Guard List:**
614
-
615
- | # | Guard Name | Purpose |
616
- |---|------------|---------|
617
- | 1 | `machine_merkle_root_v2` | Verify Merkle Root string length = 64 |
618
- | 2 | `machine_service_order_v2` | Verify order belongs to Service and current node is valid |
619
- | 3 | `machine_time_10d_v2` | Verify 10-day timeout (864000000 ms) for auto-completion |
620
- | 4 | `machine_time_2d_v2` | Verify 2-day timeout (172800000 ms) for auto-completion |
621
-
622
- > **Note**: See [MyShop_Advanced_MerchantSystem_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for detailed guard creation examples.
623
- ```
624
-
625
- ***
626
-
627
- ### Step 5: Create Machine (Multi-Path Workflow)
628
-
629
- Create Machine with all nodes and guards in a single operation.
630
-
631
- **Prompt**: Create Machine "myshop\_advanced\_machine\_v2" with permission "myshop\_permission\_v2" and all nodes.
632
-
633
- ```json
634
- {
635
- "operation_type": "machine",
636
- "data": {
637
- "object": {
638
- "name": "myshop_advanced_machine_v2",
639
- "replaceExistName": true,
640
- "permission": "myshop_permission_v2"
641
- },
642
- "description": "Multi-path order processing with delivery confirmation, wonderful rating, lost handling and return processing - Complete workflow with guards",
643
- "node": {
644
- "op": "add",
645
- "nodes": [
646
- {
647
- "name": "Order Confirmed",
648
- "pairs": [
649
- {
650
- "prev_node": "",
651
- "threshold": 1,
652
- "forwards": [
653
- {
654
- "name": "Submit Messenger Merkle Root",
655
- "permissionIndex": 1000,
656
- "weight": 1,
657
- "guard": { "guard": "machine_merkle_root_v2" }
658
- }
659
- ]
660
- }
661
- ]
662
- },
663
- {
664
- "name": "Order Cancel",
665
- "pairs": [
666
- {
667
- "prev_node": "",
668
- "threshold": 1,
669
- "forwards": [
670
- {
671
- "name": "Submit Cancellation Merkle Root",
672
- "permissionIndex": 1000,
673
- "weight": 1,
674
- "guard": { "guard": "machine_merkle_root_v2" }
675
- }
676
- ]
677
- }
678
- ]
679
- },
680
- {
681
- "name": "Shipping",
682
- "pairs": [
683
- {
684
- "prev_node": "Order Confirmed",
685
- "threshold": 1,
686
- "forwards": [
687
- {
688
- "name": "Confirm Signature and Submit Merkle Root",
689
- "permissionIndex": 1001,
690
- "weight": 1,
691
- "guard": { "guard": "machine_service_order_v2" }
692
- }
693
- ]
694
- }
695
- ]
696
- },
697
- {
698
- "name": "Delivery Complete",
699
- "pairs": [
700
- {
701
- "prev_node": "Shipping",
702
- "threshold": 1,
703
- "forwards": [
704
- {
705
- "name": "Confirm Receipt",
706
- "permissionIndex": 1001,
707
- "weight": 1
708
- }
709
- ]
710
- }
711
- ]
712
- },
713
- {
714
- "name": "Wonderful",
715
- "pairs": [
716
- {
717
- "prev_node": "Shipping",
718
- "threshold": 1,
719
- "forwards": [
720
- {
721
- "name": "Rate Wonderful",
722
- "permissionIndex": 1001,
723
- "weight": 1
724
- }
725
- ]
726
- }
727
- ]
728
- },
729
- {
730
- "name": "Order Complete",
731
- "pairs": [
732
- {
733
- "prev_node": "Shipping",
734
- "threshold": 1,
735
- "forwards": [
736
- {
737
- "name": "Auto Complete from Shipping",
738
- "permissionIndex": 1001,
739
- "weight": 1,
740
- "guard": { "guard": "machine_time_10d_v2" }
741
- }
742
- ]
743
- },
744
- {
745
- "prev_node": "Delivery Complete",
746
- "threshold": 1,
747
- "forwards": [
748
- {
749
- "name": "Auto Complete from Delivery",
750
- "permissionIndex": 1001,
751
- "weight": 1,
752
- "guard": { "guard": "machine_time_2d_v2" }
753
- }
754
- ]
755
- }
756
- ]
757
- },
758
- {
759
- "name": "Lost",
760
- "pairs": [
761
- {
762
- "prev_node": "Shipping",
763
- "threshold": 2,
764
- "forwards": [
765
- {
766
- "name": "Report Lost",
767
- "permissionIndex": 1001,
768
- "weight": 1
769
- },
770
- {
771
- "name": "Confirm Lost with Merkle Root",
772
- "permissionIndex": 1001,
773
- "weight": 1,
774
- "guard": { "guard": "machine_merkle_root_v2" }
775
- }
776
- ]
777
- }
778
- ]
779
- },
780
- {
781
- "name": "Non-receipt Return",
782
- "pairs": [
783
- {
784
- "prev_node": "Shipping",
785
- "threshold": 2,
786
- "forwards": [
787
- {
788
- "name": "Request Return",
789
- "permissionIndex": 1001,
790
- "weight": 1
791
- },
792
- {
793
- "name": "Confirm Return with Merkle Root",
794
- "permissionIndex": 1001,
795
- "weight": 1,
796
- "guard": { "guard": "machine_merkle_root_v2" }
797
- }
798
- ]
799
- }
800
- ]
801
- },
802
- {
803
- "name": "Receipt Return",
804
- "pairs": [
805
- {
806
- "prev_node": "Delivery Complete",
807
- "threshold": 2,
808
- "forwards": [
809
- {
810
- "name": "Request Return with Receipt",
811
- "permissionIndex": 1001,
812
- "weight": 1
813
- },
814
- {
815
- "name": "Confirm Return Address with Merkle Root",
816
- "permissionIndex": 1001,
817
- "weight": 1,
818
- "guard": { "guard": "machine_merkle_root_v2" }
819
- }
820
- ]
821
- }
822
- ]
823
- },
824
- {
825
- "name": "Return Fail",
826
- "pairs": [
827
- {
828
- "prev_node": "Receipt Return",
829
- "threshold": 1,
830
- "forwards": [
831
- {
832
- "name": "Timeout Return Not Received",
833
- "permissionIndex": 1001,
834
- "weight": 1,
835
- "guard": { "guard": "machine_time_10d_v2" }
836
- }
837
- ]
838
- }
839
- ]
840
- },
841
- {
842
- "name": "Return Complete",
843
- "pairs": [
844
- {
845
- "prev_node": "Receipt Return",
846
- "threshold": 2,
847
- "forwards": [
848
- {
849
- "name": "Submit Return Merkle Root",
850
- "permissionIndex": 1001,
851
- "weight": 1,
852
- "guard": { "guard": "machine_merkle_root_v2" }
853
- },
854
- {
855
- "name": "Confirm Return Received",
856
- "permissionIndex": 1001,
857
- "weight": 1
858
- }
859
- ]
860
- },
861
- {
862
- "prev_node": "Non-receipt Return",
863
- "threshold": 2,
864
- "forwards": [
865
- {
866
- "name": "Submit Return Merkle Root",
867
- "permissionIndex": 1001,
868
- "weight": 1,
869
- "guard": { "guard": "machine_merkle_root_v2" }
870
- },
871
- {
872
- "name": "Confirm Return Received",
873
- "permissionIndex": 1001,
874
- "weight": 1
875
- }
876
- ]
877
- }
878
- ]
879
- }
880
- ]
881
- }
882
- },
883
- "env": {
884
- "account": "myshop_merchant",
885
- "network": "testnet"
886
- }
887
- }
888
- ```
889
-
890
- ***
891
-
892
- ### Step 6: Bind Machine to Service
893
-
894
- Bind the Machine to the Service. **Important**: The Service must be unpublished when binding the Machine.
895
-
896
- **Prompt**: Bind machine "myshop\_advanced\_machine\_v2" to service "three\_body\_signature\_service\_v2".
897
-
898
- ```json
899
- {
900
- "operation_type": "service",
901
- "data": {
902
- "object": "three_body_signature_service_v2",
903
- "machine": "myshop_advanced_machine_v2"
904
- },
905
- "env": {
906
- "account": "myshop_merchant",
907
- "network": "testnet"
908
- }
909
- }
910
- ```
911
-
912
- **Note**: This step must be performed before publishing the Service. Once published, the Machine cannot be bound.
913
-
914
- ***
915
-
916
- ### Step 7: Create Service Guards (2 Guards)
917
-
918
- Create 2 guards for Service order_allocators.
919
-
920
- **Guard List:**
921
-
922
- | # | Guard Name | Purpose |
923
- |---|------------|---------|
924
- | 5 | `service_merchant_win_v2` | Verify node in [Order Complete, Wonderful, Return Fail] |
925
- | 6 | `service_customer_win_v2` | Verify node in [Lost, Return Complete] |
926
-
927
- > **Note**: See [MyShop_Advanced_MerchantSystem_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for detailed guard creation examples.
928
-
929
- ***
930
-
931
- ### Step 8: Create Arbitration Object
932
-
933
- Create an Arbitration object as the final on-chain mechanism for protecting user rights.
934
-
935
- **Prompt**: Create arbitration object "myshop\_arbitration\_v2".
936
-
937
- ```json
938
- {
939
- "operation_type": "arbitration",
940
- "data": {
941
- "object": {
942
- "name": "myshop_arbitration_v2",
943
- "replaceExistName": true
944
- },
945
- "description": "Arbitration for MyShop Advanced - Final dispute resolution mechanism",
946
- "fee": 100000000
947
- },
948
- "env": {
949
- "account": "myshop_merchant",
950
- "network": "testnet"
951
- }
952
- }
953
- ```
954
-
955
- ***
956
-
957
- ### Step 9: Update Service with Allocators, Arbitration and Publish
958
-
959
- Update Service with order\_allocators, sales, arbitration binding, and publish.
960
-
961
- **Prompt**: Update service "three\_body\_signature\_service\_v2" with order allocators, arbitration and publish.
962
-
963
- ```json
964
- {
965
- "operation_type": "service",
966
- "data": {
967
- "object": "three_body_signature_service_v2",
968
- "order_allocators": {
969
- "description": "Order fund allocators for MyShop Advanced",
970
- "threshold": 0,
971
- "allocators": [
972
- {
973
- "guard": "service_merchant_win_v2",
974
- "sharing": [
975
- {
976
- "who": {"Signer": "signer"},
977
- "sharing": 10000,
978
- "mode": "Rate"
979
- }
980
- ]
981
- },
982
- {
983
- "guard": "service_customer_win_v2",
984
- "sharing": [
985
- {
986
- "who": {"GuardIdentifier": 0},
987
- "sharing": 10000,
988
- "mode": "Rate"
989
- }
990
- ]
991
- }
992
- ]
993
- },
994
- "sales": {
995
- "op": "add",
996
- "sales": [
997
- {
998
- "name": "The Three-Body Problem + Author Signature",
999
- "price": 5000000000,
1000
- "stock": 100,
1001
- "suspension": false,
1002
- "wip": "https://wowok.net/test/three_body.wip",
1003
- "wip_hash": "sha256:1db6dc86d8be68bafb33418628a30e7bfcbce48de9c099d3d9cb21def3af8b43"
1004
- }
1005
- ]
1006
- },
1007
- "arbitrations": {
1008
- "op": "add",
1009
- "objects": ["myshop_arbitration_v2"]
1010
- },
1011
- "customer_required": ["phone", "email", "shipping_address"],
1012
- "publish": true
1013
- },
1014
- "env": {
1015
- "account": "myshop_merchant",
1016
- "network": "testnet"
1017
- }
1018
- }
1019
- ```
1020
-
1021
- ***
1022
-
1023
- ### Step 10: Create Reward Pool
1024
-
1025
- Create reward pool with initial balance for rewards and compensation.
1026
-
1027
- **Prompt**: Create reward object "myshop\_reward\_v2" with initial balance.
1028
-
1029
- ```json
1030
- {
1031
- "operation_type": "reward",
1032
- "data": {
1033
- "object": {
1034
- "name": "myshop_reward_v2",
1035
- "replaceExistName": true
1036
- },
1037
- "description": "Reward pool for MyShop advanced - Wonderful rewards (10000), Lost compensation (20000), Shipping timeout compensation (30000)",
1038
- "coin_add": {
1039
- "balance": 150000000
1040
- }
1041
- },
1042
- "env": {
1043
- "account": "myshop_merchant",
1044
- "network": "testnet",
1045
- "no_cache": true
1046
- }
1047
- }
1048
- ```
1049
-
1050
- ***
1051
-
1052
- ### Step 11: Create Reward Guards (3 Guards)
1053
-
1054
- Create 3 guards for reward verification:
1055
-
1056
- | # | Guard Name | Purpose | Reward Amount |
1057
- |---|------------|---------|---------------|
1058
- | 7 | `reward_wonderful_v2` | Verify order at Wonderful node | 10000 |
1059
- | 8 | `reward_lost_v2` | Verify order at Lost node | 20000 |
1060
- | 9 | `reward_shipping_timeout_v2` | Verify order at Shipping node > 2 days | 30000 |
1061
-
1062
- > **Note**: See [MyShop_Advanced_MerchantSystem_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for detailed guard creation examples.
1063
-
1064
- ***
1065
-
1066
- ### Step 12: Add Reward Guards
1067
-
1068
- Add reward guards for Wonderful (10000), Lost (20000), and Shipping timeout (30000) compensation.
1069
-
1070
- **Prompt**: Add reward guards.
1071
-
1072
- ```json
1073
- {
1074
- "operation_type": "reward",
1075
- "data": {
1076
- "object": "myshop_reward_v2",
1077
- "guard_add": [
1078
- {
1079
- "guard": "reward_wonderful_v2",
1080
- "recipient": {"Signer": "signer"},
1081
- "amount": {"type": "Fixed", "value": 10000}
1082
- },
1083
- {
1084
- "guard": "reward_lost_v2",
1085
- "recipient": {"Signer": "signer"},
1086
- "amount": {"type": "Fixed", "value": 20000}
1087
- },
1088
- {
1089
- "guard": "reward_shipping_timeout_v2",
1090
- "recipient": {"Signer": "signer"},
1091
- "amount": {"type": "Fixed", "value": 30000}
1092
- }
1093
- ]
1094
- },
1095
- "env": {
1096
- "account": "myshop_merchant",
1097
- "network": "testnet"
1098
- }
1099
- }
1100
- ```
1101
-
1102
- > **Note**: See [MyShop_Advanced_MerchantSystem_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for Guard 4-5 detailed creation examples.
1103
-
1104
- > **Note**: See [MyShop_Advanced_MerchantSystem_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for Guard 6-10 detailed creation examples.
1105
-
1106
- ***
1107
-
1108
- ## Part 3: Customer Order Flow
1109
-
1110
- ### Step 1: Create Order with WIP Verification
1111
-
1112
- Customer places an order for "The Three-Body Problem + Author Signature" with WIP hash verification.
1113
-
1114
- **Prompt**: Customer "myshop\_customer" creates an order.
1115
-
1116
- ```json
1117
- {
1118
- "operation_type": "service",
1119
- "data": {
1120
- "object": "three_body_signature_service_v2",
1121
- "order_new": {
1122
- "buy": {
1123
- "items": [
1124
- {
1125
- "name": "The Three-Body Problem + Author Signature",
1126
- "stock": 1,
1127
- "wip_hash": "sha256:1db6dc86d8be68bafb33418628a30e7bfcbce48de9c099d3d9cb21def3af8b43"
1128
- }
1129
- ],
1130
- "total_pay": {
1131
- "balance": 5000000000
1132
- },
1133
- "order_info": "To my dear friend - keep exploring the universe"
1134
- },
1135
- "namedNewOrder": {
1136
- "name": "myshop_order_v2"
1137
- },
1138
- "namedNewAllocation": {
1139
- "name": "myshop_allocation_v2"
1140
- },
1141
- "namedNewProgress": {
1142
- "name": "myshop_progress_v2"
1143
- }
1144
- }
1145
- },
1146
- "env": {
1147
- "account": "myshop_customer",
1148
- "network": "testnet"
1149
- }
1150
- }
1151
- ```
1152
-
1153
- ***
1154
-
1155
- ### Step 2: Merchant Confirms Order
1156
-
1157
- Merchant confirms order by submitting Merkle Root.
1158
-
1159
- **Prompt**: Merchant confirms order with Merkle Root.
1160
-
1161
- ```json
1162
- {
1163
- "operation_type": "progress",
1164
- "data": {
1165
- "object": "myshop_progress_v2",
1166
- "operate": {
1167
- "operation": {
1168
- "next_node_name": "Order Confirmed",
1169
- "forward": "Submit Messenger Merkle Root"
1170
- },
1171
- "hold": false,
1172
- "message": "Order confirmed - Merkle Root submitted"
1173
- }
1174
- },
1175
- "submission": {
1176
- "type": "submission",
1177
- "guard": [
1178
- {
1179
- "object": "machine_merkle_root_v2",
1180
- "impack": true
1181
- }
1182
- ],
1183
- "submission": [
1184
- {
1185
- "guard": "machine_merkle_root_v2",
1186
- "submission": [
1187
- {
1188
- "identifier": 0,
1189
- "b_submission": true,
1190
- "value_type": "String",
1191
- "value": "0xabc123...def456"
1192
- }
1193
- ]
1194
- }
1195
- ]
1196
- },
1197
- "env": {
1198
- "account": "myshop_merchant",
1199
- "network": "testnet",
1200
- "no_cache": true
1201
- }
1202
- }
1203
- ```
1204
-
1205
- ***
1206
-
1207
- ### Step 3: Merchant Starts Shipping
1208
-
1209
- Merchant starts shipping after signature service is completed.
1210
-
1211
- **Prompt**: Merchant starts shipping with signature verification and Merkle Root.
1212
-
1213
- ```json
1214
- {
1215
- "operation_type": "progress",
1216
- "data": {
1217
- "object": "myshop_progress_v2",
1218
- "operate": {
1219
- "operation": {
1220
- "next_node_name": "Shipping",
1221
- "forward": "Confirm Signature and Submit Merkle Root"
1222
- },
1223
- "hold": false,
1224
- "message": "Shipping started - signature completed and Merkle Root submitted"
1225
- }
1226
- },
1227
- "submission": {
1228
- "type": "submission",
1229
- "guard": [
1230
- {
1231
- "object": "machine_service_order_v2",
1232
- "impack": true
1233
- }
1234
- ],
1235
- "submission": [
1236
- {
1237
- "guard": "machine_service_order_v2",
1238
- "submission": [
1239
- {
1240
- "identifier": 0,
1241
- "b_submission": true,
1242
- "value_type": "Address",
1243
- "value": "myshop_order_v2"
1244
- },
1245
- {
1246
- "identifier": 1,
1247
- "b_submission": true,
1248
- "value_type": "Address",
1249
- "value": "three_body_signature_service_v2"
1250
- }
1251
- ]
1252
- }
1253
- ]
1254
- },
1255
- "env": {
1256
- "account": "myshop_merchant",
1257
- "network": "testnet",
1258
- "no_cache": true
1259
- }
1260
- }
1261
- ```
1262
-
1263
- ***
1264
-
1265
- ### Step 4: Customer Confirms Delivery
1266
-
1267
- Customer confirms receipt of goods.
1268
-
1269
- **Prompt**: Customer confirms delivery.
1270
-
1271
- ```json
1272
- {
1273
- "operation_type": "progress",
1274
- "data": {
1275
- "object": "myshop_progress_v2",
1276
- "operate": {
1277
- "operation": {
1278
- "next_node_name": "Delivery Complete",
1279
- "forward": "Confirm Receipt"
1280
- },
1281
- "hold": false,
1282
- "message": "Delivery confirmed - goods received"
1283
- }
1284
- },
1285
- "env": {
1286
- "account": "myshop_customer",
1287
- "network": "testnet",
1288
- "no_cache": true
1289
- }
1290
- }
1291
- ```
1292
-
1293
- ***
1294
-
1295
- ### Step 5: Customer Rates Wonderful
1296
-
1297
- Alternatively, customer can rate as Wonderful (very satisfied).
1298
-
1299
- **Prompt**: Customer rates order as Wonderful.
1300
-
1301
- ```json
1302
- {
1303
- "operation_type": "progress",
1304
- "data": {
1305
- "object": "myshop_progress_v2",
1306
- "operate": {
1307
- "operation": {
1308
- "next_node_name": "Wonderful",
1309
- "forward": "Rate Wonderful"
1310
- },
1311
- "hold": false,
1312
- "message": "Rated as Wonderful - very satisfied with the service"
1313
- }
1314
- },
1315
- "env": {
1316
- "account": "myshop_customer",
1317
- "network": "testnet",
1318
- "no_cache": true
1319
- }
1320
- }
1321
- ```
1322
-
1323
- ***
1324
-
1325
- ### Step 6: Claim Wonderful Reward
1326
-
1327
- Customer claims Wonderful reward from reward pool.
1328
-
1329
- **Prompt**: Customer claims Wonderful reward.
1330
-
1331
- ```json
1332
- {
1333
- "operation_type": "reward",
1334
- "data": {
1335
- "object": "myshop_reward_v2",
1336
- "claim": {
1337
- "guard": "guard_wonderful_v2",
1338
- "reward_object": "myshop_order_v2"
1339
- }
1340
- },
1341
- "submission": {
1342
- "type": "submission",
1343
- "guard": [
1344
- {
1345
- "object": "guard_wonderful_v2",
1346
- "impack": true
1347
- }
1348
- ],
1349
- "submission": [
1350
- {
1351
- "guard": "guard_wonderful_v2",
1352
- "submission": [
1353
- {
1354
- "identifier": 0,
1355
- "b_submission": true,
1356
- "value_type": "Address",
1357
- "value": "myshop_order_v2"
1358
- }
1359
- ]
1360
- }
1361
- ]
1362
- },
1363
- "env": {
1364
- "account": "myshop_customer",
1365
- "network": "testnet",
1366
- "no_cache": true
1367
- }
1368
- }
1369
- ```
1370
-
1371
- ***
1372
-
1373
- ### Step 7: Order Auto-Complete or Manual Complete
1374
-
1375
- Order can auto-complete after time thresholds or be manually completed.
1376
-
1377
- **From Shipping (10 days)**:
1378
-
1379
- ```json
1380
- {
1381
- "operation_type": "progress",
1382
- "data": {
1383
- "object": "myshop_progress_v2",
1384
- "operate": {
1385
- "operation": {
1386
- "next_node_name": "Order Complete",
1387
- "forward": "Auto Complete from Shipping"
1388
- },
1389
- "hold": false,
1390
- "message": "Order auto-completed after 10 days"
1391
- }
1392
- },
1393
- "submission": {
1394
- "type": "submission",
1395
- "guard": [
1396
- {
1397
- "object": "machine_time_10d_v2",
1398
- "impack": true
1399
- }
1400
- ],
1401
- "submission": [
1402
- {
1403
- "guard": "machine_time_10d_v2",
1404
- "submission": [
1405
- {
1406
- "identifier": 0,
1407
- "b_submission": true,
1408
- "value_type": "Address",
1409
- "value": "myshop_progress_v2"
1410
- }
1411
- ]
1412
- }
1413
- ]
1414
- },
1415
- "env": {
1416
- "account": "myshop_merchant",
1417
- "network": "testnet",
1418
- "no_cache": true
1419
- }
1420
- }
1421
- ```
1422
-
1423
- **From Delivery Complete (2 days)**:
1424
-
1425
- ```json
1426
- {
1427
- "operation_type": "progress",
1428
- "data": {
1429
- "object": "myshop_progress_v2",
1430
- "operate": {
1431
- "operation": {
1432
- "next_node_name": "Order Complete",
1433
- "forward": "Auto Complete from Delivery"
1434
- },
1435
- "hold": false,
1436
- "message": "Order auto-completed after 2 days from delivery"
1437
- }
1438
- },
1439
- "submission": {
1440
- "type": "submission",
1441
- "guard": [
1442
- {
1443
- "object": "machine_time_2d_v2",
1444
- "impack": true
1445
- }
1446
- ],
1447
- "submission": [
1448
- {
1449
- "guard": "machine_time_2d_v2",
1450
- "submission": [
1451
- {
1452
- "identifier": 0,
1453
- "b_submission": true,
1454
- "value_type": "Address",
1455
- "value": "myshop_progress_v2"
1456
- }
1457
- ]
1458
- }
1459
- ]
1460
- },
1461
- "env": {
1462
- "account": "myshop_merchant",
1463
- "network": "testnet",
1464
- "no_cache": true
1465
- }
1466
- }
1467
- ```
1468
-
1469
- ***
1470
-
1471
- ### Step 8: Lost Package Handling
1472
-
1473
- If package is lost, customer reports and merchant confirms.
1474
-
1475
- **Step 8.1: Customer Reports Lost**
1476
-
1477
- ```json
1478
- {
1479
- "operation_type": "progress",
1480
- "data": {
1481
- "object": "myshop_progress_v2",
1482
- "operate": {
1483
- "operation": {
1484
- "next_node_name": "Lost",
1485
- "forward": "Report Lost"
1486
- },
1487
- "hold": false,
1488
- "message": "Package reported as lost"
1489
- }
1490
- },
1491
- "env": {
1492
- "account": "myshop_customer",
1493
- "network": "testnet",
1494
- "no_cache": true
1495
- }
1496
- }
1497
- ```
1498
-
1499
- **Step 8.2: Merchant Confirms Lost**
1500
-
1501
- ```json
1502
- {
1503
- "operation_type": "progress",
1504
- "data": {
1505
- "object": "myshop_progress_v2",
1506
- "operate": {
1507
- "operation": {
1508
- "next_node_name": "Lost",
1509
- "forward": "Confirm Lost with Merkle Root"
1510
- },
1511
- "hold": false,
1512
- "message": "Lost confirmed with Merkle Root"
1513
- }
1514
- },
1515
- "submission": {
1516
- "type": "submission",
1517
- "guard": [
1518
- {
1519
- "object": "machine_merkle_root_v2",
1520
- "impack": true
1521
- }
1522
- ],
1523
- "submission": [
1524
- {
1525
- "guard": "machine_merkle_root_v2",
1526
- "submission": [
1527
- {
1528
- "identifier": 0,
1529
- "b_submission": true,
1530
- "value_type": "String",
1531
- "value": "0xlost123...merkle456"
1532
- }
1533
- ]
1534
- }
1535
- ]
1536
- },
1537
- "env": {
1538
- "account": "myshop_merchant",
1539
- "network": "testnet",
1540
- "no_cache": true
1541
- }
1542
- }
1543
- ```
1544
-
1545
- **Step 8.3: Claim Lost Compensation**
1546
-
1547
- ```json
1548
- {
1549
- "operation_type": "reward",
1550
- "data": {
1551
- "object": "myshop_reward_v2",
1552
- "claim": {
1553
- "guard": "guard_lost_v2",
1554
- "reward_object": "myshop_order_v2"
1555
- }
1556
- },
1557
- "submission": {
1558
- "type": "submission",
1559
- "guard": [
1560
- {
1561
- "object": "guard_lost_v2",
1562
- "impack": true
1563
- }
1564
- ],
1565
- "submission": [
1566
- {
1567
- "guard": "guard_lost_v2",
1568
- "submission": [
1569
- {
1570
- "identifier": 0,
1571
- "b_submission": true,
1572
- "value_type": "Address",
1573
- "value": "myshop_order_v2"
1574
- }
1575
- ]
1576
- }
1577
- ]
1578
- },
1579
- "env": {
1580
- "account": "myshop_customer",
1581
- "network": "testnet",
1582
- "no_cache": true
1583
- }
1584
- }
1585
- ```
1586
-
1587
- ***
1588
-
1589
- ### Step 9: Return Process (Receipt Return)
1590
-
1591
- Customer requests return after delivery confirmation.
1592
-
1593
- **Step 9.1: Customer Requests Return**
1594
-
1595
- ```json
1596
- {
1597
- "operation_type": "progress",
1598
- "data": {
1599
- "object": "myshop_progress_v2",
1600
- "operate": {
1601
- "operation": {
1602
- "next_node_name": "Receipt Return",
1603
- "forward": "Request Return with Receipt"
1604
- },
1605
- "hold": false,
1606
- "message": "Return requested after delivery"
1607
- }
1608
- },
1609
- "env": {
1610
- "account": "myshop_customer",
1611
- "network": "testnet",
1612
- "no_cache": true
1613
- }
1614
- }
1615
- ```
1616
-
1617
- **Step 9.2: Merchant Confirms Return Address**
1618
-
1619
- ```json
1620
- {
1621
- "operation_type": "progress",
1622
- "data": {
1623
- "object": "myshop_progress_v2",
1624
- "operate": {
1625
- "operation": {
1626
- "next_node_name": "Receipt Return",
1627
- "forward": "Confirm Return Address with Merkle Root"
1628
- },
1629
- "hold": false,
1630
- "message": "Return address confirmed with Merkle Root"
1631
- }
1632
- },
1633
- "submission": {
1634
- "type": "submission",
1635
- "guard": [
1636
- {
1637
- "object": "machine_merkle_root_v2",
1638
- "impack": true
1639
- }
1640
- ],
1641
- "submission": [
1642
- {
1643
- "guard": "machine_merkle_root_v2",
1644
- "submission": [
1645
- {
1646
- "identifier": 0,
1647
- "b_submission": true,
1648
- "value_type": "String",
1649
- "value": "0xreturn789...addr012"
1650
- }
1651
- ]
1652
- }
1653
- ]
1654
- },
1655
- "env": {
1656
- "account": "myshop_merchant",
1657
- "network": "testnet",
1658
- "no_cache": true
1659
- }
1660
- }
1661
- ```
1662
-
1663
- **Step 9.3: Customer Submits Return Merkle Root**
1664
-
1665
- ```json
1666
- {
1667
- "operation_type": "progress",
1668
- "data": {
1669
- "object": "myshop_progress_v2",
1670
- "operate": {
1671
- "operation": {
1672
- "next_node_name": "Return Complete",
1673
- "forward": "Submit Return Merkle Root"
1674
- },
1675
- "hold": false,
1676
- "message": "Return shipping Merkle Root submitted"
1677
- }
1678
- },
1679
- "submission": {
1680
- "type": "submission",
1681
- "guard": [
1682
- {
1683
- "object": "machine_merkle_root_v2",
1684
- "impack": true
1685
- }
1686
- ],
1687
- "submission": [
1688
- {
1689
- "guard": "machine_merkle_root_v2",
1690
- "submission": [
1691
- {
1692
- "identifier": 0,
1693
- "b_submission": true,
1694
- "value_type": "String",
1695
- "value": "0xshipreturn...track345"
1696
- }
1697
- ]
1698
- }
1699
- ]
1700
- },
1701
- "env": {
1702
- "account": "myshop_customer",
1703
- "network": "testnet",
1704
- "no_cache": true
1705
- }
1706
- }
1707
- ```
1708
-
1709
- **Step 9.4: Merchant Confirms Return Received**
1710
-
1711
- ```json
1712
- {
1713
- "operation_type": "progress",
1714
- "data": {
1715
- "object": "myshop_progress_v2",
1716
- "operate": {
1717
- "operation": {
1718
- "next_node_name": "Return Complete",
1719
- "forward": "Confirm Return Received"
1720
- },
1721
- "hold": false,
1722
- "message": "Return received and confirmed"
1723
- }
1724
- },
1725
- "env": {
1726
- "account": "myshop_merchant",
1727
- "network": "testnet",
1728
- "no_cache": true
1729
- }
1730
- }
1731
- ```
1732
-
1733
- ***
1734
-
1735
- ### Step 10: Return Fail (Timeout)
1736
-
1737
- If customer doesn't return within 10 days, merchant can mark as Return Fail.
1738
-
1739
- ```json
1740
- {
1741
- "operation_type": "progress",
1742
- "data": {
1743
- "object": "myshop_progress_v2",
1744
- "operate": {
1745
- "operation": {
1746
- "next_node_name": "Return Fail",
1747
- "forward": "Timeout Return Not Received"
1748
- },
1749
- "hold": false,
1750
- "message": "Return failed - timeout"
1751
- }
1752
- },
1753
- "submission": {
1754
- "type": "submission",
1755
- "guard": [
1756
- {
1757
- "object": "machine_time_10d_v2",
1758
- "impack": true
1759
- }
1760
- ],
1761
- "submission": [
1762
- {
1763
- "guard": "machine_time_10d_v2",
1764
- "submission": [
1765
- {
1766
- "identifier": 0,
1767
- "b_submission": true,
1768
- "value_type": "Address",
1769
- "value": "myshop_progress_v2"
1770
- }
1771
- ]
1772
- }
1773
- ]
1774
- },
1775
- "env": {
1776
- "account": "myshop_merchant",
1777
- "network": "testnet",
1778
- "no_cache": true
1779
- }
1780
- }
1781
- ```
1782
-
1783
- ***
1784
-
1785
- ## Part 4: Fund Allocation
1786
-
1787
- ### Merchant Wins (Order Complete, Wonderful, Return Fail)
1788
-
1789
- When order reaches Order Complete, Wonderful, or Return Fail, merchant can withdraw funds.
1790
-
1791
- **Prompt**: Merchant withdraws funds when winning condition is met.
1792
-
1793
- ```json
1794
- {
1795
- "operation_type": "order",
1796
- "data": {
1797
- "object": "myshop_order_v2",
1798
- "withdraw": {
1799
- "guard": "service_merchant_win_v2"
1800
- }
1801
- },
1802
- "submission": {
1803
- "type": "submission",
1804
- "guard": [
1805
- {
1806
- "object": "service_merchant_win_v2",
1807
- "impack": true
1808
- }
1809
- ],
1810
- "submission": [
1811
- {
1812
- "guard": "service_merchant_win_v2",
1813
- "submission": [
1814
- {
1815
- "identifier": 0,
1816
- "b_submission": true,
1817
- "value_type": "Address",
1818
- "value": "myshop_progress_v2"
1819
- }
1820
- ]
1821
- }
1822
- ]
1823
- },
1824
- "env": {
1825
- "account": "myshop_merchant",
1826
- "network": "testnet",
1827
- "no_cache": true
1828
- }
1829
- }
1830
- ```
1831
-
1832
- ### Customer Wins (Lost, Return Complete)
1833
-
1834
- When order reaches Lost or Return Complete, customer can withdraw funds.
1835
-
1836
- **Prompt**: Customer withdraws funds when winning condition is met.
1837
-
1838
- ```json
1839
- {
1840
- "operation_type": "order",
1841
- "data": {
1842
- "object": "myshop_order_v2",
1843
- "withdraw": {
1844
- "guard": "service_customer_win_v2"
1845
- }
1846
- },
1847
- "submission": {
1848
- "type": "submission",
1849
- "guard": [
1850
- {
1851
- "object": "service_customer_win_v2",
1852
- "impack": true
1853
- }
1854
- ],
1855
- "submission": [
1856
- {
1857
- "guard": "service_customer_win_v2",
1858
- "submission": [
1859
- {
1860
- "identifier": 0,
1861
- "b_submission": true,
1862
- "value_type": "Address",
1863
- "value": "myshop_progress_v2"
1864
- }
1865
- ]
1866
- }
1867
- ]
1868
- },
1869
- "env": {
1870
- "account": "myshop_customer",
1871
- "network": "testnet",
1872
- "no_cache": true
1873
- }
1874
- }
1875
- ```
1876
-
1877
- ***
1878
-
1879
- ## Summary
1880
-
1881
- This advanced e-commerce example demonstrates:
1882
-
1883
- 1. **Multi-Path Workflow**: Orders can complete through normal delivery, wonderful rating, or various return paths
1884
- 2. **Dual-Signature Returns**: Return processes require confirmation from both parties (threshold=2)
1885
- 3. **Time-Based Auto-Completion**: Orders auto-complete after time thresholds (10 days from shipping, 2 days from delivery)
1886
- 4. **Guard-Based Verification**: All state transitions and fund allocations are protected by guards
1887
- 5. **Reward Incentive System**: Wonderful ratings receive rewards, lost packages and shipping delays receive compensation
1888
- 6. **Arbitration Support**: Service binds to Arbitration object for final on-chain dispute resolution
1889
- 7. **Privacy-Preserving Logistics**: Only Merkle Roots are submitted on-chain, actual tracking info is shared via Messenger
1890
- 8. **Flexible Fund Allocation**: Clear rules for merchant win (Order Complete, Wonderful, Return Fail) vs customer win (Lost, Return Complete)
1891
-
1892
- The system ensures accountability through the "Who Completes the Key Action, Who Submits the Proof" principle, creating a clear audit trail for all critical actions.
1893
-
1894
- ***
1895
-
1896
- > **View Actual Execution Results**:
1897
- > - **Merchant System Setup**: See [MyShop\_Advanced\_MerchantSystem\_TestResults.md](MyShop_Advanced_MerchantSystem_TestResults.md) for service construction test results
1898
- > - **Customer Order Flow**: See [MyShop\_Advanced\_OrderFlow\_TestResults.md](MyShop_Advanced_OrderFlow_TestResults.md) for order testing results