@wowok/agent-mcp 2.2.11 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/index.d.ts +3 -0
- package/dist/docs/index.js +2 -0
- package/dist/docs/loader.d.ts +12 -0
- package/dist/docs/loader.js +177 -0
- package/dist/docs/search.d.ts +17 -0
- package/dist/docs/search.js +325 -0
- package/dist/docs/types.d.ts +55 -0
- package/dist/docs/types.js +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +146 -39
- package/docs/README.md +249 -0
- package/docs/WIP.md +388 -0
- package/docs/WTS.md +536 -0
- package/docs/docs/account.md +914 -0
- package/docs/docs/allocation.md +635 -0
- package/docs/docs/arbitration.md +1804 -0
- package/docs/docs/arbitration_state_machine.md +270 -0
- package/docs/docs/contact.md +709 -0
- package/docs/docs/demand.md +948 -0
- package/docs/docs/guard.md +1465 -0
- package/docs/docs/localinfo.md +432 -0
- package/docs/docs/localmark.md +583 -0
- package/docs/docs/machine.md +2490 -0
- package/docs/docs/messenger.md +2098 -0
- package/docs/docs/onchain_events.md +267 -0
- package/docs/docs/order.md +1001 -0
- package/docs/docs/payment.md +512 -0
- package/docs/docs/permission.md +1438 -0
- package/docs/docs/personal.md +742 -0
- package/docs/docs/progress.md +1748 -0
- package/docs/docs/query.md +467 -0
- package/docs/docs/repository.md +1043 -0
- package/docs/docs/reward.md +833 -0
- package/docs/docs/service.md +2130 -0
- package/docs/docs/stage-01-introduction.md +243 -0
- package/docs/docs/stage-02-trust.md +302 -0
- package/docs/docs/stage-03-collaboration.md +337 -0
- package/docs/docs/stage-04-transaction.md +277 -0
- package/docs/docs/stage-05-business.md +151 -0
- package/docs/docs/stage-06-personal.md +203 -0
- package/docs/docs/stage-07-query.md +572 -0
- package/docs/docs/stage-08-examples.md +184 -0
- package/docs/docs/treasury.md +1149 -0
- package/docs/docs/wowok_buildin_info.md +740 -0
- package/docs/examples/Insurance/Insurance.md +594 -0
- package/docs/examples/Insurance/Insurance_TestResults.md +481 -0
- package/docs/examples/Insurance/insurance_complete_guard_v1.json +50 -0
- package/docs/examples/MyShop/MyShop.md +1353 -0
- package/docs/examples/MyShop/MyShop_TestResults.md +1003 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +1898 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +1297 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +743 -0
- package/docs/examples/MyShop_Advanced/machine_nodes.json +222 -0
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +776 -0
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +599 -0
- package/docs/examples/Travel/Travel.md +1157 -0
- package/docs/examples/Travel/Travel_TestResults.md +743 -0
- package/docs/examples/Travel/calc-weather-timestamps.js +8 -0
- package/docs/examples/Travel/travel_machine_v2_export.json +104 -0
- package/docs/examples/Travel/weather_check_guard_v1.json +51 -0
- package/docs/skills/WOWOK.md +650 -0
- package/docs/skills/onchain_operations/_common.md +406 -0
- package/docs/skills/onchain_operations/_index.md +196 -0
- package/docs/skills/onchain_operations/allocation.md +28 -0
- package/docs/skills/onchain_operations/arbitration.md +106 -0
- package/docs/skills/onchain_operations/contact.md +40 -0
- package/docs/skills/onchain_operations/demand.md +53 -0
- package/docs/skills/onchain_operations/gen_passport.md +23 -0
- package/docs/skills/onchain_operations/guard.md +56 -0
- package/docs/skills/onchain_operations/machine.md +89 -0
- package/docs/skills/onchain_operations/order.md +56 -0
- package/docs/skills/onchain_operations/payment.md +24 -0
- package/docs/skills/onchain_operations/permission.md +68 -0
- package/docs/skills/onchain_operations/personal.md +58 -0
- package/docs/skills/onchain_operations/progress.md +38 -0
- package/docs/skills/onchain_operations/repository.md +70 -0
- package/docs/skills/onchain_operations/reward.md +38 -0
- package/docs/skills/onchain_operations/service.md +78 -0
- package/docs/skills/onchain_operations/treasury.md +68 -0
- package/docs/skills/schema-account_operation.md +402 -0
- package/docs/skills/schema-guard2file.md +153 -0
- package/docs/skills/schema-local_info_operation.md +160 -0
- package/docs/skills/schema-local_mark_operation.md +148 -0
- package/docs/skills/schema-machineNode2file.md +155 -0
- package/docs/skills/schema-messenger_operation.md +547 -0
- package/docs/skills/schema-onchain_events.md +201 -0
- package/docs/skills/schema-onchain_table_data.md +334 -0
- package/docs/skills/schema-query_toolkit.md +395 -0
- package/docs/skills/schema-wip_file.md +240 -0
- package/docs/skills/schema-wowok_buildin_info.md +296 -0
- package/docs/wip-examples/three_body.html +57 -0
- package/docs/wip-examples/three_body.wip +30 -0
- package/package.json +3 -2
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
# Insurance Service Example
|
|
2
|
+
|
|
3
|
+
A complete example demonstrating how to create an outdoor accident insurance service using WoWok protocol. This insurance service is designed to be purchased by travel service providers as part of a travel package (supply chain sub-order).
|
|
4
|
+
|
|
5
|
+
> **View Actual Execution Results**: See [Insurance_TestResults.md](Insurance_TestResults.md) for real testnet execution results with actual object addresses and transaction outputs.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Core Requirements & Features
|
|
10
|
+
|
|
11
|
+
| Requirement | Description | Implementation |
|
|
12
|
+
|-------------|-------------|----------------|
|
|
13
|
+
| **Insurance Claims** | Process insurance claims with time-lock verification | Machine with Start -> Complete workflow |
|
|
14
|
+
| **Time-Lock Guard** | Prevent premature claim completion | Guard using Order + convert_witness(TypeOrderProgress) to verify clock > progress.current_time + lock_duration |
|
|
15
|
+
| **Supply Chain Integration** | Support sub-order creation by travel service providers | Order can be created by authorized agents (travel_provider) |
|
|
16
|
+
| **Permission Control** | Role-based access for insurance operations | Permission object with custom indexes for claim processing |
|
|
17
|
+
|
|
18
|
+
### Key Design Decisions
|
|
19
|
+
|
|
20
|
+
1. **Time-Lock via Witness Conversion**: The Complete node Guard uses `convert_witness: 100` (TypeOrderProgress) to convert the submitted Order ID into its associated Progress object, then queries `progress.current_time` to verify the time-lock condition.
|
|
21
|
+
2. **Simple Two-Node Workflow**: Insurance claims follow a straightforward Start -> Complete path, keeping the workflow simple and predictable.
|
|
22
|
+
3. **Order ID as Submission**: The Order ID is submitted at runtime (`b_submission: true`) and used for witness conversion.
|
|
23
|
+
4. **Machine Creation Pattern**: Machine must be created first, then nodes added separately, then published. Creating machine with nodes and publish in one transaction does not work correctly.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
This example demonstrates:
|
|
30
|
+
|
|
31
|
+
- **Insurance Service Setup**: Permission, Guard, Machine, and Service creation
|
|
32
|
+
- **Time-Lock Guard**: Using Order + convert_witness to access Progress data
|
|
33
|
+
- **Workflow Automation**: Machine-driven claim processing
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Architecture
|
|
38
|
+
|
|
39
|
+
### System Components
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
------------------------------------------------------------------
|
|
43
|
+
| Insurance Service System |
|
|
44
|
+
|------------------------------------------------------------------|
|
|
45
|
+
| |
|
|
46
|
+
| +-----------------+ +-----------------+ |
|
|
47
|
+
| | Permission | | Guard | |
|
|
48
|
+
| | (insurance_ | | (insurance_ | |
|
|
49
|
+
| | permission) | | complete_guard)| |
|
|
50
|
+
| +--------+--------+ +--------+--------+ |
|
|
51
|
+
| | | |
|
|
52
|
+
| v v |
|
|
53
|
+
| +-----------------+ +-----------------+ |
|
|
54
|
+
| | Machine | | Service | |
|
|
55
|
+
| | (insurance_ |<---| (insurance_ | |
|
|
56
|
+
| | machine) | | service) | |
|
|
57
|
+
| +-----------------+ +-----------------+ |
|
|
58
|
+
| |
|
|
59
|
+
| Workflow: Start -> Complete (Time-Lock Guard) |
|
|
60
|
+
| |
|
|
61
|
+
------------------------------------------------------------------
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Claim Workflow
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
+----------+ +--------------+
|
|
68
|
+
| Start |-------->| Complete |
|
|
69
|
+
| | | (Time-Lock) |
|
|
70
|
+
+----------+ +--------------+
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Guard Logic**:
|
|
74
|
+
```
|
|
75
|
+
clock > progress.current_time + 1000ms
|
|
76
|
+
(progress accessed via Order + convert_witness=TypeOrderProgress)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Prerequisites
|
|
82
|
+
|
|
83
|
+
Before running this example, ensure you have:
|
|
84
|
+
|
|
85
|
+
1. An account named `insurance_provider_v1` with sufficient WOW tokens
|
|
86
|
+
2. Access to the WoWok MCP server
|
|
87
|
+
|
|
88
|
+
### Create Insurance Provider Account
|
|
89
|
+
|
|
90
|
+
**Prompt**: Create a new account named "insurance_provider_v1" for the insurance service provider.
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"gen": {
|
|
95
|
+
"name": "insurance_provider_v1",
|
|
96
|
+
"replaceExistName": true
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Get Test Tokens
|
|
102
|
+
|
|
103
|
+
**Prompt**: Request testnet WOW tokens for account "insurance_provider_v1".
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"faucet": {
|
|
108
|
+
"network": "testnet",
|
|
109
|
+
"name_or_address": "insurance_provider_v1"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Step 1: Create Permission Object
|
|
117
|
+
|
|
118
|
+
Create a Permission object to manage access control for the insurance service.
|
|
119
|
+
|
|
120
|
+
**Prompt**: Create a Permission object named "insurance_permission" for the insurance service.
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"operation_type": "permission",
|
|
125
|
+
"data": {
|
|
126
|
+
"object": {
|
|
127
|
+
"name": "insurance_permission_v1",
|
|
128
|
+
"replaceExistName": true
|
|
129
|
+
},
|
|
130
|
+
"description": "Permission for outdoor accident insurance service",
|
|
131
|
+
"table": {
|
|
132
|
+
"op": "add perm by entity",
|
|
133
|
+
"entity": {"name_or_address": "insurance_provider_v1"},
|
|
134
|
+
"index": [1000, 1001, 1002, 1003, 1004, 1005]
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"env": {
|
|
138
|
+
"account": "insurance_provider_v1",
|
|
139
|
+
"network": "testnet"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Step 2: Create Time-Lock Complete Guard
|
|
147
|
+
|
|
148
|
+
Create a Guard that verifies the time-lock condition for claim completion. The Guard uses the submitted Order ID with `convert_witness: 100` (TypeOrderProgress) to access the associated Progress object and query `progress.current_time`.
|
|
149
|
+
|
|
150
|
+
**Guard Logic**:
|
|
151
|
+
```
|
|
152
|
+
clock > progress.current_time + 1000
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Prompt**: Create a Guard named "insurance_complete_guard" for time-lock verification on claim completion.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"operation_type": "guard",
|
|
160
|
+
"data": {
|
|
161
|
+
"namedNew": {
|
|
162
|
+
"name": "insurance_complete_guard_v1",
|
|
163
|
+
"tags": ["insurance", "time-lock", "complete"],
|
|
164
|
+
"replaceExistName": true
|
|
165
|
+
},
|
|
166
|
+
"description": "Time-lock guard for insurance claim completion. Requires current clock > progress.current_time + 1000ms (1 second for TESTING; in production set to reasonable duration like 8 hours). Progress is accessed via Order with convert_witness=TypeOrderProgress(100).",
|
|
167
|
+
"table": [
|
|
168
|
+
{
|
|
169
|
+
"identifier": 0,
|
|
170
|
+
"b_submission": true,
|
|
171
|
+
"value_type": "Address",
|
|
172
|
+
"value": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
173
|
+
"name": "Order ID (submitted at runtime)"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"identifier": 1,
|
|
177
|
+
"b_submission": false,
|
|
178
|
+
"value_type": "U64",
|
|
179
|
+
"value": 1000
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"root": {
|
|
183
|
+
"type": "node",
|
|
184
|
+
"node": {
|
|
185
|
+
"type": "logic_as_u256_greater",
|
|
186
|
+
"nodes": [
|
|
187
|
+
{
|
|
188
|
+
"type": "context",
|
|
189
|
+
"context": "Clock"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "calc_number_add",
|
|
193
|
+
"nodes": [
|
|
194
|
+
{
|
|
195
|
+
"type": "query",
|
|
196
|
+
"query": "progress.current_time",
|
|
197
|
+
"object": {
|
|
198
|
+
"identifier": 0,
|
|
199
|
+
"convert_witness": 100
|
|
200
|
+
},
|
|
201
|
+
"parameters": []
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"type": "identifier",
|
|
205
|
+
"identifier": 1
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"env": {
|
|
214
|
+
"account": "insurance_provider_v1",
|
|
215
|
+
"network": "testnet"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Guard Table**:
|
|
221
|
+
|
|
222
|
+
| identifier | b_submission | value_type | value | Purpose |
|
|
223
|
+
|------------|-------------|-----------|-------|---------|
|
|
224
|
+
| 0 | **true** | Address | 0x0...0 (placeholder) | Order ID submitted at runtime, converted to Progress via convert_witness |
|
|
225
|
+
| 1 | false | U64 | 1000 | Time-lock duration in ms (1 second for testing) |
|
|
226
|
+
|
|
227
|
+
> **Important**: `1000` ms (1 second) is for testing only. In production, set to a reasonable duration (e.g., 8 hours = 28800000 ms).
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Step 3: Create Withdraw Guard for Order Allocators
|
|
232
|
+
|
|
233
|
+
Create a Guard that allows the insurance provider to withdraw funds after the order reaches the Complete node.
|
|
234
|
+
|
|
235
|
+
**Prompt**: Create a Guard named "insurance_withdraw_guard" for order fund allocation.
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"operation_type": "guard",
|
|
240
|
+
"data": {
|
|
241
|
+
"namedNew": {
|
|
242
|
+
"name": "insurance_withdraw_guard_v1",
|
|
243
|
+
"tags": ["insurance", "withdraw"],
|
|
244
|
+
"replaceExistName": true
|
|
245
|
+
},
|
|
246
|
+
"description": "Allow insurance provider to withdraw funds after order is completed.",
|
|
247
|
+
"table": [
|
|
248
|
+
{
|
|
249
|
+
"identifier": 0,
|
|
250
|
+
"b_submission": true,
|
|
251
|
+
"value_type": "Address",
|
|
252
|
+
"name": "order_id"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"identifier": 1,
|
|
256
|
+
"b_submission": false,
|
|
257
|
+
"value_type": "String",
|
|
258
|
+
"value": "Complete",
|
|
259
|
+
"name": "complete_node"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"root": {
|
|
263
|
+
"type": "node",
|
|
264
|
+
"node": {
|
|
265
|
+
"type": "logic_equal",
|
|
266
|
+
"nodes": [
|
|
267
|
+
{
|
|
268
|
+
"type": "query",
|
|
269
|
+
"query": "progress.current",
|
|
270
|
+
"object": {
|
|
271
|
+
"identifier": 0,
|
|
272
|
+
"convert_witness": 100
|
|
273
|
+
},
|
|
274
|
+
"parameters": []
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"type": "identifier",
|
|
278
|
+
"identifier": 1
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"env": {
|
|
285
|
+
"account": "insurance_provider_v1",
|
|
286
|
+
"network": "testnet"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Step 4: Create, Configure and Publish Machine
|
|
294
|
+
|
|
295
|
+
Create a Machine with workflow nodes and publish it in a single transaction. **IMPORTANT**: Machine nodes must be added during creation (in the same transaction) before publishing. Adding nodes after creation in separate transactions may not persist correctly.
|
|
296
|
+
|
|
297
|
+
**Prompt**: Create a Machine named "insurance_machine" with the claim processing workflow and publish it.
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"operation_type": "machine",
|
|
302
|
+
"data": {
|
|
303
|
+
"object": {
|
|
304
|
+
"name": "insurance_machine_v1",
|
|
305
|
+
"permission": "insurance_permission_v1",
|
|
306
|
+
"replaceExistName": true
|
|
307
|
+
},
|
|
308
|
+
"description": "Insurance claim processing workflow: Start -> Complete (with time-lock guard)",
|
|
309
|
+
"node": {
|
|
310
|
+
"op": "add",
|
|
311
|
+
"nodes": [
|
|
312
|
+
{
|
|
313
|
+
"name": "Start",
|
|
314
|
+
"pairs": [
|
|
315
|
+
{
|
|
316
|
+
"prev_node": "",
|
|
317
|
+
"threshold": 0,
|
|
318
|
+
"forwards": [
|
|
319
|
+
{
|
|
320
|
+
"name": "start_claim",
|
|
321
|
+
"permissionIndex": 1000,
|
|
322
|
+
"weight": 1
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "Complete",
|
|
330
|
+
"pairs": [
|
|
331
|
+
{
|
|
332
|
+
"prev_node": "Start",
|
|
333
|
+
"threshold": 1,
|
|
334
|
+
"forwards": [
|
|
335
|
+
{
|
|
336
|
+
"name": "complete_claim",
|
|
337
|
+
"permissionIndex": 1001,
|
|
338
|
+
"weight": 1,
|
|
339
|
+
"guard": {
|
|
340
|
+
"guard": "insurance_complete_guard_v1"
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
"publish": true
|
|
350
|
+
},
|
|
351
|
+
"env": {
|
|
352
|
+
"account": "insurance_provider_v1",
|
|
353
|
+
"network": "testnet"
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Workflow Nodes**:
|
|
359
|
+
|
|
360
|
+
| Node | Forward | Guard | Description |
|
|
361
|
+
|------|---------|-------|-------------|
|
|
362
|
+
| Start | start_claim -> Start | - | Enter the Start node from initial state |
|
|
363
|
+
| Complete | complete_claim -> Complete | insurance_complete_guard_v1 | Complete the claim after time-lock verification |
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Step 7: Create and Publish Service
|
|
368
|
+
|
|
369
|
+
Create the insurance service with machine, order_allocators, sales, and publish in a single transaction.
|
|
370
|
+
|
|
371
|
+
> **Important**: Service must include `order_allocators` when publishing. After publishing, `machine`, `order_allocators`, and `arbitrations` become immutable.
|
|
372
|
+
|
|
373
|
+
**Prompt**: Create and publish a Service named "insurance_service" with machine, order allocation, and insurance product.
|
|
374
|
+
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"operation_type": "service",
|
|
378
|
+
"data": {
|
|
379
|
+
"object": {
|
|
380
|
+
"name": "insurance_service_v1",
|
|
381
|
+
"type_parameter": "0x2::wow::WOW",
|
|
382
|
+
"permission": "insurance_permission_v1",
|
|
383
|
+
"replaceExistName": true
|
|
384
|
+
},
|
|
385
|
+
"description": "Outdoor accident insurance for Iceland travel. Provides coverage for ice scooting and other outdoor activities.",
|
|
386
|
+
"machine": "insurance_machine_v1",
|
|
387
|
+
"order_allocators": {
|
|
388
|
+
"description": "Insurance order revenue allocation",
|
|
389
|
+
"threshold": 0,
|
|
390
|
+
"allocators": [
|
|
391
|
+
{
|
|
392
|
+
"guard": "insurance_withdraw_guard_v1",
|
|
393
|
+
"sharing": [
|
|
394
|
+
{
|
|
395
|
+
"who": {"Signer": "signer"},
|
|
396
|
+
"sharing": 10000,
|
|
397
|
+
"mode": "Rate"
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
"sales": {
|
|
404
|
+
"op": "add",
|
|
405
|
+
"sales": [
|
|
406
|
+
{
|
|
407
|
+
"name": "Outdoor Accident Insurance",
|
|
408
|
+
"price": 100000000,
|
|
409
|
+
"stock": 1000,
|
|
410
|
+
"suspension": false,
|
|
411
|
+
"wip": "",
|
|
412
|
+
"wip_hash": ""
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
"publish": true
|
|
417
|
+
},
|
|
418
|
+
"env": {
|
|
419
|
+
"account": "insurance_provider_v1",
|
|
420
|
+
"network": "testnet"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Step 8: Unpause Service
|
|
428
|
+
|
|
429
|
+
Unpause the service to allow order creation.
|
|
430
|
+
|
|
431
|
+
**Prompt**: Unpause "insurance_service".
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"operation_type": "service",
|
|
436
|
+
"data": {
|
|
437
|
+
"object": "insurance_service",
|
|
438
|
+
"pause": false
|
|
439
|
+
},
|
|
440
|
+
"env": {
|
|
441
|
+
"account": "insurance_provider_v1",
|
|
442
|
+
"network": "testnet"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Step 9: Verify Service Configuration
|
|
450
|
+
|
|
451
|
+
Query the service to verify all configurations are correct.
|
|
452
|
+
|
|
453
|
+
**Prompt**: Query "insurance_service" to verify configuration.
|
|
454
|
+
|
|
455
|
+
```json
|
|
456
|
+
{
|
|
457
|
+
"query_type": "onchain_objects",
|
|
458
|
+
"objects": ["insurance_service"]
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Step 10: Test Order Creation and Progress
|
|
465
|
+
|
|
466
|
+
### 10.1 Create Insurance Order
|
|
467
|
+
|
|
468
|
+
Create an order on the insurance service using the `order_new` field of the `service` operation. In production, this would be done by the travel service provider as a supply chain sub-order.
|
|
469
|
+
|
|
470
|
+
**Prompt**: Create an order on "insurance_service" using account "insurance_provider".
|
|
471
|
+
|
|
472
|
+
```json
|
|
473
|
+
{
|
|
474
|
+
"operation_type": "service",
|
|
475
|
+
"data": {
|
|
476
|
+
"object": "insurance_service",
|
|
477
|
+
"order_new": {
|
|
478
|
+
"buy": {
|
|
479
|
+
"items": [
|
|
480
|
+
{
|
|
481
|
+
"name": "Outdoor Accident Insurance",
|
|
482
|
+
"stock": 1,
|
|
483
|
+
"wip_hash": ""
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
"total_pay": {
|
|
487
|
+
"balance": 100000000
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
"namedNewOrder": {
|
|
491
|
+
"name": "test_insurance_order_v1",
|
|
492
|
+
"replaceExistName": true
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
"env": {
|
|
497
|
+
"account": "insurance_provider_v1",
|
|
498
|
+
"network": "testnet"
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### 10.2 Advance Progress: Initial -> Start
|
|
504
|
+
|
|
505
|
+
First, advance the progress from initial state to Start node.
|
|
506
|
+
|
|
507
|
+
**Prompt**: Advance progress to Start node.
|
|
508
|
+
|
|
509
|
+
```json
|
|
510
|
+
{
|
|
511
|
+
"operation_type": "progress",
|
|
512
|
+
"data": {
|
|
513
|
+
"object": "<insurance_progress_id>",
|
|
514
|
+
"operate": {
|
|
515
|
+
"operation": {
|
|
516
|
+
"next_node_name": "Start",
|
|
517
|
+
"forward": "start_claim"
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
"env": {
|
|
522
|
+
"account": "insurance_provider_v1",
|
|
523
|
+
"network": "testnet"
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### 10.3 Advance Progress: Start -> Complete
|
|
529
|
+
|
|
530
|
+
Wait at least 1 second after entering Start node, then advance the progress to Complete with the Order ID as submission.
|
|
531
|
+
|
|
532
|
+
**Prompt**: Advance progress to Complete, submitting the Order ID. Wait 1 second before executing.
|
|
533
|
+
|
|
534
|
+
```json
|
|
535
|
+
{
|
|
536
|
+
"operation_type": "progress",
|
|
537
|
+
"data": {
|
|
538
|
+
"object": "<insurance_progress_id>",
|
|
539
|
+
"operate": {
|
|
540
|
+
"operation": {
|
|
541
|
+
"next_node_name": "Complete",
|
|
542
|
+
"forward": "complete_claim"
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
"env": {
|
|
547
|
+
"account": "insurance_provider_v1",
|
|
548
|
+
"network": "testnet"
|
|
549
|
+
},
|
|
550
|
+
"submission": {
|
|
551
|
+
"type": "submission",
|
|
552
|
+
"guard": [
|
|
553
|
+
{
|
|
554
|
+
"object": "insurance_complete_guard_v1",
|
|
555
|
+
"impack": true
|
|
556
|
+
}
|
|
557
|
+
],
|
|
558
|
+
"submission": [
|
|
559
|
+
{
|
|
560
|
+
"guard": "insurance_complete_guard_v1",
|
|
561
|
+
"submission": [
|
|
562
|
+
{
|
|
563
|
+
"identifier": 0,
|
|
564
|
+
"b_submission": true,
|
|
565
|
+
"value_type": "Address",
|
|
566
|
+
"value": "<insurance_order_id>"
|
|
567
|
+
}
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
> **Note**: Replace `<insurance_progress_id>` and `<insurance_order_id>` with actual values from step 10.1.
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## Execution Checklist
|
|
580
|
+
|
|
581
|
+
- [ ] Create `insurance_provider` account
|
|
582
|
+
- [ ] Get test tokens for `insurance_provider`
|
|
583
|
+
- [ ] Step 1: Create `insurance_permission`
|
|
584
|
+
- [ ] Step 2: Create `insurance_complete_guard`
|
|
585
|
+
- [ ] Step 3: Create `insurance_withdraw_guard`
|
|
586
|
+
- [ ] Step 4: Create `insurance_machine` (without nodes)
|
|
587
|
+
- [ ] Step 5: Add nodes to Machine (Start, Complete)
|
|
588
|
+
- [ ] Step 6: Publish Machine
|
|
589
|
+
- [ ] Step 7: Create and publish `insurance_service` (with machine, order_allocators, sales)
|
|
590
|
+
- [ ] Step 8: Unpause Service
|
|
591
|
+
- [ ] Step 9: Verify Service configuration
|
|
592
|
+
- [ ] Step 10.1: Create test insurance order
|
|
593
|
+
- [ ] Step 10.2: Advance progress Initial -> Start
|
|
594
|
+
- [ ] Step 10.3: Wait 1s, then advance progress Start -> Complete
|