@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,776 @@
|
|
|
1
|
+
# Three-Body Author Signature Service
|
|
2
|
+
|
|
3
|
+
A complete example demonstrating how to create a service for book signing by the Three-Body author. This service allows customers to request a personalized message (up to 10 characters) on their book, signed by the author.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This example demonstrates:
|
|
10
|
+
|
|
11
|
+
**Service with Buy Guard**: The buy_guard allows you to define various conditions for users to purchase products, such as identity verification, completing KYC, or being on an allowlist. In this example, only the service creator (author) can purchase this service
|
|
12
|
+
|
|
13
|
+
### Key Design Decisions
|
|
14
|
+
|
|
15
|
+
1. **Buy Guard Protection**: Only the author (`three_body_author`) can purchase this service, preventing unauthorized usage
|
|
16
|
+
2. **Simple Two-Node Workflow**: Clear progression from delivery to completion
|
|
17
|
+
3. **WIP Files Optional**: Can use WIP files or empty strings
|
|
18
|
+
4. **Fixed Price**: 888 tokens for the signature service
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
Before running this example, ensure you have:
|
|
25
|
+
|
|
26
|
+
1. **Account Setup**: The `three_body_author` account with sufficient WOW tokens
|
|
27
|
+
2. **Minimum Balance**: At least 1000 WOW for gas fees and service creation
|
|
28
|
+
|
|
29
|
+
### Check Account Balance
|
|
30
|
+
|
|
31
|
+
**Request**:
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"query_type": "account_balance",
|
|
35
|
+
"name_or_address": "three_body_author",
|
|
36
|
+
"network": "testnet"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Actual Result**:
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"address": "0xda123833e96e734815f2f57d52ad463681635c6678cfe113c77dbeee49d7865c",
|
|
44
|
+
"balance": {
|
|
45
|
+
"coinType": "0x2::wow::WOW",
|
|
46
|
+
"totalBalance": "4904827524"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Step 1: Create Permission Object
|
|
54
|
+
|
|
55
|
+
Create a Permission object to manage the service.
|
|
56
|
+
|
|
57
|
+
**Request**:
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"operation_type": "permission",
|
|
61
|
+
"data": {
|
|
62
|
+
"object": {
|
|
63
|
+
"name": "three_body_permission_v2",
|
|
64
|
+
"replaceExistName": true
|
|
65
|
+
},
|
|
66
|
+
"description": "Permission for Three-Body Signature Service v2",
|
|
67
|
+
"table": {
|
|
68
|
+
"op": "add perm by entity",
|
|
69
|
+
"entity": {"name_or_address": "three_body_author"},
|
|
70
|
+
"index": [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 306]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"env": {
|
|
74
|
+
"account": "three_body_author",
|
|
75
|
+
"network": "testnet"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Actual Result**:
|
|
81
|
+
```json
|
|
82
|
+
[{
|
|
83
|
+
"type": "Permission",
|
|
84
|
+
"object": "0xf939b4be49761ef8c30ff19ee874157e2ba1d83ab3a8de4f310443e588d1df99",
|
|
85
|
+
"version": "2195623",
|
|
86
|
+
"change": "created"
|
|
87
|
+
}]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Step 2: Create Buy Guard
|
|
93
|
+
|
|
94
|
+
Create a Guard that verifies the buyer is the service creator (author). This ensures only the author can purchase this service.
|
|
95
|
+
|
|
96
|
+
**Request**:
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"operation_type": "guard",
|
|
100
|
+
"data": {
|
|
101
|
+
"namedNew": {
|
|
102
|
+
"name": "three_body_buy_guard_v2",
|
|
103
|
+
"tags": ["signature", "book", "buy-guard"],
|
|
104
|
+
"replaceExistName": true
|
|
105
|
+
},
|
|
106
|
+
"description": "Verify buyer is the service creator (three_body_author). Only the author can purchase this signature service.",
|
|
107
|
+
"table": [
|
|
108
|
+
{
|
|
109
|
+
"identifier": 0,
|
|
110
|
+
"b_submission": false,
|
|
111
|
+
"value_type": "Address",
|
|
112
|
+
"value": "0xda123833e96e734815f2f57d52ad463681635c6678cfe113c77dbeee49d7865c",
|
|
113
|
+
"name": "author_address"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"root": {
|
|
117
|
+
"type": "node",
|
|
118
|
+
"node": {
|
|
119
|
+
"type": "logic_equal",
|
|
120
|
+
"nodes": [
|
|
121
|
+
{
|
|
122
|
+
"type": "context",
|
|
123
|
+
"context": "Signer"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"type": "identifier",
|
|
127
|
+
"identifier": 0
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"env": {
|
|
134
|
+
"account": "three_body_author",
|
|
135
|
+
"network": "testnet"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Actual Result**:
|
|
141
|
+
```json
|
|
142
|
+
[{
|
|
143
|
+
"type": "Guard",
|
|
144
|
+
"object": "0x2fc0283e55f4322eb602a5370b32e455597e339c74a23ada5d9a4a82f02f7925",
|
|
145
|
+
"version": "2195993",
|
|
146
|
+
"change": "created"
|
|
147
|
+
}]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Step 3: Create Machine with Workflow Nodes
|
|
153
|
+
|
|
154
|
+
Create a Machine to define the service workflow: Book Delivery → Signature Completion.
|
|
155
|
+
|
|
156
|
+
### Create Machine
|
|
157
|
+
|
|
158
|
+
**Request**:
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"operation_type": "machine",
|
|
162
|
+
"data": {
|
|
163
|
+
"object": {
|
|
164
|
+
"name": "three_body_machine_v2",
|
|
165
|
+
"permission": "three_body_permission_v2",
|
|
166
|
+
"replaceExistName": true
|
|
167
|
+
},
|
|
168
|
+
"description": "Three-Body signature service workflow v2: Book Delivery -> Signature Completion",
|
|
169
|
+
"node": {
|
|
170
|
+
"op": "add",
|
|
171
|
+
"nodes": [
|
|
172
|
+
{
|
|
173
|
+
"name": "Book Delivered",
|
|
174
|
+
"pairs": [
|
|
175
|
+
{
|
|
176
|
+
"prev_node": "",
|
|
177
|
+
"threshold": 0,
|
|
178
|
+
"forwards": [
|
|
179
|
+
{
|
|
180
|
+
"name": "Confirm Delivery",
|
|
181
|
+
"permissionIndex": 1000,
|
|
182
|
+
"weight": 1
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "Signature Completed",
|
|
190
|
+
"pairs": [
|
|
191
|
+
{
|
|
192
|
+
"prev_node": "Book Delivered",
|
|
193
|
+
"threshold": 1,
|
|
194
|
+
"forwards": [
|
|
195
|
+
{
|
|
196
|
+
"name": "Complete Signature",
|
|
197
|
+
"permissionIndex": 1001,
|
|
198
|
+
"weight": 1
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
"publish": true
|
|
207
|
+
},
|
|
208
|
+
"env": {
|
|
209
|
+
"account": "three_body_author",
|
|
210
|
+
"network": "testnet"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Actual Result**:
|
|
216
|
+
```json
|
|
217
|
+
[{
|
|
218
|
+
"type": "Machine",
|
|
219
|
+
"object": "0x8e7e1c3f173c9e2203ca2e1e50b4c634dd1cef06d248ac50e35749adf7499411",
|
|
220
|
+
"version": "2196424",
|
|
221
|
+
"change": "created"
|
|
222
|
+
}]
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Step 4: Create Service (Unpublished)
|
|
230
|
+
|
|
231
|
+
Create the Three-Body signature service without publishing. The Service must be unpublished when binding the Machine.
|
|
232
|
+
|
|
233
|
+
**Request**:
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"operation_type": "service",
|
|
237
|
+
"data": {
|
|
238
|
+
"object": {
|
|
239
|
+
"name": "three_body_signature_service_v2",
|
|
240
|
+
"type_parameter": "0x2::wow::WOW",
|
|
241
|
+
"permission": "three_body_permission_v2",
|
|
242
|
+
"replaceExistName": true
|
|
243
|
+
},
|
|
244
|
+
"description": "Three-Body author book signature service v2. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888.",
|
|
245
|
+
"publish": false
|
|
246
|
+
},
|
|
247
|
+
"env": {
|
|
248
|
+
"account": "three_body_author",
|
|
249
|
+
"network": "testnet"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Actual Result**:
|
|
255
|
+
```json
|
|
256
|
+
[{
|
|
257
|
+
"type": "Service",
|
|
258
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
259
|
+
"version": "2198123",
|
|
260
|
+
"change": "created"
|
|
261
|
+
}]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Step 5: Configure Machine
|
|
267
|
+
|
|
268
|
+
Bind the published Machine to the Service. **Important**: The Service must be unpublished when binding the Machine.
|
|
269
|
+
|
|
270
|
+
**Request**:
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"operation_type": "service",
|
|
274
|
+
"data": {
|
|
275
|
+
"object": "three_body_signature_service_v2",
|
|
276
|
+
"machine": "three_body_machine_v2"
|
|
277
|
+
},
|
|
278
|
+
"env": {
|
|
279
|
+
"account": "three_body_author",
|
|
280
|
+
"network": "testnet"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Actual Result**:
|
|
286
|
+
```json
|
|
287
|
+
[{
|
|
288
|
+
"type": "Service",
|
|
289
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
290
|
+
"version": "2198329",
|
|
291
|
+
"change": "mutated"
|
|
292
|
+
}]
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Verification** (with no_cache: true):
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"machine": "0x8e7e1c3f173c9e2203ca2e1e50b4c634dd1cef06d248ac50e35749adf7499411",
|
|
299
|
+
"bPublished": false
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Step 6: Set Buy Guard
|
|
306
|
+
|
|
307
|
+
Configure the Buy Guard to restrict purchases to the author only.
|
|
308
|
+
|
|
309
|
+
**Request**:
|
|
310
|
+
```json
|
|
311
|
+
{
|
|
312
|
+
"operation_type": "service",
|
|
313
|
+
"data": {
|
|
314
|
+
"object": "three_body_signature_service_v2",
|
|
315
|
+
"buy_guard": "three_body_buy_guard_v2"
|
|
316
|
+
},
|
|
317
|
+
"env": {
|
|
318
|
+
"account": "three_body_author",
|
|
319
|
+
"network": "testnet"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Actual Result**:
|
|
325
|
+
```json
|
|
326
|
+
[{
|
|
327
|
+
"type": "Service",
|
|
328
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
329
|
+
"version": "2203786",
|
|
330
|
+
"change": "mutated"
|
|
331
|
+
}]
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Step 7: Configure Order Allocators
|
|
337
|
+
|
|
338
|
+
Set up fund allocation: 100% to the author upon order completion.
|
|
339
|
+
|
|
340
|
+
**Request**:
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"operation_type": "service",
|
|
344
|
+
"data": {
|
|
345
|
+
"object": "three_body_signature_service_v2",
|
|
346
|
+
"order_allocators": {
|
|
347
|
+
"description": "Three-Body signature service fund allocation - 100% to author",
|
|
348
|
+
"threshold": 0,
|
|
349
|
+
"allocators": [
|
|
350
|
+
{
|
|
351
|
+
"guard": "three_body_buy_guard_v2",
|
|
352
|
+
"sharing": [
|
|
353
|
+
{
|
|
354
|
+
"who": {
|
|
355
|
+
"Signer": "signer"
|
|
356
|
+
},
|
|
357
|
+
"sharing": 10000,
|
|
358
|
+
"mode": "Rate"
|
|
359
|
+
}
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
"customer_required": ["phone", "email", "shipping_address"]
|
|
365
|
+
},
|
|
366
|
+
"env": {
|
|
367
|
+
"account": "three_body_author",
|
|
368
|
+
"network": "testnet"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Actual Result**:
|
|
374
|
+
```json
|
|
375
|
+
[{
|
|
376
|
+
"type": "Service",
|
|
377
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
378
|
+
"version": "2203787",
|
|
379
|
+
"change": "mutated"
|
|
380
|
+
}]
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Step 8: Add Sales and Publish Service
|
|
386
|
+
|
|
387
|
+
Add sales items and publish the service to make it available for orders.
|
|
388
|
+
|
|
389
|
+
**Request**:
|
|
390
|
+
```json
|
|
391
|
+
{
|
|
392
|
+
"operation_type": "service",
|
|
393
|
+
"data": {
|
|
394
|
+
"object": "three_body_signature_service_v2",
|
|
395
|
+
"sales": {
|
|
396
|
+
"op": "add",
|
|
397
|
+
"sales": [
|
|
398
|
+
{
|
|
399
|
+
"name": "Three-Body Book Signature",
|
|
400
|
+
"price": 888,
|
|
401
|
+
"stock": 100,
|
|
402
|
+
"suspension": false,
|
|
403
|
+
"wip": "",
|
|
404
|
+
"wip_hash": ""
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
},
|
|
408
|
+
"publish": true
|
|
409
|
+
},
|
|
410
|
+
"env": {
|
|
411
|
+
"account": "three_body_author",
|
|
412
|
+
"network": "testnet"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Actual Result**:
|
|
418
|
+
```json
|
|
419
|
+
[{
|
|
420
|
+
"type": "Service",
|
|
421
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
422
|
+
"version": "2205976",
|
|
423
|
+
"change": "mutated"
|
|
424
|
+
}]
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Step 9: Unpause Service
|
|
430
|
+
|
|
431
|
+
Unpause the service to allow order creation.
|
|
432
|
+
|
|
433
|
+
**Request**:
|
|
434
|
+
```json
|
|
435
|
+
{
|
|
436
|
+
"operation_type": "service",
|
|
437
|
+
"data": {
|
|
438
|
+
"object": "three_body_signature_service_v2",
|
|
439
|
+
"pause": false
|
|
440
|
+
},
|
|
441
|
+
"env": {
|
|
442
|
+
"account": "three_body_author",
|
|
443
|
+
"network": "testnet"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**Actual Result**:
|
|
449
|
+
```json
|
|
450
|
+
[{
|
|
451
|
+
"type": "Service",
|
|
452
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
453
|
+
"version": "2205975",
|
|
454
|
+
"change": "mutated"
|
|
455
|
+
}]
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Step 10: Verify Service Configuration
|
|
461
|
+
|
|
462
|
+
Query the service to verify all configurations.
|
|
463
|
+
|
|
464
|
+
**Request**:
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"query_type": "onchain_objects",
|
|
468
|
+
"objects": ["three_body_signature_service_v2"],
|
|
469
|
+
"no_cache": true,
|
|
470
|
+
"network": "testnet"
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
**Actual Result**:
|
|
475
|
+
```json
|
|
476
|
+
{
|
|
477
|
+
"object": "0x140e91943775592736f587e596afce7d28f41fee1593f8dfbc2f04d852e5d45c",
|
|
478
|
+
"type": "Service",
|
|
479
|
+
"description": "Three-Body author book signature service v2. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888.",
|
|
480
|
+
"sales": [
|
|
481
|
+
{
|
|
482
|
+
"name": "Three-Body Book Signature",
|
|
483
|
+
"stock": "100",
|
|
484
|
+
"suspension": false,
|
|
485
|
+
"price": "888",
|
|
486
|
+
"wip": "",
|
|
487
|
+
"wip_hash": ""
|
|
488
|
+
}
|
|
489
|
+
],
|
|
490
|
+
"buy_guard": "0x2fc0283e55f4322eb602a5370b32e455597e339c74a23ada5d9a4a82f02f7925",
|
|
491
|
+
"machine": "0x8e7e1c3f173c9e2203ca2e1e50b4c634dd1cef06d248ac50e35749adf7499411",
|
|
492
|
+
"bPublished": true,
|
|
493
|
+
"bPaused": false,
|
|
494
|
+
"customer_required": ["phone", "email", "shipping_address"],
|
|
495
|
+
"permission": "0xf939b4be49761ef8c30ff19ee874157e2ba1d83ab3a8de4f310443e588d1df99"
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
## Testing the Buy Guard
|
|
502
|
+
|
|
503
|
+
### Test 1: Author Purchase (Should Succeed)
|
|
504
|
+
|
|
505
|
+
The author (`three_body_author`) should be able to purchase the service.
|
|
506
|
+
|
|
507
|
+
**Request**:
|
|
508
|
+
```json
|
|
509
|
+
{
|
|
510
|
+
"operation_type": "service",
|
|
511
|
+
"data": {
|
|
512
|
+
"object": "three_body_signature_service_v2",
|
|
513
|
+
"order_new": {
|
|
514
|
+
"buy": {
|
|
515
|
+
"items": [
|
|
516
|
+
{
|
|
517
|
+
"name": "Three-Body Book Signature",
|
|
518
|
+
"stock": 1,
|
|
519
|
+
"wip_hash": ""
|
|
520
|
+
}
|
|
521
|
+
],
|
|
522
|
+
"total_pay": {
|
|
523
|
+
"balance": 888
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
"namedNewOrder": {
|
|
527
|
+
"name": "three_body_order_v2",
|
|
528
|
+
"replaceExistName": true
|
|
529
|
+
},
|
|
530
|
+
"namedNewProgress": {
|
|
531
|
+
"name": "three_body_progress_v2",
|
|
532
|
+
"replaceExistName": true
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
"env": {
|
|
537
|
+
"account": "three_body_author",
|
|
538
|
+
"network": "testnet"
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
### Test 2: Non-Author Purchase (Should Fail)
|
|
546
|
+
|
|
547
|
+
Any other account attempting to purchase should fail with Buy Guard verification error.
|
|
548
|
+
|
|
549
|
+
**Request**:
|
|
550
|
+
```json
|
|
551
|
+
{
|
|
552
|
+
"operation_type": "service",
|
|
553
|
+
"data": {
|
|
554
|
+
"object": "three_body_signature_service_v2",
|
|
555
|
+
"order_new": {
|
|
556
|
+
"buy": {
|
|
557
|
+
"items": [
|
|
558
|
+
{
|
|
559
|
+
"name": "Three-Body Book Signature",
|
|
560
|
+
"stock": 1,
|
|
561
|
+
"wip_hash": ""
|
|
562
|
+
}
|
|
563
|
+
],
|
|
564
|
+
"total_pay": {
|
|
565
|
+
"balance": 888
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
"env": {
|
|
571
|
+
"account": "myshop_customer",
|
|
572
|
+
"network": "testnet"
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## Workflow Execution
|
|
580
|
+
|
|
581
|
+
After a successful purchase by the author, the order progresses through the Machine nodes:
|
|
582
|
+
|
|
583
|
+
### Node 1: Book Delivered
|
|
584
|
+
|
|
585
|
+
The author confirms the book has been delivered.
|
|
586
|
+
|
|
587
|
+
**Request**:
|
|
588
|
+
```json
|
|
589
|
+
{
|
|
590
|
+
"operation_type": "progress",
|
|
591
|
+
"data": {
|
|
592
|
+
"object": "three_body_progress_v2",
|
|
593
|
+
"forward": {
|
|
594
|
+
"forward": "Confirm Delivery",
|
|
595
|
+
"namedOperator": ""
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
"env": {
|
|
599
|
+
"account": "three_body_author",
|
|
600
|
+
"network": "testnet"
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Node 2: Signature Completed
|
|
606
|
+
|
|
607
|
+
The author completes the signature.
|
|
608
|
+
|
|
609
|
+
**Request**:
|
|
610
|
+
```json
|
|
611
|
+
{
|
|
612
|
+
"operation_type": "progress",
|
|
613
|
+
"data": {
|
|
614
|
+
"object": "three_body_progress_v2",
|
|
615
|
+
"forward": {
|
|
616
|
+
"forward": "Complete Signature",
|
|
617
|
+
"namedOperator": ""
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
"env": {
|
|
621
|
+
"account": "three_body_author",
|
|
622
|
+
"network": "testnet"
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## Summary
|
|
630
|
+
|
|
631
|
+
This example demonstrates:
|
|
632
|
+
|
|
633
|
+
1. **Buy Guard Implementation**: Restricts service purchases to specific accounts
|
|
634
|
+
2. **Machine Workflow**: Two-node process for service delivery tracking
|
|
635
|
+
3. **WIP Files Optional**: Sales items can use WIP files or empty strings
|
|
636
|
+
4. **Service Configuration**: Complete setup from creation to publication
|
|
637
|
+
|
|
638
|
+
### Key Object IDs (Actual)
|
|
639
|
+
|
|
640
|
+
| Object | Name | ID | Version |
|
|
641
|
+
|--------|------|-----|---------|
|
|
642
|
+
| Permission | three_body_permission_v2 | `0xf939b4...1df99` | 2195623 |
|
|
643
|
+
| Buy Guard | three_body_buy_guard_v2 | `0x2fc028...f7925` | 2195993 |
|
|
644
|
+
| Machine | three_body_machine_v2 | `0x8e7e1c...99411` | 2196424 |
|
|
645
|
+
| Service | three_body_signature_service_v2 | `0x140e91...e5d45c` | 2205976 |
|
|
646
|
+
| Order | three_body_order_v2 | `0x7684ab...3f35d49` | 2209290 |
|
|
647
|
+
| Allocation | three_body_allocation_v2 | `0xd6f2da...99e00` | 2209290 |
|
|
648
|
+
| Progress | three_body_progress_v2 | `0x97ef34...d935d9` | 2209290 |
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
652
|
+
## Design Notes
|
|
653
|
+
|
|
654
|
+
### Why Buy Guard?
|
|
655
|
+
|
|
656
|
+
The Buy Guard ensures only the intended user (the author) can purchase this service. This is useful when:
|
|
657
|
+
- The service is an internal tool
|
|
658
|
+
- Purchase authorization requires verification
|
|
659
|
+
- The service is part of a larger workflow controlled by a specific entity
|
|
660
|
+
|
|
661
|
+
### WIP Files Optional
|
|
662
|
+
|
|
663
|
+
This example shows both options for sales items:
|
|
664
|
+
- Can use WIP files with hash validation
|
|
665
|
+
- Can use empty wip/wip_hash for simpler setup
|
|
666
|
+
- WIP validation is skipped when wip is empty string
|
|
667
|
+
|
|
668
|
+
### Workflow Design
|
|
669
|
+
|
|
670
|
+
The two-node workflow provides clear tracking:
|
|
671
|
+
1. **Book Delivered**: Confirms physical delivery of the book
|
|
672
|
+
2. **Signature Completed**: Confirms the author has signed the book
|
|
673
|
+
|
|
674
|
+
Each node transition requires the author's confirmation, ensuring accountability.
|
|
675
|
+
|
|
676
|
+
---
|
|
677
|
+
|
|
678
|
+
## Execution Experience & Best Practices
|
|
679
|
+
|
|
680
|
+
### 1. Naming Strategy (Critical!)
|
|
681
|
+
|
|
682
|
+
**Always establish naming conventions first** :
|
|
683
|
+
|
|
684
|
+
- **Example**: Use consistent suffixes or no suffixes at all
|
|
685
|
+
- Good: `three_body_permission_v2`, `three_body_buy_guard_v2`, `three_body_machine_v2`
|
|
686
|
+
- Good: All names follow the same pattern
|
|
687
|
+
- Provide naming rules for AI to manage object names automatically; avoid conflicts with other naming conventions such as version/timestamp/random numbers for unique names
|
|
688
|
+
- Strongly recommend using the `replaceExistName` method in `LocalMarkOperationSchema` to enforce name usage (even if already exists)
|
|
689
|
+
- All operations use names instead of addresses (much easier!)
|
|
690
|
+
- Local marks map names to addresses automatically
|
|
691
|
+
- Easier to read, test, and document
|
|
692
|
+
|
|
693
|
+
**Recommendation**:
|
|
694
|
+
1. Decide on naming before starting
|
|
695
|
+
2. Stick to it throughout the entire workflow
|
|
696
|
+
3. Document your naming pattern in the test results
|
|
697
|
+
|
|
698
|
+
### 2. Execution Order Matters (Critical!)
|
|
699
|
+
|
|
700
|
+
**Publish operations lock objects** - plan carefully:
|
|
701
|
+
|
|
702
|
+
#### Correct Order (Must Follow!)
|
|
703
|
+
1. **Permission** first - foundation for all other objects
|
|
704
|
+
2. **Machine** - create workflow before service
|
|
705
|
+
3. **Service (unpublished)** - get address for Guards
|
|
706
|
+
4. **Guards** - need Service address for verification logic
|
|
707
|
+
5. **Configure Service** - add machine, buy_guard, order_allocators
|
|
708
|
+
6. **Publish Service** - LAST! Once published, many changes are blocked
|
|
709
|
+
|
|
710
|
+
### 3. Guard Creation Tips
|
|
711
|
+
|
|
712
|
+
**Guards often depend on other objects**:
|
|
713
|
+
- Buy Guards: May reference Service address
|
|
714
|
+
- Progress Guards: May need Machine or Service information
|
|
715
|
+
- Order Allocator Guards: Should be created before Service publish
|
|
716
|
+
|
|
717
|
+
**Best Practice**:
|
|
718
|
+
1. Create empty Service with name first (unpublished)
|
|
719
|
+
2. Create all required Guards using that name
|
|
720
|
+
3. Configure Service with Guards
|
|
721
|
+
4. Publish Service
|
|
722
|
+
|
|
723
|
+
### 4. Machine Workflow Setup
|
|
724
|
+
|
|
725
|
+
**Machine nodes require permission indexes**:
|
|
726
|
+
- If you use permissionIndex, make sure they exist!
|
|
727
|
+
- Create permission indexes before adding machine nodes
|
|
728
|
+
|
|
729
|
+
**Machine Publish**:
|
|
730
|
+
- Must publish Machine before binding to Service
|
|
731
|
+
- Published Machine can still have nodes added/modified
|
|
732
|
+
|
|
733
|
+
### 5. Service Configuration Flow
|
|
734
|
+
|
|
735
|
+
**Configure everything before publishing**:
|
|
736
|
+
```
|
|
737
|
+
Service Created (unpublished)
|
|
738
|
+
↓
|
|
739
|
+
Add Sales Items
|
|
740
|
+
↓
|
|
741
|
+
Bind Machine
|
|
742
|
+
↓
|
|
743
|
+
Set Buy Guard
|
|
744
|
+
↓
|
|
745
|
+
Configure Order Allocators
|
|
746
|
+
↓
|
|
747
|
+
Set Arbitration (if needed)
|
|
748
|
+
↓
|
|
749
|
+
PUBLISH (LAST STEP!)
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
### 6. Testing Strategy
|
|
753
|
+
|
|
754
|
+
**Test incrementally, not all at once**:
|
|
755
|
+
1. Test each step as you go
|
|
756
|
+
2. Verify object creation with queries
|
|
757
|
+
3. Don't proceed to next step until current one is verified
|
|
758
|
+
4. Keep track of all object IDs in a test results file
|
|
759
|
+
|
|
760
|
+
### 7. Common Pitfalls to Avoid
|
|
761
|
+
|
|
762
|
+
1. **Price Units**: WOW tokens use 9 decimals, but testnet examples often use simple numbers (888 tokens)
|
|
763
|
+
2. **Local Marks**: Verify objects exist with `local_mark_list` queries
|
|
764
|
+
3. **Account Balance**: Always check balance before starting - gas fees add up!
|
|
765
|
+
|
|
766
|
+
### 8. Let AI Manage Object Naming for You
|
|
767
|
+
|
|
768
|
+
### 9. Query Toolkit is Your Best Friend
|
|
769
|
+
|
|
770
|
+
**Use queries constantly**:
|
|
771
|
+
- Verify objects exist
|
|
772
|
+
- Check configurations
|
|
773
|
+
- Debug issues
|
|
774
|
+
- Confirm state changes
|
|
775
|
+
|
|
776
|
+
The `query_toolkit` and `onchain_table_data` are essential for validating every step of the way.
|