@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
|
@@ -18,9 +18,11 @@ This example sets `env.confirmed: true` on irreversible operations (e.g., `publi
|
|
|
18
18
|
1. **Phase 1 — Preview**: Call the tool **without** `env.confirmed`. The server returns `{ status: "pending_confirmation", confirmation_text: "..." }` containing the full operation summary, risk assessment, and irreversible-action warnings.
|
|
19
19
|
2. **Phase 2 — Confirm**: Review `confirmation_text` with the user. Only after explicit user approval, call the tool again **with** `env.confirmed: true` to actually execute the on-chain transaction.
|
|
20
20
|
|
|
21
|
-
> Skipping Phase 1 means the user never sees the risk summary before gas is spent. Always preview first, then confirm. This is especially critical for the `publish: true`
|
|
21
|
+
> Skipping Phase 1 means the user never sees the risk summary before gas is spent. Always preview first, then confirm. This is especially critical for the two `publish: true` steps in this doc: the Machine publish (**Step 3**), which irreversibly locks the workflow definition (`nodes`/`pairs`/`forwards`), and the Service publish (**Step 10**), which irreversibly locks the `machine` and `order_allocators` fields.
|
|
22
22
|
|
|
23
23
|
> **💡 Call Format**: All WoWok operations go through a single unified `wowok` tool. The AI calls `wowok({ tool: "<sub-tool>", data: {<params>} })`. If parameters don't match the schema, the response includes the correct schema for self-correction. See [Response Format](../../docs/response-format.md) for details.
|
|
24
|
+
>
|
|
25
|
+
> **📄 Expected Results**: The Expected Result envelopes below omit the optional `message` and `semantic` fields (human-readable summary / business semantic summary) for brevity — real responses may include them.
|
|
24
26
|
|
|
25
27
|
---
|
|
26
28
|
|
|
@@ -35,7 +37,7 @@ This example demonstrates:
|
|
|
35
37
|
1. **Buy Guard Protection**: Only the author (`three_body_author`) can purchase this service, preventing unauthorized usage
|
|
36
38
|
2. **Simple Two-Node Workflow**: Clear progression from delivery to completion
|
|
37
39
|
3. **WIP Files Optional**: Can use WIP files or empty strings
|
|
38
|
-
4. **Fixed Price**: 888
|
|
40
|
+
4. **Fixed Price**: 888 WOW for the signature service
|
|
39
41
|
|
|
40
42
|
---
|
|
41
43
|
|
|
@@ -182,6 +184,8 @@ If the accounts do not exist locally, generate them first.
|
|
|
182
184
|
```
|
|
183
185
|
|
|
184
186
|
> **Note**: Each faucet result item includes a `transferTxDigest` field representing the on-chain transaction digest for the faucet transfer. This is useful for tracking and verifying the faucet transaction on a block explorer.
|
|
187
|
+
>
|
|
188
|
+
> **Amount Note**: Each faucet request distributes 3 WOW (3 × 1 WOW; WOW has 9 decimals, so 1 WOW = 1,000,000,000 smallest units). Since the sale price in this example is 888 WOW, repeat the faucet request until each account holds ≥ 1000 WOW (price + gas).
|
|
185
189
|
|
|
186
190
|
> **Important**: Repeat the faucet request for `three_body_customer` as well, since Test 2 requires a funded non-author account to attempt the blocked purchase.
|
|
187
191
|
|
|
@@ -219,8 +223,10 @@ Create a Permission object to manage the service.
|
|
|
219
223
|
```
|
|
220
224
|
|
|
221
225
|
> **Permission Index Explanation**:
|
|
222
|
-
> -
|
|
223
|
-
> - **`
|
|
226
|
+
> - **Admin bypass (why this single-account flow works)**: The Permission creator (`three_body_author`) automatically becomes an **admin** of the Permission object, and admins bypass per-index checks — the SDK's permission check only looks up granted indexes when the caller is NOT an admin. So the author can execute every step below even though the granted index list does not enumerate every built-in index used.
|
|
227
|
+
> - **`1000`–`1009`**: User-defined permission indexes (starting from `USER_DEFINED_PERM_INDEX_START = 1000`). In this example, `1000` is used for the "Confirm Delivery" forward and `1001` for the "Complete Signature" forward in the Machine workflow (see Step 3). The remaining indexes (`1002`–`1009`) are reserved for future workflow extensions. These grants matter for non-admin operators: a Machine forward checks its `permissionIndex` against the operator's granted indexes (or admin status).
|
|
228
|
+
> - **`306`**: The built-in `SERVICE_MACHINE` permission (Service module permission index `306`), which authorizes binding a Machine to a Service (used in Step 5, Configure Machine). It is granted here defensively — the author does not strictly need it thanks to the admin bypass above, but a non-admin operator would.
|
|
229
|
+
> - **Full built-in index list a NON-admin operator would need for this example**: Service ops — `305` (SERVICE_SALES), `306` (SERVICE_MACHINE), `307` (SERVICE_BUY_GUARD), `309` (SERVICE_CUSTOMER_INFO_REQUIRED), `310` (SERVICE_PAUSE), `311` (SERVICE_PUBLISH), `313` (SERVICE_ORDER_ALLOCATOR); Machine ops — `200` (MACHINE_NEW), `201` (MACHINE_DESCRIPTION), `205` (MACHINE_PUBLISH), `206` (MACHINE_NODE); Treasury — `250` (TREASURY_NEW), `251` (TREASURY_DESCRIPTION).
|
|
224
230
|
>
|
|
225
231
|
> See `BuiltinPermissionIndex` in `ts-sdk/packages/wowok/src/w/call/permission.ts` for the full list of built-in permission indexes.
|
|
226
232
|
|
|
@@ -480,7 +486,7 @@ Create the Three-Body signature service without publishing. The Service must be
|
|
|
480
486
|
"permission": "three_body_permission",
|
|
481
487
|
"replaceExistName": true
|
|
482
488
|
},
|
|
483
|
-
"description": "Three-Body author book signature service. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888.",
|
|
489
|
+
"description": "Three-Body author book signature service. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888 WOW.",
|
|
484
490
|
"publish": false
|
|
485
491
|
},
|
|
486
492
|
"env": {
|
|
@@ -643,7 +649,7 @@ Configure the Buy Guard to restrict purchases to the author only.
|
|
|
643
649
|
|
|
644
650
|
---
|
|
645
651
|
|
|
646
|
-
## Step
|
|
652
|
+
## Step 7: Create Treasury Object
|
|
647
653
|
|
|
648
654
|
Create a Treasury object to aggregate signature service revenue (public funds for the author's operational distribution). The Treasury uses the same Permission as the Service (`three_body_permission`) — this ensures a single consistent permission organization governs both fund collection and service operations.
|
|
649
655
|
|
|
@@ -713,7 +719,7 @@ Create a Treasury object to aggregate signature service revenue (public funds fo
|
|
|
713
719
|
|
|
714
720
|
---
|
|
715
721
|
|
|
716
|
-
## Step
|
|
722
|
+
## Step 8: Create Allocator Guard
|
|
717
723
|
|
|
718
724
|
Create a dedicated Guard for the order allocator that verifies the order belongs to this service. This is a **Level 3 scene-combined** Guard: no Signer binding is needed because the allocator uses `sharing.who=Entity(three_body_treasury)` — funds always flow to the fixed Treasury regardless of who triggers the allocation.
|
|
719
725
|
|
|
@@ -813,7 +819,7 @@ order.service == three_body_signature_service
|
|
|
813
819
|
|
|
814
820
|
---
|
|
815
821
|
|
|
816
|
-
## Step
|
|
822
|
+
## Step 9: Configure Order Allocators
|
|
817
823
|
|
|
818
824
|
Set up fund allocation: 100% to the author's Treasury upon order completion.
|
|
819
825
|
|
|
@@ -854,7 +860,7 @@ Set up fund allocation: 100% to the author's Treasury upon order completion.
|
|
|
854
860
|
```
|
|
855
861
|
|
|
856
862
|
> **⚠️ Risk Elimination — Why this configuration is safe**:
|
|
857
|
-
> - **R-C3-05 (Cross-service theft)**: Eliminated by `three_body_allocator_guard` (Step
|
|
863
|
+
> - **R-C3-05 (Cross-service theft)**: Eliminated by `three_body_allocator_guard` (Step 8), which verifies `order.service == three_body_signature_service` before allocation proceeds.
|
|
858
864
|
> - **R-C3-06 (Fund theft via Signer)**: Eliminated by `sharing.who = {"Entity": {"name_or_address": "three_body_treasury"}}` — funds always flow to the fixed Treasury address regardless of who triggers the allocation. An attacker cannot redirect funds to themselves even if they somehow bypass the Guard.
|
|
859
865
|
> - **Previous unsafe pattern (DO NOT USE)**: The original design used `guard: "three_body_buy_guard"` (no `order.service` check) with `sharing.who = {"Signer": "signer"}` — this allowed anyone to trigger allocation of any order's funds to themselves.
|
|
860
866
|
|
|
@@ -885,7 +891,7 @@ Set up fund allocation: 100% to the author's Treasury upon order completion.
|
|
|
885
891
|
|
|
886
892
|
---
|
|
887
893
|
|
|
888
|
-
## Step
|
|
894
|
+
## Step 10: Add Sales and Publish Service
|
|
889
895
|
|
|
890
896
|
Add sales items and publish the service to make it available for orders.
|
|
891
897
|
|
|
@@ -902,7 +908,7 @@ Add sales items and publish the service to make it available for orders.
|
|
|
902
908
|
"sales": [
|
|
903
909
|
{
|
|
904
910
|
"name": "Three-Body Book Signature",
|
|
905
|
-
"price":
|
|
911
|
+
"price": "888WOW",
|
|
906
912
|
"stock": 100,
|
|
907
913
|
"suspension": false,
|
|
908
914
|
"wip": "",
|
|
@@ -950,7 +956,7 @@ Add sales items and publish the service to make it available for orders.
|
|
|
950
956
|
|
|
951
957
|
---
|
|
952
958
|
|
|
953
|
-
## Step
|
|
959
|
+
## Step 11: Unpause Service
|
|
954
960
|
|
|
955
961
|
Unpause the service to allow order creation.
|
|
956
962
|
|
|
@@ -999,7 +1005,7 @@ Unpause the service to allow order creation.
|
|
|
999
1005
|
|
|
1000
1006
|
---
|
|
1001
1007
|
|
|
1002
|
-
## Step
|
|
1008
|
+
## Step 12: Verify Service Configuration
|
|
1003
1009
|
|
|
1004
1010
|
Query the service to verify all configurations.
|
|
1005
1011
|
|
|
@@ -1033,14 +1039,14 @@ Query the service to verify all configurations.
|
|
|
1033
1039
|
"owner": {"Shared": {"initial_shared_version": "..."}},
|
|
1034
1040
|
"version": "...",
|
|
1035
1041
|
"previousTransaction": "...",
|
|
1036
|
-
"description": "Three-Body author book signature service. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888.",
|
|
1042
|
+
"description": "Three-Body author book signature service. Provide a message up to 10 characters, and the author will sign your book. Process: 1.Book Delivery 2.Signature Completion. Fee: 888 WOW.",
|
|
1037
1043
|
"location": "",
|
|
1038
1044
|
"sales": [
|
|
1039
1045
|
{
|
|
1040
1046
|
"name": "Three-Body Book Signature",
|
|
1041
1047
|
"stock": "100",
|
|
1042
1048
|
"suspension": false,
|
|
1043
|
-
"price": "
|
|
1049
|
+
"price": "888000000000",
|
|
1044
1050
|
"wip": "",
|
|
1045
1051
|
"wip_hash": ""
|
|
1046
1052
|
}
|
|
@@ -1091,10 +1097,11 @@ Query the service to verify all configurations.
|
|
|
1091
1097
|
> **Field Reference**:
|
|
1092
1098
|
> - **`buy_guard`**, **`machine`**, **`permission`**: Return **on-chain object IDs** (not names). The on-chain data stores raw object IDs; resolving them back to local mark names requires a separate reverse lookup that is not performed by `onchain_objects` queries.
|
|
1093
1099
|
> - **`query_name`**: The original name string passed in the query request (here, `"three_body_signature_service"`). This is automatically populated by the SDK from the input `objects` array, so you can identify which queried name corresponds to which returned object.
|
|
1094
|
-
> - **`order_allocators.allocators[].guard`**: Returns the on-chain object ID of `three_body_allocator_guard` (created in Step
|
|
1095
|
-
> - **`order_allocators.allocators[].sharing[].who`**: `{"Entity": "0x..."}` indicates funds flow to the fixed Treasury object (`three_body_treasury` from Step
|
|
1100
|
+
> - **`order_allocators.allocators[].guard`**: Returns the on-chain object ID of `three_body_allocator_guard` (created in Step 8). This Guard verifies `order.service == three_body_signature_service` (R-C3-05 protection).
|
|
1101
|
+
> - **`order_allocators.allocators[].sharing[].who`**: `{"Entity": "0x..."}` indicates funds flow to the fixed Treasury object (`three_body_treasury` from Step 7). The address is the Treasury's on-chain object ID. This eliminates R-C3-06 (fund theft via Signer) because the recipient is fixed regardless of caller.
|
|
1096
1102
|
> - **`order_allocators.allocators[].sharing[].mode`**: `1` is the numeric enum for `Rate` mode (input accepts the string `"Rate"`, output returns the numeric `1`).
|
|
1097
1103
|
> - **`order_allocators.allocators[].fix`** and **`max`**: Additional fields returned on-chain (default `"0"` and `null` respectively) that are not part of the input schema but are present in the on-chain data structure.
|
|
1104
|
+
> - **`sales[].price`**: Returns the on-chain smallest-unit value as a string (`"888000000000"` = 888 WOW; WOW has 9 decimals). The input accepts the display format `"888WOW"` (auto-converted by the Fund Processing Layer) or the raw smallest-unit integer `888000000000`.
|
|
1098
1105
|
|
|
1099
1106
|
---
|
|
1100
1107
|
|
|
@@ -1122,7 +1129,7 @@ The author (`three_body_author`) should be able to purchase the service.
|
|
|
1122
1129
|
}
|
|
1123
1130
|
],
|
|
1124
1131
|
"total_pay": {
|
|
1125
|
-
"balance":
|
|
1132
|
+
"balance": "888WOW"
|
|
1126
1133
|
}
|
|
1127
1134
|
},
|
|
1128
1135
|
"namedNewOrder": {
|
|
@@ -1147,6 +1154,8 @@ The author (`three_body_author`) should be able to purchase the service.
|
|
|
1147
1154
|
}
|
|
1148
1155
|
```
|
|
1149
1156
|
|
|
1157
|
+
> **Amount Format**: `"888WOW"` is the display format — the Fund Processing Layer converts it to `888000000000` smallest units (WOW has 9 decimals) before submission. The raw integer `888000000000` is equally valid. The order pays exactly the sale price set in Step 10.
|
|
1158
|
+
|
|
1150
1159
|
**Expected Result**:
|
|
1151
1160
|
```json
|
|
1152
1161
|
{
|
|
@@ -1258,7 +1267,7 @@ Any other account attempting to purchase should fail with Buy Guard verification
|
|
|
1258
1267
|
}
|
|
1259
1268
|
],
|
|
1260
1269
|
"total_pay": {
|
|
1261
|
-
"balance":
|
|
1270
|
+
"balance": "888WOW"
|
|
1262
1271
|
}
|
|
1263
1272
|
}
|
|
1264
1273
|
}
|
|
@@ -1294,7 +1303,7 @@ Transaction resolution failed: MoveAbort in 8th command, abort code: 7 (Verify f
|
|
|
1294
1303
|
|
|
1295
1304
|
## Workflow Execution
|
|
1296
1305
|
|
|
1297
|
-
After a successful purchase by the author, the order progresses through the Machine nodes:
|
|
1306
|
+
After a successful purchase by the author, the order progresses through the Machine nodes, and the payment is then released to the Treasury via the order allocator:
|
|
1298
1307
|
|
|
1299
1308
|
### Node 1: Book Delivered
|
|
1300
1309
|
|
|
@@ -1312,7 +1321,8 @@ The author confirms the book has been delivered.
|
|
|
1312
1321
|
"operation": {
|
|
1313
1322
|
"next_node_name": "Book Delivered",
|
|
1314
1323
|
"forward": "Confirm Delivery"
|
|
1315
|
-
}
|
|
1324
|
+
},
|
|
1325
|
+
"op": "next"
|
|
1316
1326
|
}
|
|
1317
1327
|
},
|
|
1318
1328
|
"env": {
|
|
@@ -1377,7 +1387,8 @@ The author completes the signature.
|
|
|
1377
1387
|
"operation": {
|
|
1378
1388
|
"next_node_name": "Signature Completed",
|
|
1379
1389
|
"forward": "Complete Signature"
|
|
1380
|
-
}
|
|
1390
|
+
},
|
|
1391
|
+
"op": "next"
|
|
1381
1392
|
}
|
|
1382
1393
|
},
|
|
1383
1394
|
"env": {
|
|
@@ -1422,6 +1433,241 @@ The author completes the signature.
|
|
|
1422
1433
|
}
|
|
1423
1434
|
```
|
|
1424
1435
|
|
|
1436
|
+
### Fund Allocation: Release the 888 WOW Payment to the Treasury
|
|
1437
|
+
|
|
1438
|
+
Once the Progress reaches the final node (`Signature Completed`), the order is fulfilled and the 888 WOW payment held by `three_body_allocation` can be distributed. The Service's `order_allocators` (Step 9) routes 100% to `three_body_treasury` when `three_body_allocator_guard` (Step 8) verifies `order.service == three_body_signature_service`.
|
|
1439
|
+
|
|
1440
|
+
#### (a) Trigger the Allocation (`alloc_by_guard`)
|
|
1441
|
+
|
|
1442
|
+
The allocator Guard's table item `0` has `b_submission: true` (the Order address is only known at runtime), so the call must carry a **top-level `submission` block** — at the SAME level as `data` and `env`, NOT inside `data.data`.
|
|
1443
|
+
|
|
1444
|
+
**Request**:
|
|
1445
|
+
```json
|
|
1446
|
+
{
|
|
1447
|
+
"tool": "onchain_operations",
|
|
1448
|
+
"data": {
|
|
1449
|
+
"operation_type": "allocation",
|
|
1450
|
+
"data": {
|
|
1451
|
+
"object": "three_body_allocation",
|
|
1452
|
+
"alloc_by_guard": "three_body_allocator_guard"
|
|
1453
|
+
},
|
|
1454
|
+
"env": {
|
|
1455
|
+
"account": "three_body_author",
|
|
1456
|
+
"network": "testnet"
|
|
1457
|
+
},
|
|
1458
|
+
"submission": {
|
|
1459
|
+
"type": "submission",
|
|
1460
|
+
"guard": [
|
|
1461
|
+
{
|
|
1462
|
+
"object": "three_body_allocator_guard",
|
|
1463
|
+
"impack": true
|
|
1464
|
+
}
|
|
1465
|
+
],
|
|
1466
|
+
"submission": [
|
|
1467
|
+
{
|
|
1468
|
+
"guard": "three_body_allocator_guard",
|
|
1469
|
+
"submission": [
|
|
1470
|
+
{
|
|
1471
|
+
"identifier": 0,
|
|
1472
|
+
"b_submission": true,
|
|
1473
|
+
"value_type": "Address",
|
|
1474
|
+
"value": "three_body_order",
|
|
1475
|
+
"name": "Order ID (submitted at runtime)"
|
|
1476
|
+
}
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
]
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
> **Two-Phase Reminder**: The ConfirmGate does not gate `allocation` operations, but treat fund distribution as irreversible in production — preview first (call without `confirmed`), then execute after user approval.
|
|
1486
|
+
|
|
1487
|
+
**Expected Result**:
|
|
1488
|
+
```json
|
|
1489
|
+
{
|
|
1490
|
+
"result": {
|
|
1491
|
+
"status": "success",
|
|
1492
|
+
"data": {
|
|
1493
|
+
"result": {
|
|
1494
|
+
"type": "transaction",
|
|
1495
|
+
"objectChanges": [
|
|
1496
|
+
{
|
|
1497
|
+
"type": "Allocation",
|
|
1498
|
+
"type_raw": "0x2::allocation::Allocation<0x2::wow::WOW>",
|
|
1499
|
+
"object": "0x...",
|
|
1500
|
+
"version": "...",
|
|
1501
|
+
"owner": {"Shared": {"initial_shared_version": "..."}},
|
|
1502
|
+
"change": "mutated"
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
"type": "Payment",
|
|
1506
|
+
"type_raw": "0x2::payment::Payment<0x2::wow::WOW>",
|
|
1507
|
+
"object": "0x...",
|
|
1508
|
+
"version": "...",
|
|
1509
|
+
"owner": "Immutable",
|
|
1510
|
+
"change": "created"
|
|
1511
|
+
}
|
|
1512
|
+
]
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
"schema": null
|
|
1517
|
+
}
|
|
1518
|
+
```
|
|
1519
|
+
|
|
1520
|
+
> The immutable `Payment` object created by this call is the on-chain receipt of the distribution — its `payment` array records each recipient and amount (here: 100% of 888 WOW to `three_body_treasury`).
|
|
1521
|
+
|
|
1522
|
+
#### (b) Verify the Pending CoinWrapper at the Treasury
|
|
1523
|
+
|
|
1524
|
+
The Treasury does NOT receive spendable coins directly — each allocation recipient receives a `CoinWrapper` object that must be unwrapped before the funds enter its balance. Query the Treasury's received objects:
|
|
1525
|
+
|
|
1526
|
+
**Request**:
|
|
1527
|
+
```json
|
|
1528
|
+
{
|
|
1529
|
+
"tool": "query_toolkit",
|
|
1530
|
+
"data": {
|
|
1531
|
+
"query_type": "onchain_received",
|
|
1532
|
+
"name_or_address": "three_body_treasury",
|
|
1533
|
+
"network": "testnet"
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
```
|
|
1537
|
+
|
|
1538
|
+
**Expected Result**:
|
|
1539
|
+
```json
|
|
1540
|
+
{
|
|
1541
|
+
"result": {
|
|
1542
|
+
"status": "success",
|
|
1543
|
+
"data": {
|
|
1544
|
+
"result": {
|
|
1545
|
+
"query_type": "onchain_received",
|
|
1546
|
+
"result": {
|
|
1547
|
+
"balance": "888000000000",
|
|
1548
|
+
"token_type": "0x2::wow::WOW",
|
|
1549
|
+
"received": [
|
|
1550
|
+
{
|
|
1551
|
+
"id": "0x...",
|
|
1552
|
+
"balance": "888000000000",
|
|
1553
|
+
"payment": "0x..."
|
|
1554
|
+
}
|
|
1555
|
+
]
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
"schema": null
|
|
1561
|
+
}
|
|
1562
|
+
```
|
|
1563
|
+
|
|
1564
|
+
> The CoinWrapper holds the full 888 WOW (`888000000000` smallest units — Rate `10000` = 100% of the order payment) and references the `Payment` receipt created in step (a).
|
|
1565
|
+
|
|
1566
|
+
#### (c) Unwrap into the Treasury Balance (`receive`)
|
|
1567
|
+
|
|
1568
|
+
Deposit the pending CoinWrapper into the Treasury's balance. The literal `"recently"` auto-receives ALL recently received CoinWrappers:
|
|
1569
|
+
|
|
1570
|
+
**Request**:
|
|
1571
|
+
```json
|
|
1572
|
+
{
|
|
1573
|
+
"tool": "onchain_operations",
|
|
1574
|
+
"data": {
|
|
1575
|
+
"operation_type": "treasury",
|
|
1576
|
+
"data": {
|
|
1577
|
+
"object": "three_body_treasury",
|
|
1578
|
+
"receive": "recently"
|
|
1579
|
+
},
|
|
1580
|
+
"env": {
|
|
1581
|
+
"account": "three_body_author",
|
|
1582
|
+
"network": "testnet"
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
```
|
|
1587
|
+
|
|
1588
|
+
**Expected Result**:
|
|
1589
|
+
```json
|
|
1590
|
+
{
|
|
1591
|
+
"result": {
|
|
1592
|
+
"status": "success",
|
|
1593
|
+
"data": {
|
|
1594
|
+
"result": {
|
|
1595
|
+
"type": "transaction",
|
|
1596
|
+
"objectChanges": [
|
|
1597
|
+
{
|
|
1598
|
+
"type": "Treasury",
|
|
1599
|
+
"type_raw": "0x2::treasury::Treasury<0x2::wow::WOW>",
|
|
1600
|
+
"object": "0x...",
|
|
1601
|
+
"version": "...",
|
|
1602
|
+
"owner": {"Shared": {"initial_shared_version": "..."}},
|
|
1603
|
+
"change": "mutated"
|
|
1604
|
+
},
|
|
1605
|
+
{
|
|
1606
|
+
"type": "TableItem_TreasuryHistory",
|
|
1607
|
+
"type_raw": "0x2::dynamic_field::Field<address, 0x2::parent_linked_table::Node<address, 0x2::treasury::Record>>",
|
|
1608
|
+
"object": "0x...",
|
|
1609
|
+
"version": "...",
|
|
1610
|
+
"owner": {"ObjectOwner": "0x..."},
|
|
1611
|
+
"change": "created"
|
|
1612
|
+
}
|
|
1613
|
+
]
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
},
|
|
1617
|
+
"schema": null
|
|
1618
|
+
}
|
|
1619
|
+
```
|
|
1620
|
+
|
|
1621
|
+
> **Permission**: The author passes as the Permission's admin (see Step 1). A non-admin operator would additionally need the built-in `TREASURY_RECEIVE` index (`253`).
|
|
1622
|
+
|
|
1623
|
+
#### (d) Final Verification
|
|
1624
|
+
|
|
1625
|
+
Query the Treasury to confirm the funds have landed in its balance:
|
|
1626
|
+
|
|
1627
|
+
**Request**:
|
|
1628
|
+
```json
|
|
1629
|
+
{
|
|
1630
|
+
"tool": "query_toolkit",
|
|
1631
|
+
"data": {
|
|
1632
|
+
"query_type": "onchain_objects",
|
|
1633
|
+
"objects": ["three_body_treasury"],
|
|
1634
|
+
"no_cache": true,
|
|
1635
|
+
"network": "testnet"
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
```
|
|
1639
|
+
|
|
1640
|
+
**Expected Result** (key fields):
|
|
1641
|
+
```json
|
|
1642
|
+
{
|
|
1643
|
+
"result": {
|
|
1644
|
+
"status": "success",
|
|
1645
|
+
"data": {
|
|
1646
|
+
"result": {
|
|
1647
|
+
"query_type": "onchain_objects",
|
|
1648
|
+
"result": {
|
|
1649
|
+
"objects": [
|
|
1650
|
+
{
|
|
1651
|
+
"object": "0x...",
|
|
1652
|
+
"type": "Treasury",
|
|
1653
|
+
"type_raw": "0x2::treasury::Treasury<0x2::wow::WOW>",
|
|
1654
|
+
"balance": "888000000000",
|
|
1655
|
+
"inflow": "888000000000",
|
|
1656
|
+
"outflow": "0",
|
|
1657
|
+
"history_count": 1,
|
|
1658
|
+
"query_name": "three_body_treasury"
|
|
1659
|
+
}
|
|
1660
|
+
]
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1665
|
+
"schema": null
|
|
1666
|
+
}
|
|
1667
|
+
```
|
|
1668
|
+
|
|
1669
|
+
> The full 888 WOW order payment now sits in `three_body_treasury` (`balance` = `888000000000` = 888 WOW) — the Treasury-first fund flow (Step 7) executed end-to-end: Order → Allocation → Guard-verified distribution → Treasury.
|
|
1670
|
+
|
|
1425
1671
|
---
|
|
1426
1672
|
|
|
1427
1673
|
## Summary
|
|
@@ -1433,6 +1679,7 @@ This example demonstrates:
|
|
|
1433
1679
|
3. **WIP Files Optional**: Sales items can use WIP files or empty strings
|
|
1434
1680
|
4. **Service Configuration**: Complete setup from creation to publication
|
|
1435
1681
|
5. **Safe Fund Allocation**: Treasury-first design with Level 3 scene-combined allocator Guard — funds always flow to the fixed Treasury, eliminating R-C3-05 (cross-service theft) and R-C3-06 (fund theft via Signer)
|
|
1682
|
+
6. **Fund Allocation Execution**: `alloc_by_guard` distributes the completed order's 888 WOW payment to `three_body_treasury`, and the pending CoinWrapper is unwrapped via Treasury `receive` (see Workflow Execution → Fund Allocation)
|
|
1436
1683
|
|
|
1437
1684
|
### Key Objects
|
|
1438
1685
|
|
|
@@ -1498,9 +1745,9 @@ Each node transition requires the author's confirmation, ensuring accountability
|
|
|
1498
1745
|
3. **Treasury-First Fund Flow**: Always route merchant revenue through a Treasury object using `sharing.who = {"Entity": {"name_or_address": "treasury_name"}}` instead of `{"Signer": "signer"}`. This eliminates R-C3-06 (critical fund theft via Signer) because funds flow to a fixed recipient regardless of who triggers the allocation. Combined with an allocator Guard that verifies `order.service == this_service` (R-C3-05 protection), the fund allocation becomes inherently safe.
|
|
1499
1746
|
|
|
1500
1747
|
4. **Use `confirmed: true` for Irreversible/Destructive Operations**: The MCP server enforces a two-phase confirmation for safety. You MUST add `"confirmed": true` to the `env` for:
|
|
1501
|
-
- Any operation
|
|
1502
|
-
- Any `publish: true` operation (irreversible lock on Machine
|
|
1503
|
-
Without `confirmed: true`, the server returns a `
|
|
1748
|
+
- Any operation whose **top-level** `data.namedNew ?? data.object` sets `replaceExistName: true` (unbinds existing names). Note: ConfirmGate's default-value warnings only scan that top-level field — the NESTED naming fields inside `order_new` (`namedNewOrder`/`namedNewProgress`/`namedNewAllocation`) are NOT scanned, which is why Test 1 runs without `confirmed: true` despite its nested `replaceExistName: true` entries.
|
|
1749
|
+
- Any `publish: true` operation (irreversible lock on Machine `nodes`/`pairs`/`forwards`, or Service `machine`/`order_allocators`)
|
|
1750
|
+
Without `confirmed: true`, the server returns a `pending_confirmation` result and blocks the transaction until you re-call with `confirmed: true`.
|
|
1504
1751
|
|
|
1505
1752
|
5. **Use `no_cache: true` for Sequential Operations**: When performing multiple operations on the same object in sequence (especially Progress workflow advancement), always set `no_cache: true` in the `env` to ensure the SDK reads the latest on-chain state.
|
|
1506
1753
|
|