@wowok/skills 1.1.11 → 1.1.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.
@@ -395,7 +395,7 @@ Create the insurance service with machine, order_allocators, sales, and publish
395
395
  "machine": "insurance_machine_v1",
396
396
  "order_allocators": {
397
397
  "description": "Insurance order revenue allocation",
398
- "threshold": 0,
398
+ "threshold": 1,
399
399
  "allocators": [
400
400
  {
401
401
  "guard": "insurance_withdraw_guard_v1",
@@ -417,7 +417,7 @@ Create the insurance service with machine, order_allocators, sales, and publish
417
417
  "price": 100000000,
418
418
  "stock": 1000,
419
419
  "suspension": false,
420
- "wip": "",
420
+ "wip": "https://cdn.jsdelivr.net/gh/wowok-ai/docs@main/wip-examples/three_body.wip",
421
421
  "wip_hash": ""
422
422
  }
423
423
  ]
@@ -434,10 +434,13 @@ Create the insurance service with machine, order_allocators, sales, and publish
434
434
  > **Important**:
435
435
  > - `mode: "Rate"` represents Rate allocation mode (valid values: `"Amount"`, `"Rate"`, `"Surplus"`)
436
436
  > - `who: {"Signer": "signer"}` represents the transaction signer
437
+ > - `wip_hash: ""` (empty string) means the system will automatically extract and use the hash from within the WIP file (`meta.hash` field). The WIP file at the `wip` URL must be a valid JSON file in WIP format. Do NOT use the SHA-256 of the file bytes as `wip_hash` — it must be the `meta.hash` value inside the WIP JSON, or empty string for auto-extraction.
437
438
 
438
439
  ---
439
440
 
440
- ## Step 6: Unpause Service
441
+ ## Step 6: Unpause Service (Optional)
442
+
443
+ > **Note**: A newly created Service is **not paused by default**. This step is only needed if you explicitly paused the service earlier. You can safely skip this step and proceed to Step 7.
441
444
 
442
445
  Unpause the service to allow order creation.
443
446
 
@@ -504,6 +507,14 @@ Create an order on the insurance service using the `order_new` field of the `ser
504
507
  "namedNewOrder": {
505
508
  "name": "test_insurance_order_v1",
506
509
  "replaceExistName": true
510
+ },
511
+ "namedNewAllocation": {
512
+ "name": "insurance_test_alloc_v1",
513
+ "replaceExistName": true
514
+ },
515
+ "namedNewProgress": {
516
+ "name": "insurance_test_progress_v1",
517
+ "replaceExistName": true
507
518
  }
508
519
  }
509
520
  },
@@ -514,7 +525,9 @@ Create an order on the insurance service using the `order_new` field of the `ser
514
525
  }
515
526
  ```
516
527
 
517
- > **Get the Progress ID**: After creating the order, query it to obtain the Progress object ID needed for the next steps:
528
+ > **Named Objects**: The `namedNewOrder`, `namedNewAllocation`, and `namedNewProgress` fields assign local names to the created objects. You can reference them by name (e.g., `"test_insurance_order_v1"`, `"insurance_test_alloc_v1"`, `"insurance_test_progress_v1"`) in subsequent operations instead of using raw on-chain IDs.
529
+ >
530
+ > **Optional — Query the Order**: To verify the order or obtain on-chain object IDs:
518
531
  > ```json
519
532
  > {
520
533
  > "query_type": "onchain_objects",
@@ -523,7 +536,7 @@ Create an order on the insurance service using the `order_new` field of the `ser
523
536
  > "no_cache": true
524
537
  > }
525
538
  > ```
526
- > The response includes a `progress` field containing the Progress object ID, and an `allocation` field containing the Allocation object ID.
539
+ > The response includes `progress` and `allocation` fields with the on-chain object IDs.
527
540
 
528
541
  ### 8.2 Advance Progress: Initial -> Start
529
542
 
@@ -533,10 +546,10 @@ First, advance the progress from initial state to Start node.
533
546
 
534
547
  ```json
535
548
  {
536
- "operation_type": "progress",
549
+ "operation_type": "order",
537
550
  "data": {
538
- "object": "<insurance_progress_id>",
539
- "operate": {
551
+ "object": "test_insurance_order_v1",
552
+ "progress": {
540
553
  "operation": {
541
554
  "next_node_name": "Start",
542
555
  "forward": "start_claim"
@@ -553,7 +566,7 @@ First, advance the progress from initial state to Start node.
553
566
  > **Note**:
554
567
  > - Both `next_node_name` and `forward` fields are required in the operation object
555
568
  > - Use simple forward name (e.g., `"start_claim"`) without node prefix. The system automatically resolves the path from current node
556
- > - The Progress object ID can be obtained by querying the Order object (it has a `progress` field) see Step 8.1
569
+ > - The Progress is advanced via the Order object's `progress` field, using the Order name as reference
557
570
 
558
571
  ### 8.3 Advance Progress: Start -> Complete
559
572
 
@@ -569,10 +582,10 @@ Wait at least 10 seconds after entering Start node, then advance the progress to
569
582
 
570
583
  ```json
571
584
  {
572
- "operation_type": "progress",
585
+ "operation_type": "order",
573
586
  "data": {
574
- "object": "<insurance_progress_id>",
575
- "operate": {
587
+ "object": "test_insurance_order_v1",
588
+ "progress": {
576
589
  "operation": {
577
590
  "next_node_name": "Complete",
578
591
  "forward": "complete_claim"
@@ -601,7 +614,7 @@ The server will return a `submission` prompt like:
601
614
  {
602
615
  "identifier": 0,
603
616
  "b_submission": true,
604
- "value_type": "Address",
617
+ "value_type": 1,
605
618
  "name": "Order ID (submitted at runtime)",
606
619
  "object_type": "Order"
607
620
  }
@@ -617,10 +630,10 @@ The server will return a `submission` prompt like:
617
630
 
618
631
  ```json
619
632
  {
620
- "operation_type": "progress",
633
+ "operation_type": "order",
621
634
  "data": {
622
- "object": "<insurance_progress_id>",
623
- "operate": {
635
+ "object": "test_insurance_order_v1",
636
+ "progress": {
624
637
  "operation": {
625
638
  "next_node_name": "Complete",
626
639
  "forward": "complete_claim"
@@ -642,10 +655,10 @@ The server will return a `submission` prompt like:
642
655
  {
643
656
  "identifier": 0,
644
657
  "b_submission": true,
645
- "value_type": "Address",
658
+ "value_type": 1,
646
659
  "name": "Order ID (submitted at runtime)",
647
660
  "object_type": "Order",
648
- "value": "<insurance_order_id>"
661
+ "value": "test_insurance_order_v1"
649
662
  }
650
663
  ]
651
664
  }
@@ -659,15 +672,120 @@ The server will return a `submission` prompt like:
659
672
  ```
660
673
 
661
674
  > **⚠️ Important**:
662
- > - The `submission` field must be at the **root level** of the request (sibling to `operation_type`, `data`, and `env`), NOT nested inside `data` or `operate.operation`.
663
- > - The `guard` objects in the submission use on-chain addresses (not names), as returned by the Phase 1 response.
664
- > - Fill in the `value` field with the actual Order ID (or Order name). Keep the other fields (`identifier`, `value_type`, `name`, `object_type`) as returned by Phase 1.
665
- > - Replace `<insurance_progress_id>` and `<insurance_order_id>` with actual values from step 8.1.
675
+ > - The `submission` field must be at the **root level** of the request (sibling to `operation_type`, `data`, and `env`), NOT nested inside `data` or `progress.operation`.
676
+ > - The `guard` objects in the submission use on-chain addresses (not names), as returned by the Phase 1 response. Replace `0x1508ded8...` with the actual guard address from your Phase 1 response.
677
+ > - The `value` field accepts either an on-chain object ID or a named object reference (e.g., `"test_insurance_order_v1"`). Keep the other fields (`identifier`, `value_type`, `name`, `object_type`) as returned by Phase 1.
678
+ > - The Order is referenced by its name (`"test_insurance_order_v1"`) in the `data.object` field.
666
679
  > - Both `next_node_name` and `forward` fields are required in the operation object.
667
680
  > - Use simple forward name `"complete_claim"` without node prefix.
668
681
 
669
682
  ---
670
683
 
684
+ ## Step 9: Withdraw Funds via Allocation
685
+
686
+ After the Progress reaches the Complete node, the insurance provider can withdraw the order funds using the `insurance_withdraw_guard_v1` Guard. This Guard verifies that `progress.current == "Complete"` (query 1253) via the submitted Order ID with `convert_witness: 100` (TypeOrderProgress).
687
+
688
+ The Allocation object was created automatically when the Order was placed (Step 8.1). Query the Order to obtain the Allocation object ID — it is in the `allocation` field of the Order object.
689
+
690
+ > **Two-Phase Submission**: The `alloc_by_guard` operation also uses two-phase submission when the Guard has `b_submission: true` fields, just like the Progress operation in Step 8.3.
691
+
692
+ ### 9.1 Phase 1: Request Submission Prompt
693
+
694
+ Call the allocation operation WITHOUT the `submission` field to obtain the Guard submission structure.
695
+
696
+ **Prompt**: Withdraw funds from allocation "insurance_test_alloc_v1" using withdraw guard.
697
+
698
+ ```json
699
+ {
700
+ "operation_type": "allocation",
701
+ "data": {
702
+ "object": "insurance_test_alloc_v1",
703
+ "alloc_by_guard": "insurance_withdraw_guard_v1"
704
+ },
705
+ "env": {
706
+ "account": "insurance_provider_v1",
707
+ "network": "testnet"
708
+ }
709
+ }
710
+ ```
711
+
712
+ The server will return a `submission` prompt like:
713
+
714
+ ```json
715
+ {
716
+ "type": "submission",
717
+ "guard": [
718
+ { "object": "0xfb8bed2f...", "impack": true }
719
+ ],
720
+ "submission": [
721
+ {
722
+ "guard": "0xfb8bed2f...",
723
+ "submission": [
724
+ {
725
+ "identifier": 0,
726
+ "b_submission": true,
727
+ "value_type": 1,
728
+ "name": "order_id",
729
+ "object_type": "Order"
730
+ }
731
+ ]
732
+ }
733
+ ]
734
+ }
735
+ ```
736
+
737
+ ### 9.2 Phase 2: Submit with Order ID
738
+
739
+ Fill in the `value` field with the Order ID (or Order name) and resubmit. The `submission` field must be placed at the **root level** of the request.
740
+
741
+ **Prompt**: Withdraw funds from allocation with Order ID submission.
742
+
743
+ ```json
744
+ {
745
+ "operation_type": "allocation",
746
+ "data": {
747
+ "object": "insurance_test_alloc_v1",
748
+ "alloc_by_guard": "insurance_withdraw_guard_v1"
749
+ },
750
+ "submission": {
751
+ "type": "submission",
752
+ "guard": [
753
+ {
754
+ "object": "0xfb8bed2f...",
755
+ "impack": true
756
+ }
757
+ ],
758
+ "submission": [
759
+ {
760
+ "guard": "0xfb8bed2f...",
761
+ "submission": [
762
+ {
763
+ "identifier": 0,
764
+ "b_submission": true,
765
+ "value_type": 1,
766
+ "name": "order_id",
767
+ "object_type": "Order",
768
+ "value": "test_insurance_order_v1"
769
+ }
770
+ ]
771
+ }
772
+ ]
773
+ },
774
+ "env": {
775
+ "account": "insurance_provider_v1",
776
+ "network": "testnet"
777
+ }
778
+ }
779
+ ```
780
+
781
+ > **⚠️ Important**:
782
+ > - Replace `0xfb8bed2f...` with the actual `insurance_withdraw_guard_v1` address from your Phase 1 response.
783
+ > - The `value` field accepts either an on-chain object ID or a named object reference (e.g., `"test_insurance_order_v1"`).
784
+ > - The `sharing` configuration (100% Rate to Signer) determines how funds are distributed. In this example, 100% of the order amount goes to the transaction signer (`insurance_provider_v1`).
785
+ > - After a successful withdrawal, the Allocation `balance` becomes `0` and a Payment object is created as an immutable record.
786
+
787
+ ---
788
+
671
789
  ## Troubleshooting
672
790
 
673
791
  ### MoveAbort code: 7 (Guard Verification Failed)
@@ -715,8 +833,9 @@ Published Machine nodes are immutable (`MoveAbort code: 3`). Create a new Machin
715
833
  - [ ] Step 3: Create `insurance_withdraw_guard_v1`
716
834
  - [ ] Step 4: Create `insurance_machine_v1` with nodes and publish
717
835
  - [ ] Step 5: Create and publish `insurance_service_v1` (with machine, order_allocators, sales)
718
- - [ ] Step 6: Unpause Service
836
+ - [ ] Step 6: Unpause Service (Optional — skip if service was never paused)
719
837
  - [ ] Step 7: Verify Service configuration
720
838
  - [ ] Step 8.1: Create test insurance order
721
839
  - [ ] Step 8.2: Advance progress Initial -> Start
722
840
  - [ ] Step 8.3: Advance progress Start -> Complete with submission (wait 10s after Step 8.2)
841
+ - [ ] Step 9: Withdraw funds via Allocation (alloc_by_guard with withdraw guard)