@wowok/skills 1.3.4 → 2.0.1
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/README.md +18 -11
- package/dist/cli.js +26 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/skills.d.ts +52 -5
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +104 -63
- package/dist/skills.js.map +1 -1
- package/examples/Insurance/Insurance.md +224 -197
- package/examples/MyShop/MyShop.md +133 -35
- package/examples/MyShop_Advanced/MyShop_Advanced.md +368 -300
- package/examples/ThreeBody_Signature/ThreeBody_Signature.md +272 -25
- package/examples/Travel/Travel.md +104 -17
- package/package.json +2 -6
- package/scripts/install.js +52 -6
- package/wowok-arbitrator/SKILL.md +1 -1
- package/wowok-auditor/SKILL.md +1 -1
- package/wowok-machine/SKILL.md +2 -2
- package/wowok-messenger/SKILL.md +5 -3
- package/wowok-onboard/SKILL.md +43 -24
- package/wowok-order/SKILL.md +22 -7
- package/wowok-output/SKILL.md +4 -4
- package/wowok-planner/SKILL.md +2 -1
- package/wowok-provider/SKILL.md +48 -38
- package/wowok-guard/SKILL.md +0 -359
- package/wowok-safety/SKILL.md +0 -275
- package/wowok-scenario/SKILL.md +0 -371
- package/wowok-tools/SKILL.md +0 -389
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Insurance Service Example
|
|
2
2
|
|
|
3
|
-
A complete example demonstrating how to create an outdoor accident insurance service using WoWok protocol. This insurance
|
|
3
|
+
A complete example demonstrating how to create an outdoor accident insurance service using WoWok protocol. This example demonstrates the **single-payer flow** — the insurance provider creates a test order with its own account. Supply-chain sub-ordering (a travel service provider purchasing on behalf of travelers via the `order_new.agents` field, with its own account and permissions) is out of scope for this document.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ A complete example demonstrating how to create an outdoor accident insurance ser
|
|
|
21
21
|
|-------------|-------------|----------------|
|
|
22
22
|
| **Insurance Claims** | Process insurance claims with time-lock verification | Machine with Start -> Complete workflow |
|
|
23
23
|
| **Time-Lock Guard** | Prevent premature claim completion | Guard using Order + convert_witness(TypeOrderProgress) to verify clock > progress.current_time + lock_duration |
|
|
24
|
-
| **
|
|
24
|
+
| **Single-Payer Order Flow** | Demonstrates order creation by the insurance provider's own account | `order_new` on the Service (supply-chain sub-ordering via the `agents` field is out of scope for this example) |
|
|
25
25
|
| **Permission Control** | Role-based access for insurance operations | Permission object with custom indexes for claim processing |
|
|
26
26
|
| **Safe Fund Allocation** | Merchant revenue collection without theft risk | 2 alternative allocators with `sharing.who = {"Entity": ...}` (funds flow to fixed Treasury or personal address) |
|
|
27
27
|
|
|
@@ -94,7 +94,7 @@ This example demonstrates:
|
|
|
94
94
|
|
|
95
95
|
**Guard Logic**:
|
|
96
96
|
```
|
|
97
|
-
clock > progress.current_time +
|
|
97
|
+
clock > progress.current_time + 10000ms
|
|
98
98
|
(progress accessed via Order + convert_witness="OrderProgress")
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -244,7 +244,7 @@ Create a Guard that verifies the time-lock condition for claim completion. The G
|
|
|
244
244
|
|
|
245
245
|
**Guard Logic**:
|
|
246
246
|
```
|
|
247
|
-
clock > progress.current_time +
|
|
247
|
+
clock > progress.current_time + 10000
|
|
248
248
|
```
|
|
249
249
|
|
|
250
250
|
**Prompt**: Create a Guard named "insurance_complete_guard" for time-lock verification on claim completion.
|
|
@@ -323,10 +323,143 @@ clock > progress.current_time + 1000
|
|
|
323
323
|
|
|
324
324
|
---
|
|
325
325
|
|
|
326
|
-
## Step 4: Create
|
|
326
|
+
## Step 4: Create, Configure and Publish Machine
|
|
327
|
+
|
|
328
|
+
Create a Machine with workflow nodes and publish it in a single transaction.
|
|
329
|
+
|
|
330
|
+
> **IMPORTANT**:
|
|
331
|
+
> - Machine nodes are added during creation in the same transaction
|
|
332
|
+
> - Once published, Machine nodes become immutable and cannot be modified
|
|
333
|
+
> - If you need to change nodes after publishing, you must create a new Machine
|
|
334
|
+
|
|
335
|
+
**Prompt**: Create a Machine named "insurance_machine" with the claim processing workflow and publish it.
|
|
336
|
+
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"tool": "onchain_operations",
|
|
340
|
+
"data": {
|
|
341
|
+
"operation_type": "machine",
|
|
342
|
+
"data": {
|
|
343
|
+
"object": {
|
|
344
|
+
"name": "insurance_machine_v1",
|
|
345
|
+
"permission": "insurance_permission_v1",
|
|
346
|
+
"replaceExistName": true
|
|
347
|
+
},
|
|
348
|
+
"description": "Insurance claim processing workflow: Start -> Complete (with time-lock guard)",
|
|
349
|
+
"node": {
|
|
350
|
+
"op": "add",
|
|
351
|
+
"nodes": [
|
|
352
|
+
{
|
|
353
|
+
"name": "Start",
|
|
354
|
+
"pairs": [
|
|
355
|
+
{
|
|
356
|
+
"prev_node": "",
|
|
357
|
+
"threshold": 0,
|
|
358
|
+
"forwards": [
|
|
359
|
+
{
|
|
360
|
+
"name": "start_claim",
|
|
361
|
+
"permissionIndex": 1000,
|
|
362
|
+
"weight": 1
|
|
363
|
+
}
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"name": "Complete",
|
|
370
|
+
"pairs": [
|
|
371
|
+
{
|
|
372
|
+
"prev_node": "Start",
|
|
373
|
+
"threshold": 1,
|
|
374
|
+
"forwards": [
|
|
375
|
+
{
|
|
376
|
+
"name": "complete_claim",
|
|
377
|
+
"permissionIndex": 1001,
|
|
378
|
+
"weight": 1,
|
|
379
|
+
"guard": {
|
|
380
|
+
"guard": "insurance_complete_guard_v1"
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
"publish": true
|
|
390
|
+
},
|
|
391
|
+
"env": {
|
|
392
|
+
"account": "insurance_provider_v1",
|
|
393
|
+
"network": "testnet"
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Workflow Nodes**:
|
|
400
|
+
|
|
401
|
+
| Node | Forward | Guard | Description |
|
|
402
|
+
|------|---------|-------|-------------|
|
|
403
|
+
| Start | start_claim -> Start | - | Enter the Start node from initial state |
|
|
404
|
+
| Complete | complete_claim -> Complete | insurance_complete_guard_v1 | Complete the claim after time-lock verification |
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Step 5: Create Service (Unpublished)
|
|
409
|
+
|
|
410
|
+
Create the insurance service with machine, sales, and description — WITHOUT `order_allocators` and WITHOUT publishing (`publish: false`).
|
|
411
|
+
|
|
412
|
+
> **Why create the Service before the withdraw Guards?** Each withdraw Guard's static table (Step 6) stores the Service address as `value: "insurance_service_v1"`, and this name must resolve to an on-chain object at transaction build time. Creating the Service first (unpublished) makes the name resolvable — otherwise Guard creation fails at build time, or (on re-runs with `replaceExistName`) silently binds to the previous run's orphaned Service address. `order_allocators` is then added in Step 7 together with `publish: true` (allocators can only be set before publish). This is the standard object–Guard circular-reference pattern: create the object → create the Guards that reference it → update the object to bind the Guards.
|
|
413
|
+
|
|
414
|
+
**Prompt**: Create a Service named "insurance_service_v1" with machine and insurance product (unpublished).
|
|
415
|
+
|
|
416
|
+
```json
|
|
417
|
+
{
|
|
418
|
+
"tool": "onchain_operations",
|
|
419
|
+
"data": {
|
|
420
|
+
"operation_type": "service",
|
|
421
|
+
"data": {
|
|
422
|
+
"object": {
|
|
423
|
+
"name": "insurance_service_v1",
|
|
424
|
+
"type_parameter": "0x2::wow::WOW",
|
|
425
|
+
"permission": "insurance_permission_v1",
|
|
426
|
+
"replaceExistName": true
|
|
427
|
+
},
|
|
428
|
+
"description": "Outdoor accident insurance for Iceland travel. Provides coverage for ice scooting and other outdoor activities.",
|
|
429
|
+
"machine": "insurance_machine_v1",
|
|
430
|
+
"sales": {
|
|
431
|
+
"op": "add",
|
|
432
|
+
"sales": [
|
|
433
|
+
{
|
|
434
|
+
"name": "Outdoor Accident Insurance",
|
|
435
|
+
"price": 100000000,
|
|
436
|
+
"stock": 1000,
|
|
437
|
+
"suspension": false,
|
|
438
|
+
"wip": "https://cdn.jsdelivr.net/gh/wowok-ai/docs@main/wip-examples/three_body.wip",
|
|
439
|
+
"wip_hash": ""
|
|
440
|
+
}
|
|
441
|
+
]
|
|
442
|
+
},
|
|
443
|
+
"publish": false
|
|
444
|
+
},
|
|
445
|
+
"env": {
|
|
446
|
+
"account": "insurance_provider_v1",
|
|
447
|
+
"network": "testnet"
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
> **Note**: The `wip` URL above is a **placeholder** (a sample WIP file from the Three-Body example) — replace it with your own insurance product WIP file in real use. `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.
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
## Step 6: Create Withdraw Guards for Order Allocators
|
|
327
458
|
|
|
328
459
|
Create **two** withdraw Guards — one for each merchant collection approach. Both Guards share identical root/table logic (order at Complete node + project binding) but differ in `description` to indicate their distinct purposes. Allocators require unique Guard addresses, so two Guard objects are needed.
|
|
329
460
|
|
|
461
|
+
The `insurance_service_v1` name used in each Guard's static table below (`value: "insurance_service_v1"`) was created in Step 5, so it resolves to the current run's Service address at transaction build time.
|
|
462
|
+
|
|
330
463
|
**Guard Logic** (identical for both):
|
|
331
464
|
```
|
|
332
465
|
logic_and[
|
|
@@ -337,9 +470,9 @@ logic_and[
|
|
|
337
470
|
|
|
338
471
|
**Risk Elimination**:
|
|
339
472
|
- **Project binding** (query 1563): prevents cross-service order theft — an attacker cannot submit another Service's completed Order to trigger allocation.
|
|
340
|
-
- **Entity sharing** (configured in Step
|
|
473
|
+
- **Entity sharing** (configured in Step 7): funds flow to a fixed address regardless of caller — no Signer binding needed in the Guard.
|
|
341
474
|
|
|
342
|
-
###
|
|
475
|
+
### 6.1 Treasury Collection Guard
|
|
343
476
|
|
|
344
477
|
**Prompt**: Create a Guard named "insurance_withdraw_guard_treasury" for Treasury fund collection.
|
|
345
478
|
|
|
@@ -360,7 +493,6 @@ logic_and[
|
|
|
360
493
|
"identifier": 0,
|
|
361
494
|
"b_submission": true,
|
|
362
495
|
"value_type": "Address",
|
|
363
|
-
"object_type": "Order",
|
|
364
496
|
"name": "order_id (Order object submitted at runtime)"
|
|
365
497
|
},
|
|
366
498
|
{
|
|
@@ -427,7 +559,7 @@ logic_and[
|
|
|
427
559
|
}
|
|
428
560
|
```
|
|
429
561
|
|
|
430
|
-
###
|
|
562
|
+
### 6.2 Personal Collection Guard
|
|
431
563
|
|
|
432
564
|
**Prompt**: Create a Guard named "insurance_withdraw_guard_personal" for personal fund collection.
|
|
433
565
|
|
|
@@ -448,7 +580,6 @@ logic_and[
|
|
|
448
580
|
"identifier": 0,
|
|
449
581
|
"b_submission": true,
|
|
450
582
|
"value_type": "Address",
|
|
451
|
-
"object_type": "Order",
|
|
452
583
|
"name": "order_id (Order object submitted at runtime)"
|
|
453
584
|
},
|
|
454
585
|
{
|
|
@@ -527,98 +658,16 @@ logic_and[
|
|
|
527
658
|
|
|
528
659
|
---
|
|
529
660
|
|
|
530
|
-
## Step
|
|
531
|
-
|
|
532
|
-
Create a Machine with workflow nodes and publish it in a single transaction.
|
|
533
|
-
|
|
534
|
-
> **IMPORTANT**:
|
|
535
|
-
> - Machine nodes are added during creation in the same transaction
|
|
536
|
-
> - Once published, Machine nodes become immutable and cannot be modified
|
|
537
|
-
> - If you need to change nodes after publishing, you must create a new Machine
|
|
538
|
-
|
|
539
|
-
**Prompt**: Create a Machine named "insurance_machine" with the claim processing workflow and publish it.
|
|
540
|
-
|
|
541
|
-
```json
|
|
542
|
-
{
|
|
543
|
-
"tool": "onchain_operations",
|
|
544
|
-
"data": {
|
|
545
|
-
"operation_type": "machine",
|
|
546
|
-
"data": {
|
|
547
|
-
"object": {
|
|
548
|
-
"name": "insurance_machine_v1",
|
|
549
|
-
"permission": "insurance_permission_v1",
|
|
550
|
-
"replaceExistName": true
|
|
551
|
-
},
|
|
552
|
-
"description": "Insurance claim processing workflow: Start -> Complete (with time-lock guard)",
|
|
553
|
-
"node": {
|
|
554
|
-
"op": "add",
|
|
555
|
-
"nodes": [
|
|
556
|
-
{
|
|
557
|
-
"name": "Start",
|
|
558
|
-
"pairs": [
|
|
559
|
-
{
|
|
560
|
-
"prev_node": "",
|
|
561
|
-
"threshold": 0,
|
|
562
|
-
"forwards": [
|
|
563
|
-
{
|
|
564
|
-
"name": "start_claim",
|
|
565
|
-
"permissionIndex": 1000,
|
|
566
|
-
"weight": 1
|
|
567
|
-
}
|
|
568
|
-
]
|
|
569
|
-
}
|
|
570
|
-
]
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
"name": "Complete",
|
|
574
|
-
"pairs": [
|
|
575
|
-
{
|
|
576
|
-
"prev_node": "Start",
|
|
577
|
-
"threshold": 1,
|
|
578
|
-
"forwards": [
|
|
579
|
-
{
|
|
580
|
-
"name": "complete_claim",
|
|
581
|
-
"permissionIndex": 1001,
|
|
582
|
-
"weight": 1,
|
|
583
|
-
"guard": {
|
|
584
|
-
"guard": "insurance_complete_guard_v1"
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
]
|
|
588
|
-
}
|
|
589
|
-
]
|
|
590
|
-
}
|
|
591
|
-
]
|
|
592
|
-
},
|
|
593
|
-
"publish": true
|
|
594
|
-
},
|
|
595
|
-
"env": {
|
|
596
|
-
"account": "insurance_provider_v1",
|
|
597
|
-
"network": "testnet"
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
**Workflow Nodes**:
|
|
604
|
-
|
|
605
|
-
| Node | Forward | Guard | Description |
|
|
606
|
-
|------|---------|-------|-------------|
|
|
607
|
-
| Start | start_claim -> Start | - | Enter the Start node from initial state |
|
|
608
|
-
| Complete | complete_claim -> Complete | insurance_complete_guard_v1 | Complete the claim after time-lock verification |
|
|
609
|
-
|
|
610
|
-
---
|
|
611
|
-
|
|
612
|
-
## Step 6: Create and Publish Service
|
|
661
|
+
## Step 7: Add Order Allocators and Publish Service
|
|
613
662
|
|
|
614
|
-
|
|
663
|
+
Update `insurance_service_v1` to add the `order_allocators` (2 alternative merchant collection approaches referencing the withdraw Guards created in Step 6) and publish the Service in a single transaction.
|
|
615
664
|
|
|
616
665
|
> **Important**:
|
|
617
666
|
> - Service must include `order_allocators` when publishing
|
|
618
667
|
> - After publishing, `machine`, `order_allocators`, and `arbitrations` become immutable
|
|
619
|
-
> - Ensure the Machine is properly configured
|
|
668
|
+
> - Ensure the Machine is properly configured (Step 4) and both withdraw Guards exist (Step 6) before publishing
|
|
620
669
|
|
|
621
|
-
**Prompt**:
|
|
670
|
+
**Prompt**: Update "insurance_service_v1" to add order allocation rules and publish it.
|
|
622
671
|
|
|
623
672
|
```json
|
|
624
673
|
{
|
|
@@ -626,14 +675,7 @@ Create the insurance service with machine, order_allocators (2 alternative appro
|
|
|
626
675
|
"data": {
|
|
627
676
|
"operation_type": "service",
|
|
628
677
|
"data": {
|
|
629
|
-
"object":
|
|
630
|
-
"name": "insurance_service_v1",
|
|
631
|
-
"type_parameter": "0x2::wow::WOW",
|
|
632
|
-
"permission": "insurance_permission_v1",
|
|
633
|
-
"replaceExistName": true
|
|
634
|
-
},
|
|
635
|
-
"description": "Outdoor accident insurance for Iceland travel. Provides coverage for ice scooting and other outdoor activities.",
|
|
636
|
-
"machine": "insurance_machine_v1",
|
|
678
|
+
"object": "insurance_service_v1",
|
|
637
679
|
"order_allocators": {
|
|
638
680
|
"description": "Insurance order revenue allocation — 2 alternative merchant collection approaches (first-match-wins means only the first passing allocator executes)",
|
|
639
681
|
"threshold": 0,
|
|
@@ -642,7 +684,7 @@ Create the insurance service with machine, order_allocators (2 alternative appro
|
|
|
642
684
|
"guard": "insurance_withdraw_guard_treasury_v1",
|
|
643
685
|
"sharing": [
|
|
644
686
|
{
|
|
645
|
-
"who": {"Entity": "insurance_treasury_v1"},
|
|
687
|
+
"who": {"Entity": {"name_or_address": "insurance_treasury_v1"}},
|
|
646
688
|
"sharing": 10000,
|
|
647
689
|
"mode": "Rate"
|
|
648
690
|
}
|
|
@@ -652,7 +694,7 @@ Create the insurance service with machine, order_allocators (2 alternative appro
|
|
|
652
694
|
"guard": "insurance_withdraw_guard_personal_v1",
|
|
653
695
|
"sharing": [
|
|
654
696
|
{
|
|
655
|
-
"who": {"Entity": "insurance_provider_v1"},
|
|
697
|
+
"who": {"Entity": {"name_or_address": "insurance_provider_v1"}},
|
|
656
698
|
"sharing": 10000,
|
|
657
699
|
"mode": "Rate"
|
|
658
700
|
}
|
|
@@ -660,19 +702,6 @@ Create the insurance service with machine, order_allocators (2 alternative appro
|
|
|
660
702
|
}
|
|
661
703
|
]
|
|
662
704
|
},
|
|
663
|
-
"sales": {
|
|
664
|
-
"op": "add",
|
|
665
|
-
"sales": [
|
|
666
|
-
{
|
|
667
|
-
"name": "Outdoor Accident Insurance",
|
|
668
|
-
"price": 100000000,
|
|
669
|
-
"stock": 1000,
|
|
670
|
-
"suspension": false,
|
|
671
|
-
"wip": "https://cdn.jsdelivr.net/gh/wowok-ai/docs@main/wip-examples/three_body.wip",
|
|
672
|
-
"wip_hash": ""
|
|
673
|
-
}
|
|
674
|
-
]
|
|
675
|
-
},
|
|
676
705
|
"publish": true
|
|
677
706
|
},
|
|
678
707
|
"env": {
|
|
@@ -685,17 +714,16 @@ Create the insurance service with machine, order_allocators (2 alternative appro
|
|
|
685
714
|
|
|
686
715
|
> **Important — Fund Allocation Safety**:
|
|
687
716
|
> - `mode: "Rate"` represents Rate allocation mode (valid values: `"Amount"`, `"Rate"`, `"Surplus"`)
|
|
688
|
-
> - `who: {"Entity": "name_or_address"}` — funds flow to a FIXED address (Treasury or personal). This is the SAFE pattern: even if the Guard is somehow bypassed or an attacker submits a forged Order, funds still go to the fixed Entity — the attacker cannot redirect funds to themselves.
|
|
717
|
+
> - `who: {"Entity": {"name_or_address": "..."}}` — funds flow to a FIXED address (Treasury or personal). This is the SAFE pattern: even if the Guard is somehow bypassed or an attacker submits a forged Order, funds still go to the fixed Entity — the attacker cannot redirect funds to themselves.
|
|
689
718
|
> - **NEVER use `who: {"Signer": "signer"}` for merchant collection** — this means funds flow to whoever calls the allocation. Combined with a Guard that only checks order status (no Signer binding), anyone can submit any completed Order and steal 100% of funds.
|
|
690
719
|
> - **2 allocators = 2 alternative approaches**: first-match-wins means only the FIRST allocator whose Guard passes will execute. In production, pick ONE approach (Treasury OR personal) and delete the other. Listing both here illustrates the 2 design options.
|
|
691
720
|
> - **Permission consistency**: the Treasury uses `insurance_permission_v1` (same as Service) — keep Permissions consistent unless you have a specific reason to separate them.
|
|
692
|
-
> - `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.
|
|
693
721
|
|
|
694
722
|
---
|
|
695
723
|
|
|
696
|
-
## Step
|
|
724
|
+
## Step 8: Unpause Service (Optional)
|
|
697
725
|
|
|
698
|
-
> **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
|
|
726
|
+
> **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 9.
|
|
699
727
|
|
|
700
728
|
Unpause the service to allow order creation.
|
|
701
729
|
|
|
@@ -720,7 +748,7 @@ Unpause the service to allow order creation.
|
|
|
720
748
|
|
|
721
749
|
---
|
|
722
750
|
|
|
723
|
-
## Step
|
|
751
|
+
## Step 9: Verify Service Configuration
|
|
724
752
|
|
|
725
753
|
Query the service to verify all configurations are correct.
|
|
726
754
|
|
|
@@ -739,11 +767,11 @@ Query the service to verify all configurations are correct.
|
|
|
739
767
|
|
|
740
768
|
---
|
|
741
769
|
|
|
742
|
-
## Step
|
|
770
|
+
## Step 10: Test Order Creation and Progress
|
|
743
771
|
|
|
744
|
-
###
|
|
772
|
+
### 10.1 Create Insurance Order
|
|
745
773
|
|
|
746
|
-
Create an order on the insurance service using the `order_new` field of the `service` operation.
|
|
774
|
+
Create an order on the insurance service using the `order_new` field of the `service` operation. This example uses a single-payer flow — the insurance provider creates the test order with its own account. Supply-chain sub-ordering (a travel agency purchasing via `order_new.agents`) is out of scope for this example.
|
|
747
775
|
|
|
748
776
|
**Prompt**: Create an order on "insurance_service_v1" using account "insurance_provider_v1".
|
|
749
777
|
|
|
@@ -805,7 +833,7 @@ Create an order on the insurance service using the `order_new` field of the `ser
|
|
|
805
833
|
> ```
|
|
806
834
|
> The response includes `progress` and `allocation` fields with the on-chain object IDs.
|
|
807
835
|
|
|
808
|
-
###
|
|
836
|
+
### 10.2 Advance Progress: Initial -> Start
|
|
809
837
|
|
|
810
838
|
First, advance the progress from initial state to Start node.
|
|
811
839
|
|
|
@@ -822,7 +850,8 @@ First, advance the progress from initial state to Start node.
|
|
|
822
850
|
"operation": {
|
|
823
851
|
"next_node_name": "Start",
|
|
824
852
|
"forward": "start_claim"
|
|
825
|
-
}
|
|
853
|
+
},
|
|
854
|
+
"op": "next"
|
|
826
855
|
}
|
|
827
856
|
},
|
|
828
857
|
"env": {
|
|
@@ -834,11 +863,11 @@ First, advance the progress from initial state to Start node.
|
|
|
834
863
|
```
|
|
835
864
|
|
|
836
865
|
> **Note**:
|
|
837
|
-
> -
|
|
866
|
+
> - The `progress` object requires `operation` (with both `next_node_name` and `forward` fields) plus the `op` field — use `"op": "next"` to advance the forward (other values: `"hold"`, `"unhold"`, `"adminUnhold"`)
|
|
838
867
|
> - Use simple forward name (e.g., `"start_claim"`) without node prefix. The system automatically resolves the path from current node
|
|
839
868
|
> - The Progress is advanced via the Order object's `progress` field, using the Order name as reference
|
|
840
869
|
|
|
841
|
-
###
|
|
870
|
+
### 10.3 Advance Progress: Start -> Complete
|
|
842
871
|
|
|
843
872
|
Wait at least 10 seconds after entering Start node, then advance the progress to Complete with the Order ID as submission.
|
|
844
873
|
|
|
@@ -861,7 +890,8 @@ Wait at least 10 seconds after entering Start node, then advance the progress to
|
|
|
861
890
|
"operation": {
|
|
862
891
|
"next_node_name": "Complete",
|
|
863
892
|
"forward": "complete_claim"
|
|
864
|
-
}
|
|
893
|
+
},
|
|
894
|
+
"op": "next"
|
|
865
895
|
}
|
|
866
896
|
},
|
|
867
897
|
"env": {
|
|
@@ -872,38 +902,35 @@ Wait at least 10 seconds after entering Start node, then advance the progress to
|
|
|
872
902
|
}
|
|
873
903
|
```
|
|
874
904
|
|
|
875
|
-
The server will return a `submission` prompt
|
|
905
|
+
The server will return a `submission` prompt (illustrative example — actual guard addresses come from your Phase 1 response):
|
|
876
906
|
|
|
877
907
|
```json
|
|
878
908
|
{
|
|
879
909
|
"result": {
|
|
880
|
-
"
|
|
881
|
-
"
|
|
882
|
-
"
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
]
|
|
900
|
-
}
|
|
910
|
+
"type": "submission",
|
|
911
|
+
"guard": [
|
|
912
|
+
{ "object": "0x1508ded8...", "impack": true }
|
|
913
|
+
],
|
|
914
|
+
"submission": [
|
|
915
|
+
{
|
|
916
|
+
"guard": "0x1508ded8...",
|
|
917
|
+
"submission": [
|
|
918
|
+
{
|
|
919
|
+
"identifier": 0,
|
|
920
|
+
"b_submission": true,
|
|
921
|
+
"value_type": "Address",
|
|
922
|
+
"name": "Order ID (submitted at runtime)",
|
|
923
|
+
"object_type": "Order"
|
|
924
|
+
}
|
|
925
|
+
]
|
|
926
|
+
}
|
|
927
|
+
]
|
|
901
928
|
},
|
|
902
|
-
"
|
|
929
|
+
"message": "Guard verification required: fill the submission array and resubmit."
|
|
903
930
|
}
|
|
904
931
|
```
|
|
905
932
|
|
|
906
|
-
> **Note**: The
|
|
933
|
+
> **Note**: The examples in this document use the string form of `value_type` (e.g., `"Address"`). The numeric enum ID form (e.g., `1` for Address) is also accepted as input — when filling in Phase 2, you can use either the string name (`"Address"`) or the numeric form (`1`).
|
|
907
934
|
|
|
908
935
|
**Phase 2**: Fill in the `value` field with the Order ID and resubmit. The `submission` field must be placed at the **root level** of the request (sibling to `operation_type`, `data`, and `env`).
|
|
909
936
|
|
|
@@ -918,7 +945,8 @@ The server will return a `submission` prompt like:
|
|
|
918
945
|
"operation": {
|
|
919
946
|
"next_node_name": "Complete",
|
|
920
947
|
"forward": "complete_claim"
|
|
921
|
-
}
|
|
948
|
+
},
|
|
949
|
+
"op": "next"
|
|
922
950
|
}
|
|
923
951
|
},
|
|
924
952
|
"submission": {
|
|
@@ -958,12 +986,12 @@ The server will return a `submission` prompt like:
|
|
|
958
986
|
> - 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.
|
|
959
987
|
> - 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.
|
|
960
988
|
> - The Order is referenced by its name (`"test_insurance_order_v1"`) in the `data.object` field.
|
|
961
|
-
> -
|
|
989
|
+
> - The `progress` object requires `operation` (with both `next_node_name` and `forward` fields) plus `"op": "next"`.
|
|
962
990
|
> - Use simple forward name `"complete_claim"` without node prefix.
|
|
963
991
|
|
|
964
992
|
---
|
|
965
993
|
|
|
966
|
-
## Step
|
|
994
|
+
## Step 11: Withdraw Funds via Allocation
|
|
967
995
|
|
|
968
996
|
After the Progress reaches the Complete node, funds can be withdrawn using one of the withdraw Guards. This example uses the Treasury collection Guard (`insurance_withdraw_guard_treasury_v1`). To use the personal collection approach instead, substitute `insurance_withdraw_guard_personal_v1`.
|
|
969
997
|
|
|
@@ -971,13 +999,13 @@ The Guard verifies:
|
|
|
971
999
|
1. `progress.current == "Complete"` (query 1253) via the submitted Order ID with `convert_witness: "OrderProgress"` (TypeOrderProgress)
|
|
972
1000
|
2. `order.service == insurance_service_v1` (query 1563) — project binding prevents cross-service order theft
|
|
973
1001
|
|
|
974
|
-
The Allocation object was created automatically when the Order was placed (Step
|
|
1002
|
+
The Allocation object was created automatically when the Order was placed (Step 10.1). Query the Order to obtain the Allocation object ID — it is in the `allocation` field of the Order object.
|
|
975
1003
|
|
|
976
1004
|
> **Fund Flow**: With `sharing.who = {"Entity": "insurance_treasury_v1"}`, 100% of the order amount flows to the Treasury object regardless of who triggers the allocation. The caller cannot redirect funds — this is the safe Entity-sharing pattern.
|
|
977
1005
|
|
|
978
|
-
> **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
|
|
1006
|
+
> **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 10.3.
|
|
979
1007
|
|
|
980
|
-
###
|
|
1008
|
+
### 11.1 Phase 1: Request Submission Prompt
|
|
981
1009
|
|
|
982
1010
|
Call the allocation operation WITHOUT the `submission` field to obtain the Guard submission structure.
|
|
983
1011
|
|
|
@@ -1000,38 +1028,35 @@ Call the allocation operation WITHOUT the `submission` field to obtain the Guard
|
|
|
1000
1028
|
}
|
|
1001
1029
|
```
|
|
1002
1030
|
|
|
1003
|
-
The server will return a `submission` prompt
|
|
1031
|
+
The server will return a `submission` prompt (illustrative example — actual guard addresses come from your Phase 1 response):
|
|
1004
1032
|
|
|
1005
1033
|
```json
|
|
1006
1034
|
{
|
|
1007
1035
|
"result": {
|
|
1008
|
-
"
|
|
1009
|
-
"
|
|
1010
|
-
"
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
]
|
|
1028
|
-
}
|
|
1036
|
+
"type": "submission",
|
|
1037
|
+
"guard": [
|
|
1038
|
+
{ "object": "0xfb8bed2f...", "impack": true }
|
|
1039
|
+
],
|
|
1040
|
+
"submission": [
|
|
1041
|
+
{
|
|
1042
|
+
"guard": "0xfb8bed2f...",
|
|
1043
|
+
"submission": [
|
|
1044
|
+
{
|
|
1045
|
+
"identifier": 0,
|
|
1046
|
+
"b_submission": true,
|
|
1047
|
+
"value_type": "Address",
|
|
1048
|
+
"name": "order_id (Order object submitted at runtime)",
|
|
1049
|
+
"object_type": "Order"
|
|
1050
|
+
}
|
|
1051
|
+
]
|
|
1052
|
+
}
|
|
1053
|
+
]
|
|
1029
1054
|
},
|
|
1030
|
-
"
|
|
1055
|
+
"message": "Guard verification required: fill the submission array and resubmit."
|
|
1031
1056
|
}
|
|
1032
1057
|
```
|
|
1033
1058
|
|
|
1034
|
-
###
|
|
1059
|
+
### 11.2 Phase 2: Submit with Order ID
|
|
1035
1060
|
|
|
1036
1061
|
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.
|
|
1037
1062
|
|
|
@@ -1106,13 +1131,14 @@ If you see `Connection from current node "" to target node "Complete" does not e
|
|
|
1106
1131
|
|
|
1107
1132
|
### Missing required field 'next_node_name'
|
|
1108
1133
|
|
|
1109
|
-
The progress operation requires both `next_node_name` and `forward` fields
|
|
1134
|
+
The progress operation requires `operation` (with both `next_node_name` and `forward` fields) plus the `op` field:
|
|
1110
1135
|
```json
|
|
1111
1136
|
{
|
|
1112
1137
|
"operation": {
|
|
1113
1138
|
"next_node_name": "Start",
|
|
1114
1139
|
"forward": "start_claim"
|
|
1115
|
-
}
|
|
1140
|
+
},
|
|
1141
|
+
"op": "next"
|
|
1116
1142
|
}
|
|
1117
1143
|
```
|
|
1118
1144
|
|
|
@@ -1135,12 +1161,13 @@ Published Machine nodes are immutable (`MoveAbort code: 3`). Create a new Machin
|
|
|
1135
1161
|
- [ ] Step 1: Create `insurance_permission_v1` with all required indexes
|
|
1136
1162
|
- [ ] Step 2: Create `insurance_treasury_v1` (same Permission as Service)
|
|
1137
1163
|
- [ ] Step 3: Create `insurance_complete_guard_v1` (time-lock)
|
|
1138
|
-
- [ ] Step 4: Create `
|
|
1139
|
-
- [ ] Step 5: Create `
|
|
1140
|
-
- [ ] Step 6: Create
|
|
1141
|
-
- [ ] Step 7:
|
|
1142
|
-
- [ ] Step 8:
|
|
1143
|
-
- [ ] Step 9
|
|
1144
|
-
- [ ] Step
|
|
1145
|
-
- [ ] Step
|
|
1146
|
-
- [ ] Step 10:
|
|
1164
|
+
- [ ] Step 4: Create `insurance_machine_v1` with nodes and publish
|
|
1165
|
+
- [ ] Step 5: Create `insurance_service_v1` unpublished (machine + sales, `publish: false` — so withdraw Guards can resolve its address)
|
|
1166
|
+
- [ ] Step 6: Create `insurance_withdraw_guard_treasury_v1` + `insurance_withdraw_guard_personal_v1` (project binding)
|
|
1167
|
+
- [ ] Step 7: Add 2 Entity-sharing order_allocators to `insurance_service_v1` and publish
|
|
1168
|
+
- [ ] Step 8: Unpause Service (Optional — skip if service was never paused)
|
|
1169
|
+
- [ ] Step 9: Verify Service configuration
|
|
1170
|
+
- [ ] Step 10.1: Create test insurance order
|
|
1171
|
+
- [ ] Step 10.2: Advance progress Initial -> Start
|
|
1172
|
+
- [ ] Step 10.3: Advance progress Start -> Complete with submission (wait 10s after Step 10.2)
|
|
1173
|
+
- [ ] Step 11: Withdraw funds via Allocation (alloc_by_guard with Treasury or personal withdraw guard)
|