@wowok/skills 1.1.9 → 1.1.10
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/LICENSE +36 -0
- package/README.md +1 -8
- package/examples/Insurance/Insurance.md +218 -90
- package/examples/MyShop/MyShop.md +513 -245
- package/examples/MyShop/myshop_machine_nodes.json +87 -0
- package/examples/MyShop_Advanced/MyShop_Advanced.md +633 -228
- package/examples/ThreeBody_Signature/ThreeBody_Signature.md +195 -202
- package/examples/Travel/Travel.md +775 -487
- package/examples/Travel/calc-weather-timestamps.js +9 -5
- package/package.json +4 -3
- package/wowok-tools/SKILL.md +21 -0
- package/examples/Insurance/Insurance_TestResults.md +0 -481
- package/examples/Insurance/insurance_complete_guard_v1.json +0 -50
- package/examples/MyShop/MyShop_TestResults.md +0 -1003
- package/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
- package/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
- package/examples/MyShop_Advanced/machine_nodes.json +0 -222
- package/examples/MyShop_Advanced/three_body_signature.wip +0 -30
- package/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
- package/examples/Travel/Travel_TestResults.md +0 -743
- package/examples/Travel/travel_machine_v2_export.json +0 -104
- package/examples/Travel/weather_check_guard_v1.json +0 -51
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
const DAY_MS = 86400000; // 24 * 60 * 60 * 1000
|
|
2
2
|
const now = Date.now();
|
|
3
|
-
|
|
3
|
+
// Align to UTC 00:00:00 of today, then compute the next 5 days.
|
|
4
|
+
// Repository data is keyed by timestamp, so the submitted activity date
|
|
5
|
+
// must match exactly the id used when adding weather data.
|
|
6
|
+
const todayStart = Math.floor(now / DAY_MS) * DAY_MS;
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
// Future 5 days UTC day-start timestamps (for testing weather-dependent activities)
|
|
9
|
+
for (let i = 1; i <= 5; i++) {
|
|
10
|
+
const ts = todayStart + i * DAY_MS;
|
|
11
|
+
console.log(`Day ${i}: ${ts} (${new Date(ts).toISOString()})`);
|
|
8
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wowok/skills",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "WoWok AI Skills for Claude and other AI assistants - Helping AI use WoWok MCP tools correctly",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"wowok-output/",
|
|
21
21
|
"examples/",
|
|
22
22
|
"scripts/install.js",
|
|
23
|
-
"README.md"
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "tsc",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"ai-agent"
|
|
41
42
|
],
|
|
42
43
|
"author": "wowok <build@wowok.net>",
|
|
43
|
-
"license": "
|
|
44
|
+
"license": "MIT",
|
|
44
45
|
"repository": {
|
|
45
46
|
"type": "git",
|
|
46
47
|
"url": "https://github.com/wowok-ai/skills.git"
|
package/wowok-tools/SKILL.md
CHANGED
|
@@ -95,6 +95,27 @@ Ordered Guard evaluation where **the first Guard returning `true` wins** applies
|
|
|
95
95
|
- `allocation`: evaluated modes (Amount → Rate → Surplus)
|
|
96
96
|
- `demand`: presenter submission filtering
|
|
97
97
|
|
|
98
|
+
### Object-Guard Circular Reference Pattern
|
|
99
|
+
|
|
100
|
+
When an object and its Guard need to reference each other (Guard queries the object it protects), follow this **universal three-step pattern**:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
1. CREATE object (without Guard)
|
|
104
|
+
2. CREATE Guard (reference object by NAME in table)
|
|
105
|
+
3. MODIFY object (bind Guard by name)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Applies to all:** Service, Machine, Reward, Repository, Treasury, Demand, Arbitration — any object with Guard fields.
|
|
109
|
+
|
|
110
|
+
**Key point:** Guards are immutable and require the target object's address in their table. Use the object's **name** (string) as the table value; the SDK resolves it to the actual address at runtime.
|
|
111
|
+
|
|
112
|
+
**Example (Reward):**
|
|
113
|
+
```
|
|
114
|
+
Step 1: CREATE reward { name: "reward_v1" } // no guard
|
|
115
|
+
Step 2: CREATE guard { table: [{ value: "reward_v1", ... }] } // name reference
|
|
116
|
+
Step 3: MODIFY reward { object: "reward_v1", guard_add: [...] } // bind guard
|
|
117
|
+
```
|
|
118
|
+
|
|
98
119
|
---
|
|
99
120
|
|
|
100
121
|
## The 13 Tools
|
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
# Insurance Service Example - Test Results
|
|
2
|
-
|
|
3
|
-
This document records the actual execution results of the Insurance example on the WoWok testnet.
|
|
4
|
-
|
|
5
|
-
## Test Environment
|
|
6
|
-
- **Network**: testnet
|
|
7
|
-
- **Test Date**: 2026-05-03
|
|
8
|
-
- **SDK Version**: WoWok TypeScript SDK (local build)
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
This example demonstrates an outdoor accident insurance service with time-lock completion guards. The service uses a simple two-node workflow (Start -> Complete) where the completion requires a time-lock guard to prevent premature order finalization.
|
|
13
|
-
|
|
14
|
-
## Key Object Addresses
|
|
15
|
-
|
|
16
|
-
| Object Type | Name | Object Address |
|
|
17
|
-
|-------------|------|----------------|
|
|
18
|
-
| Permission | insurance_permission_v1 | 0x93221f078e5aff1bab5f6486f9a0922268c3734a1ed5a9535109439bb7dd17e4 |
|
|
19
|
-
| Guard (Complete) | insurance_complete_guard_v1 | 0x3c07695d6f01c875c718bef8fae78cdf9ee19bcb174a9b35bb6213c29816f200 |
|
|
20
|
-
| Guard (Withdraw) | insurance_withdraw_guard_v1 | 0xc736a8296bd502aeae7802aadaf9a8d194ce2d498f5a1ed8fe63c33981f523b3 |
|
|
21
|
-
| Machine | insurance_machine_v1 | 0xd66d95bc0ed855ba0c0a650368f025871f817ca2145d6ea09b9566a2f17f74b3 |
|
|
22
|
-
| Service | insurance_service_v1 | 0x161b4a7398dd2fca54559e924c7f1619169f88e81c36bbad06ebb2931f5f2e32 |
|
|
23
|
-
| Test Order | test_insurance_order_v1 | 0xf0809ed1ee30e4d7cf1e8fc91c00e70e2d219f6d447aaa633b28a8d83f9ea243 |
|
|
24
|
-
| Progress | - | 0x5d06b916e8d6ce8fb75ad2b46426335c297d890d60a99cdbc8c59c6616ab0f8c |
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Part 1: Merchant System Setup - Actual Execution Results
|
|
29
|
-
|
|
30
|
-
### Create Merchant Account and Get Test Tokens
|
|
31
|
-
|
|
32
|
-
**Create Account:**
|
|
33
|
-
```json
|
|
34
|
-
{
|
|
35
|
-
"gen": {
|
|
36
|
-
"name": "insurance_provider_v1",
|
|
37
|
-
"replaceExistName": true
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**Execution Result:**
|
|
43
|
-
```json
|
|
44
|
-
{
|
|
45
|
-
"gen": {
|
|
46
|
-
"address": "0xda54ebfdbeecec5cae8ae8cdb2d0bf741dfc4e1051c0b4c7bb9968b441067e02",
|
|
47
|
-
"name": "insurance_provider_v1"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**Get Test Tokens:**
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"faucet": {
|
|
56
|
-
"network": "testnet",
|
|
57
|
-
"name_or_address": "insurance_provider_v1"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Execution Result:** Successfully received 5 WOW tokens (5,000,000,000 MIST).
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
### Step 1: Create Permission Object
|
|
67
|
-
|
|
68
|
-
**Prompt:**
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"operation_type": "permission",
|
|
72
|
-
"data": {
|
|
73
|
-
"object": {
|
|
74
|
-
"name": "insurance_permission_v1",
|
|
75
|
-
"tags": ["insurance", "outdoor", "accident"],
|
|
76
|
-
"replaceExistName": true
|
|
77
|
-
},
|
|
78
|
-
"description": "Permission for outdoor accident insurance service"
|
|
79
|
-
},
|
|
80
|
-
"env": {
|
|
81
|
-
"account": "insurance_provider_v1",
|
|
82
|
-
"network": "testnet"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**Execution Result:**
|
|
88
|
-
- **Object Address**: 0x93221f078e5aff1bab5f6486f9a0922268c3734a1ed5a9535109439bb7dd17e4
|
|
89
|
-
- **Transaction**: 58gPUwgwM6npS7cs5XbpmCg7SVoTodE8PpTCMLYAMt6m
|
|
90
|
-
- **Status**: Success
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
### Step 2: Create Insurance Complete Guard (Time-Lock)
|
|
95
|
-
|
|
96
|
-
**Guard Definition** (`insurance_complete_guard_v1.json`):
|
|
97
|
-
```json
|
|
98
|
-
{
|
|
99
|
-
"namedNew": {
|
|
100
|
-
"name": "insurance_complete_guard_v1",
|
|
101
|
-
"tags": ["insurance", "complete", "time-lock"],
|
|
102
|
-
"replaceExistName": true
|
|
103
|
-
},
|
|
104
|
-
"description": "Time-lock guard for insurance claim completion",
|
|
105
|
-
"table": [
|
|
106
|
-
{
|
|
107
|
-
"identifier": 0,
|
|
108
|
-
"b_submission": true,
|
|
109
|
-
"value_type": "Address",
|
|
110
|
-
"name": "Order ID (submitted at runtime)"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"identifier": 1,
|
|
114
|
-
"b_submission": false,
|
|
115
|
-
"value_type": "U64",
|
|
116
|
-
"value": "1000",
|
|
117
|
-
"name": "Time-lock duration in ms"
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"root": {
|
|
121
|
-
"type": "logic_as_u256_greater",
|
|
122
|
-
"nodes": [
|
|
123
|
-
{
|
|
124
|
-
"type": "context",
|
|
125
|
-
"context": "Clock"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"type": "calc_number_add",
|
|
129
|
-
"nodes": [
|
|
130
|
-
{
|
|
131
|
-
"type": "query",
|
|
132
|
-
"query": "progress.current_time",
|
|
133
|
-
"object": {
|
|
134
|
-
"identifier": 0,
|
|
135
|
-
"convert_witness": 100
|
|
136
|
-
},
|
|
137
|
-
"parameters": []
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"type": "identifier",
|
|
141
|
-
"identifier": 1
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
**Key Design Pattern**: Uses `convert_witness: 100` (WitnessType.TypeOrderProgress) to convert the submitted Order ID to access its associated Progress object's `current_time` field.
|
|
151
|
-
|
|
152
|
-
**Execution Result:**
|
|
153
|
-
- **Object Address**: 0x3c07695d6f01c875c718bef8fae78cdf9ee19bcb174a9b35bb6213c29816f200
|
|
154
|
-
- **Transaction**: Bi6ykn7kewLsAjhUGLMKeErVJ9J7yvm8UsW78Y7F9We1
|
|
155
|
-
- **Status**: Success
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
### Step 3: Create Insurance Withdraw Guard
|
|
160
|
-
|
|
161
|
-
**Guard Definition** (`insurance_withdraw_guard_v1.json`):
|
|
162
|
-
```json
|
|
163
|
-
{
|
|
164
|
-
"namedNew": {
|
|
165
|
-
"name": "insurance_withdraw_guard_v1",
|
|
166
|
-
"tags": ["insurance", "withdraw"],
|
|
167
|
-
"replaceExistName": true
|
|
168
|
-
},
|
|
169
|
-
"description": "Allow insurance provider to withdraw funds after order is completed.",
|
|
170
|
-
"table": [
|
|
171
|
-
{
|
|
172
|
-
"identifier": 0,
|
|
173
|
-
"b_submission": true,
|
|
174
|
-
"value_type": "Address",
|
|
175
|
-
"name": "order_id"
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
"identifier": 1,
|
|
179
|
-
"b_submission": false,
|
|
180
|
-
"value_type": "String",
|
|
181
|
-
"value": "Complete",
|
|
182
|
-
"name": "complete_node"
|
|
183
|
-
}
|
|
184
|
-
],
|
|
185
|
-
"root": {
|
|
186
|
-
"type": "logic_equal",
|
|
187
|
-
"nodes": [
|
|
188
|
-
{
|
|
189
|
-
"type": "query",
|
|
190
|
-
"query": "progress.current",
|
|
191
|
-
"object": {
|
|
192
|
-
"identifier": 0,
|
|
193
|
-
"convert_witness": 100
|
|
194
|
-
},
|
|
195
|
-
"parameters": []
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"type": "identifier",
|
|
199
|
-
"identifier": 1
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
**Execution Result:**
|
|
207
|
-
- **Object Address**: 0xc736a8296bd502aeae7802aadaf9a8d194ce2d498f5a1ed8fe63c33981f523b3
|
|
208
|
-
- **Transaction**: FrL3z1jExLrs652vFr12faL9Xb5XMzh9vT9hZWPdgJyz
|
|
209
|
-
- **Status**: Success
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
### Step 4: Create Insurance Machine
|
|
214
|
-
|
|
215
|
-
**Prompt:**
|
|
216
|
-
```json
|
|
217
|
-
{
|
|
218
|
-
"operation_type": "machine",
|
|
219
|
-
"data": {
|
|
220
|
-
"object": {
|
|
221
|
-
"name": "insurance_machine_v1",
|
|
222
|
-
"permission": "insurance_permission_v1",
|
|
223
|
-
"replaceExistName": true
|
|
224
|
-
},
|
|
225
|
-
"description": "Insurance claim processing workflow: Start -> Complete (with time-lock guard)",
|
|
226
|
-
"node": {
|
|
227
|
-
"op": "add",
|
|
228
|
-
"data": [
|
|
229
|
-
{
|
|
230
|
-
"name": "Start",
|
|
231
|
-
"pairs": [
|
|
232
|
-
{
|
|
233
|
-
"prev_node": "",
|
|
234
|
-
"forwards": [
|
|
235
|
-
{
|
|
236
|
-
"name": "claim",
|
|
237
|
-
"guard": [],
|
|
238
|
-
"next_node_name": "Complete"
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
"name": "Complete",
|
|
246
|
-
"pairs": [
|
|
247
|
-
{
|
|
248
|
-
"prev_node": "Start",
|
|
249
|
-
"forwards": [
|
|
250
|
-
{
|
|
251
|
-
"name": "complete_claim",
|
|
252
|
-
"guard": ["insurance_complete_guard_v1"],
|
|
253
|
-
"next_node_name": ""
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
}
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
},
|
|
261
|
-
"publish": true
|
|
262
|
-
},
|
|
263
|
-
"env": {
|
|
264
|
-
"account": "insurance_provider_v1",
|
|
265
|
-
"network": "testnet"
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**Execution Result:**
|
|
271
|
-
- **Object Address**: 0xd66d95bc0ed855ba0c0a650368f025871f817ca2145d6ea09b9566a2f17f74b3
|
|
272
|
-
- **Transaction**: BBjtFHkZQc7ag4uHziGNmB719g9w4vMNRX4j1AB4EQMq
|
|
273
|
-
- **Status**: Success
|
|
274
|
-
- **Node Count**: 2
|
|
275
|
-
- **Published**: Yes
|
|
276
|
-
|
|
277
|
-
---
|
|
278
|
-
|
|
279
|
-
### Step 5: Create Insurance Service
|
|
280
|
-
|
|
281
|
-
**Prompt:**
|
|
282
|
-
```json
|
|
283
|
-
{
|
|
284
|
-
"operation_type": "service",
|
|
285
|
-
"data": {
|
|
286
|
-
"object": {
|
|
287
|
-
"name": "insurance_service_v1",
|
|
288
|
-
"permission": "insurance_permission_v1",
|
|
289
|
-
"replaceExistName": true
|
|
290
|
-
},
|
|
291
|
-
"description": "Outdoor accident insurance for Iceland travel. Provides coverage for ice scooting and other outdoor activities.",
|
|
292
|
-
"machine": "insurance_machine_v1",
|
|
293
|
-
"sales": [
|
|
294
|
-
{
|
|
295
|
-
"name": "Outdoor Accident Insurance",
|
|
296
|
-
"price": "100000000",
|
|
297
|
-
"stock": "999"
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
"order_allocators": {
|
|
301
|
-
"description": "Insurance order revenue allocation",
|
|
302
|
-
"threshold": "0",
|
|
303
|
-
"allocators": [
|
|
304
|
-
{
|
|
305
|
-
"guard": "insurance_withdraw_guard_v1",
|
|
306
|
-
"sharing": [
|
|
307
|
-
{
|
|
308
|
-
"who": "Signer",
|
|
309
|
-
"sharing": "10000",
|
|
310
|
-
"mode": 1
|
|
311
|
-
}
|
|
312
|
-
],
|
|
313
|
-
"fix": "0",
|
|
314
|
-
"max": null
|
|
315
|
-
}
|
|
316
|
-
]
|
|
317
|
-
},
|
|
318
|
-
"publish": true
|
|
319
|
-
},
|
|
320
|
-
"env": {
|
|
321
|
-
"account": "insurance_provider_v1",
|
|
322
|
-
"network": "testnet"
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
**Execution Result:**
|
|
328
|
-
- **Object Address**: 0x161b4a7398dd2fca54559e924c7f1619169f88e81c36bbad06ebb2931f5f2e32
|
|
329
|
-
- **Transaction**: ju5K75sakrHsWnSLDv42kNTE37Q9LKF3Ue9ML9c2taT
|
|
330
|
-
- **Status**: Success
|
|
331
|
-
- **Published**: Yes
|
|
332
|
-
- **Paused**: No
|
|
333
|
-
|
|
334
|
-
---
|
|
335
|
-
|
|
336
|
-
### Step 6: Unpause Service
|
|
337
|
-
|
|
338
|
-
The service was already unpaused after creation. Verified configuration:
|
|
339
|
-
- **Service Status**: Active
|
|
340
|
-
- **Machine Bound**: insurance_machine_v1
|
|
341
|
-
- **Sales**: 1 item available
|
|
342
|
-
- **Order Allocators**: 1 allocator configured
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
## Part 2: Order Workflow Test
|
|
347
|
-
|
|
348
|
-
### Test Order Creation
|
|
349
|
-
|
|
350
|
-
**Prompt:**
|
|
351
|
-
```json
|
|
352
|
-
{
|
|
353
|
-
"operation_type": "order",
|
|
354
|
-
"data": {
|
|
355
|
-
"object": {
|
|
356
|
-
"name": "test_insurance_order_v1",
|
|
357
|
-
"replaceExistName": true
|
|
358
|
-
},
|
|
359
|
-
"service": "insurance_service_v1",
|
|
360
|
-
"item": {
|
|
361
|
-
"name": "Outdoor Accident Insurance",
|
|
362
|
-
"price": "100000000",
|
|
363
|
-
"quantity": 1
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
"env": {
|
|
367
|
-
"account": "insurance_provider_v1",
|
|
368
|
-
"network": "testnet"
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
**Execution Result:**
|
|
374
|
-
- **Order Address**: 0xf0809ed1ee30e4d7cf1e8fc91c00e70e2d219f6d447aaa633b28a8d83f9ea243
|
|
375
|
-
- **Progress Address**: 0x5d06b916e8d6ce8fb75ad2b46426335c297d890d60a99cdbc8c59c6616ab0f8c
|
|
376
|
-
- **Transaction**: ju5K75sakrHsWnSLDv42kNTE37Q9LKF3Ue9ML9c2taT
|
|
377
|
-
- **Amount**: 100,000,000 MIST (0.1 WOW)
|
|
378
|
-
|
|
379
|
-
---
|
|
380
|
-
|
|
381
|
-
### Progress Workflow Test
|
|
382
|
-
|
|
383
|
-
#### Initial -> Start
|
|
384
|
-
**Prompt:**
|
|
385
|
-
```json
|
|
386
|
-
{
|
|
387
|
-
"operation_type": "progress",
|
|
388
|
-
"data": {
|
|
389
|
-
"object": "test_insurance_order_v1",
|
|
390
|
-
"operate": {
|
|
391
|
-
"operation": {
|
|
392
|
-
"next_node_name": "Start",
|
|
393
|
-
"forward": "claim"
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
"env": {
|
|
398
|
-
"account": "insurance_provider_v1",
|
|
399
|
-
"network": "testnet"
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
**Result**: Success - Progress moved from "" to "Start"
|
|
405
|
-
|
|
406
|
-
#### Start -> Complete (Time-Lock Test)
|
|
407
|
-
|
|
408
|
-
**Attempt 1 (Immediate - Should Fail):**
|
|
409
|
-
```json
|
|
410
|
-
{
|
|
411
|
-
"operation_type": "progress",
|
|
412
|
-
"data": {
|
|
413
|
-
"object": "test_insurance_order_v1",
|
|
414
|
-
"operate": {
|
|
415
|
-
"operation": {
|
|
416
|
-
"next_node_name": "Complete",
|
|
417
|
-
"forward": "complete_claim"
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
"submission": {
|
|
422
|
-
"type": "submission",
|
|
423
|
-
"guard": [{"object": "insurance_complete_guard_v1", "impack": true}],
|
|
424
|
-
"submission": [{
|
|
425
|
-
"guard": "insurance_complete_guard_v1",
|
|
426
|
-
"submission": [{
|
|
427
|
-
"identifier": 0,
|
|
428
|
-
"b_submission": true,
|
|
429
|
-
"value_type": "Address",
|
|
430
|
-
"value": "0xf0809ed1ee30e4d7cf1e8fc91c00e70e2d219f6d447aaa633b28a8d83f9ea243"
|
|
431
|
-
}]
|
|
432
|
-
}]
|
|
433
|
-
},
|
|
434
|
-
"env": {
|
|
435
|
-
"account": "insurance_provider_v1",
|
|
436
|
-
"network": "testnet"
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
**Result**: Guard validation failed - Time-lock not yet expired (expected behavior)
|
|
442
|
-
|
|
443
|
-
**Attempt 2 (After 1.5s - Should Succeed):**
|
|
444
|
-
|
|
445
|
-
Waited 1.5 seconds and retried the same operation.
|
|
446
|
-
|
|
447
|
-
**Result**: Success - Progress moved from "Start" to "Complete"
|
|
448
|
-
- **Transaction**: mqLXfDYKwGwJPg3jytvzC9NnPeykSkioV6nKqKgvmFt
|
|
449
|
-
- **Current Node**: Complete
|
|
450
|
-
- **History Count**: 2
|
|
451
|
-
|
|
452
|
-
---
|
|
453
|
-
|
|
454
|
-
## Summary
|
|
455
|
-
|
|
456
|
-
### Test Results
|
|
457
|
-
|
|
458
|
-
| Test Case | Expected | Actual | Status |
|
|
459
|
-
|-----------|----------|--------|--------|
|
|
460
|
-
| Account Creation | Success | Success | ✅ |
|
|
461
|
-
| Permission Creation | Success | Success | ✅ |
|
|
462
|
-
| Guard Creation (Complete) | Success | Success | ✅ |
|
|
463
|
-
| Guard Creation (Withdraw) | Success | Success | ✅ |
|
|
464
|
-
| Machine Creation | Success | Success | ✅ |
|
|
465
|
-
| Service Creation | Success | Success | ✅ |
|
|
466
|
-
| Order Creation | Success | Success | ✅ |
|
|
467
|
-
| Progress: Initial -> Start | Success | Success | ✅ |
|
|
468
|
-
| Progress: Start -> Complete (Immediate) | Fail (Time-Lock) | Failed as expected | ✅ |
|
|
469
|
-
| Progress: Start -> Complete (After 1.5s) | Success | Success | ✅ |
|
|
470
|
-
|
|
471
|
-
### Key Learnings
|
|
472
|
-
|
|
473
|
-
1. **Time-Lock Implementation**: The `convert_witness: 100` (TypeOrderProgress) is essential for accessing Progress data from an Order ID submission.
|
|
474
|
-
|
|
475
|
-
2. **Guard Submission Schema**: Guard submissions require `b_submission` and `value_type` fields to be explicitly specified.
|
|
476
|
-
|
|
477
|
-
3. **Machine Node Structure**: The `prev_node: ""` (empty string) defines the entry point from the initial Progress state.
|
|
478
|
-
|
|
479
|
-
4. **Submission Parameter Location**: Guard submissions must be passed as a top-level `submission` parameter, not nested within `data.operate`.
|
|
480
|
-
|
|
481
|
-
---
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"namedNew": {
|
|
3
|
-
"name": "insurance_complete_guard_v1",
|
|
4
|
-
"tags": ["insurance", "time-lock", "complete"],
|
|
5
|
-
"replaceExistName": true
|
|
6
|
-
},
|
|
7
|
-
"description": "Time-lock guard for insurance claim completion. Requires clock > progress.current_time + 1000ms.",
|
|
8
|
-
"table": [
|
|
9
|
-
{
|
|
10
|
-
"identifier": 0,
|
|
11
|
-
"b_submission": true,
|
|
12
|
-
"value_type": "Address",
|
|
13
|
-
"name": "Order ID (submitted at runtime)"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"identifier": 1,
|
|
17
|
-
"b_submission": false,
|
|
18
|
-
"value_type": "U64",
|
|
19
|
-
"value": 1000,
|
|
20
|
-
"name": "Time-lock duration in ms"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"root": {
|
|
24
|
-
"type": "logic_as_u256_greater",
|
|
25
|
-
"nodes": [
|
|
26
|
-
{
|
|
27
|
-
"type": "context",
|
|
28
|
-
"context": "Clock"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"type": "calc_number_add",
|
|
32
|
-
"nodes": [
|
|
33
|
-
{
|
|
34
|
-
"type": "query",
|
|
35
|
-
"query": 1272,
|
|
36
|
-
"object": {
|
|
37
|
-
"identifier": 0,
|
|
38
|
-
"convert_witness": 100
|
|
39
|
-
},
|
|
40
|
-
"parameters": []
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"type": "identifier",
|
|
44
|
-
"identifier": 1
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
}
|