@wowok/skills 1.1.9 → 1.1.11

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 (40) hide show
  1. package/LICENSE +36 -0
  2. package/README.md +1 -8
  3. package/dist/cli.js +4 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/skills.d.ts.map +1 -1
  6. package/dist/skills.js +33 -0
  7. package/dist/skills.js.map +1 -1
  8. package/examples/Insurance/Insurance.md +218 -90
  9. package/examples/MyShop/MyShop.md +513 -245
  10. package/examples/MyShop/myshop_machine_nodes.json +87 -0
  11. package/examples/MyShop_Advanced/MyShop_Advanced.md +633 -228
  12. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +195 -202
  13. package/examples/Travel/Travel.md +775 -487
  14. package/examples/Travel/calc-weather-timestamps.js +9 -5
  15. package/package.json +8 -3
  16. package/scripts/install.js +4 -0
  17. package/wowok-arbitrator/SKILL.md +542 -1
  18. package/wowok-auditor/SKILL.md +581 -0
  19. package/wowok-guard/SKILL.md +425 -1
  20. package/wowok-machine/SKILL.md +404 -1
  21. package/wowok-messenger/SKILL.md +551 -1
  22. package/wowok-onboard/SKILL.md +520 -0
  23. package/wowok-order/SKILL.md +528 -1
  24. package/wowok-output/SKILL.md +571 -0
  25. package/wowok-planner/SKILL.md +757 -0
  26. package/wowok-provider/SKILL.md +455 -1
  27. package/wowok-safety/SKILL.md +557 -0
  28. package/wowok-scenario/SKILL.md +585 -0
  29. package/wowok-tools/SKILL.md +423 -1
  30. package/examples/Insurance/Insurance_TestResults.md +0 -481
  31. package/examples/Insurance/insurance_complete_guard_v1.json +0 -50
  32. package/examples/MyShop/MyShop_TestResults.md +0 -1003
  33. package/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
  34. package/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
  35. package/examples/MyShop_Advanced/machine_nodes.json +0 -222
  36. package/examples/MyShop_Advanced/three_body_signature.wip +0 -30
  37. package/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
  38. package/examples/Travel/Travel_TestResults.md +0 -743
  39. package/examples/Travel/travel_machine_v2_export.json +0 -104
  40. package/examples/Travel/weather_check_guard_v1.json +0 -51
@@ -1,4 +1,4 @@
1
- # MyShop Advanced E-Commerce Example
1
+ # MyShop Advanced E-Commerce Example
2
2
 
3
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
4
 
@@ -181,9 +181,15 @@ Understanding the correct order for creating WoWok objects is crucial for a succ
181
181
  │ │ _win_v2 │ │ _win_v2 │ │ _v2 │ │
182
182
  │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
183
183
  │ │
184
- │ Phase 2b: Reward Guards
185
- ═══════════════════════
184
+ │ Phase 2b: Reward System (Empty Object First)
185
+ ════════════════════════════════════════════
186
186
  │ │
187
+ │ ┌─────────────────┐ │
188
+ │ │ Empty Reward │◄─── Create empty reward object first │
189
+ │ │myshop_reward_v2 │ Guards will reference this object │
190
+ │ └────────┬────────┘ │
191
+ │ │ │
192
+ │ ▼ │
187
193
  │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
188
194
  │ │ reward_wonderful│ │ reward_lost │ │ reward_shipping │ │
189
195
  │ │ _v2 │ │ _v2 │ │ _timeout_v2 │ │
@@ -226,12 +232,13 @@ Understanding the correct order for creating WoWok objects is crucial for a succ
226
232
  │ │ and Publish │ Requires: All Guards, Arbitration │
227
233
  │ └─────────────────┘ │
228
234
  │ │
229
- │ Phase 7: Reward Pool
230
- ═════════════════════
235
+ │ Phase 7: Reward Pool Configuration
236
+ ══════════════════════════════════
231
237
  │ │
232
238
  │ ┌─────────────────┐ │
233
- │ │ Reward │◄─── Requires: Service (for guard verification)
234
- │ │myshop_reward_v2 Add: reward_guards for Wonderful/Lost/Timeout
239
+ │ │ Add Guards to │◄─── Add reward guards with store_from_id
240
+ │ │ Reward Enables double-claim protection
241
+ │ │myshop_reward_v2 │ │
235
242
  │ └─────────────────┘ │
236
243
  │ │
237
244
  └─────────────────────────────────────────────────────────────────────────────┘
@@ -249,7 +256,10 @@ Understanding the correct order for creating WoWok objects is crucial for a succ
249
256
  | 5 | **Machine Binding** | Service, Machine | Bind Machine to Service before publishing. Once published, Machine cannot be bound. |
250
257
  | 6 | **Arbitration** | None | Arbitration is independent but needs to be bound to Service. Create before Service update. |
251
258
  | 7 | **Service (Update)** | Guards, Arb, Machine | Update Service with order\_allocators, sales, arbitrations, machine binding. Then publish. |
252
- | 8 | **Reward** | Service, Guards | Reward pool needs Service name in guards for claim verification. Create after Service is available. |
259
+ | 8 | **Empty Reward** | None | Create empty reward object first. This object is referenced by reward guards for double-claim protection. |
260
+ | 9 | **Reward Guards** | Reward (by name) | Create reward guards that reference the reward object by name. Guards verify order node + no prior claim. |
261
+ | 10 | **Add Guards to Reward** | Reward, Guards | Add reward guards to the reward object with store\_from\_id set. This enables order-based double-claim protection. |
262
+ | 11 | **Deposit to Reward** | Reward | Deposit WOW tokens to reward pool for claim distribution. |
253
263
 
254
264
  ### Key Design Decisions
255
265
 
@@ -259,14 +269,15 @@ Understanding the correct order for creating WoWok objects is crucial for a succ
259
269
  4. **Guards Before Machine**: Machine nodes reference guards for verification. Create all guards first, then create Machine with guard references.
260
270
  5. **Machine Binding Before Publish**: Bind Machine to Service before publishing. Once published, Machine cannot be bound.
261
271
  6. **Arbitration Before Service Update**: Arbitration must be created before Service update so it can be bound to Service.
262
- 6. **Service Publishing Last**: Only publish Service after all guards, machine, and arbitration are ready.
263
- 7. **Reward Last**: Reward references Service address in guards for claim verification. Create after Service is available.
272
+ 7. **Service Publishing Last**: Only publish Service after all guards, machine, and arbitration are ready.
273
+ 8. **Empty Reward Before Reward Guards**: Create an empty reward object first. Reward guards reference this object by name to verify no double-claiming.
274
+ 9. **Reward Guards Before Adding to Reward**: Create reward guards that check both order node and no prior claim, then add them to the reward object with store_from_id set.
264
275
 
265
276
  ### Simplified Build Sequence
266
277
 
267
278
  ```
268
279
  Phase 1: Foundation
269
- └── 1. Create Permission (myshop_permission_v2)
280
+ └── 1. Create Permission (myshop_perm_v2)
270
281
  └── Add permission indexes (1000 for Order Confirmed/Cancel, 1001 for other operations)
271
282
 
272
283
  Phase 2: Service Creation
@@ -276,7 +287,7 @@ Phase 2: Service Creation
276
287
 
277
288
  Phase 3: Guard Creation (Machine Guards)
278
289
  └── 3. Create Machine Guards (4 guards)
279
- ├── machine_merkle_root_v2 (verify string length = 64)
290
+ ├── machine_merkle_root_v2 (verify string length = 66)
280
291
  ├── machine_service_order_v2 (verify order service + node)
281
292
  ├── machine_time_10d_v2 (time >= 10 days)
282
293
  └── machine_time_2d_v2 (time >= 2 days)
@@ -307,11 +318,25 @@ Phase 7: Service Configuration
307
318
  ├── Add arbitrations binding
308
319
  └── Publish service
309
320
 
310
- Phase 8: Reward Pool
311
- └── 8. Create Reward (myshop_reward_v2)
312
- ├── Deposit initial balance
313
- ├── Create reward_guards (reward_wonderful_v2, reward_lost_v2, reward_shipping_timeout_v2)
314
- └── Add reward_guards (Wonderful: 10000, Lost: 20000, Shipping Timeout: 30000)
321
+ Phase 8: Reward Pool Setup
322
+ └── 8. Create Empty Reward (myshop_reward_v2)
323
+ └── Create empty reward object first (guards will reference it)
324
+
325
+ Phase 9: Reward Guards Creation
326
+ └── 9. Create Reward Guards (3 guards)
327
+ ├── reward_wonderful_v2 (verify Wonderful node + no prior claim)
328
+ ├── reward_lost_v2 (verify Lost node + no prior claim)
329
+ └── reward_shipping_timeout_v2 (verify Shipping node + no prior claim)
330
+
331
+ Phase 10: Reward Guards Configuration
332
+ └── 10. Add Guards to Reward Object
333
+ ├── Add reward_wonderful_v2 (amount: 10000, store_from_id: 0)
334
+ ├── Add reward_lost_v2 (amount: 20000, store_from_id: 0)
335
+ └── Add reward_shipping_timeout_v2 (amount: 20000, store_from_id: 0)
336
+
337
+ Phase 11: Deposit to Reward Pool
338
+ └── 11. Deposit WOW tokens to reward pool
339
+ └── Add sufficient balance for all reward payments
315
340
  ```
316
341
 
317
342
  ***
@@ -333,21 +358,22 @@ Ensure both accounts have sufficient testnet WOW tokens.
333
358
 
334
359
  Create a new permission object for the advanced shop.
335
360
 
336
- **Prompt**: Create permission object "myshop\_permission\_v2".
361
+ **Prompt**: Create permission object "myshop\_perm\_v2".
337
362
 
338
363
  ```json
339
364
  {
340
365
  "operation_type": "permission",
341
366
  "data": {
342
367
  "object": {
343
- "name": "myshop_permission_v2",
368
+ "name": "myshop_perm_v2",
344
369
  "replaceExistName": true
345
370
  },
346
371
  "description": "Permission object for MyShop Advanced e-commerce system"
347
372
  },
348
373
  "env": {
349
374
  "account": "myshop_merchant",
350
- "network": "testnet"
375
+ "network": "testnet",
376
+ "no_cache": true
351
377
  }
352
378
  }
353
379
  ```
@@ -364,11 +390,11 @@ Add custom permission indexes for advanced operations.
364
390
  {
365
391
  "operation_type": "permission",
366
392
  "data": {
367
- "object": "myshop_permission_v2",
393
+ "object": "myshop_perm_v2",
368
394
  "remark": {
369
395
  "op": "set",
370
396
  "index": 1000,
371
- "remark": "Order Confirmed and Order Cancel - Merchant confirms or cancels order with Merkle Root"
397
+ "remark": "Order Confirmed and Order Cancel - Merchant confirms or cancels order"
372
398
  },
373
399
  "table": {
374
400
  "op": "add perm by index",
@@ -380,7 +406,8 @@ Add custom permission indexes for advanced operations.
380
406
  },
381
407
  "env": {
382
408
  "account": "myshop_merchant",
383
- "network": "testnet"
409
+ "network": "testnet",
410
+ "no_cache": true
384
411
  }
385
412
  }
386
413
  ```
@@ -391,11 +418,11 @@ Add custom permission indexes for advanced operations.
391
418
  {
392
419
  "operation_type": "permission",
393
420
  "data": {
394
- "object": "myshop_permission_v2",
421
+ "object": "myshop_perm_v2",
395
422
  "remark": {
396
423
  "op": "set",
397
424
  "index": 1001,
398
- "remark": "Shipping, Order Complete, Lost, Return operations - Merchant logistics operations with Merkle Root"
425
+ "remark": "Shipping, Order Complete, Lost, Return operations - Merchant logistics operations"
399
426
  },
400
427
  "table": {
401
428
  "op": "add perm by index",
@@ -407,7 +434,8 @@ Add custom permission indexes for advanced operations.
407
434
  },
408
435
  "env": {
409
436
  "account": "myshop_merchant",
410
- "network": "testnet"
437
+ "network": "testnet",
438
+ "no_cache": true
411
439
  }
412
440
  }
413
441
  ```
@@ -418,7 +446,7 @@ Add custom permission indexes for advanced operations.
418
446
 
419
447
  Create the Service without publishing to obtain its address for Guard creation.
420
448
 
421
- **Prompt**: Create Service "three\_body\_signature\_service\_v2" with permission "myshop\_permission\_v2", do not publish.
449
+ **Prompt**: Create Service "three\_body\_signature\_service\_v2" with permission "myshop\_perm\_v2", do not publish.
422
450
 
423
451
  ```json
424
452
  {
@@ -426,14 +454,16 @@ Create the Service without publishing to obtain its address for Guard creation.
426
454
  "data": {
427
455
  "object": {
428
456
  "name": "three_body_signature_service_v2",
429
- "permission": "myshop_permission_v2"
457
+ "replaceExistName": true,
458
+ "permission": "myshop_perm_v2"
430
459
  },
431
460
  "description": "Three-Body Problem Signature Edition - Limited collector's item with WIP verification",
432
- "publish": false
461
+ "pause": false
433
462
  },
434
463
  "env": {
435
464
  "account": "myshop_merchant",
436
- "network": "testnet"
465
+ "network": "testnet",
466
+ "no_cache": true
437
467
  }
438
468
  }
439
469
  ```
@@ -446,40 +476,46 @@ Create the Service without publishing to obtain its address for Guard creation.
446
476
 
447
477
  Create Guards using the Service address. Guards verify order state and service ownership.
448
478
 
449
- **Guard 1: machine_merkle_root_v2** - Verify Merkle Root string length = 64
479
+ > **Pre-Query Step**: Before designing Guards, query available Guard instructions via `wowok_buildin_info` to confirm correct query IDs, parameter types, and return types. This is mandatory per the skill framework.
480
+ >
481
+ > ```json
482
+ > {
483
+ > "info": "guard instructions",
484
+ > "filter": { "scope": "all" }
485
+ > }
486
+ > ```
487
+ >
488
+ > Key instructions used in this example:
489
+ > - Query ID 1563 (`order.service`): Returns the Service address of an Order — used to verify order belongs to this service
490
+ > - Query ID for `progress.node_current`: Returns current node name — used to verify order at specific workflow node
491
+
492
+ **Guard 1: machine_merkle_root_v2** - Verify Merkle Root string length = 66 (0x prefix + 64 hex chars)
450
493
 
451
494
  ```json
452
495
  {
453
496
  "operation_type": "guard",
454
497
  "data": {
455
- "object": {
498
+ "namedNew": {
456
499
  "name": "machine_merkle_root_v2",
457
500
  "replaceExistName": true
458
501
  },
459
- "description": "Verify Merkle Root string length is 64 characters",
502
+ "description": "Verify Merkle Root string length is 66 characters (0x prefix + 64 hex)",
503
+ "table": [
504
+ {"identifier": 0, "b_submission": true, "value_type": "String"},
505
+ {"identifier": 1, "b_submission": false, "value_type": "U64", "value": "66"}
506
+ ],
460
507
  "root": {
461
508
  "type": "logic_as_u256_equal",
462
509
  "nodes": [
463
- {
464
- "type": "string_length",
465
- "nodes": [
466
- {
467
- "type": "identifier",
468
- "identifier": 0
469
- }
470
- ]
471
- },
472
- {
473
- "type": "constant",
474
- "value": 64,
475
- "value_type": "U256"
476
- }
510
+ {"type": "calc_string_length", "node": {"type": "identifier", "identifier": 0}},
511
+ {"type": "identifier", "identifier": 1}
477
512
  ]
478
513
  }
479
514
  },
480
515
  "env": {
481
516
  "account": "myshop_merchant",
482
- "network": "testnet"
517
+ "network": "testnet",
518
+ "no_cache": true
483
519
  }
484
520
  }
485
521
  ```
@@ -490,92 +526,128 @@ Create Guards using the Service address. Guards verify order state and service o
490
526
  {
491
527
  "operation_type": "guard",
492
528
  "data": {
493
- "object": {
529
+ "namedNew": {
494
530
  "name": "machine_time_10d_v2",
495
531
  "replaceExistName": true
496
532
  },
497
533
  "description": "Verify time elapsed >= 10 days (864000000 ms)",
534
+ "table": [
535
+ {"identifier": 0, "b_submission": true, "value_type": "U64"},
536
+ {"identifier": 1, "b_submission": false, "value_type": "U64", "value": "864000000"}
537
+ ],
498
538
  "root": {
499
539
  "type": "logic_as_u256_greater_or_equal",
500
540
  "nodes": [
501
541
  {
502
542
  "type": "calc_number_subtract",
503
543
  "nodes": [
504
- {
505
- "type": "context",
506
- "context": "Clock"
507
- },
508
- {
509
- "type": "identifier",
510
- "identifier": 0
511
- }
544
+ {"type": "context", "context": "Clock"},
545
+ {"type": "identifier", "identifier": 0}
512
546
  ]
513
547
  },
514
- {
515
- "type": "identifier",
516
- "identifier": 1
517
- }
548
+ {"type": "identifier", "identifier": 1}
518
549
  ]
519
550
  }
520
551
  },
521
552
  "env": {
522
553
  "account": "myshop_merchant",
523
- "network": "testnet"
554
+ "network": "testnet",
555
+ "no_cache": true
524
556
  }
525
557
  }
526
558
  ```
527
559
 
528
- **Guard 3: service_merchant_win_v2** - Verify node in [Order Complete, Wonderful, Return Fail]
560
+ **Guard 3: machine_time_2d_v2** - Verify 2-day timeout (172800000 ms)
529
561
 
530
562
  ```json
531
563
  {
532
564
  "operation_type": "guard",
533
565
  "data": {
534
- "object": {
535
- "name": "service_merchant_win_v2",
566
+ "namedNew": {
567
+ "name": "machine_time_2d_v2",
536
568
  "replaceExistName": true
537
569
  },
538
- "description": "Verify order at merchant win nodes: Order Complete, Wonderful, Return Fail",
570
+ "description": "Verify time elapsed >= 2 days (172800000 ms)",
571
+ "table": [
572
+ {"identifier": 0, "b_submission": true, "value_type": "U64"},
573
+ {"identifier": 1, "b_submission": false, "value_type": "U64", "value": "172800000"}
574
+ ],
539
575
  "root": {
540
- "type": "logic_or",
576
+ "type": "logic_as_u256_greater_or_equal",
541
577
  "nodes": [
542
578
  {
543
- "type": "logic_as_string_equal",
579
+ "type": "calc_number_subtract",
544
580
  "nodes": [
545
- {
546
- "type": "progress_current_node"
547
- },
548
- {
549
- "type": "constant",
550
- "value": "Order Complete",
551
- "value_type": "String"
552
- }
581
+ {"type": "context", "context": "Clock"},
582
+ {"type": "identifier", "identifier": 0}
553
583
  ]
554
584
  },
585
+ {"type": "identifier", "identifier": 1}
586
+ ]
587
+ }
588
+ },
589
+ "env": {
590
+ "account": "myshop_merchant",
591
+ "network": "testnet",
592
+ "no_cache": true
593
+ }
594
+ }
595
+ ```
596
+
597
+ ***
598
+
599
+ **Guard 4: service_merchant_win_v2** - Verify order at merchant win nodes AND order belongs to this service
600
+
601
+ ```json
602
+ {
603
+ "operation_type": "guard",
604
+ "data": {
605
+ "namedNew": {
606
+ "name": "service_merchant_win_v2",
607
+ "replaceExistName": true
608
+ },
609
+ "description": "Verify order at merchant win nodes (Order Complete, Wonderful, Return Fail) AND order belongs to three_body_signature_service_v2",
610
+ "table": [
611
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
612
+ {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Order Complete"},
613
+ {"identifier": 2, "b_submission": false, "value_type": "String", "value": "Wonderful"},
614
+ {"identifier": 3, "b_submission": false, "value_type": "String", "value": "Return Fail"},
615
+ {"identifier": 4, "b_submission": false, "value_type": "Address", "name": "service_address", "value": "three_body_signature_service_v2"}
616
+ ],
617
+ "root": {
618
+ "type": "logic_and",
619
+ "nodes": [
555
620
  {
556
- "type": "logic_as_string_equal",
621
+ "type": "logic_or",
557
622
  "nodes": [
558
623
  {
559
- "type": "progress_current_node"
624
+ "type": "logic_string_nocase_equal",
625
+ "nodes": [
626
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
627
+ {"type": "identifier", "identifier": 1}
628
+ ]
629
+ },
630
+ {
631
+ "type": "logic_string_nocase_equal",
632
+ "nodes": [
633
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
634
+ {"type": "identifier", "identifier": 2}
635
+ ]
560
636
  },
561
637
  {
562
- "type": "constant",
563
- "value": "Wonderful",
564
- "value_type": "String"
638
+ "type": "logic_string_nocase_equal",
639
+ "nodes": [
640
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
641
+ {"type": "identifier", "identifier": 3}
642
+ ]
565
643
  }
566
644
  ]
567
645
  },
568
646
  {
569
- "type": "logic_as_string_equal",
647
+ "type": "logic_equal",
570
648
  "nodes": [
571
- {
572
- "type": "progress_current_node"
573
- },
574
- {
575
- "type": "constant",
576
- "value": "Return Fail",
577
- "value_type": "String"
578
- }
649
+ {"type": "query", "query": 1563, "object": {"identifier": 0}, "parameters": []},
650
+ {"type": "identifier", "identifier": 4}
579
651
  ]
580
652
  }
581
653
  ]
@@ -583,49 +655,102 @@ Create Guards using the Service address. Guards verify order state and service o
583
655
  },
584
656
  "env": {
585
657
  "account": "myshop_merchant",
586
- "network": "testnet"
658
+ "network": "testnet",
659
+ "no_cache": true
587
660
  }
588
661
  }
589
662
  ```
590
663
 
591
- **Guard 4: service_customer_win_v2** - Verify node in [Lost, Return Complete]
664
+ **Guard Logic:**
665
+ 1. 验证订单当前节点是 Order Complete、Wonderful 或 Return Fail(商家胜利节点)
666
+ 2. 验证订单的 Service 地址等于当前 Guard 所属的 Service 地址(使用 `order.service` 查询指令 ID 1563)
667
+ ```
668
+
669
+ **Guard 5: machine_service_order_v2** - Verify order belongs to this Service
592
670
 
593
671
  ```json
594
672
  {
595
673
  "operation_type": "guard",
596
674
  "data": {
597
- "object": {
675
+ "namedNew": {
676
+ "name": "machine_service_order_v2",
677
+ "replaceExistName": true
678
+ },
679
+ "description": "Verify order belongs to three_body_signature_service_v2",
680
+ "table": [
681
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
682
+ {"identifier": 1, "b_submission": false, "value_type": "Address", "name": "service_address", "value": "three_body_signature_service_v2"}
683
+ ],
684
+ "root": {
685
+ "type": "logic_equal",
686
+ "nodes": [
687
+ {
688
+ "type": "query",
689
+ "query": 1563,
690
+ "object": {"identifier": 0},
691
+ "parameters": []
692
+ },
693
+ {
694
+ "type": "identifier",
695
+ "identifier": 1
696
+ }
697
+ ]
698
+ }
699
+ },
700
+ "env": {
701
+ "account": "myshop_merchant",
702
+ "network": "testnet",
703
+ "no_cache": true
704
+ }
705
+ }
706
+ ```
707
+
708
+ ***
709
+
710
+ **Guard 6: service_customer_win_v2** - Verify order at customer win nodes AND order belongs to this service
711
+
712
+ ```json
713
+ {
714
+ "operation_type": "guard",
715
+ "data": {
716
+ "namedNew": {
598
717
  "name": "service_customer_win_v2",
599
718
  "replaceExistName": true
600
719
  },
601
- "description": "Verify order at customer win nodes: Lost, Return Complete",
720
+ "description": "Verify order at customer win nodes (Lost, Return Complete) AND order belongs to three_body_signature_service_v2",
721
+ "table": [
722
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
723
+ {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Lost"},
724
+ {"identifier": 2, "b_submission": false, "value_type": "String", "value": "Return Complete"},
725
+ {"identifier": 3, "b_submission": false, "value_type": "Address", "name": "service_address", "value": "three_body_signature_service_v2"}
726
+ ],
602
727
  "root": {
603
- "type": "logic_or",
728
+ "type": "logic_and",
604
729
  "nodes": [
605
730
  {
606
- "type": "logic_as_string_equal",
731
+ "type": "logic_or",
607
732
  "nodes": [
608
733
  {
609
- "type": "progress_current_node"
734
+ "type": "logic_string_nocase_equal",
735
+ "nodes": [
736
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
737
+ {"type": "identifier", "identifier": 1}
738
+ ]
610
739
  },
611
740
  {
612
- "type": "constant",
613
- "value": "Lost",
614
- "value_type": "String"
741
+ "type": "logic_string_nocase_equal",
742
+ "nodes": [
743
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
744
+ {"type": "identifier", "identifier": 2}
745
+ ]
615
746
  }
616
747
  ]
617
748
  },
618
749
  {
619
- "type": "logic_as_string_equal",
750
+ "type": "logic_equal",
620
751
  "nodes": [
621
- {
622
- "type": "progress_current_node"
623
- },
624
- {
625
- "type": "constant",
626
- "value": "Return Complete",
627
- "value_type": "String"
628
- }
752
+ {"type": "query", "query": 1563, "object": {"identifier": 0}, "parameters": []},
753
+ {"type": "identifier", "identifier": 3}
629
754
  ]
630
755
  }
631
756
  ]
@@ -633,18 +758,32 @@ Create Guards using the Service address. Guards verify order state and service o
633
758
  },
634
759
  "env": {
635
760
  "account": "myshop_merchant",
636
- "network": "testnet"
761
+ "network": "testnet",
762
+ "no_cache": true
637
763
  }
638
764
  }
639
765
  ```
640
766
 
767
+ **Guard Logic:**
768
+ 1. 验证订单当前节点是 Lost 或 Return Complete(客户胜利节点)
769
+ 2. 验证订单的 Service 地址等于当前 Guard 所属的 Service 地址(使用 `order.service` 查询指令 ID 1563)
770
+ ```
771
+
641
772
  ***
642
773
 
643
774
  ### Step 5: Create Machine (Multi-Path Workflow)
644
775
 
645
776
  Create Machine with all nodes and guards in a single operation.
646
777
 
647
- **Prompt**: Create Machine "myshop\_advanced\_machine\_v2" with permission "myshop\_permission\_v2" and all nodes.
778
+ **Important Notes on Machine Design**:
779
+
780
+ 1. **Entry Node Constraint (Mandatory)**: At least one node MUST have a pair with `prev_node: ""` (empty string). This defines the entry point from the initial state. Without such a node, Progress cannot advance from its initial empty state. In this example, the "Order Confirmed" node has `prev_node: ""` serving as the entry point.
781
+
782
+ 2. **`namedOperator` for Customer Operations**: In Machine forwards, setting `namedOperator: ""` (empty string) allows the **customer** to operate the Progress through their Order. This is required for all forwards that should be triggered by the customer via the order system. Forwards without `namedOperator` or with a specific named operator require the merchant or designated operator to execute.
783
+
784
+ 3. **Permission Index vs namedOperator**: Each forward MUST specify either `permissionIndex` (shared internal role) OR `namedOperator` (per-Progress namespace). Order user operations MUST use `namedOperator("")`.
785
+
786
+ **Prompt**: Create Machine "myshop\_advanced\_machine\_v2" with permission "myshop\_perm\_v2" and all nodes.
648
787
 
649
788
  ```json
650
789
  {
@@ -653,7 +792,7 @@ Create Machine with all nodes and guards in a single operation.
653
792
  "object": {
654
793
  "name": "myshop_advanced_machine_v2",
655
794
  "replaceExistName": true,
656
- "permission": "myshop_permission_v2"
795
+ "permission": "myshop_perm_v2"
657
796
  },
658
797
  "description": "Multi-path order processing with delivery confirmation, wonderful rating, lost handling and return processing - Complete workflow with guards",
659
798
  "node": {
@@ -717,8 +856,8 @@ Create Machine with all nodes and guards in a single operation.
717
856
  "forwards": [
718
857
  {
719
858
  "name": "Confirm Receipt",
720
- "permissionIndex": 1001,
721
- "weight": 1
859
+ "weight": 1,
860
+ "namedOperator": ""
722
861
  }
723
862
  ]
724
863
  }
@@ -733,8 +872,8 @@ Create Machine with all nodes and guards in a single operation.
733
872
  "forwards": [
734
873
  {
735
874
  "name": "Rate as Wonderful",
736
- "permissionIndex": 1001,
737
- "weight": 1
875
+ "weight": 1,
876
+ "namedOperator": ""
738
877
  }
739
878
  ]
740
879
  }
@@ -777,8 +916,8 @@ Create Machine with all nodes and guards in a single operation.
777
916
  "forwards": [
778
917
  {
779
918
  "name": "Report Lost",
780
- "permissionIndex": 1001,
781
- "weight": 1
919
+ "weight": 1,
920
+ "namedOperator": ""
782
921
  },
783
922
  {
784
923
  "name": "Confirm Lost with Merkle Root",
@@ -799,8 +938,8 @@ Create Machine with all nodes and guards in a single operation.
799
938
  "forwards": [
800
939
  {
801
940
  "name": "Request Return",
802
- "permissionIndex": 1001,
803
- "weight": 1
941
+ "weight": 1,
942
+ "namedOperator": ""
804
943
  },
805
944
  {
806
945
  "name": "Confirm Return with Merkle Root",
@@ -821,8 +960,8 @@ Create Machine with all nodes and guards in a single operation.
821
960
  "forwards": [
822
961
  {
823
962
  "name": "Request Return with Receipt",
824
- "permissionIndex": 1001,
825
- "weight": 1
963
+ "weight": 1,
964
+ "namedOperator": ""
826
965
  },
827
966
  {
828
967
  "name": "Confirm Return Address with Merkle Root",
@@ -860,14 +999,14 @@ Create Machine with all nodes and guards in a single operation.
860
999
  "forwards": [
861
1000
  {
862
1001
  "name": "Submit Return Merkle Root",
863
- "permissionIndex": 1001,
864
1002
  "weight": 1,
1003
+ "namedOperator": "",
865
1004
  "guard": { "guard": "machine_merkle_root_v2" }
866
1005
  },
867
1006
  {
868
1007
  "name": "Confirm Return Received",
869
- "permissionIndex": 1001,
870
- "weight": 1
1008
+ "weight": 1,
1009
+ "namedOperator": ""
871
1010
  }
872
1011
  ]
873
1012
  },
@@ -877,14 +1016,14 @@ Create Machine with all nodes and guards in a single operation.
877
1016
  "forwards": [
878
1017
  {
879
1018
  "name": "Submit Return Merkle Root",
880
- "permissionIndex": 1001,
881
1019
  "weight": 1,
1020
+ "namedOperator": "",
882
1021
  "guard": { "guard": "machine_merkle_root_v2" }
883
1022
  },
884
1023
  {
885
1024
  "name": "Confirm Return Received",
886
- "permissionIndex": 1001,
887
- "weight": 1
1025
+ "weight": 1,
1026
+ "namedOperator": ""
888
1027
  }
889
1028
  ]
890
1029
  }
@@ -895,7 +1034,8 @@ Create Machine with all nodes and guards in a single operation.
895
1034
  },
896
1035
  "env": {
897
1036
  "account": "myshop_merchant",
898
- "network": "testnet"
1037
+ "network": "testnet",
1038
+ "no_cache": true
899
1039
  }
900
1040
  }
901
1041
  ```
@@ -904,6 +1044,17 @@ Create Machine with all nodes and guards in a single operation.
904
1044
 
905
1045
  ### Step 6: Publish Machine
906
1046
 
1047
+ > **Pre-Publish Verification (Mandatory)**: Before publishing, export and review the Machine node structure using `machineNode2file`. Once published, node settings become immutable. Verify all nodes, forwards, guards, and permission indices are correct.
1048
+ >
1049
+ > ```json
1050
+ > {
1051
+ > "object": "myshop_advanced_machine_v2",
1052
+ > "format": "json"
1053
+ > }
1054
+ > ```
1055
+ >
1056
+ > Confirm with the user that the exported structure is correct before proceeding to publish.
1057
+
907
1058
  Machine must be published before binding to Service.
908
1059
 
909
1060
  ```json
@@ -915,7 +1066,8 @@ Machine must be published before binding to Service.
915
1066
  },
916
1067
  "env": {
917
1068
  "account": "myshop_merchant",
918
- "network": "testnet"
1069
+ "network": "testnet",
1070
+ "no_cache": true
919
1071
  }
920
1072
  }
921
1073
  ```
@@ -937,7 +1089,8 @@ Bind the Machine to the Service. **Important**: The Service must be unpublished
937
1089
  },
938
1090
  "env": {
939
1091
  "account": "myshop_merchant",
940
- "network": "testnet"
1092
+ "network": "testnet",
1093
+ "no_cache": true
941
1094
  }
942
1095
  }
943
1096
  ```
@@ -992,44 +1145,119 @@ Create an Arbitration object as the final on-chain mechanism for protecting user
992
1145
  },
993
1146
  "env": {
994
1147
  "account": "myshop_merchant",
995
- "network": "testnet"
1148
+ "network": "testnet",
1149
+ "no_cache": true
996
1150
  }
997
1151
  }
998
1152
  ```
999
1153
 
1154
+ **Note**: Arbitration object is automatically published upon creation. No separate publish step is required.
1155
+ ```
1156
+
1000
1157
  ***
1001
1158
 
1002
- ### Step 10: Update Service with Arbitration and Publish
1159
+ ### Step 10: Configure Order Allocators and Publish
1160
+
1161
+ Configure order_allocators to define fund distribution rules, then publish the Service.
1162
+
1163
+ > **Pre-Publish Verification (Mandatory)**: Before publishing the Service, verify all bindings are correct: Machine, Arbitration, Rewards, and order_allocators. Once published, all bindings become immutable. Use `query_toolkit` to confirm the Service state:
1164
+ >
1165
+ > ```json
1166
+ > {
1167
+ > "query_type": "service",
1168
+ > "object": "three_body_signature_service_v2",
1169
+ > "network": "testnet",
1170
+ > "no_cache": true
1171
+ > }
1172
+ > ```
1173
+ >
1174
+ > Confirm with the user that all bindings and configurations are correct before proceeding to publish.
1003
1175
 
1004
- Update Service with arbitration binding, and publish.
1176
+ **IMPORTANT**: Service must have order_allocators configured before publishing. Once published, order_allocators becomes immutable.
1005
1177
 
1006
- **Prompt**: Update service "three\_body\_signature\_service\_v2" with arbitration and publish.
1178
+ **Prompt**: Configure order_allocators and publish service "three\_body\_signature\_service\_v2".
1007
1179
 
1008
1180
  ```json
1009
1181
  {
1010
1182
  "operation_type": "service",
1011
1183
  "data": {
1012
1184
  "object": "three_body_signature_service_v2",
1185
+ "sales": {
1186
+ "op": "add",
1187
+ "sales": [
1188
+ {
1189
+ "name": "The Three-Body Problem + Author Signature",
1190
+ "price": 1000000000,
1191
+ "stock": 100,
1192
+ "suspension": false,
1193
+ "wip": "https://wowok.net/test/three_body.wip",
1194
+ "wip_hash": ""
1195
+ }
1196
+ ]
1197
+ },
1198
+ "order_allocators": {
1199
+ "description": "Order fund allocation - 100% to Service when order complete/wonderful/return fail, 100% to Order when lost/return complete",
1200
+ "threshold": 1,
1201
+ "allocators": [
1202
+ {
1203
+ "guard": "service_merchant_win_v2",
1204
+ "sharing": [
1205
+ {
1206
+ "who": {"Entity": {"name_or_address": "three_body_signature_service_v2"}},
1207
+ "sharing": 10000,
1208
+ "mode": "Rate"
1209
+ }
1210
+ ]
1211
+ },
1212
+ {
1213
+ "guard": "service_customer_win_v2",
1214
+ "sharing": [
1215
+ {
1216
+ "who": {"Signer": "signer"},
1217
+ "sharing": 10000,
1218
+ "mode": "Rate"
1219
+ }
1220
+ ]
1221
+ }
1222
+ ]
1223
+ },
1013
1224
  "arbitrations": {
1014
1225
  "op": "add",
1015
1226
  "objects": ["myshop_arbitration_v2"]
1016
1227
  },
1228
+ "rewards": {
1229
+ "op": "add",
1230
+ "objects": ["myshop_reward_v2"]
1231
+ },
1017
1232
  "publish": true
1018
1233
  },
1019
1234
  "env": {
1020
1235
  "account": "myshop_merchant",
1021
- "network": "testnet"
1236
+ "network": "testnet",
1237
+ "no_cache": true
1022
1238
  }
1023
1239
  }
1024
1240
  ```
1025
1241
 
1242
+ **Fund Allocation Rules:**
1243
+
1244
+ | Guard | Condition | Recipient | Amount |
1245
+ |-------|-----------|-----------|--------|
1246
+ | service_merchant_win_v2 | Node is Order Complete / Wonderful / Return Fail | Service (merchant) | 100% |
1247
+ | service_customer_win_v2 | Node is Lost / Return Complete | Order (customer) | 100% |
1248
+
1249
+ **Recipient Types:**
1250
+ - **Service**: 资金分配给 Service 对象(商家收款)
1251
+ - **Order**: 资金分配给 Order 对象(客户收款,订单所有者可以提取)
1252
+ ```
1253
+
1026
1254
  ***
1027
1255
 
1028
- ### Step 11: Create Reward Pool (Optional)
1256
+ ### Step 11: Create Empty Reward Object (Optional)
1029
1257
 
1030
- Create reward pool with initial balance for rewards and compensation.
1258
+ Create an empty reward object first. This object will be referenced by reward guards to prevent double-claiming.
1031
1259
 
1032
- **Prompt**: Create reward object "myshop\_reward\_v2" with initial balance.
1260
+ **Prompt**: Create empty reward object.
1033
1261
 
1034
1262
  ```json
1035
1263
  {
@@ -1037,12 +1265,10 @@ Create reward pool with initial balance for rewards and compensation.
1037
1265
  "data": {
1038
1266
  "object": {
1039
1267
  "name": "myshop_reward_v2",
1040
- "replaceExistName": true
1268
+ "replaceExistName": true,
1269
+ "permission": "myshop_perm_v2"
1041
1270
  },
1042
- "description": "Reward pool for MyShop advanced - Wonderful rewards (10000), Lost compensation (20000), Shipping timeout compensation (30000)",
1043
- "coin_add": {
1044
- "balance": 150000000
1045
- }
1271
+ "description": "MyShop reward pool for wonderful service and compensation"
1046
1272
  },
1047
1273
  "env": {
1048
1274
  "account": "myshop_merchant",
@@ -1056,21 +1282,203 @@ Create reward pool with initial balance for rewards and compensation.
1056
1282
 
1057
1283
  ### Step 12: Create Reward Guards (Optional)
1058
1284
 
1059
- Create guards for reward verification:
1285
+ Create guards for reward verification with double-claim protection:
1060
1286
 
1061
1287
  | # | Guard Name | Purpose | Reward Amount |
1062
1288
  |---|------------|---------|---------------|
1063
- | 7 | `reward_wonderful_v2` | Verify order at Wonderful node | 10000 |
1064
- | 8 | `reward_lost_v2` | Verify order at Lost node | 20000 |
1065
- | 9 | `reward_shipping_timeout_v2` | Verify order at Shipping node > 2 days | 30000 |
1289
+ **Guard 7: reward_wonderful_v2**
1290
+
1291
+ ```json
1292
+ {
1293
+ "operation_type": "guard",
1294
+ "data": {
1295
+ "namedNew": {
1296
+ "name": "reward_wonderful_v2",
1297
+ "replaceExistName": true
1298
+ },
1299
+ "description": "Verify order at Wonderful node for reward, signer must be order owner, order belongs to this service, and not claimed before",
1300
+ "table": [
1301
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
1302
+ {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Wonderful"},
1303
+ {"identifier": 2, "b_submission": false, "value_type": "Address", "value": "myshop_reward_v2", "name": "reward_object"},
1304
+ {"identifier": 3, "b_submission": false, "value_type": "Address", "value": "three_body_signature_service_v2", "name": "service_address"}
1305
+ ],
1306
+ "root": {
1307
+ "type": "logic_and",
1308
+ "nodes": [
1309
+ {
1310
+ "type": "logic_string_nocase_equal",
1311
+ "nodes": [
1312
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
1313
+ {"type": "identifier", "identifier": 1}
1314
+ ]
1315
+ },
1316
+ {
1317
+ "type": "logic_equal",
1318
+ "nodes": [
1319
+ {"type": "query", "query": 1562, "object": {"identifier": 0}, "parameters": []},
1320
+ {"type": "context", "context": "Signer"}
1321
+ ]
1322
+ },
1323
+ {
1324
+ "type": "logic_equal",
1325
+ "nodes": [
1326
+ {"type": "query", "query": 1563, "object": {"identifier": 0}, "parameters": []},
1327
+ {"type": "identifier", "identifier": 3}
1328
+ ]
1329
+ },
1330
+ {
1331
+ "type": "logic_not",
1332
+ "node": {
1333
+ "type": "query_reward_record_exists",
1334
+ "object": {"identifier": 2},
1335
+ "where": {
1336
+ "storeFromId": {"identifier": 0}
1337
+ }
1338
+ }
1339
+ }
1340
+ ]
1341
+ }
1342
+ },
1343
+ "env": {
1344
+ "account": "myshop_merchant",
1345
+ "network": "testnet",
1346
+ "no_cache": true
1347
+ }
1348
+ }
1349
+ ```
1350
+
1351
+ **Guard 8: reward_lost_v2**
1352
+
1353
+ ```json
1354
+ {
1355
+ "operation_type": "guard",
1356
+ "data": {
1357
+ "namedNew": {
1358
+ "name": "reward_lost_v2",
1359
+ "replaceExistName": true
1360
+ },
1361
+ "description": "Verify order at Lost node for compensation, signer must be order owner, order belongs to this service, and not claimed before",
1362
+ "table": [
1363
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
1364
+ {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Lost"},
1365
+ {"identifier": 2, "b_submission": false, "value_type": "Address", "value": "myshop_reward_v2", "name": "reward_object"},
1366
+ {"identifier": 3, "b_submission": false, "value_type": "Address", "value": "three_body_signature_service_v2", "name": "service_address"}
1367
+ ],
1368
+ "root": {
1369
+ "type": "logic_and",
1370
+ "nodes": [
1371
+ {
1372
+ "type": "logic_string_nocase_equal",
1373
+ "nodes": [
1374
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
1375
+ {"type": "identifier", "identifier": 1}
1376
+ ]
1377
+ },
1378
+ {
1379
+ "type": "logic_equal",
1380
+ "nodes": [
1381
+ {"type": "query", "query": 1562, "object": {"identifier": 0}, "parameters": []},
1382
+ {"type": "context", "context": "Signer"}
1383
+ ]
1384
+ },
1385
+ {
1386
+ "type": "logic_equal",
1387
+ "nodes": [
1388
+ {"type": "query", "query": 1563, "object": {"identifier": 0}, "parameters": []},
1389
+ {"type": "identifier", "identifier": 3}
1390
+ ]
1391
+ },
1392
+ {
1393
+ "type": "logic_not",
1394
+ "node": {
1395
+ "type": "query_reward_record_exists",
1396
+ "object": {"identifier": 2},
1397
+ "where": {
1398
+ "storeFromId": {"identifier": 0}
1399
+ }
1400
+ }
1401
+ }
1402
+ ]
1403
+ }
1404
+ },
1405
+ "env": {
1406
+ "account": "myshop_merchant",
1407
+ "network": "testnet",
1408
+ "no_cache": true
1409
+ }
1410
+ }
1411
+ ```
1412
+
1413
+ **Guard 9: reward_shipping_timeout_v2**
1414
+
1415
+ ```json
1416
+ {
1417
+ "operation_type": "guard",
1418
+ "data": {
1419
+ "namedNew": {
1420
+ "name": "reward_shipping_timeout_v2",
1421
+ "replaceExistName": true
1422
+ },
1423
+ "description": "Verify order at Shipping node for timeout compensation, signer must be order owner, order belongs to this service, and not claimed before",
1424
+ "table": [
1425
+ {"identifier": 0, "b_submission": true, "value_type": "Address", "name": "order_id"},
1426
+ {"identifier": 1, "b_submission": false, "value_type": "String", "value": "Shipping"},
1427
+ {"identifier": 2, "b_submission": false, "value_type": "Address", "value": "myshop_reward_v2", "name": "reward_object"},
1428
+ {"identifier": 3, "b_submission": false, "value_type": "Address", "value": "three_body_signature_service_v2", "name": "service_address"}
1429
+ ],
1430
+ "root": {
1431
+ "type": "logic_and",
1432
+ "nodes": [
1433
+ {
1434
+ "type": "logic_string_nocase_equal",
1435
+ "nodes": [
1436
+ {"type": "query", "query": 1253, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
1437
+ {"type": "identifier", "identifier": 1}
1438
+ ]
1439
+ },
1440
+ {
1441
+ "type": "logic_equal",
1442
+ "nodes": [
1443
+ {"type": "query", "query": 1562, "object": {"identifier": 0}, "parameters": []},
1444
+ {"type": "context", "context": "Signer"}
1445
+ ]
1446
+ },
1447
+ {
1448
+ "type": "logic_equal",
1449
+ "nodes": [
1450
+ {"type": "query", "query": 1563, "object": {"identifier": 0}, "parameters": []},
1451
+ {"type": "identifier", "identifier": 3}
1452
+ ]
1453
+ },
1454
+ {
1455
+ "type": "logic_not",
1456
+ "node": {
1457
+ "type": "query_reward_record_exists",
1458
+ "object": {"identifier": 2},
1459
+ "where": {
1460
+ "storeFromId": {"identifier": 0}
1461
+ }
1462
+ }
1463
+ }
1464
+ ]
1465
+ }
1466
+ },
1467
+ "env": {
1468
+ "account": "myshop_merchant",
1469
+ "network": "testnet",
1470
+ "no_cache": true
1471
+ }
1472
+ }
1473
+ ```
1066
1474
 
1067
1475
  ***
1068
1476
 
1069
- ### Step 13: Add Reward Guards (Optional)
1477
+ ### Step 13: Add Reward Guards to Reward Object (Optional)
1070
1478
 
1071
- Add reward guards for Wonderful (10000), Lost (20000), and Shipping timeout (30000) compensation.
1479
+ Add reward guards to the reward object with `store_from_id` set to the order identifier. This enables double-claim protection by storing the order ID in reward records.
1072
1480
 
1073
- **Prompt**: Add reward guards.
1481
+ **Prompt**: Add reward guards with store_from_id.
1074
1482
 
1075
1483
  ```json
1076
1484
  {
@@ -1081,25 +1489,54 @@ Add reward guards for Wonderful (10000), Lost (20000), and Shipping timeout (300
1081
1489
  {
1082
1490
  "guard": "reward_wonderful_v2",
1083
1491
  "recipient": {"Signer": "signer"},
1084
- "amount": {"type": "Fixed", "value": 10000}
1492
+ "amount": {"type": "Fixed", "value": 10000},
1493
+ "store_from_id": 0
1085
1494
  },
1086
1495
  {
1087
1496
  "guard": "reward_lost_v2",
1088
1497
  "recipient": {"Signer": "signer"},
1089
- "amount": {"type": "Fixed", "value": 20000}
1498
+ "amount": {"type": "Fixed", "value": 20000},
1499
+ "store_from_id": 0
1090
1500
  },
1091
1501
  {
1092
1502
  "guard": "reward_shipping_timeout_v2",
1093
1503
  "recipient": {"Signer": "signer"},
1094
- "amount": {"type": "Fixed", "value": 30000}
1504
+ "amount": {"type": "Fixed", "value": 20000},
1505
+ "store_from_id": 0
1095
1506
  }
1096
1507
  ]
1097
1508
  },
1098
1509
  "env": {
1099
1510
  "account": "myshop_merchant",
1100
- "network": "testnet"
1511
+ "network": "testnet",
1512
+ "no_cache": true
1513
+ }
1514
+ }
1515
+
1516
+ ***
1517
+
1518
+ ### Step 14: Deposit to Reward Pool (Optional)
1519
+
1520
+ Deposit WOW tokens to the reward pool for rewards and compensation.
1521
+
1522
+ **Prompt**: Deposit to reward object "myshop\_reward\_v2".
1523
+
1524
+ ```json
1525
+ {
1526
+ "operation_type": "reward",
1527
+ "data": {
1528
+ "object": "myshop_reward_v2",
1529
+ "coin_add": {
1530
+ "balance": 150000000
1531
+ }
1532
+ },
1533
+ "env": {
1534
+ "account": "myshop_merchant",
1535
+ "network": "testnet",
1536
+ "no_cache": true
1101
1537
  }
1102
1538
  }
1539
+ ```
1103
1540
 
1104
1541
  ***
1105
1542
 
@@ -1122,28 +1559,32 @@ Customer places an order for "The Three-Body Problem + Author Signature" with WI
1122
1559
  {
1123
1560
  "name": "The Three-Body Problem + Author Signature",
1124
1561
  "stock": 1,
1125
- "wip_hash": "sha256:1db6dc86d8be68bafb33418628a30e7bfcbce48de9c099d3d9cb21def3af8b43"
1562
+ "wip_hash": "03c18561efa8faf4d75480eb1f732c4a46ffde95599e92eca06167785fc07a5b"
1126
1563
  }
1127
1564
  ],
1128
1565
  "total_pay": {
1129
- "balance": 5000000000
1566
+ "balance": 1000000000
1130
1567
  },
1131
- "order_info": "To my dear friend - keep exploring the universe"
1568
+ "payment_remark": "To my dear friend - keep exploring the universe"
1132
1569
  },
1133
1570
  "namedNewOrder": {
1134
- "name": "myshop_order_v2"
1571
+ "name": "myshop_order_v2",
1572
+ "replaceExistName": true
1135
1573
  },
1136
1574
  "namedNewAllocation": {
1137
- "name": "myshop_allocation_v2"
1575
+ "name": "myshop_allocation_v2",
1576
+ "replaceExistName": true
1138
1577
  },
1139
1578
  "namedNewProgress": {
1140
- "name": "myshop_progress_v2"
1579
+ "name": "myshop_progress_v2",
1580
+ "replaceExistName": true
1141
1581
  }
1142
1582
  }
1143
1583
  },
1144
1584
  "env": {
1145
1585
  "account": "myshop_customer",
1146
- "network": "testnet"
1586
+ "network": "testnet",
1587
+ "no_cache": true
1147
1588
  }
1148
1589
  }
1149
1590
  ```
@@ -1152,9 +1593,9 @@ Customer places an order for "The Three-Body Problem + Author Signature" with WI
1152
1593
 
1153
1594
  ### Step 2: Merchant Confirms Order
1154
1595
 
1155
- Merchant confirms order by submitting Merkle Root.
1596
+ Merchant confirms the order. This step uses permission index 1000 (no Guard submission needed).
1156
1597
 
1157
- **Prompt**: Merchant confirms order with Merkle Root.
1598
+ **Prompt**: Merchant confirms order.
1158
1599
 
1159
1600
  ```json
1160
1601
  {
@@ -1164,34 +1605,11 @@ Merchant confirms order by submitting Merkle Root.
1164
1605
  "operate": {
1165
1606
  "operation": {
1166
1607
  "next_node_name": "Order Confirmed",
1167
- "forward": "Submit Messenger Merkle Root"
1608
+ "forward": "Confirm Order"
1168
1609
  },
1169
- "hold": false,
1170
- "message": "Order confirmed - Merkle Root submitted"
1610
+ "message": "Order confirmed by merchant"
1171
1611
  }
1172
1612
  },
1173
- "submission": {
1174
- "type": "submission",
1175
- "guard": [
1176
- {
1177
- "object": "machine_merkle_root_v2",
1178
- "impack": true
1179
- }
1180
- ],
1181
- "submission": [
1182
- {
1183
- "guard": "machine_merkle_root_v2",
1184
- "submission": [
1185
- {
1186
- "identifier": 0,
1187
- "b_submission": true,
1188
- "value_type": "String",
1189
- "value": "0xabc123...def456"
1190
- }
1191
- ]
1192
- }
1193
- ]
1194
- },
1195
1613
  "env": {
1196
1614
  "account": "myshop_merchant",
1197
1615
  "network": "testnet",
@@ -1204,9 +1622,9 @@ Merchant confirms order by submitting Merkle Root.
1204
1622
 
1205
1623
  ### Step 3: Merchant Starts Shipping
1206
1624
 
1207
- Merchant starts shipping after signature service is completed.
1625
+ Merchant starts shipping after signature service is completed. The merchant submits a Merkle Root (66-character hex string with 0x prefix) proving communication with the customer via Messenger.
1208
1626
 
1209
- **Prompt**: Merchant starts shipping with signature verification and Merkle Root.
1627
+ **Prompt**: Merchant starts shipping with Merkle Root submission.
1210
1628
 
1211
1629
  ```json
1212
1630
  {
@@ -1218,7 +1636,6 @@ Merchant starts shipping after signature service is completed.
1218
1636
  "next_node_name": "Shipping",
1219
1637
  "forward": "Confirm Signature and Submit Merkle Root"
1220
1638
  },
1221
- "hold": false,
1222
1639
  "message": "Shipping started - signature completed and Merkle Root submitted"
1223
1640
  }
1224
1641
  },
@@ -1226,25 +1643,19 @@ Merchant starts shipping after signature service is completed.
1226
1643
  "type": "submission",
1227
1644
  "guard": [
1228
1645
  {
1229
- "object": "machine_service_order_v2",
1646
+ "object": "machine_merkle_root_v2",
1230
1647
  "impack": true
1231
1648
  }
1232
1649
  ],
1233
1650
  "submission": [
1234
1651
  {
1235
- "guard": "machine_service_order_v2",
1652
+ "guard": "machine_merkle_root_v2",
1236
1653
  "submission": [
1237
1654
  {
1238
1655
  "identifier": 0,
1239
1656
  "b_submission": true,
1240
- "value_type": "Address",
1241
- "value": "myshop_order_v2"
1242
- },
1243
- {
1244
- "identifier": 1,
1245
- "b_submission": true,
1246
- "value_type": "Address",
1247
- "value": "three_body_signature_service_v2"
1657
+ "value_type": "String",
1658
+ "value": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
1248
1659
  }
1249
1660
  ]
1250
1661
  }
@@ -1258,6 +1669,8 @@ Merchant starts shipping after signature service is completed.
1258
1669
  }
1259
1670
  ```
1260
1671
 
1672
+ **Note**: The `machine_merkle_root_v2` Guard expects a 66-character string (including "0x" prefix). The Guard validates that the string length equals 66 characters. The Merkle Root is computed from the Messenger conversation between merchant and customer, proving that tracking information was exchanged.
1673
+
1261
1674
  ***
1262
1675
 
1263
1676
  ### Step 4: Customer Confirms Delivery
@@ -1268,15 +1681,14 @@ Customer confirms receipt of goods.
1268
1681
 
1269
1682
  ```json
1270
1683
  {
1271
- "operation_type": "progress",
1684
+ "operation_type": "order",
1272
1685
  "data": {
1273
- "object": "myshop_progress_v2",
1274
- "operate": {
1686
+ "object": "myshop_order_v2",
1687
+ "progress": {
1275
1688
  "operation": {
1276
1689
  "next_node_name": "Delivery Complete",
1277
1690
  "forward": "Confirm Receipt"
1278
1691
  },
1279
- "hold": false,
1280
1692
  "message": "Delivery confirmed - goods received"
1281
1693
  }
1282
1694
  },
@@ -1298,15 +1710,14 @@ Alternatively, customer can rate as Wonderful (very satisfied).
1298
1710
 
1299
1711
  ```json
1300
1712
  {
1301
- "operation_type": "progress",
1713
+ "operation_type": "order",
1302
1714
  "data": {
1303
- "object": "myshop_progress_v2",
1304
- "operate": {
1715
+ "object": "myshop_order_v2",
1716
+ "progress": {
1305
1717
  "operation": {
1306
1718
  "next_node_name": "Wonderful",
1307
- "forward": "Rate Wonderful"
1719
+ "forward": "Rate as Wonderful"
1308
1720
  },
1309
- "hold": false,
1310
1721
  "message": "Rated as Wonderful - very satisfied with the service"
1311
1722
  }
1312
1723
  },
@@ -1331,22 +1742,19 @@ Customer claims Wonderful reward from reward pool.
1331
1742
  "operation_type": "reward",
1332
1743
  "data": {
1333
1744
  "object": "myshop_reward_v2",
1334
- "claim": {
1335
- "guard": "guard_wonderful_v2",
1336
- "reward_object": "myshop_order_v2"
1337
- }
1745
+ "claim": "reward_wonderful_v2"
1338
1746
  },
1339
1747
  "submission": {
1340
1748
  "type": "submission",
1341
1749
  "guard": [
1342
1750
  {
1343
- "object": "guard_wonderful_v2",
1751
+ "object": "reward_wonderful_v2",
1344
1752
  "impack": true
1345
1753
  }
1346
1754
  ],
1347
1755
  "submission": [
1348
1756
  {
1349
- "guard": "guard_wonderful_v2",
1757
+ "guard": "reward_wonderful_v2",
1350
1758
  "submission": [
1351
1759
  {
1352
1760
  "identifier": 0,
@@ -1526,7 +1934,7 @@ If package is lost, customer reports and merchant confirms.
1526
1934
  "identifier": 0,
1527
1935
  "b_submission": true,
1528
1936
  "value_type": "String",
1529
- "value": "0xlost123...merkle456"
1937
+ "value": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
1530
1938
  }
1531
1939
  ]
1532
1940
  }
@@ -1547,22 +1955,19 @@ If package is lost, customer reports and merchant confirms.
1547
1955
  "operation_type": "reward",
1548
1956
  "data": {
1549
1957
  "object": "myshop_reward_v2",
1550
- "claim": {
1551
- "guard": "guard_lost_v2",
1552
- "reward_object": "myshop_order_v2"
1553
- }
1958
+ "claim": "reward_lost_v2"
1554
1959
  },
1555
1960
  "submission": {
1556
1961
  "type": "submission",
1557
1962
  "guard": [
1558
1963
  {
1559
- "object": "guard_lost_v2",
1964
+ "object": "reward_lost_v2",
1560
1965
  "impack": true
1561
1966
  }
1562
1967
  ],
1563
1968
  "submission": [
1564
1969
  {
1565
- "guard": "guard_lost_v2",
1970
+ "guard": "reward_lost_v2",
1566
1971
  "submission": [
1567
1972
  {
1568
1973
  "identifier": 0,
@@ -1644,7 +2049,7 @@ Customer requests return after delivery confirmation.
1644
2049
  "identifier": 0,
1645
2050
  "b_submission": true,
1646
2051
  "value_type": "String",
1647
- "value": "0xreturn789...addr012"
2052
+ "value": "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
1648
2053
  }
1649
2054
  ]
1650
2055
  }
@@ -1690,7 +2095,7 @@ Customer requests return after delivery confirmation.
1690
2095
  "identifier": 0,
1691
2096
  "b_submission": true,
1692
2097
  "value_type": "String",
1693
- "value": "0xshipreturn...track345"
2098
+ "value": "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
1694
2099
  }
1695
2100
  ]
1696
2101
  }
@@ -1813,7 +2218,7 @@ When order reaches Order Complete, Wonderful, or Return Fail, merchant can withd
1813
2218
  "identifier": 0,
1814
2219
  "b_submission": true,
1815
2220
  "value_type": "Address",
1816
- "value": "myshop_progress_v2"
2221
+ "value": "myshop_order_v2"
1817
2222
  }
1818
2223
  ]
1819
2224
  }
@@ -1858,7 +2263,7 @@ When order reaches Lost or Return Complete, customer can withdraw funds.
1858
2263
  "identifier": 0,
1859
2264
  "b_submission": true,
1860
2265
  "value_type": "Address",
1861
- "value": "myshop_progress_v2"
2266
+ "value": "myshop_order_v2"
1862
2267
  }
1863
2268
  ]
1864
2269
  }