@wowok/agent-mcp 2.7.0 → 2.7.2
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/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.d.ts +5 -1
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +23 -0
- package/dist/evaluation/arbitration-game.js +1 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +1 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +1 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +1 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +1 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +1 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +1 -0
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +1 -0
- package/dist/evaluation/index.d.ts +12 -0
- package/dist/evaluation/index.js +1 -0
- package/dist/evaluation/node-game.d.ts +62 -0
- package/dist/evaluation/node-game.js +1 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +1 -0
- package/dist/evaluation/types.d.ts +77 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +1 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -276
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.d.ts +1 -0
- package/dist/intent/enrich.js +1 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +1 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +1 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +1 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +1 -0
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -433
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -825
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -670
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -773
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -615
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -341
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -155
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.d.ts +16 -0
- package/dist/persona/analyzer.js +1 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +1 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +1 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +1 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +1 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +1 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +1 -0
- package/dist/persona/types.d.ts +45 -0
- package/dist/persona/types.js +1 -0
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.d.ts +5 -0
- package/dist/project/handlers.js +1 -1762
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -245
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.d.ts +2 -0
- package/dist/rules.js +1 -9
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1657
- package/dist/schema/call/service.js +1 -178
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +4436 -0
- package/dist/schema/evaluation/index.js +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +1 -13
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +1 -0
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +1985 -0
- package/dist/schema/persona/index.js +1 -0
- package/dist/schema/project/index.d.ts +96 -50
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1640
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +1 -282
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +1 -0
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +782 -0
- package/dist/schemas/evaluation_operation.schema.json +990 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +232 -0
- package/dist/schemas/intent_radar.schema.json +138 -0
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +6 -6
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +3 -3
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +392 -0
- package/dist/schemas/persona_operation.schema.json +250 -0
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +9 -6
- package/dist/schemas/trust_score.schema.json +1 -1
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +1 -0
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +1 -0
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1082
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +1 -0
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +1 -55
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1306
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -278
- package/dist/tools/wrap.js +1 -500
- package/package.json +5 -3
|
@@ -1,970 +1 @@
|
|
|
1
|
-
export const ALLOCATION_TEMPLATES = [
|
|
2
|
-
{
|
|
3
|
-
id: "T-A-01",
|
|
4
|
-
name: "Single Rate 100% to Treasury",
|
|
5
|
-
description: "Simplest allocation — single Allocator, single Rate=10000 sharing to one Treasury/personal address",
|
|
6
|
-
applicable_scenes: ["allocation_merchant_full_payment"],
|
|
7
|
-
industry_tags: ["universal", "retail", "service"],
|
|
8
|
-
params: [
|
|
9
|
-
{
|
|
10
|
-
name: "allocation_name",
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "Local name for the new Allocation object",
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "coin_type",
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "Coin<T> type string (e.g. '0x2::wow::WOW')",
|
|
19
|
-
required: true,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: "recipient_address",
|
|
23
|
-
type: "address",
|
|
24
|
-
description: "Treasury or personal wallet address to receive 100%",
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "guard_address",
|
|
29
|
-
type: "address",
|
|
30
|
-
description: "Guard object address (verifies order completion)",
|
|
31
|
-
required: true,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "description",
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "Allocation description",
|
|
37
|
-
required: false,
|
|
38
|
-
default: "Single Rate 100% allocation",
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
body: (p) => ({
|
|
42
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
43
|
-
allocators: {
|
|
44
|
-
description: p.description ?? "Single Rate 100% allocation",
|
|
45
|
-
threshold: "0",
|
|
46
|
-
allocators: [
|
|
47
|
-
{
|
|
48
|
-
guard: p.guard_address,
|
|
49
|
-
sharing: [
|
|
50
|
-
{
|
|
51
|
-
who: { Entity: p.recipient_address },
|
|
52
|
-
sharing: "10000",
|
|
53
|
-
mode: "Rate",
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
max: null,
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
61
|
-
payment_info: {},
|
|
62
|
-
}),
|
|
63
|
-
notes: [
|
|
64
|
-
"Simplest configuration — no multi-party coordination",
|
|
65
|
-
"Guard only needs to verify order status, no complex conditions",
|
|
66
|
-
"Suitable for solo merchants or single-treasury services",
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: "T-A-02",
|
|
71
|
-
name: "Standard 3-way Rate split",
|
|
72
|
-
description: "Three-way split: merchant / platform / logistics. Pure Rate mode, sum(rates) MUST equal 10000",
|
|
73
|
-
applicable_scenes: ["allocation_standard_three_way_split"],
|
|
74
|
-
industry_tags: ["retail", "ecommerce", "logistics"],
|
|
75
|
-
params: [
|
|
76
|
-
{
|
|
77
|
-
name: "allocation_name",
|
|
78
|
-
type: "string",
|
|
79
|
-
description: "Local name for the new Allocation object",
|
|
80
|
-
required: true,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: "coin_type",
|
|
84
|
-
type: "string",
|
|
85
|
-
description: "Coin<T> type string",
|
|
86
|
-
required: true,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "merchant_treasury",
|
|
90
|
-
type: "address",
|
|
91
|
-
description: "Merchant Treasury address",
|
|
92
|
-
required: true,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "platform_treasury",
|
|
96
|
-
type: "address",
|
|
97
|
-
description: "Platform Treasury address",
|
|
98
|
-
required: true,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: "logistics_treasury",
|
|
102
|
-
type: "address",
|
|
103
|
-
description: "Logistics Treasury address (set to platform_treasury if N/A)",
|
|
104
|
-
required: true,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: "merchant_rate",
|
|
108
|
-
type: "number",
|
|
109
|
-
description: "Merchant rate in basis points (e.g. 8000 = 80%)",
|
|
110
|
-
required: true,
|
|
111
|
-
default: 8000,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: "platform_rate",
|
|
115
|
-
type: "number",
|
|
116
|
-
description: "Platform rate in basis points (e.g. 1000 = 10%)",
|
|
117
|
-
required: true,
|
|
118
|
-
default: 1000,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "logistics_rate",
|
|
122
|
-
type: "number",
|
|
123
|
-
description: "Logistics rate in basis points (e.g. 1000 = 10%)",
|
|
124
|
-
required: true,
|
|
125
|
-
default: 1000,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: "guard_address",
|
|
129
|
-
type: "address",
|
|
130
|
-
description: "Guard object address (verifies order completion + service binding)",
|
|
131
|
-
required: true,
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
body: (p) => {
|
|
135
|
-
const merchantRate = Number(p.merchant_rate);
|
|
136
|
-
const platformRate = Number(p.platform_rate);
|
|
137
|
-
const logisticsRate = Number(p.logistics_rate);
|
|
138
|
-
const total = merchantRate + platformRate + logisticsRate;
|
|
139
|
-
if (total !== 10000) {
|
|
140
|
-
throw new Error(`T-A-02: sum(rates) MUST equal 10000 (RATE_TOTAL_FULL), got ${total} ` +
|
|
141
|
-
`(merchant=${merchantRate} + platform=${platformRate} + logistics=${logisticsRate})`);
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
145
|
-
allocators: {
|
|
146
|
-
description: `3-way split: merchant ${merchantRate}/10000, platform ${platformRate}/10000, logistics ${logisticsRate}/10000`,
|
|
147
|
-
threshold: "0",
|
|
148
|
-
allocators: [
|
|
149
|
-
{
|
|
150
|
-
guard: p.guard_address,
|
|
151
|
-
sharing: [
|
|
152
|
-
{ who: { Entity: p.merchant_treasury }, sharing: String(merchantRate), mode: "Rate" },
|
|
153
|
-
{ who: { Entity: p.platform_treasury }, sharing: String(platformRate), mode: "Rate" },
|
|
154
|
-
{ who: { Entity: p.logistics_treasury }, sharing: String(logisticsRate), mode: "Rate" },
|
|
155
|
-
],
|
|
156
|
-
max: null,
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
161
|
-
payment_info: {},
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
notes: [
|
|
165
|
-
"F-A-05: sum(rates) MUST equal 10000 (pure Rate mode, no Surplus)",
|
|
166
|
-
"Treasury Permission should match Service Permission (R-A-3-02)",
|
|
167
|
-
"Guard should verify order.service binding (query 1563) to prevent cross-project bypass",
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: "T-A-03",
|
|
172
|
-
name: "Refund-first + Surplus-to-merchant (Amount + Surplus hybrid)",
|
|
173
|
-
description: "Single Allocator with 2 sharing items: Amount=refund_value to customer, Surplus to merchant",
|
|
174
|
-
applicable_scenes: ["allocation_refund_first_surplus_to_merchant"],
|
|
175
|
-
industry_tags: ["retail", "refund", "customer_protection"],
|
|
176
|
-
params: [
|
|
177
|
-
{
|
|
178
|
-
name: "allocation_name",
|
|
179
|
-
type: "string",
|
|
180
|
-
description: "Local name for the new Allocation object",
|
|
181
|
-
required: true,
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "coin_type",
|
|
185
|
-
type: "string",
|
|
186
|
-
description: "Coin<T> type string",
|
|
187
|
-
required: true,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: "customer_address",
|
|
191
|
-
type: "address",
|
|
192
|
-
description: "Customer address to receive refund Amount",
|
|
193
|
-
required: true,
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "merchant_treasury",
|
|
197
|
-
type: "address",
|
|
198
|
-
description: "Merchant Treasury address to receive Surplus",
|
|
199
|
-
required: true,
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
name: "refund_amount",
|
|
203
|
-
type: "number",
|
|
204
|
-
description: "Refund amount in smallest coin unit (e.g. MIST for WOW)",
|
|
205
|
-
required: true,
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: "guard_address",
|
|
209
|
-
type: "address",
|
|
210
|
-
description: "Guard object address (verifies refund approval)",
|
|
211
|
-
required: true,
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: "description",
|
|
215
|
-
type: "string",
|
|
216
|
-
description: "Allocation description",
|
|
217
|
-
required: false,
|
|
218
|
-
default: "Refund-first + Surplus-to-merchant",
|
|
219
|
-
},
|
|
220
|
-
],
|
|
221
|
-
body: (p) => {
|
|
222
|
-
const refundAmount = Number(p.refund_amount);
|
|
223
|
-
if (refundAmount <= 0) {
|
|
224
|
-
throw new Error(`T-A-03: refund_amount MUST be > 0, got ${refundAmount}`);
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
228
|
-
allocators: {
|
|
229
|
-
description: p.description ?? "Refund-first + Surplus-to-merchant",
|
|
230
|
-
threshold: String(refundAmount),
|
|
231
|
-
allocators: [
|
|
232
|
-
{
|
|
233
|
-
guard: p.guard_address,
|
|
234
|
-
sharing: [
|
|
235
|
-
{
|
|
236
|
-
who: { Entity: p.customer_address },
|
|
237
|
-
sharing: String(refundAmount),
|
|
238
|
-
mode: "Amount",
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
who: { Entity: p.merchant_treasury },
|
|
242
|
-
sharing: "0",
|
|
243
|
-
mode: "Surplus",
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
max: null,
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
251
|
-
payment_info: {},
|
|
252
|
-
};
|
|
253
|
-
},
|
|
254
|
-
notes: [
|
|
255
|
-
"F-A-04: at most 1 Surplus per Allocator (✓ single Surplus here)",
|
|
256
|
-
"F-A-07: threshold = refundAmount (ensure balance covers Amount)",
|
|
257
|
-
"fix is cached as refundAmount at allocator_add time",
|
|
258
|
-
"Guard must verify customer refund eligibility (e.g. order status = Refunded)",
|
|
259
|
-
],
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
id: "T-A-04",
|
|
263
|
-
name: "Treasury + Personal alternative (caller-specified guard, 2 Allocators)",
|
|
264
|
-
description: "2 Allocators as alternative strategies: caller selects Treasury or Personal wallet via alloc_by_guard (hard verification per call)",
|
|
265
|
-
applicable_scenes: ["allocation_treasury_personal_alternatives"],
|
|
266
|
-
industry_tags: ["universal", "alternative", "treasury"],
|
|
267
|
-
params: [
|
|
268
|
-
{
|
|
269
|
-
name: "allocation_name",
|
|
270
|
-
type: "string",
|
|
271
|
-
description: "Local name for the new Allocation object",
|
|
272
|
-
required: true,
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: "coin_type",
|
|
276
|
-
type: "string",
|
|
277
|
-
description: "Coin<T> type string",
|
|
278
|
-
required: true,
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: "treasury_address",
|
|
282
|
-
type: "address",
|
|
283
|
-
description: "Treasury address (primary recipient)",
|
|
284
|
-
required: true,
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
name: "personal_address",
|
|
288
|
-
type: "address",
|
|
289
|
-
description: "Personal wallet address (alternative recipient)",
|
|
290
|
-
required: true,
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
name: "treasury_guard",
|
|
294
|
-
type: "address",
|
|
295
|
-
description: "Guard for Treasury path (verifies treasury operational)",
|
|
296
|
-
required: true,
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: "personal_guard",
|
|
300
|
-
type: "address",
|
|
301
|
-
description: "Guard for Personal path (verifies personal wallet active) — MUST differ from treasury_guard",
|
|
302
|
-
required: true,
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
body: (p) => {
|
|
306
|
-
if (p.treasury_guard === p.personal_guard) {
|
|
307
|
-
throw new Error(`T-A-04: treasury_guard and personal_guard MUST be different addresses (F-A-14: allocators[].guard must be unique)`);
|
|
308
|
-
}
|
|
309
|
-
return {
|
|
310
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
311
|
-
allocators: {
|
|
312
|
-
description: "Treasury / Personal alternative (caller-specified guard)",
|
|
313
|
-
threshold: "0",
|
|
314
|
-
allocators: [
|
|
315
|
-
{
|
|
316
|
-
guard: p.treasury_guard,
|
|
317
|
-
sharing: [
|
|
318
|
-
{ who: { Entity: p.treasury_address }, sharing: "10000", mode: "Rate" },
|
|
319
|
-
],
|
|
320
|
-
max: null,
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
guard: p.personal_guard,
|
|
324
|
-
sharing: [
|
|
325
|
-
{ who: { Entity: p.personal_address }, sharing: "10000", mode: "Rate" },
|
|
326
|
-
],
|
|
327
|
-
max: null,
|
|
328
|
-
},
|
|
329
|
-
],
|
|
330
|
-
},
|
|
331
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
332
|
-
payment_info: {},
|
|
333
|
-
};
|
|
334
|
-
},
|
|
335
|
-
notes: [
|
|
336
|
-
"F-A-14: treasury_guard != personal_guard (Allocator Guards must be unique)",
|
|
337
|
-
"caller-specified guard: alloc_by_guard explicitly selects an Allocator; passport::result_for_guard hard-verifies (failure aborts E_VERIFY_FAILED)",
|
|
338
|
-
"No auto-fallback: on verification failure the caller must switch guard and retry",
|
|
339
|
-
"R-A-4-02: if the caller's submitted Passport satisfies both Guards simultaneously, the caller may freely choose between the two paths (mutual exclusion is a design clarity recommendation, not a correctness requirement)",
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
id: "T-A-05",
|
|
344
|
-
name: "Tiered by order amount (mutually exclusive Guard conditions)",
|
|
345
|
-
description: "2 Allocators triggered by mutually exclusive Guard conditions (small order vs large order)",
|
|
346
|
-
applicable_scenes: ["allocation_tiered_by_order_amount"],
|
|
347
|
-
industry_tags: ["retail", "tiered_pricing", "volume_discount"],
|
|
348
|
-
params: [
|
|
349
|
-
{
|
|
350
|
-
name: "allocation_name",
|
|
351
|
-
type: "string",
|
|
352
|
-
description: "Local name for the new Allocation object",
|
|
353
|
-
required: true,
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
name: "coin_type",
|
|
357
|
-
type: "string",
|
|
358
|
-
description: "Coin<T> type string",
|
|
359
|
-
required: true,
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
name: "merchant_treasury",
|
|
363
|
-
type: "address",
|
|
364
|
-
description: "Merchant Treasury address",
|
|
365
|
-
required: true,
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: "platform_treasury",
|
|
369
|
-
type: "address",
|
|
370
|
-
description: "Platform Treasury address",
|
|
371
|
-
required: true,
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: "small_order_guard",
|
|
375
|
-
type: "address",
|
|
376
|
-
description: "Guard verifying order.amount < threshold (small order path)",
|
|
377
|
-
required: true,
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: "large_order_guard",
|
|
381
|
-
type: "address",
|
|
382
|
-
description: "Guard verifying order.amount >= threshold (large order path) — MUST differ from small_order_guard",
|
|
383
|
-
required: true,
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
name: "small_order_merchant_rate",
|
|
387
|
-
type: "number",
|
|
388
|
-
description: "Merchant rate for small orders (e.g. 10000 = 100%)",
|
|
389
|
-
required: true,
|
|
390
|
-
default: 10000,
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
name: "large_order_merchant_rate",
|
|
394
|
-
type: "number",
|
|
395
|
-
description: "Merchant rate for large orders (e.g. 8000 = 80%)",
|
|
396
|
-
required: true,
|
|
397
|
-
default: 8000,
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
name: "large_order_platform_rate",
|
|
401
|
-
type: "number",
|
|
402
|
-
description: "Platform rate for large orders (e.g. 2000 = 20%)",
|
|
403
|
-
required: true,
|
|
404
|
-
default: 2000,
|
|
405
|
-
},
|
|
406
|
-
],
|
|
407
|
-
body: (p) => {
|
|
408
|
-
if (p.small_order_guard === p.large_order_guard) {
|
|
409
|
-
throw new Error(`T-A-05: small_order_guard and large_order_guard MUST be different addresses (F-A-14)`);
|
|
410
|
-
}
|
|
411
|
-
const smallRate = Number(p.small_order_merchant_rate);
|
|
412
|
-
if (smallRate !== 10000) {
|
|
413
|
-
throw new Error(`T-A-05: small_order_merchant_rate MUST equal 10000 (pure Rate, no Surplus in this Allocator), got ${smallRate}`);
|
|
414
|
-
}
|
|
415
|
-
const largeMerchantRate = Number(p.large_order_merchant_rate);
|
|
416
|
-
const largePlatformRate = Number(p.large_order_platform_rate);
|
|
417
|
-
const largeTotal = largeMerchantRate + largePlatformRate;
|
|
418
|
-
if (largeTotal !== 10000) {
|
|
419
|
-
throw new Error(`T-A-05: large_order rates MUST sum to 10000, got ${largeTotal} (merchant=${largeMerchantRate} + platform=${largePlatformRate})`);
|
|
420
|
-
}
|
|
421
|
-
return {
|
|
422
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
423
|
-
allocators: {
|
|
424
|
-
description: "Tiered by order amount: small=100% merchant, large=80/20 merchant/platform",
|
|
425
|
-
threshold: "0",
|
|
426
|
-
allocators: [
|
|
427
|
-
{
|
|
428
|
-
guard: p.small_order_guard,
|
|
429
|
-
sharing: [
|
|
430
|
-
{ who: { Entity: p.merchant_treasury }, sharing: "10000", mode: "Rate" },
|
|
431
|
-
],
|
|
432
|
-
max: null,
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
guard: p.large_order_guard,
|
|
436
|
-
sharing: [
|
|
437
|
-
{ who: { Entity: p.merchant_treasury }, sharing: String(largeMerchantRate), mode: "Rate" },
|
|
438
|
-
{ who: { Entity: p.platform_treasury }, sharing: String(largePlatformRate), mode: "Rate" },
|
|
439
|
-
],
|
|
440
|
-
max: null,
|
|
441
|
-
},
|
|
442
|
-
],
|
|
443
|
-
},
|
|
444
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
445
|
-
payment_info: {},
|
|
446
|
-
};
|
|
447
|
-
},
|
|
448
|
-
notes: [
|
|
449
|
-
"Guard conditions MUST be mutually exclusive (R-A-4-02)",
|
|
450
|
-
"Sequence-sensitive: strict condition (small order) first, relaxed condition (large order) last",
|
|
451
|
-
"Guard queries order.amount (query 1561) to determine which Allocator fires",
|
|
452
|
-
"If neither Guard passes, funds are silently locked (R-A-4-02)",
|
|
453
|
-
],
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
id: "T-A-06",
|
|
457
|
-
name: "Dynamic recipient via GuardIdentifier (referrer from Passport)",
|
|
458
|
-
description: "Single Allocator with 3 Rate sharing items, one recipient resolved from customer's Passport table[0]",
|
|
459
|
-
applicable_scenes: ["allocation_dynamic_recipient"],
|
|
460
|
-
industry_tags: ["referral", "affiliate", "marketing"],
|
|
461
|
-
params: [
|
|
462
|
-
{
|
|
463
|
-
name: "allocation_name",
|
|
464
|
-
type: "string",
|
|
465
|
-
description: "Local name for the new Allocation object",
|
|
466
|
-
required: true,
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: "coin_type",
|
|
470
|
-
type: "string",
|
|
471
|
-
description: "Coin<T> type string",
|
|
472
|
-
required: true,
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
name: "merchant_treasury",
|
|
476
|
-
type: "address",
|
|
477
|
-
description: "Merchant Treasury address",
|
|
478
|
-
required: true,
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
name: "platform_treasury",
|
|
482
|
-
type: "address",
|
|
483
|
-
description: "Platform Treasury address",
|
|
484
|
-
required: true,
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
name: "guard_address",
|
|
488
|
-
type: "address",
|
|
489
|
-
description: "Guard object address (must be configured with identifier=0 as address type)",
|
|
490
|
-
required: true,
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
name: "passport_identifier",
|
|
494
|
-
type: "number",
|
|
495
|
-
description: "Passport table identifier (u8, 0-255) — customer submits referrer address at this slot",
|
|
496
|
-
required: true,
|
|
497
|
-
default: 0,
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
name: "merchant_rate",
|
|
501
|
-
type: "number",
|
|
502
|
-
description: "Merchant rate in basis points (e.g. 8000 = 80%)",
|
|
503
|
-
required: true,
|
|
504
|
-
default: 8000,
|
|
505
|
-
},
|
|
506
|
-
{
|
|
507
|
-
name: "platform_rate",
|
|
508
|
-
type: "number",
|
|
509
|
-
description: "Platform rate in basis points (e.g. 1000 = 10%)",
|
|
510
|
-
required: true,
|
|
511
|
-
default: 1000,
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
name: "referrer_rate",
|
|
515
|
-
type: "number",
|
|
516
|
-
description: "Referrer rate in basis points (e.g. 1000 = 10%)",
|
|
517
|
-
required: true,
|
|
518
|
-
default: 1000,
|
|
519
|
-
},
|
|
520
|
-
],
|
|
521
|
-
body: (p) => {
|
|
522
|
-
const merchantRate = Number(p.merchant_rate);
|
|
523
|
-
const platformRate = Number(p.platform_rate);
|
|
524
|
-
const referrerRate = Number(p.referrer_rate);
|
|
525
|
-
const total = merchantRate + platformRate + referrerRate;
|
|
526
|
-
if (total !== 10000) {
|
|
527
|
-
throw new Error(`T-A-06: sum(rates) MUST equal 10000, got ${total} (merchant=${merchantRate} + platform=${platformRate} + referrer=${referrerRate})`);
|
|
528
|
-
}
|
|
529
|
-
const identifier = Number(p.passport_identifier);
|
|
530
|
-
if (identifier < 0 || identifier > 255) {
|
|
531
|
-
throw new Error(`T-A-06: passport_identifier MUST be u8 (0-255), got ${identifier}`);
|
|
532
|
-
}
|
|
533
|
-
return {
|
|
534
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
535
|
-
allocators: {
|
|
536
|
-
description: `Dynamic recipient: merchant ${merchantRate}/10000, platform ${platformRate}/10000, referrer ${referrerRate}/10000 (from Passport identifier=${identifier})`,
|
|
537
|
-
threshold: "0",
|
|
538
|
-
allocators: [
|
|
539
|
-
{
|
|
540
|
-
guard: p.guard_address,
|
|
541
|
-
sharing: [
|
|
542
|
-
{ who: { Entity: p.merchant_treasury }, sharing: String(merchantRate), mode: "Rate" },
|
|
543
|
-
{ who: { Entity: p.platform_treasury }, sharing: String(platformRate), mode: "Rate" },
|
|
544
|
-
{ who: { GuardIdentifier: identifier }, sharing: String(referrerRate), mode: "Rate" },
|
|
545
|
-
],
|
|
546
|
-
max: null,
|
|
547
|
-
},
|
|
548
|
-
],
|
|
549
|
-
},
|
|
550
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
551
|
-
payment_info: {},
|
|
552
|
-
};
|
|
553
|
-
},
|
|
554
|
-
notes: [
|
|
555
|
-
"F-A-13: Passport table[identifier] MUST be address type (else ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)",
|
|
556
|
-
"Guard.is_identifier_address(guard, identifier) MUST be true at allocator_add time (else allocator_add fails)",
|
|
557
|
-
"Customer must submit Passport with referrer address at the specified identifier slot",
|
|
558
|
-
"Guard should verify Passport completeness before alloc() executes",
|
|
559
|
-
],
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
id: "T-A-07",
|
|
563
|
-
name: "Refund to Order (100% to Order object, not personal wallet)",
|
|
564
|
-
description: "Single Allocator, 1 Rate=10000 sharing to Order object address. Refund funds return to Order for downstream handling.",
|
|
565
|
-
applicable_scenes: ["allocation_refund_to_order"],
|
|
566
|
-
industry_tags: ["refund", "customer_protection", "order_lifecycle"],
|
|
567
|
-
params: [
|
|
568
|
-
{
|
|
569
|
-
name: "allocation_name",
|
|
570
|
-
type: "string",
|
|
571
|
-
description: "Local name for the new Allocation object",
|
|
572
|
-
required: true,
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
name: "coin_type",
|
|
576
|
-
type: "string",
|
|
577
|
-
description: "Coin<T> type string",
|
|
578
|
-
required: true,
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
name: "order_address",
|
|
582
|
-
type: "address",
|
|
583
|
-
description: "Order object address (NOT personal wallet) — funds flow back to Order",
|
|
584
|
-
required: true,
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
name: "guard_address",
|
|
588
|
-
type: "address",
|
|
589
|
-
description: "Guard object address (verifies customer refund request and eligibility)",
|
|
590
|
-
required: true,
|
|
591
|
-
},
|
|
592
|
-
],
|
|
593
|
-
body: (p) => ({
|
|
594
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
595
|
-
allocators: {
|
|
596
|
-
description: "Refund to Order (100% to Order object for downstream handling)",
|
|
597
|
-
threshold: "0",
|
|
598
|
-
allocators: [
|
|
599
|
-
{
|
|
600
|
-
guard: p.guard_address,
|
|
601
|
-
sharing: [
|
|
602
|
-
{
|
|
603
|
-
who: { Entity: p.order_address },
|
|
604
|
-
sharing: "10000",
|
|
605
|
-
mode: "Rate",
|
|
606
|
-
},
|
|
607
|
-
],
|
|
608
|
-
max: null,
|
|
609
|
-
},
|
|
610
|
-
],
|
|
611
|
-
},
|
|
612
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
613
|
-
payment_info: {},
|
|
614
|
-
}),
|
|
615
|
-
notes: [
|
|
616
|
-
"⚠️ who=Entity MUST be Order object address (not personal address)",
|
|
617
|
-
"Customer due-diligence rewards this configuration (8-point weight in customer/risk-assessment.ts)",
|
|
618
|
-
"Refund funds return to Order for downstream handling (e.g. customer withdrawal)",
|
|
619
|
-
"Guard must verify customer refund eligibility (e.g. dispute resolved in customer's favor)",
|
|
620
|
-
],
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
id: "T-A-08",
|
|
624
|
-
name: "Arbitration fees split (arbitrator 80% / platform 20%)",
|
|
625
|
-
description: "Single Allocator, 2 Rate sharing items. Triggered by Arbitration.fees_alloc (permission 365) or fees_alloc_with_passport.",
|
|
626
|
-
applicable_scenes: ["allocation_arbitration_fees"],
|
|
627
|
-
industry_tags: ["arbitration", "dispute", "fees"],
|
|
628
|
-
params: [
|
|
629
|
-
{
|
|
630
|
-
name: "allocation_name",
|
|
631
|
-
type: "string",
|
|
632
|
-
description: "Local name for the new Allocation object",
|
|
633
|
-
required: true,
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
name: "coin_type",
|
|
637
|
-
type: "string",
|
|
638
|
-
description: "Coin<T> type string (must match Arbitration fee Coin type)",
|
|
639
|
-
required: true,
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
name: "arbitrator_treasury",
|
|
643
|
-
type: "address",
|
|
644
|
-
description: "Arbitrator Treasury address",
|
|
645
|
-
required: true,
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
name: "platform_treasury",
|
|
649
|
-
type: "address",
|
|
650
|
-
description: "Platform Treasury address",
|
|
651
|
-
required: true,
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
name: "arbitrator_rate",
|
|
655
|
-
type: "number",
|
|
656
|
-
description: "Arbitrator rate in basis points (e.g. 8000 = 80%)",
|
|
657
|
-
required: true,
|
|
658
|
-
default: 8000,
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
name: "platform_rate",
|
|
662
|
-
type: "number",
|
|
663
|
-
description: "Platform rate in basis points (e.g. 2000 = 20%)",
|
|
664
|
-
required: true,
|
|
665
|
-
default: 2000,
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
name: "guard_address",
|
|
669
|
-
type: "address",
|
|
670
|
-
description: "Guard object address (verifies Arbitration ruling finalized)",
|
|
671
|
-
required: true,
|
|
672
|
-
},
|
|
673
|
-
],
|
|
674
|
-
body: (p) => {
|
|
675
|
-
const arbRate = Number(p.arbitrator_rate);
|
|
676
|
-
const platRate = Number(p.platform_rate);
|
|
677
|
-
const total = arbRate + platRate;
|
|
678
|
-
if (total !== 10000) {
|
|
679
|
-
throw new Error(`T-A-08: sum(rates) MUST equal 10000, got ${total} (arbitrator=${arbRate} + platform=${platRate})`);
|
|
680
|
-
}
|
|
681
|
-
return {
|
|
682
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
683
|
-
allocators: {
|
|
684
|
-
description: `Arbitration fees split: arbitrator ${arbRate}/10000, platform ${platRate}/10000`,
|
|
685
|
-
threshold: "0",
|
|
686
|
-
allocators: [
|
|
687
|
-
{
|
|
688
|
-
guard: p.guard_address,
|
|
689
|
-
sharing: [
|
|
690
|
-
{ who: { Entity: p.arbitrator_treasury }, sharing: String(arbRate), mode: "Rate" },
|
|
691
|
-
{ who: { Entity: p.platform_treasury }, sharing: String(platRate), mode: "Rate" },
|
|
692
|
-
],
|
|
693
|
-
max: null,
|
|
694
|
-
},
|
|
695
|
-
],
|
|
696
|
-
},
|
|
697
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
698
|
-
payment_info: {},
|
|
699
|
-
};
|
|
700
|
-
},
|
|
701
|
-
notes: [
|
|
702
|
-
"Triggered by Arbitration.fees_alloc (permission ARBITRATION_FEES_ALLOC=365) or fees_alloc_with_passport",
|
|
703
|
-
"Independent from Service-order Allocation (this Allocation is not bound to Order)",
|
|
704
|
-
"payment_info typically reuses Arbitration's payment_info",
|
|
705
|
-
"Caller MUST hold ARBITRATION_FEES_ALLOC=365 permission",
|
|
706
|
-
],
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
id: "T-A-09",
|
|
710
|
-
name: "Standalone periodic split (investment dividends / shared income)",
|
|
711
|
-
description: "Standalone Allocation with single Allocator, N Rate sharing items to beneficiary wallets. No Service context. Guard provides time-based or signer-based access control.",
|
|
712
|
-
applicable_scenes: ["allocation_standalone_periodic_split"],
|
|
713
|
-
industry_tags: ["standalone", "investment", "dividends", "shared_income"],
|
|
714
|
-
params: [
|
|
715
|
-
{
|
|
716
|
-
name: "allocation_name",
|
|
717
|
-
type: "string",
|
|
718
|
-
description: "Local name for the new Allocation object",
|
|
719
|
-
required: true,
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
name: "coin_type",
|
|
723
|
-
type: "string",
|
|
724
|
-
description: "Coin<T> type string (e.g. '0x2::wow::WOW' or profit token type)",
|
|
725
|
-
required: true,
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
name: "beneficiaries",
|
|
729
|
-
type: "address[]",
|
|
730
|
-
description: "Array of beneficiary wallet addresses (NOT Treasury objects — standalone mode has no Service context)",
|
|
731
|
-
required: true,
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
name: "rates",
|
|
735
|
-
type: "string[]",
|
|
736
|
-
description: "Array of rates in basis points (e.g. ['5000','3000','2000'] = 50%/30%/20%). MUST sum to 10000.",
|
|
737
|
-
required: true,
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
name: "guard_address",
|
|
741
|
-
type: "address",
|
|
742
|
-
description: "Guard object address — MUST bind Signer or verify time-based trigger (R-A-3-04: standalone has no Service-layer access control)",
|
|
743
|
-
required: true,
|
|
744
|
-
},
|
|
745
|
-
{
|
|
746
|
-
name: "description",
|
|
747
|
-
type: "string",
|
|
748
|
-
description: "Allocation description",
|
|
749
|
-
required: false,
|
|
750
|
-
default: "Standalone periodic split",
|
|
751
|
-
},
|
|
752
|
-
],
|
|
753
|
-
body: (p) => {
|
|
754
|
-
const beneficiaries = p.beneficiaries;
|
|
755
|
-
const rates = p.rates.map(r => Number(r));
|
|
756
|
-
if (beneficiaries.length !== rates.length) {
|
|
757
|
-
throw new Error(`T-A-09: beneficiaries (${beneficiaries.length}) and rates (${rates.length}) MUST have equal length`);
|
|
758
|
-
}
|
|
759
|
-
if (beneficiaries.length === 0) {
|
|
760
|
-
throw new Error(`T-A-09: at least 1 beneficiary required`);
|
|
761
|
-
}
|
|
762
|
-
if (beneficiaries.length > 100) {
|
|
763
|
-
throw new Error(`T-A-09: beneficiaries count ${beneficiaries.length} exceeds MAX_SHARING_COUNT (100)`);
|
|
764
|
-
}
|
|
765
|
-
const total = rates.reduce((sum, r) => sum + r, 0);
|
|
766
|
-
if (total !== 10000) {
|
|
767
|
-
throw new Error(`T-A-09: sum(rates) MUST equal 10000 (RATE_TOTAL_FULL), got ${total}`);
|
|
768
|
-
}
|
|
769
|
-
return {
|
|
770
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
771
|
-
allocators: {
|
|
772
|
-
description: p.description ?? "Standalone periodic split",
|
|
773
|
-
threshold: "0",
|
|
774
|
-
allocators: [
|
|
775
|
-
{
|
|
776
|
-
guard: p.guard_address,
|
|
777
|
-
sharing: beneficiaries.map((addr, i) => ({
|
|
778
|
-
who: { Entity: addr },
|
|
779
|
-
sharing: String(rates[i]),
|
|
780
|
-
mode: "Rate",
|
|
781
|
-
})),
|
|
782
|
-
max: null,
|
|
783
|
-
},
|
|
784
|
-
],
|
|
785
|
-
},
|
|
786
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
787
|
-
payment_info: {},
|
|
788
|
-
};
|
|
789
|
-
},
|
|
790
|
-
notes: [
|
|
791
|
-
"Standalone mode (§0): no Service/Order/Arbitration context required",
|
|
792
|
-
"R-A-3-04: Guard MUST bind Signer or verify time-based trigger — no Service-layer access control exists",
|
|
793
|
-
"F-A-05: sum(rates) MUST equal 10000 (pure Rate mode, no Surplus)",
|
|
794
|
-
"Caller lifecycle: receive() to deposit funds → alloc() to trigger distribution",
|
|
795
|
-
"Guard should bind context(Signer)==authorized to prevent unauthorized alloc() calls",
|
|
796
|
-
"beneficiaries are personal wallets, NOT Treasury objects (no Service context)",
|
|
797
|
-
],
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
id: "T-A-10",
|
|
801
|
-
name: "Standalone vesting release (time-locked multi-stage unlock)",
|
|
802
|
-
description: "Standalone Allocation with N Allocators (default 3 stages), each triggered by a time-locked Guard. Stages 1..N-1 use Amount mode; final stage uses Surplus to drain remaining balance. No Service context.",
|
|
803
|
-
applicable_scenes: ["allocation_standalone_vesting"],
|
|
804
|
-
industry_tags: ["standalone", "vesting", "time_lock", "team_tokens"],
|
|
805
|
-
params: [
|
|
806
|
-
{
|
|
807
|
-
name: "allocation_name",
|
|
808
|
-
type: "string",
|
|
809
|
-
description: "Local name for the new Allocation object",
|
|
810
|
-
required: true,
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
name: "coin_type",
|
|
814
|
-
type: "string",
|
|
815
|
-
description: "Coin<T> type string (vested asset, e.g. locked team tokens)",
|
|
816
|
-
required: true,
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
name: "beneficiary_address",
|
|
820
|
-
type: "address",
|
|
821
|
-
description: "Single beneficiary wallet address (vesting recipient)",
|
|
822
|
-
required: true,
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
name: "stage_1_guard",
|
|
826
|
-
type: "address",
|
|
827
|
-
description: "Guard for stage 1 (verifies context(Clock).timestamp >= stage_1_unlock)",
|
|
828
|
-
required: true,
|
|
829
|
-
},
|
|
830
|
-
{
|
|
831
|
-
name: "stage_1_amount",
|
|
832
|
-
type: "number",
|
|
833
|
-
description: "Amount to release at stage 1 (smallest coin unit, e.g. MIST)",
|
|
834
|
-
required: true,
|
|
835
|
-
},
|
|
836
|
-
{
|
|
837
|
-
name: "stage_2_guard",
|
|
838
|
-
type: "address",
|
|
839
|
-
description: "Guard for stage 2 (verifies context(Clock).timestamp >= stage_2_unlock) — MUST differ from stage_1_guard",
|
|
840
|
-
required: true,
|
|
841
|
-
},
|
|
842
|
-
{
|
|
843
|
-
name: "stage_2_amount",
|
|
844
|
-
type: "number",
|
|
845
|
-
description: "Amount to release at stage 2 (smallest coin unit)",
|
|
846
|
-
required: true,
|
|
847
|
-
},
|
|
848
|
-
{
|
|
849
|
-
name: "stage_3_guard",
|
|
850
|
-
type: "address",
|
|
851
|
-
description: "Guard for stage 3 (final stage, uses Surplus to drain remaining balance) — MUST differ from stage_1_guard and stage_2_guard",
|
|
852
|
-
required: true,
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
name: "max_cap",
|
|
856
|
-
type: "number",
|
|
857
|
-
description: "Maximum cumulative release cap (applied to stages 1 and 2 via max field). Stage 3 uses Surplus so no max needed.",
|
|
858
|
-
required: false,
|
|
859
|
-
},
|
|
860
|
-
{
|
|
861
|
-
name: "description",
|
|
862
|
-
type: "string",
|
|
863
|
-
description: "Allocation description",
|
|
864
|
-
required: false,
|
|
865
|
-
default: "Standalone vesting release (3-stage time-locked)",
|
|
866
|
-
},
|
|
867
|
-
],
|
|
868
|
-
body: (p) => {
|
|
869
|
-
const guards = [p.stage_1_guard, p.stage_2_guard, p.stage_3_guard];
|
|
870
|
-
const unique = new Set(guards);
|
|
871
|
-
if (unique.size !== guards.length) {
|
|
872
|
-
const dupes = guards.filter((g, i) => guards.indexOf(g) !== i);
|
|
873
|
-
throw new Error(`T-A-10: stage guards MUST be unique (F-A-14), duplicates: ${dupes.join(", ")}`);
|
|
874
|
-
}
|
|
875
|
-
const stage1Amount = Number(p.stage_1_amount);
|
|
876
|
-
const stage2Amount = Number(p.stage_2_amount);
|
|
877
|
-
if (stage1Amount <= 0 || stage2Amount <= 0) {
|
|
878
|
-
throw new Error(`T-A-10: stage_1_amount and stage_2_amount MUST be > 0, got stage1=${stage1Amount}, stage2=${stage2Amount}`);
|
|
879
|
-
}
|
|
880
|
-
const totalFix = stage1Amount + stage2Amount;
|
|
881
|
-
const maxCap = p.max_cap != null ? Number(p.max_cap) : null;
|
|
882
|
-
if (maxCap !== null && totalFix > maxCap) {
|
|
883
|
-
throw new Error(`T-A-10: stage_1_amount + stage_2_amount (${totalFix}) MUST be <= max_cap (${maxCap}) — F-A-08 (EAMOUNT_EXCEEDS_MAX)`);
|
|
884
|
-
}
|
|
885
|
-
return {
|
|
886
|
-
object: { name: p.allocation_name, type_parameter: p.coin_type },
|
|
887
|
-
allocators: {
|
|
888
|
-
description: p.description ?? "Standalone vesting release (3-stage time-locked)",
|
|
889
|
-
threshold: "0",
|
|
890
|
-
allocators: [
|
|
891
|
-
{
|
|
892
|
-
guard: p.stage_1_guard,
|
|
893
|
-
sharing: [
|
|
894
|
-
{ who: { Entity: p.beneficiary_address }, sharing: String(stage1Amount), mode: "Amount" },
|
|
895
|
-
],
|
|
896
|
-
max: maxCap != null ? String(maxCap) : null,
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
guard: p.stage_2_guard,
|
|
900
|
-
sharing: [
|
|
901
|
-
{ who: { Entity: p.beneficiary_address }, sharing: String(stage2Amount), mode: "Amount" },
|
|
902
|
-
],
|
|
903
|
-
max: maxCap != null ? String(maxCap) : null,
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
guard: p.stage_3_guard,
|
|
907
|
-
sharing: [
|
|
908
|
-
{ who: { Entity: p.beneficiary_address }, sharing: "0", mode: "Surplus" },
|
|
909
|
-
],
|
|
910
|
-
max: null,
|
|
911
|
-
},
|
|
912
|
-
],
|
|
913
|
-
},
|
|
914
|
-
coin: { name: `${p.allocation_name}_coin` },
|
|
915
|
-
payment_info: {},
|
|
916
|
-
};
|
|
917
|
-
},
|
|
918
|
-
notes: [
|
|
919
|
-
"Standalone mode (§0): no Service/Order/Arbitration context required",
|
|
920
|
-
"R-A-3-04: Guard time-lock MUST be enforced — no Service-layer access control exists",
|
|
921
|
-
"F-A-14: stage_1_guard, stage_2_guard, stage_3_guard MUST be unique (duplicate guards are dead code)",
|
|
922
|
-
"F-A-04: at most 1 Surplus per Allocator (stage 3 uses Surplus to drain remainder)",
|
|
923
|
-
"F-A-08: stage_1_amount + stage_2_amount MUST be <= max_cap (if max_cap provided)",
|
|
924
|
-
"R-A-4-01: if caller calls alloc() before stage time-lock expires, alloc() silently returns — caller should check balance==0 after alloc()",
|
|
925
|
-
"R-A-4-02: Guard conditions SHOULD be mutually exclusive by timestamp (e.g. stage_1: ts<stage_2_unlock, stage_2: stage_2_unlock<=ts<stage_3_unlock, stage_3: ts>=stage_3_unlock)",
|
|
926
|
-
"Caller lifecycle: receive() to deposit locked tokens → alloc() at each vesting milestone",
|
|
927
|
-
],
|
|
928
|
-
},
|
|
929
|
-
];
|
|
930
|
-
export const ALLOCATION_TEMPLATES_VERSION = "1.0.0";
|
|
931
|
-
export function getAllTemplates() {
|
|
932
|
-
return [...ALLOCATION_TEMPLATES];
|
|
933
|
-
}
|
|
934
|
-
export function getTemplateById(id) {
|
|
935
|
-
return ALLOCATION_TEMPLATES.find(t => t.id === id);
|
|
936
|
-
}
|
|
937
|
-
export function getTemplatesByScene(sceneId) {
|
|
938
|
-
return ALLOCATION_TEMPLATES.filter(t => t.applicable_scenes.includes(sceneId));
|
|
939
|
-
}
|
|
940
|
-
export function getTemplatesByIndustry(industry) {
|
|
941
|
-
return ALLOCATION_TEMPLATES.filter(t => t.industry_tags.includes(industry) || t.industry_tags.includes("universal"));
|
|
942
|
-
}
|
|
943
|
-
export function suggestTemplateForScene(sceneId) {
|
|
944
|
-
const matches = getTemplatesByScene(sceneId);
|
|
945
|
-
return matches.length > 0 ? matches[0] : undefined;
|
|
946
|
-
}
|
|
947
|
-
export function listTemplates() {
|
|
948
|
-
return ALLOCATION_TEMPLATES.map(t => ({
|
|
949
|
-
id: t.id,
|
|
950
|
-
name: t.name,
|
|
951
|
-
description: t.description,
|
|
952
|
-
scenes: t.applicable_scenes,
|
|
953
|
-
}));
|
|
954
|
-
}
|
|
955
|
-
export function fillTemplate(templateId, params) {
|
|
956
|
-
const tpl = getTemplateById(templateId);
|
|
957
|
-
if (!tpl)
|
|
958
|
-
return { ok: false, error: `Template ${templateId} not found` };
|
|
959
|
-
for (const p of tpl.params) {
|
|
960
|
-
if (p.required && !(p.name in params)) {
|
|
961
|
-
return { ok: false, error: `Missing required param: ${p.name}` };
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
try {
|
|
965
|
-
return { ok: true, body: tpl.body(params) };
|
|
966
|
-
}
|
|
967
|
-
catch (e) {
|
|
968
|
-
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
969
|
-
}
|
|
970
|
-
}
|
|
1
|
+
export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services']},{'id':'T-A-02','name':'Standard\x203-way\x20Rate\x20split','description':'Three-way\x20split:\x20merchant\x20/\x20platform\x20/\x20logistics.\x20Pure\x20Rate\x20mode,\x20sum(rates)\x20MUST\x20equal\x2010000','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'logistics_treasury','type':'address','description':'Logistics\x20Treasury\x20address\x20(set\x20to\x20platform_treasury\x20if\x20N/A)','required':!![]},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'logistics_rate','type':'number','description':'Logistics\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['logistics_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20logistics='+d+')'));return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'3-way\x20split:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20logistics\x20'+d+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['logistics_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','fix\x20is\x20cached\x20as\x20refundAmount\x20at\x20allocator_add\x20time','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20passport::result_for_guard\x20hard-verifies\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order)','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20small\x20orders\x20(e.g.\x2010000\x20=\x20100%)','required':!![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20large\x20orders\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'large_order_platform_rate','type':'number','description':'Platform\x20rate\x20for\x20large\x20orders\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=Number(a['small_order_merchant_rate']);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=Number(a['large_order_merchant_rate']),d=Number(a['large_order_platform_rate']),e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20platform='+d+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount:\x20small=100%\x20merchant,\x20large=80/20\x20merchant/platform','threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20with\x203\x20Rate\x20sharing\x20items,\x20one\x20recipient\x20resolved\x20from\x20customer\x27s\x20Passport\x20table[0]','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20—\x20customer\x20submits\x20referrer\x20address\x20at\x20this\x20slot','required':!![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'referrer_rate','type':'number','description':'Referrer\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['referrer_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20referrer='+d+')');const f=Number(a['passport_identifier']);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','Guard.is_identifier_address(guard,\x20identifier)\x20MUST\x20be\x20true\x20at\x20allocator_add\x20time\x20(else\x20allocator_add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes']},{'id':'T-A-07','name':'Refund\x20to\x20Order\x20(100%\x20to\x20Order\x20object,\x20not\x20personal\x20wallet)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20to\x20Order\x20object\x20address.\x20Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'order_address','type':'address','description':'Order\x20object\x20address\x20(NOT\x20personal\x20wallet)\x20—\x20funds\x20flow\x20back\x20to\x20Order','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20customer\x20refund\x20request\x20and\x20eligibility)','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20Order\x20(100%\x20to\x20Order\x20object\x20for\x20downstream\x20handling)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['order_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['⚠️\x20who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight\x20in\x20customer/risk-assessment.ts)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling\x20(e.g.\x20customer\x20withdrawal)','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20dispute\x20resolved\x20in\x20customer\x27s\x20favor)']},{'id':'T-A-08','name':'Arbitration\x20fees\x20split\x20(arbitrator\x2080%\x20/\x20platform\x2020%)','description':'Single\x20Allocator,\x202\x20Rate\x20sharing\x20items.\x20Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport.','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=Number(a['arbitrator_rate']),c=Number(a['platform_rate']),d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20platform='+c+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20split:\x20arbitrator\x20'+b+'/10000,\x20platform\x20'+c+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20ARBITRATION_FEES_ALLOC=365)\x20or\x20fees_alloc_with_passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone']}];export const ALLOCATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
|