@wowok/agent-mcp 2.7.2 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.js +1 -1
- package/dist/customer/account-events.d.ts +32 -0
- package/dist/customer/account-events.js +1 -0
- package/dist/customer/customer-advice.d.ts +1 -0
- package/dist/customer/customer-advice.js +1 -1
- package/dist/customer/info-puzzle.js +1 -1
- package/dist/customer/order-strategy.d.ts +1 -1
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +1 -1
- package/dist/customer/risk-assessment.d.ts +1 -0
- package/dist/customer/risk-assessment.js +1 -1
- package/dist/customer/types.d.ts +2 -0
- package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -0
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/category-match-rules.d.ts +30 -0
- package/dist/evaluation/category-match-rules.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -1
- package/dist/evaluation/location-match.d.ts +42 -0
- package/dist/evaluation/location-match.js +1 -0
- package/dist/evaluation/path-reasoning.d.ts +35 -0
- package/dist/evaluation/path-reasoning.js +1 -0
- package/dist/evaluation/region.d.ts +6 -0
- package/dist/evaluation/region.js +1 -1
- package/dist/evaluation/types.d.ts +17 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.d.ts +1 -1
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +75 -0
- package/dist/extensions/industry-layers.js +1 -0
- package/dist/extensions/industry-pack.d.ts +105 -0
- package/dist/extensions/industry-pack.js +1 -0
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +1 -1
- package/dist/extensions/registry.d.ts +1 -0
- package/dist/extensions/registry.js +1 -1
- package/dist/graph/base.d.ts +8 -0
- package/dist/graph/base.js +1 -0
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +2 -0
- package/dist/harness/plan.js +1 -1
- package/dist/harness/recover.d.ts +1 -1
- package/dist/harness/types.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-confirm.js +1 -1
- package/dist/knowledge/anti-cheat.d.ts +37 -0
- package/dist/knowledge/anti-cheat.js +1 -0
- package/dist/knowledge/arb-confirm.d.ts +28 -0
- package/dist/knowledge/arb-confirm.js +1 -0
- package/dist/knowledge/arb-translation.d.ts +48 -0
- package/dist/knowledge/arb-translation.js +1 -0
- package/dist/knowledge/arbitration-context.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/bridge-confirm.d.ts +26 -0
- package/dist/knowledge/bridge-confirm.js +1 -0
- package/dist/knowledge/bridge-translation.d.ts +37 -0
- package/dist/knowledge/bridge-translation.js +1 -0
- package/dist/knowledge/contact-confirm.d.ts +27 -0
- package/dist/knowledge/contact-confirm.js +1 -0
- package/dist/knowledge/contact-translation.d.ts +39 -0
- package/dist/knowledge/contact-translation.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -1
- package/dist/knowledge/demand-context.d.ts +17 -0
- package/dist/knowledge/demand-context.js +1 -0
- package/dist/knowledge/demand-ledger.d.ts +26 -0
- package/dist/knowledge/demand-ledger.js +1 -0
- package/dist/knowledge/demand-puzzle.d.ts +29 -0
- package/dist/knowledge/demand-puzzle.js +1 -0
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/demand-templates.d.ts +12 -0
- package/dist/knowledge/demand-templates.js +1 -0
- package/dist/knowledge/demand-translation.js +1 -1
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/evidence-review.d.ts +12 -0
- package/dist/knowledge/evidence-review.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/flywheel-loop.d.ts +0 -1
- package/dist/knowledge/flywheel-loop.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-migration.d.ts +1 -1
- package/dist/knowledge/index.d.ts +71 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/machine-render.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +12 -0
- package/dist/knowledge/market-metrics.js +1 -0
- package/dist/knowledge/market-operations.d.ts +46 -0
- package/dist/knowledge/market-operations.js +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/payment-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- package/dist/knowledge/permission-context.d.ts +11 -0
- package/dist/knowledge/permission-context.js +1 -1
- package/dist/knowledge/permission-ledger.d.ts +11 -0
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/personal-confirm.d.ts +29 -0
- package/dist/knowledge/personal-confirm.js +1 -0
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/personal-translation.d.ts +37 -0
- package/dist/knowledge/personal-translation.js +1 -0
- package/dist/knowledge/process-model.d.ts +1 -11
- package/dist/knowledge/process-model.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/proof-context.d.ts +17 -0
- package/dist/knowledge/proof-context.js +1 -0
- package/dist/knowledge/proof-ledger.d.ts +34 -0
- package/dist/knowledge/proof-ledger.js +1 -0
- package/dist/knowledge/proof-puzzle.d.ts +35 -0
- package/dist/knowledge/proof-puzzle.js +1 -0
- package/dist/knowledge/proof-templates.d.ts +22 -0
- package/dist/knowledge/proof-templates.js +1 -0
- package/dist/knowledge/registrar-confirm.d.ts +26 -0
- package/dist/knowledge/registrar-confirm.js +1 -0
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/registrar-translation.d.ts +37 -0
- package/dist/knowledge/registrar-translation.js +1 -0
- package/dist/knowledge/repository-context.d.ts +12 -0
- package/dist/knowledge/repository-context.js +1 -0
- package/dist/knowledge/repository-ledger.d.ts +25 -0
- package/dist/knowledge/repository-ledger.js +1 -0
- package/dist/knowledge/repository-puzzle.d.ts +30 -0
- package/dist/knowledge/repository-puzzle.js +1 -0
- package/dist/knowledge/repository-templates.d.ts +14 -0
- package/dist/knowledge/repository-templates.js +1 -0
- package/dist/knowledge/resource-confirm.d.ts +25 -0
- package/dist/knowledge/resource-confirm.js +1 -0
- package/dist/knowledge/resource-translation.d.ts +37 -0
- package/dist/knowledge/resource-translation.js +1 -0
- package/dist/knowledge/reward-context.d.ts +2 -2
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-translation.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-context.d.ts +1 -1
- package/dist/knowledge/treasury-context.js +1 -1
- package/dist/knowledge/treasury-ledger.js +1 -1
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/universal-template.d.ts +22 -0
- package/dist/knowledge/universal-template.js +1 -0
- package/dist/knowledge/util-confirm.d.ts +24 -0
- package/dist/knowledge/util-confirm.js +1 -0
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/knowledge/util-translation.d.ts +39 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +180 -0
- package/dist/knowledge/workflow-guidance.js +1 -0
- package/dist/participation/employee-kpi.d.ts +25 -0
- package/dist/participation/employee-kpi.js +1 -0
- package/dist/participation/employee-store.d.ts +16 -0
- package/dist/participation/employee-store.js +1 -0
- package/dist/participation/index.d.ts +2 -0
- package/dist/participation/index.js +1 -0
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/index.d.ts +9 -2
- package/dist/persona/index.js +1 -1
- package/dist/persona/local-region.d.ts +20 -0
- package/dist/persona/local-region.js +1 -0
- package/dist/persona/model.js +1 -1
- package/dist/persona/overrides.d.ts +10 -0
- package/dist/persona/overrides.js +1 -0
- package/dist/persona/pack-personae.d.ts +11 -0
- package/dist/persona/pack-personae.js +1 -0
- package/dist/persona/strategy-intent.d.ts +20 -0
- package/dist/persona/strategy-intent.js +1 -0
- package/dist/persona/types.d.ts +3 -1
- package/dist/project/business-puzzle.d.ts +1 -1
- package/dist/project/business-puzzle.js +1 -1
- package/dist/project/deployment-doc.js +1 -1
- package/dist/project/edit-planner.js +1 -1
- package/dist/project/evaluation.d.ts +37 -1
- package/dist/project/evaluation.js +1 -1
- package/dist/project/graph-builder.d.ts +2 -2
- package/dist/project/graph-builder.js +1 -1
- package/dist/project/graph.d.ts +3 -6
- package/dist/project/handlers.d.ts +33 -2
- package/dist/project/handlers.js +1 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -1
- package/dist/project/merchant-guide.d.ts +19 -0
- package/dist/project/merchant-guide.js +1 -1
- package/dist/project/mode-actions.js +1 -1
- package/dist/project/rollback-policy.js +1 -1
- package/dist/project/semantic-assembler.d.ts +2 -2
- package/dist/project/semantic-assembler.js +1 -1
- package/dist/project/semantic-graph.d.ts +3 -5
- package/dist/project/workflow-design-assessment.d.ts +24 -0
- package/dist/project/workflow-design-assessment.js +1 -0
- package/dist/safety/confirm-gate.d.ts +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +186 -1385
- package/dist/schema/call/arbitration.d.ts +272 -1871
- package/dist/schema/call/base.d.ts +1831 -9076
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +911 -3171
- package/dist/schema/call/contact.d.ts +135 -931
- package/dist/schema/call/demand.d.ts +164 -1194
- package/dist/schema/call/guard.d.ts +298 -1140
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +459 -5403
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +137 -844
- package/dist/schema/call/payment.d.ts +74 -561
- package/dist/schema/call/permission.d.ts +335 -2791
- package/dist/schema/call/personal.d.ts +227 -1814
- package/dist/schema/call/progress.d.ts +140 -843
- package/dist/schema/call/proof.d.ts +42 -258
- package/dist/schema/call/repository.d.ts +324 -2222
- package/dist/schema/call/reward.d.ts +153 -1183
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +376 -3431
- package/dist/schema/call/treasury.d.ts +252 -2158
- package/dist/schema/common/index.d.ts +222 -697
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +18 -161
- package/dist/schema/employee/index.d.ts +99 -0
- package/dist/schema/employee/index.js +1 -0
- package/dist/schema/evaluation/index.d.ts +1035 -3918
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +132 -0
- package/dist/schema/industry-pack/index.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +92 -245
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +2045 -18080
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/local/wip.d.ts +61 -651
- package/dist/schema/local/wip.js +1 -1
- package/dist/schema/messenger/index.d.ts +949 -5557
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +3168 -26468
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +121 -0
- package/dist/schema/permission/index.js +1 -0
- package/dist/schema/persona/index.d.ts +469 -1820
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/project/index.d.ts +1023 -8450
- package/dist/schema/project/index.js +1 -1
- package/dist/schema/query/index.d.ts +12121 -75556
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +35 -98
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/task-status.d.ts +26 -132
- package/dist/schema/trust/index.d.ts +194 -1290
- package/dist/schema/utils/guard-parser.js +1 -1
- package/dist/schema/utils/node-parser.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +1 -0
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema/workflow/index.d.ts +161 -0
- package/dist/schema/workflow/index.js +1 -0
- package/dist/schema/workspace/index.d.ts +69 -0
- package/dist/schema/workspace/index.js +1 -0
- package/dist/{schema-query → schema-query-impl}/index.js +1 -1
- package/dist/schemas/account_operation.output.json +3147 -1655
- package/dist/schemas/account_operation.schema.json +225 -218
- package/dist/schemas/bridge_operation.output.json +1168 -653
- package/dist/schemas/bridge_operation.schema.json +736 -504
- package/dist/schemas/config_operation.output.json +185 -179
- package/dist/schemas/config_operation.schema.json +21 -26
- package/dist/schemas/employee_operation.output.json +207 -0
- package/dist/schemas/employee_operation.schema.json +176 -0
- package/dist/schemas/evaluation_operation.output.json +2268 -601
- package/dist/schemas/evaluation_operation.schema.json +2919 -787
- package/dist/schemas/guard2file.output.json +58 -64
- package/dist/schemas/guard2file.schema.json +79 -81
- package/dist/schemas/index.json +41 -11
- package/dist/schemas/industry_pack_operation.output.json +594 -0
- package/dist/schemas/industry_pack_operation.schema.json +55 -0
- package/dist/schemas/intent_radar.output.json +275 -203
- package/dist/schemas/intent_radar.schema.json +124 -126
- package/dist/schemas/local_info_operation.output.json +1174 -660
- package/dist/schemas/local_info_operation.schema.json +119 -125
- package/dist/schemas/local_mark_operation.output.json +1239 -692
- package/dist/schemas/local_mark_operation.schema.json +91 -96
- package/dist/schemas/machineNode2file.output.json +63 -69
- package/dist/schemas/machineNode2file.schema.json +79 -81
- package/dist/schemas/messenger_operation.output.json +2722 -1531
- package/dist/schemas/messenger_operation.schema.json +1482 -1264
- package/dist/schemas/onchain_events.output.json +2590 -978
- package/dist/schemas/onchain_events.schema.json +117 -99
- package/dist/schemas/onchain_operations.output.json +3957 -2312
- package/dist/schemas/onchain_operations.schema.json +20799 -9285
- package/dist/schemas/onchain_operations_allocation.schema.json +171 -107
- package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
- package/dist/schemas/onchain_operations_contact.schema.json +129 -90
- package/dist/schemas/onchain_operations_demand.schema.json +170 -112
- package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
- package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
- package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
- package/dist/schemas/onchain_operations_machine.schema.json +536 -163
- package/dist/schemas/onchain_operations_order.schema.json +126 -96
- package/dist/schemas/onchain_operations_payment.schema.json +82 -67
- package/dist/schemas/onchain_operations_permission.schema.json +331 -93
- package/dist/schemas/onchain_operations_personal.schema.json +636 -96
- package/dist/schemas/onchain_operations_progress.schema.json +125 -92
- package/dist/schemas/onchain_operations_proof.schema.json +76 -69
- package/dist/schemas/onchain_operations_repository.schema.json +636 -249
- package/dist/schemas/onchain_operations_reward.schema.json +218 -108
- package/dist/schemas/onchain_operations_service.schema.json +678 -220
- package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
- package/dist/schemas/onchain_table_data.output.json +6833 -2432
- package/dist/schemas/onchain_table_data.schema.json +684 -417
- package/dist/schemas/permission_operation.output.json +173 -0
- package/dist/schemas/permission_operation.schema.json +39 -0
- package/dist/schemas/persona_operation.output.json +1568 -268
- package/dist/schemas/persona_operation.schema.json +346 -205
- package/dist/schemas/project_operation.output.json +6922 -5132
- package/dist/schemas/project_operation.schema.json +1050 -1020
- package/dist/schemas/query_task_status.output.json +195 -99
- package/dist/schemas/query_task_status.schema.json +12 -18
- package/dist/schemas/query_toolkit.output.json +18862 -14561
- package/dist/schemas/query_toolkit.schema.json +614 -522
- package/dist/schemas/schema_query.output.json +127 -129
- package/dist/schemas/schema_query.schema.json +64 -69
- package/dist/schemas/trust_score.output.json +678 -587
- package/dist/schemas/trust_score.schema.json +289 -277
- package/dist/schemas/wip_file.output.json +116 -124
- package/dist/schemas/wip_file.schema.json +142 -143
- package/dist/schemas/workflow_operation.output.json +164 -0
- package/dist/schemas/workflow_operation.schema.json +116 -0
- package/dist/schemas/workspace_operation.output.json +277 -0
- package/dist/schemas/workspace_operation.schema.json +45 -0
- package/dist/schemas/wowok_buildin_info.output.json +1682 -844
- package/dist/schemas/wowok_buildin_info.schema.json +576 -526
- package/dist/tools/handlers/bridge.d.ts +8 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/employee.d.ts +2 -0
- package/dist/tools/handlers/employee.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.d.ts +2 -0
- package/dist/tools/handlers/industry-pack.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.d.ts +2 -0
- package/dist/tools/handlers/permission.js +1 -0
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/project.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/trust.js +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/handlers/workflow.d.ts +2 -0
- package/dist/tools/handlers/workflow.js +1 -0
- package/dist/tools/handlers/workspace.d.ts +4 -0
- package/dist/tools/handlers/workspace.js +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/types.d.ts +2 -1
- package/package.json +4 -5
- package/dist/knowledge/arbitration-trust.d.ts +0 -24
- package/dist/knowledge/arbitration-trust.js +0 -1
- package/dist/schema/call/bridge-handler.d.ts +0 -8
- package/dist/schema/call/bridge-handler.js +0 -1
- package/dist/schema/sync-layer4.d.ts +0 -21
- package/dist/schema/sync-layer4.js +0 -1
- /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export const TREASURY_PERMISSIONS=[{'index':0xfa,'name':'TREASURY_NEW','description':'Create\x20new\x20Treasury','governed_operation':'treasury::new','active':!![]},{'index':0xfb,'name':'TREASURY_DESCRIPTION','description':'Modify\x20Treasury\x20description','governed_operation':'treasury::description_set','active':!![]},{'index':0xfc,'name':'TREASURY_DEPOSIT','description':'Internal\x20deposit\x20(Permission\x20path)','governed_operation':'treasury::deposit','active':!![]},{'index':0xfd,'name':'TREASURY_RECEIVE','description':'Receive\x20CoinWrapper\x20into\x20balance','governed_operation':'treasury::receive','active':!![]},{'index':0xfe,'name':'TREASURY_WITHDRAW','description':'Internal\x20withdraw\x20(Permission\x20path,\x20fixed\x20amount)','governed_operation':'treasury::withdraw','active':!![]},{'index':0xff,'name':'TREASURY_EXTERNAL_DEPOSIT_GUARD','description':'Manage\x20external\x20deposit\x20Guard\x20list\x20(add/remove/clear)','governed_operation':'treasury::external_deposit_guard_add/remove/clear','active':!![]},{'index':0x100,'name':'TREASURY_EXTERNAL_WITHDRAW_GUARD','description':'Manage\x20external\x20withdraw\x20Guard\x20list\x20(add/remove/clear)','governed_operation':'treasury::external_withdraw_guard_add/remove/clear','active':!![]},{'index':0x101,'name':'TREASURY_OWNER_RECEIVE','description':'Owner\x20receive\x20(unwrap\x20received\x20objects,\x20send\x20to\x20Permission\x20owner)','governed_operation':'treasury::owner_receive\x20/\x20owner_receive_object','active':!![]},{'index':0x102,'name':'TREASURY_UM','description':'Set\x20UM\x20(User\x20Manager\x20=\x20Contact\x20object)','governed_operation':'treasury::um_set\x20/\x20um_none','active':!![]},{'index':-0x1,'name':'TREASURY_EXTERNAL_DEPOSIT_RESERVED','description':'RESERVED\x20—\x20external_deposit\x20uses\x20Guard\x20+\x20Passport,\x20does\x20NOT\x20call\x20permission::check','governed_operation':'treasury::external_deposit\x20(Guard\x20path)','active':![]},{'index':-0x1,'name':'TREASURY_EXTERNAL_WITHDRAW_RESERVED','description':'RESERVED\x20—\x20external_withdraw\x20uses\x20Guard\x20+\x20Passport,\x20does\x20NOT\x20call\x20permission::check','governed_operation':'treasury::external_withdraw\x20(Guard\x20path)','active':![]}];export const TREASURY_SCENES=[{'id':'treasury_fund_collection','name':'Team\x20fund\x20collection\x20(internal\x20deposit\x20+\x20receive)','coin_type_category':'generic','permission_index_range':'250-254','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xfa,0xfb,0xfc,0xfd,0xfe]['includes'](a['index'])),'owner_operations':['um_set\x20(258)','owner_receive\x20(257)','permission\x20transfer'],'admin_operations':['description_set\x20(251)'],'permission_index_operations':['treasury::deposit\x20(252)','treasury::receive\x20(253)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Owner-only\x20deposit:\x20TREASURY_DEPOSIT\x20(252)\x20granted\x20to\x20team\x20finance','Receive\x20automation:\x20TREASURY_RECEIVE\x20(253)\x20for\x20CoinWrapper\x20intake','No\x20external\x20Guard:\x20all\x20deposits\x20via\x20Permission\x20path','inflow\x20accumulates\x20total\x20team\x20contributions'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Allocator.sharing.who=Entity\x20→\x20Treasury\x20address\x20(fund\x20inflow)','Treasury.receive\x20(253)\x20converts\x20CoinWrapper\x20to\x20balance'],'recommended_templates':['T-T-01','T-T-06']},{'id':'treasury_external_ops','name':'External\x20deposit\x20/\x20withdraw\x20with\x20Guard\x20protection','coin_type_category':'generic','permission_index_range':'255-256','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xff,0x100]['includes'](a['index'])),'owner_operations':['external_deposit_guard_add/remove/clear\x20(255)','external_withdraw_guard_add/remove/clear\x20(256)'],'admin_operations':[],'permission_index_operations':['treasury::external_deposit_guard_*\x20(255)','treasury::external_withdraw_guard_*\x20(256)'],'external_operations':['treasury::external_deposit\x20(Guard\x20+\x20Passport,\x20no\x20Permission)','treasury::external_withdraw\x20(Guard\x20+\x20Passport,\x20no\x20Permission)'],'guard_list_mutable_after_publish':!![],'common_patterns':['Whitelist\x20external\x20deposit:\x20external_deposit_guard\x20with\x20identifier=None','Capped\x20external\x20withdraw:\x20external_withdraw_guard\x20with\x20identifier=amount\x20field','Pair\x20external\x20ops\x20with\x20Guard\x20for\x20zero-Permission\x20external\x20access','store_from_id\x20tracks\x20order/business\x20ID\x20for\x20audit\x20trail'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Guard\x20object\x20referenced\x20by\x20external_deposit_guard\x20/\x20external_withdraw_guard','Passport\x20object\x20required\x20for\x20every\x20external_deposit\x20/\x20external_withdraw\x20call'],'recommended_templates':['T-T-03','T-T-04']},{'id':'treasury_guard_protection','name':'Guard-protected\x20Treasury\x20(asymmetric\x20identifier\x20design)','coin_type_category':'generic','permission_index_range':'255-256','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xff,0x100]['includes'](a['index'])),'owner_operations':['external_deposit_guard\x20management\x20(255)','external_withdraw_guard\x20management\x20(256)'],'admin_operations':[],'permission_index_operations':['treasury::external_deposit_guard_add\x20(255)','treasury::external_withdraw_guard_add\x20(256)'],'external_operations':['external_deposit\x20via\x20Guard\x20(identifier:\x20Option<u8>\x20—\x20None\x20means\x20no\x20amount\x20limit)','external_withdraw\x20via\x20Guard\x20(identifier:\x20u8\x20—\x20REQUIRED,\x20no\x20None\x20option)'],'guard_list_mutable_after_publish':!![],'common_patterns':['Asymmetric\x20identifier:\x20deposit\x20optional,\x20withdraw\x20required','Deposit\x20amount\x20from\x20Coin\x20itself;\x20withdraw\x20amount\x20from\x20Guard\x20submission','upsert\x20semantics:\x20add\x20updates\x20existing\x20guard,\x20else\x20appends','external_deposit\x20splits\x20coin\x20if\x20value\x20>\x20guard-specified\x20amount'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Guard\x20table\x20item\x20value\x20type\x20must\x20be\x20number\x20(is_number_type)\x20for\x20identifier','Guard\x20table\x20item\x20value\x20type\x20must\x20be\x20address-compatible\x20for\x20store_from_id'],'recommended_templates':['T-T-03']},{'id':'treasury_permission_sharing','name':'Treasury\x20shared\x20with\x20Service\x20via\x20common\x20Permission','coin_type_category':'generic','permission_index_range':'250-258','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['active']),'owner_operations':['um_set\x20(258)','owner_receive\x20(257)'],'admin_operations':['description_set\x20(251)'],'permission_index_operations':['treasury::deposit\x20(252)\x20+\x20service::publish\x20(311)\x20on\x20same\x20Permission','treasury::withdraw\x20(254)\x20+\x20service::compensation_fund_withdraw\x20(315)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Shared\x20Permission:\x20Treasury\x20+\x20Service\x20reference\x20same\x20Permission\x20object','Unified\x20admin\x20list:\x20single\x20admin\x20team\x20manages\x20both\x20Service\x20and\x20Treasury','Simplifies\x20key\x20management:\x20one\x20Permission\x20object\x20per\x20business\x20unit'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Service.compensation_fund\x20(parallel\x20design,\x20NOT\x20a\x20Treasury)','Service.order_allocator\x20→\x20Treasury\x20as\x20Entity\x20target'],'recommended_templates':['T-T-04','T-T-05']},{'id':'treasury_um_delegation','name':'UM\x20delegation\x20(User\x20Manager\x20=\x20Contact\x20object)','coin_type_category':'generic','permission_index_range':'258','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['index']===0x102),'owner_operations':['um_set\x20(258)','um_none\x20(258)'],'admin_operations':[],'permission_index_operations':['treasury::um_set\x20(258)','treasury::um_none\x20(258)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Owner-only\x20UM:\x20TREASURY_UM\x20(258)\x20restricted\x20to\x20owner\x20(assert_owner)','UM\x20is\x20a\x20Contact\x20object\x20address,\x20not\x20a\x20regular\x20user\x20address','UM\x20≠\x20admin:\x20UM\x20is\x20for\x20contact\x20management,\x20not\x20permission\x20management','um_none\x20revokes\x20UM\x20and\x20disaffiliates\x20from\x20Registrar'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Contact\x20object\x20referenced\x20by\x20Treasury.um','Registrar.affiliation\x20/\x20disaffiliation\x20tracks\x20UM-Treasury\x20binding'],'recommended_templates':['T-T-01']},{'id':'treasury_owner_receive','name':'Owner\x20receive\x20(unwrap\x20&\x20forward\x20to\x20Permission\x20owner)','coin_type_category':'generic','permission_index_range':'257','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['index']===0x101),'owner_operations':['owner_receive\x20(257)','owner_receive_object\x20(257)'],'admin_operations':[],'permission_index_operations':['treasury::owner_receive\x20(257)','treasury::owner_receive_object\x20(257)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Forward\x20received\x20assets:\x20CoinWrapper\x20unwrapped,\x20sent\x20to\x20Permission.owner','Does\x20NOT\x20write\x20to\x20history\x20(direct\x20forward,\x20no\x20Record\x20entry)','Used\x20when\x20Treasury\x20should\x20not\x20retain\x20received\x20assets','owner_receive_object\x20handles\x20non-coin\x20objects\x20too'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Permission.owner\x20is\x20the\x20recipient\x20(resolved\x20at\x20tx\x20time)','Received\x20objects\x20come\x20from\x20Allocator\x20/\x20Arbitration.fees_transfer\x20/\x20external\x20deposits'],'recommended_templates':['T-T-06']}];export const TREASURY_LEDGER_VERSION='1.0.0';export function getScenesByHostObject(a){return TREASURY_SCENES;}export function findSceneById(a){return TREASURY_SCENES['find'](b=>b['id']===a);}export function findSceneByPermissionIndex(a){for(const b of TREASURY_SCENES){if(b['builtin_indexes']['some'](c=>c['index']===a&&c['active']))return b;}return undefined;}export function getBuiltinPermissionByIndex(a){return TREASURY_PERMISSIONS['find'](b=>b['index']===a&&b['active']);}export function isBuiltinTreasuryPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function getActiveBuiltinPermissions(){return TREASURY_PERMISSIONS['filter'](a=>a['active']);}export function getReservedBuiltinPermissions(){return TREASURY_PERMISSIONS['filter'](a=>!a['active']);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('um')||b['includes']('delegate')||b['includes']('user\x20manager'))return findSceneById('treasury_um_delegation');if(b['includes']('owner_receive')||b['includes']('owner\x20receive')||b['includes']('forward'))return findSceneById('treasury_owner_receive');if(b['includes']('external')||b['includes']('guard')){if(b['includes']('deposit'))return findSceneById('treasury_external_ops');if(b['includes']('withdraw'))return findSceneById('treasury_external_ops');return findSceneById('treasury_guard_protection');}if(b['includes']('service')||b['includes']('share'))return findSceneById('treasury_permission_sharing');if(b['includes']('deposit')||b['includes']('receive')||b['includes']('fund')||b['includes']('collect'))return findSceneById('treasury_fund_collection');return undefined;}export function getTreasuryScenesCount(){return TREASURY_SCENES['length'];}export function getMoveFunctionsForPermissionIndex(a){const b={0xfa:['treasury::new','treasury::new_with_passport'],0xfb:['treasury::description_set','treasury::description_set_with_passport'],0xfc:['treasury::deposit','treasury::deposit_with_passport'],0xfd:['treasury::receive','treasury::receive_with_passport'],0xfe:['treasury::withdraw','treasury::withdraw_with_passport'],0xff:['treasury::external_deposit_guard_add','treasury::external_deposit_guard_add_with_passport','treasury::external_deposit_guard_remove','treasury::external_deposit_guard_remove_with_passport','treasury::external_deposit_guard_clear','treasury::external_deposit_guard_clear_with_passport'],0x100:['treasury::external_withdraw_guard_add','treasury::external_withdraw_guard_add_with_passport','treasury::external_withdraw_guard_remove','treasury::external_withdraw_guard_remove_with_passport','treasury::external_withdraw_guard_clear','treasury::external_withdraw_guard_clear_with_passport'],0x101:['treasury::owner_receive','treasury::owner_receive_object'],0x102:['treasury::um_set','treasury::um_set_with_passport','treasury::um_none','treasury::um_none_with_passport']};return b[a]??[];}
|
|
1
|
+
export const TREASURY_PERMISSIONS=[{'index':0xfa,'name':'TREASURY_NEW','description':'Create\x20new\x20Treasury','governed_operation':'treasury::new','active':!![]},{'index':0xfb,'name':'TREASURY_DESCRIPTION','description':'Modify\x20Treasury\x20description','governed_operation':'treasury::description_set','active':!![]},{'index':0xfc,'name':'TREASURY_DEPOSIT','description':'Internal\x20deposit\x20(Permission\x20path)','governed_operation':'treasury::deposit','active':!![]},{'index':0xfd,'name':'TREASURY_RECEIVE','description':'Receive\x20CoinWrapper\x20into\x20balance','governed_operation':'treasury::receive','active':!![]},{'index':0xfe,'name':'TREASURY_WITHDRAW','description':'Internal\x20withdraw\x20(Permission\x20path,\x20fixed\x20amount)','governed_operation':'treasury::withdraw','active':!![]},{'index':0xff,'name':'TREASURY_EXTERNAL_DEPOSIT_GUARD','description':'Manage\x20external\x20deposit\x20Guard\x20list\x20(add/remove/clear)','governed_operation':'treasury::external_deposit_guard_add/remove/clear','active':!![]},{'index':0x100,'name':'TREASURY_EXTERNAL_WITHDRAW_GUARD','description':'Manage\x20external\x20withdraw\x20Guard\x20list\x20(add/remove/clear)','governed_operation':'treasury::external_withdraw_guard_add/remove/clear','active':!![]},{'index':0x101,'name':'TREASURY_OWNER_RECEIVE','description':'Owner\x20receive\x20(unwrap\x20received\x20objects,\x20send\x20to\x20Permission\x20owner)','governed_operation':'treasury::owner_receive\x20/\x20owner_receive_object','active':!![]},{'index':0x102,'name':'TREASURY_UM','description':'Set\x20UM\x20(User\x20Manager\x20=\x20Contact\x20object)','governed_operation':'treasury::um_set\x20/\x20um_none','active':!![]},{'index':-0x1,'name':'TREASURY_EXTERNAL_DEPOSIT_RESERVED','description':'RESERVED\x20—\x20external_deposit\x20uses\x20Guard\x20+\x20Passport,\x20does\x20NOT\x20call\x20permission::check','governed_operation':'treasury::external_deposit\x20(Guard\x20path)','active':![]},{'index':-0x1,'name':'TREASURY_EXTERNAL_WITHDRAW_RESERVED','description':'RESERVED\x20—\x20external_withdraw\x20uses\x20Guard\x20+\x20Passport,\x20does\x20NOT\x20call\x20permission::check','governed_operation':'treasury::external_withdraw\x20(Guard\x20path)','active':![]}];export const TREASURY_SCENES=[{'id':'treasury_fund_collection','name':'Team\x20fund\x20collection\x20(internal\x20deposit\x20+\x20receive)','coin_type_category':'generic','permission_index_range':'250-254','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xfa,0xfb,0xfc,0xfd,0xfe]['includes'](a['index'])),'owner_operations':['um_set\x20(258)','owner_receive\x20(257)','permission\x20transfer'],'admin_operations':['description_set\x20(251)'],'permission_index_operations':['treasury::deposit\x20(252)','treasury::receive\x20(253)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Owner-only\x20deposit:\x20TREASURY_DEPOSIT\x20(252)\x20granted\x20to\x20team\x20finance','Receive\x20automation:\x20TREASURY_RECEIVE\x20(253)\x20for\x20CoinWrapper\x20intake','No\x20external\x20Guard:\x20all\x20deposits\x20via\x20Permission\x20path','inflow\x20accumulates\x20total\x20team\x20contributions'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Allocator.sharing.who=Entity\x20→\x20Treasury\x20address\x20(fund\x20inflow)','Treasury.receive\x20(253)\x20converts\x20CoinWrapper\x20to\x20balance'],'recommended_templates':['T-T-01','T-T-06']},{'id':'treasury_external_ops','name':'External\x20deposit\x20/\x20withdraw\x20with\x20Guard\x20protection','coin_type_category':'generic','permission_index_range':'255-256','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xff,0x100]['includes'](a['index'])),'owner_operations':['external_deposit_guard_add/remove/clear\x20(255)','external_withdraw_guard_add/remove/clear\x20(256)'],'admin_operations':[],'permission_index_operations':['treasury::external_deposit_guard_*\x20(255)','treasury::external_withdraw_guard_*\x20(256)'],'external_operations':['treasury::external_deposit\x20(Guard\x20+\x20Passport,\x20no\x20Permission)','treasury::external_withdraw\x20(Guard\x20+\x20Passport,\x20no\x20Permission)'],'guard_list_mutable_after_publish':!![],'common_patterns':['Whitelist\x20external\x20deposit:\x20external_deposit_guard\x20with\x20identifier=None','Capped\x20external\x20withdraw:\x20external_withdraw_guard\x20with\x20identifier=amount\x20field','Pair\x20external\x20ops\x20with\x20Guard\x20for\x20zero-Permission\x20external\x20access','store_from_id\x20tracks\x20order/business\x20ID\x20for\x20audit\x20trail'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Guard\x20object\x20referenced\x20by\x20external_deposit_guard\x20/\x20external_withdraw_guard','Passport\x20object\x20required\x20for\x20every\x20external_deposit\x20/\x20external_withdraw\x20call'],'recommended_templates':['T-T-03','T-T-04']},{'id':'treasury_guard_protection','name':'Guard-protected\x20Treasury\x20(asymmetric\x20identifier\x20design)','coin_type_category':'generic','permission_index_range':'255-256','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>[0xff,0x100]['includes'](a['index'])),'owner_operations':['external_deposit_guard\x20management\x20(255)','external_withdraw_guard\x20management\x20(256)'],'admin_operations':[],'permission_index_operations':['treasury::external_deposit_guard_add\x20(255)','treasury::external_withdraw_guard_add\x20(256)'],'external_operations':['external_deposit\x20via\x20Guard\x20(identifier:\x20Option<u8>\x20—\x20None\x20means\x20no\x20amount\x20limit)','external_withdraw\x20via\x20Guard\x20(identifier:\x20u8\x20—\x20REQUIRED,\x20no\x20None\x20option)'],'guard_list_mutable_after_publish':!![],'common_patterns':['Asymmetric\x20identifier:\x20deposit\x20optional,\x20withdraw\x20required','Deposit\x20amount\x20from\x20Coin\x20itself;\x20withdraw\x20amount\x20from\x20Guard\x20submission','upsert\x20semantics:\x20add\x20updates\x20existing\x20guard,\x20else\x20appends','external_deposit\x20splits\x20coin\x20if\x20value\x20>\x20guard-specified\x20amount'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Guard\x20table\x20item\x20value\x20type\x20must\x20be\x20number\x20(is_number_type)\x20for\x20identifier','Guard\x20table\x20item\x20value\x20type\x20must\x20be\x20address-compatible\x20for\x20store_from_id'],'recommended_templates':['T-T-03']},{'id':'treasury_permission_sharing','name':'Treasury\x20shared\x20with\x20Service\x20via\x20common\x20Permission','coin_type_category':'generic','permission_index_range':'250-258','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['active']),'owner_operations':['um_set\x20(258)','owner_receive\x20(257)'],'admin_operations':['description_set\x20(251)'],'permission_index_operations':['treasury::deposit\x20(252)\x20+\x20service::publish\x20(311)\x20on\x20same\x20Permission','treasury::withdraw\x20(254)\x20+\x20service::compensation_fund_withdraw\x20(315)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Shared\x20Permission:\x20Treasury\x20+\x20Service\x20reference\x20same\x20Permission\x20object','Unified\x20admin\x20list:\x20single\x20admin\x20team\x20manages\x20both\x20Service\x20and\x20Treasury','Simplifies\x20key\x20management:\x20one\x20Permission\x20object\x20per\x20business\x20unit'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Service.compensation_fund\x20(parallel\x20design,\x20NOT\x20a\x20Treasury)','Service.order_allocator\x20→\x20Treasury\x20as\x20Entity\x20target'],'recommended_templates':['T-T-04','T-T-05']},{'id':'treasury_um_delegation','name':'UM\x20delegation\x20(User\x20Manager\x20=\x20Contact\x20object)','coin_type_category':'generic','permission_index_range':'258','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['index']===0x102),'owner_operations':['um_set\x20(258)','um_none\x20(258)'],'admin_operations':[],'permission_index_operations':['treasury::um_set\x20(258)','treasury::um_none\x20(258)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Owner-only\x20UM:\x20TREASURY_UM\x20(258)\x20restricted\x20to\x20owner\x20(assert_owner)','UM\x20is\x20a\x20Contact\x20object\x20address,\x20not\x20a\x20regular\x20user\x20address','UM\x20≠\x20admin:\x20UM\x20is\x20for\x20contact\x20management,\x20not\x20permission\x20management','um_none\x20revokes\x20UM\x20and\x20disaffiliates\x20from\x20Registrar'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Contact\x20object\x20referenced\x20by\x20Treasury.um','object_linker::affiliation_core\x20/\x20disaffiliation\x20tracks\x20UM-Treasury\x20binding'],'recommended_templates':['T-T-01']},{'id':'treasury_owner_receive','name':'Owner\x20receive\x20(unwrap\x20&\x20forward\x20to\x20Permission\x20owner)','coin_type_category':'generic','permission_index_range':'257','builtin_indexes':TREASURY_PERMISSIONS['filter'](a=>a['index']===0x101),'owner_operations':['owner_receive\x20(257)','owner_receive_object\x20(257)'],'admin_operations':[],'permission_index_operations':['treasury::owner_receive\x20(257)','treasury::owner_receive_object\x20(257)'],'external_operations':[],'guard_list_mutable_after_publish':!![],'common_patterns':['Forward\x20received\x20assets:\x20CoinWrapper\x20unwrapped,\x20sent\x20to\x20Permission.owner','Does\x20NOT\x20write\x20to\x20history\x20(direct\x20forward,\x20no\x20Record\x20entry)','Used\x20when\x20Treasury\x20should\x20not\x20retain\x20received\x20assets','owner_receive_object\x20handles\x20non-coin\x20objects\x20too'],'irreversibility':{'deposit':'reversible','withdraw':'irreversible','external_deposit':'reversible','external_withdraw':'irreversible','owner_receive':'irreversible'},'cross_object_collaboration':['Permission.owner\x20is\x20the\x20recipient\x20(resolved\x20at\x20tx\x20time)','Received\x20objects\x20come\x20from\x20Allocator\x20/\x20Arbitration.fees_transfer\x20/\x20external\x20deposits'],'recommended_templates':['T-T-06']}];export const TREASURY_LEDGER_VERSION='1.0.0';export function getScenesByHostObject(a){return TREASURY_SCENES;}export function findSceneById(a){return TREASURY_SCENES['find'](b=>b['id']===a);}export function findSceneByPermissionIndex(a){for(const b of TREASURY_SCENES){if(b['builtin_indexes']['some'](c=>c['index']===a&&c['active']))return b;}return undefined;}export function getBuiltinPermissionByIndex(a){return TREASURY_PERMISSIONS['find'](b=>b['index']===a&&b['active']);}export function isBuiltinTreasuryPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function getActiveBuiltinPermissions(){return TREASURY_PERMISSIONS['filter'](a=>a['active']);}export function getReservedBuiltinPermissions(){return TREASURY_PERMISSIONS['filter'](a=>!a['active']);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('um')||b['includes']('delegate')||b['includes']('user\x20manager'))return findSceneById('treasury_um_delegation');if(b['includes']('owner_receive')||b['includes']('owner\x20receive')||b['includes']('forward'))return findSceneById('treasury_owner_receive');if(b['includes']('external')||b['includes']('guard')){if(b['includes']('deposit'))return findSceneById('treasury_external_ops');if(b['includes']('withdraw'))return findSceneById('treasury_external_ops');return findSceneById('treasury_guard_protection');}if(b['includes']('service')||b['includes']('share'))return findSceneById('treasury_permission_sharing');if(b['includes']('deposit')||b['includes']('receive')||b['includes']('fund')||b['includes']('collect'))return findSceneById('treasury_fund_collection');return undefined;}export function getTreasuryScenesCount(){return TREASURY_SCENES['length'];}export function getMoveFunctionsForPermissionIndex(a){const b={0xfa:['treasury::new','treasury::new_with_passport'],0xfb:['treasury::description_set','treasury::description_set_with_passport'],0xfc:['treasury::deposit','treasury::deposit_with_passport'],0xfd:['treasury::receive','treasury::receive_with_passport'],0xfe:['treasury::withdraw','treasury::withdraw_with_passport'],0xff:['treasury::external_deposit_guard_add','treasury::external_deposit_guard_add_with_passport','treasury::external_deposit_guard_remove','treasury::external_deposit_guard_remove_with_passport','treasury::external_deposit_guard_clear','treasury::external_deposit_guard_clear_with_passport'],0x100:['treasury::external_withdraw_guard_add','treasury::external_withdraw_guard_add_with_passport','treasury::external_withdraw_guard_remove','treasury::external_withdraw_guard_remove_with_passport','treasury::external_withdraw_guard_clear','treasury::external_withdraw_guard_clear_with_passport'],0x101:['treasury::owner_receive','treasury::owner_receive_object'],0x102:['treasury::um_set','treasury::um_set_with_passport','treasury::um_none','treasury::um_none_with_passport']};return b[a]??[];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,MAX_DESCRIPTION_LENGTH}from'./treasury-puzzle.js';const R_T_1_01={'id':'R-T-1-01','category':'structural','trigger':'Description\x20length\x20exceeds\x20MAX_DESCRIPTION_LENGTH\x20(4000)','check':a=>{if(!a['description'])return null;if(a['description']['length']>MAX_DESCRIPTION_LENGTH)return{'id':'R-T-1-01','level':'HIGH','category':'structural','title':'Description\x20length\x20exceeds\x20limit','description':'Description\x20length\x20'+a['description']['length']+'\x20exceeds\x20MAX_DESCRIPTION_LENGTH\x20'+MAX_DESCRIPTION_LENGTH,'affected_stakeholders':['owner','admin'],'scenario':'Setting\x20a\x20description\x20longer\x20than\x204000\x20characters','mitigation':'Truncate\x20description\x20to\x20fit\x20within\x204000\x20characters','evidence':'length='+a['description']['length']};return null;}},R_T_1_02={'id':'R-T-1-02','category':'structural','trigger':'external_deposit_guard\x20count\x20exceeds\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20(100)','check':a=>{if(!a['external_deposit_guard']||a['external_deposit_guard']['op']!=='add')return null;const b=a['current_external_deposit_guard_count']??0x0,c=a['external_deposit_guard']['guards']['length'];if(b+c>MAX_EXTERNAL_DEPOSIT_GUARD_COUNT)return{'id':'R-T-1-02','level':'HIGH','category':'structural','title':'external_deposit_guard\x20count\x20exceeds\x20limit','description':'Adding\x20'+c+'\x20guards\x20to\x20existing\x20'+b+'\x20would\x20exceed\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20'+MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,'affected_stakeholders':['owner'],'scenario':'Adding\x20too\x20many\x20external\x20deposit\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones,\x20or\x20use\x20\x27set\x27\x20to\x20replace\x20the\x20list','evidence':'current='+b+',\x20adding='+c+',\x20limit='+MAX_EXTERNAL_DEPOSIT_GUARD_COUNT};return null;}},R_T_1_03={'id':'R-T-1-03','category':'structural','trigger':'external_withdraw_guard\x20count\x20exceeds\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20(200)','check':a=>{if(!a['external_withdraw_guard']||a['external_withdraw_guard']['op']!=='add')return null;const b=a['current_external_withdraw_guard_count']??0x0,c=a['external_withdraw_guard']['guards']['length'];if(b+c>MAX_EXTERNAL_WITHDRAW_GUARD_COUNT)return{'id':'R-T-1-03','level':'HIGH','category':'structural','title':'external_withdraw_guard\x20count\x20exceeds\x20limit','description':'Adding\x20'+c+'\x20guards\x20to\x20existing\x20'+b+'\x20would\x20exceed\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20'+MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,'affected_stakeholders':['owner'],'scenario':'Adding\x20too\x20many\x20external\x20withdraw\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones,\x20or\x20use\x20\x27set\x27\x20to\x20replace\x20the\x20list','evidence':'current='+b+',\x20adding='+c+',\x20limit='+MAX_EXTERNAL_WITHDRAW_GUARD_COUNT};return null;}},R_T_1_04={'id':'R-T-1-04','category':'structural','trigger':'external_withdraw_guard.identifier\x20is\x20missing\x20(required\x20u8,\x20not\x20Option)','check':a=>{if(!a['external_withdraw_guard'])return null;if(a['external_withdraw_guard']['op']!=='add'&&a['external_withdraw_guard']['op']!=='set')return null;for(const b of a['external_withdraw_guard']['guards']){if(b['identifier']===undefined||b['identifier']===null)return{'id':'R-T-1-04','level':'HIGH','category':'structural','title':'external_withdraw_guard.identifier\x20missing','description':'Guard\x20'+b['guard']+'\x20missing\x20required\x20identifier.\x20AmountFromWithdrawGuard.identifier\x20is\x20u8\x20(not\x20Option<u8>);\x20withdraw\x20amount\x20must\x20come\x20from\x20Guard\x20table.','affected_stakeholders':['owner','external_operator'],'scenario':'Configuring\x20external\x20withdraw\x20guard\x20without\x20amount\x20source','mitigation':'Set\x20identifier\x20to\x20the\x20Guard\x20table\x20index\x20that\x20provides\x20the\x20withdraw\x20amount\x20(must\x20be\x20a\x20number-type\x20field)','evidence':'guard='+b['guard']+',\x20identifier=undefined'};}return null;}},R_T_2_01={'id':'R-T-2-01','category':'semantic','trigger':'External\x20operation\x20(deposit/withdraw)\x20requested\x20without\x20corresponding\x20guard\x20configured','check':a=>{if(a['deposit']?.['by_external_deposit_guard']){const b=a['deposit']['by_external_deposit_guard'];if((a['current_external_deposit_guard_count']??0x0)===0x0)return{'id':'R-T-2-01','level':'MEDIUM','category':'semantic','title':'External\x20deposit\x20guard\x20list\x20is\x20empty','description':'Requesting\x20external_deposit\x20via\x20guard\x20'+b+',\x20but\x20Treasury\x20has\x20no\x20external_deposit_guard\x20configured.\x20Operation\x20will\x20abort\x20with\x20E_EXTERNAL_DEPOSIT_GUARD_NOT_FOUND.','affected_stakeholders':['external_operator','owner'],'scenario':'External\x20deposit\x20attempted\x20before\x20guard_add','mitigation':'Call\x20external_deposit_guard_add\x20(Permission\x20index\x20255)\x20first\x20to\x20register\x20guard\x20'+b,'evidence':'guard='+b+',\x20current_count=0'};}if(a['withdraw']?.['amount_by_external_withdraw_guard']){const c=a['withdraw']['amount_by_external_withdraw_guard'];if((a['current_external_withdraw_guard_count']??0x0)===0x0)return{'id':'R-T-2-01','level':'MEDIUM','category':'semantic','title':'External\x20withdraw\x20guard\x20list\x20is\x20empty','description':'Requesting\x20external_withdraw\x20via\x20guard\x20'+c+',\x20but\x20Treasury\x20has\x20no\x20external_withdraw_guard\x20configured.\x20Operation\x20will\x20abort\x20with\x20E_EXTERNAL_WITHDRAW_GUARD_NOT_FOUND.','affected_stakeholders':['external_operator','owner'],'scenario':'External\x20withdraw\x20attempted\x20before\x20guard_add','mitigation':'Call\x20external_withdraw_guard_add\x20(Permission\x20index\x20256)\x20first\x20to\x20register\x20guard\x20'+c,'evidence':'guard='+c+',\x20current_count=0'};}return null;}},R_T_2_02={'id':'R-T-2-02','category':'semantic','trigger':'External\x20operation\x20paired\x20with\x20Permission\x20path\x20(confused\x20access\x20control)','check':a=>{if(a['deposit']?.['by_external_deposit_guard']&&a['current_permission_indexes_granted']?.['includes'](0xfc))return{'id':'R-T-2-02','level':'LOW','category':'semantic','title':'Both\x20Permission\x20deposit\x20and\x20external\x20deposit\x20guard\x20configured','description':'Treasury\x20has\x20both\x20TREASURY_DEPOSIT\x20(252)\x20granted\x20and\x20external_deposit_guard\x20configured.\x20While\x20not\x20an\x20error,\x20mixing\x20access\x20paths\x20complicates\x20audit.','affected_stakeholders':['owner','admin'],'scenario':'Hybrid\x20internal+external\x20deposit\x20setup','mitigation':'Document\x20which\x20path\x20each\x20depositor\x20should\x20use;\x20consider\x20splitting\x20into\x20separate\x20Treasury\x20objects\x20for\x20clarity','evidence':'has_perm_252=true,\x20has_external_deposit_guard=true'};return null;}},R_T_2_03={'id':'R-T-2-03','category':'semantic','trigger':'external_deposit\x20amount\x20exceeds\x20guard-specified\x20value\x20(split-and-refund\x20path)','check':a=>{if(!a['deposit']?.['by_external_deposit_guard']||!a['deposit']?.['coin_balance'])return null;return{'id':'R-T-2-03','level':'LOW','category':'semantic','title':'External\x20deposit\x20may\x20trigger\x20split-and-refund','description':'If\x20coin\x20value\x20('+a['deposit']['coin_balance']+')\x20exceeds\x20guard-specified\x20amount,\x20the\x20excess\x20will\x20be\x20split\x20and\x20refunded\x20to\x20sender.\x20Verify\x20intent.','affected_stakeholders':['external_operator'],'scenario':'External\x20deposit\x20with\x20coin\x20value\x20>\x20guard\x20limit','mitigation':'Pre-split\x20the\x20coin\x20to\x20exact\x20guard-specified\x20amount,\x20or\x20accept\x20the\x20refund\x20behavior','evidence':'coin_balance='+a['deposit']['coin_balance']};}},R_T_3_01={'id':'R-T-3-01','category':'authority','trigger':'Same\x20address\x20holds\x20both\x20TREASURY_DEPOSIT\x20(252)\x20and\x20TREASURY_WITHDRAW\x20(254)','check':a=>{if(!a['current_permission_indexes_granted'])return null;const b=a['current_permission_indexes_granted']['includes'](0xfc),c=a['current_permission_indexes_granted']['includes'](0xfe);if(b&&c)return{'id':'R-T-3-01','level':'MEDIUM','category':'authority','title':'Deposit\x20and\x20withdraw\x20permissions\x20both\x20present\x20(review\x20separation)','description':'Both\x20TREASURY_DEPOSIT\x20(252)\x20and\x20TREASURY_WITHDRAW\x20(254)\x20are\x20granted.\x20Verify\x20they\x20are\x20assigned\x20to\x20different\x20entities\x20to\x20enforce\x20separation\x20of\x20duties.','affected_stakeholders':['owner','depositor','withdrawer'],'scenario':'Single\x20role\x20can\x20both\x20add\x20and\x20remove\x20funds','mitigation':'Assign\x20252\x20to\x20depositor\x20role,\x20254\x20to\x20withdrawer\x20role;\x20use\x20separate\x20Permission\x20objects\x20if\x20needed','evidence':'has_252=true,\x20has_254=true'};return null;}},R_T_3_02={'id':'R-T-3-02','category':'authority','trigger':'TREASURY_EXTERNAL_DEPOSIT_GUARD\x20(255)\x20granted\x20to\x20non-owner\x20(admin-level\x20risk)','check':a=>{if(!a['current_permission_indexes_granted']?.['includes'](0xff))return null;return{'id':'R-T-3-02','level':'MEDIUM','category':'authority','title':'External\x20deposit\x20guard\x20management\x20permission\x20granted','description':'TREASURY_EXTERNAL_DEPOSIT_GUARD\x20(255)\x20is\x20granted.\x20Managing\x20external_deposit_guard\x20list\x20controls\x20who\x20can\x20externally\x20deposit.\x20Verify\x20assignment\x20scope.','affected_stakeholders':['owner','admin'],'scenario':'Guard\x20management\x20delegated\x20to\x20operator','mitigation':'Restrict\x20255\x20to\x20owner/admin\x20only;\x20guard\x20list\x20changes\x20affect\x20external\x20access\x20policy','evidence':'has_perm_255=true'};}},R_T_3_03={'id':'R-T-3-03','category':'authority','trigger':'TREASURY_EXTERNAL_WITHDRAW_GUARD\x20(256)\x20granted\x20—\x20high-impact\x20permission','check':a=>{if(!a['current_permission_indexes_granted']?.['includes'](0x100))return null;return{'id':'R-T-3-03','level':'HIGH','category':'authority','title':'External\x20withdraw\x20guard\x20management\x20permission\x20granted','description':'TREASURY_EXTERNAL_WITHDRAW_GUARD\x20(256)\x20is\x20granted.\x20Managing\x20external_withdraw_guard\x20list\x20controls\x20who\x20can\x20externally\x20withdraw\x20(irreversible).\x20Tightly\x20restrict.','affected_stakeholders':['owner','withdrawer'],'scenario':'External\x20withdraw\x20guard\x20management\x20delegated','mitigation':'Restrict\x20256\x20to\x20owner\x20only;\x20consider\x20multi-sig\x20for\x20production\x20Treasury','evidence':'has_perm_256=true'};}},R_T_4_01={'id':'R-T-4-01','category':'lifecycle','trigger':'Internal\x20withdraw\x20(fixed\x20amount)\x20—\x20irreversible\x20fund\x20operation','check':a=>{if(!a['withdraw']?.['amount_fixed'])return null;return{'id':'R-T-4-01','level':'CRITICAL','category':'lifecycle','title':'Internal\x20withdraw\x20is\x20irreversible','description':'Fixed\x20withdraw\x20of\x20'+a['withdraw']['amount_fixed']+'\x20to\x20'+(a['withdraw']['recipient']??'recipient')+'.\x20Once\x20executed,\x20funds\x20cannot\x20be\x20recovered\x20without\x20recipient\x20cooperation.','affected_stakeholders':['owner','withdrawer'],'scenario':'Permission-authorized\x20withdraw\x20(254)','mitigation':'1)\x20Verify\x20recipient\x20address\x20twice.\x202)\x20Confirm\x20amount.\x203)\x20Check\x20balance\x20sufficiency.\x204)\x20Record\x20Payment\x20object\x20for\x20audit.','evidence':'amount='+a['withdraw']['amount_fixed']+',\x20recipient='+(a['withdraw']['recipient']??'?')};}},R_T_4_02={'id':'R-T-4-02','category':'lifecycle','trigger':'External\x20withdraw\x20(via\x20guard)\x20—\x20irreversible\x20fund\x20operation','check':a=>{if(!a['withdraw']?.['amount_by_external_withdraw_guard'])return null;return{'id':'R-T-4-02','level':'CRITICAL','category':'lifecycle','title':'External\x20withdraw\x20is\x20irreversible','description':'External\x20withdraw\x20via\x20guard\x20'+a['withdraw']['amount_by_external_withdraw_guard']+'\x20to\x20'+(a['withdraw']['recipient']??'recipient')+'.\x20Amount\x20determined\x20by\x20Guard\x20table\x20identifier;\x20verify\x20Guard\x20rules\x20before\x20execution.','affected_stakeholders':['owner','external_operator','withdrawer'],'scenario':'Guard-authorized\x20external\x20withdraw','mitigation':'1)\x20Verify\x20Guard\x20rules\x20match\x20business\x20intent.\x202)\x20Verify\x20recipient.\x203)\x20Ensure\x20Guard\x20identifier\x20points\x20to\x20correct\x20amount\x20field.\x204)\x20Test\x20on\x20testnet\x20first.','evidence':'guard='+a['withdraw']['amount_by_external_withdraw_guard']+',\x20recipient='+(a['withdraw']['recipient']??'?')};}},R_T_4_03={'id':'R-T-4-03','category':'lifecycle','trigger':'UM\x20set\x20or\x20revoked\x20—\x20affiliation\x20change','check':a=>{if(a['um']===undefined)return null;if(a['um']===null)return{'id':'R-T-4-03','level':'LOW','category':'lifecycle','title':'UM\x20revocation','description':'Revoking\x20UM\x20disaffiliates\x20Contact\x20from\x20Treasury\x20via\x20Registrar.\x20Existing\x20contact\x20bindings\x20become\x20orphaned.','affected_stakeholders':['owner'],'scenario':'Owner\x20revokes\x20UM\x20(um_none)','mitigation':'Verify\x20no\x20active\x20business\x20process\x20depends\x20on\x20UM\x20before\x20revoking','evidence':'um=null'};return{'id':'R-T-4-03','level':'LOW','category':'lifecycle','title':'UM\x20delegation','description':'Setting\x20UM\x20to\x20'+a['um']+'.\x20UM\x20(Contact\x20object)\x20gains\x20affiliation\x20with\x20Treasury\x20via\x20Registrar.','affected_stakeholders':['owner'],'scenario':'Owner\x20delegates\x20UM\x20(um_set)','mitigation':'Verify\x20UM\x20address\x20is\x20a\x20valid\x20Contact\x20object\x20(not\x20a\x20user\x20wallet)','evidence':'um='+a['um']};}},R_T_5_01={'id':'R-T-5-01','category':'cross_object','trigger':'Treasury\x20shared\x20with\x20Service\x20via\x20common\x20Permission\x20—\x20verify\x20alignment','check':a=>{if(!a['shared_with_service'])return null;return{'id':'R-T-5-01','level':'MEDIUM','category':'cross_object','title':'Treasury-Service\x20Permission\x20sharing\x20—\x20verify\x20index\x20alignment','description':'Treasury\x20and\x20Service\x20share\x20a\x20Permission\x20object.\x20Ensure\x20Treasury\x20indexes\x20(250-258)\x20and\x20Service\x20indexes\x20(300-320)\x20are\x20assigned\x20to\x20intended\x20entities;\x20cross-object\x20admin\x20changes\x20affect\x20both.','affected_stakeholders':['owner','admin'],'scenario':'Single\x20Permission\x20for\x20both\x20Treasury\x20and\x20Service','mitigation':'Document\x20which\x20entities\x20hold\x20which\x20indexes\x20across\x20both\x20objects;\x20review\x20admin\x20list\x20changes\x20for\x20cross-impact','evidence':'shared_with_service=true'};}},R_T_5_02={'id':'R-T-5-02','category':'cross_object','trigger':'Treasury\x20referenced\x20by\x20Allocator/Arbitration\x20—\x20receive\x20(253)\x20must\x20be\x20granted','check':a=>{if(!a['shared_with_allocator']&&!a['shared_with_arbitration'])return null;const b=a['current_permission_indexes_granted']?.['includes'](0xfd);if(!b)return{'id':'R-T-5-02','level':'HIGH','category':'cross_object','title':'Treasury\x20referenced\x20by\x20Allocator/Arbitration\x20but\x20TREASURY_RECEIVE\x20(253)\x20not\x20granted','description':'Allocator/Arbitration\x20will\x20send\x20CoinWrapper/Payment\x20to\x20Treasury,\x20but\x20no\x20entity\x20has\x20TREASURY_RECEIVE\x20(253)\x20to\x20call\x20treasury::receive\x20and\x20convert\x20to\x20balance.\x20Funds\x20will\x20accumulate\x20as\x20received\x20objects\x20without\x20entering\x20balance.','affected_stakeholders':['owner','system'],'scenario':'Revenue\x20collection\x20setup\x20without\x20receive\x20permission','mitigation':'Grant\x20TREASURY_RECEIVE\x20(253)\x20to\x20a\x20trusted\x20operator\x20(or\x20owner)\x20who\x20will\x20regularly\x20call\x20receive\x20to\x20convert\x20CoinWrapper\x20to\x20balance','evidence':'shared_allocator='+a['shared_with_allocator']+',\x20shared_arbitration='+a['shared_with_arbitration']+',\x20has_253=false'};return null;}},R_T_0_01={'id':'R-T-0-01','category':'structural','trigger':'Permission\x20index\x20in\x20259-260\x20range\x20detected\x20(regression\x20check\x20for\x20R-T-01)','check':a=>{if(!a['current_permission_indexes_granted'])return null;const b=a['current_permission_indexes_granted']['filter'](c=>c===0x103||c===0x104);if(b['length']>0x0)return{'id':'R-T-0-01','level':'CRITICAL','category':'structural','title':'Stale\x20Treasury\x20permission\x20index\x20259/260\x20detected\x20(R-T-01\x20regression)','description':'Permission\x20indexes\x20259/260\x20are\x20no\x20longer\x20valid\x20Treasury\x20indexes\x20(SDK\x20fixed\x20to\x20use\x20255-258\x20matching\x20Move).\x20Found:\x20'+b['join'](',\x20'),'affected_stakeholders':['owner','admin','system'],'scenario':'SDK\x20regression\x20reintroducing\x20off-by-2\x20divergence','mitigation':'Use\x20canonical\x20indexes:\x20255=EXTERNAL_DEPOSIT_GUARD,\x20256=EXTERNAL_WITHDRAW_GUARD,\x20257=OWNER_RECEIVE,\x20258=UM','evidence':'stale_indexes='+b['join'](',')};return null;}},ALL_RULES=[R_T_1_01,R_T_1_02,R_T_1_03,R_T_1_04,R_T_2_01,R_T_2_02,R_T_2_03,R_T_3_01,R_T_3_02,R_T_3_03,R_T_4_01,R_T_4_02,R_T_4_03,R_T_5_01,R_T_5_02,R_T_0_01];export const TREASURY_RISK_VERSION='1.0.0';export function getAllTreasuryRiskRules(){return[...ALL_RULES];}export function getTreasuryRiskRulesCount(){return ALL_RULES['length'];}export function getTreasuryRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessTreasuryRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
|
|
1
|
+
import{MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,MAX_DESCRIPTION_LENGTH}from'./treasury-puzzle.js';const R_T_1_01={'id':'R-T-1-01','category':'structural','trigger':'Description\x20length\x20exceeds\x20MAX_DESCRIPTION_LENGTH\x20(4000)','check':a=>{if(!a['description'])return null;if(a['description']['length']>MAX_DESCRIPTION_LENGTH)return{'id':'R-T-1-01','level':'HIGH','category':'structural','title':'Description\x20length\x20exceeds\x20limit','description':'Description\x20length\x20'+a['description']['length']+'\x20exceeds\x20MAX_DESCRIPTION_LENGTH\x20'+MAX_DESCRIPTION_LENGTH,'affected_stakeholders':['owner','admin'],'scenario':'Setting\x20a\x20description\x20longer\x20than\x204000\x20characters','mitigation':'Truncate\x20description\x20to\x20fit\x20within\x204000\x20characters','evidence':'length='+a['description']['length']};return null;}},R_T_1_02={'id':'R-T-1-02','category':'structural','trigger':'external_deposit_guard\x20count\x20exceeds\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20(100)','check':a=>{if(!a['external_deposit_guard']||a['external_deposit_guard']['op']!=='add')return null;const b=a['current_external_deposit_guard_count']??0x0,c=a['external_deposit_guard']['guards']['length'];if(b+c>MAX_EXTERNAL_DEPOSIT_GUARD_COUNT)return{'id':'R-T-1-02','level':'HIGH','category':'structural','title':'external_deposit_guard\x20count\x20exceeds\x20limit','description':'Adding\x20'+c+'\x20guards\x20to\x20existing\x20'+b+'\x20would\x20exceed\x20MAX_EXTERNAL_DEPOSIT_GUARD_COUNT\x20'+MAX_EXTERNAL_DEPOSIT_GUARD_COUNT,'affected_stakeholders':['owner'],'scenario':'Adding\x20too\x20many\x20external\x20deposit\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones,\x20or\x20use\x20\x27set\x27\x20to\x20replace\x20the\x20list','evidence':'current='+b+',\x20adding='+c+',\x20limit='+MAX_EXTERNAL_DEPOSIT_GUARD_COUNT};return null;}},R_T_1_03={'id':'R-T-1-03','category':'structural','trigger':'external_withdraw_guard\x20count\x20exceeds\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20(200)','check':a=>{if(!a['external_withdraw_guard']||a['external_withdraw_guard']['op']!=='add')return null;const b=a['current_external_withdraw_guard_count']??0x0,c=a['external_withdraw_guard']['guards']['length'];if(b+c>MAX_EXTERNAL_WITHDRAW_GUARD_COUNT)return{'id':'R-T-1-03','level':'HIGH','category':'structural','title':'external_withdraw_guard\x20count\x20exceeds\x20limit','description':'Adding\x20'+c+'\x20guards\x20to\x20existing\x20'+b+'\x20would\x20exceed\x20MAX_EXTERNAL_WITHDRAW_GUARD_COUNT\x20'+MAX_EXTERNAL_WITHDRAW_GUARD_COUNT,'affected_stakeholders':['owner'],'scenario':'Adding\x20too\x20many\x20external\x20withdraw\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones,\x20or\x20use\x20\x27set\x27\x20to\x20replace\x20the\x20list','evidence':'current='+b+',\x20adding='+c+',\x20limit='+MAX_EXTERNAL_WITHDRAW_GUARD_COUNT};return null;}},R_T_1_04={'id':'R-T-1-04','category':'structural','trigger':'external_withdraw_guard.identifier\x20is\x20missing\x20(required\x20u8,\x20not\x20Option)','check':a=>{if(!a['external_withdraw_guard'])return null;if(a['external_withdraw_guard']['op']!=='add'&&a['external_withdraw_guard']['op']!=='set')return null;for(const b of a['external_withdraw_guard']['guards']){if(b['identifier']===undefined||b['identifier']===null)return{'id':'R-T-1-04','level':'HIGH','category':'structural','title':'external_withdraw_guard.identifier\x20missing','description':'Guard\x20'+b['guard']+'\x20missing\x20required\x20identifier.\x20AmountFromWithdrawGuard.identifier\x20is\x20u8\x20(not\x20Option<u8>);\x20withdraw\x20amount\x20must\x20come\x20from\x20Guard\x20table.','affected_stakeholders':['owner','external_operator'],'scenario':'Configuring\x20external\x20withdraw\x20guard\x20without\x20amount\x20source','mitigation':'Set\x20identifier\x20to\x20the\x20Guard\x20table\x20index\x20that\x20provides\x20the\x20withdraw\x20amount\x20(must\x20be\x20a\x20number-type\x20field)','evidence':'guard='+b['guard']+',\x20identifier=undefined'};}return null;}},R_T_2_01={'id':'R-T-2-01','category':'semantic','trigger':'External\x20operation\x20(deposit/withdraw)\x20requested\x20without\x20corresponding\x20guard\x20configured','check':a=>{if(a['deposit']?.['by_external_deposit_guard']){const b=a['deposit']['by_external_deposit_guard'];if((a['current_external_deposit_guard_count']??0x0)===0x0)return{'id':'R-T-2-01','level':'MEDIUM','category':'semantic','title':'External\x20deposit\x20guard\x20list\x20is\x20empty','description':'Requesting\x20external_deposit\x20via\x20guard\x20'+b+',\x20but\x20Treasury\x20has\x20no\x20external_deposit_guard\x20configured.\x20Operation\x20will\x20abort\x20with\x20E_EXTERNAL_DEPOSIT_GUARD_NOT_FOUND.','affected_stakeholders':['external_operator','owner'],'scenario':'External\x20deposit\x20attempted\x20before\x20guard_add','mitigation':'Call\x20external_deposit_guard_add\x20(Permission\x20index\x20255)\x20first\x20to\x20register\x20guard\x20'+b,'evidence':'guard='+b+',\x20current_count=0'};}if(a['withdraw']?.['amount_by_external_withdraw_guard']){const c=a['withdraw']['amount_by_external_withdraw_guard'];if((a['current_external_withdraw_guard_count']??0x0)===0x0)return{'id':'R-T-2-01','level':'MEDIUM','category':'semantic','title':'External\x20withdraw\x20guard\x20list\x20is\x20empty','description':'Requesting\x20external_withdraw\x20via\x20guard\x20'+c+',\x20but\x20Treasury\x20has\x20no\x20external_withdraw_guard\x20configured.\x20Operation\x20will\x20abort\x20with\x20E_EXTERNAL_WITHDRAW_GUARD_NOT_FOUND.','affected_stakeholders':['external_operator','owner'],'scenario':'External\x20withdraw\x20attempted\x20before\x20guard_add','mitigation':'Call\x20external_withdraw_guard_add\x20(Permission\x20index\x20256)\x20first\x20to\x20register\x20guard\x20'+c,'evidence':'guard='+c+',\x20current_count=0'};}return null;}},R_T_2_02={'id':'R-T-2-02','category':'semantic','trigger':'External\x20operation\x20paired\x20with\x20Permission\x20path\x20(confused\x20access\x20control)','check':a=>{if(a['deposit']?.['by_external_deposit_guard']&&a['current_permission_indexes_granted']?.['includes'](0xfc))return{'id':'R-T-2-02','level':'LOW','category':'semantic','title':'Both\x20Permission\x20deposit\x20and\x20external\x20deposit\x20guard\x20configured','description':'Treasury\x20has\x20both\x20TREASURY_DEPOSIT\x20(252)\x20granted\x20and\x20external_deposit_guard\x20configured.\x20While\x20not\x20an\x20error,\x20mixing\x20access\x20paths\x20complicates\x20audit.','affected_stakeholders':['owner','admin'],'scenario':'Hybrid\x20internal+external\x20deposit\x20setup','mitigation':'Document\x20which\x20path\x20each\x20depositor\x20should\x20use;\x20consider\x20splitting\x20into\x20separate\x20Treasury\x20objects\x20for\x20clarity','evidence':'has_perm_252=true,\x20has_external_deposit_guard=true'};return null;}},R_T_2_03={'id':'R-T-2-03','category':'semantic','trigger':'external_deposit\x20amount\x20exceeds\x20guard-specified\x20value\x20(split-and-refund\x20path)','check':a=>{if(!a['deposit']?.['by_external_deposit_guard']||!a['deposit']?.['coin_balance'])return null;return{'id':'R-T-2-03','level':'LOW','category':'semantic','title':'External\x20deposit\x20may\x20trigger\x20split-and-refund','description':'If\x20coin\x20value\x20('+a['deposit']['coin_balance']+')\x20exceeds\x20guard-specified\x20amount,\x20the\x20excess\x20will\x20be\x20split\x20and\x20refunded\x20to\x20sender.\x20Verify\x20intent.','affected_stakeholders':['external_operator'],'scenario':'External\x20deposit\x20with\x20coin\x20value\x20>\x20guard\x20limit','mitigation':'Pre-split\x20the\x20coin\x20to\x20exact\x20guard-specified\x20amount,\x20or\x20accept\x20the\x20refund\x20behavior','evidence':'coin_balance='+a['deposit']['coin_balance']};}},R_T_3_01={'id':'R-T-3-01','category':'authority','trigger':'Same\x20address\x20holds\x20both\x20TREASURY_DEPOSIT\x20(252)\x20and\x20TREASURY_WITHDRAW\x20(254)','check':a=>{if(!a['current_permission_indexes_granted'])return null;const b=a['current_permission_indexes_granted']['includes'](0xfc),c=a['current_permission_indexes_granted']['includes'](0xfe);if(b&&c)return{'id':'R-T-3-01','level':'MEDIUM','category':'authority','title':'Deposit\x20and\x20withdraw\x20permissions\x20both\x20present\x20(review\x20separation)','description':'Both\x20TREASURY_DEPOSIT\x20(252)\x20and\x20TREASURY_WITHDRAW\x20(254)\x20are\x20granted.\x20Verify\x20they\x20are\x20assigned\x20to\x20different\x20entities\x20to\x20enforce\x20separation\x20of\x20duties.','affected_stakeholders':['owner','depositor','withdrawer'],'scenario':'Single\x20role\x20can\x20both\x20add\x20and\x20remove\x20funds','mitigation':'Assign\x20252\x20to\x20depositor\x20role,\x20254\x20to\x20withdrawer\x20role;\x20use\x20separate\x20Permission\x20objects\x20if\x20needed','evidence':'has_252=true,\x20has_254=true'};return null;}},R_T_3_02={'id':'R-T-3-02','category':'authority','trigger':'TREASURY_EXTERNAL_DEPOSIT_GUARD\x20(255)\x20granted\x20to\x20non-owner\x20(admin-level\x20risk)','check':a=>{if(!a['current_permission_indexes_granted']?.['includes'](0xff))return null;return{'id':'R-T-3-02','level':'MEDIUM','category':'authority','title':'External\x20deposit\x20guard\x20management\x20permission\x20granted','description':'TREASURY_EXTERNAL_DEPOSIT_GUARD\x20(255)\x20is\x20granted.\x20Managing\x20external_deposit_guard\x20list\x20controls\x20who\x20can\x20externally\x20deposit.\x20Verify\x20assignment\x20scope.','affected_stakeholders':['owner','admin'],'scenario':'Guard\x20management\x20delegated\x20to\x20operator','mitigation':'Restrict\x20255\x20to\x20owner/admin\x20only;\x20guard\x20list\x20changes\x20affect\x20external\x20access\x20policy','evidence':'has_perm_255=true'};}},R_T_3_03={'id':'R-T-3-03','category':'authority','trigger':'TREASURY_EXTERNAL_WITHDRAW_GUARD\x20(256)\x20granted\x20—\x20high-impact\x20permission','check':a=>{if(!a['current_permission_indexes_granted']?.['includes'](0x100))return null;return{'id':'R-T-3-03','level':'HIGH','category':'authority','title':'External\x20withdraw\x20guard\x20management\x20permission\x20granted','description':'TREASURY_EXTERNAL_WITHDRAW_GUARD\x20(256)\x20is\x20granted.\x20Managing\x20external_withdraw_guard\x20list\x20controls\x20who\x20can\x20externally\x20withdraw\x20(irreversible).\x20Tightly\x20restrict.','affected_stakeholders':['owner','withdrawer'],'scenario':'External\x20withdraw\x20guard\x20management\x20delegated','mitigation':'Restrict\x20256\x20to\x20owner\x20only;\x20consider\x20multi-sig\x20for\x20production\x20Treasury','evidence':'has_perm_256=true'};}},R_T_4_01={'id':'R-T-4-01','category':'lifecycle','trigger':'Internal\x20withdraw\x20(fixed\x20amount)\x20—\x20irreversible\x20fund\x20operation','check':a=>{if(!a['withdraw']?.['amount_fixed'])return null;return{'id':'R-T-4-01','level':'CRITICAL','category':'lifecycle','title':'Internal\x20withdraw\x20is\x20irreversible','description':'Fixed\x20withdraw\x20of\x20'+a['withdraw']['amount_fixed']+'\x20to\x20'+(a['withdraw']['recipient']??'recipient')+'.\x20Once\x20executed,\x20funds\x20cannot\x20be\x20recovered\x20without\x20recipient\x20cooperation.','affected_stakeholders':['owner','withdrawer'],'scenario':'Permission-authorized\x20withdraw\x20(254)','mitigation':'1)\x20Verify\x20recipient\x20address\x20twice.\x202)\x20Confirm\x20amount.\x203)\x20Check\x20balance\x20sufficiency.\x204)\x20Record\x20Payment\x20object\x20for\x20audit.','evidence':'amount='+a['withdraw']['amount_fixed']+',\x20recipient='+(a['withdraw']['recipient']??'?')};}},R_T_4_02={'id':'R-T-4-02','category':'lifecycle','trigger':'External\x20withdraw\x20(via\x20guard)\x20—\x20irreversible\x20fund\x20operation','check':a=>{if(!a['withdraw']?.['amount_by_external_withdraw_guard'])return null;return{'id':'R-T-4-02','level':'CRITICAL','category':'lifecycle','title':'External\x20withdraw\x20is\x20irreversible','description':'External\x20withdraw\x20via\x20guard\x20'+a['withdraw']['amount_by_external_withdraw_guard']+'\x20to\x20'+(a['withdraw']['recipient']??'recipient')+'.\x20Amount\x20determined\x20by\x20Guard\x20table\x20identifier;\x20verify\x20Guard\x20rules\x20before\x20execution.','affected_stakeholders':['owner','external_operator','withdrawer'],'scenario':'Guard-authorized\x20external\x20withdraw','mitigation':'1)\x20Verify\x20Guard\x20rules\x20match\x20business\x20intent.\x202)\x20Verify\x20recipient.\x203)\x20Ensure\x20Guard\x20identifier\x20points\x20to\x20correct\x20amount\x20field.\x204)\x20Test\x20on\x20testnet\x20first.','evidence':'guard='+a['withdraw']['amount_by_external_withdraw_guard']+',\x20recipient='+(a['withdraw']['recipient']??'?')};}},R_T_4_03={'id':'R-T-4-03','category':'lifecycle','trigger':'UM\x20set\x20or\x20revoked\x20—\x20object-linker\x20core\x20binding\x20change','check':a=>{if(a['um']===undefined)return null;if(a['um']===null)return{'id':'R-T-4-03','level':'LOW','category':'lifecycle','title':'UM\x20revocation','description':'Revoking\x20UM\x20disaffiliates\x20Contact\x20from\x20Treasury\x20via\x20object_linker::disaffiliation_core.\x20Existing\x20contact\x20bindings\x20become\x20orphaned.','affected_stakeholders':['owner'],'scenario':'Owner\x20revokes\x20UM\x20(um_none)','mitigation':'Verify\x20no\x20active\x20business\x20process\x20depends\x20on\x20UM\x20before\x20revoking','evidence':'um=null'};return{'id':'R-T-4-03','level':'LOW','category':'lifecycle','title':'UM\x20delegation','description':'Setting\x20UM\x20to\x20'+a['um']+'.\x20UM\x20(Contact\x20object)\x20gains\x20binding\x20with\x20Treasury\x20via\x20object_linker::affiliation_core.','affected_stakeholders':['owner'],'scenario':'Owner\x20delegates\x20UM\x20(um_set)','mitigation':'Verify\x20UM\x20address\x20is\x20a\x20valid\x20Contact\x20object\x20(not\x20a\x20user\x20wallet)','evidence':'um='+a['um']};}},R_T_5_01={'id':'R-T-5-01','category':'cross_object','trigger':'Treasury\x20shared\x20with\x20Service\x20via\x20common\x20Permission\x20—\x20verify\x20alignment','check':a=>{if(!a['shared_with_service'])return null;return{'id':'R-T-5-01','level':'MEDIUM','category':'cross_object','title':'Treasury-Service\x20Permission\x20sharing\x20—\x20verify\x20index\x20alignment','description':'Treasury\x20and\x20Service\x20share\x20a\x20Permission\x20object.\x20Ensure\x20Treasury\x20indexes\x20(250-258)\x20and\x20Service\x20indexes\x20(300-320)\x20are\x20assigned\x20to\x20intended\x20entities;\x20cross-object\x20admin\x20changes\x20affect\x20both.','affected_stakeholders':['owner','admin'],'scenario':'Single\x20Permission\x20for\x20both\x20Treasury\x20and\x20Service','mitigation':'Document\x20which\x20entities\x20hold\x20which\x20indexes\x20across\x20both\x20objects;\x20review\x20admin\x20list\x20changes\x20for\x20cross-impact','evidence':'shared_with_service=true'};}},R_T_5_02={'id':'R-T-5-02','category':'cross_object','trigger':'Treasury\x20referenced\x20by\x20Allocator/Arbitration\x20—\x20receive\x20(253)\x20must\x20be\x20granted','check':a=>{if(!a['shared_with_allocator']&&!a['shared_with_arbitration'])return null;const b=a['current_permission_indexes_granted']?.['includes'](0xfd);if(!b)return{'id':'R-T-5-02','level':'HIGH','category':'cross_object','title':'Treasury\x20referenced\x20by\x20Allocator/Arbitration\x20but\x20TREASURY_RECEIVE\x20(253)\x20not\x20granted','description':'Allocator/Arbitration\x20will\x20send\x20CoinWrapper/Payment\x20to\x20Treasury,\x20but\x20no\x20entity\x20has\x20TREASURY_RECEIVE\x20(253)\x20to\x20call\x20treasury::receive\x20and\x20convert\x20to\x20balance.\x20Funds\x20will\x20accumulate\x20as\x20received\x20objects\x20without\x20entering\x20balance.','affected_stakeholders':['owner','system'],'scenario':'Revenue\x20collection\x20setup\x20without\x20receive\x20permission','mitigation':'Grant\x20TREASURY_RECEIVE\x20(253)\x20to\x20a\x20trusted\x20operator\x20(or\x20owner)\x20who\x20will\x20regularly\x20call\x20receive\x20to\x20convert\x20CoinWrapper\x20to\x20balance','evidence':'shared_allocator='+a['shared_with_allocator']+',\x20shared_arbitration='+a['shared_with_arbitration']+',\x20has_253=false'};return null;}},R_T_0_01={'id':'R-T-0-01','category':'structural','trigger':'Permission\x20index\x20in\x20259-260\x20range\x20detected\x20(regression\x20check\x20for\x20R-T-01)','check':a=>{if(!a['current_permission_indexes_granted'])return null;const b=a['current_permission_indexes_granted']['filter'](c=>c===0x103||c===0x104);if(b['length']>0x0)return{'id':'R-T-0-01','level':'CRITICAL','category':'structural','title':'Stale\x20Treasury\x20permission\x20index\x20259/260\x20detected\x20(R-T-01\x20regression)','description':'Permission\x20indexes\x20259/260\x20are\x20no\x20longer\x20valid\x20Treasury\x20indexes\x20(SDK\x20fixed\x20to\x20use\x20255-258\x20matching\x20Move).\x20Found:\x20'+b['join'](',\x20'),'affected_stakeholders':['owner','admin','system'],'scenario':'SDK\x20regression\x20reintroducing\x20off-by-2\x20divergence','mitigation':'Use\x20canonical\x20indexes:\x20255=EXTERNAL_DEPOSIT_GUARD,\x20256=EXTERNAL_WITHDRAW_GUARD,\x20257=OWNER_RECEIVE,\x20258=UM','evidence':'stale_indexes='+b['join'](',')};return null;}},ALL_RULES=[R_T_1_01,R_T_1_02,R_T_1_03,R_T_1_04,R_T_2_01,R_T_2_02,R_T_2_03,R_T_3_01,R_T_3_02,R_T_3_03,R_T_4_01,R_T_4_02,R_T_4_03,R_T_5_01,R_T_5_02,R_T_0_01];export const TREASURY_RISK_VERSION='1.0.0';export function getAllTreasuryRiskRules(){return[...ALL_RULES];}export function getTreasuryRiskRulesCount(){return ALL_RULES['length'];}export function getTreasuryRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessTreasuryRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface AntiCheatBaseline {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
rules: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface UniversalTemplate {
|
|
6
|
+
template: "universal";
|
|
7
|
+
version: string;
|
|
8
|
+
anti_cheat_baseline: {
|
|
9
|
+
fake_orders: AntiCheatBaseline;
|
|
10
|
+
fake_reviews: AntiCheatBaseline;
|
|
11
|
+
shell_merchant: AntiCheatBaseline;
|
|
12
|
+
reputation_trade: AntiCheatBaseline;
|
|
13
|
+
};
|
|
14
|
+
pricing_redlines: string[];
|
|
15
|
+
governance_redlines: string[];
|
|
16
|
+
quality_signals: string[];
|
|
17
|
+
consumer_journey: string[];
|
|
18
|
+
north_star_metric: string;
|
|
19
|
+
revenue_boundary: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const UNIVERSAL_TEMPLATE: UniversalTemplate;
|
|
22
|
+
export declare function getUniversalTemplate(): UniversalTemplate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const UNIVERSAL_TEMPLATE={'template':'universal','version':'1.0.0','anti_cheat_baseline':{'fake_orders':{'enabled':!![],'rules':['self_trade','mutual_brush','no_fund_closure']},'fake_reviews':{'enabled':!![],'rules':['no_order_no_review','amount_weighted','small_order_decay']},'shell_merchant':{'enabled':!![],'rules':['no_arbitration','no_machine']},'reputation_trade':{'enabled':!![],'rules':['immune']}},'pricing_redlines':['profile_pricing','hidden_surcharge','post_order_price_change'],'governance_redlines':['no_bid_ranking','no_default_charge','no_take_rate','no_personal_info_on_chain'],'quality_signals':['trust_score','fund_visibility','fulfillment','review_reputation','tenure'],'consumer_journey':['awareness','diligence','compare','decide','fulfill','review','retain','repurchase'],'north_star_metric':'weekly_completed_orders','revenue_boundary':'no_take_rate'};export function getUniversalTemplate(){return UNIVERSAL_TEMPLATE;}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const UTIL_CONFIRM_VERSION = "1.0.0";
|
|
2
|
+
export type ConfirmSeverity = "block" | "warn" | "info";
|
|
3
|
+
export interface UtilConfirmItem {
|
|
4
|
+
id: string;
|
|
5
|
+
severity: ConfirmSeverity;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
passed: boolean;
|
|
9
|
+
evidence?: string;
|
|
10
|
+
fix_hint?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UtilCallCheckInput {
|
|
13
|
+
uses_typo_function_name?: boolean;
|
|
14
|
+
assumes_stable_address_bytes?: boolean;
|
|
15
|
+
bcs_manually_synced?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function preCheckUtilCall(input: UtilCallCheckInput): UtilConfirmItem[];
|
|
18
|
+
export declare function canProceedUtilCall(input: UtilCallCheckInput): {
|
|
19
|
+
canProceed: boolean;
|
|
20
|
+
blockers: UtilConfirmItem[];
|
|
21
|
+
warnings: UtilConfirmItem[];
|
|
22
|
+
info: UtilConfirmItem[];
|
|
23
|
+
};
|
|
24
|
+
export declare function formatUtilCallSummary(input: UtilCallCheckInput): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const UTIL_CONFIRM_VERSION='1.0.0';function checkTypo(a){const b=!!a['uses_typo_function_name'];return{'id':'C-UTIL-01','severity':b?'info':'info','title':'Typo\x27d\x20function\x20name\x20is\x20handled\x20(is_chiild_object_address_byte)','description':'util.move\x20defines\x20is_chiild_object_address_byte\x20with\x20a\x20\x27chiild\x27\x20typo;\x20it\x20cannot\x20be\x20renamed\x20post-publish.\x20The\x20SDK\x20should\x20expose\x20a\x20correct\x20alias.','passed':!![],'evidence':b?'uses_typo_function_name=true\x20(must\x20use\x20\x27chiild\x27)':'typo\x20handled\x20via\x20alias'};}function checkAddressBytes(a){const b=!!a['assumes_stable_address_bytes'];return{'id':'C-UTIL-02','severity':b?'warn':'info','title':'Address-byte\x20thresholds\x20are\x20hardcoded','description':'util.move\x20classifies\x20addresses\x20by\x20first\x20byte\x20(user\x200x00,\x20object\x200xf1\x20or\x200x10..0x24,\x20child\x20unified\x20with\x20object).\x20A\x20Wow\x20protocol\x20upgrade\x20could\x20invalidate\x20them.','passed':!b,'evidence':b?'assumes_stable_address_bytes=true':'upgrade\x20coupling\x20understood','fix_hint':'Track\x20Wow\x20address-layout\x20upgrades;\x20ship\x20util.move\x20+\x20SDK\x20in\x20lockstep.'};}function checkBcs(a){const b=a['bcs_manually_synced']===!![];return{'id':'C-UTIL-03','severity':b?'warn':'info','title':'SDK\x20BCS\x20structures\x20stay\x20in\x20sync\x20with\x20Move\x20structs','description':'util.ts\x20defines\x20BCS\x20query\x20structures\x20that\x20must\x20match\x20Move\x20layouts\x20byte-for-byte;\x20drift\x20breaks\x20queries\x20silently.','passed':!b,'evidence':b?'bcs_manually_synced=true\x20(drift\x20risk)':'BCS\x20sync\x20safe','fix_hint':'Generate\x20BCS\x20from\x20Move\x20via\x20codegen,\x20or\x20run\x20a\x20layout\x20sync\x20test.'};}export function preCheckUtilCall(a){return[checkTypo(a),checkAddressBytes(a),checkBcs(a)];}export function canProceedUtilCall(a){const b=preCheckUtilCall(a);return{'canProceed':b['every'](c=>c['severity']!=='block'||c['passed']),'blockers':b['filter'](c=>c['severity']==='block'&&!c['passed']),'warnings':b['filter'](c=>c['severity']==='warn'&&!c['passed']),'info':b['filter'](c=>c['severity']==='info')};}export function formatUtilCallSummary(a){const {canProceed:b,warnings:c}=canProceedUtilCall(a),d=[b?'✓\x20Util\x20call\x20pre-check\x20PASSED':'✗\x20Util\x20call\x20pre-check\x20FAILED',''];return c['length']>0x0&&(d['push']('WARNINGS:'),c['forEach'](e=>d['push']('\x20\x20['+e['id']+']\x20'+e['title']+'\x20—\x20'+(e['evidence']??'')))),d['join']('\x0a');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const USER_ADDRESS_BYTE=0x0,OBJECT_ADDRESS_BYTE=0xf1,TYPED_OBJECT_BYTE_MIN=0x10,TYPED_OBJECT_BYTE_MAX=0x24,R_U_01={'rule':{'id':'R-UTIL-01','level':'LOW','category':'semantic','title':'is_chiild_object_address_byte\x20has\x20a\x20typo\x20(\x27chiild\x27)\x20—\x20cannot\x20be\x20renamed\x20post-publish','description':'util.move:30\x20defines\x20is_chiild_object_address_byte\x20(note\x20the\x20\x27chiild\x27\x20typo).\x20The\x20'+'function\x20is\x20already\x20published\x20on\x20mainnet,\x20so\x20the\x20name\x20cannot\x20be\x20fixed\x20without\x20a\x20'+'breaking\x20package\x20upgrade.\x20Callers\x20must\x20use\x20the\x20misspelled\x20name\x20exactly;\x20SDK\x20wrappers\x20'+'should\x20expose\x20a\x20correctly-spelled\x20alias\x20and\x20route\x20to\x20the\x20typo\x20function.','affected_stakeholders':['caller'],'scenario':'Caller\x20writes\x20is_child_object_address_byte;\x20Move\x20linker\x20cannot\x20resolve\x20the\x20symbol','mitigation':'SDK\x20should\x20expose\x20isChildObjectAddressByte\x20as\x20the\x20public\x20API\x20and\x20internally\x20call\x20the\x20'+'typo\x27d\x20Move\x20function.\x20Document\x20the\x20typo\x20so\x20future\x20maintainers\x20don\x27t\x20\x27fix\x27\x20it.','auto_fixable':![]},'check':a=>{if(!a['uses_typo_function_name'])return null;return{...R_U_01['rule'],'evidence':'uses_typo_function_name=true\x20(must\x20use\x20\x27chiild\x27)'};}},R_U_02={'rule':{'id':'R-UTIL-02','level':'MEDIUM','category':'semantic','title':'Address-byte\x20thresholds\x20are\x20hardcoded\x20—\x20Wow\x20protocol\x20upgrades\x20could\x20invalidate\x20them','description':'util.move\x20classifies\x20addresses\x20by\x20first\x20byte:\x20user\x20('+USER_ADDRESS_BYTE+'),\x20'+('object\x20('+OBJECT_ADDRESS_BYTE+'\x20for\x20regular/child,\x20or\x20'+TYPED_OBJECT_BYTE_MIN+'..'+TYPED_OBJECT_BYTE_MAX+'\x20for\x20typed\x20business\x20objects).\x20')+'These\x20thresholds\x20are\x20hardcoded\x20as\x20Move\x20constants,\x20not\x20configurable.\x20If\x20a\x20future\x20Wow\x20'+'protocol\x20upgrade\x20changes\x20the\x20address\x20byte\x20layout\x20(e.g.\x20reserves\x20a\x20new\x20prefix),\x20Util\x20'+'would\x20silently\x20misclassify\x20addresses\x20until\x20the\x20Move\x20code\x20is\x20upgraded.','affected_stakeholders':['caller','system'],'scenario':'Wow\x20protocol\x20upgrade\x20introduces\x20a\x20new\x20address\x20prefix;\x20Util\x20misclassifies\x20it\x20as\x20user','mitigation':'Track\x20Wow\x20protocol\x20upgrades\x20that\x20touch\x20address\x20layout.\x20When\x20a\x20change\x20ships,\x20upgrade\x20'+'util.move\x20and\x20the\x20SDK\x20in\x20lockstep.\x20Add\x20a\x20sync\x20test\x20that\x20asserts\x20the\x20byte\x20values.','auto_fixable':![]},'check':a=>{if(!a['assumes_stable_address_bytes'])return null;return{...R_U_02['rule'],'evidence':'assumes_stable_address_bytes=true\x20(hardcoded\x20'+USER_ADDRESS_BYTE+'/'+OBJECT_ADDRESS_BYTE+'/'+TYPED_OBJECT_BYTE_MIN+'..'+TYPED_OBJECT_BYTE_MAX+')'};}},R_U_03={'rule':{'id':'R-UTIL-03','level':'LOW','category':'structural','title':'util.ts\x20is\x20~50KB\x20—\x20over-concentrated,\x20hard\x20to\x20navigate','description':'The\x20SDK\x20util.ts\x20is\x20~50428\x20bytes,\x20mixing\x20BCS\x20structure\x20definitions,\x20query\x20condition\x20'+'builders,\x20Guard\x20query\x20helpers,\x20and\x20address\x20utilities.\x20The\x20size\x20makes\x20it\x20hard\x20to\x20'+'navigate\x20and\x20increases\x20the\x20risk\x20of\x20accidental\x20circular\x20imports.\x20New\x20contributors\x20'+'often\x20import\x20the\x20wrong\x20symbol\x20because\x20so\x20many\x20are\x20exported\x20from\x20one\x20file.','affected_stakeholders':['caller','system'],'scenario':'Developer\x20imports\x20ProgressHistoryFindConditionsBCS\x20and\x20accidentally\x20pulls\x20in\x20unrelated\x20code','mitigation':'Consider\x20splitting\x20util.ts\x20into\x20focused\x20sub-modules\x20(bcs.ts,\x20query.ts,\x20address.ts).\x20'+'Until\x20then,\x20prefer\x20named\x20imports\x20over\x20namespace\x20imports\x20to\x20keep\x20bundles\x20lean.','auto_fixable':![]},'check':a=>{if(!a['large_util_import'])return null;return{...R_U_03['rule'],'evidence':'large_util_import=true\x20(consider\x20sub-modules)'};}},R_U_04={'rule':{'id':'R-UTIL-04','level':'LOW','category':'lifecycle','title':'Util\x20emits\x20no\x20events\x20—\x20tool-call\x20observability\x20is\x20caller\x27s\x20responsibility','description':'Util\x20functions\x20are\x20pure:\x20they\x20neither\x20emit\x20nor\x20consume\x20events.\x20Callers\x20cannot\x20rely\x20on\x20'+'an\x20event\x20stream\x20to\x20trace\x20Util\x20invocations.\x20For\x20audit\x20and\x20debugging,\x20the\x20calling\x20'+'module\x20must\x20record\x20its\x20own\x20log\x20entries\x20around\x20Util\x20calls.','affected_stakeholders':['caller'],'scenario':'Auditor\x20expects\x20Util-call\x20events;\x20none\x20exist,\x20the\x20call\x20chain\x20is\x20invisible','mitigation':'Callers\x20should\x20emit\x20their\x20own\x20events\x20or\x20write\x20logs\x20around\x20Util\x20calls\x20when\x20auditability\x20'+'is\x20required.\x20Treat\x20Util\x20as\x20an\x20opaque\x20library\x20function.','auto_fixable':![]},'check':a=>{if(!a['expects_util_events'])return null;return{...R_U_04['rule'],'evidence':'expects_util_events=true\x20(none\x20emitted)'};}},R_U_05={'rule':{'id':'R-UTIL-05','level':'MEDIUM','category':'cross_object','title':'SDK\x20BCS\x20structures\x20must\x20stay\x20in\x20sync\x20with\x20Move\x20structs\x20—\x20drift\x20breaks\x20queries','description':'util.ts\x20defines\x20BCS\x20structures\x20for\x20Progress\x20History\x20/\x20Session\x20/\x20Forward\x20/\x20Record\x20'+'query\x20conditions.\x20These\x20must\x20match\x20the\x20Move\x20struct\x20layouts\x20byte-for-byte.\x20If\x20a\x20Move\x20'+'struct\x20adds\x20a\x20field\x20and\x20the\x20SDK\x20BCS\x20is\x20not\x20regenerated,\x20query\x20submissions\x20will\x20'+'deserialize\x20incorrectly\x20on-chain,\x20producing\x20silent\x20failures\x20or\x20aborts.','affected_stakeholders':['caller','system'],'scenario':'Progress\x20struct\x20adds\x20a\x20field;\x20SDK\x20BCS\x20is\x20stale;\x20queries\x20return\x20wrong\x20results','mitigation':'Generate\x20BCS\x20structures\x20from\x20Move\x20source\x20via\x20codegen,\x20or\x20run\x20a\x20sync\x20test\x20that\x20'+'compares\x20SDK\x20BCS\x20layouts\x20against\x20Move\x20structs\x20on\x20every\x20release.','auto_fixable':![]},'check':a=>{if(a['bcs_manually_synced']===undefined)return null;if(!a['bcs_manually_synced'])return null;return{...R_U_05['rule'],'evidence':'bcs_manually_synced=true\x20(drift\x20risk)'};}};export const UTIL_RISK_RULES=[R_U_01,R_U_02,R_U_03,R_U_04,R_U_05];export const UTIL_RISK_VERSION='1.0.0';export function checkUtilRisks(a){const b=[];for(const c of UTIL_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}export function getUtilRiskById(a){return UTIL_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const UTIL_TRANSLATION_VERSION = "1.0.0";
|
|
2
|
+
export declare const UTIL_ADDRESS_BYTES: {
|
|
3
|
+
readonly USER: 0;
|
|
4
|
+
readonly OBJECT: 241;
|
|
5
|
+
readonly TYPED_OBJECT_MIN: 16;
|
|
6
|
+
readonly TYPED_OBJECT_MAX: 36;
|
|
7
|
+
};
|
|
8
|
+
export interface SemanticToUtilSchemaRule {
|
|
9
|
+
id: string;
|
|
10
|
+
pattern_name: string;
|
|
11
|
+
semantic_intent: string;
|
|
12
|
+
match_keywords: string[];
|
|
13
|
+
example: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare const SEMANTIC_TO_UTIL_SCHEMA_RULES: SemanticToUtilSchemaRule[];
|
|
16
|
+
export interface UtilFieldTranslation {
|
|
17
|
+
field_name: string;
|
|
18
|
+
value_type: string;
|
|
19
|
+
semantic: string;
|
|
20
|
+
format_example: string;
|
|
21
|
+
validation_rules: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare const UTIL_FIELD_TRANSLATIONS: UtilFieldTranslation[];
|
|
24
|
+
export interface UtilConstraintRule {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
related_field: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const UTIL_CONSTRAINT_RULES: UtilConstraintRule[];
|
|
31
|
+
export interface UtilExplainInput {
|
|
32
|
+
first_byte?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface UtilExplanation {
|
|
35
|
+
summary: string;
|
|
36
|
+
classification: string;
|
|
37
|
+
warnings: string[];
|
|
38
|
+
}
|
|
39
|
+
export declare function explainUtil(input: UtilExplainInput): UtilExplanation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const UTIL_TRANSLATION_VERSION='1.0.0';export const UTIL_ADDRESS_BYTES={'USER':0x0,'OBJECT':0xf1,'TYPED_OBJECT_MIN':0x10,'TYPED_OBJECT_MAX':0x24};export const SEMANTIC_TO_UTIL_SCHEMA_RULES=[{'id':'P-UTIL-01','pattern_name':'Classify\x20address','semantic_intent':'Determine\x20whether\x20an\x20address\x20is\x20a\x20user,\x20object,\x20or\x20child-object.','match_keywords':['is\x20user\x20address','is\x20object\x20address','classify\x20address'],'example':{'addr':'0x...'}}];export const UTIL_FIELD_TRANSLATIONS=[{'field_name':'first_byte','value_type':'u8','semantic':'Address\x20classification\x20byte:\x20user\x200x00,\x20object\x200xf1\x20(regular/child)\x20or\x200x10..0x24\x20(typed\x20business).','format_example':'0xf1\x20(object)','validation_rules':['hardcoded\x20in\x20util.move']}];export const UTIL_CONSTRAINT_RULES=[{'id':'UTIL_C_01','name':'typo\x20function','description':'is_chiild_object_address_byte\x20has\x20a\x20\x27chiild\x27\x20typo;\x20cannot\x20rename\x20post-publish.','related_field':'first_byte'},{'id':'UTIL_C_02','name':'address-byte\x20stability','description':'byte\x20thresholds\x20are\x20hardcoded;\x20Wow\x20upgrade\x20could\x20invalidate\x20them.','related_field':'first_byte'},{'id':'UTIL_C_03','name':'BCS\x20sync','description':'SDK\x20BCS\x20structures\x20must\x20match\x20Move\x20layouts\x20byte-for-byte.','related_field':'first_byte'}];export function explainUtil(a){const b=[];let c='unknown';if(a['first_byte']!==undefined){if(a['first_byte']===UTIL_ADDRESS_BYTES['USER'])c='user\x20address';else{if(a['first_byte']===UTIL_ADDRESS_BYTES['OBJECT'])c='object\x20address\x20(regular/child)';else{if(a['first_byte']>=UTIL_ADDRESS_BYTES['TYPED_OBJECT_MIN']&&a['first_byte']<=UTIL_ADDRESS_BYTES['TYPED_OBJECT_MAX'])c='typed\x20business\x20object\x20address';else b['push']('first\x20byte\x200x'+a['first_byte']['toString'](0x10)+'\x20not\x20in\x20known\x20classification\x20range');}}}return{'summary':'Util\x20address\x20classification:\x20'+c+'.','classification':c,'warnings':b};}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export interface ParsedForward {
|
|
2
|
+
name: string;
|
|
3
|
+
weight: number;
|
|
4
|
+
namedOperator?: string | null;
|
|
5
|
+
permissionIndex?: number | null;
|
|
6
|
+
guard?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedPair {
|
|
9
|
+
prev_node: string;
|
|
10
|
+
threshold: number;
|
|
11
|
+
forwards: ParsedForward[];
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedMachineNode {
|
|
14
|
+
name: string;
|
|
15
|
+
pairs: ParsedPair[];
|
|
16
|
+
}
|
|
17
|
+
export type NameResolver = (addr: string | undefined | null) => string | undefined;
|
|
18
|
+
export declare function resolvePermissionRole(index: number | undefined | null, permissionDescription?: string): string;
|
|
19
|
+
export declare function fetchMachineNodes(machine: string, network?: string, noCache?: boolean): Promise<ParsedMachineNode[]>;
|
|
20
|
+
export interface GuidanceInput {
|
|
21
|
+
current: string;
|
|
22
|
+
nodes: ParsedMachineNode[];
|
|
23
|
+
caller?: string;
|
|
24
|
+
callerAddress?: string;
|
|
25
|
+
orderHolderAddresses?: string[];
|
|
26
|
+
progressNamedOperator?: {
|
|
27
|
+
name: string;
|
|
28
|
+
operators: string[];
|
|
29
|
+
}[];
|
|
30
|
+
permissionContext?: PermissionContext;
|
|
31
|
+
orderContext?: OrderContext;
|
|
32
|
+
permissionDescription?: string;
|
|
33
|
+
nameResolver?: NameResolver;
|
|
34
|
+
}
|
|
35
|
+
export interface OperatorInfo {
|
|
36
|
+
kind: "order_holder" | "permission_index" | "named_operator";
|
|
37
|
+
permission_index?: number;
|
|
38
|
+
role_name?: string;
|
|
39
|
+
account_name?: string;
|
|
40
|
+
named_operator?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface OptionInfo {
|
|
43
|
+
next_node: string;
|
|
44
|
+
forward: string;
|
|
45
|
+
weight: number;
|
|
46
|
+
operator: OperatorInfo;
|
|
47
|
+
guard?: string;
|
|
48
|
+
business_meaning: string;
|
|
49
|
+
gains: string[];
|
|
50
|
+
risks: string[];
|
|
51
|
+
consistency: number;
|
|
52
|
+
recommended: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface GuidanceResult {
|
|
55
|
+
current_node: string;
|
|
56
|
+
caller?: string;
|
|
57
|
+
options: OptionInfo[];
|
|
58
|
+
recommendation?: {
|
|
59
|
+
best?: string;
|
|
60
|
+
rationale?: string;
|
|
61
|
+
caveat?: string;
|
|
62
|
+
};
|
|
63
|
+
note?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function buildWorkflowGuidance(input: GuidanceInput): GuidanceResult;
|
|
66
|
+
export interface ReceiptInput extends GuidanceInput {
|
|
67
|
+
callerName: string;
|
|
68
|
+
forward: string;
|
|
69
|
+
targetNode: string;
|
|
70
|
+
op?: string;
|
|
71
|
+
session?: Array<{
|
|
72
|
+
next_node?: string;
|
|
73
|
+
forwards?: Array<{
|
|
74
|
+
forward?: string;
|
|
75
|
+
accomplished?: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
weights?: number;
|
|
78
|
+
threshold?: number;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
export interface WaitingInfo {
|
|
82
|
+
forward: string;
|
|
83
|
+
operator: OperatorInfo;
|
|
84
|
+
}
|
|
85
|
+
export interface ReceiptResult {
|
|
86
|
+
account: string;
|
|
87
|
+
action: string;
|
|
88
|
+
forward: string;
|
|
89
|
+
target_node: string;
|
|
90
|
+
op?: string;
|
|
91
|
+
migrated: boolean;
|
|
92
|
+
current_node: string;
|
|
93
|
+
threshold?: number;
|
|
94
|
+
accumulated_weight?: number;
|
|
95
|
+
remaining?: number;
|
|
96
|
+
waiting_on?: WaitingInfo[];
|
|
97
|
+
next_guidance?: GuidanceResult;
|
|
98
|
+
note?: string;
|
|
99
|
+
}
|
|
100
|
+
export declare function buildWorkflowReceipt(input: ReceiptInput): ReceiptResult;
|
|
101
|
+
export declare function renderGuidanceText(g: GuidanceResult): string;
|
|
102
|
+
export declare function renderReceiptText(r: ReceiptResult): string;
|
|
103
|
+
export interface EnrichOptions {
|
|
104
|
+
progressRef: string;
|
|
105
|
+
network?: string;
|
|
106
|
+
accountName?: string;
|
|
107
|
+
operate?: {
|
|
108
|
+
forward?: string;
|
|
109
|
+
next_node_name?: string;
|
|
110
|
+
op?: string;
|
|
111
|
+
};
|
|
112
|
+
noCache?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface EnrichResult {
|
|
115
|
+
guidance?: GuidanceResult;
|
|
116
|
+
receipt?: ReceiptResult;
|
|
117
|
+
text?: string;
|
|
118
|
+
}
|
|
119
|
+
export declare function enrichWorkflowGuidance(opts: EnrichOptions): Promise<EnrichResult | undefined>;
|
|
120
|
+
export declare function mergeGuidanceIntoOutput<T extends {
|
|
121
|
+
content: any[];
|
|
122
|
+
structuredContent: any;
|
|
123
|
+
}>(output: T, enrichment: EnrichResult | undefined): T;
|
|
124
|
+
export interface LocalAccountInfo {
|
|
125
|
+
address: string;
|
|
126
|
+
name?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface PermissionContext {
|
|
129
|
+
admin: Set<string>;
|
|
130
|
+
table: Map<string, Set<number>>;
|
|
131
|
+
}
|
|
132
|
+
export interface OrderContext {
|
|
133
|
+
builder: string;
|
|
134
|
+
agent: Set<string>;
|
|
135
|
+
}
|
|
136
|
+
export declare const ENTITY_PERMISSION_OBJECT_ID = "0xaad";
|
|
137
|
+
export declare const ENTITY_PERMISSION_ROLES: {
|
|
138
|
+
readonly OWNER: 1;
|
|
139
|
+
readonly ADMIN: 2;
|
|
140
|
+
readonly ENTITY: 4;
|
|
141
|
+
};
|
|
142
|
+
export interface EntityPermissionItem {
|
|
143
|
+
role: number;
|
|
144
|
+
permission: string;
|
|
145
|
+
time: number;
|
|
146
|
+
}
|
|
147
|
+
export interface EntityPermissionContext {
|
|
148
|
+
items: EntityPermissionItem[];
|
|
149
|
+
byPermission: Map<string, number>;
|
|
150
|
+
}
|
|
151
|
+
export declare function fetchEntityPermission(entityAddr: string, network?: string, noCache?: boolean): Promise<EntityPermissionContext | undefined>;
|
|
152
|
+
export declare const ENTITY_CONTACT_OBJECT_ID = "0xaa9";
|
|
153
|
+
export interface EntityContactItem {
|
|
154
|
+
contact: string;
|
|
155
|
+
time: number;
|
|
156
|
+
}
|
|
157
|
+
export interface EntityContactContext {
|
|
158
|
+
items: EntityContactItem[];
|
|
159
|
+
byContact: Map<string, number>;
|
|
160
|
+
}
|
|
161
|
+
export declare function fetchEntityContact(entityAddr: string, network?: string, noCache?: boolean): Promise<EntityContactContext | undefined>;
|
|
162
|
+
export declare const OBJECT_LINKER_CORE_OBJECT_ID = "0xaae";
|
|
163
|
+
export declare const OBJECT_LINKER_TX_OBJECT_ID = "0xaaf";
|
|
164
|
+
export interface ObjectLinkerItem {
|
|
165
|
+
who: string;
|
|
166
|
+
time: number;
|
|
167
|
+
}
|
|
168
|
+
export interface ObjectLinkerContext {
|
|
169
|
+
items: ObjectLinkerItem[];
|
|
170
|
+
byWho: Map<string, number>;
|
|
171
|
+
}
|
|
172
|
+
export declare function fetchObjectLinkerCore(targetAddr: string, network?: string, noCache?: boolean): Promise<ObjectLinkerContext | undefined>;
|
|
173
|
+
export declare function fetchObjectLinkerTx(targetAddr: string, network?: string, noCache?: boolean): Promise<ObjectLinkerContext | undefined>;
|
|
174
|
+
export declare function fetchPermissionContext(permAddr: string, network?: string, noCache?: boolean): Promise<PermissionContext | undefined>;
|
|
175
|
+
export declare function fetchOrderContext(orderAddr: string, network?: string, noCache?: boolean): Promise<OrderContext | undefined>;
|
|
176
|
+
export declare function listLocalAccounts(): Promise<LocalAccountInfo[]>;
|
|
177
|
+
export declare function accountCanExecuteForward(f: ParsedForward, account: string, progressNamedOperator: {
|
|
178
|
+
name: string;
|
|
179
|
+
operators: string[];
|
|
180
|
+
}[], orderCtx: OrderContext | undefined, permCtx: PermissionContext | undefined): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{query_objects,query_table,query_account_list,LocalMark,GetLocalNamesByAddresses,bcs,deriveDynamicFieldID}from'@wowok/wowok';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSION_MAP=new Map();for(const entry of[...REPOSITORY_PERMISSIONS,...REWARD_PERMISSIONS,...MACHINE_PERMISSIONS,...PROGRESS_PERMISSIONS,...TREASURY_PERMISSIONS,...SERVICE_PERMISSIONS,...ARBITRATION_PERMISSIONS,...DEMAND_PERMISSIONS,...CONTACT_PERMISSIONS]){BUILTIN_PERMISSION_MAP['set'](entry['index'],entry['name']);}export function resolvePermissionRole(a,b){if(a===undefined||a===null)return'unknown\x20role';if(b){const d=/([A-Za-z][A-Za-z0-9_]*)\s*=\s*(\d+)/g;let e;while((e=d['exec'](b))!==null){if(Number(e[0x2])===a)return e[0x1]+'\x20(permission\x20'+a+')';}}const c=BUILTIN_PERMISSION_MAP['get'](a);if(c)return c+'\x20(permission\x20'+a+')';return'permission\x20'+a;}export async function fetchMachineNodes(a,b,c){const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const g=await query_table({'parent':f,'no_cache':c,'network':b}),h=(g?.['items']??[])['map'](j=>j?.['object'])['filter'](j=>typeof j==='string');if(h['length']===0x0)return[];const i=await query_objects({'objects':h,'no_cache':c,'network':b});return(i?.['objects']??[])['filter'](j=>j?.['type']==='TableItem_MachineNode')['map'](j=>{const k=j?.['data']??j,l=typeof k?.['name']==='string'?k['name']:'',m=Array['isArray'](k?.['value'])?k['value']:Array['isArray'](k?.['pairs'])?k['pairs']:[];if(!l)return null;return{'name':l,'pairs':m['map'](n=>({'prev_node':String(n?.['prev_node']??''),'threshold':Number(n?.['threshold']??0x0),'forwards':Array['isArray'](n?.['forwards'])?n['forwards']['map'](q=>{const r=typeof q?.['guard']==='object'&&q?.['guard']!==null?q['guard']['guard']??undefined:typeof q?.['guard']==='string'?q['guard']:undefined;return{'name':String(q?.['name']??''),'weight':Number(q?.['weight']??0x0),'namedOperator':q?.['namedOperator']!==undefined&&q?.['namedOperator']!==null?String(q['namedOperator']):undefined,'permissionIndex':q?.['permissionIndex']!==undefined&&q?.['permissionIndex']!==null?Number(q['permissionIndex']):undefined,'guard':r};}):[]}))};})['filter'](j=>j!==null);}const COMPLETE_RE=/(^|_)(completed?|done|finished|received|delivered|accepted|confirmed|finalized|success|approved)(_|$)/i,REFUND_RE=/(^|_)(cancel(led)?|refund(ed)?|return(ed|_approved)?)(_|$)/i,EXCEPTION_RE=/(^|_)(interrupt(ed)?|exception|dispute(d)?|fail(ed)?|abort(ed)?|reject(ed)?)(_|$)/i;function classifyNode(a){if(COMPLETE_RE['test'](a))return'complete';if(REFUND_RE['test'](a))return'refund';if(EXCEPTION_RE['test'](a))return'exception';return'advance';}function businessMeaning(a,b){switch(b){case'complete':return'Service/deliverable\x20accepted\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20settlement\x20allocation\x20(funds\x20released\x20to\x20the\x20provider)';case'refund':return'Order\x20cancelled/returned\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20refund\x20allocation\x20(funds\x20back\x20to\x20the\x20customer)';case'exception':return'Exception\x20path\x20at\x20\x22'+a+'\x22\x20—\x20typically\x20routes\x20to\x20arbitration\x20or\x20partial-refund\x20handling';default:return'Progress\x20to\x20\x22'+a+'\x22';}}function shortAddr(a){if(!a)return undefined;if(a['length']>0xe)return a['slice'](0x0,0x8)+'...'+a['slice'](-0x4);return a;}function callerIsOrderHolder(a,b){if(!a||!b?.['length'])return![];const d=a['toLowerCase']();return b['some'](e=>e?.['toLowerCase']()===d);}function resolveOperator(a,b,c,d){if(a['namedOperator']===''){const e=b?.[0x0];return{'kind':'order_holder','role_name':'order\x20holder\x20(customer)','account_name':d?d(e):shortAddr(e)};}if(typeof a['namedOperator']==='string'&&a['namedOperator']['length']>0x0)return{'kind':'named_operator','named_operator':a['namedOperator'],'role_name':'named\x20operator\x20\x22'+a['namedOperator']+'\x22'};if(a['permissionIndex']!==undefined&&a['permissionIndex']!==null)return{'kind':'permission_index','permission_index':a['permissionIndex'],'role_name':resolvePermissionRole(a['permissionIndex'],c)};return{'kind':'order_holder','role_name':'unknown\x20operator'};}function gainsRisksFor(a,b,c){if(!c)return{'gains':[],'risks':[]};if(b)switch(a){case'complete':return{'gains':['Flow\x20advances','Settlement\x20triggered\x20(funds\x20released)'],'risks':['Funds\x20released\x20to\x20provider','Refund\x20leverage\x20lost\x20—\x20confirm\x20only\x20if\x20service\x20verified']};case'refund':return{'gains':['Funds\x20returned\x20to\x20you'],'risks':['If\x20service\x20was\x20already\x20rendered,\x20cancellation\x20may\x20be\x20disputed']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20reputation\x20impact']};default:return{'gains':['Flow\x20advances'],'risks':[]};}switch(a){case'complete':return{'gains':['Settlement\x20triggered\x20—\x20funds\x20released\x20to\x20provider'],'risks':[]};case'refund':return{'gains':['Clean\x20closure'],'risks':['Lost\x20revenue\x20for\x20this\x20order']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20compensation\x20fund']};default:return{'gains':['Flow\x20advances'],'risks':[]};}}function consistencyFor(a,b,c,d,e){let f;if(!e)f=a==='exception'?0x2d:0x32;else b?f=a==='refund'?0x46:a==='complete'?0x37:a==='exception'?0x23:0x32:f=a==='complete'?0x4b:a==='refund'?0x1e:a==='exception'?0x23:0x32;if(e&&c)f+=0x14;if(d)f-=0xa;return Math['max'](0x0,Math['min'](0x64,f));}export function buildWorkflowGuidance(a){const b=[];for(const i of a['nodes']){for(const j of i['pairs']){if(j['prev_node']!==a['current'])continue;for(const k of j['forwards']){if(!k['name'])continue;const l=resolveOperator(k,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver']),m=callerIsOrderHolder(a['callerAddress']??a['caller'],a['orderHolderAddresses']);let n=![];a['callerAddress']&&(n=accountCanExecuteForward(k,a['callerAddress'],a['progressNamedOperator']??[],a['orderContext'],a['permissionContext']));const p=classifyNode(i['name']),q=!!a['caller'],{gains:r,risks:s}=gainsRisksFor(p,m,q),t=consistencyFor(p,m,n,!!k['guard'],q);b['push']({'next_node':i['name'],'forward':k['name'],'weight':k['weight'],'operator':l,'guard':k['guard'],'business_meaning':businessMeaning(i['name'],p),'gains':r,'risks':s,'consistency':t,'recommended':![]});}}}if(b['length']===0x0)return{'current_node':a['current'],'caller':a['caller'],'options':[],'note':'Node\x20\x22'+a['current']+'\x22\x20has\x20no\x20outgoing\x20forwards\x20—\x20it\x20is\x20a\x20terminal\x20node\x20(or\x20the\x20workflow\x20is\x20stuck).\x20No\x20further\x20progress\x20operation\x20is\x20available\x20here.'};b['sort']((u,v)=>v['consistency']-u['consistency']);const c=b[0x0];b[0x0]={...c,'recommended':!![]};const d=[];for(const u of b){u!==c&&u['consistency']>0x0&&u['forward']!==c['forward']&&d['push']('Choosing\x20\x22'+u['forward']+'\x20→\x20'+u['next_node']+'\x22\x20forfeits\x20the\x20faster/more\x20aligned\x20path\x20\x22'+c['forward']+'\x20→\x20'+c['next_node']+'\x22');}const e=[],g=b['filter'](v=>v['operator']['kind']==='order_holder'&&v['forward']!==c['forward']&&c['forward']!==v['forward']),h=b['filter'](v=>v['operator']['account_name']&&v['operator']['account_name']!==a['caller']);return h['length']>0x0&&!b['some'](v=>v['recommended']&&v['operator']['account_name']===a['caller'])&&e['push']('The\x20recommended\x20action\x20is\x20executed\x20by\x20another\x20account\x20('+h[0x0]['operator']['account_name']+');\x20switch\x20the\x20signing\x20account\x20(env.account)\x20before\x20operating.'),{'current_node':a['current'],'caller':a['caller'],'options':b,'recommendation':{'best':c['forward']+'\x20→\x20'+c['next_node'],'rationale':'Highest\x20consistency\x20('+c['consistency']+'/100)\x20with\x20the\x20caller\x27s\x20interests.\x20Gains:\x20'+(c['gains']['join'](';\x20')||'none')+'.\x20Risks:\x20'+(c['risks']['join'](';\x20')||'none')+'.\x20Operator:\x20'+(c['operator']['role_name']??c['operator']['kind'])+(c['operator']['account_name']?'\x20('+c['operator']['account_name']+')':'')+'.'+(c['guard']?'\x20Guard\x20to\x20satisfy:\x20'+c['guard']+'.':''),'caveat':d['length']?d['join']('.\x20'):undefined},'note':e['length']?e['join']('\x20'):undefined};}export function buildWorkflowReceipt(a){const b=a['current']===a['targetNode'],c={'account':a['callerName'],'action':a['callerName']+'\x20executed\x20'+a['forward']+'\x20(→\x20'+a['targetNode']+')','forward':a['forward'],'target_node':a['targetNode'],'op':a['op'],'migrated':b,'current_node':a['current']};if(!b){const e=a['nodes']['filter'](j=>j['name']===a['targetNode'])['flatMap'](j=>j['pairs'])['find'](j=>j['prev_node']===a['current']),g=a['session']?.['slice'](-0x1)[0x0],h=g?.['threshold']??e?.['threshold']??0x0,i=g?.['weights']??0x0;if(h>0x0){c['threshold']=h,c['accumulated_weight']=i,c['remaining']=Math['max'](0x0,h-i);const j=new Set((g?.['forwards']??[])['filter'](l=>l?.['accomplished']!==![])['map'](l=>l?.['forward'])['filter'](l=>!!l)),k=[];for(const l of e?.['forwards']??[]){if(!l['name']||j['has'](l['name']))continue;k['push']({'forward':l['name'],'operator':resolveOperator(l,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver'])});}if(k['length'])c['waiting_on']=k;c['note']='Node\x20did\x20not\x20migrate:\x20threshold\x20'+h+',\x20accumulated\x20weight\x20'+i+',\x20remaining\x20'+Math['max'](0x0,h-i)+'.\x20'+(k['length']?'Waiting\x20for:\x20'+k['map'](m=>m['forward']+'\x20('+(m['operator']['role_name']??m['operator']['kind'])+')')['join'](';\x20'):'All\x20forwards\x20on\x20this\x20pair\x20are\x20accomplished\x20—\x20the\x20node\x20should\x20migrate\x20on\x20the\x20next\x20operation.');}else c['note']='Node\x20did\x20not\x20migrate\x20(threshold\x200)\x20—\x20no\x20further\x20weight\x20cooperation\x20required;\x20verify\x20the\x20operation\x20outcome.';}const d=buildWorkflowGuidance({'current':a['current'],'nodes':a['nodes'],'caller':a['caller'],'orderHolderAddresses':a['orderHolderAddresses'],'permissionDescription':a['permissionDescription'],'nameResolver':a['nameResolver']});if(d['options']['length']>0x0)c['next_guidance']=d;return c;}function operatorText(a){const b=[a['role_name']??a['kind']];if(a['account_name'])b['push'](a['account_name']);return b['join']('\x20/\x20');}export function renderGuidanceText(a){const b=['[WORKFLOW\x20GUIDANCE]\x20current\x20node:\x20\x22'+a['current_node']+'\x22'+(a['caller']?'\x20(caller:\x20'+a['caller']+')':'')];if(a['options']['length']===0x0)return b['push']('\x20\x20•\x20'+(a['note']??'No\x20reachable\x20next\x20nodes.')),b['join']('\x0a');for(const c of a['options']){const d=['\x22'+c['forward']+'\x22\x20→\x20\x22'+c['next_node']+'\x22','operator:\x20'+operatorText(c['operator']),'weight:\x20'+c['weight'],'consistency:\x20'+c['consistency']+'/100'+(c['recommended']?'\x20[RECOMMENDED]':'')];if(c['guard'])d['push']('guard:\x20'+c['guard']);d['push']('meaning:\x20'+c['business_meaning']);if(c['gains']['length'])d['push']('gains:\x20'+c['gains']['join'](';\x20'));if(c['risks']['length'])d['push']('risks:\x20'+c['risks']['join'](';\x20'));b['push']('\x20\x20•\x20'+d['join']('\x20|\x20'));}if(a['recommendation']?.['best']){b['push']('\x20\x20RECOMMENDED:\x20'+a['recommendation']['best']+'.\x20'+(a['recommendation']['rationale']??''));if(a['recommendation']['caveat'])b['push']('\x20\x20CAVEAT\x20(opportunity\x20cost):\x20'+a['recommendation']['caveat']);}if(a['note'])b['push']('\x20\x20NOTE:\x20'+a['note']);return b['push']('\x20\x20(AI\x20recommendation\x20only\x20—\x20the\x20account\x20decides;\x20switch\x20env.account\x20if\x20another\x20operator\x20must\x20act.)'),b['join']('\x0a');}export function renderReceiptText(a){const b=['[WORKFLOW\x20RECEIPT]\x20'+a['action']];b['push']('\x20\x20•\x20node\x20migrated:\x20'+(a['migrated']?'yes\x20→\x20current:\x20\x22'+a['current_node']+'\x22':'no\x20→\x20current:\x20\x22'+a['current_node']+'\x22'));if(!a['migrated']){a['threshold']!==undefined&&a['threshold']>0x0&&(b['push']('\x20\x20•\x20threshold:\x20'+a['threshold']+'\x20|\x20accumulated\x20weight:\x20'+(a['accumulated_weight']??0x0)+'\x20|\x20remaining:\x20'+(a['remaining']??0x0)),a['waiting_on']?.['length']&&b['push']('\x20\x20•\x20waiting\x20on:\x20'+a['waiting_on']['map'](c=>'\x22'+c['forward']+'\x22\x20('+operatorText(c['operator'])+')')['join'](';\x20')));if(a['note'])b['push']('\x20\x20•\x20note:\x20'+a['note']);}return a['next_guidance']&&a['next_guidance']['options']['length']>0x0&&b['push'](renderGuidanceText(a['next_guidance'])),b['join']('\x0a');}async function makeNameResolver(a){const b=[...new Set(a['filter'](d=>!!d))],c=new Map();if(b['length'])try{const d=await GetLocalNamesByAddresses(b);for(const e of d){const f=e?.['account']??e?.['local_mark'];if(f)c['set'](e['address']['toLowerCase'](),f);}}catch{}return g=>{if(!g)return undefined;const h=c['get'](g['toLowerCase']());return h??shortAddr(g);};}export async function enrichWorkflowGuidance(a){try{let b;if(a['progressRef']['startsWith']('0x'))b=a['progressRef'];else b=await LocalMark['Instance']()['get_address'](a['progressRef'])??undefined;if(!b)return undefined;const c=await query_objects({'objects':[b],'no_cache':a['noCache'],'network':a['network']}),d=c?.['objects']?.[0x0],e=d?.['data']??d;if((d?.['type']??e?.['type'])!=='Progress')return undefined;const f=e['current']??'',g=e['machine'],h=Array['isArray'](e['session'])?e['session']:[],i=(Array['isArray'](e['namedOperator'])?e['namedOperator']['find'](u=>u?.['name']==='')?.['operators']:undefined)??[];if(!g)return undefined;const j=await fetchMachineNodes(g,a['network'],a['noCache']);let k,l;try{const u=await query_objects({'objects':[g],'no_cache':a['noCache'],'network':a['network']}),v=u?.['objects']?.[0x0],w=v?.['data']??v,x=w?.['permission'];if(x){const y=await query_objects({'objects':[x],'no_cache':a['noCache'],'network':a['network']}),z=y?.['objects']?.[0x0];k=(z?.['data']??z)?.['description']??undefined,l=await fetchPermissionContext(x,a['network'],a['noCache']);}}catch{}const m=(Array['isArray'](e['namedOperator'])?e['namedOperator']:[])['map'](A=>({'name':String(A?.['name']??''),'operators':(A?.['operators']??[])['map'](B=>String(B))}));let n;e['task']&&(n=await fetchOrderContext(e['task'],a['network'],a['noCache']));let o;try{o=await LocalMark['Instance']()['get_address'](a['accountName'])??undefined;}catch{o=undefined;}const p=await makeNameResolver([a['accountName'],...i]),q={'current':f,'nodes':j,'caller':a['accountName'],'callerAddress':o,'orderHolderAddresses':i,'progressNamedOperator':m,'permissionContext':l,'orderContext':n,'permissionDescription':k,'nameResolver':p},r=buildWorkflowGuidance(q);let s;a['operate']?.['forward']&&a['operate']?.['next_node_name']&&(s=buildWorkflowReceipt({...q,'callerName':a['accountName']??b,'forward':a['operate']['forward'],'targetNode':a['operate']['next_node_name'],'op':a['operate']['op'],'session':h}));const t=[s?renderReceiptText(s):undefined,r['options']['length']?renderGuidanceText(r):undefined]['filter'](A=>!!A)['join']('\x0a\x0a');return{'guidance':r,'receipt':s,'text':t};}catch{return undefined;}}export function mergeGuidanceIntoOutput(a,b){if(!b)return a;try{const c=a?.['structuredContent'];if(c&&typeof c==='object'){const d=c['semantic'];if(d&&typeof d==='object'){if(b['guidance'])d['workflow_guidance']=b['guidance'];if(b['receipt'])d['workflow_receipt']=b['receipt'];}}b['text']&&Array['isArray'](a?.['content'])&&a['content'][0x0]?.['text']!==undefined&&(a['content'][0x0]['text']=b['text']+'\x0a\x0a'+a['content'][0x0]['text']);}catch{}return a;}export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_PERMISSION_ROLES={'OWNER':0x1,'ADMIN':0x2,'ENTITY':0x4};export async function fetchEntityPermission(a,b,c){try{const e=bcs['Address']['serialize'](a)['toBytes'](),f=deriveDynamicFieldID(ENTITY_PERMISSION_OBJECT_ID,'address',e),g=await query_objects({'objects':[f],'no_cache':c,'network':b}),h=g?.['objects']?.[0x0],i=h?.['data']??h,j=[],k=new Map(),l=Array['isArray'](i?.['items'])?i['items']:[];for(const m of l){const n=Number(m?.['role']??0x0),o=String(m?.['permission']??'')['toLowerCase'](),p=Number(m?.['time']??0x0);o&&(j['push']({'role':n,'permission':o,'time':p}),k['set'](o,(k['get'](o)??0x0)|n));}return{'items':j,'byPermission':k};}catch{return undefined;}}export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export async function fetchEntityContact(a,b,c){try{const e=bcs['Address']['serialize'](a)['toBytes'](),f=deriveDynamicFieldID(ENTITY_CONTACT_OBJECT_ID,'address',e),g=await query_objects({'objects':[f],'no_cache':c,'network':b}),h=g?.['objects']?.[0x0],i=h?.['data']??h,j=[],k=new Map(),l=Array['isArray'](i?.['items'])?i['items']:[];for(const m of l){const n=String(m?.['contact']??'')['toLowerCase'](),o=Number(m?.['time']??0x0);n&&(j['push']({'contact':n,'time':o}),k['set'](n,o));}return{'items':j,'byContact':k};}catch{return undefined;}}export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';async function fetchObjectLinker(a,b,c,e){try{const f=bcs['Address']['serialize'](b)['toBytes'](),g=deriveDynamicFieldID(a,'address',f),h=await query_objects({'objects':[g],'no_cache':e,'network':c}),i=h?.['objects']?.[0x0],j=i?.['data']??i,k=[],l=new Map(),m=Array['isArray'](j?.['items'])?j['items']:[];for(const n of m){const o=String(n?.['who']??'')['toLowerCase'](),p=Number(n?.['time']??0x0);o&&(k['push']({'who':o,'time':p}),l['set'](o,p));}return{'items':k,'byWho':l};}catch{return undefined;}}export async function fetchObjectLinkerCore(a,b,c){return fetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export async function fetchObjectLinkerTx(a,b,c){return fetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}export async function fetchPermissionContext(a,b,c){try{const e=await query_objects({'objects':[a],'no_cache':c,'network':b}),f=e?.['objects']?.[0x0],g=f?.['data']??f,h=new Set((g?.['admin']??[])['map'](l=>String(l)['toLowerCase']())),i=new Map(),j=await query_table({'parent':a,'no_cache':c,'network':b}),k=(j?.['items']??[])['map'](l=>l?.['object'])['filter'](l=>typeof l==='string');if(k['length']>0x0){const l=await query_objects({'objects':k,'no_cache':c,'network':b});for(const m of l?.['objects']??[]){const n=m?.['data']??m,p=n?.['address'],q=n?.['perm'];p!=null&&Array['isArray'](q)&&i['set'](String(p)['toLowerCase'](),new Set(q['map'](r=>Number(r))));}}return{'admin':h,'table':i};}catch{return undefined;}}export async function fetchOrderContext(a,b,c){try{const e=await query_objects({'objects':[a],'no_cache':c,'network':b}),f=e?.['objects']?.[0x0];if((f?.['type']??f?.['data']?.['type'])!=='Order')return undefined;const g=f?.['data']??f;return{'builder':String(g?.['builder']??''),'agent':new Set((g?.['agent']??[])['map'](h=>String(h)['toLowerCase']()))};}catch{return undefined;}}export async function listLocalAccounts(){try{const a=await query_account_list({'suspended':![]});return(a??[])['filter'](b=>b?.['address'])['map'](b=>({'address':String(b['address']),'name':b['name']??undefined}));}catch{return[];}}export function accountCanExecuteForward(a,b,c,d,e){const g=b['toLowerCase']();if(a['namedOperator']!==undefined&&a['namedOperator']!==null){if(a['namedOperator']===''){if(d&&(g===d['builder']['toLowerCase']()||d['agent']['has'](g)))return!![];}else{if(a['namedOperator']['length']>0x0){const h=c['find'](i=>i?.['name']===a['namedOperator']);if(h?.['operators']?.['some'](i=>String(i)['toLowerCase']()===g))return!![];}}}if(a['permissionIndex']!==undefined&&a['permissionIndex']!==null&&e){if(e['admin']['has'](g))return!![];const i=e['table']['get'](g);if(i?.['has'](a['permissionIndex']))return!![];}return![];}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type EmployeeDepartment = "customer_service" | "logistics" | "finance" | "operations";
|
|
2
|
+
export type EmployeeLiability = "merchant_bears" | "self_bears" | "hybrid";
|
|
3
|
+
export interface EmployeeProfile {
|
|
4
|
+
department: EmployeeDepartment;
|
|
5
|
+
liability: EmployeeLiability;
|
|
6
|
+
response_time_budget_ms?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ReactionKpi {
|
|
9
|
+
node: string;
|
|
10
|
+
reaction_ms: number;
|
|
11
|
+
within_budget: boolean;
|
|
12
|
+
status: "pass" | "warn" | "fail";
|
|
13
|
+
}
|
|
14
|
+
export interface LiabilityResolution {
|
|
15
|
+
bears: "merchant" | "employee";
|
|
16
|
+
must_compensate_before_resume: boolean;
|
|
17
|
+
note: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function assessReactionKpi(node: string, assigned_at: number, advanced_at: number | undefined, budget_ms?: number): ReactionKpi;
|
|
20
|
+
export declare function resolveLiability(liability: EmployeeLiability, loss_amount: number, hybrid_threshold?: number): LiabilityResolution;
|
|
21
|
+
export interface EmployeeProfileValidation {
|
|
22
|
+
valid: boolean;
|
|
23
|
+
issues: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare function validateEmployeeProfile(profile: EmployeeProfile): EmployeeProfileValidation;
|