@wowok/agent-mcp 3.1.7 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/dist/config/exposure.d.ts +2 -2
  2. package/dist/config/judgment.d.ts +5 -5
  3. package/dist/config/rule-engine.d.ts +5 -5
  4. package/dist/customer/user-preferences.d.ts +2 -2
  5. package/dist/evaluation/arbitration-game.js +1 -1
  6. package/dist/evaluation/capability.d.ts +1 -1
  7. package/dist/evaluation/extract.js +1 -1
  8. package/dist/evaluation/match-operation.js +1 -1
  9. package/dist/extensions/industry-pack.d.ts +3 -2
  10. package/dist/extensions/industry-pack.js +1 -1
  11. package/dist/extensions/modes.js +1 -1
  12. package/dist/extensions/registry.js +1 -1
  13. package/dist/extensions/types.d.ts +1 -0
  14. package/dist/graph/onchain/analyze.js +1 -1
  15. package/dist/graph/onchain/analyze.spec.js +1 -1
  16. package/dist/graph/onchain/edge-schema.js +1 -1
  17. package/dist/graph/onchain/extract.js +1 -1
  18. package/dist/graph/onchain/facts.js +1 -1
  19. package/dist/graph/onchain/field-manifest.js +1 -1
  20. package/dist/graph/onchain/project-relationship.js +1 -1
  21. package/dist/graph/onchain/sdk-batch.d.ts +1 -0
  22. package/dist/graph/onchain/sdk-batch.js +1 -1
  23. package/dist/graph/onchain/sdk-dataplane.d.ts +1 -0
  24. package/dist/graph/onchain/sdk-dataplane.js +1 -1
  25. package/dist/graph/onchain/types.d.ts +1 -1
  26. package/dist/harness/recover.js +1 -1
  27. package/dist/keeper/KeeperScan.d.ts +2 -1
  28. package/dist/keeper/KeeperScan.js +1 -1
  29. package/dist/keeper/detectors.d.ts +9 -0
  30. package/dist/keeper/detectors.js +1 -1
  31. package/dist/keeper/keeper.spec.js +1 -1
  32. package/dist/keeper/types.d.ts +1 -1
  33. package/dist/keeper/types.js +1 -1
  34. package/dist/knowledge/allocation-ledger.d.ts +4 -1
  35. package/dist/knowledge/allocation-ledger.js +1 -1
  36. package/dist/knowledge/allocation-puzzle.d.ts +2 -0
  37. package/dist/knowledge/allocation-puzzle.js +1 -1
  38. package/dist/knowledge/allocation-risk.d.ts +1 -1
  39. package/dist/knowledge/allocation-risk.js +1 -1
  40. package/dist/knowledge/allocation-templates.d.ts +1 -1
  41. package/dist/knowledge/allocation-templates.js +1 -1
  42. package/dist/knowledge/arb-risk.d.ts +3 -1
  43. package/dist/knowledge/arb-risk.js +1 -1
  44. package/dist/knowledge/arbitration-ledger.js +1 -1
  45. package/dist/knowledge/arbitration-risk.js +1 -1
  46. package/dist/knowledge/arbitration-templates.d.ts +1 -0
  47. package/dist/knowledge/arbitration-templates.js +1 -1
  48. package/dist/knowledge/audit-rules.d.ts +13 -2
  49. package/dist/knowledge/audit-rules.js +1 -1
  50. package/dist/knowledge/baselines/rules/allocation.json +50 -1
  51. package/dist/knowledge/baselines/rules/arb.json +20 -1
  52. package/dist/knowledge/baselines/rules/arbitration.json +27 -0
  53. package/dist/knowledge/baselines/rules/guard.json +75 -2
  54. package/dist/knowledge/baselines/rules/machine.json +38 -13
  55. package/dist/knowledge/baselines/rules/order.json +2 -2
  56. package/dist/knowledge/builtin-templates.d.ts +3 -1
  57. package/dist/knowledge/builtin-templates.js +1 -1
  58. package/dist/knowledge/discount-threshold.d.ts +15 -0
  59. package/dist/knowledge/discount-threshold.js +1 -0
  60. package/dist/knowledge/event-semantics.js +1 -1
  61. package/dist/knowledge/fund-layer.js +1 -1
  62. package/dist/knowledge/getting-started.js +1 -1
  63. package/dist/knowledge/guard-anchor-reach.d.ts +19 -0
  64. package/dist/knowledge/guard-anchor-reach.js +1 -0
  65. package/dist/knowledge/guard-bindings.js +1 -1
  66. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  67. package/dist/knowledge/guard-design-patterns.js +1 -1
  68. package/dist/knowledge/guard-ledger.js +1 -1
  69. package/dist/knowledge/guard-lint.js +1 -1
  70. package/dist/knowledge/guard-render.d.ts +6 -0
  71. package/dist/knowledge/guard-render.js +1 -1
  72. package/dist/knowledge/guard-risk.js +1 -1
  73. package/dist/knowledge/guard-submission-prompt.d.ts +6 -0
  74. package/dist/knowledge/guard-submission-prompt.js +1 -1
  75. package/dist/knowledge/guard-templates.d.ts +1 -1
  76. package/dist/knowledge/guard-templates.js +1 -1
  77. package/dist/knowledge/guard-translation.js +1 -1
  78. package/dist/knowledge/index.d.ts +6 -6
  79. package/dist/knowledge/index.js +1 -1
  80. package/dist/knowledge/industry-generalizer.d.ts +38 -1
  81. package/dist/knowledge/industry-generalizer.js +1 -1
  82. package/dist/knowledge/industry-registry.d.ts +1 -1
  83. package/dist/knowledge/industry-registry.js +1 -1
  84. package/dist/knowledge/industry-strategy.js +1 -1
  85. package/dist/knowledge/jsonrpc-enum.js +1 -1
  86. package/dist/knowledge/machine-ledger.js +1 -1
  87. package/dist/knowledge/machine-risk.js +1 -1
  88. package/dist/knowledge/machine-templates.js +1 -1
  89. package/dist/knowledge/onchain-constants.d.ts +2 -2
  90. package/dist/knowledge/onchain-constants.js +1 -1
  91. package/dist/knowledge/order-ledger.js +1 -1
  92. package/dist/knowledge/order-templates.js +1 -1
  93. package/dist/knowledge/permission-ledger.js +1 -1
  94. package/dist/knowledge/release-sentinel.d.ts +12 -0
  95. package/dist/knowledge/release-sentinel.js +1 -0
  96. package/dist/knowledge/repository-write-semantics.d.ts +27 -0
  97. package/dist/knowledge/repository-write-semantics.js +1 -0
  98. package/dist/knowledge/rule-node-analyzers.d.ts +6 -0
  99. package/dist/knowledge/rule-node-analyzers.js +1 -1
  100. package/dist/knowledge/safety-rules.d.ts +5 -1
  101. package/dist/knowledge/safety-rules.js +1 -1
  102. package/dist/knowledge/scenario-modes.d.ts +20 -1
  103. package/dist/knowledge/scenario-modes.js +1 -1
  104. package/dist/knowledge/service-allocation-semantics.d.ts +36 -0
  105. package/dist/knowledge/service-allocation-semantics.js +1 -0
  106. package/dist/knowledge/strategy-manuals.d.ts +4 -6
  107. package/dist/knowledge/strategy-manuals.js +1 -1
  108. package/dist/knowledge/template-loader.d.ts +48 -12
  109. package/dist/knowledge/template-loader.js +1 -1
  110. package/dist/knowledge/template-registry.js +1 -1
  111. package/dist/knowledge/template-scanner.js +1 -1
  112. package/dist/knowledge/tools-reference.js +1 -1
  113. package/dist/knowledge/workflow-guidance.d.ts +26 -0
  114. package/dist/knowledge/workflow-guidance.js +1 -1
  115. package/dist/monitor/MonitorLoop.js +1 -1
  116. package/dist/participation/allocation-advice.d.ts +38 -0
  117. package/dist/participation/allocation-advice.js +1 -0
  118. package/dist/participation/arbitrator-interest.js +1 -1
  119. package/dist/participation/customer-interest.js +1 -1
  120. package/dist/participation/merchant-interest.js +1 -1
  121. package/dist/participation/radar-core.d.ts +2 -0
  122. package/dist/persona/types.d.ts +3 -2
  123. package/dist/persona/types.js +1 -1
  124. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  125. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  126. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  127. package/dist/playbooks/service-build/merchant-guide.d.ts +70 -63
  128. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  129. package/dist/playbooks/service-build/migration-planner.js +1 -1
  130. package/dist/playbooks/service-build/mode-actions.d.ts +17 -1
  131. package/dist/playbooks/service-build/mode-actions.js +1 -1
  132. package/dist/playbooks/service-build/object-panorama.js +1 -1
  133. package/dist/playbooks/service-build/participation-radar.js +1 -1
  134. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  135. package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.js +1 -0
  136. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  137. package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
  138. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  139. package/dist/playbooks/service-build/service-panorama.js +1 -1
  140. package/dist/playbooks/service-build/service-quote.d.ts +2 -0
  141. package/dist/playbooks/service-build/service-quote.js +1 -0
  142. package/dist/relationship/derivation.d.ts +1 -1
  143. package/dist/review/index.js +1 -1
  144. package/dist/role/profiles.js +1 -1
  145. package/dist/role/types.d.ts +2 -0
  146. package/dist/role/types.js +1 -1
  147. package/dist/safety/confirm-gate.js +1 -1
  148. package/dist/schema/benchmark-migration/index.d.ts +30 -8
  149. package/dist/schema/benchmark-migration/index.js +1 -1
  150. package/dist/schema/call/allocation.d.ts +10 -7
  151. package/dist/schema/call/arbitration.d.ts +1 -1
  152. package/dist/schema/call/arbitration.js +1 -1
  153. package/dist/schema/call/base.d.ts +5 -5
  154. package/dist/schema/call/base.js +1 -1
  155. package/dist/schema/call/bridge.d.ts +5 -9
  156. package/dist/schema/call/bridge.js +1 -1
  157. package/dist/schema/call/contact.d.ts +1 -1
  158. package/dist/schema/call/demand.d.ts +1 -1
  159. package/dist/schema/call/guard.d.ts +15 -15
  160. package/dist/schema/call/handler.js +1 -1
  161. package/dist/schema/call/machine.d.ts +58 -2
  162. package/dist/schema/call/machine.js +1 -1
  163. package/dist/schema/call/order.d.ts +1 -1
  164. package/dist/schema/call/order.js +1 -1
  165. package/dist/schema/call/payment.d.ts +1 -1
  166. package/dist/schema/call/payment.js +1 -1
  167. package/dist/schema/call/permission.d.ts +1 -1
  168. package/dist/schema/call/personal.d.ts +1 -1
  169. package/dist/schema/call/progress.d.ts +1 -1
  170. package/dist/schema/call/proof.d.ts +2 -2
  171. package/dist/schema/call/repository.d.ts +1 -1
  172. package/dist/schema/call/reward.d.ts +1 -1
  173. package/dist/schema/call/semantic.js +1 -1
  174. package/dist/schema/call/service.d.ts +87 -25
  175. package/dist/schema/call/service.js +1 -1
  176. package/dist/schema/call/treasury.d.ts +1 -1
  177. package/dist/schema/common/index.js +1 -1
  178. package/dist/schema/common/tokentype-short-probe.spec.js +1 -0
  179. package/dist/schema/evaluation/index.d.ts +14 -82
  180. package/dist/schema/evaluation/index.js +1 -1
  181. package/dist/schema/goal/index.d.ts +8 -41
  182. package/dist/schema/goal/planning.d.ts +22 -57
  183. package/dist/schema/goal/planning.js +1 -1
  184. package/dist/schema/industry-pack/index.d.ts +15 -0
  185. package/dist/schema/industry-pack/modes.d.ts +15 -0
  186. package/dist/schema/industry-pack/modes.js +1 -1
  187. package/dist/schema/intent-radar/index.d.ts +5 -20
  188. package/dist/schema/intent-radar/index.js +1 -1
  189. package/dist/schema/interaction/index.d.ts +1 -1
  190. package/dist/schema/keeper/index.d.ts +3 -0
  191. package/dist/schema/keeper/index.js +1 -1
  192. package/dist/schema/local/index.d.ts +577 -18
  193. package/dist/schema/local/index.js +1 -1
  194. package/dist/schema/messenger/index.d.ts +140 -20
  195. package/dist/schema/messenger/index.js +1 -1
  196. package/dist/schema/operations.d.ts +97 -35
  197. package/dist/schema/operations.js +1 -1
  198. package/dist/schema/persona/index.d.ts +811 -916
  199. package/dist/schema/persona/index.js +1 -1
  200. package/dist/schema/query/bi.d.ts +161 -8
  201. package/dist/schema/query/bi.js +1 -1
  202. package/dist/schema/query/index.d.ts +49 -30
  203. package/dist/schema/query/index.js +1 -1
  204. package/dist/schema/schema-query/index.d.ts +2 -2
  205. package/dist/schema/workflow/index.d.ts +2 -2
  206. package/dist/schema-query-impl/index.d.ts +1 -0
  207. package/dist/schema-query-impl/index.js +1 -1
  208. package/dist/schemas/account_operation.output.json +8 -4
  209. package/dist/schemas/account_operation.schema.json +1 -1
  210. package/dist/schemas/benchmark_migration_operation.output.json +116 -2
  211. package/dist/schemas/benchmark_migration_operation.schema.json +2 -10
  212. package/dist/schemas/bridge_operation.output.json +2 -2
  213. package/dist/schemas/bridge_operation.schema.json +2 -10
  214. package/dist/schemas/evaluation_operation.output.json +2 -0
  215. package/dist/schemas/evaluation_operation.schema.json +9 -70
  216. package/dist/schemas/goal_operation.schema.json +6 -39
  217. package/dist/schemas/index.json +7 -1
  218. package/dist/schemas/industry_pack_operation.output.json +87 -4
  219. package/dist/schemas/intent_radar.output.json +6 -20
  220. package/dist/schemas/intent_radar.schema.json +1 -0
  221. package/dist/schemas/keeper_operation.output.json +2 -2
  222. package/dist/schemas/keeper_operation.schema.json +9 -4
  223. package/dist/schemas/local_cache_operation.output.json +1536 -0
  224. package/dist/schemas/local_cache_operation.schema.json +101 -0
  225. package/dist/schemas/local_history_operation.output.json +2 -2
  226. package/dist/schemas/local_info_operation.output.json +2 -2
  227. package/dist/schemas/local_mark_operation.output.json +53 -38
  228. package/dist/schemas/local_mark_operation.schema.json +1 -0
  229. package/dist/schemas/messenger_operation.output.json +2 -2
  230. package/dist/schemas/messenger_operation.schema.json +358 -35
  231. package/dist/schemas/monitor_events.output.json +2 -2
  232. package/dist/schemas/monitor_subscription.output.json +2 -2
  233. package/dist/schemas/onchain_events.output.json +2 -2
  234. package/dist/schemas/onchain_operations.output.json +6 -6
  235. package/dist/schemas/onchain_operations.schema.json +237 -64
  236. package/dist/schemas/onchain_operations_allocation.schema.json +12 -11
  237. package/dist/schemas/onchain_operations_arbitration.schema.json +16 -16
  238. package/dist/schemas/onchain_operations_machine.schema.json +27 -5
  239. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  240. package/dist/schemas/onchain_operations_payment.schema.json +3 -3
  241. package/dist/schemas/onchain_operations_reward.schema.json +2 -2
  242. package/dist/schemas/onchain_operations_service.schema.json +174 -24
  243. package/dist/schemas/onchain_operations_treasury.schema.json +2 -2
  244. package/dist/schemas/onchain_table_data.output.json +68 -4
  245. package/dist/schemas/persona_operation.output.json +11 -88
  246. package/dist/schemas/persona_operation.schema.json +4 -32
  247. package/dist/schemas/query_toolkit.output.json +331 -26
  248. package/dist/schemas/query_toolkit.schema.json +66 -2
  249. package/dist/tools/handlers/benchmark-migration.js +1 -1
  250. package/dist/tools/handlers/bridge.js +1 -1
  251. package/dist/tools/handlers/dispatch-expectations.spec.js +1 -1
  252. package/dist/tools/handlers/keeper.d.ts +1 -1
  253. package/dist/tools/handlers/local.d.ts +1 -0
  254. package/dist/tools/handlers/local.js +1 -1
  255. package/dist/tools/handlers/messenger.d.ts +9 -2
  256. package/dist/tools/handlers/messenger.js +1 -1
  257. package/dist/tools/handlers/name-resolution.d.ts +4 -0
  258. package/dist/tools/handlers/name-resolution.js +1 -0
  259. package/dist/tools/handlers/name-resolution.spec.js +1 -0
  260. package/dist/tools/handlers/onchain-name-registration.d.ts +37 -0
  261. package/dist/tools/handlers/onchain-name-registration.js +1 -0
  262. package/dist/tools/handlers/onchain-name-registration.spec.js +1 -0
  263. package/dist/tools/handlers/onchain.d.ts +1 -0
  264. package/dist/tools/handlers/onchain.js +1 -1
  265. package/dist/tools/handlers/query.d.ts +1 -0
  266. package/dist/tools/handlers/query.js +1 -1
  267. package/dist/tools/handlers/schema-query.js +1 -1
  268. package/dist/tools/index.js +1 -1
  269. package/dist/tools/move-fn-index.gen.js +1 -1
  270. package/dist/tools/registry/business.js +1 -1
  271. package/dist/tools/registry/local.js +1 -1
  272. package/dist/tools/sanitize-description-roundtrip.spec.js +1 -0
  273. package/dist/tools/sanitize-output.d.ts +1 -0
  274. package/dist/tools/sanitize-output.js +1 -1
  275. package/dist/tools/wrap.js +1 -1
  276. package/package.json +2 -2
  277. package/dist/knowledge/alloc-audit-policy.spec.js +0 -1
  278. package/dist/knowledge/event-semantics.spec.js +0 -1
  279. package/dist/knowledge/facts-sync.spec.js +0 -1
  280. package/dist/knowledge/guard-design-patterns.spec.js +0 -1
  281. package/dist/knowledge/guard-eval.spec.js +0 -1
  282. package/dist/knowledge/rule-node-analyzers.spec.d.ts +0 -1
  283. package/dist/knowledge/rule-node-analyzers.spec.js +0 -1
  284. package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +0 -1
  285. package/dist/knowledge/safety-rules.extract-amount.spec.js +0 -1
  286. package/dist/knowledge/template-loader.spec.d.ts +0 -1
  287. package/dist/knowledge/template-loader.spec.js +0 -1
  288. package/dist/knowledge/template-scanner.spec.d.ts +0 -1
  289. package/dist/knowledge/template-scanner.spec.js +0 -1
  290. /package/dist/{knowledge/alloc-audit-policy.spec.d.ts → playbooks/service-build/reverse-mapping-refund-p0-5.spec.d.ts} +0 -0
  291. /package/dist/{knowledge/event-semantics.spec.d.ts → schema/common/tokentype-short-probe.spec.d.ts} +0 -0
  292. /package/dist/{knowledge/facts-sync.spec.d.ts → tools/handlers/name-resolution.spec.d.ts} +0 -0
  293. /package/dist/{knowledge/guard-design-patterns.spec.d.ts → tools/handlers/onchain-name-registration.spec.d.ts} +0 -0
  294. /package/dist/{knowledge/guard-eval.spec.d.ts → tools/sanitize-description-roundtrip.spec.d.ts} +0 -0
@@ -17,7 +17,7 @@ export interface AllocationTemplate {
17
17
  notes?: string[];
18
18
  }
19
19
  export declare const ALLOCATION_TEMPLATES: AllocationTemplate[];
20
- export declare const ALLOCATION_TEMPLATES_VERSION = "1.0.0";
20
+ export declare const ALLOCATION_TEMPLATES_VERSION = "1.1.0";
21
21
  export declare function getAllTemplates(): AllocationTemplate[];
22
22
  export declare function getTemplateById(id: string): AllocationTemplate | undefined;
23
23
  export declare function getTemplatesByScene(sceneId: string): AllocationTemplate[];
@@ -1 +1 @@
1
- export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services']},{'id':'T-A-02','name':'Standard\x203-way\x20Rate\x20split','description':'Three-way\x20split:\x20merchant\x20/\x20platform\x20/\x20logistics.\x20Pure\x20Rate\x20mode,\x20sum(rates)\x20MUST\x20equal\x2010000','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'logistics_treasury','type':'address','description':'Logistics\x20Treasury\x20address\x20(set\x20to\x20platform_treasury\x20if\x20N/A)','required':!![]},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'logistics_rate','type':'number','description':'Logistics\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['logistics_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20logistics='+d+')'));return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'3-way\x20split:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20logistics\x20'+d+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['logistics_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','the\x20fix\x20is\x20cached\x20as\x20refundAmount\x20when\x20the\x20Allocator\x20is\x20added','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20the\x20Passport\x27s\x20guard\x20result\x20is\x20hard-verified\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order)','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20small\x20orders\x20(e.g.\x2010000\x20=\x20100%)','required':!![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20large\x20orders\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'large_order_platform_rate','type':'number','description':'Platform\x20rate\x20for\x20large\x20orders\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=Number(a['small_order_merchant_rate']);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=Number(a['large_order_merchant_rate']),d=Number(a['large_order_platform_rate']),e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20platform='+d+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount:\x20small=100%\x20merchant,\x20large=80/20\x20merchant/platform','threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20with\x203\x20Rate\x20sharing\x20items,\x20one\x20recipient\x20resolved\x20from\x20customer\x27s\x20Passport\x20table[0]','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20—\x20customer\x20submits\x20referrer\x20address\x20at\x20this\x20slot','required':!![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'referrer_rate','type':'number','description':'Referrer\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['referrer_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20referrer='+d+')');const f=Number(a['passport_identifier']);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','The\x20Guard\x20identifier\x20slot\x27s\x20address-type\x20check\x20MUST\x20pass\x20when\x20the\x20Allocator\x20is\x20added\x20(else\x20the\x20Allocator\x20add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20the\x20Allocator\x20add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.']},{'id':'T-A-08','name':'Arbitration\x20fees\x20split\x20(arbitrator\x2080%\x20/\x20platform\x2020%)','description':'Single\x20Allocator,\x202\x20Rate\x20sharing\x20items.\x20Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20365),\x20with\x20or\x20without\x20a\x20Passport.','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=Number(a['arbitrator_rate']),c=Number(a['platform_rate']),d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20platform='+c+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20split:\x20arbitrator\x20'+b+'/10000,\x20platform\x20'+c+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20ARBITRATION_FEES_ALLOC=365),\x20with\x20or\x20without\x20a\x20Passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer']}];export const ALLOCATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
1
+ function assert_declared_share(a,b,c,d){const e=c===undefined||c===null||c===''?d:c,f=Number(e);if(!Number['isInteger'](f))throw new Error('E-RATE-EXPLICIT:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20an\x20explicit\x20integer\x20number\x20of\x20basis\x20points\x20'+('(the\x20buyer\x20must\x20be\x20able\x20to\x20compute\x20it\x20pre-order;\x20never\x20an\x20implicit\x20remainder),\x20got\x20'+String(c)));if(f<0x0||f>0x2710)throw new Error('E-RATE-RANGE:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20within\x20[0,\x2010000],\x20got\x20'+f);return f;}function assert_explicit_recipient(a,b,c,d){if(d<=0x0)return;const e=typeof c==='string'?c['trim']():'';if(e['length']===0x0)throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20a\x20non-empty\x20explicit\x20recipient\x20'+('because\x20its\x20rate\x20is\x20'+d+'\x20>\x200.\x20A\x20blank/omitted\x20recipient\x20silently\x20falls\x20back\x20to\x20')+'Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86),\x20'+'so\x20the\x20outflow\x20would\x20go\x20to\x20whoever\x20ran\x20the\x20deploy.');if(e['toLowerCase']()['startsWith']('0x')){const f=e['slice'](0x2);if(f['length']===0x0||!/^[0-9a-f]+$/['test'](f)||/^0+$/['test'](f))throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20looks\x20like\x20an\x20address\x20but\x20carries\x20no\x20'+('identity\x20(\x22'+e+'\x22).\x20Point\x20it\x20at\x20the\x20declared\x20recipient\x20Entity\x20(a\x20Treasury/Entity\x20address\x20the\x20')+'buyer\x20can\x20see\x20pre-order).');}}export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services','DIRECT-SALES\x20DEFAULT\x20SHAPE\x20(L2):\x20this\x20IS\x20the\x20default\x20payout\x20form\x20—\x20one\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant\x27s\x20own\x20Entity.\x20No\x20platform\x20leg\x20exists,\x20and\x20nothing\x20is\x20left\x20over','If\x20the\x20merchant\x20declares\x20its\x20OWN\x20fee,\x20use\x20T-A-02\x20(an\x20explicit\x20fee\x20leg\x20to\x20an\x20explicit\x20non-empty\x20recipient)\x20instead\x20of\x20shrinking\x20this\x20leg\x20and\x20routing\x20the\x20difference\x20through\x20an\x20implicit\x20remainder\x20(L3)','A\x20BLANK\x20recipient_address\x20is\x20NOT\x20a\x20no-op:\x20it\x20resolves\x20to\x20Account.Instance().get_address(undefined),\x20the\x20logged-in/deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86)\x20—\x20so\x20this\x20template\x20pays\x20whoever\x20ran\x20the\x20deploy']},{'id':'T-A-02','name':'Merchant\x20payout\x20+\x20optional\x20declared\x20fee\x20/\x20third-party\x20leg\x20(merchant\x20keeps\x20100%\x20by\x20default)','description':'DIRECT-SALES\x20split:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20by\x20default\x20(one\x20Rate\x2010000\x20leg\x20to\x20its\x20own\x20Entity).\x20Optional\x20extra\x20legs\x20are\x20(a)\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20—\x20only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator\x20—\x20and\x20(b)\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider,\x20arbitrator,\x20partner),\x20which\x20is\x20a\x20payment\x20for\x20a\x20service,\x20not\x20platform\x20extraction.\x20Pure\x20Rate\x20mode:\x20the\x20emitted\x20sharing\x20rows\x20MUST\x20sum\x20to\x20exactly\x2010000,\x20and\x20with\x20the\x20default\x20parameters\x20they\x20are\x20a\x20single\x2010000\x20row.\x20L3\x20fee\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20buyer\x20can\x20compute\x20BEFORE\x20ordering,\x20never\x20an\x20implicit\x20remainder\x20such\x20as\x20\x27order\x20total\x20-\x20segment\x20sums\x27;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20the\x20buyer\x20can\x20see\x20pre-order\x20(a\x20blank\x20recipient\x20is\x20NOT\x20a\x20no-op\x20—\x20it\x20falls\x20back\x20to\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86);\x20(3)\x20no\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).\x20WoWok\x20itself\x20takes\x20nothing.','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Entity\x20that\x20receives\x20its\x20own\x20sale\x20proceeds\x20—\x20the\x20direct-sales\x20destination.\x20Required\x20and\x20never\x20blank\x20(blank\x20silently\x20routes\x20the\x20payout\x20to\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86).','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20merchant_service_fee_bps\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86).\x20Pass\x20merchant_treasury\x20if\x20the\x20merchant\x20charges\x20itself.','required':![]},{'name':'third_party_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20third_party_rate\x20(e.g.\x20the\x20logistics\x20provider\x27s\x20own\x20Treasury).\x20MUST\x20be\x20explicit\x20and\x20non-empty\x20whenever\x20third_party_rate\x20>\x200\x20—\x20same\x20blank-fallback\x20hazard\x20as\x20merchant_fee_treasury.','required':![]},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium\x20/\x20an\x20OTA\x20that\x20really\x20is\x20the\x20seller\x27s\x20counterparty).\x20WoWok\x20extracts\x20nothing\x20—\x20this\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20price,\x20never\x20a\x20platform\x20share.\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20before\x20ordering;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20third_party_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'third_party_rate','type':'number','description':'Rate\x20for\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider\x20/\x20arbitrator\x20/\x20supply-chain\x20partner),\x20default\x200.\x20Kept\x20expressible\x20on\x20purpose\x20—\x20a\x20real\x20provider\x20fee\x20is\x20a\x20payment\x20FOR\x20a\x20service\x20—\x20but\x20it\x20must\x20be\x20an\x20explicit\x20number\x20with\x20an\x20explicit\x20recipient,\x20exactly\x20like\x20the\x20merchant\x20fee.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-02','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-02','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-02','third_party_rate',a['third_party_rate'],0x0);assert_explicit_recipient('T-A-02','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-02','merchant_fee_treasury',a['merchant_fee_treasury'],c),assert_explicit_recipient('T-A-02','third_party_treasury',a['third_party_treasury'],d);const e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20third_party='+d+')'));const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&f['push']({'who':{'Entity':a['third_party_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Direct-sales\x20payout\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20third\x20party\x20(e.g.\x20logistics)\x20'+d+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)\x20—\x20a\x20Rate\x20sum\x20<\x2010000\x20with\x20no\x20Surplus\x20recipient\x20leaves\x20residual\x20balance\x20that\x20ANYONE\x20passing\x20the\x20same\x20Guard\x20can\x20claim\x20repeatedly\x20(E-2\x20/\x20finding\x20T-04)','DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','merchant_service_fee_bps\x20is\x20the\x20MERCHANT\x27s\x20own\x20fee\x20(merchant\x20IS\x20the\x20aggregator),\x20default\x200\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission\x20and\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template','third_party_rate\x20is\x20a\x20real\x20provider\x20payment\x20(logistics\x20/\x20arbitrator\x20/\x20partner),\x20not\x20platform\x20extraction;\x20keep\x20it\x20expressible,\x20but\x20name\x20the\x20payee\x20explicitly','Never\x20express\x20a\x20fee\x20as\x20an\x20implicit\x20remainder\x20(\x27the\x20merchant\x20keeps\x20whatever\x20is\x20left\x27)\x20and\x20never\x20take\x20one\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant.\x20No\x20fee\x20and\x20no\x20platform\x20leg:\x20the\x20Surplus\x20is\x20the\x20merchant\x27s\x20residual\x20of\x20a\x20mixed\x20refund/delivery\x20pool,\x20NOT\x20a\x20fee\x20mechanism','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','the\x20fix\x20is\x20cached\x20as\x20refundAmount\x20when\x20the\x20Allocator\x20is\x20added','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)','SURPLUS\x20IS\x20NOT\x20A\x20FEE:\x20Surplus\x20calls\x20balance::withdraw_all\x20(allocation.move:420),\x20so\x20a\x20fee\x20taken\x20that\x20way\x20doubles\x20as\x20draining\x20the\x20pool\x20(L3\x20constraint\x203).\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg,\x20never\x20here','The\x20Surplus\x20recipient\x20is\x20the\x20merchant\x20(the\x20counterparty\x20of\x20the\x20delivered\x20part),\x20not\x20an\x20unnamed\x20third\x20party\x20—\x20but\x20pin\x20refund_amount\x20to\x20the\x20refund\x20actually\x20owed,\x20or\x20a\x20smaller/empty\x20refund\x20lets\x20the\x20Surplus\x20leg\x20absorb\x20money\x20that\x20is\x20not\x20the\x20merchant\x27s']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20the\x20Passport\x27s\x20guard\x20result\x20is\x20hard-verified\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)','Each\x20Allocator\x20sums\x20to\x2010000\x20INDEPENDENTLY\x20—\x20the\x20Rate-total\x20invariant\x20is\x20per\x20Allocator,\x20not\x20across\x20Allocators,\x20and\x20each\x20of\x20the\x20two\x20paths\x20pays\x20ONE\x20recipient\x20the\x20full\x20amount\x20(no\x20split,\x20no\x20platform\x20leg,\x20no\x20residual)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order).\x20DIRECT-SALES\x20default:\x20BOTH\x20tiers\x20pay\x20the\x20merchant\x20100%\x20—\x20the\x20tier\x20selects\x20the\x20guard,\x20not\x20a\x20cut.\x20The\x20large\x20tier\x20may\x20add\x20the\x20merchant\x27s\x20OWN\x20declared\x20fee,\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20computable\x20before\x20ordering,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(blank\x20silently\x20routes\x20it\x20to\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20never\x20a\x20Surplus\x20fee\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all).\x20No\x20platform\x20leg\x20exists\x20in\x20this\x20template.','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(receives\x20the\x20full\x20sale\x20on\x20both\x20tiers\x20by\x20default)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20large_order_merchant_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86),\x20not\x20a\x20no-op.','required':![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20small-order\x20tier.\x20Default\x20(and\x20only)\x20value\x2010000\x20—\x20direct\x20sales:\x20no\x20platform\x20take.','required':![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20large-order\x20tier.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(there\x20is\x20no\x20platform\x20take\x20to\x20deduct).','required':![],'default':0x2710},{'name':'large_order_merchant_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20on\x20the\x20large-order\x20tier,\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20large_order_merchant_rate\x20+\x20large_order_merchant_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20takes\x20no\x20platform\x20commission.','required':![],'default':0x0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=assert_declared_share('T-A-05','small_order_merchant_rate',a['small_order_merchant_rate'],0x2710);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=assert_declared_share('T-A-05','large_order_merchant_rate',a['large_order_merchant_rate'],0x2710),d=assert_declared_share('T-A-05','large_order_merchant_fee_bps',a['large_order_merchant_fee_bps'],0x0);assert_explicit_recipient('T-A-05','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-05','merchant_fee_treasury',a['merchant_fee_treasury'],d);const e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20merchant_fee='+d+')');const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'}];return d>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount\x20(platform\x20commission\x200):\x20small=100%\x20merchant,\x20'+('large='+c+'/10000\x20merchant')+(d>0x0?'\x20+\x20'+d+'/10000\x20merchant\x27s\x20own\x20service\x20fee':''),'threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)','DIRECT-SALES\x20DEFAULT:\x20both\x20tiers\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury\x20—\x20the\x20tier\x20picks\x20the\x20guard,\x20not\x20a\x20cut.\x20Each\x20Allocator\x20sums\x20to\x2010000\x20on\x20its\x20own','large_order_merchant_fee_bps\x20is\x20the\x20merchant\x27s\x20OWN\x20large-tier\x20fee\x20(default\x200),\x20only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator;\x20it\x20is\x20never\x20a\x20platform\x20take,\x20never\x20an\x20implicit\x20remainder,\x20and\x20its\x20recipient\x20must\x20be\x20explicit\x20and\x20non-empty']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20whose\x20Rate\x20sharing\x20items\x20include\x20one\x20recipient\x20resolved\x20from\x20the\x20customer\x27s\x20Passport\x20table[identifier].\x20DIRECT-SALES\x20default:\x20merchant_rate\x2010000\x20and\x20every\x20optional\x20leg\x200,\x20so\x20the\x20emitted\x20template\x20is\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant.\x20Two\x20optional\x20legs\x20may\x20be\x20switched\x20on,\x20each\x20under\x20the\x20L3\x20rule\x20(explicit\x20number\x20computable\x20pre-order;\x20explicit\x20non-empty\x20recipient\x20—\x20blank\x20silently\x20pays\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86;\x20no\x20mandatory\x20transit\x20pool,\x20never\x20a\x20Surplus\x20fee\x20leg):\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20(only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator)\x20and\x20a\x20referral/reward\x20to\x20a\x20referrer\x20the\x20buyer\x20names.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template.','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(default:\x20the\x20sole\x2010000\x20recipient)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86).\x20NEVER\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20through\x20GuardIdentifier:\x20that\x20recipient\x20is\x20buyer-submitted,\x20not\x20merchant-declared.','required':![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20carrying\x20the\x20referrer\x20address\x20the\x20buyer\x20submits\x20—\x20only\x20consulted\x20when\x20referrer_rate\x20>\x200\x20(default\x200)','required':![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20referrer_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'referrer_rate','type':'number','description':'Referral\x20/\x20reward\x20rate\x20paid\x20to\x20the\x20referrer\x20the\x20BUYER\x20names\x20in\x20its\x20Passport,\x20default\x200.\x20This\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20acquisition\x20price,\x20not\x20a\x20platform\x20share\x20—\x20keep\x20it\x200\x20unless\x20the\x20merchant\x20actually\x20runs\x20a\x20referral\x20programme,\x20and\x20never\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20here.','required':![],'default':0x0}],'body':a=>{const b=assert_declared_share('T-A-06','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-06','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-06','referrer_rate',a['referrer_rate'],0x0),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20referrer='+d+')');assert_explicit_recipient('T-A-06','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-06','merchant_fee_treasury',a['merchant_fee_treasury'],c);const f=Number(a['passport_identifier']??0x0);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);const g=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&g['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&g['push']({'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':g,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury;\x20to\x20exercise\x20the\x20GuardIdentifier\x20form\x20set\x20referrer_rate\x20>\x200\x20and\x20lower\x20merchant_rate\x20by\x20exactly\x20that\x20amount\x20(the\x20emitted\x20rows\x20must\x20still\x20total\x2010000)','F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','The\x20Guard\x20identifier\x20slot\x27s\x20address-type\x20check\x20MUST\x20pass\x20when\x20the\x20Allocator\x20is\x20added\x20(else\x20the\x20Allocator\x20add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes','The\x20GuardIdentifier\x20recipient\x20is\x20CHOSEN\x20BY\x20THE\x20BUYER\x20(the\x20submitted\x20address\x20bound\x20to\x20for_object),\x20so\x20the\x20Guard\x20—\x20not\x20the\x20template\x20—\x20is\x20what\x20makes\x20it\x20trustworthy:\x20bind\x20it\x20(e.g.\x20an\x20allow-listed\x20referrer)\x20before\x20enabling\x20a\x20non-zero\x20referrer_rate,\x20and\x20never\x20use\x20it\x20for\x20the\x20merchant\x27s\x20own\x20fee','merchant_service_fee_bps\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20fee,\x20default\x200,\x20and\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20—\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20the\x20Allocator\x20add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.','No\x20fee\x20leg\x20and\x20no\x20platform\x20leg:\x20a\x20refund\x20path\x20pays\x20the\x20order\x27s\x20owner\x20and\x20nothing\x20else.\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg\x20—\x20never\x20as\x20a\x20leg\x20here,\x20and\x20never\x20as\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain']},{'id':'T-A-08','name':'Arbitration\x20fees\x20payout\x20(arbitrator\x20keeps\x20100%\x20by\x20default\x20/\x20optional\x20declared\x20operator\x20fee)','description':'Single\x20Allocator,\x20Rate\x20sharing\x20items\x20summing\x20to\x20exactly\x2010000.\x20Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20365),\x20with\x20or\x20without\x20a\x20Passport.\x20DIRECT-SALES\x20default:\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20fee\x20(single\x20Rate\x2010000\x20leg)\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission.\x20An\x20optional\x20fee\x20for\x20the\x20arbitration\x20OPERATOR\x20(the\x20arbitrator\x27s\x20own\x20declared\x20service\x20price,\x20or\x20a\x20third\x20party\x20such\x20as\x20a\x20payments/escrow\x20provider)\x20is\x20allowed\x20only\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20parties\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20visible\x20to\x20both\x20sides\x20beforehand\x20(blank\x20silently\x20routes\x20the\x20money\x20to\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address\x20—\x20default\x20sole\x2010000\x20recipient\x20of\x20the\x20dispute\x20fee','required':!![]},{'name':'arbitration_operator_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20arbitration_operator_fee_bps:\x20the\x20ARBITRATION\x20OPERATOR\x27s\x20own\x20fee\x20treasury\x20(the\x20arbitrator\x27s\x20declared\x20service\x20price)\x20or\x20a\x20genuine\x20third-party\x20treasury\x20(e.g.\x20an\x20escrow\x20/\x20payments\x20provider).\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20the\x20fee\x20is\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/w/local/index.ts:74-86).','required':![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x27s\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'arbitration_operator_fee_bps','type':'number','description':'The\x20ARBITRATION\x20OPERATOR\x27s\x20(or\x20a\x20named\x20third\x20party\x27s)\x20own\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Explicit\x20number\x20both\x20sides\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged;\x20arbitrator_rate\x20+\x20arbitration_operator_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20extracts\x20nothing,\x20so\x20there\x20is\x20no\x20platform\x20share\x20here.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-08','arbitrator_rate',a['arbitrator_rate'],0x2710),c=assert_declared_share('T-A-08','arbitration_operator_fee_bps',a['arbitration_operator_fee_bps'],0x0);assert_explicit_recipient('T-A-08','arbitrator_treasury',a['arbitrator_treasury'],b),assert_explicit_recipient('T-A-08','arbitration_operator_treasury',a['arbitration_operator_treasury'],c);const d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20operator_fee='+c+')');const e=[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&e['push']({'who':{'Entity':a['arbitration_operator_treasury']},'sharing':String(c),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20(platform\x20commission\x200):\x20arbitrator\x20'+b+'/10000'+(c>0x0?',\x20arbitration\x20operator\x27s\x20own\x20fee\x20'+c+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':e,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20ARBITRATION_FEES_ALLOC=365),\x20with\x20or\x20without\x20a\x20Passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission','DIRECT-SALES\x20DEFAULT:\x20the\x20emitted\x20rows\x20are\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20arbitrator_treasury\x20—\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee,\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','arbitration_operator_fee_bps\x20is\x20the\x20arbitration\x20OPERATOR\x27s\x20own\x20declared\x20fee\x20(or\x20a\x20named\x20third\x20party\x27s),\x20default\x200;\x20it\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20and\x20is\x20never\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)','Every\x20rate\x20is\x20an\x20EXPLICIT\x20declared\x20share\x20to\x20an\x20EXPLICIT\x20non-empty\x20address:\x20nothing\x20here\x20is\x20an\x20implicit\x20platform\x20beneficiary\x20and\x20no\x20leg\x20is\x20left\x20unset\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86).\x20A\x20share\x20intended\x20for\x20a\x20third\x20party\x20is\x20the\x20payer\x27s\x20own\x20declared\x20price\x20and\x20must\x20be\x20named\x20on\x20both\x20sides']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone','Single\x20beneficiary\x20—\x20no\x20platform\x20leg.\x20The\x20stage-3\x20Surplus\x20is\x20this\x20contract\x27s\x20own\x20vesting\x20remainder,\x20NOT\x20a\x20fee:\x20Surplus\x20calls\x20balance::withdraw_all,\x20so\x20never\x20express\x20a\x20declared\x20fee\x20through\x20a\x20Surplus\x20leg\x20(L3\x20constraint\x203)']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer','The\x20issuer/employer\x20is\x20the\x20payer\x20and\x20keeps\x20the\x20whole\x20payroll\x20pool\x20by\x20default:\x20there\x20is\x20no\x20platform\x20share\x20in\x20this\x20template.\x20Every\x20rate\x20is\x20an\x20explicit\x20per-employee\x20price\x20to\x20an\x20explicit\x20non-empty\x20address\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/w/local/index.ts:74-86),\x20and\x20sum(rates)\x20MUST\x20stay\x2010000\x20so\x20no\x20residual\x20stays\x20claimable']}];export const ALLOCATION_TEMPLATES_VERSION='1.1.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
@@ -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.0.0";
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.0.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
+ 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,\x20so\x20a\x20settlement\x20'+'forward\x20can\x20still\x20FIRE\x20after\x20a\x20claim.\x20But\x20the\x20order\x20has\x20SEALED\x20itself:\x20compensate()\x20sets\x20'+'claimed_by\x20(single-use,\x20E_ORDER_ALREADY_CLAIMED),\x20and\x20both\x20owner_receive\x20entries\x20assert\x20'+'claimed_by\x20is\x20none\x20—\x20so\x20any\x20escrow\x20the\x20refund\x20track\x20splits\x20after\x20the\x20claim\x20is\x20UNCLAIMABLE\x20by\x20'+'anyone.\x20The\x20provider\x20release\x20track\x20(direct\x20transfer)\x20stays\x20usable.\x20So\x20\x27accept\x20both\x20payouts\x27\x20is\x20'+'NOT\x20available\x20by\x20default:\x20claim\x20→\x20refund\x20is\x20closed\x20by\x20the\x20seal;\x20only\x20refund\x20→\x20claim\x20stacks,\x20and\x20'+'that\x20direction\x20is\x20the\x20ARBITRATOR\x27S\x20to\x20net\x20(see\x20the\x20netting\x20rule)\x20or\x20the\x20merchant\x27s\x20to\x20gate\x20'+'(refund\x20allocator\x20Guard\x20on\x20order.claimed_by)'],'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 E of b['guards']){const F=E??{},G=F['vote_weight'];if(!G||typeof G!=='object')continue;if('GuardIdentifier'in G&&G['GuardIdentifier']!==undefined&&Number(G['GuardIdentifier'])>U8_MAX){e=Number(G['GuardIdentifier']);break;}if('FixedValue'in G&&G['FixedValue']!==undefined&&Number(G['FixedValue'])>U32_MAX){f=Number(G['FixedValue']);break;}}let h=![],i,j,k;if(c){const H=b['guards'];if(H['length']>=0x2){const I=H['filter'](J=>{const K=J?.['vote_weight'];return!!K&&typeof K==='object'&&'FixedValue'in K&&K['FixedValue']!==undefined;})['map'](J=>Number(J['vote_weight']['FixedValue']));if(I['length']>0x0){const J=I['reduce']((L,M)=>L+M,0x0),K=Math['max'](...I);J>0x0&&K/J>0.5&&(h=!![],i=K,j=J,k=(K/J*0x64)['toFixed'](0x1));}}}let l=![],m,n;if(a['dispute']&&a['current_arbitration_fee']!==undefined)try{const L=BigInt(a['current_arbitration_fee']),M=a['dispute']['fee'],N=typeof M==='object'&&M!==null&&'balance'in M?BigInt(M['balance']??0x0):BigInt(0x0);m=N['toString'](),n=L['toString'](),l=N<L;}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['current_arb_status'],x=a['expected_arb_status'],y=!!v&&!!x&&v!==x&&!isValidArbStatusTransition(v,x),z=!!v&&isTerminalArbStatus(v),A=z&&!a['arb_withdraw']&&!!(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']),B=a['reset']?String(a['reset']['arb']):undefined;let C,D;if(a['fees_transfer']){const O=a['fees_transfer']['to']??{};C='allocation'in O?'Allocation\x20'+O['allocation']:'Treasury\x20'+O['treasury'],D=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_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':v,'expected_arb_status':x,'arb_transition_invalid':y,'arb_status_terminal':z,'arb_terminal_op_blocked':A,'reset_present':!!a['reset'],'reset_arb':B,'fees_transfer_present':!!a['fees_transfer'],'fees_transfer_dest':C,'fees_transfer_remark':D,'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')};}
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[];