@wowok/agent-mcp 3.1.7 → 3.2.0
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/exposure.d.ts +10 -10
- package/dist/config/judgment.d.ts +25 -25
- package/dist/config/rule-engine.d.ts +25 -25
- package/dist/customer/user-preferences.d.ts +2 -2
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/capability.d.ts +1 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-operation.js +1 -1
- package/dist/extensions/industry-pack.d.ts +3 -2
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +1 -0
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/field-manifest.js +1 -1
- package/dist/graph/onchain/project-relationship.js +1 -1
- package/dist/graph/onchain/types.d.ts +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/keeper/KeeperScan.d.ts +2 -1
- package/dist/keeper/KeeperScan.js +1 -1
- package/dist/keeper/detectors.d.ts +9 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/keeper.spec.js +1 -1
- package/dist/keeper/types.d.ts +1 -1
- package/dist/keeper/types.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +4 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.d.ts +2 -0
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-risk.d.ts +3 -1
- package/dist/knowledge/arb-risk.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/arbitration-templates.d.ts +1 -0
- package/dist/knowledge/arbitration-templates.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +13 -2
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/allocation.json +50 -1
- package/dist/knowledge/baselines/rules/arb.json +20 -1
- package/dist/knowledge/baselines/rules/arbitration.json +27 -0
- package/dist/knowledge/baselines/rules/guard.json +75 -2
- package/dist/knowledge/baselines/rules/machine.json +38 -13
- package/dist/knowledge/baselines/rules/order.json +2 -2
- package/dist/knowledge/builtin-templates.d.ts +3 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-anchor-reach.d.ts +19 -0
- package/dist/knowledge/guard-anchor-reach.js +1 -0
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-render.d.ts +6 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +6 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.d.ts +4 -4
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.d.ts +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/order-templates.js +1 -1
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/release-sentinel.d.ts +12 -0
- package/dist/knowledge/release-sentinel.js +1 -0
- package/dist/knowledge/repository-write-semantics.d.ts +27 -0
- package/dist/knowledge/repository-write-semantics.js +1 -0
- package/dist/knowledge/rule-node-analyzers.d.ts +6 -0
- package/dist/knowledge/rule-node-analyzers.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +5 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +10 -1
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/service-allocation-semantics.d.ts +36 -0
- package/dist/knowledge/service-allocation-semantics.js +1 -0
- package/dist/knowledge/strategy-manuals.d.ts +3 -5
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +28 -12
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +26 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/allocation-advice.d.ts +38 -0
- package/dist/participation/allocation-advice.js +1 -0
- package/dist/participation/radar-core.d.ts +2 -0
- package/dist/persona/types.d.ts +3 -2
- package/dist/persona/types.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +70 -63
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +5 -0
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-quote.d.ts +2 -0
- package/dist/playbooks/service-build/service-quote.js +1 -0
- package/dist/relationship/derivation.d.ts +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +30 -8
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +6 -3
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/guard.d.ts +8 -8
- package/dist/schema/call/machine.d.ts +56 -0
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/payment.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +84 -22
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/common/tokentype-short-probe.spec.js +1 -0
- package/dist/schema/evaluation/index.d.ts +8 -80
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +9 -42
- package/dist/schema/goal/planning.d.ts +25 -60
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +2 -20
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/keeper/index.d.ts +3 -0
- package/dist/schema/keeper/index.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +74 -14
- package/dist/schema/persona/index.d.ts +279 -384
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +149 -10
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +35 -16
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +4 -4
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/watch/index.d.ts +2 -2
- package/dist/schema-query-impl/index.d.ts +1 -0
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +2 -2
- package/dist/schemas/benchmark_migration_operation.output.json +116 -2
- package/dist/schemas/benchmark_migration_operation.schema.json +2 -10
- package/dist/schemas/bridge_operation.output.json +2 -2
- package/dist/schemas/evaluation_operation.schema.json +7 -70
- package/dist/schemas/goal_operation.schema.json +6 -39
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -20
- package/dist/schemas/keeper_operation.output.json +2 -2
- package/dist/schemas/keeper_operation.schema.json +9 -4
- package/dist/schemas/local_history_operation.output.json +2 -2
- package/dist/schemas/local_info_operation.output.json +2 -2
- package/dist/schemas/local_mark_operation.output.json +2 -2
- package/dist/schemas/messenger_operation.output.json +2 -2
- package/dist/schemas/monitor_events.output.json +2 -2
- package/dist/schemas/monitor_subscription.output.json +2 -2
- package/dist/schemas/onchain_events.output.json +2 -2
- package/dist/schemas/onchain_operations.output.json +6 -6
- package/dist/schemas/onchain_operations.schema.json +227 -54
- package/dist/schemas/onchain_operations_allocation.schema.json +11 -10
- package/dist/schemas/onchain_operations_arbitration.schema.json +13 -13
- package/dist/schemas/onchain_operations_machine.schema.json +27 -5
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_payment.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +171 -21
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +57 -4
- package/dist/schemas/persona_operation.output.json +11 -88
- package/dist/schemas/persona_operation.schema.json +4 -32
- package/dist/schemas/query_toolkit.output.json +320 -22
- package/dist/schemas/query_toolkit.schema.json +53 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.spec.js +1 -1
- package/dist/tools/handlers/keeper.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
- package/dist/knowledge/alloc-audit-policy.spec.js +0 -1
- package/dist/knowledge/event-semantics.spec.d.ts +0 -1
- package/dist/knowledge/event-semantics.spec.js +0 -1
- package/dist/knowledge/facts-sync.spec.d.ts +0 -1
- package/dist/knowledge/facts-sync.spec.js +0 -1
- package/dist/knowledge/guard-design-patterns.spec.d.ts +0 -1
- package/dist/knowledge/guard-design-patterns.spec.js +0 -1
- package/dist/knowledge/guard-eval.spec.d.ts +0 -1
- package/dist/knowledge/guard-eval.spec.js +0 -1
- package/dist/knowledge/rule-node-analyzers.spec.d.ts +0 -1
- package/dist/knowledge/rule-node-analyzers.spec.js +0 -1
- package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +0 -1
- package/dist/knowledge/safety-rules.extract-amount.spec.js +0 -1
- package/dist/knowledge/template-loader.spec.d.ts +0 -1
- package/dist/knowledge/template-loader.spec.js +0 -1
- package/dist/knowledge/template-scanner.spec.d.ts +0 -1
- package/dist/knowledge/template-scanner.spec.js +0 -1
- /package/dist/{knowledge/alloc-audit-policy.spec.d.ts → schema/common/tokentype-short-probe.spec.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const m of f['sharing']){!['Amount','Rate','Surplus']['includes'](m['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+m['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](n=>n['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](n=>n['mode']==='Rate')['reduce']((n,o)=>n+Number(o['sharing']),0x0),i=g>0x0;!i&&h>0x0&&h!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+h+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'});i&&h>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+h+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});const j=f['sharing']['filter'](n=>n['mode']==='Amount')['reduce']((n,o)=>n+Number(o['sharing']),0x0),k=Number(c['threshold']);j>0x0&&j<k&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+j+'\x20<\x20threshold\x20'+k,'current_value':j,'limit':k,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&j>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+j+'\x20>\x20max\x20'+Number(f['max']),'current_value':j,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const l=f['sharing']['find'](n=>typeof n['who']==='object'&&'GuardIdentifier'in n['who']);if(l){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|
|
1
|
+
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![],'F_A_16_rate_gross_sum_le_10000':!![],'F_A_17_no_mixed_rate_bases':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const r of f['sharing']){!['Amount','Rate','Surplus','RateGross']['includes'](r['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+r['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](t=>t['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](t=>t['mode']==='Amount')['reduce']((t,u)=>t+Number(u['sharing']),0x0),i=f['sharing']['some'](t=>t['mode']==='RateGross'),j=f['sharing']['some'](t=>t['mode']==='Rate'),k=i&&h===0x0&&j,l=f['sharing']['filter'](t=>t['mode']==='Rate'||k&&t['mode']==='RateGross')['reduce']((t,u)=>t+Number(u['sharing']),0x0),n=g>0x0;!(j&&i&&h>0x0)&&(!n&&l>0x0&&l!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+l+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':l,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'}),n&&l>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+l+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':l,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'}));const o=Number(c['threshold']);h>0x0&&h<o&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+h+'\x20<\x20threshold\x20'+o,'current_value':h,'limit':o,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&h>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+h+'\x20>\x20max\x20'+Number(f['max']),'current_value':h,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const p=f['sharing']['filter'](t=>t['mode']==='RateGross')['reduce']((t,u)=>t+Number(u['sharing']),0x0);if(i&&!j){if(p>RATE_TOTAL_FULL)b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+p+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':p,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});else{if(f['max']!=null){const t=Number(f['max']);h*RATE_TOTAL_FULL+p*t>t*RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20plan\x20overdraws\x20max:\x20fix\x20'+h+'×10000\x20+\x20rateSum\x20'+p+'×'+t+'\x20>\x20'+t+'×10000','related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}else h>0x0&&p>=RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+p+'\x20with\x20fixed\x20total\x20'+h+'\x20and\x20no\x20max\x20must\x20be\x20<\x20'+RATE_TOTAL_FULL,'current_value':p,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}}j&&i&&h>0x0&&b['push']({'constraint_id':'F-A-17','severity':'high','message':'Allocator\x20'+f['guard']+'\x20mixes\x20NET\x20Rate\x20and\x20RateGross\x20with\x20a\x20fixed\x20Amount\x20total\x20('+h+')\x20—\x20abort\x20EMIXED_RATE_BASES','related_move_error':'EMIXED_RATE_BASES\x20(17)'});const q=f['sharing']['find'](u=>typeof u['who']==='object'&&'GuardIdentifier'in u['who']);if(q){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'NET\x20Rate:\x20total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix;\x20RateGross:\x20total_rates\x20=\x20max\x20(if\x20max)\x20else\x20balance\x20(fix\x20NOT\x20removed)'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/RateGross/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|
|
@@ -40,7 +40,7 @@ export interface AllocationRiskCheckContext {
|
|
|
40
40
|
Signer: "signer";
|
|
41
41
|
};
|
|
42
42
|
sharing: string | number;
|
|
43
|
-
mode: "Amount" | "Rate" | "Surplus";
|
|
43
|
+
mode: "Amount" | "Rate" | "Surplus" | "RateGross";
|
|
44
44
|
}[];
|
|
45
45
|
fix?: string | number;
|
|
46
46
|
max?: string | number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft}from'./recipient-constraint.js';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,evaluateCondition}from'../config/rule-engine.js';const AUTO_FIXABLE=new Set(['R-A-1-02#0','R-A-1-02#1','R-A-1-03#0','R-A-1-03#2','R-A-2-03#0','R-A-5-03#0']),RELATED_MOVE_ERROR={'R-A-1-01#0':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','R-A-1-01#1':'ENO_ALLOCATOR\x20(3)','R-A-1-02#0':'ERATE_NOT_10000\x20(4)','R-A-1-02#1':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-03#0':'EMULTIPLE_SURPLUS\x20(5)','R-A-1-03#1':'EAMOUNT_BELOW_THRESHOLD\x20(12)','R-A-1-03#2':'EAMOUNT_EXCEEDS_MAX\x20(13)','R-A-2-02#0':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','R-A-2-04#0':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','R-A-2-04#1':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','R-A-5-01#0':'E_ALLOCATION_ALREADY_SPECIFIED','R-A-5-02#0':'ENO_PAYMENT_INFO\x20(9)'},RELATED_GUARD_RISK={'R-A-2-01#0':'R-C3-06','R-A-3-04#0':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','R-A-4-01#0':'R-X1-05','R-A-4-03#0':'reentrancy\x20low'};export function allocationRiskFacts(b){const c=b['allocators_config'],d=!!c,e=d?c['allocators']:[];let f,g;if(d&&e['length']>0x0)for(let P=0x0;P<e['length'];P++){if(e[P]['sharing']['length']===0x0){f=P,g=e[P]['guard'];break;}}let h,j,k,l=![],m=![];if(d)for(let Q=0x0;Q<e['length'];Q++){const R=e[Q],S=R['sharing']['filter'](U=>U['mode']==='Rate')['reduce']((U,V)=>U+Number(V['sharing']),0x0),T=R['sharing']['some'](U=>U['mode']==='Surplus');if(!T&&S>0x0&&S!==RATE_TOTAL_FULL){h=Q,j=R['guard'],k=S,l=!![];break;}if(T&&S>RATE_TOTAL_FULL){h=Q,j=R['guard'],k=S,m=!![];break;}}let n,o,p,q,r,t,u;if(d){const U=Number(c['threshold']);for(let V=0x0;V<e['length'];V++){const W=e[V],X=W['sharing']['filter'](Z=>Z['mode']==='Surplus')['length'];if(X>0x1){n='multiple_surplus',o=V,p=W['guard'],q=X;break;}const Y=W['sharing']['filter'](Z=>Z['mode']==='Amount')['reduce']((Z,a0)=>Z+Number(a0['sharing']),0x0);if(Y>0x0&&Y<U){n='below_threshold',o=V,p=W['guard'],r=Y,t=U;break;}if(W['max']!=null&&Y>Number(W['max'])){n='exceeds_max',o=V,p=W['guard'],r=Y,u=Number(W['max']);break;}}}let v=![],w,x,y;if(d)for(let Z=0x0;Z<e['length'];Z++){const a0=e[Z],a1=a0['sharing']['some'](a3=>'Signer'in a3['who']),a2=b['guard_signer_bindings']?.[a0['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':a1,'caller_identity_constrained':a2})){v=!![],w=Z,x=a0['guard'],y=a2;break;}}let z,A,B;if(d&&b['passport_identifier_types'])for(let a3=0x0;a3<e['length'];a3++){const a4=e[a3],a5=a4['sharing']['find'](a8=>'GuardIdentifier'in a8['who']);if(!a5)continue;const a6=a5['who']['GuardIdentifier'],a7=b['passport_identifier_types'][a6];if(a7!==undefined&&a7!=='address'){z=a6,A=a7,B=a3;break;}}let C=![],D,E,F,G;if(d){const a8=e['map'](aa=>aa['guard']),a9=new Set(a8);if(a9['size']!==a8['length']){const aa=a8['filter']((ab,ad)=>a8['indexOf'](ab)!==ad);C=!![],D=a8['length'],E=a9['size'],F=aa['join'](',\x20'),G=aa['join'](',');}}const H=b['payment_info_for_object']!==undefined,I=d&&e['some'](ab=>ab['sharing']['some'](ad=>'GuardIdentifier'in ad['who'])),J=!!b['payment_info_for_object'];let K=![],L,M;if(d&&b['referenced_treasuries_permissions']&&b['host_service_permission'])for(const ab of e){for(const ad of ab['sharing']){if(!(ad['who']!==null&&typeof ad['who']==='object'&&'Entity'in ad['who']))continue;const ae=ad['who']['Entity'],af=b['referenced_treasuries_permissions'][ae];if(af&&af!==b['host_service_permission']){K=!![],L=ae,M=af;break;}}if(K)break;}let N;if(b['trigger_source']==='standalone'&&d){const ag=[];for(const ah of e){const ai=b['guard_signer_bindings']?.[ah['guard']]===!![],aj=b['guard_has_time_lock']?.[ah['guard']]===!![];if(!ai&&!aj)ag['push'](ah['guard']);}N=ag;}let O;if(d)for(let ak=0x0;ak<e['length'];ak++){const al=e[ak],am=al['sharing']['length']>0x0&&al['sharing']['every'](an=>an['mode']==='Amount');if(am){O=ak;break;}}return{'allocators_config_present':d,'allocators_count':d?e['length']:undefined,'allocators_empty':d&&e['length']===0x0,'empty_sharing_allocator_index':f,'empty_sharing_allocator_guard':g,'rate_rule_index':h,'rate_rule_guard':j,'rate_rule_sum':k,'rate_rule_pure':l,'rate_rule_exceed':m,'rate_total_full':RATE_TOTAL_FULL,'amount_rule_branch':n,'amount_rule_index':o,'amount_rule_guard':p,'amount_rule_surplus_count':q,'amount_rule_amount_sum':r,'amount_rule_threshold':t,'amount_rule_max':u,'signer_theft_detected':v,'signer_theft_index':w,'signer_theft_guard':x,'signer_theft_guard_bound':y,'guard_id_bad_identifier':z,'guard_id_bad_type':A,'guard_id_bad_index':B,'duplicate_guards_present':C,'allocators_total':D,'allocators_unique':E,'duplicate_guards_csv_sp':F,'duplicate_guards_csv':G,'for_object_anchor_known':H,'guard_identifier_recipient_present':I,'for_object_anchor_set':J,'for_object_anchor':H&&J?b['payment_info_for_object']??undefined:undefined,'host_service_published':b['host_service_published'],'treasury_perm_mismatch':K,'treasury_perm_entity':L,'treasury_perm_treasury':M,'host_service_permission':b['host_service_permission'],'allocation_create_op':b['operation_type']==='create','allocation_standalone':b['trigger_source']==='standalone','trigger_source_display':b['trigger_source']??'unknown','standalone_weak_guards_count':N?.['length'],'standalone_weak_guards_csv_sp':N?.['join'](',\x20'),'standalone_weak_guards_csv':N?.['join'](','),'has_fallback_allocator':b['has_fallback_allocator'],'guard_conditions_mutually_exclusive':b['guard_conditions_mutually_exclusive'],'has_fallback_allocator_display':String(b['has_fallback_allocator']??![]),'mutually_exclusive_display':String(b['guard_conditions_mutually_exclusive']??![]),'pure_amount_index':O,'order_already_has_allocation':b['order_already_has_allocation'],'bound_order_display':b['bound_order']??'unknown','bound_order_paren_display':b['bound_order']??'(unknown)','has_payment_info':b['has_payment_info'],'operation_type':b['operation_type'],'max_allocator_count':MAX_ALLOCATOR_COUNT};}function allocationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['allocation'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27allocation\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function firedCaseKey(a,b,c){const d=a['find'](e=>e['rule_id']===c);if(d)for(let e=0x0;e<d['cases']['length'];e++){if(evaluateCondition(d['cases'][e]['when'],b))return c+'#'+e;}return c+'#0';}function findingToAllocationRisk(a,b){const c=RELATED_MOVE_ERROR[b],d=RELATED_GUARD_RISK[b];return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...c!==undefined?{'related_move_error':c}:{},...d!==undefined?{'related_guard_risk':d}:{},'auto_fixable':AUTO_FIXABLE['has'](b),...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){const a=factoryRulePack('allocation');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const d=allocationRiskFacts(c),{findings:e}=evaluateRuleBook([b],d);return e['length']>0x0?findingToAllocationRisk(e[0x0],firedCaseKey([b],d,b['rule_id'])):null;}}));}export function assessAllocationRisks(a){const b=allocationRuleBook(),c=allocationRiskFacts(a),{findings:d}=evaluateRuleBook(b,c),e=d['map'](j=>findingToAllocationRisk(j,firedCaseKey(b,c,j['rule_id']))),f=e['length']===0x0?'low':e['some'](j=>j['level']==='critical')?'critical':e['some'](j=>j['level']==='high')?'high':e['some'](j=>j['level']==='medium')?'medium':'low',g={},h={};for(const j of e){g[j['category']]=(g[j['category']]??0x0)+0x1,h[j['level']]=(h[j['level']]??0x0)+0x1;}const i={};for(const k of e){for(const l of k['affected_stakeholders']){if(!i[l])i[l]=[];i[l]['push'](k['id']+':\x20'+k['mitigation']);}}return{'summary':'Assessed\x20'+e['length']+'\x20risk(s)\x20across\x20'+Object['keys'](g)['length']+'\x20categories','risks':e,'overall_risk':f,'risks_by_category':g,'risks_by_level':h,'stakeholder_advice':i,'needs_human_review':e['some'](m=>m['level']==='critical'||m['level']==='high'),'blocks_publish':e['some'](m=>m['level']==='critical')};}export{ALLOCATION_ERROR_CODES};
|
|
1
|
+
import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft}from'./recipient-constraint.js';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,evaluateCondition}from'../config/rule-engine.js';const AUTO_FIXABLE=new Set(['R-A-1-02#0','R-A-1-02#1','R-A-1-02#2','R-A-1-02#3','R-A-1-02#4','R-A-1-03#0','R-A-1-03#2','R-A-2-03#0','R-A-5-03#0']),RELATED_MOVE_ERROR={'R-A-1-01#0':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','R-A-1-01#1':'ENO_ALLOCATOR\x20(3)','R-A-1-02#0':'ERATE_NOT_10000\x20(4)','R-A-1-02#1':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#2':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#3':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#4':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#5':'EMIXED_RATE_BASES\x20(17)','R-A-1-03#0':'EMULTIPLE_SURPLUS\x20(5)','R-A-1-03#1':'EAMOUNT_BELOW_THRESHOLD\x20(12)','R-A-1-03#2':'EAMOUNT_EXCEEDS_MAX\x20(13)','R-A-2-02#0':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','R-A-2-04#0':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','R-A-2-04#1':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','R-A-5-01#0':'E_ALLOCATION_ALREADY_SPECIFIED','R-A-5-02#0':'ENO_PAYMENT_INFO\x20(9)'},RELATED_GUARD_RISK={'R-A-2-01#0':'R-C3-06','R-A-3-04#0':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','R-A-4-01#0':'R-X1-05','R-A-4-03#0':'reentrancy\x20low'};export function allocationRiskFacts(b){const c=b['allocators_config'],d=!!c,e=d?c['allocators']:[];let f,g;if(d&&e['length']>0x0)for(let Z=0x0;Z<e['length'];Z++){if(e[Z]['sharing']['length']===0x0){f=Z,g=e[Z]['guard'];break;}}let h,j,k,l=![],n=![];if(d)for(let a0=0x0;a0<e['length'];a0++){const a1=e[a0],a2=a1['sharing']['some'](a9=>a9['mode']==='RateGross'),a3=a1['sharing']['filter'](a9=>a9['mode']==='Amount')['reduce']((a9,aa)=>a9+Number(aa['sharing']),0x0);if(a2&&a3>0x0)continue;const a4=a2&&a3===0x0&&a1['sharing']['some'](a9=>a9['mode']==='Rate'),a5=a1['sharing']['filter'](a9=>a9['mode']==='Rate'||a4&&a9['mode']==='RateGross');if(a5['length']===0x0)continue;const a6=a5['map'](a9=>Number(a9['sharing']));if(a6['some'](a9=>!Number['isFinite'](a9)))continue;const a7=a6['reduce']((a9,aa)=>a9+aa,0x0),a8=a1['sharing']['some'](a9=>a9['mode']==='Surplus');if(!a8&&a7!==RATE_TOTAL_FULL){h=a0,j=a1['guard'],k=a7,l=!![];break;}if(a8&&a7>RATE_TOTAL_FULL){h=a0,j=a1['guard'],k=a7,n=!![];break;}}let o,p,q,r,t,u,v=![],w,x;if(d)for(let a9=0x0;a9<e['length'];a9++){const aa=e[a9],ab=aa['sharing']['some'](ah=>ah['mode']==='Rate'),ad=aa['sharing']['filter'](ah=>ah['mode']==='RateGross');if(ad['length']===0x0)continue;const ae=aa['sharing']['filter'](ah=>ah['mode']==='Amount')['reduce']((ah,ai)=>ah+Number(ai['sharing']),0x0);if(ab){if(ae>0x0){v=!![],w=a9,x=aa['guard'];break;}continue;}const af=ad['map'](ah=>Number(ah['sharing']));if(af['some'](ah=>!Number['isFinite'](ah))||!Number['isFinite'](ae))continue;const ag=af['reduce']((ah,ai)=>ah+ai,0x0);if(ag>RATE_TOTAL_FULL){o='sum_exceeds_10000',p=a9,q=aa['guard'],r=ag,t=ae;break;}if(aa['max']!=null){const ah=Number(aa['max']);if(Number['isFinite'](ah)&&ae*RATE_TOTAL_FULL+ag*ah>ah*RATE_TOTAL_FULL){o='cap_fit',p=a9,q=aa['guard'],r=ag,t=ae,u=ah;break;}}else{if(ae>0x0&&ag>=RATE_TOTAL_FULL){o='fixed_full',p=a9,q=aa['guard'],r=ag,t=ae;break;}}}let y,z,A,B,C,D,E;if(d){const ai=Number(c['threshold']);for(let aj=0x0;aj<e['length'];aj++){const ak=e[aj],al=ak['sharing']['filter'](ao=>ao['mode']==='Surplus')['length'];if(al>0x1){y='multiple_surplus',z=aj,A=ak['guard'],B=al;break;}const am=ak['sharing']['filter'](ao=>ao['mode']==='Amount')['reduce']((ao,ap)=>ao+Number(ap['sharing']),0x0),an=ak['sharing']['some'](ao=>ao['mode']==='Rate'||ao['mode']==='Surplus');if(!an&&am>0x0&&am<ai){y='below_threshold',z=aj,A=ak['guard'],C=am,D=ai;break;}if(ak['max']!=null&&am>Number(ak['max'])){y='exceeds_max',z=aj,A=ak['guard'],C=am,E=Number(ak['max']);break;}}}let F=![],G,H,I;if(d)for(let ao=0x0;ao<e['length'];ao++){const ap=e[ao],aq=ap['sharing']['some'](as=>'Signer'in as['who']),ar=b['guard_signer_bindings']?.[ap['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':aq,'caller_identity_constrained':ar})){F=!![],G=ao,H=ap['guard'],I=ar;break;}}let J,K,L;if(d&&b['passport_identifier_types'])for(let as=0x0;as<e['length'];as++){const at=e[as],au=at['sharing']['find'](ax=>'GuardIdentifier'in ax['who']);if(!au)continue;const av=au['who']['GuardIdentifier'],aw=b['passport_identifier_types'][av];if(aw!==undefined&&aw!=='address'){J=av,K=aw,L=as;break;}}let M=![],N,O,P,Q;if(d){const ax=e['map'](az=>az['guard']),ay=new Set(ax);if(ay['size']!==ax['length']){const az=ax['filter']((aA,aB)=>ax['indexOf'](aA)!==aB);M=!![],N=ax['length'],O=ay['size'],P=az['join'](',\x20'),Q=az['join'](',');}}const R=b['payment_info_for_object']!==undefined,S=d&&e['some'](aA=>aA['sharing']['some'](aB=>'GuardIdentifier'in aB['who'])),T=!!b['payment_info_for_object'];let U=![],V,W;if(d&&b['referenced_treasuries_permissions']&&b['host_service_permission'])for(const aA of e){for(const aB of aA['sharing']){if(!(aB['who']!==null&&typeof aB['who']==='object'&&'Entity'in aB['who']))continue;const aC=aB['who']['Entity'],aD=b['referenced_treasuries_permissions'][aC];if(aD&&aD!==b['host_service_permission']){U=!![],V=aC,W=aD;break;}}if(U)break;}let X;if(b['trigger_source']==='standalone'&&d){const aE=[];for(const aF of e){const aG=b['guard_signer_bindings']?.[aF['guard']]===!![],aH=b['guard_has_time_lock']?.[aF['guard']]===!![];if(!aG&&!aH)aE['push'](aF['guard']);}X=aE;}let Y;if(d)for(let aI=0x0;aI<e['length'];aI++){const aJ=e[aI],aK=aJ['sharing']['length']>0x0&&aJ['sharing']['every'](aL=>aL['mode']==='Amount');if(aK){Y=aI;break;}}return{'allocators_config_present':d,'allocators_count':d?e['length']:undefined,'allocators_empty':d&&e['length']===0x0,'empty_sharing_allocator_index':f,'empty_sharing_allocator_guard':g,'rate_rule_index':h,'rate_rule_guard':j,'rate_rule_sum':k,'rate_rule_pure':l,'rate_rule_exceed':n,'rate_total_full':RATE_TOTAL_FULL,'rate_gross_branch':o,'rate_gross_index':p,'rate_gross_guard':q,'rate_gross_sum':r,'rate_gross_fix':t,'rate_gross_max':u,'mixed_rate_bases_present':v,'mixed_rate_bases_index':w,'mixed_rate_bases_guard':x,'amount_rule_branch':y,'amount_rule_index':z,'amount_rule_guard':A,'amount_rule_surplus_count':B,'amount_rule_amount_sum':C,'amount_rule_threshold':D,'amount_rule_max':E,'signer_theft_detected':F,'signer_theft_index':G,'signer_theft_guard':H,'signer_theft_guard_bound':I,'guard_id_bad_identifier':J,'guard_id_bad_type':K,'guard_id_bad_index':L,'duplicate_guards_present':M,'allocators_total':N,'allocators_unique':O,'duplicate_guards_csv_sp':P,'duplicate_guards_csv':Q,'for_object_anchor_known':R,'guard_identifier_recipient_present':S,'for_object_anchor_set':T,'for_object_anchor':R&&T?b['payment_info_for_object']??undefined:undefined,'host_service_published':b['host_service_published'],'treasury_perm_mismatch':U,'treasury_perm_entity':V,'treasury_perm_treasury':W,'host_service_permission':b['host_service_permission'],'allocation_create_op':b['operation_type']==='create','allocation_standalone':b['trigger_source']==='standalone','trigger_source_display':b['trigger_source']??'unknown','standalone_weak_guards_count':X?.['length'],'standalone_weak_guards_csv_sp':X?.['join'](',\x20'),'standalone_weak_guards_csv':X?.['join'](','),'has_fallback_allocator':b['has_fallback_allocator'],'guard_conditions_mutually_exclusive':b['guard_conditions_mutually_exclusive'],'has_fallback_allocator_display':String(b['has_fallback_allocator']??![]),'mutually_exclusive_display':String(b['guard_conditions_mutually_exclusive']??![]),'pure_amount_index':Y,'order_already_has_allocation':b['order_already_has_allocation'],'bound_order_display':b['bound_order']??'unknown','bound_order_paren_display':b['bound_order']??'(unknown)','has_payment_info':b['has_payment_info'],'operation_type':b['operation_type'],'max_allocator_count':MAX_ALLOCATOR_COUNT};}function allocationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['allocation'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27allocation\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function firedCaseKey(a,b,c){const d=a['find'](e=>e['rule_id']===c);if(d)for(let e=0x0;e<d['cases']['length'];e++){if(evaluateCondition(d['cases'][e]['when'],b))return c+'#'+e;}return c+'#0';}function findingToAllocationRisk(a,b){const c=RELATED_MOVE_ERROR[b],d=RELATED_GUARD_RISK[b];return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...c!==undefined?{'related_move_error':c}:{},...d!==undefined?{'related_guard_risk':d}:{},'auto_fixable':AUTO_FIXABLE['has'](b),...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){const a=factoryRulePack('allocation');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const d=allocationRiskFacts(c),{findings:e}=evaluateRuleBook([b],d);return e['length']>0x0?findingToAllocationRisk(e[0x0],firedCaseKey([b],d,b['rule_id'])):null;}}));}export function assessAllocationRisks(a){const b=allocationRuleBook(),c=allocationRiskFacts(a),{findings:d}=evaluateRuleBook(b,c),e=d['map'](j=>findingToAllocationRisk(j,firedCaseKey(b,c,j['rule_id']))),f=e['length']===0x0?'low':e['some'](j=>j['level']==='critical')?'critical':e['some'](j=>j['level']==='high')?'high':e['some'](j=>j['level']==='medium')?'medium':'low',g={},h={};for(const j of e){g[j['category']]=(g[j['category']]??0x0)+0x1,h[j['level']]=(h[j['level']]??0x0)+0x1;}const i={};for(const k of e){for(const l of k['affected_stakeholders']){if(!i[l])i[l]=[];i[l]['push'](k['id']+':\x20'+k['mitigation']);}}return{'summary':'Assessed\x20'+e['length']+'\x20risk(s)\x20across\x20'+Object['keys'](g)['length']+'\x20categories','risks':e,'overall_risk':f,'risks_by_category':g,'risks_by_level':h,'stakeholder_advice':i,'needs_human_review':e['some'](m=>m['level']==='critical'||m['level']==='high'),'blocks_publish':e['some'](m=>m['level']==='critical')};}export{ALLOCATION_ERROR_CODES};
|
|
@@ -28,9 +28,11 @@ export interface ArbRiskCheckContext {
|
|
|
28
28
|
expects_status_enum?: boolean;
|
|
29
29
|
order_mismatch?: boolean;
|
|
30
30
|
constants_synced?: boolean;
|
|
31
|
+
escrow_released_before_case?: boolean;
|
|
32
|
+
escrow_deficit_display?: string;
|
|
31
33
|
}
|
|
32
34
|
export declare function arbRiskFacts(ctx: ArbRiskCheckContext): Facts;
|
|
33
|
-
export declare const ARB_RISK_VERSION = "1.
|
|
35
|
+
export declare const ARB_RISK_VERSION = "1.1.0";
|
|
34
36
|
export declare const ARB_RISK_RULES: Array<ArbRisk & {
|
|
35
37
|
trigger?: string;
|
|
36
38
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,interpolate}from'../config/rule-engine.js';import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';export function arbRiskFacts(a){return{'status_display':a['status']===undefined?'?':String(a['status']),'invalid_transition':a['invalid_transition'],'withdraw_too_early':a['withdraw_too_early'],'votor_count':a['votor_count'],'votor_count_at_limit':a['votor_count']!==undefined&&a['votor_count']>=MAX_VOTOR_COUNT,'voting_deadline_none':a['voting_deadline_none'],'expects_proposition_event':a['expects_proposition_event'],'indemnity_none':a['indemnity_none'],'weight_concentrated':a['weight_concentrated'],'expects_status_enum':a['expects_status_enum'],'max_votor_count':MAX_VOTOR_COUNT,'withdraw_duration_time_ms':WITHDRAW_DURATION_TIME};}function arbRuleBook(){const a=getJudgmentDoc()['rules']['domains']['arb'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27arb\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function findingToArbRisk(a){return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'semantic','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],'auto_fixable':![]};}export const ARB_RISK_VERSION='1.
|
|
1
|
+
import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,interpolate}from'../config/rule-engine.js';import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';export function arbRiskFacts(a){return{'status_display':a['status']===undefined?'?':String(a['status']),'invalid_transition':a['invalid_transition'],'withdraw_too_early':a['withdraw_too_early'],'votor_count':a['votor_count'],'votor_count_at_limit':a['votor_count']!==undefined&&a['votor_count']>=MAX_VOTOR_COUNT,'voting_deadline_none':a['voting_deadline_none'],'expects_proposition_event':a['expects_proposition_event'],'indemnity_none':a['indemnity_none'],'weight_concentrated':a['weight_concentrated'],'expects_status_enum':a['expects_status_enum'],'escrow_released_before_case':a['escrow_released_before_case'],'escrow_deficit_display':a['escrow_deficit_display'],'max_votor_count':MAX_VOTOR_COUNT,'withdraw_duration_time_ms':WITHDRAW_DURATION_TIME};}function arbRuleBook(){const a=getJudgmentDoc()['rules']['domains']['arb'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27arb\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function findingToArbRisk(a){return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'semantic','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],'auto_fixable':![]};}export const ARB_RISK_VERSION='1.1.0';export const ARB_RISK_RULES=((()=>{const a=factoryRulePack('arb');if(!a)return[];const b=arbRiskFacts({});return a['rules']['map'](d=>{const e=d['cases'][0x0];return{'id':d['rule_id'],'level':e['level'],'category':d['dimension']??'semantic','title':interpolate(e['title'],b),'description':interpolate(e['description'],b),'affected_stakeholders':e['stakeholders']??[],'scenario':e['scenario']===undefined?'':interpolate(e['scenario'],b),'mitigation':e['mitigation']===undefined?'':interpolate(e['mitigation'],b),'auto_fixable':![],...d['trigger']===undefined?{}:{'trigger':d['trigger']}};});})());export function checkArbRisks(a){const {findings:b}=evaluateRuleBook(arbRuleBook(),arbRiskFacts(a));return b['map'](findingToArbRisk);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ARB_STATUS_CODE={'Principal_confirming':0x0,'Arbitrator_confirming':0x1,'Voting':0x2,'Arbitrated':0x3,'Objectionable':0x4,'Finished':0x5,'Withdrawn':0x6};export const ARB_TERMINAL_STATUSES=['Finished','Withdrawn'];export const ARB_STATUS_ALIASES={'created':'Principal_confirming','voting':'Voting','feedback':'Arbitrator_confirming','confirmed':'Arbitrated','completed':'Finished','reset':'Objectionable','disputed':'Withdrawn'};export const ARBITRATION_PERMISSIONS=[{'index':0x15e,'name':'ARBITRATION_NEW','description':'Create\x20new\x20Arbitration\x20object','governed_operations':['create\x20a\x20new\x20arbitration\x20service']},{'index':0x15f,'name':'ARBITRATION_DESCRIPTION','description':'Modify\x20Arbitration\x20description','governed_operations':['modify\x20the\x20arbitration\x20description']},{'index':0x160,'name':'ARBITRATION_ENDPOINT','description':'Reserved\x20placeholder\x20—\x20not\x20used\x20on-chain\x20(SDK\x20commented\x20out)','governed_operations':[],'is_reserved':!![]},{'index':0x161,'name':'ARBITRATION_LOCATION','description':'Set\x20Arbitration\x20location','governed_operations':['set\x20the\x20arbitration\x20location']},{'index':0x162,'name':'ARBITRATION_VOTING_GUARD','description':'Manage\x20voting_guard\x20list\x20(add\x20/\x20remove\x20/\x20clear)\x20—\x20controls\x20vote\x20weight','governed_operations':['add\x20a\x20passport-identifier\x20voting\x20guard\x20(dynamic\x20weight)','add\x20a\x20fixed-weight\x20voting\x20guard','remove\x20a\x20voting\x20guard','clear\x20the\x20voting\x20guard\x20list']},{'index':0x163,'name':'ARBITRATION_USAGE_GUARD','description':'Set\x20/\x20clear\x20usage_guard\x20—\x20controls\x20who\x20can\x20file\x20disputes','governed_operations':['set\x20the\x20usage\x20guard\x20(restrict\x20who\x20can\x20file\x20disputes)','clear\x20the\x20usage\x20guard']},{'index':0x164,'name':'ARBITRATION_PAUSE','description':'Pause\x20/\x20resume\x20Arbitration\x20(bPaused\x20default\x20true)','governed_operations':['pause/resume\x20the\x20arbitration\x20service']},{'index':0x165,'name':'ARBITRATION_FEE','description':'Set\x20dispute\x20application\x20fee\x20(u64)','governed_operations':['set\x20the\x20dispute\x20application\x20fee']},{'index':0x166,'name':'ARBITRATION_VOTE','description':'Open\x20vote\x20(no\x20voting_guard\x20configured\x20—\x201\x20person\x201\x20vote)','governed_operations':['open\x20a\x20vote\x20(1\x20person\x201\x20vote)']},{'index':0x167,'name':'ARBITRATION_ARBITRATION','description':'Make\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)','governed_operations':['issue\x20the\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)']},{'index':0x168,'name':'ARBITRATION_FEEDBACK','description':'Provide\x20feedback\x20on\x20Arb\x20case','governed_operations':['attach\x20feedback\x20to\x20the\x20Arb\x20case']},{'index':0x169,'name':'ARBITRATION_CONFIRM','description':'Confirm\x20materials\x20submitted\x20by\x20principal\x20(starts\x20voting\x20phase)','governed_operations':['confirm\x20the\x20principal\x27s\x20materials\x20(starts\x20the\x20voting\x20phase)']},{'index':0x16a,'name':'ARBITRATION_VOTING_DEADLINE_CHANGE','description':'Change\x20voting\x20deadline\x20for\x20an\x20Arb\x20case','governed_operations':['change\x20the\x20voting\x20deadline\x20for\x20an\x20Arb\x20case']},{'index':0x16b,'name':'ARBITRATION_RESET','description':'Reset\x20arbitration\x20—\x20principal\x20resubmits\x20materials,\x20restart\x20lifecycle','governed_operations':['reset\x20the\x20arbitration\x20(principal\x20resubmits\x20materials)']},{'index':0x16c,'name':'ARBITRATION_ARB_WITHDRAW','description':'Withdraw\x20arbitration\x20fees\x20from\x20Arb\x20into\x20Arbitration.balance','governed_operations':['withdraw\x20arbitration\x20fees\x20from\x20the\x20Arb\x20into\x20Arbitration.balance']},{'index':0x16d,'name':'ARBITRATION_FEES_ALLOC','description':'Allocate\x20arbitration\x20fees\x20to\x20Allocation\x20object','governed_operations':['allocate\x20arbitration\x20fees\x20to\x20an\x20Allocation\x20object']},{'index':0x16e,'name':'ARBITRATION_FEES_TRANSFER','description':'Transfer\x20arbitration\x20fees\x20to\x20Treasury\x20object','governed_operations':['transfer\x20arbitration\x20fees\x20to\x20a\x20Treasury\x20object']},{'index':0x16f,'name':'ARBITRATION_OWNER_RECEIVE','description':'Owner\x20receive\x20(unwrap\x20received\x20Coin/Object\x20and\x20send\x20to\x20Permission\x20owner)','governed_operations':['owner\x20receipt\x20of\x20payments\x20(unwrapped\x20to\x20the\x20owner)','owner\x20receipt\x20of\x20whole\x20objects']},{'index':0x170,'name':'ARBITRATION_UM','description':'Set\x20/\x20clear\x20User\x20Manager\x20(Contact\x20object)','governed_operations':['bind\x20a\x20Contact\x20as\x20the\x20UM\x20coordinator','unbind\x20the\x20UM\x20Contact']}];export const DUAL_GUARD_MATRIX=[{'voting_guard_empty':!![],'usage_guard_empty':!![],'dispute_method':'dispute','vote_method':'vote','scenario':'Open\x20dispute\x20+\x20open\x20voting\x20(1\x20person\x201\x20vote)'},{'voting_guard_empty':!![],'usage_guard_empty':![],'dispute_method':'dispute_via_passport','vote_method':'vote','scenario':'Restricted\x20dispute\x20+\x20open\x20voting'},{'voting_guard_empty':![],'usage_guard_empty':!![],'dispute_method':'dispute','vote_method':'vote_weighted_by_guard','scenario':'Open\x20dispute\x20+\x20weighted\x20voting'},{'voting_guard_empty':![],'usage_guard_empty':![],'dispute_method':'dispute_via_passport','vote_method':'vote_weighted_by_guard','scenario':'Restricted\x20dispute\x20+\x20weighted\x20voting\x20(most\x20controlled)'}];export const ARBITRATION_SCENES=[{'id':'arbitration_create','name':'Create\x20new\x20Arbitration\x20service','operation_category':'lifecycle','permission_index':0x15e,'permission_name':'ARBITRATION_NEW','requires_voting_guard':'any','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['create\x20a\x20new\x20arbitration\x20service'],'common_patterns':['Pre-publish\x20config:\x20create\x20Arbitration\x20+\x20Permission\x20together','bPaused\x20defaults\x20to\x20true\x20—\x20must\x20call\x20pause(false)\x20to\x20enable','Generic\x20T:\x20choose\x20Coin\x20type\x20(e.g.\x200x2::wow::WOW)\x20at\x20creation','object-linker\x20binding\x20(core):\x20permission\x20+\x20arbitration\x20linked\x20by\x20an\x20affiliation\x20core\x20binding'],'recommended_templates':['T-AB-01','T-AB-02']},{'id':'arbitration_dispute','name':'File\x20dispute\x20against\x20an\x20Order\x20(creates\x20Arb\x20case)','operation_category':'dispute','permission_index':0x0,'permission_name':'(order\x20op\x20permission\x20—\x20no\x20ARBITRATION_*\x20index)','required_arb_status':[],'resulting_arb_status':'Arbitrator_confirming','requires_voting_guard':'any','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['file\x20a\x20dispute\x20against\x20an\x20Order\x20(creates\x20the\x20Arb\x20case)'],'common_patterns':['Fee\x20gate:\x20coin::value(&fee)\x20>=\x20self.fee,\x20else\x20E_FEE_NOT_ENOUGH','Order\x20op\x20permission\x20check\x20required\x20(caller\x20must\x20hold\x20the\x20matching\x20order\x20operation\x20permission)','Creates\x20independent\x20Arb<T>\x20object\x20with\x20its\x20own\x20lifecycle','If\x20usage_guard\x20is\x20Some\x20→\x20the\x20dispute\x20must\x20go\x20through\x20passport\x20verification','Order.dispute\x20list:\x20appends\x20new\x20Arb\x20(max\x2010\x20per\x20Order)'],'recommended_templates':['T-AB-01','T-AB-03','T-AB-04']},{'id':'arbitration_vote','name':'Vote\x20on\x20Arb\x20propositions','operation_category':'voting','permission_index':0x166,'permission_name':'ARBITRATION_VOTE','required_arb_status':['Voting'],'requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['open\x20a\x20vote\x20(1\x20person\x201\x20vote)','cast\x20a\x20weighted\x20vote\x20(weights\x20resolved\x20from\x20the\x20voting\x20guard)'],'common_patterns':['Open\x20vote:\x20voting_guard\x20empty\x20→\x20plain\x20vote\x20(passport\x20variant\x20supported)','Weighted\x20vote:\x20voting_guard\x20non-empty\x20→\x20vote\x20weight\x20resolved\x20per\x20voting\x20guard','votes:\x20u8\x20array\x20—\x20index\x20into\x20proposition\x20list\x20(0..N-1)','Mismatch:\x20vote()\x20with\x20non-empty\x20voting_guard\x20→\x20E_VOTING_GUARD_USED','Guard\x20not\x20in\x20list:\x20E_VOTING_GUARD_NOT_FOUND'],'recommended_templates':['T-AB-02','T-AB-03']},{'id':'arbitration_confirm','name':'Confirm\x20principal\x20materials\x20and\x20start\x20voting\x20phase','operation_category':'ruling','permission_index':0x169,'permission_name':'ARBITRATION_CONFIRM','required_arb_status':['Arbitrator_confirming'],'resulting_arb_status':'Voting','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['confirm\x20the\x20principal\x27s\x20materials\x20(starts\x20the\x20voting\x20phase)'],'common_patterns':['Transitions\x20Arb\x20from\x20Arbitrator_confirming\x20→\x20Voting','voting_deadline:\x20u64\x20timestamp_ms\x20(null\x20=\x20no\x20deadline)','Once\x20in\x20Voting,\x20only\x20vote\x20/\x20voting_deadline_change\x20/\x20reset\x20allowed'],'recommended_templates':['T-AB-01','T-AB-02']},{'id':'arbitration_feedback','name':'Provide\x20feedback\x20on\x20Arb\x20case','operation_category':'ruling','permission_index':0x168,'permission_name':'ARBITRATION_FEEDBACK','required_arb_status':['Principal_confirming','Arbitrator_confirming','Voting','Arbitrated','Objectionable'],'requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['attach\x20feedback\x20to\x20the\x20Arb\x20case'],'common_patterns':['Feedback\x20is\x20informational\x20—\x20does\x20not\x20change\x20Arb\x20status','Used\x20by\x20principal\x20/\x20arbitrator\x20/\x20voters\x20to\x20attach\x20notes','No\x20state\x20transition;\x20supplements\x20the\x20case\x20record'],'recommended_templates':['T-AB-01','T-AB-07']},{'id':'arbitration_ruling','name':'Make\x20definitive\x20arbitration\x20ruling\x20with\x20indemnity','operation_category':'ruling','permission_index':0x167,'permission_name':'ARBITRATION_ARBITRATION','required_arb_status':['Voting'],'resulting_arb_status':'Arbitrated','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['issue\x20the\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)'],'common_patterns':['Ruling\x20produces:\x20feedback\x20(string)\x20+\x20indemnity\x20(u64)','indemnity\x20is\x20compensation\x20amount\x20—\x20paid\x20through\x20the\x20order\x20compensation\x20flow','compensation\x20is\x20package-internal\x20—\x20only\x20the\x20order\x20lifecycle\x20can\x20trigger\x20it','Once\x20Arbitrated,\x20case\x20enters\x20Objectionable\x20window\x20(reset\x20possible)'],'recommended_templates':['T-AB-01','T-AB-05']},{'id':'arbitration_reset','name':'Reset\x20arbitration\x20—\x20principal\x20resubmits\x20materials','operation_category':'ruling','permission_index':0x16b,'permission_name':'ARBITRATION_RESET','required_arb_status':['Objectionable','Arbitrator_confirming'],'resulting_arb_status':'Principal_confirming','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['reset\x20the\x20arbitration\x20(principal\x20resubmits\x20materials)'],'common_patterns':['Resets\x20Arb\x20from\x20Objectionable/Arbitrator_confirming\x20→\x20Principal_confirming','Used\x20when\x20principal\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','Feedback\x20required\x20(string\x20explaining\x20reset\x20reason)','Restart\x20full\x20lifecycle:\x20Principal_confirming\x20→\x20...\x20→\x20Finished'],'recommended_templates':['T-AB-07']},{'id':'arbitration_arb_withdraw','name':'Withdraw\x20arbitration\x20fees\x20from\x20Arb\x20into\x20Arbitration.balance','operation_category':'fund','permission_index':0x16c,'permission_name':'ARBITRATION_ARB_WITHDRAW','required_arb_status':['Finished','Arbitrated'],'requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['withdraw\x20arbitration\x20fees\x20from\x20the\x20Arb\x20into\x20Arbitration.balance'],'common_patterns':['Moves\x20fees\x20from\x20the\x20Arb\x20object\x20into\x20Arbitration.balance\x20(clock-checked)','Finished:\x20withdraw\x20immediately','Arbitrated:\x20must\x20wait\x20WITHDRAW_DURATION_TIME\x20(30d)\x20past\x20indemnity.time\x20—\x20silence\x20=\x20acceptance','Objectionable:\x20NEVER\x20withdrawable\x20(protocol\x20141)\x20—\x20the\x20fee\x20stays\x20escrowed\x20until\x20the\x20objection\x20cycle\x20is\x20closed\x20by\x20the\x20principal\x20re-confirming','Increases\x20Arbitration.balance\x20—\x20funds\x20available\x20for\x20fee\x20allocation/transfer'],'recommended_templates':['T-AB-06']},{'id':'arbitration_fees_alloc','name':'Allocate\x20arbitration\x20fees\x20to\x20Allocation\x20object','operation_category':'fund','permission_index':0x16d,'permission_name':'ARBITRATION_FEES_ALLOC','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['allocate\x20arbitration\x20fees\x20to\x20an\x20Allocation\x20object'],'common_patterns':['Destination:\x20Allocation\x20object\x20(parameterized\x20fund\x20distribution)','payment_remark\x20+\x20payment_index:\x20bookkeeping\x20for\x20Payment\x20object','May\x20create\x20new\x20Payment\x20object\x20if\x20newPayment\x20name\x20provided','Triggers\x20balance::withdraw_all\x20—\x20extracts\x20ALL\x20balance'],'recommended_templates':['T-AB-06']},{'id':'arbitration_fees_transfer','name':'Transfer\x20arbitration\x20fees\x20to\x20Treasury\x20object','operation_category':'fund','permission_index':0x16e,'permission_name':'ARBITRATION_FEES_TRANSFER','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['transfer\x20arbitration\x20fees\x20to\x20a\x20Treasury\x20object'],'common_patterns':['Destination:\x20Treasury\x20object\x20(general\x20fund\x20pool)','Same\x20bookkeeping\x20as\x20fee\x20allocation\x20(remark\x20+\x20index\x20+\x20newPayment)','Triggers\x20balance::withdraw_all\x20—\x20extracts\x20ALL\x20balance','Choose\x20Allocation\x20vs\x20Treasury\x20by\x20distribution\x20need'],'recommended_templates':['T-AB-06']},{'id':'arbitration_voting_guard_config','name':'Configure\x20voting_guard\x20list\x20(add\x20/\x20set\x20/\x20remove\x20/\x20clear)','operation_category':'guard','permission_index':0x162,'permission_name':'ARBITRATION_VOTING_GUARD','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['add\x20a\x20passport-identifier\x20voting\x20guard\x20(dynamic\x20weight)','add\x20a\x20fixed-weight\x20voting\x20guard','remove\x20a\x20voting\x20guard','clear\x20the\x20voting\x20guard\x20list'],'common_patterns':['Max\x2050\x20guards:\x20MAX_VOTING_GUARD_COUNT=50\x20(off-by-one-safe:\x20len<50\x20allows\x20add)','GuardIdentifier(u8):\x20dynamic\x20weight\x20from\x20Passport\x20submission\x20value','FixedValue(u32):\x20static\x20weight\x20(e.g.\x20100\x20votes\x20per\x20holder)','Add\x20same\x20guard\x20twice\x20→\x20updates\x20vote_weight\x20(no\x20duplicate)','op=\x27set\x27\x20=\x20clear\x20then\x20add;\x20op=\x27add\x27\x20=\x20append;\x20op=\x27remove\x27\x20=\x20by\x20address'],'recommended_templates':['T-AB-02','T-AB-03']},{'id':'arbitration_usage_guard_config','name':'Configure\x20usage_guard\x20(set\x20/\x20clear)','operation_category':'guard','permission_index':0x163,'permission_name':'ARBITRATION_USAGE_GUARD','requires_voting_guard':'not_applicable','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['set\x20the\x20usage\x20guard\x20(restrict\x20who\x20can\x20file\x20disputes)','clear\x20the\x20usage\x20guard'],'common_patterns':['Single\x20guard\x20(Option<address>)\x20—\x20not\x20a\x20list','Some(guard):\x20the\x20dispute\x20must\x20go\x20through\x20passport\x20verification','None:\x20dispute\x20can\x20use\x20either\x20variant\x20(no\x20passport\x20needed)','object-linker\x20affiliation\x20change:\x20updates\x20link\x20when\x20guard\x20changes'],'recommended_templates':['T-AB-04']},{'id':'arbitration_pause','name':'Pause\x20/\x20resume\x20Arbitration\x20service','operation_category':'lifecycle','permission_index':0x164,'permission_name':'ARBITRATION_PAUSE','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['pause/resume\x20the\x20arbitration\x20service'],'common_patterns':['bPaused\x20default\x20true\x20—\x20new\x20Arbitration\x20cannot\x20accept\x20disputes','pause(false)\x20to\x20enable,\x20pause(true)\x20to\x20disable','Paused\x20Arbitration\x20rejects\x20dispute\x20(E_PAUSED)','Does\x20not\x20affect\x20already-open\x20Arb\x20cases'],'recommended_templates':['T-AB-01']},{'id':'arbitration_service_statement','name':'Service\x20(defendant)\x20appends\x20a\x20text\x20statement\x20to\x20the\x20case\x20record','operation_category':'dispute','permission_index':0x141,'permission_name':'SERVICE_ARB_STATEMENT','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['append\x20the\x20seller\x27s\x20text\x20statement\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20the\x20service\x20(ArbStatementEvent)'],'common_patterns':['Defendant-side\x20voice\x20WITHOUT\x20holding\x20the\x20order\x20—\x20the\x20arb/arbitration\x20function\x20family\x20is\x20order-anchored;\x20this\x20entry\x20is\x20service-anchored','PRIMARY\x20evidence\x20channel\x20is\x20Messenger:\x20submit\x20encrypted\x20WTS\x20records\x20of\x20the\x20exchange\x20with\x20the\x20order\x20customer\x20first','This\x20statement\x20is\x20the\x20SECONDARY\x20channel:\x20declare\x20facts\x20or\x20report\x20customer\x20behavior\x20(absence,\x20non-cooperation)\x20on\x20the\x20case\x20record','Event-only:\x20nothing\x20on\x20the\x20Arb\x20object\x20is\x20mutated;\x20the\x20record\x20cannot\x20be\x20rewritten\x20or\x20deleted\x20by\x20any\x20party','Text\x20length\x20cap\x20identical\x20to\x20description/objection\x20(DESCRIPTION\x20bound,\x204000)'],'recommended_templates':[]}];export const ARBITRATION_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return ARBITRATION_SCENES['filter'](b=>b['operation_category']===a);}export function findSceneById(a){return ARBITRATION_SCENES['find'](b=>b['id']===a);}export function findSceneByPermissionIndex(a){return ARBITRATION_SCENES['find'](b=>b['permission_index']===a);}export function getPermissionByIndex(a){return ARBITRATION_PERMISSIONS['find'](b=>b['index']===a);}export function getPermissionByName(a){return ARBITRATION_PERMISSIONS['find'](b=>b['name']===a);}export function isReservedIndex(a){const b=getPermissionByIndex(a);return!!b?.['is_reserved'];}export function isUsedPermissionIndex(a){const b=getPermissionByIndex(a);return!!b&&!b['is_reserved'];}export function getActivePermissionCount(){return ARBITRATION_PERMISSIONS['filter'](a=>!a['is_reserved'])['length'];}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[{'keywords':['create','new'],'sceneId':'arbitration_create'},{'keywords':['dispute','file','complaint'],'sceneId':'arbitration_dispute'},{'keywords':['vote','voting','decide'],'sceneId':'arbitration_vote'},{'keywords':['confirm','materials'],'sceneId':'arbitration_confirm'},{'keywords':['feedback','opinion'],'sceneId':'arbitration_feedback'},{'keywords':['ruling','arbitration','verdict'],'sceneId':'arbitration_ruling'},{'keywords':['reset','resubmit'],'sceneId':'arbitration_reset'},{'keywords':['arb_withdraw','withdraw','withdraw\x20fees'],'sceneId':'arbitration_arb_withdraw'},{'keywords':['allocate','allocate\x20fees','fees\x20allocation'],'sceneId':'arbitration_fees_alloc'},{'keywords':['fees_transfer','transfer','transfer\x20in'],'sceneId':'arbitration_fees_transfer'},{'keywords':['voting_guard','voting\x20guard'],'sceneId':'arbitration_voting_guard_config'},{'keywords':['usage_guard','usage\x20guard'],'sceneId':'arbitration_usage_guard_config'},{'keywords':['pause','enable'],'sceneId':'arbitration_pause'}];for(const {keywords:d,sceneId:e}of c){if(d['some'](f=>b['includes'](f['toLowerCase']()))){const f=findSceneById(e);if(f)return f;}}return undefined;}export function getDualGuardMatrixEntry(a,b){return DUAL_GUARD_MATRIX['find'](c=>c['voting_guard_empty']===a&&c['usage_guard_empty']===b);}export function isValidArbStatusTransition(a,b){const c={'Principal_confirming':['Arbitrator_confirming'],'Arbitrator_confirming':['Voting','Principal_confirming'],'Voting':['Arbitrated'],'Arbitrated':['Objectionable','Finished','Withdrawn'],'Objectionable':['Principal_confirming'],'Finished':['Withdrawn'],'Withdrawn':[]};return c[a]?.['includes'](b)??![];}export function isTerminalArbStatus(a){return ARB_TERMINAL_STATUSES['includes'](a);}export function getScenesProducingStatus(a){return ARBITRATION_SCENES['filter'](b=>b['resulting_arb_status']===a);}export function getScenesRequiringStatus(a){return ARBITRATION_SCENES['filter'](b=>b['required_arb_status']?.['includes'](a));}export function getArbitrationScenesCount(){return ARBITRATION_SCENES['length'];}export function getAllArbitrationPermissions(){return[...ARBITRATION_PERMISSIONS];}export function getActiveArbitrationPermissions(){return ARBITRATION_PERMISSIONS['filter'](a=>!a['is_reserved']);}
|
|
1
|
+
export const ARB_STATUS_CODE={'Principal_confirming':0x0,'Arbitrator_confirming':0x1,'Voting':0x2,'Arbitrated':0x3,'Objectionable':0x4,'Finished':0x5,'Withdrawn':0x6};export const ARB_TERMINAL_STATUSES=['Finished','Withdrawn'];export const ARB_STATUS_ALIASES={'created':'Principal_confirming','voting':'Voting','feedback':'Arbitrator_confirming','confirmed':'Arbitrated','completed':'Finished','reset':'Objectionable','disputed':'Withdrawn'};export const ARBITRATION_PERMISSIONS=[{'index':0x15e,'name':'ARBITRATION_NEW','description':'Create\x20new\x20Arbitration\x20object','governed_operations':['create\x20a\x20new\x20arbitration\x20service']},{'index':0x15f,'name':'ARBITRATION_DESCRIPTION','description':'Modify\x20Arbitration\x20description','governed_operations':['modify\x20the\x20arbitration\x20description']},{'index':0x160,'name':'ARBITRATION_ENDPOINT','description':'Reserved\x20placeholder\x20—\x20not\x20used\x20on-chain\x20(SDK\x20commented\x20out)','governed_operations':[],'is_reserved':!![]},{'index':0x161,'name':'ARBITRATION_LOCATION','description':'Set\x20Arbitration\x20location','governed_operations':['set\x20the\x20arbitration\x20location']},{'index':0x162,'name':'ARBITRATION_VOTING_GUARD','description':'Manage\x20voting_guard\x20list\x20(add\x20/\x20remove\x20/\x20clear)\x20—\x20controls\x20vote\x20weight','governed_operations':['add\x20a\x20passport-identifier\x20voting\x20guard\x20(dynamic\x20weight)','add\x20a\x20fixed-weight\x20voting\x20guard','remove\x20a\x20voting\x20guard','clear\x20the\x20voting\x20guard\x20list']},{'index':0x163,'name':'ARBITRATION_USAGE_GUARD','description':'Set\x20/\x20clear\x20usage_guard\x20—\x20controls\x20who\x20can\x20file\x20disputes','governed_operations':['set\x20the\x20usage\x20guard\x20(restrict\x20who\x20can\x20file\x20disputes)','clear\x20the\x20usage\x20guard']},{'index':0x164,'name':'ARBITRATION_PAUSE','description':'Pause\x20/\x20resume\x20Arbitration\x20(bPaused\x20default\x20true)','governed_operations':['pause/resume\x20the\x20arbitration\x20service']},{'index':0x165,'name':'ARBITRATION_FEE','description':'Set\x20dispute\x20application\x20fee\x20(u64)','governed_operations':['set\x20the\x20dispute\x20application\x20fee']},{'index':0x166,'name':'ARBITRATION_VOTE','description':'Cast\x20a\x20vote.\x20With\x20an\x20EMPTY\x20voting_guard\x20this\x20is\x20an\x20equal-weight\x20vote\x20(1\x20person\x201\x20vote)\x20—\x20'+'NOT\x20permissionless:\x20vote()\x20asserts\x20permission\x20358\x20unconditionally,\x20so\x20every\x20voter\x20(both\x20disputing\x20'+'parties\x20in\x20open\x20voting)\x20must\x20be\x20GRANTED\x20358\x20first.\x20A\x20fresh\x20Arbitration\x20has\x20no\x20grants\x20at\x20all,\x20so\x20'+'without\x20explicit\x20grants\x20nobody\x20can\x20vote\x20(E-13,\x20test/6)','governed_operations':['cast\x20a\x20vote\x20(empty\x20voting_guard\x20=\x201\x20person\x201\x20vote,\x20permission\x20358\x20still\x20required)','cast\x20a\x20weighted\x20vote\x20via\x20voting_guard\x20(weights\x20resolved\x20per\x20guard)']},{'index':0x167,'name':'ARBITRATION_ARBITRATION','description':'Make\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)','governed_operations':['issue\x20the\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)']},{'index':0x168,'name':'ARBITRATION_FEEDBACK','description':'Provide\x20feedback\x20on\x20Arb\x20case','governed_operations':['attach\x20feedback\x20to\x20the\x20Arb\x20case']},{'index':0x169,'name':'ARBITRATION_CONFIRM','description':'Confirm\x20materials\x20submitted\x20by\x20principal\x20(starts\x20voting\x20phase)','governed_operations':['confirm\x20the\x20principal\x27s\x20materials\x20(starts\x20the\x20voting\x20phase)']},{'index':0x16a,'name':'ARBITRATION_VOTING_DEADLINE_CHANGE','description':'Change\x20voting\x20deadline\x20for\x20an\x20Arb\x20case','governed_operations':['change\x20the\x20voting\x20deadline\x20for\x20an\x20Arb\x20case']},{'index':0x16b,'name':'ARBITRATION_RESET','description':'Reset\x20arbitration\x20—\x20principal\x20resubmits\x20materials,\x20restart\x20lifecycle','governed_operations':['reset\x20the\x20arbitration\x20(principal\x20resubmits\x20materials)']},{'index':0x16c,'name':'ARBITRATION_ARB_WITHDRAW','description':'Withdraw\x20arbitration\x20fees\x20from\x20Arb\x20into\x20Arbitration.balance','governed_operations':['withdraw\x20arbitration\x20fees\x20from\x20the\x20Arb\x20into\x20Arbitration.balance']},{'index':0x16d,'name':'ARBITRATION_FEES_ALLOC','description':'Allocate\x20arbitration\x20fees\x20to\x20Allocation\x20object','governed_operations':['allocate\x20arbitration\x20fees\x20to\x20an\x20Allocation\x20object']},{'index':0x16e,'name':'ARBITRATION_FEES_TRANSFER','description':'Transfer\x20arbitration\x20fees\x20to\x20Treasury\x20object','governed_operations':['transfer\x20arbitration\x20fees\x20to\x20a\x20Treasury\x20object']},{'index':0x16f,'name':'ARBITRATION_OWNER_RECEIVE','description':'Owner\x20receive\x20(unwrap\x20received\x20Coin/Object\x20and\x20send\x20to\x20Permission\x20owner)','governed_operations':['owner\x20receipt\x20of\x20payments\x20(unwrapped\x20to\x20the\x20owner)','owner\x20receipt\x20of\x20whole\x20objects']},{'index':0x170,'name':'ARBITRATION_UM','description':'Set\x20/\x20clear\x20User\x20Manager\x20(Contact\x20object)','governed_operations':['bind\x20a\x20Contact\x20as\x20the\x20UM\x20coordinator','unbind\x20the\x20UM\x20Contact']}];export const DUAL_GUARD_MATRIX=[{'voting_guard_empty':!![],'usage_guard_empty':!![],'dispute_method':'dispute','vote_method':'vote','scenario':'Open\x20dispute\x20+\x20open\x20voting\x20(1\x20person\x201\x20vote)'},{'voting_guard_empty':!![],'usage_guard_empty':![],'dispute_method':'dispute_via_passport','vote_method':'vote','scenario':'Restricted\x20dispute\x20+\x20open\x20voting'},{'voting_guard_empty':![],'usage_guard_empty':!![],'dispute_method':'dispute','vote_method':'vote_weighted_by_guard','scenario':'Open\x20dispute\x20+\x20weighted\x20voting'},{'voting_guard_empty':![],'usage_guard_empty':![],'dispute_method':'dispute_via_passport','vote_method':'vote_weighted_by_guard','scenario':'Restricted\x20dispute\x20+\x20weighted\x20voting\x20(most\x20controlled)'}];export const ARBITRATION_SCENES=[{'id':'arbitration_create','name':'Create\x20new\x20Arbitration\x20service','operation_category':'lifecycle','permission_index':0x15e,'permission_name':'ARBITRATION_NEW','requires_voting_guard':'any','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['create\x20a\x20new\x20arbitration\x20service'],'common_patterns':['Pre-publish\x20config:\x20create\x20Arbitration\x20+\x20Permission\x20together','bPaused\x20defaults\x20to\x20true\x20—\x20must\x20call\x20pause(false)\x20to\x20enable','Generic\x20T:\x20choose\x20Coin\x20type\x20(e.g.\x200x2::wow::WOW)\x20at\x20creation','object-linker\x20binding\x20(core):\x20permission\x20+\x20arbitration\x20linked\x20by\x20an\x20affiliation\x20core\x20binding'],'recommended_templates':['T-AB-01','T-AB-02']},{'id':'arbitration_dispute','name':'File\x20dispute\x20against\x20an\x20Order\x20(creates\x20Arb\x20case)','operation_category':'dispute','permission_index':0x0,'permission_name':'(order\x20op\x20permission\x20—\x20no\x20ARBITRATION_*\x20index)','required_arb_status':[],'resulting_arb_status':'Arbitrator_confirming','requires_voting_guard':'any','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['file\x20a\x20dispute\x20against\x20an\x20Order\x20(creates\x20the\x20Arb\x20case)'],'common_patterns':['Fee\x20gate:\x20coin::value(&fee)\x20>=\x20self.fee,\x20else\x20E_FEE_NOT_ENOUGH','Order\x20op\x20permission\x20check\x20required\x20(caller\x20must\x20hold\x20the\x20matching\x20order\x20operation\x20permission)','Creates\x20independent\x20Arb<T>\x20object\x20with\x20its\x20own\x20lifecycle','If\x20usage_guard\x20is\x20Some\x20→\x20the\x20dispute\x20must\x20go\x20through\x20passport\x20verification','Order.dispute\x20list:\x20appends\x20new\x20Arb\x20(max\x2010\x20per\x20Order)','One-shot\x20filing:\x20the\x20Arb\x20is\x20created\x20directly\x20in\x20Arbitrator_confirming\x20status\x20—\x20proposition\x20and\x20description\x20are\x20final\x20at\x20filing;\x20edits\x20require\x20the\x20arbitrator\x20to\x20reset\x20the\x20case\x20back\x20to\x20Principal_confirming\x20first.\x20Assemble\x20the\x20complete\x20proposition\x20before\x20calling\x20dispute.'],'recommended_templates':['T-AB-01','T-AB-03','T-AB-04']},{'id':'arbitration_vote','name':'Vote\x20on\x20Arb\x20propositions','operation_category':'voting','permission_index':0x166,'permission_name':'ARBITRATION_VOTE','required_arb_status':['Voting'],'requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['open\x20a\x20vote\x20(1\x20person\x201\x20vote)','cast\x20a\x20weighted\x20vote\x20(weights\x20resolved\x20from\x20the\x20voting\x20guard)'],'common_patterns':['Open\x20vote:\x20voting_guard\x20empty\x20→\x20plain\x20vote\x20(passport\x20variant\x20supported);\x20equal\x20weight\x20'+'(1\x20person\x201\x20vote)\x20but\x20still\x20requires\x20permission\x20358\x20for\x20EVERY\x20voter\x20—\x20grant\x20358\x20to\x20both\x20'+'disputing\x20parties,\x20otherwise\x20no\x20one\x20can\x20vote\x20(E-13)','Weighted\x20vote:\x20voting_guard\x20non-empty\x20→\x20vote\x20weight\x20resolved\x20per\x20voting\x20guard','votes:\x20u8\x20array\x20—\x20index\x20into\x20proposition\x20list\x20(0..N-1)','Mismatch:\x20vote()\x20with\x20non-empty\x20voting_guard\x20→\x20E_VOTING_GUARD_USED','Guard\x20not\x20in\x20list:\x20E_VOTING_GUARD_NOT_FOUND','E-15:\x20the\x20voting_deadline\x20IS\x20the\x20dispute-resolution\x20delay\x20window\x20—\x20the\x20ruling\x20(arbitration)\x20'+'aborts\x20with\x20E_VOTING_DEADLINE_NOT_PASSED\x20until\x20the\x20deadline\x20elapses.\x20Size\x20the\x20window\x20to\x20the\x20'+'business\x20expectation\x20(e.g.\x2010\x20minutes\x20for\x20tests,\x20days\x20for\x20production)'],'recommended_templates':['T-AB-02','T-AB-03']},{'id':'arbitration_confirm','name':'Confirm\x20principal\x20materials\x20and\x20start\x20voting\x20phase','operation_category':'ruling','permission_index':0x169,'permission_name':'ARBITRATION_CONFIRM','required_arb_status':['Arbitrator_confirming'],'resulting_arb_status':'Voting','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['confirm\x20the\x20principal\x27s\x20materials\x20(starts\x20the\x20voting\x20phase)'],'common_patterns':['Transitions\x20Arb\x20from\x20Arbitrator_confirming\x20→\x20Voting','voting_deadline:\x20u64\x20timestamp_ms\x20(null\x20=\x20no\x20deadline)','Once\x20in\x20Voting,\x20only\x20vote\x20/\x20voting_deadline_change\x20/\x20reset\x20allowed'],'recommended_templates':['T-AB-01','T-AB-02']},{'id':'arbitration_feedback','name':'Provide\x20feedback\x20on\x20Arb\x20case','operation_category':'ruling','permission_index':0x168,'permission_name':'ARBITRATION_FEEDBACK','required_arb_status':['Principal_confirming','Arbitrator_confirming','Voting','Arbitrated','Objectionable'],'requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['attach\x20feedback\x20to\x20the\x20Arb\x20case'],'common_patterns':['Feedback\x20is\x20informational\x20—\x20does\x20not\x20change\x20Arb\x20status','Used\x20by\x20principal\x20/\x20arbitrator\x20/\x20voters\x20to\x20attach\x20notes','No\x20state\x20transition;\x20supplements\x20the\x20case\x20record'],'recommended_templates':['T-AB-01','T-AB-07']},{'id':'arbitration_ruling','name':'Make\x20definitive\x20arbitration\x20ruling\x20with\x20indemnity','operation_category':'ruling','permission_index':0x167,'permission_name':'ARBITRATION_ARBITRATION','required_arb_status':['Voting'],'resulting_arb_status':'Arbitrated','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['issue\x20the\x20definitive\x20arbitration\x20ruling\x20(with\x20indemnity)'],'common_patterns':['Ruling\x20produces:\x20feedback\x20(string)\x20+\x20indemnity\x20(u64)','indemnity\x20is\x20compensation\x20amount\x20—\x20paid\x20through\x20the\x20order\x20compensation\x20flow','compensation\x20is\x20package-internal\x20—\x20only\x20the\x20order\x20lifecycle\x20can\x20trigger\x20it','Once\x20Arbitrated,\x20case\x20enters\x20Objectionable\x20window\x20(reset\x20possible)','E-16:\x20the\x20indemnity\x20is\x20paid\x20from\x20the\x20SERVICE\x27s\x20merchant-prepaid\x20compensation_fund\x20pool,\x20'+'NOT\x20from\x20the\x20order\x20escrow.\x20If\x20the\x20pool\x20is\x20smaller\x20than\x20the\x20indemnity,\x20arb_claim_compensation\x20'+'aborts\x20with\x20code\x2027\x20(E_COMPENSATION_NOT_MATCH)\x20—\x20the\x20ruling\x20stands\x20but\x20is\x20unpayable\x20until\x20the\x20'+'merchant\x20tops\x20up\x20(the\x20abort\x20does\x20NOT\x20consume\x20the\x20claim)','E-17/E-17b:\x20the\x20ruling\x20does\x20NOT\x20propagate\x20to\x20the\x20Machine/Allocation\x20escrow\x20—\x20after\x20a\x20claim\x20the\x20'+'order\x20can\x20still\x20be\x20driven\x20to\x20completed\x20and\x20settle\x20the\x20FULL\x20escrow\x20on\x20top\x20of\x20the\x20compensation\x20'+'(claim/objection\x20are\x20orthogonal\x20to\x20the\x20workflow;\x20they\x20are\x20only\x20mutually\x20exclusive\x20with\x20each\x20'+'other).\x20Deliberately\x20gate:\x20hold/adjust\x20the\x20order\x20before\x20settlement,\x20or\x20accept\x20both\x20payouts'],'recommended_templates':['T-AB-01','T-AB-05']},{'id':'arbitration_reset','name':'Reset\x20arbitration\x20—\x20principal\x20resubmits\x20materials','operation_category':'ruling','permission_index':0x16b,'permission_name':'ARBITRATION_RESET','required_arb_status':['Objectionable','Arbitrator_confirming'],'resulting_arb_status':'Principal_confirming','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['reset\x20the\x20arbitration\x20(principal\x20resubmits\x20materials)'],'common_patterns':['Resets\x20Arb\x20from\x20Objectionable/Arbitrator_confirming\x20→\x20Principal_confirming','Used\x20when\x20principal\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','Feedback\x20required\x20(string\x20explaining\x20reset\x20reason)','Restart\x20full\x20lifecycle:\x20Principal_confirming\x20→\x20...\x20→\x20Finished'],'recommended_templates':['T-AB-07']},{'id':'arbitration_arb_withdraw','name':'Withdraw\x20arbitration\x20fees\x20from\x20Arb\x20into\x20Arbitration.balance','operation_category':'fund','permission_index':0x16c,'permission_name':'ARBITRATION_ARB_WITHDRAW','required_arb_status':['Finished','Arbitrated'],'requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['withdraw\x20arbitration\x20fees\x20from\x20the\x20Arb\x20into\x20Arbitration.balance'],'common_patterns':['Moves\x20fees\x20from\x20the\x20Arb\x20object\x20into\x20Arbitration.balance\x20(clock-checked)','Finished:\x20withdraw\x20immediately','Arbitrated:\x20must\x20wait\x20WITHDRAW_DURATION_TIME\x20(30d)\x20past\x20indemnity.time\x20—\x20silence\x20=\x20acceptance','Objectionable:\x20NEVER\x20withdrawable\x20(protocol\x20141)\x20—\x20the\x20fee\x20stays\x20escrowed\x20until\x20the\x20objection\x20cycle\x20is\x20closed\x20by\x20the\x20principal\x20re-confirming','Increases\x20Arbitration.balance\x20—\x20funds\x20available\x20for\x20fee\x20allocation/transfer'],'recommended_templates':['T-AB-06']},{'id':'arbitration_fees_alloc','name':'Allocate\x20arbitration\x20fees\x20to\x20Allocation\x20object','operation_category':'fund','permission_index':0x16d,'permission_name':'ARBITRATION_FEES_ALLOC','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['allocate\x20arbitration\x20fees\x20to\x20an\x20Allocation\x20object'],'common_patterns':['Destination:\x20Allocation\x20object\x20(parameterized\x20fund\x20distribution)','payment_remark\x20+\x20payment_index:\x20bookkeeping\x20for\x20Payment\x20object','May\x20create\x20new\x20Payment\x20object\x20if\x20newPayment\x20name\x20provided','Triggers\x20balance::withdraw_all\x20—\x20extracts\x20ALL\x20balance'],'recommended_templates':['T-AB-06']},{'id':'arbitration_fees_transfer','name':'Transfer\x20arbitration\x20fees\x20to\x20Treasury\x20object','operation_category':'fund','permission_index':0x16e,'permission_name':'ARBITRATION_FEES_TRANSFER','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['transfer\x20arbitration\x20fees\x20to\x20a\x20Treasury\x20object'],'common_patterns':['Destination:\x20Treasury\x20object\x20(general\x20fund\x20pool)','Same\x20bookkeeping\x20as\x20fee\x20allocation\x20(remark\x20+\x20index\x20+\x20newPayment)','Triggers\x20balance::withdraw_all\x20—\x20extracts\x20ALL\x20balance','Choose\x20Allocation\x20vs\x20Treasury\x20by\x20distribution\x20need'],'recommended_templates':['T-AB-06']},{'id':'arbitration_voting_guard_config','name':'Configure\x20voting_guard\x20list\x20(add\x20/\x20set\x20/\x20remove\x20/\x20clear)','operation_category':'guard','permission_index':0x162,'permission_name':'ARBITRATION_VOTING_GUARD','requires_voting_guard':'any','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['add\x20a\x20passport-identifier\x20voting\x20guard\x20(dynamic\x20weight)','add\x20a\x20fixed-weight\x20voting\x20guard','remove\x20a\x20voting\x20guard','clear\x20the\x20voting\x20guard\x20list'],'common_patterns':['Max\x2050\x20guards:\x20MAX_VOTING_GUARD_COUNT=50\x20(off-by-one-safe:\x20len<50\x20allows\x20add)','GuardIdentifier(u8):\x20dynamic\x20weight\x20from\x20Passport\x20submission\x20value','FixedValue(u32):\x20static\x20weight\x20(e.g.\x20100\x20votes\x20per\x20holder)','Add\x20same\x20guard\x20twice\x20→\x20updates\x20vote_weight\x20(no\x20duplicate)','op=\x27set\x27\x20=\x20clear\x20then\x20add;\x20op=\x27add\x27\x20=\x20append;\x20op=\x27remove\x27\x20=\x20by\x20address'],'recommended_templates':['T-AB-02','T-AB-03']},{'id':'arbitration_usage_guard_config','name':'Configure\x20usage_guard\x20(set\x20/\x20clear)','operation_category':'guard','permission_index':0x163,'permission_name':'ARBITRATION_USAGE_GUARD','requires_voting_guard':'not_applicable','requires_usage_guard':'any','has_passport_variant':!![],'governed_operations':['set\x20the\x20usage\x20guard\x20(restrict\x20who\x20can\x20file\x20disputes)','clear\x20the\x20usage\x20guard'],'common_patterns':['Single\x20guard\x20(Option<address>)\x20—\x20not\x20a\x20list','Some(guard):\x20the\x20dispute\x20must\x20go\x20through\x20passport\x20verification','None:\x20dispute\x20can\x20use\x20either\x20variant\x20(no\x20passport\x20needed)','object-linker\x20affiliation\x20change:\x20updates\x20link\x20when\x20guard\x20changes'],'recommended_templates':['T-AB-04']},{'id':'arbitration_pause','name':'Pause\x20/\x20resume\x20Arbitration\x20service','operation_category':'lifecycle','permission_index':0x164,'permission_name':'ARBITRATION_PAUSE','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['pause/resume\x20the\x20arbitration\x20service'],'common_patterns':['bPaused\x20default\x20true\x20—\x20new\x20Arbitration\x20cannot\x20accept\x20disputes','pause(false)\x20to\x20enable,\x20pause(true)\x20to\x20disable','Paused\x20Arbitration\x20rejects\x20dispute\x20(E_PAUSED)','Does\x20not\x20affect\x20already-open\x20Arb\x20cases'],'recommended_templates':['T-AB-01']},{'id':'arbitration_service_statement','name':'Service\x20(defendant)\x20appends\x20a\x20text\x20statement\x20to\x20the\x20case\x20record','operation_category':'dispute','permission_index':0x141,'permission_name':'SERVICE_ARB_STATEMENT','requires_voting_guard':'not_applicable','requires_usage_guard':'not_applicable','has_passport_variant':!![],'governed_operations':['append\x20the\x20seller\x27s\x20text\x20statement\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20the\x20service\x20(ArbStatementEvent)'],'common_patterns':['Defendant-side\x20voice\x20WITHOUT\x20holding\x20the\x20order\x20—\x20the\x20arb/arbitration\x20function\x20family\x20is\x20order-anchored;\x20this\x20entry\x20is\x20service-anchored','PRIMARY\x20evidence\x20channel\x20is\x20Messenger:\x20submit\x20encrypted\x20WTS\x20records\x20of\x20the\x20exchange\x20with\x20the\x20order\x20customer\x20first','This\x20statement\x20is\x20the\x20SECONDARY\x20channel:\x20declare\x20facts\x20or\x20report\x20customer\x20behavior\x20(absence,\x20non-cooperation)\x20on\x20the\x20case\x20record','Event-only:\x20nothing\x20on\x20the\x20Arb\x20object\x20is\x20mutated;\x20the\x20record\x20cannot\x20be\x20rewritten\x20or\x20deleted\x20by\x20any\x20party','Text\x20length\x20cap\x20identical\x20to\x20description/objection\x20(DESCRIPTION\x20bound,\x204000)'],'recommended_templates':[]}];export const ARBITRATION_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return ARBITRATION_SCENES['filter'](b=>b['operation_category']===a);}export function findSceneById(a){return ARBITRATION_SCENES['find'](b=>b['id']===a);}export function findSceneByPermissionIndex(a){return ARBITRATION_SCENES['find'](b=>b['permission_index']===a);}export function getPermissionByIndex(a){return ARBITRATION_PERMISSIONS['find'](b=>b['index']===a);}export function getPermissionByName(a){return ARBITRATION_PERMISSIONS['find'](b=>b['name']===a);}export function isReservedIndex(a){const b=getPermissionByIndex(a);return!!b?.['is_reserved'];}export function isUsedPermissionIndex(a){const b=getPermissionByIndex(a);return!!b&&!b['is_reserved'];}export function getActivePermissionCount(){return ARBITRATION_PERMISSIONS['filter'](a=>!a['is_reserved'])['length'];}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[{'keywords':['create','new'],'sceneId':'arbitration_create'},{'keywords':['dispute','file','complaint'],'sceneId':'arbitration_dispute'},{'keywords':['vote','voting','decide'],'sceneId':'arbitration_vote'},{'keywords':['confirm','materials'],'sceneId':'arbitration_confirm'},{'keywords':['feedback','opinion'],'sceneId':'arbitration_feedback'},{'keywords':['ruling','arbitration','verdict'],'sceneId':'arbitration_ruling'},{'keywords':['reset','resubmit'],'sceneId':'arbitration_reset'},{'keywords':['arb_withdraw','withdraw','withdraw\x20fees'],'sceneId':'arbitration_arb_withdraw'},{'keywords':['allocate','allocate\x20fees','fees\x20allocation'],'sceneId':'arbitration_fees_alloc'},{'keywords':['fees_transfer','transfer','transfer\x20in'],'sceneId':'arbitration_fees_transfer'},{'keywords':['voting_guard','voting\x20guard'],'sceneId':'arbitration_voting_guard_config'},{'keywords':['usage_guard','usage\x20guard'],'sceneId':'arbitration_usage_guard_config'},{'keywords':['pause','enable'],'sceneId':'arbitration_pause'}];for(const {keywords:d,sceneId:e}of c){if(d['some'](f=>b['includes'](f['toLowerCase']()))){const f=findSceneById(e);if(f)return f;}}return undefined;}export function getDualGuardMatrixEntry(a,b){return DUAL_GUARD_MATRIX['find'](c=>c['voting_guard_empty']===a&&c['usage_guard_empty']===b);}export function isValidArbStatusTransition(a,b){const c={'Principal_confirming':['Arbitrator_confirming'],'Arbitrator_confirming':['Voting','Principal_confirming'],'Voting':['Arbitrated'],'Arbitrated':['Objectionable','Finished','Withdrawn'],'Objectionable':['Principal_confirming'],'Finished':['Withdrawn'],'Withdrawn':[]};return c[a]?.['includes'](b)??![];}export function isTerminalArbStatus(a){return ARB_TERMINAL_STATUSES['includes'](a);}export function getScenesProducingStatus(a){return ARBITRATION_SCENES['filter'](b=>b['resulting_arb_status']===a);}export function getScenesRequiringStatus(a){return ARBITRATION_SCENES['filter'](b=>b['required_arb_status']?.['includes'](a));}export function getArbitrationScenesCount(){return ARBITRATION_SCENES['length'];}export function getAllArbitrationPermissions(){return[...ARBITRATION_PERMISSIONS];}export function getActiveArbitrationPermissions(){return ARBITRATION_PERMISSIONS['filter'](a=>!a['is_reserved']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook}from'../config/rule-engine.js';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const U8_MAX=0xff,U32_MAX=0xffffffff;export function arbitrationRiskFacts(a){const b=a['voting_guard'],c=!!b&&(b['op']==='add'||b['op']==='set'),d=c?b['op']==='set'?b['guards']['length']:(a['current_voting_guard_count']??0x0)+b['guards']['length']:undefined;let e,f;if(c)for(const
|
|
1
|
+
import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook}from'../config/rule-engine.js';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const U8_MAX=0xff,U32_MAX=0xffffffff;export function arbitrationRiskFacts(a){const b=a['voting_guard'],c=!!b&&(b['op']==='add'||b['op']==='set'),d=c?b['op']==='set'?b['guards']['length']:(a['current_voting_guard_count']??0x0)+b['guards']['length']:undefined;let e,f;if(c)for(const F of b['guards']){const G=F??{},H=G['vote_weight'];if(!H||typeof H!=='object')continue;if('GuardIdentifier'in H&&H['GuardIdentifier']!==undefined&&Number(H['GuardIdentifier'])>U8_MAX){e=Number(H['GuardIdentifier']);break;}if('FixedValue'in H&&H['FixedValue']!==undefined&&Number(H['FixedValue'])>U32_MAX){f=Number(H['FixedValue']);break;}}let h=![],i,j,k;if(c){const I=b['guards'];if(I['length']>=0x2){const J=I['filter'](K=>{const L=K?.['vote_weight'];return!!L&&typeof L==='object'&&'FixedValue'in L&&L['FixedValue']!==undefined;})['map'](K=>Number(K['vote_weight']['FixedValue']));if(J['length']>0x0){const K=J['reduce']((M,N)=>M+N,0x0),L=Math['max'](...J);K>0x0&&L/K>0.5&&(h=!![],i=L,j=K,k=(L/K*0x64)['toFixed'](0x1));}}}let l=![],m,n;if(a['dispute']&&a['current_arbitration_fee']!==undefined)try{const M=BigInt(a['current_arbitration_fee']),N=a['dispute']['fee'],O=typeof N==='object'&&N!==null&&'balance'in N?BigInt(N['balance']??0x0):BigInt(0x0);m=O['toString'](),n=M['toString'](),l=O<M;}catch{}const o=!!a['dispute'],p=a['confirm']?.['voting_deadline']??a['voting_deadline_change']?.['voting_deadline'],q=a['current_timestamp_ms'],r=p!==undefined&&p!==null&&q!==undefined&&p<q,s=a['vote']?.['voting_guard'],t=a['current_voting_guard_addresses'],u=!t||t['length']===0x0,v=!!a['vote'],x=a['current_arb_status'],y=a['expected_arb_status'],z=!!x&&!!y&&x!==y&&!isValidArbStatusTransition(x,y),A=!!x&&isTerminalArbStatus(x),B=A&&!a['arb_withdraw']&&!!(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']),C=a['reset']?String(a['reset']['arb']):undefined;let D,E;if(a['fees_transfer']){const P=a['fees_transfer']['to']??{};D='allocation'in P?'Allocation\x20'+P['allocation']:'Treasury\x20'+P['treasury'],E=String(a['fees_transfer']['payment_remark']);}return{'voting_guard_add_set':c,'voting_guard_new_count':d,'max_voting_guard_count':MAX_VOTING_GUARD_COUNT,'voting_guard_count_exceeded':d!==undefined&&d>MAX_VOTING_GUARD_COUNT,'weight_guard_identifier_over':e!==undefined,'weight_guard_identifier_value':e,'weight_fixed_over':f!==undefined,'weight_fixed_value':f,'weight_collusion_dominant':h,'weight_max':i,'weight_total':j,'weight_ratio_pct':k,'dispute_present':o,'dispute_fee_insufficient':l,'dispute_fee_provided':m,'arbitration_fee_required':n,'current_bPaused':a['current_bPaused'],'voting_deadline_selected':p??undefined,'current_timestamp_ms':q,'voting_deadline_in_past':r,'vote_voting_guard':s,'voting_guard_list_empty':u,'vote_present':v,'vote_guard_registered':!u&&s!==undefined?t['includes'](s):![],'registered_voting_guards':!u?t['join'](','):undefined,'builder':a['builder'],'arbitration_op_present':!!a['arbitration'],'current_arb_status':x,'expected_arb_status':y,'arb_transition_invalid':z,'arb_status_terminal':A,'arb_terminal_op_blocked':B,'reset_present':!!a['reset'],'reset_arb':C,'fees_transfer_present':!!a['fees_transfer'],'fees_transfer_dest':D,'fees_transfer_remark':E,'dispute_order':a['dispute']?String(a['dispute']['order']):undefined};}function arbitrationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['arbitration'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27arbitration\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function findingToArbitrationRisk(a){return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ARBITRATION_RISK_VERSION='1.0.0';export function getAllRiskRules(){const a=factoryRulePack('arbitration');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const {findings:d}=evaluateRuleBook([b],arbitrationRiskFacts(c));return d['length']>0x0?findingToArbitrationRisk(d[0x0]):null;}}));}export function assessArbitrationRisks(a){const {findings:b}=evaluateRuleBook(arbitrationRuleBook(),arbitrationRiskFacts(a)),c=b['map'](findingToArbitrationRisk),d=c['length']===0x0?'low':c['some'](g=>g['level']==='critical')?'critical':c['some'](g=>g['level']==='high')?'high':c['some'](g=>g['level']==='medium')?'medium':'low',e={};for(const g of c){e[g['category']]=(e[g['category']]??0x0)+0x1;}const f={};for(const h of c){for(const i of h['affected_stakeholders']){if(!f[i])f[i]=[];f[i]['push'](h['id']+':\x20'+h['mitigation']);}}return{'summary':'Assessed\x20'+c['length']+'\x20risk(s)\x20across\x20'+Object['keys'](e)['length']+'\x20categories','risks':c,'overall_risk':d,'risks_by_category':e,'stakeholder_advice':f,'needs_human_review':c['some'](j=>j['level']==='critical'||j['level']==='high')};}
|
|
@@ -16,6 +16,7 @@ export interface ArbitrationTemplate {
|
|
|
16
16
|
body: (params: Record<string, string | number | string[] | object>) => object;
|
|
17
17
|
notes?: string[];
|
|
18
18
|
}
|
|
19
|
+
export declare const ARBITRATION_ACTIVATION_NOTES: string[];
|
|
19
20
|
export declare const ARBITRATION_TEMPLATES: ArbitrationTemplate[];
|
|
20
21
|
export declare const ARBITRATION_TEMPLATES_VERSION = "1.0.0";
|
|
21
22
|
export declare function getAllTemplates(): ArbitrationTemplate[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ARBITRATION_TEMPLATES=[{'id':'T-AB-01','name':'Single-arbiter\x20quick\x20ruling','description':'Simplest\x20Arbitration:\x20one\x20arbiter\x20makes\x20all\x20rulings.\x20voting_guard\x20empty\x20(open\x20vote,\x20but\x20only\x20arbiter\x20has\x20358\x20perm).\x20Suitable\x20for\x20small-scale\x20/\x20fast\x20dispute\x20resolution.','applicable_scenes':['arbitration_create','arbitration_ruling','arbitration_confirm'],'industry_tags':['retail','freelance','small_business'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner\x20(also\x20admin)','required':!![]},{'name':'arbiter_address','type':'address','description':'Single\x20arbiter\x20address\x20(gets\x20ARBITRATION_VOTE=358\x20+\x20ARBITRATION_ARBITRATION=359)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type\x20for\x20arbitration\x20fee\x20(e.g.\x200x2::wow::WOW)','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20application\x20fee\x20(u64,\x20in\x20Coin\x20base\x20units)','required':![],'default':0x0},{'name':'arbitration_name','type':'string','description':'Local\x20name\x20for\x20the\x20Arbitration\x20object','required':![]}],'body':a=>({'object':{'name':a['arbitration_name']??'single_arb_arbitration','type_parameter':a['coin_type'],'permission':{'name':(a['arbitration_name']??'single_arb')+'_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x0),'pause':![]}),'notes':['voting_guard\x20remains\x20empty\x20→\x20vote()\x20uses\x20open\x20vote\x20(1\x20person\x201\x20vote)','Only\x20arbiter_address\x20should\x20be\x20granted\x20ARBITRATION_VOTE\x20(358)\x20+\x20ARBITRATION_ARBITRATION\x20(359)','Fast\x20ruling:\x20arbiter\x20confirms\x20materials\x20→\x20votes\x20→\x20makes\x20ruling\x20in\x20one\x20session','Not\x20suitable\x20for\x20high-value\x20disputes\x20(no\x20consensus\x20check)']},{'id':'T-AB-02','name':'Multi-arbiter\x20voting\x20(weighted)','description':'Multiple\x20arbiters\x20vote\x20with\x20weighted\x20voting_guard.\x20Each\x20arbiter\x27s\x20Guard\x20has\x20FixedValue\x20weight.\x20Ruling\x20requires\x20majority\x20weight.','applicable_scenes':['arbitration_create','arbitration_vote','arbitration_voting_guard_config'],'industry_tags':['governance','dao','committee'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'arbiter_guards','type':'string[]','description':'Guard\x20addresses\x20for\x20each\x20arbiter\x20(will\x20be\x20added\x20to\x20voting_guard)','required':!![]},{'name':'vote_weights','type':'string[]','description':'FixedValue\x20weights\x20for\x20each\x20arbiter\x20(parallel\x20to\x20arbiter_guards)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee','required':![],'default':0x0}],'body':a=>{const b=a['arbiter_guards']['map']((c,d)=>({'guard':c,'vote_weight':{'FixedValue':Number(a['vote_weights'][d]??0x1)}}));return{'object':{'name':'weighted_arbitration','type_parameter':a['coin_type'],'permission':{'name':'weighted_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x0),'pause':![],'voting_guard':{'op':'set','guards':b}};},'notes':['voting_guard\x20non-empty\x20→\x20votes\x20MUST\x20be\x20submitted\x20via\x20the\x20Passport-verified\x20voting\x20path','Each\x20arbiter\x27s\x20Guard\x20must\x20be\x20a\x20valid\x20Guard\x20object\x20they\x20can\x20submit\x20Passport\x20for','Consider:\x20max(arbiter_weights)\x20/\x20total_weights\x20<\x200.5\x20to\x20avoid\x20collusion\x20(see\x20R-AB-3-01)','Max\x2050\x20voting_guards\x20(MAX_VOTING_GUARD_COUNT)']},{'id':'T-AB-03','name':'Public\x20voting\x20arbitration','description':'voting_guard\x20allows\x20public\x20to\x20vote\x20(anyone\x20with\x20a\x20Guard\x20can\x20vote).\x20Suitable\x20for\x20community-driven\x20dispute\x20resolution.','applicable_scenes':['arbitration_create','arbitration_vote','arbitration_voting_guard_config'],'industry_tags':['community','public_goods','social'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'public_guard','type':'address','description':'Guard\x20address\x20anyone\x20can\x20submit\x20Passport\x20for\x20(e.g.\x20based\x20on\x20account\x20existence)','required':!![]},{'name':'vote_weight','type':'number','description':'FixedValue\x20weight\x20per\x20public\x20voter\x20(e.g.\x201)','required':![],'default':0x1},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]}],'body':a=>({'object':{'name':'public_arbitration','type_parameter':a['coin_type'],'permission':{'name':'public_arb_permission'}},'description':a['description'],'fee':'0','pause':![],'voting_guard':{'op':'set','guards':[{'guard':a['public_guard'],'vote_weight':{'FixedValue':Number(a['vote_weight']??0x1)}}]}}),'notes':['Public\x20voting:\x20anyone\x20holding\x20the\x20public_guard\x20can\x20vote','Consider\x20using\x20GuardIdentifier\x20(dynamic\x20weight)\x20for\x20token-weighted\x20voting','Low/zero\x20fee\x20to\x20encourage\x20participation\x20—\x20but\x20watch\x20for\x20spam\x20disputes','Suitable\x20for\x20community\x20moderation,\x20content\x20disputes,\x20public\x20goods\x20arbitration']},{'id':'T-AB-04','name':'Scope-restricted\x20arbitration','description':'usage_guard\x20filters\x20which\x20disputes\x20can\x20be\x20filed.\x20Only\x20users\x20passing\x20the\x20Guard\x20can\x20file\x20disputes.\x20Suitable\x20for\x20verified-merchant\x20/\x20KYC\x20arbitration.','applicable_scenes':['arbitration_create','arbitration_usage_guard_config','arbitration_dispute'],'industry_tags':['kyc','verified_merchant','enterprise'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'usage_guard_address','type':'address','description':'Guard\x20address\x20that\x20filters\x20who\x20can\x20file\x20disputes\x20(KYC/verification)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'arbiter_address','type':'address','description':'Arbiter\x20address\x20(single\x20arbiter\x20for\x20simplicity)','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(higher\x20to\x20deter\x20spam)','required':![],'default':0x3b9aca00}],'body':a=>({'object':{'name':'restricted_arbitration','type_parameter':a['coin_type'],'permission':{'name':'restricted_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x3b9aca00),'pause':![],'usage_guard':a['usage_guard_address']}),'notes':['usage_guard\x20set\x20→\x20disputes\x20MUST\x20be\x20filed\x20via\x20the\x20Passport-verified\x20dispute\x20variant','Guard\x20verifies:\x20KYC\x20/\x20membership\x20/\x20token-balance\x20/\x20etc.','Higher\x20fee\x20(default\x201\x20WOW)\x20to\x20deter\x20spam\x20from\x20verified\x20users','Arbiter\x20should\x20also\x20be\x20Guard-verified\x20for\x20consistency']},{'id':'T-AB-05','name':'Arbitration\x20committee','description':'Multi-arbiter\x20committee\x20with\x20weighted\x20voting\x20+\x20usage_guard.\x20Most\x20controlled\x20configuration\x20—\x20restricted\x20dispute\x20filing\x20+\x20weighted\x20voting\x20+\x20multi-arbiter\x20ruling.','applicable_scenes':['arbitration_create','arbitration_voting_guard_config','arbitration_usage_guard_config','arbitration_ruling'],'industry_tags':['enterprise','legal','high_value'],'params':[{'name':'owner_address','type':'address','description':'Committee\x20owner','required':!![]},{'name':'committee_guards','type':'string[]','description':'Guard\x20addresses\x20for\x20each\x20committee\x20member','required':!![]},{'name':'member_weights','type':'string[]','description':'Vote\x20weights\x20for\x20each\x20member\x20(parallel\x20to\x20committee_guards)','required':!![]},{'name':'membership_guard','type':'address','description':'usage_guard\x20for\x20dispute\x20filing\x20(membership\x20verification)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(high\x20for\x20high-value\x20disputes)','required':![],'default':0x2540be400}],'body':a=>{const b=a['committee_guards']['map']((c,d)=>({'guard':c,'vote_weight':{'FixedValue':Number(a['member_weights'][d]??0x1)}}));return{'object':{'name':'committee_arbitration','type_parameter':a['coin_type'],'permission':{'name':'committee_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x2540be400),'pause':![],'voting_guard':{'op':'set','guards':b},'usage_guard':a['membership_guard']};},'notes':['Most\x20restrictive\x20config:\x20weighted\x20voting\x20+\x20restricted\x20filing','Suitable\x20for\x20high-value\x20B2B\x20disputes,\x20legal\x20arbitration,\x20enterprise\x20SLA\x20enforcement','Committee\x20members\x20should\x20have\x20clear\x20escalation\x20/\x20tiebreaker\x20rules','All\x20disputes\x20require\x20Passport\x20(both\x20filing\x20and\x20voting)']},{'id':'T-AB-06','name':'Fee-split\x20arbitration','description':'Pre-configured\x20fee-distribution\x20destination.\x20After\x20the\x20fee\x20withdrawal\x20(364),\x20fees\x20are\x20automatically\x20distributed\x20to\x20the\x20Allocation\x20(for\x20arbiter\x20compensation).','applicable_scenes':['arbitration_create','arbitration_arb_withdraw','arbitration_fees_alloc'],'industry_tags':['marketplace','service','platform'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'allocation_address','type':'address','description':'Allocation\x20object\x20address\x20for\x20fee\x20distribution\x20to\x20arbiters','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'arbiter_address','type':'address','description':'Arbiter\x20(single\x20for\x20simplicity)','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(will\x20be\x20split\x20to\x20arbiters\x20via\x20Allocation)','required':![],'default':0x12a05f200}],'body':a=>({'object':{'name':'feesplit_arbitration','type_parameter':a['coin_type'],'permission':{'name':'feesplit_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x12a05f200),'pause':![]}),'notes':['Fee-split\x20is\x20a\x202-step\x20process:\x20withdraw\x20fees\x20from\x20the\x20Arb\x20object\x20(364)\x20→\x20transfer\x20them\x20out\x20of\x20the\x20Arbitration\x20balance\x20(365/366)','Fee\x20withdrawal\x20(364)\x20moves\x20fees\x20from\x20the\x20Arb\x20object\x20into\x20the\x20Arbitration\x20balance','Fee\x20distribution\x20(365)\x20or\x20the\x20balance\x20transfer\x20(366)\x20moves\x20fees\x20to\x20the\x20Allocation/Treasury','Allocation\x20policy\x20determines\x20how\x20fees\x20are\x20split\x20among\x20arbiters','Payment\x20object\x20is\x20created\x20for\x20bookkeeping\x20(payment_remark\x20+\x20payment_index)']},{'id':'T-AB-07','name':'Appeal\x20arbitration\x20(reset\x20flow)','description':'Template\x20for\x20reset\x20operation\x20—\x20disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials.\x20Restarts\x20Arb\x20lifecycle\x20from\x20Principal_confirming.','applicable_scenes':['arbitration_reset','arbitration_ruling'],'industry_tags':['legal','appeal','high_value'],'params':[{'name':'arbitration_object','type':'address','description':'Existing\x20Arbitration\x20object\x20address','required':!![]},{'name':'arb_address','type':'address','description':'Arb\x20object\x20address\x20to\x20reset\x20(must\x20be\x20in\x20Objectionable/Arbitrated\x20status)','required':!![]},{'name':'reset_feedback','type':'string','description':'Feedback\x20explaining\x20why\x20disputant\x20objects\x20to\x20the\x20ruling','required':!![]}],'body':a=>({'object':a['arbitration_object'],'reset':{'arb':a['arb_address'],'feedback':a['reset_feedback']}}),'notes':['Precondition:\x20Arb\x20must\x20be\x20in\x20Objectionable\x20(4)\x20or\x20Arbitrated\x20(3)\x20status','Post-condition:\x20Arb\x20status\x20→\x20Principal_confirming\x20(0),\x20lifecycle\x20restarts','Original\x20ruling\x20is\x20invalidated\x20—\x20new\x20voting\x20+\x20ruling\x20required','Consider\x20capping\x20reset\x20count\x20to\x20prevent\x20infinite\x20appeals','reset\x20feedback\x20is\x20permanent\x20—\x20recorded\x20on-chain\x20for\x20audit\x20trail']}];export const ARBITRATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ARBITRATION_TEMPLATES];}export function getTemplateById(a){return ARBITRATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ARBITRATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ARBITRATION_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 ARBITRATION_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']};}return{'ok':!![],'body':c['body'](b)};}
|
|
1
|
+
export const ARBITRATION_ACTIVATION_NOTES=['ACTIVATION:\x20a\x20newly\x20created\x20Arbitration\x20is\x20born\x20PAUSED\x20(bPaused=true).\x20This\x20template\x20passes\x20pause:false\x20in\x20the\x20create\x20payload\x20to\x20unpause\x20in\x20the\x20SAME\x20transaction\x20(the\x20creator\x20is\x20an\x20admin\x20of\x20the\x20new\x20Permission,\x20so\x20the\x20356\x20check\x20passes).\x20If\x20the\x20unpause\x20is\x20skipped,\x20no\x20dispute\x20can\x20be\x20filed\x20(E_PAUSED)\x20until\x20a\x20separate\x20{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20pause:false}}\x20is\x20issued.','PERMISSIONS:\x20a\x20freshly\x20created\x20Arbitration\x20has\x20an\x20EMPTY\x20permission\x20table\x20—\x20every\x20operation\x20aborts\x20with\x20\x27Missing\x20permission\x27\x20(code\x205)\x20until\x20grants\x20are\x20issued\x20via\x20its\x20Permission\x20object:\x20356\x20(pause/unpause),\x20358\x20(vote),\x20359\x20(issue\x20ruling),\x20361\x20(arbitrator\x20material\x20confirm),\x20plus\x20357/362/363/364-368\x20(fee\x20/\x20deadline\x20/\x20reset\x20/\x20withdraw\x20/\x20receive).','OPEN\x20VOTE\x20IS\x20NOT\x20PERMISSIONLESS:\x20an\x20empty\x20voting_guard\x20means\x20EQUAL\x20WEIGHT\x20(1\x20person\x201\x20vote),\x20but\x20vote()\x20still\x20asserts\x20ARBITRATION_VOTE=358\x20—\x20\x27anyone\x20can\x20vote\x27\x20requires\x20granting\x20358\x20to\x20the\x20intended\x20voters\x20first.'];export const ARBITRATION_TEMPLATES=[{'id':'T-AB-01','name':'Single-arbiter\x20quick\x20ruling','description':'Simplest\x20Arbitration:\x20one\x20arbiter\x20makes\x20all\x20rulings.\x20voting_guard\x20empty\x20(open\x20vote,\x20but\x20only\x20arbiter\x20has\x20358\x20perm).\x20Suitable\x20for\x20small-scale\x20/\x20fast\x20dispute\x20resolution.','applicable_scenes':['arbitration_create','arbitration_ruling','arbitration_confirm'],'industry_tags':['retail','freelance','small_business'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner\x20(also\x20admin)','required':!![]},{'name':'arbiter_address','type':'address','description':'Single\x20arbiter\x20address\x20(gets\x20ARBITRATION_VOTE=358\x20+\x20ARBITRATION_ARBITRATION=359)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type\x20for\x20arbitration\x20fee\x20(e.g.\x200x2::wow::WOW)','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20application\x20fee\x20(u64,\x20in\x20Coin\x20base\x20units)','required':![],'default':0x0},{'name':'arbitration_name','type':'string','description':'Local\x20name\x20for\x20the\x20Arbitration\x20object','required':![]}],'body':a=>({'object':{'name':a['arbitration_name']??'single_arb_arbitration','type_parameter':a['coin_type'],'permission':{'name':(a['arbitration_name']??'single_arb')+'_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x0),'pause':![]}),'notes':['voting_guard\x20remains\x20empty\x20→\x20vote()\x20uses\x20open\x20vote\x20(1\x20person\x201\x20vote)','Only\x20arbiter_address\x20should\x20be\x20granted\x20ARBITRATION_VOTE\x20(358)\x20+\x20ARBITRATION_ARBITRATION\x20(359)','Fast\x20ruling:\x20arbiter\x20confirms\x20materials\x20→\x20votes\x20→\x20makes\x20ruling\x20in\x20one\x20session','Not\x20suitable\x20for\x20high-value\x20disputes\x20(no\x20consensus\x20check)',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-02','name':'Multi-arbiter\x20voting\x20(weighted)','description':'Multiple\x20arbiters\x20vote\x20with\x20weighted\x20voting_guard.\x20Each\x20arbiter\x27s\x20Guard\x20has\x20FixedValue\x20weight.\x20Ruling\x20requires\x20majority\x20weight.','applicable_scenes':['arbitration_create','arbitration_vote','arbitration_voting_guard_config'],'industry_tags':['governance','dao','committee'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'arbiter_guards','type':'string[]','description':'Guard\x20addresses\x20for\x20each\x20arbiter\x20(will\x20be\x20added\x20to\x20voting_guard)','required':!![]},{'name':'vote_weights','type':'string[]','description':'FixedValue\x20weights\x20for\x20each\x20arbiter\x20(parallel\x20to\x20arbiter_guards)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee','required':![],'default':0x0}],'body':a=>{const b=a['arbiter_guards']['map']((c,d)=>({'guard':c,'vote_weight':{'FixedValue':Number(a['vote_weights'][d]??0x1)}}));return{'object':{'name':'weighted_arbitration','type_parameter':a['coin_type'],'permission':{'name':'weighted_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x0),'pause':![],'voting_guard':{'op':'set','guards':b}};},'notes':['voting_guard\x20non-empty\x20→\x20votes\x20MUST\x20be\x20submitted\x20via\x20the\x20Passport-verified\x20voting\x20path','Each\x20arbiter\x27s\x20Guard\x20must\x20be\x20a\x20valid\x20Guard\x20object\x20they\x20can\x20submit\x20Passport\x20for','Consider:\x20max(arbiter_weights)\x20/\x20total_weights\x20<\x200.5\x20to\x20avoid\x20collusion\x20(see\x20R-AB-3-01)','Max\x2050\x20voting_guards\x20(MAX_VOTING_GUARD_COUNT)',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-03','name':'Public\x20voting\x20arbitration','description':'voting_guard\x20allows\x20public\x20to\x20vote\x20(anyone\x20with\x20a\x20Guard\x20can\x20vote).\x20Suitable\x20for\x20community-driven\x20dispute\x20resolution.','applicable_scenes':['arbitration_create','arbitration_vote','arbitration_voting_guard_config'],'industry_tags':['community','public_goods','social'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'public_guard','type':'address','description':'Guard\x20address\x20anyone\x20can\x20submit\x20Passport\x20for\x20(e.g.\x20based\x20on\x20account\x20existence)','required':!![]},{'name':'vote_weight','type':'number','description':'FixedValue\x20weight\x20per\x20public\x20voter\x20(e.g.\x201)','required':![],'default':0x1},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]}],'body':a=>({'object':{'name':'public_arbitration','type_parameter':a['coin_type'],'permission':{'name':'public_arb_permission'}},'description':a['description'],'fee':'0','pause':![],'voting_guard':{'op':'set','guards':[{'guard':a['public_guard'],'vote_weight':{'FixedValue':Number(a['vote_weight']??0x1)}}]}}),'notes':['Public\x20voting:\x20anyone\x20holding\x20the\x20public_guard\x20can\x20vote','Consider\x20using\x20GuardIdentifier\x20(dynamic\x20weight)\x20for\x20token-weighted\x20voting','Low/zero\x20fee\x20to\x20encourage\x20participation\x20—\x20but\x20watch\x20for\x20spam\x20disputes','Suitable\x20for\x20community\x20moderation,\x20content\x20disputes,\x20public\x20goods\x20arbitration',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-04','name':'Scope-restricted\x20arbitration','description':'usage_guard\x20filters\x20which\x20disputes\x20can\x20be\x20filed.\x20Only\x20users\x20passing\x20the\x20Guard\x20can\x20file\x20disputes.\x20Suitable\x20for\x20verified-merchant\x20/\x20KYC\x20arbitration.','applicable_scenes':['arbitration_create','arbitration_usage_guard_config','arbitration_dispute'],'industry_tags':['kyc','verified_merchant','enterprise'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'usage_guard_address','type':'address','description':'Guard\x20address\x20that\x20filters\x20who\x20can\x20file\x20disputes\x20(KYC/verification)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'arbiter_address','type':'address','description':'Arbiter\x20address\x20(single\x20arbiter\x20for\x20simplicity)','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(higher\x20to\x20deter\x20spam)','required':![],'default':0x3b9aca00}],'body':a=>({'object':{'name':'restricted_arbitration','type_parameter':a['coin_type'],'permission':{'name':'restricted_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x3b9aca00),'pause':![],'usage_guard':a['usage_guard_address']}),'notes':['usage_guard\x20set\x20→\x20disputes\x20MUST\x20be\x20filed\x20via\x20the\x20Passport-verified\x20dispute\x20variant','Guard\x20verifies:\x20KYC\x20/\x20membership\x20/\x20token-balance\x20/\x20etc.','Higher\x20fee\x20(default\x201\x20WOW)\x20to\x20deter\x20spam\x20from\x20verified\x20users','Arbiter\x20should\x20also\x20be\x20Guard-verified\x20for\x20consistency',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-05','name':'Arbitration\x20committee','description':'Multi-arbiter\x20committee\x20with\x20weighted\x20voting\x20+\x20usage_guard.\x20Most\x20controlled\x20configuration\x20—\x20restricted\x20dispute\x20filing\x20+\x20weighted\x20voting\x20+\x20multi-arbiter\x20ruling.','applicable_scenes':['arbitration_create','arbitration_voting_guard_config','arbitration_usage_guard_config','arbitration_ruling'],'industry_tags':['enterprise','legal','high_value'],'params':[{'name':'owner_address','type':'address','description':'Committee\x20owner','required':!![]},{'name':'committee_guards','type':'string[]','description':'Guard\x20addresses\x20for\x20each\x20committee\x20member','required':!![]},{'name':'member_weights','type':'string[]','description':'Vote\x20weights\x20for\x20each\x20member\x20(parallel\x20to\x20committee_guards)','required':!![]},{'name':'membership_guard','type':'address','description':'usage_guard\x20for\x20dispute\x20filing\x20(membership\x20verification)','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(high\x20for\x20high-value\x20disputes)','required':![],'default':0x2540be400}],'body':a=>{const b=a['committee_guards']['map']((c,d)=>({'guard':c,'vote_weight':{'FixedValue':Number(a['member_weights'][d]??0x1)}}));return{'object':{'name':'committee_arbitration','type_parameter':a['coin_type'],'permission':{'name':'committee_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x2540be400),'pause':![],'voting_guard':{'op':'set','guards':b},'usage_guard':a['membership_guard']};},'notes':['Most\x20restrictive\x20config:\x20weighted\x20voting\x20+\x20restricted\x20filing','Suitable\x20for\x20high-value\x20B2B\x20disputes,\x20legal\x20arbitration,\x20enterprise\x20SLA\x20enforcement','Committee\x20members\x20should\x20have\x20clear\x20escalation\x20/\x20tiebreaker\x20rules','All\x20disputes\x20require\x20Passport\x20(both\x20filing\x20and\x20voting)',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-06','name':'Fee-split\x20arbitration','description':'Pre-configured\x20fee-distribution\x20destination.\x20After\x20the\x20fee\x20withdrawal\x20(364),\x20fees\x20are\x20automatically\x20distributed\x20to\x20the\x20Allocation\x20(for\x20arbiter\x20compensation).','applicable_scenes':['arbitration_create','arbitration_arb_withdraw','arbitration_fees_alloc'],'industry_tags':['marketplace','service','platform'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'allocation_address','type':'address','description':'Allocation\x20object\x20address\x20for\x20fee\x20distribution\x20to\x20arbiters','required':!![]},{'name':'coin_type','type':'string','description':'Coin\x20type','required':!![]},{'name':'description','type':'string','description':'Arbitration\x20description','required':!![]},{'name':'arbiter_address','type':'address','description':'Arbiter\x20(single\x20for\x20simplicity)','required':!![]},{'name':'fee_amount','type':'number','description':'Dispute\x20fee\x20(will\x20be\x20split\x20to\x20arbiters\x20via\x20Allocation)','required':![],'default':0x12a05f200}],'body':a=>({'object':{'name':'feesplit_arbitration','type_parameter':a['coin_type'],'permission':{'name':'feesplit_arb_permission'}},'description':a['description'],'fee':String(a['fee_amount']??0x12a05f200),'pause':![]}),'notes':['Fee-split\x20is\x20a\x202-step\x20process:\x20withdraw\x20fees\x20from\x20the\x20Arb\x20object\x20(364)\x20→\x20transfer\x20them\x20out\x20of\x20the\x20Arbitration\x20balance\x20(365/366)','Fee\x20withdrawal\x20(364)\x20moves\x20fees\x20from\x20the\x20Arb\x20object\x20into\x20the\x20Arbitration\x20balance','Fee\x20distribution\x20(365)\x20or\x20the\x20balance\x20transfer\x20(366)\x20moves\x20fees\x20to\x20the\x20Allocation/Treasury','Allocation\x20policy\x20determines\x20how\x20fees\x20are\x20split\x20among\x20arbiters','Payment\x20object\x20is\x20created\x20for\x20bookkeeping\x20(payment_remark\x20+\x20payment_index)',...ARBITRATION_ACTIVATION_NOTES]},{'id':'T-AB-07','name':'Appeal\x20arbitration\x20(reset\x20flow)','description':'Template\x20for\x20reset\x20operation\x20—\x20disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials.\x20Restarts\x20Arb\x20lifecycle\x20from\x20Principal_confirming.','applicable_scenes':['arbitration_reset','arbitration_ruling'],'industry_tags':['legal','appeal','high_value'],'params':[{'name':'arbitration_object','type':'address','description':'Existing\x20Arbitration\x20object\x20address','required':!![]},{'name':'arb_address','type':'address','description':'Arb\x20object\x20address\x20to\x20reset\x20(must\x20be\x20in\x20Objectionable/Arbitrated\x20status)','required':!![]},{'name':'reset_feedback','type':'string','description':'Feedback\x20explaining\x20why\x20disputant\x20objects\x20to\x20the\x20ruling','required':!![]}],'body':a=>({'object':a['arbitration_object'],'reset':{'arb':a['arb_address'],'feedback':a['reset_feedback']}}),'notes':['Precondition:\x20Arb\x20must\x20be\x20in\x20Objectionable\x20(4)\x20or\x20Arbitrated\x20(3)\x20status','Post-condition:\x20Arb\x20status\x20→\x20Principal_confirming\x20(0),\x20lifecycle\x20restarts','Original\x20ruling\x20is\x20invalidated\x20—\x20new\x20voting\x20+\x20ruling\x20required','Consider\x20capping\x20reset\x20count\x20to\x20prevent\x20infinite\x20appeals','reset\x20feedback\x20is\x20permanent\x20—\x20recorded\x20on-chain\x20for\x20audit\x20trail']}];export const ARBITRATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ARBITRATION_TEMPLATES];}export function getTemplateById(a){return ARBITRATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ARBITRATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ARBITRATION_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 ARBITRATION_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']};}return{'ok':!![],'body':c['body'](b)};}
|
|
@@ -19,13 +19,24 @@ export interface AuditContext {
|
|
|
19
19
|
graph?: {
|
|
20
20
|
findDanglingDependencies: () => string[];
|
|
21
21
|
};
|
|
22
|
-
hasName?: boolean;
|
|
23
22
|
userConfirmed?: boolean;
|
|
24
23
|
}
|
|
24
|
+
export declare function salesItemsOf(d: any): any[];
|
|
25
|
+
export declare function allocatorCountOf(d: any): number;
|
|
26
|
+
export declare function arbitrationRefsOf(d: any): string[];
|
|
27
|
+
export declare function compensationFundOf(d: any): unknown;
|
|
28
|
+
export declare function serviceNameOf(d: any): string | undefined;
|
|
29
|
+
export declare function typeParameterOf(d: any): string | undefined;
|
|
30
|
+
export declare const ANTI_PATTERN_NODE_REGEX: RegExp;
|
|
31
|
+
export interface MachineNodeAudit {
|
|
32
|
+
critical: string[];
|
|
33
|
+
warnings: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function auditMachineNodes(nodes: unknown[]): MachineNodeAudit;
|
|
25
36
|
export declare const AUDIT_RULES: AuditRule[];
|
|
26
37
|
export declare function auditService(data: any, context?: AuditContext): AuditFinding[];
|
|
27
38
|
export declare function hasBlockingErrors(findings: AuditFinding[]): boolean;
|
|
28
39
|
export declare function getErrors(findings: AuditFinding[]): AuditFinding[];
|
|
29
40
|
export declare function getWarnings(findings: AuditFinding[]): AuditFinding[];
|
|
30
41
|
export declare function summarizeFindings(findings: AuditFinding[]): string;
|
|
31
|
-
export declare const AUDIT_RULES_VERSION =
|
|
42
|
+
export declare const AUDIT_RULES_VERSION = 3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AUDIT_RULES=[{'id':'audit_machine_bound','description':'Service\x20should\x20have\x20a\x20Machine\x20workflow\x20bound\x20before\x20publish','severity':'warning','fields':['machine'],'check':(a,b)=>{if(!a?.['publish'])return!![];return!!a?.['machine'];},'message':()=>'Publishing\x20a\x20service\x20without\x20a\x20Machine\x20workflow.\x20Customers\x20won\x27t\x20have\x20a\x20structured\x20order\x20process.','recommendation':'Create\x20a\x20Machine\x20(workflow\x20template)\x20and\x20bind\x20it\x20to\x20the\x20service\x20before\x20publishing.\x20The\x20machine\x20field\x20becomes\x20IMMUTABLE\x20after\x20publish.'},{'id':'audit_order_allocators','description':'Service\x20should\x20have\x20order_allocators\x20for\x20fund\x20distribution','severity':'warning','fields':['order_allocators'],'check':a=>{if(!a?.['publish'])return!![];return Array['isArray'](a?.['order_allocators'])&&a['order_allocators']['length']>0x0;},'message':()=>'Publishing\x20a\x20service\x20without\x20order_allocators.\x20Order\x20funds\x20cannot\x20be\x20auto-distributed\x20to\x20suppliers.','recommendation':'Configure\x20order_allocators\x20before\x20publishing\x20—\x20this\x20field\x20becomes\x20IMMUTABLE\x20after\x20publish.'},{'id':'audit_buy_guard','description':'Service\x20should\x20have\x20a\x20buy_guard\x20for\x20customer\x20screening','severity':'info','fields':['buy_guard'],'check':a=>!!a?.['buy_guard'],'message':()=>'No\x20buy_guard\x20configured\x20—\x20anyone\x20can\x20purchase\x20this\x20service\x20without\x20verification.','recommendation':'Consider\x20adding\x20a\x20Guard\x20to\x20verify\x20customer\x20eligibility\x20(e.g.,\x20identity,\x20wallet\x20balance,\x20location).'},{'id':'audit_compensation_fund','description':'Service\x20should\x20have\x20a\x20compensation_fund\x20for\x20trust','severity':'warning','fields':['compensation_fund'],'check':a=>!!a?.['compensation_fund'],'message':()=>'No\x20compensation_fund\x20configured.\x20Customers\x20have\x20no\x20financial\x20protection\x20if\x20you\x20fail\x20to\x20deliver.','recommendation':'Lock\x20a\x20compensation_fund\x20(Treasury)\x20to\x20build\x20trust.\x20The\x20fund\x20deters\x20fraud\x20and\x20enables\x20arbitration\x20claims.'},{'id':'audit_arbitrations','description':'Service\x20should\x20have\x20arbitration\x20options\x20for\x20dispute\x20resolution','severity':'info','fields':['arbitrations'],'check':a=>Array['isArray'](a?.['arbitrations'])&&a['arbitrations']['length']>0x0,'message':()=>'No\x20arbitration\x20configured.\x20Disputes\x20cannot\x20be\x20resolved\x20through\x20a\x20third\x20party.','recommendation':'Add\x20at\x20least\x20one\x20Arb\x20object\x20to\x20enable\x20on-chain\x20dispute\x20resolution.'},{'id':'audit_price','description':'Service\x20should\x20have\x20a\x20price\x20set','severity':'error','fields':['price'],'check':a=>a?.['price']!==undefined&&a?.['price']!==null,'message':()=>'Service\x20has\x20no\x20price.\x20Customers\x20cannot\x20place\x20orders\x20without\x20knowing\x20the\x20cost.','recommendation':'Set\x20the\x20price\x20field\x20before\x20publishing.'},{'id':'audit_description','description':'Service\x20should\x20have\x20a\x20description','severity':'warning','fields':['description'],'check':a=>typeof a?.['description']==='string'&&a['description']['length']>0x0,'message':()=>'Service\x20has\x20no\x20description.\x20Customers\x20won\x27t\x20understand\x20what\x20you\x27re\x20offering.','recommendation':'Write\x20a\x20clear\x20description\x20of\x20the\x20service,\x20including\x20deliverables,\x20timelines,\x20and\x20terms.'},{'id':'audit_named_new_name','description':'Service\x20being\x20created\x20should\x20have\x20a\x20name','severity':'warning','check':a=>!!a?.['namedNew']?.['name']||typeof a?.['object']==='string','message':()=>'Creating\x20a\x20service\x20without\x20a\x20name\x20makes\x20it\x20hard\x20to\x20reference\x20and\x20organize.','recommendation':'Set\x20namedNew.name\x20following\x20the\x20convention:\x20<projectPrefix>_<service>_<purpose>.'},{'id':'audit_dangling_deps','description':'Service\x20dependencies\x20should\x20be\x20fully\x20created','severity':'error','check':(a,b)=>{if(!a?.['publish'])return!![];if(!b?.['graph'])return!![];const c=b['graph']['findDanglingDependencies']()??[];return c['length']===0x0;},'message':()=>'Service\x20references\x20objects\x20that\x20are\x20not\x20yet\x20created.\x20Publishing\x20will\x20lock\x20these\x20references.','recommendation':'Ensure\x20all\x20referenced\x20objects\x20(machine,\x20allocators,\x20guards)\x20are\x20created\x20and\x20finalized\x20before\x20publishing.'},{'id':'audit_type_parameter','description':'Service\x20should\x20have\x20a\x20token\x20type\x20specified','severity':'info','fields':['type_parameter'],'check':a=>!!a?.['type_parameter']||!!a?.['namedNew']?.['type_parameter'],'message':()=>'No\x20payment\x20token\x20type\x20specified.\x20Defaulting\x20to\x20WOW\x20(0x2::wow::WOW).','recommendation':'Explicitly\x20set\x20type_parameter\x20if\x20you\x20want\x20to\x20accept\x20non-WOW\x20tokens\x20(e.g.,\x20USDT,\x20ETH).'}];const RULE_INDEX=new Map(AUDIT_RULES['map'](a=>[a['id'],a]));export function auditService(a,b){const c=[],d=a?.['publish']===!![]&&typeof a?.['object']==='string';for(const e of AUDIT_RULES){try{if(d&&e['fields']&&!e['fields']['some'](g=>a[g]!==undefined))continue;!e['check'](a,b)&&c['push']({'rule_id':e['id'],'severity':e['severity'],'message':e['message'](a),'recommendation':e['recommendation']});}catch{}}return c;}export function hasBlockingErrors(a){return a['some'](b=>b['severity']==='error');}export function getErrors(a){return a['filter'](b=>b['severity']==='error');}export function getWarnings(a){return a['filter'](b=>b['severity']==='warning');}export function summarizeFindings(a){if(a['length']===0x0)return'All\x20audit\x20checks\x20passed.';const b=getErrors(a),c=getWarnings(a),d=a['filter'](g=>g['severity']==='info'),e=[];if(b['length']>0x0)e['push'](b['length']+'\x20error(s)');if(c['length']>0x0)e['push'](c['length']+'\x20warning(s)');if(d['length']>0x0)e['push'](d['length']+'\x20info');return'Audit:\x20'+e['join'](',\x20')+'.\x20Review\x20before\x20publishing.';}export const AUDIT_RULES_VERSION=0x1;
|
|
1
|
+
export function salesItemsOf(a){if(Array['isArray'](a?.['sales']))return a['sales'];if(Array['isArray'](a?.['sales']?.['sales']))return a['sales']['sales'];return[];}export function allocatorCountOf(a){const b=a?.['order_allocators'];if(Array['isArray'](b))return b['length'];if(Array['isArray'](b?.['allocators']))return b['allocators']['length'];return 0x0;}export function arbitrationRefsOf(b){const c=b?.['arbitrations'];if(Array['isArray'](c))return c['filter'](e=>typeof e==='string');if(Array['isArray'](c?.['objects']))return c['objects']['filter'](e=>typeof e==='string');return[];}export function compensationFundOf(a){if(a?.['compensation_fund_add']?.['balance']!=null)return a['compensation_fund_add']['balance'];if(a?.['compensation_fund']!=null)return a['compensation_fund'];return undefined;}export function serviceNameOf(a){if(typeof a?.['object']==='string')return a['object'];if(typeof a?.['object']?.['name']==='string'&&a['object']['name'])return a['object']['name'];if(typeof a?.['namedNew']?.['name']==='string'&&a['namedNew']['name'])return a['namedNew']['name'];return undefined;}export function typeParameterOf(a){if(typeof a?.['type_parameter']==='string'&&a['type_parameter'])return a['type_parameter'];if(typeof a?.['object']?.['type_parameter']==='string'&&a['object']['type_parameter'])return a['object']['type_parameter'];if(typeof a?.['namedNew']?.['type_parameter']==='string'&&a['namedNew']['type_parameter'])return a['namedNew']['type_parameter'];return undefined;}export const ANTI_PATTERN_NODE_REGEX=/(^|_)(disputed?|arbitration|arb)(_|$)|^(refund|refunded|deposit_refunded|deposit_deducted|cancel|cancelled)$/i;export function auditMachineNodes(a){const b=[],c=[];if(!Array['isArray'](a)||a['length']===0x0)return c['push']('pre_publish:\x20machine\x20node\x20set\x20unavailable\x20—\x20topology\x20not\x20verifiable;\x20'+'verify\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)'),{'critical':b,'warnings':c};const d=a;for(const q of d){const r=typeof q?.['name']==='string'?q['name']:'';r&&ANTI_PATTERN_NODE_REGEX['test'](r)&&b['push']('R-M1-11:\x20machine\x20node\x20\x22'+r+'\x22\x20models\x20dispute/refund\x20flow\x20—\x20'+'refunds\x20must\x20route\x20via\x20an\x20Allocator\x20triggered\x20by\x20business\x20states,\x20'+'disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x20(off-Machine)');}const e=new Set();for(const s of d){const t=typeof s?.['name']==='string'?s['name']:'';if(!t)continue;e['has'](t)&&b['push']('MC-C-04:\x20duplicate\x20machine\x20node\x20name\x20\x22'+t+'\x22\x20—\x20on-chain\x20will\x20reject\x20the\x20publish\x20transaction'),e['add'](t);}const g=d['some'](u=>Array['isArray'](u?.['pairs'])&&u['pairs']['some'](v=>v?.['prev_node']===''));!g&&b['push']('Machine\x20has\x20no\x20entry\x20pair\x20(prev_node=\x22\x22)\x20—\x20Progress\x20can\x20never\x20advance\x20'+'from\x20the\x20initial\x20state;\x20orders\x20are\x20permanently\x20stuck');const h=new Map();for(const u of d){const v=typeof u?.['name']==='string'?u['name']:'';if(!v)continue;if(!h['has'](v))h['set'](v,[]);for(const w of u?.['pairs']??[]){const x=w?.['prev_node'];if(typeof x==='string'&&x!==''){const y=h['get'](x);if(y)y['push'](v);else h['set'](x,[v]);}}}const i=0x0,j=0x1,k=0x2,l=new Map(),m=[],o=z=>{l['set'](z,j);for(const A of h['get'](z)??[]){const B=l['get'](A)??i;if(B===j)m['push'](z+'->'+A);else B===i&&o(A);}l['set'](z,k);};for(const z of h['keys']()){if((l['get'](z)??i)===i)o(z);}m['length']>0x0&&c['push']('pre_publish:\x20machine\x20contains\x20loop\x20back-edge(s)\x20'+m['join'](',\x20')+'\x20—\x20on-chain\x20a\x20revisit\x20'+'is\x20NOT\x20verified\x20to\x20re-fund\x20the\x20Allocation.\x20Every\x20renewal/loop\x20forward\x20MUST\x20carry\x20the\x20new-period\x20'+'payment\x20into\x20the\x20order\x20escrow\x20atomically\x20(create\x20the\x20period\x20payment,\x20receive\x20it\x20into\x20the\x20'+'allocation,\x20and\x20advance\x20the\x20progress\x20—\x20all\x20in\x20one\x20transaction),\x20or\x20the\x20loop\x20allows\x20zero-value\x20'+'re-delivery\x20cycles\x20(test/11\x20R2-F3).\x20'+'Recommended:\x20bind\x20a\x20fund-gate\x20Guard\x20on\x20the\x20loop\x20forward\x20(allocation\x20balance\x20>=\x20period\x20price)\x20—\x20'+'note\x20the\x20allocation.balance\x20query\x20is\x20not\x20yet\x20available\x20on-chain,\x20so\x20per-period\x20NEW\x20Orders\x20remain\x20'+'the\x20safe\x20default\x20for\x20long\x20subscriptions.');for(const A of d){const B=typeof A?.['name']==='string'?A['name']:'?';for(const C of A?.['pairs']??[]){for(const D of C?.['forwards']??[]){const E=D?.['namedOperator']!==undefined&&D?.['namedOperator']!==null,F=D?.['permissionIndex']!==undefined&&D?.['permissionIndex']!==null,G=D?.['guard']!==undefined&&D?.['guard']!==null;!E&&!F&&!G&&c['push']('pre_publish:\x20node\x20\x22'+B+'\x22\x20forward\x20\x22'+String(D?.['name']??'?')+'\x22\x20has\x20no\x20executor\x20binding\x20(namedOperator\x20/\x20permissionIndex\x20/\x20guard)\x20—\x20no\x20one\x20can\x20advance\x20it');}}}return{'critical':b,'warnings':c};}export const AUDIT_RULES=[{'id':'audit_machine_bound','description':'Service\x20should\x20have\x20a\x20Machine\x20workflow\x20bound\x20before\x20publish','severity':'warning','fields':['machine'],'check':(a,b)=>{if(!a?.['publish'])return!![];return!!a?.['machine'];},'message':()=>'Publishing\x20a\x20service\x20without\x20a\x20Machine\x20workflow.\x20Customers\x20won\x27t\x20have\x20a\x20structured\x20order\x20process.','recommendation':'Create\x20a\x20Machine\x20(workflow\x20template)\x20and\x20bind\x20it\x20to\x20the\x20service\x20before\x20publishing.\x20The\x20machine\x20field\x20becomes\x20IMMUTABLE\x20after\x20publish.'},{'id':'audit_order_allocators','description':'Service\x20should\x20have\x20order_allocators\x20for\x20fund\x20distribution','severity':'warning','fields':['order_allocators'],'check':a=>{if(!a?.['publish'])return!![];return allocatorCountOf(a)>0x0;},'message':()=>'Publishing\x20a\x20service\x20without\x20order_allocators.\x20Order\x20funds\x20cannot\x20be\x20auto-distributed\x20to\x20suppliers.','recommendation':'Configure\x20order_allocators\x20before\x20publishing\x20—\x20this\x20field\x20becomes\x20IMMUTABLE\x20after\x20publish.'},{'id':'audit_buy_guard','description':'Service\x20should\x20have\x20a\x20buy_guard\x20for\x20customer\x20screening','severity':'info','fields':['buy_guard'],'check':a=>!!a?.['buy_guard'],'message':()=>'No\x20buy_guard\x20configured\x20—\x20anyone\x20can\x20purchase\x20this\x20service\x20without\x20verification.','recommendation':'Consider\x20adding\x20a\x20Guard\x20to\x20verify\x20customer\x20eligibility\x20(e.g.,\x20identity,\x20wallet\x20balance,\x20location).'},{'id':'audit_arb_alloc_boundary','description':'Arbitration\x20and\x20Allocator\x20coexist\x20→\x20surface\x20the\x20two-system\x20boundary\x20reminder','severity':'warning','fields':['arbitrations','compensation_fund_add','compensation_fund','order_allocators'],'check':a=>{if(!a?.['publish'])return!![];const b=arbitrationRefsOf(a)['length']>0x0||compensationFundOf(a)!==undefined;return!(b&&allocatorCountOf(a)>0x0);},'message':()=>'Arbitration\x20and\x20Allocator\x20are\x20INDEPENDENT\x20systems\x20by\x20design:\x20a\x20ruling\x20records\x20the\x20case\x20and\x20pays\x20from\x20the\x20service\x20compensation\x20fund\x20—\x20it\x20never\x20moves\x20escrow\x20and\x20never\x20advances\x20the\x20workflow.\x20With\x20both\x20configured,\x20a\x20buyer\x20can\x20receive\x20BOTH\x20the\x20arbitration\x20compensation\x20AND\x20a\x20full\x20escrow\x20refund\x20unless\x20the\x20refund/settlement\x20path\x20is\x20gated.\x20This\x20is\x20a\x20boundary\x20reminder,\x20not\x20a\x20defect\x20—\x20verify\x20the\x20coupling\x20check\x20was\x20done\x20deliberately.','recommendation':'Gate\x20the\x20refund/settlement\x20allocator\x27s\x20Guard\x20on\x20order.claimed_by\x20(read-only\x20cross-system\x20evidence\x20—\x20the\x20sanctioned\x20link),\x20or\x20hold\x20the\x20final\x20settlement\x20forward\x20until\x20the\x20case\x20closes.\x20Do\x20NOT\x20couple\x20the\x20systems\x20the\x20other\x20way\x20(no\x20dispute\x20state\x20on\x20the\x20order\x20flow,\x20no\x20workflow\x20step\x20into\x20arbitration):\x20coupling\x20opens\x20the\x20double-pay\x20path.\x20For\x20per-case\x20fund\x20actions,\x20the\x20deposit-reimbursement\x20pattern\x20(guard-design\x20patterns)\x20is\x20the\x20supported\x20route.'},{'id':'audit_compensation_fund','description':'Service\x20should\x20have\x20a\x20compensation_fund\x20for\x20trust','severity':'warning','fields':['compensation_fund_add','compensation_fund'],'check':a=>compensationFundOf(a)!==undefined,'message':()=>'No\x20compensation_fund\x20configured.\x20Customers\x20have\x20no\x20financial\x20protection\x20if\x20you\x20fail\x20to\x20deliver.','recommendation':'Deposit\x20via\x20compensation_fund_add\x20{balance}\x20to\x20enable\x20arbitration\x20payouts.\x20The\x20fund\x20deters\x20fraud\x20and\x20enables\x20arbitration\x20claims.'},{'id':'audit_arbitrations','description':'Service\x20should\x20have\x20arbitration\x20options\x20for\x20dispute\x20resolution','severity':'info','fields':['arbitrations'],'check':a=>arbitrationRefsOf(a)['length']>0x0,'message':()=>'No\x20arbitration\x20configured.\x20Disputes\x20cannot\x20be\x20resolved\x20through\x20a\x20third\x20party.','recommendation':'Add\x20at\x20least\x20one\x20Arbitration\x20object\x20via\x20arbitrations:{op:\x27add\x27,\x20objects:[...]}\x20to\x20enable\x20on-chain\x20dispute\x20resolution.'},{'id':'audit_price','description':'Service\x20should\x20have\x20at\x20least\x20one\x20priced\x20sale\x20item','severity':'error','fields':['sales'],'check':a=>{const b=salesItemsOf(a);if(b['length']===0x0)return!![];return b['some'](c=>c?.['price']!==undefined&&c?.['price']!==null);},'message':()=>'Sales\x20list\x20present\x20but\x20no\x20item\x20has\x20a\x20price.\x20Customers\x20cannot\x20place\x20orders\x20without\x20knowing\x20the\x20cost.','recommendation':'Set\x20price\x20on\x20each\x20sales\x20item\x20(smallest-unit\x20string\x20or\x20display\x20form\x20like\x20\x272.5WOW\x27).'},{'id':'audit_description','description':'Service\x20should\x20have\x20a\x20description','severity':'warning','fields':['description'],'check':a=>typeof a?.['description']==='string'&&a['description']['length']>0x0,'message':()=>'Service\x20has\x20no\x20description.\x20Customers\x20won\x27t\x20understand\x20what\x20you\x27re\x20offering.','recommendation':'Write\x20a\x20clear\x20description\x20of\x20the\x20service,\x20including\x20deliverables,\x20timelines,\x20and\x20terms.'},{'id':'audit_named_new_name','description':'Service\x20being\x20created\x20should\x20have\x20a\x20name','severity':'warning','check':a=>serviceNameOf(a)!==undefined,'message':()=>'Creating\x20a\x20service\x20without\x20a\x20name\x20makes\x20it\x20hard\x20to\x20reference\x20and\x20organize.','recommendation':'Set\x20object:{name:\x20...}\x20(or\x20namedNew.name)\x20following\x20the\x20convention:\x20<projectPrefix>_<service>_<purpose>.'},{'id':'audit_customer_required_needs_um','description':'customer_required\x20requires\x20a\x20Contact\x20bound\x20via\x20um\x20(SDK-enforced\x20hard\x20link;\x20mirrored\x20here)','severity':'error','fields':['customer_required','um'],'check':a=>{const b=Array['isArray'](a?.['customer_required'])?a['customer_required']:[];if(b['length']===0x0)return!![];return!!a?.['um'];},'message':()=>'customer_required\x20is\x20set\x20but\x20no\x20Contact\x20is\x20bound\x20via\x20um\x20—\x20customers\x20cannot\x20deliver\x20the\x20required\x20private\x20information\x20through\x20end-to-end\x20encrypted\x20Messenger.','recommendation':'Bind\x20um:{Contact\x20name/id}\x20in\x20the\x20same\x20call\x20(SDK\x20order_new\x20will\x20fail\x20the\x20buyer\x20otherwise).'},{'id':'audit_customer_required_is_declared_not_enforced','description':'customer_required\x20has\x20no\x20on-chain\x20enforcement\x20at\x20buy\x20time\x20—\x20a\x20Guard\x20must\x20gate\x20fulfilment','severity':'warning','fields':['customer_required'],'check':a=>{const b=Array['isArray'](a?.['customer_required'])?a['customer_required']:[];return b['length']===0x0;},'message':a=>{const b=Array['isArray'](a?.['customer_required'])?a['customer_required']:[];return'customer_required\x20('+b['length']+'\x20field(s):\x20'+b['join'](',\x20')+')\x20is\x20DECLARATIVE\x20ONLY:\x20the\x20on-chain\x20purchase\x20entry\x20never\x20reads\x20it\x20(service.move:399-419),\x20so\x20an\x20order\x20that\x20supplies\x20none\x20of\x20these\x20fields\x20is\x20still\x20created\x20and\x20progresses.\x20Nothing\x20on-chain\x20will\x20stop\x20it.';},'recommendation':'Bind\x20pattern.required_info_evidence_gate\x20(schema_query\x20action=get_guard_design_patterns)\x20on\x20the\x20first\x20forward\x20that\x20needs\x20the\x20information:\x20query\x20\x27order.required_info\x20some\x27\x20(1572)\x20over\x20the\x20Order.\x20The\x20buyer\x20records\x20the\x20credential\x20via\x20order_required_info_update:\x20EITHER\x20the\x20merchant\x27s\x20IM\x20user\x20address\x20resolved\x20from\x20the\x20Service\x27s\x20Contact\x20(zero\x20cost,\x20address\x20record\x20only)\x20OR\x20an\x20on-chain\x20WTS\x20Proof\x20object\x20address\x20(embeds\x20the\x20merchant\x20IM\x20address\x20and\x20the\x20last-message\x20timestamp;\x20costs\x20gas,\x20publicly\x20verifiable).\x20\x27order.required_info\x27\x20(1573)\x20returns\x20the\x20recorded\x20address\x20but\x20aborts\x20while\x20nothing\x20is\x20recorded\x20—\x20gate\x20on\x201572\x20first.'},{'id':'audit_dangling_deps','description':'Service\x20dependencies\x20should\x20be\x20fully\x20created','severity':'error','check':(a,b)=>{if(!a?.['publish'])return!![];if(!b?.['graph'])return!![];const c=b['graph']['findDanglingDependencies']()??[];return c['length']===0x0;},'message':()=>'Service\x20references\x20objects\x20that\x20are\x20not\x20yet\x20created.\x20Publishing\x20will\x20lock\x20these\x20references.','recommendation':'Ensure\x20all\x20referenced\x20objects\x20(machine,\x20allocators,\x20guards)\x20are\x20created\x20and\x20finalized\x20before\x20publishing.'},{'id':'audit_type_parameter','description':'Service\x20should\x20have\x20a\x20token\x20type\x20specified','severity':'info','fields':['type_parameter','namedNew'],'check':a=>typeParameterOf(a)!==undefined,'message':()=>'No\x20payment\x20token\x20type\x20specified.\x20Defaulting\x20to\x20WOW\x20(0x2::wow::WOW).','recommendation':'Explicitly\x20set\x20type_parameter\x20(inside\x20object:{...})\x20if\x20you\x20want\x20to\x20accept\x20non-WOW\x20tokens\x20(e.g.,\x20USDT,\x20ETH).'}];const RULE_INDEX=new Map(AUDIT_RULES['map'](a=>[a['id'],a]));export function auditService(a,b){const c=[],d=a?.['publish']===!![]&&typeof a?.['object']==='string';for(const e of AUDIT_RULES){try{if(d&&e['fields']&&!e['fields']['some'](g=>a[g]!==undefined))continue;!e['check'](a,b)&&c['push']({'rule_id':e['id'],'severity':e['severity'],'message':e['message'](a),'recommendation':e['recommendation']});}catch{}}return c;}export function hasBlockingErrors(a){return a['some'](b=>b['severity']==='error');}export function getErrors(a){return a['filter'](b=>b['severity']==='error');}export function getWarnings(a){return a['filter'](b=>b['severity']==='warning');}export function summarizeFindings(a){if(a['length']===0x0)return'All\x20audit\x20checks\x20passed.';const b=getErrors(a),c=getWarnings(a),d=a['filter'](g=>g['severity']==='info'),e=[];if(b['length']>0x0)e['push'](b['length']+'\x20error(s)');if(c['length']>0x0)e['push'](c['length']+'\x20warning(s)');if(d['length']>0x0)e['push'](d['length']+'\x20info');return'Audit:\x20'+e['join'](',\x20')+'.\x20Review\x20before\x20publishing.';}export const AUDIT_RULES_VERSION=0x3;
|