@wowok/agent-mcp 3.2.9 → 3.3.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 (207) hide show
  1. package/README.md +2 -2
  2. package/dist/chain-semantics/field-capability.js +1 -1
  3. package/dist/chain-semantics/freeze-map.js +1 -1
  4. package/dist/chain-semantics/fund-flow.js +1 -1
  5. package/dist/chain-semantics/object-graph.js +1 -1
  6. package/dist/composition/audit.js +1 -1
  7. package/dist/composition/compile.d.ts +10 -1
  8. package/dist/composition/compile.js +1 -1
  9. package/dist/composition/inflight.js +1 -1
  10. package/dist/extensions/capability-manifest.js +1 -1
  11. package/dist/extensions/industry-audit.spec.js +1 -1
  12. package/dist/extensions/industry-pack.js +1 -1
  13. package/dist/graph/onchain/facts.spec.js +1 -1
  14. package/dist/graph/onchain/field-manifest.js +1 -1
  15. package/dist/harness/recover.js +1 -1
  16. package/dist/intent/types.d.ts +1 -1
  17. package/dist/intent/types.js +1 -1
  18. package/dist/keeper/KeeperScan.d.ts +2 -1
  19. package/dist/keeper/KeeperScan.js +1 -1
  20. package/dist/keeper/keeper.spec.js +1 -1
  21. package/dist/keeper/types.d.ts +3 -0
  22. package/dist/keeper/types.js +1 -1
  23. package/dist/knowledge/allocator-rail-verifier.d.ts +34 -0
  24. package/dist/knowledge/allocator-rail-verifier.js +1 -0
  25. package/dist/knowledge/arbitration-ledger.js +1 -1
  26. package/dist/knowledge/arbitration-templates.js +1 -1
  27. package/dist/knowledge/arbitration-venue-order.js +1 -1
  28. package/dist/knowledge/audit-rules.d.ts +19 -1
  29. package/dist/knowledge/audit-rules.js +1 -1
  30. package/dist/knowledge/baselines/rules/alloc_audit.json +1 -1
  31. package/dist/knowledge/baselines/rules/arb.json +1 -1
  32. package/dist/knowledge/baselines/rules/guard.json +15 -5
  33. package/dist/knowledge/baselines/rules/machine.json +9 -6
  34. package/dist/knowledge/baselines/rules/plan.json +12 -12
  35. package/dist/knowledge/baselines/semantic-facts.js +1 -1
  36. package/dist/knowledge/builtin-templates.d.ts +1 -1
  37. package/dist/knowledge/builtin-templates.js +1 -1
  38. package/dist/knowledge/contract-invariants.js +1 -1
  39. package/dist/knowledge/event-semantics.js +1 -1
  40. package/dist/knowledge/fund-layer.js +1 -1
  41. package/dist/knowledge/getting-started.js +1 -1
  42. package/dist/knowledge/guard-anchor-reach.d.ts +1 -1
  43. package/dist/knowledge/guard-anchor-reach.js +1 -1
  44. package/dist/knowledge/guard-bindings.js +1 -1
  45. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  46. package/dist/knowledge/guard-design-patterns.js +1 -1
  47. package/dist/knowledge/guard-field-cognition.js +1 -1
  48. package/dist/knowledge/guard-render.js +1 -1
  49. package/dist/knowledge/guard-risk.js +1 -1
  50. package/dist/knowledge/guard-templates.d.ts +1 -1
  51. package/dist/knowledge/guard-templates.js +1 -1
  52. package/dist/knowledge/index.js +1 -1
  53. package/dist/knowledge/industry-registry.js +1 -1
  54. package/dist/knowledge/industry-strategy.js +1 -1
  55. package/dist/knowledge/jsonrpc-enum.js +1 -1
  56. package/dist/knowledge/machine-ledger.js +1 -1
  57. package/dist/knowledge/machine-puzzle.d.ts +1 -1
  58. package/dist/knowledge/machine-puzzle.js +1 -1
  59. package/dist/knowledge/machine-risk.js +1 -1
  60. package/dist/knowledge/machine-templates.js +1 -1
  61. package/dist/knowledge/machine-topology.d.ts +8 -0
  62. package/dist/knowledge/machine-topology.js +1 -1
  63. package/dist/knowledge/machine-translation.js +1 -1
  64. package/dist/knowledge/permission-ledger.js +1 -1
  65. package/dist/knowledge/protocol-facts.d.ts +16 -0
  66. package/dist/knowledge/protocol-facts.js +1 -0
  67. package/dist/knowledge/recipient-constraint.js +1 -1
  68. package/dist/knowledge/reward-ledger.d.ts +2 -1
  69. package/dist/knowledge/reward-ledger.js +1 -1
  70. package/dist/knowledge/reward-templates.js +1 -1
  71. package/dist/knowledge/safety-rules.d.ts +0 -2
  72. package/dist/knowledge/safety-rules.js +1 -1
  73. package/dist/knowledge/scenario-modes.d.ts +7 -0
  74. package/dist/knowledge/scenario-modes.js +1 -1
  75. package/dist/knowledge/strategy-manuals.js +1 -1
  76. package/dist/knowledge/template-loader.d.ts +13 -1
  77. package/dist/knowledge/template-loader.js +1 -1
  78. package/dist/knowledge/template-registry.js +1 -1
  79. package/dist/knowledge/template-scanner.js +1 -1
  80. package/dist/knowledge/tool-constraints.js +1 -1
  81. package/dist/knowledge/tools-reference.js +1 -1
  82. package/dist/monitor/MonitorLoop.js +1 -1
  83. package/dist/monitor/normalize.d.ts +1 -1
  84. package/dist/monitor/normalize.js +1 -1
  85. package/dist/monitor/types.d.ts +1 -1
  86. package/dist/monitor/types.js +1 -1
  87. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  88. package/dist/playbooks/service-build/game-theory.d.ts +1 -0
  89. package/dist/playbooks/service-build/game-theory.js +1 -1
  90. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  91. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  92. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  93. package/dist/playbooks/service-build/object-panorama.js +1 -1
  94. package/dist/playbooks/service-build/participation-radar.js +1 -1
  95. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  96. package/dist/playbooks/service-build/service-panorama.js +1 -1
  97. package/dist/playbooks/service-build/service-quote.js +1 -1
  98. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  99. package/dist/relationship/registry.js +1 -1
  100. package/dist/review/index.js +1 -1
  101. package/dist/role/profiles.js +1 -1
  102. package/dist/rules.js +1 -1
  103. package/dist/safety/confirm-gate.js +1 -1
  104. package/dist/schema/benchmark-migration/index.d.ts +5 -1
  105. package/dist/schema/benchmark-migration/index.js +1 -1
  106. package/dist/schema/call/arbitration.d.ts +4 -4
  107. package/dist/schema/call/arbitration.js +1 -1
  108. package/dist/schema/call/base.d.ts +39 -0
  109. package/dist/schema/call/base.js +1 -1
  110. package/dist/schema/call/bridge.d.ts +1 -0
  111. package/dist/schema/call/contact.d.ts +4 -4
  112. package/dist/schema/call/demand.d.ts +4 -4
  113. package/dist/schema/call/error-codes.d.ts +1 -1
  114. package/dist/schema/call/error-codes.js +1 -1
  115. package/dist/schema/call/handler.js +1 -1
  116. package/dist/schema/call/machine.d.ts +12 -4
  117. package/dist/schema/call/order.d.ts +4 -4
  118. package/dist/schema/call/permission.d.ts +4 -4
  119. package/dist/schema/call/progress.d.ts +4 -4
  120. package/dist/schema/call/receipt.d.ts +8 -0
  121. package/dist/schema/call/receipt.js +1 -1
  122. package/dist/schema/call/repository.d.ts +4 -4
  123. package/dist/schema/call/reward.d.ts +24 -4
  124. package/dist/schema/call/reward.js +1 -1
  125. package/dist/schema/call/semantic.js +1 -1
  126. package/dist/schema/call/service.d.ts +6 -4
  127. package/dist/schema/call/service.js +1 -1
  128. package/dist/schema/call/treasury.d.ts +4 -4
  129. package/dist/schema/common/index.d.ts +2 -2
  130. package/dist/schema/common/index.js +1 -1
  131. package/dist/schema/goal/index.d.ts +5 -1
  132. package/dist/schema/goal/planning.d.ts +10 -2
  133. package/dist/schema/goal/planning.js +1 -1
  134. package/dist/schema/industry-pack/index.d.ts +3 -0
  135. package/dist/schema/industry-pack/index.js +1 -1
  136. package/dist/schema/intent-radar/index.d.ts +9 -0
  137. package/dist/schema/intent-radar/index.js +1 -1
  138. package/dist/schema/local/index.d.ts +10 -0
  139. package/dist/schema/local/index.js +1 -1
  140. package/dist/schema/operations.d.ts +35 -22
  141. package/dist/schema/operations.js +1 -1
  142. package/dist/schema/query/bi.d.ts +16 -0
  143. package/dist/schema/query/bi.js +1 -1
  144. package/dist/schema/query/index.d.ts +52 -48
  145. package/dist/schema/query/index.js +1 -1
  146. package/dist/schema/schema-query/index.d.ts +1 -0
  147. package/dist/schema/schema-query/index.js +1 -1
  148. package/dist/schema/schema-version.js +1 -1
  149. package/dist/schema/workspace/index.d.ts +9 -0
  150. package/dist/schema/workspace/index.js +1 -1
  151. package/dist/schema-query-impl/index.d.ts +1 -1
  152. package/dist/schema-query-impl/index.js +1 -1
  153. package/dist/schemas/account_operation.output.json +1 -0
  154. package/dist/schemas/account_operation.schema.json +1 -1
  155. package/dist/schemas/benchmark_migration_operation.schema.json +27 -3
  156. package/dist/schemas/bridge_operation.output.json +1 -0
  157. package/dist/schemas/goal_operation.schema.json +26 -2
  158. package/dist/schemas/index.json +1 -1
  159. package/dist/schemas/industry_pack_operation.output.json +8 -0
  160. package/dist/schemas/industry_pack_operation.schema.json +9 -0
  161. package/dist/schemas/intent_radar.output.json +8 -2
  162. package/dist/schemas/intent_radar.schema.json +4 -1
  163. package/dist/schemas/local_cache_operation.output.json +1 -0
  164. package/dist/schemas/local_history_operation.output.json +1 -0
  165. package/dist/schemas/local_info_operation.output.json +1 -0
  166. package/dist/schemas/local_mark_operation.output.json +1 -0
  167. package/dist/schemas/monitor_events.schema.json +3 -1
  168. package/dist/schemas/onchain_events.output.json +275 -11
  169. package/dist/schemas/onchain_events.schema.json +25 -1
  170. package/dist/schemas/onchain_operations.output.json +40 -0
  171. package/dist/schemas/onchain_operations.schema.json +573 -104
  172. package/dist/schemas/onchain_operations_allocation.schema.json +2 -2
  173. package/dist/schemas/onchain_operations_arbitration.schema.json +11 -7
  174. package/dist/schemas/onchain_operations_contact.schema.json +9 -5
  175. package/dist/schemas/onchain_operations_demand.schema.json +9 -5
  176. package/dist/schemas/onchain_operations_guard.schema.json +342 -4
  177. package/dist/schemas/onchain_operations_machine.schema.json +17 -5
  178. package/dist/schemas/onchain_operations_order.schema.json +9 -5
  179. package/dist/schemas/onchain_operations_permission.schema.json +9 -5
  180. package/dist/schemas/onchain_operations_progress.schema.json +9 -5
  181. package/dist/schemas/onchain_operations_repository.schema.json +9 -5
  182. package/dist/schemas/onchain_operations_reward.schema.json +89 -9
  183. package/dist/schemas/onchain_operations_service.schema.json +18 -11
  184. package/dist/schemas/onchain_operations_treasury.schema.json +9 -5
  185. package/dist/schemas/query_toolkit.output.json +237 -14
  186. package/dist/schemas/schema_query.schema.json +3 -2
  187. package/dist/schemas/workspace_operation.output.json +23 -3
  188. package/dist/schemas/workspace_operation.schema.json +3 -3
  189. package/dist/tools/handlers/benchmark-migration.d.ts +45 -1
  190. package/dist/tools/handlers/benchmark-migration.js +1 -1
  191. package/dist/tools/handlers/config.js +1 -1
  192. package/dist/tools/handlers/industry-pack.js +1 -1
  193. package/dist/tools/handlers/intent-radar.js +1 -1
  194. package/dist/tools/handlers/keeper.d.ts +1 -1
  195. package/dist/tools/handlers/onchain.d.ts +12 -0
  196. package/dist/tools/handlers/onchain.js +1 -1
  197. package/dist/tools/handlers/schema-query.js +1 -1
  198. package/dist/tools/handlers/workflow.js +1 -1
  199. package/dist/tools/handlers/workspace.js +1 -1
  200. package/dist/tools/index.js +1 -1
  201. package/dist/tools/registry/agent.js +1 -1
  202. package/dist/tools/registry/business.js +1 -1
  203. package/dist/tools/registry/local.js +1 -1
  204. package/dist/tools/registry/query.js +1 -1
  205. package/dist/tools/rules-hook.js +1 -1
  206. package/dist/tools/wrap.js +1 -1
  207. package/package.json +2 -2
@@ -1 +1 @@
1
- import{ValueType}from'@wowok/wowok';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';function asNode(a){if(typeof a!=='object'||a===null)return null;const b=a['type'];return typeof b==='string'?a:null;}function queryMeta(a){if(typeof a!=='number'&&typeof a!=='string')return null;const b=getGuardQueryByIdOrName(a);return b?{'id':b['id'],'name':b['name']}:null;}function childNodes(a){const b=[];if(Array['isArray'](a['nodes']))a['nodes']['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);});if(asNode(a['node']))b['push'](asNode(a['node']));return[a['nodeLeft'],a['nodeRight']]['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);}),b;}export function classifyRecipient(a){if(typeof a!=='object'||a===null)return null;const b=a;if(typeof b['Entity']==='string')return{'kind':'entity','address':b['Entity']};const c=b['Entity'];if(c&&typeof c==='object'&&typeof c['name_or_address']==='string')return{'kind':'entity','address':c['name_or_address']};if(b['Signer']==='signer'||b['Signer']===!![])return{'kind':'signer'};if(typeof b['GuardIdentifier']==='number')return{'kind':'submission','identifier':b['GuardIdentifier']};return null;}function leafInfo(a,b){if(a['type']==='context'&&typeof a['context']==='string'){if(a['context']==='Signer')return{'kind':'signer'};if(a['context']==='Clock')return{'kind':'clock'};}if(a['type']==='query'){const c=queryMeta(a['query']),d=a['object'];if(c&&d&&typeof d['identifier']==='number')return{'kind':'query','query_name':c['name'],'query_id':c['id'],'object_identifier':d['identifier'],'convert_witness':d['convert_witness']};}if(a['type']==='identifier'){const e=typeof a['identifier']==='number'?a['identifier']:-0x1,f=b['find'](g=>g['identifier']===e);if(f){const g=typeof f['value']==='string'?f['value']:undefined,h=normalizeValueType(f['value_type']);if(h===ValueType['Address'])return{'kind':'static_address','value':g};if(h===ValueType['String'])return{'kind':'static_string','value':g};}}return{'kind':'other'};}function comparisonLeaves(a,b){if(a['type']==='logic_equal'){const c=childNodes(a)['map'](d=>flattenLeaf(d,b));return c;}return[];}function flattenLeaf(a,b){if(a['type']==='logic_not'){const d=childNodes(a)[0x0];return d?flattenLeaf(d,b):{'kind':'other'};}return leafInfo(a,b);}function isOrderProgressWitness(a){if(a===0x64)return!![];return typeof a==='string'&&a['toLowerCase']()['includes']('orderprogress');}function describe(a){switch(a){case'service_binding':return'Submitted\x20object\x20must\x20belong\x20to\x20the\x20expected\x20service';case'progress_node_state':return'Submitted\x20order\x20must\x20be\x20at\x20a\x20qualifying\x20workflow\x20node';case'signer_is_submitted_object_owner':return'Caller\x20must\x20be\x20the\x20owner\x20of\x20the\x20submitted\x20object';case'signer_authorized_entity':return'Caller\x20must\x20equal\x20a\x20fixed\x20authorized\x20address';case'signer_permission_member':return'Caller\x20must\x20satisfy\x20a\x20Permission\x20membership\x20rule';case'time_lock':return'Current\x20time\x20must\x20satisfy\x20the\x20time-lock';case'repository_crosscheck':return'Repository\x20data\x20must\x20satisfy\x20the\x20cross-check';default:return'Other\x20guard\x20constraint';}}function extractConstraints(a,b){const c=[],d=new Set(),e=h=>{const i=h['code']+':'+(h['slot']??'-');!d['has'](i)&&(d['add'](i),c['push'](h));},f=(h,i)=>({'path':h,'queries':i}),g=(h,i)=>{const j=comparisonLeaves(h,b);if(j['length']>=0x2){const k=j['find'](r=>r['kind']==='signer'),l=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.owner'),m=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.service'),n=j['find'](r=>r['kind']==='query'&&r['query_name']==='progress.current'),o=j['find'](r=>r['kind']==='static_address'),p=j['find'](r=>r['kind']==='static_string');k&&l&&e({'code':'signer_is_submitted_object_owner','slot':l['object_identifier'],'description':describe('signer_is_submitted_object_owner'),'caller_constraint':!![],'evidence':f(i,['Signer','order.owner'])});k&&o&&e({'code':'signer_authorized_entity','description':describe('signer_authorized_entity'),'caller_constraint':!![],'evidence':f(i,['Signer'])});m&&o&&e({'code':'service_binding','slot':m['object_identifier'],'description':describe('service_binding'),'caller_constraint':![],'evidence':f(i,['order.service'])});if(n&&p){const r=n['object_identifier'];isOrderProgressWitness(n['convert_witness'])&&e({'code':'progress_node_state','slot':r,'description':describe('progress_node_state'),'caller_constraint':![],'evidence':f(i,['progress.current'])});}}if(h['type']['startsWith']('logic_as_u256')||h['type']==='calc_number_add'){const s=[h,...childNodes(h)]['map'](t=>flattenLeaf(t,b));if(s['some'](t=>t['kind']==='clock')&&s['some'](t=>t['kind']==='query'&&(t['query_name']==='progress.current_time'||t['query_name']==='progress.session.forward.time'))){const t=s['find'](u=>u['kind']==='query');e({'code':'time_lock','slot':t['object_identifier'],'description':describe('time_lock'),'caller_constraint':![],'evidence':f(i,['Clock',t['query_name']])});}}if(h['type']==='query'){const u=queryMeta(h['query']);if(u&&u['name']['startsWith']('repository.')){const v=h['object'];e({'code':'repository_crosscheck','slot':v?.['identifier'],'description':describe('repository_crosscheck'),'caller_constraint':![],'evidence':f(i,[u['name']])});}}childNodes(h)['forEach']((w,x)=>g(w,i+'/'+x));};return g(a,'/root'),c;}function findSessionQueries(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']);if(f&&(f['id']===0x4f6||f['id']===0x4f7))b['push'](e);}childNodes(d)['forEach']((g,h)=>c(g,e+'/'+h));};return c(a,'/root'),b;}function collectSlotUsages(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']),g=d['object'];f&&g&&typeof g['identifier']==='number'&&b['push']({'slot':g['identifier'],'path':e,'query_id':f['id'],'query_name':f['name'],...g['convert_witness']!==undefined?{'convert_witness':g['convert_witness']}:{}});}childNodes(d)['forEach']((h,j)=>c(h,e+'/'+j));};return c(a,'/root'),b;}function deriveReceiptRight(a,b){const c=b['find'](e=>e['code']==='progress_node_state'&&e['slot']===a),d=b['find'](e=>e['code']==='signer_is_submitted_object_owner'&&e['slot']===a);if(c||d)return{'object_type':'order','receive_entry':'owner-side\x20extraction\x20on\x20the\x20order','guarantee':'Delivered\x20funds\x20are\x20owned\x20by\x20the\x20submitted\x20Order;\x20only\x20its\x20current\x20owner\x20can\x20'+'extract\x20them\x20(&mut\x20Order\x20input),\x20and\x20coins\x20transfer\x20to\x20that\x20owner.'};return undefined;}function deriveBeneficialOwner(a,b){switch(a['kind']){case'entity':return'Fixed\x20entity\x20'+a['address'];case'signer':return'Transaction\x20caller\x20(Signer)\x20—\x20direct\x20wallet';case'submission':return b?'Owner\x20of\x20the\x20submitted\x20object\x20at\x20table['+a['identifier']+']\x20(object\x20receipt\x20=\x20owner\x20receipt)':'Address\x20submitted\x20at\x20table['+a['identifier']+']\x20(caller-provided)';}}function buildSlotModels(a,b,c,d){const e=[...new Set(c['map'](f=>f['spec'])['filter'](f=>f['kind']==='submission')['map'](f=>f['identifier']))];return e['map'](f=>{const g=a['find'](p=>p['identifier']===f),h=g?normalizeValueType(g['value_type']):undefined,i=h===ValueType['Address'],j=b['filter'](p=>p['slot']===f),k=c['filter'](p=>p['spec']['kind']==='submission'&&p['spec']['identifier']===f)['map'](p=>p['mode']??'Unknown'),l=d['filter'](p=>p['slot']===undefined||p['slot']===f),m=deriveReceiptRight(f,d),n=l['some'](p=>p['code']==='service_binding'||p['code']==='repository_crosscheck'||p['code']==='signer_permission_member'),o=[];if(h!==undefined&&!i)o['push']('RC-FIND-07');if(!n)o['push']('RC-FIND-02');if(m?.['object_type']==='order')o['push']('RC-FIND-03');return{'identifier':f,'externally_submitted':g?.['b_submission']??!![],...h!==undefined?{'declared_value_type':h}:{},'is_address':i,'usages':j,'recipient_modes':k,'constraints':l,...m?{'receipt':m}:{},'beneficial_owner':deriveBeneficialOwner({'kind':'submission','identifier':f},m),'assessment':{'address_typed':i,'scope_bound':n,'object_receipt':m?.['object_type']==='order'},'findings':o};});}function buildSlotFinding(a,b,c){const d=a['identifier'];switch(b){case'RC-FIND-07':return{'code':b,'severity':'medium','title':'Submission\x20slot\x20'+d+'\x20is\x20not\x20address-typed','explanation':'GuardIdentifier\x20recipients\x20require\x20an\x20address-typed\x20table\x20entry\x20'+'(enforced\x20at\x20allocator\x20registration\x20/\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','evidence_paths':c,'mitigation':'Set\x20the\x20slot\x20value_type\x20to\x20Address,\x20or\x20use\x20an\x20Entity\x20recipient.','unavoidable':![]};case'RC-FIND-02':return{'code':b,'severity':'high','title':'Submission\x20slot\x20'+d+'\x20has\x20no\x20scope\x20binding','explanation':'Nothing\x20constrains\x20which\x20submitted\x20objects/addresses\x20qualify:\x20no\x20'+'service\x20binding,\x20repository\x20cross-check\x20or\x20permission\x20membership.\x20A\x20caller\x20'+'can\x20submit\x20arbitrary\x20qualifying-by-other-conditions\x20inputs.','evidence_paths':c,'mitigation':'Add\x20a\x20constraint\x20binding\x20the\x20slot\x20(e.g.\x20order.service\x20==\x20host\x20service).','unavoidable':![]};case'RC-FIND-03':return{'code':b,'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','explanation':'The\x20submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20Allocation\x20being\x20settled\x20'+'(alloc\x20is\x20permissionless\x20and\x20allocation\x20context\x20is\x20not\x20a\x20Guard\x20input).\x20A\x20'+'caller\x20owning\x20ANY\x20qualifying\x20order\x20can\x20settle\x20OTHER\x20allocations;\x20funds\x20land\x20'+'at\x20the\x20submitted\x20order\x20and\x20are\x20receivable\x20by\x20its\x20owner.\x20Destination\x20is\x20safe\x20'+'(an\x20order\x20owner),\x20allocation\x20choice\x20is\x20the\x20residual.','evidence_paths':c,'mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20—\x20declare\x20that\x20any\x20qualifying\x20order\x20may\x20settle\x20'+'this\x20allocation\x20and\x20cap\x20the\x20exposure\x20(sharing\x20threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20—\x20use\x20a\x20fixed\x20Entity\x20(treasury)\x20recipient,\x20the\x20only\x20'+'exclusive\x20choice\x20on\x20the\x20automatic\x20order_allocators\x20route\x20(trust\x20shifts\x20to\x20'+'the\x20entity\x20operator);\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20—\x20abandon\x20automatic\x20order_allocators\x20and\x20attach\x20'+'a\x20per-order\x20Guard\x20pinning\x20the\x20order\x20id\x20(order.owner\x20==\x20constant),\x20the\x20'+'trustless\x20exclusive\x20route.','unavoidable':!![],'resolution_required':!![]};default:return{'code':b,'severity':'low','title':'Slot\x20'+d+'\x20finding\x20'+b,'explanation':'','evidence_paths':c,'mitigation':'','unavoidable':![]};}}function buildFindings(a,b){const c=[];let d=![],e=![];for(const f of b){const g=f['recipients']['flatMap'](h=>h['constraints'])['filter'](h=>h['caller_constraint']);if(g['length']>0x0)d=!![];if(f['slots']['some'](h=>h['assessment']['scope_bound']))e=!![];for(const h of f['recipients']){const i=h['constraints']['map'](j=>j['evidence']['path']);h['spec']['kind']==='signer'&&g['length']===0x0&&c['push']({'code':'RC-FIND-01','severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','explanation':'Funds\x20are\x20delivered\x20directly\x20to\x20the\x20transaction\x20caller,\x20but\x20the\x20Guard\x20'+'does\x20not\x20bind\x20the\x20Signer\x20to\x20an\x20authorized\x20identity.\x20Anyone\x20who\x20satisfies\x20the\x20'+'other\x20conditions\x20steals\x20the\x20funds.','evidence_paths':i,'mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.','unavoidable':![]});}for(const j of f['slots']){const k=j['constraints']['map'](l=>l['evidence']['path']);for(const l of j['findings']){c['push'](buildSlotFinding(j,l,k));}}a['trigger_source']==='service_order_allocators'&&f['recipients']['length']>0x0&&!f['recipients']['some'](m=>m['spec']['kind']==='submission')&&c['push']({'code':'RC-FIND-09','severity':'low','title':'Allocator\x20Guard\x20'+f['guard']+'\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','explanation':'Every\x20sharing\x20row\x20is\x20a\x20fixed\x20recipient\x20(Entity/Signer),\x20which\x20resolves\x20no\x20'+'submission.\x20The\x20Guard\x20therefore\x20cannot\x20read\x20the\x20paying\x20order\x20(order.*\x20queries\x20have\x20'+'no\x20binding\x20target),\x20and\x20the\x20allocation\x20pays\x20the\x20same\x20fixed\x20destinations\x20for\x20EVERY\x20order.\x20'+'This\x20is\x20often\x20intended\x20—\x20confirm\x20it\x20is.','evidence_paths':[],'mitigation':'If\x20the\x20Guard\x20should\x20distinguish\x20orders,\x20add\x20a\x20zero-share\x20{GuardIdentifier:\x200}\x20'+'anchor\x20row\x20(Rate\x200)\x20so\x20the\x20Identifier\x20slot\x20resolves\x20to\x20the\x20paying\x20order\x20'+'(pattern.allocator_order_anchor).\x20If\x20fixed-pay\x20is\x20intended,\x20no\x20action.','unavoidable':![]});}a['trigger_source']==='standalone'&&!d&&c['push']({'code':'RC-FIND-04','severity':'high','title':'Standalone\x20allocation\x20without\x20issuer\x20identity\x20constraint','explanation':'Standalone\x20allocations\x20have\x20no\x20Service/Arbitration\x20access-control\x20layer.\x20'+'Without\x20a\x20Signer/permission\x20binding\x20in\x20the\x20Guard,\x20anyone\x20can\x20trigger\x20distribution.','evidence_paths':[],'mitigation':'Bind\x20the\x20issuer\x20(Signer==owner/admin)\x20or\x20move\x20the\x20allocation\x20into\x20a\x20Service.','unavoidable':![]});c['push']({'code':'RC-FIND-06','severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','explanation':'Once\x20the\x20Guard\x27s\x20conditions\x20are\x20satisfiable,\x20anyone\x20can\x20trigger\x20settlement\x20of\x20an\x20'+'order\x27s\x20allocation.\x20With\x20Entity/object\x20recipients\x20this\x20affects\x20timing\x20only,\x20not\x20destination.','evidence_paths':[],'mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.','unavoidable':!![]});for(const [m,n]of Object['entries'](a['guards']??{})){const o=asNode(n['root']);if(!o)continue;for(const q of findSessionQueries(o)){c['push']({'code':'RC-FIND-05','severity':'medium','title':'Guard\x20'+m+'\x20uses\x20session-only\x20query\x20at\x20'+q,'explanation':'Queries\x201270/1271\x20read\x20the\x20active\x20session;\x20after\x20the\x20session\x20migrates\x20to\x20'+'history\x20the\x20query\x20aborts\x20(W_FIELD_NOT_FOUND)\x20and\x20the\x20Guard\x20permanently\x20fails.','evidence_paths':[q],'mitigation':'Use\x20progress.current_time\x20(1272)\x20or\x20history\x20queries\x20(1274-1279).','unavoidable':![]});}}for(const [s,t]of Object['entries'](a['guards']??{})){const u=(t['relies']??[])['filter'](v=>typeof v==='string'&&v);if(u['length']===0x0)continue;c['push']({'code':'RC-FIND-08','severity':'low','title':'Guard\x20'+s+'\x20relies\x20on\x20'+u['length']+'\x20sub-guard(s)\x20—\x20not\x20credited\x20by\x20this\x20audit','explanation':'Guard\x20composition\x20(relies,\x20one\x20level,\x20≤4,\x20'+((t['relies_logic_and']===![]?'OR':'AND')+'-logic)\x20may\x20carry\x20the\x20scope/signer\x20')+'constraints\x20in\x20the\x20relied\x20sub-guards.\x20This\x20audit\x20evaluates\x20only\x20the\x20guard\x27s\x20own\x20root:\x20'+'sub-guard\x20constraints\x20are\x20NOT\x20credited,\x20so\x20scope-binding\x20gaps\x20(RC-FIND-02)\x20may\x20be\x20'+'over-reported\x20and\x20sub-guard-only\x20conditions\x20stay\x20unverified.','evidence_paths':u,'mitigation':'Resolve\x20the\x20relied\x20sub-guards\x20and\x20verify\x20their\x20constraints\x20manually,\x20or\x20re-run\x20'+'with\x20the\x20sub-guard\x20defs\x20included\x20(read-side\x20resolvers\x20attach\x20them\x20automatically).','unavoidable':![]});}if(!e&&a['trigger_source']==='service_order_allocators'){}return c;}function buildPayoff(a,b){const c=a['recipients']['some'](h=>h['constraints']['some'](i=>i['caller_constraint'])),d=c?'Caller\x20must\x20satisfy\x20the\x20Guard\x27s\x20Signer/identity\x20binding':b==='standalone'?'Any\x20caller\x20(no\x20identity\x20binding)':'Any\x20caller\x20who\x20satisfies\x20the\x20Guard\x27s\x20object/state\x20conditions',e=a['recipients']['map'](h=>h['beneficial_owner'])['join'](';\x20')||'(none)',f={},g=a['recipients']['some'](h=>h['spec']['kind']==='signer'&&!c);return f['caller']=g?'gains':c?'conditional':'neutral',f['provider']=a['recipients']['some'](h=>h['spec']['kind']==='entity')?'gains':'conditional',f['customer']=a['recipients']['some'](h=>h['receipt']?.['object_type']==='order')?'conditional':'neutral',f['system']='neutral',{'caller_eligibility':d,'beneficial_recipient':e,'positions':f};}export const RECIPIENT_CONSTRAINT_VERSION='1.2.0';export function analyzeRecipientConstraints(a){const b=a['allocators']['map'](h=>{const i=a['guards']?.[h['guard']],j=asNode(i?.['root']),k=i?.['table']??[],l=j?extractConstraints(j,k):[],m=j?collectSlotUsages(j):[],n=h['sharing']['map'](q=>{const r=classifyRecipient(q['who']);if(!r)return{'spec':{'kind':'entity','address':'(unclassifiable)'},'constraints':l,'beneficial_owner':'Unclassifiable\x20recipient\x20—\x20check\x20allocator\x20config'};const t=r['kind']==='submission'?r['identifier']:undefined,u=t!==undefined?k['find'](w=>w['identifier']===t):undefined,v=t!==undefined?deriveReceiptRight(t,l):undefined;return{'spec':r,'slot_value_type':u?normalizeValueType(u['value_type']):undefined,'constraints':t!==undefined?l['filter'](w=>w['slot']===undefined||w['slot']===t):l,'receipt':v,'beneficial_owner':deriveBeneficialOwner(r,v)};}),o=buildSlotModels(k,m,h['sharing']['map'](q=>({'spec':classifyRecipient(q['who'])??{'kind':'entity','address':'(unclassifiable)'},'mode':q['mode']})),l),p={'guard':h['guard'],'recipients':n,'slots':o,'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return p['payoff']=buildPayoff(p,a['trigger_source']),p;}),c=buildFindings(a,b),d=c['some'](h=>h['severity']==='critical')?'critical':c['some'](h=>h['severity']==='high')?'high':c['some'](h=>h['severity']==='medium')?'medium':'low',e=!c['some'](h=>h['code']==='RC-FIND-01'),f=c['some'](h=>h['resolution_required']),g=[{'code':'RC-FIND-03','title':'Cross-allocation\x20settlement','detail':'Submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20settled\x20allocation;\x20destination\x20stays\x20at\x20an\x20order\x20owner.'},{'code':'RC-FIND-06','title':'Forced\x20settlement\x20timing','detail':'alloc\x20is\x20permissionless;\x20settlement\x20can\x20be\x20triggered\x20by\x20anyone\x20once\x20conditions\x20hold.'},{'code':'RC-RES-01','title':'Published\x20immutability','detail':'order_allocators,\x20Machine\x20and\x20Guards\x20are\x20immutable\x20after\x20publish.'},{'code':'RC-RES-03','title':'Off-chain\x20arbitration\x20backstop','detail':'No\x20on-chain\x20clawback;\x20post-incident\x20recovery\x20relies\x20on\x20arbitration.'}];return{'version':RECIPIENT_CONSTRAINT_VERSION,'scope':{'trigger_source':a['trigger_source'],'host_service':a['host_service'],'allocation':a['allocation']},'allocators':b,'findings':c,'unavoidable':g,'safe_destination':e,'resolution_required':f,'overall':d,'summary':'Analyzed\x20'+b['length']+'\x20allocator(s):\x20'+c['filter'](h=>!h['unavoidable'])['length']+'\x20actionable,\x20'+(c['filter'](h=>h['unavoidable'])['length']+'\x20structural\x20finding(s).\x20Safe\x20destination:\x20'+e+'.')+(''+(f?'\x20Resolution\x20REQUIRED:\x20at\x20least\x20one\x20residual\x20demands\x20an\x20explicit\x20design\x20decision\x20before\x20publish.':''))};}export function derivePayoffFromSharing(a,b,c){const d=asNode(c?.['root']),e=c?.['table']??[],f=d?extractConstraints(d,e):[],g=a['map'](i=>{const j=classifyRecipient(i['who'])??{'kind':'entity','address':'(unclassifiable)'},k=j['kind']==='submission'?j['identifier']:undefined,l=k!==undefined?e['find'](n=>n['identifier']===k):undefined,m=k!==undefined?deriveReceiptRight(k,f):undefined;return{'spec':j,'slot_value_type':l?normalizeValueType(l['value_type']):undefined,'constraints':k!==undefined?f['filter'](n=>n['slot']===undefined||n['slot']===k):f,'receipt':m,'beneficial_owner':deriveBeneficialOwner(j,m)};}),h={'guard':'','recipients':g,'slots':[],'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return buildPayoff(h,b);}function normalizeValueType(a){if(typeof a==='number')return a;const b={'bool':ValueType['Bool'],'address':ValueType['Address'],'string':ValueType['String'],'u64':ValueType['U64'],'u256':ValueType['U256']};return b[a['toLowerCase']()];}export function isUnboundSignerTheft(a){return a['recipient_is_signer']&&!a['caller_identity_constrained'];}export function canonicalDoctrine(a){switch(a){case'RC-FIND-01':return{'severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.'};case'RC-FIND-03':return{'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20with\x20capped\x20exposure\x20(threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20(treasury)\x20—\x20the\x20only\x20exclusive\x20choice\x20on\x20the\x20automatic\x20'+'order_allocators\x20route;\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20(order.owner\x20==\x20constant)\x20—\x20the\x20trustless\x20'+'exclusive\x20route.','resolution_required':!![]};case'RC-FIND-06':return{'severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.'};}}export const RECIPIENT_DESIGN_OPTIONS=[{'id':'entity','move_recipient':'Recipient::Entity(address)','semantics':'Funds\x20flow\x20to\x20a\x20fixed\x20address\x20(a\x20constrained\x20user\x20account\x20/\x20treasury).\x20'+'Destination\x20never\x20depends\x20on\x20the\x20caller.','required_constraints':['The\x20address\x20is\x20chosen\x20at\x20design\x20time\x20and\x20recorded\x20in\x20the\x20allocator\x20table.']},{'id':'submitted_object','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20the\x20object\x20submitted\x20under\x20protocol\x20context\x20(e.g.\x20the\x20order\x20being\x20settled).\x20'+'Receivable\x20only\x20by\x20that\x20object\x27s\x20owner\x20—\x20object\x20receipt\x20=\x20owner\x20receipt.','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(which\x20query/object\x20type\x20the\x20slot\x20carries).','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-02\x20/\x20RC-FIND-07'},{'id':'signer','move_recipient':'Recipient::Signer','semantics':'Funds\x20flow\x20to\x20the\x20caller\x20who\x20executes\x20the\x20permissionless\x20alloc.\x20'+'Safe\x20only\x20when\x20the\x20Guard\x20proves\x20exactly\x20who\x20the\x20caller\x20may\x20be.','required_constraints':['The\x20Guard\x20constrains\x20the\x20Signer\x20identity\x20(signer\x20==\x20a\x20fixed\x20address\x20or\x20a\x20derived\x20legitimate\x20owner).'],'finding_if_unmet':'RC-FIND-01'},{'id':'constrained_submission','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20an\x20object\x20address\x20supplied\x20by\x20the\x20signer,\x20but\x20the\x20Guard\x20constrains\x20'+'both\x20the\x20submission\x20scope\x20and\x20the\x20signer\x27s\x20relation\x20to\x20it\x20(e.g.\x20the\x20signer\x20owns\x20the\x20submitted\x20order).','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(object/query\x20type).','The\x20Guard\x20binds\x20the\x20signer\x20to\x20the\x20submitted\x20object.','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-01\x20/\x20RC-FIND-02\x20/\x20RC-FIND-07'}];export function recipientDesignGuidance(){return RECIPIENT_DESIGN_OPTIONS;}export const OBJECT_DRIVEABILITY=[{'object_type':'order','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20order','owner-side\x20object\x20extraction\x20from\x20the\x20order'],'anyone_drivable':!![],'funds_settle_to':'order.owner','rationale':'Order\x20is\x20a\x20shared\x20object\x20and\x20extraction\x20has\x20no\x20signer\x20gate;\x20'+'Receiving\x20is\x20restricted\x20to\x20objects\x20actually\x20delivered\x20to\x20that\x20order,\x20and\x20coins\x20settle\x20to\x20its\x20owner.'},{'object_type':'permission','receive_entries':['owner-side\x20coin\x20extraction\x20via\x20the\x20permission\x20object','owner-side\x20object\x20extraction\x20via\x20the\x20permission\x20object'],'anyone_drivable':!![],'funds_settle_to':'permission.owner','rationale':'Permission\x20is\x20the\x20final\x20authority;\x20anyone\x20can\x20drive\x20extraction\x20of\x20funds\x20sent\x20to\x20its\x20address,\x20but\x20the\x20destination\x20is\x20its\x20owner.'},{'object_type':'service','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20service','owner-side\x20object\x20extraction\x20from\x20the\x20service'],'anyone_drivable':![],'permission_index':0x13f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20319);\x20members\x20drive,\x20value\x20settles\x20to\x20the\x20organization\x20owner.'},{'object_type':'treasury','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20treasury','owner-side\x20object\x20extraction\x20from\x20the\x20treasury'],'anyone_drivable':![],'permission_index':0x101,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20257).'},{'object_type':'arbitration','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20arbitration','owner-side\x20object\x20extraction\x20from\x20the\x20arbitration'],'anyone_drivable':![],'permission_index':0x16f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20367).'},{'object_type':'machine','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20machine','owner-side\x20object\x20extraction\x20from\x20the\x20machine'],'anyone_drivable':![],'permission_index':0xcf,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20207).'},{'object_type':'progress','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20progress','owner-side\x20object\x20extraction\x20from\x20the\x20progress'],'anyone_drivable':![],'permission_index':0xe1,'funds_settle_to':'machine\x27s\x20permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20225),\x20scoped\x20to\x20the\x20Machine\x20permission.'},{'object_type':'demand','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20demand','owner-side\x20object\x20extraction\x20from\x20the\x20demand'],'anyone_drivable':![],'permission_index':0x197,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20407).'},{'object_type':'contact','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20contact','owner-side\x20object\x20extraction\x20from\x20the\x20contact'],'anyone_drivable':![],'permission_index':0x1c6,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20454).'}];export function driveabilityOf(a){return OBJECT_DRIVEABILITY['find'](b=>b['object_type']===a);}function rewardRecipientKind(a){if(typeof a==='string'){const e=a['toLowerCase']();if(e==='signer')return{'kind':'signer'};return{'kind':'entity'};}if(typeof a!=='object'||a===null)return{'kind':'entity'};const b=a,c=f=>typeof b[f]==='number'?b[f]:undefined,d=c('GuardIdentifier')??c('guard_identifier')??c('identifier');if(d!==undefined)return{'kind':'submission','slot':d};if(b['Signer']!==undefined||b['signer']!==undefined)return{'kind':'signer'};return{'kind':'entity'};}const SLOT_BINDING_CODES=new Set(['service_binding','progress_node_state','signer_is_submitted_object_owner','repository_crosscheck','signer_permission_member']);export function analyzeRewardClaimGuard(a){const {kind:b,slot:c}=rewardRecipientKind(a['recipient']),d={'entry_index':a['entry_index'],'guard':a['guard'],'recipient_kind':b,...c!==undefined?{'recipient_slot':c}:{},'guard_resolved':![],'constraint_codes':[],'recipient_slot_usages':0x0,'caller_identity_constrained':![],'viability':'unverifiable','reason':'Guard\x20table/root\x20not\x20fetched\x20with\x20the\x20topology\x20—\x20the\x20deciding\x20predicate\x20is\x20outside\x20the\x20evidence;\x20the\x20owner\x20must\x20disclose\x20the\x20full\x20guard\x20definitions.'},e=asNode(a['guard_def']?.['root']);if(!e)return d;const f=a['guard_def']?.['table']??[],g=extractConstraints(e,f);d['guard_resolved']=!![],d['constraint_codes']=g['map'](k=>k['code']),d['caller_identity_constrained']=g['some'](k=>k['caller_constraint']);if(b==='entity')return d['viability']='blocked',d['reason']='Payout\x20address\x20is\x20fixed\x20at\x20guard\x20registration\x20(Entity\x20recipient);\x20the\x20claim\x20path\x20cannot\x20redirect\x20it.',d;if(b==='signer')return d['caller_identity_constrained']?(d['viability']='blocked',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20but\x20the\x20guard\x20binds\x20the\x20caller\x20identity\x20—\x20only\x20the\x20authorized\x20party\x20can\x20claim.'):(d['viability']='viable',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20with\x20no\x20identity\x20binding\x20—\x20anyone\x20satisfying\x20the\x20remaining\x20conditions\x20claims\x20to\x20their\x20own\x20address.'),d;const h=c??-0x1,i=collectSlotUsages(e)['filter'](k=>k['slot']===h);d['recipient_slot_usages']=i['length'];const j=g['filter'](k=>k['slot']===h&&SLOT_BINDING_CODES['has'](k['code']));if(j['length']>0x0)d['viability']='blocked',d['reason']='Submitted\x20address\x20is\x20constrained\x20inside\x20the\x20guard\x20('+j['map'](k=>k['code'])['join'](',\x20')+')\x20—\x20a\x20passerby\x20cannot\x20fill\x20the\x20slot\x20with\x20an\x20arbitrary\x20address.';else i['length']>0x0?(d['viability']='conditional',d['reason']='The\x20guard\x20reads\x20the\x20submitted\x20slot\x20('+i['length']+'\x20query\x20usage(s))\x20but\x20no\x20recognized\x20scope/equality\x20constraint\x20was\x20matched\x20—\x20manual\x20predicate\x20review\x20required.'):(d['viability']='viable',d['reason']='No\x20guard\x20query\x20consumes\x20the\x20submitted\x20slot\x20—\x20the\x20predicate\x20cannot\x20constrain\x20the\x20payout\x20address;\x20any\x20passing\x20party\x20claims\x20to\x20their\x20own\x20address.');return d;}
1
+ import{ValueType}from'@wowok/wowok';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';function asNode(a){if(typeof a!=='object'||a===null)return null;const b=a['type'];return typeof b==='string'?a:null;}function queryMeta(a){if(typeof a!=='number'&&typeof a!=='string')return null;const b=getGuardQueryByIdOrName(a);return b?{'id':b['id'],'name':b['name']}:null;}function childNodes(a){const b=[];if(Array['isArray'](a['nodes']))a['nodes']['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);});if(asNode(a['node']))b['push'](asNode(a['node']));return[a['nodeLeft'],a['nodeRight']]['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);}),b;}export function classifyRecipient(a){if(typeof a!=='object'||a===null)return null;const b=a;if(typeof b['Entity']==='string')return{'kind':'entity','address':b['Entity']};const c=b['Entity'];if(c&&typeof c==='object'&&typeof c['name_or_address']==='string')return{'kind':'entity','address':c['name_or_address']};if(b['Signer']==='signer'||b['Signer']===!![])return{'kind':'signer'};if(typeof b['GuardIdentifier']==='number')return{'kind':'submission','identifier':b['GuardIdentifier']};return null;}function leafInfo(a,b){if(a['type']==='context'&&typeof a['context']==='string'){if(a['context']==='Signer')return{'kind':'signer'};if(a['context']==='Clock')return{'kind':'clock'};}if(a['type']==='query'){const c=queryMeta(a['query']),d=a['object'];if(c&&d&&typeof d['identifier']==='number')return{'kind':'query','query_name':c['name'],'query_id':c['id'],'object_identifier':d['identifier'],'convert_witness':d['convert_witness']};}if(a['type']==='identifier'){const e=typeof a['identifier']==='number'?a['identifier']:-0x1,f=b['find'](g=>g['identifier']===e);if(f){const g=typeof f['value']==='string'?f['value']:undefined,h=normalizeValueType(f['value_type']);if(h===ValueType['Address'])return{'kind':'static_address','value':g};if(h===ValueType['String'])return{'kind':'static_string','value':g};}}return{'kind':'other'};}function comparisonLeaves(a,b){if(a['type']==='logic_equal'){const c=childNodes(a)['map'](d=>flattenLeaf(d,b));return c;}return[];}function flattenLeaf(a,b){if(a['type']==='logic_not'){const d=childNodes(a)[0x0];return d?flattenLeaf(d,b):{'kind':'other'};}return leafInfo(a,b);}function isOrderProgressWitness(a){if(a===0x64)return!![];return typeof a==='string'&&a['toLowerCase']()['includes']('orderprogress');}function describe(a){switch(a){case'service_binding':return'Submitted\x20object\x20must\x20belong\x20to\x20the\x20expected\x20service';case'progress_node_state':return'Submitted\x20order\x20must\x20be\x20at\x20a\x20qualifying\x20workflow\x20node';case'signer_is_submitted_object_owner':return'Caller\x20must\x20be\x20the\x20owner\x20of\x20the\x20submitted\x20object';case'signer_authorized_entity':return'Caller\x20must\x20equal\x20a\x20fixed\x20authorized\x20address';case'signer_permission_member':return'Caller\x20must\x20satisfy\x20a\x20Permission\x20membership\x20rule';case'time_lock':return'Current\x20time\x20must\x20satisfy\x20the\x20time-lock';case'repository_crosscheck':return'Repository\x20data\x20must\x20satisfy\x20the\x20cross-check';default:return'Other\x20guard\x20constraint';}}function extractConstraints(a,b){const c=[],d=new Set(),e=h=>{const i=h['code']+':'+(h['slot']??'-');!d['has'](i)&&(d['add'](i),c['push'](h));},f=(h,i)=>({'path':h,'queries':i}),g=(h,i)=>{const j=comparisonLeaves(h,b);if(j['length']>=0x2){const k=j['find'](r=>r['kind']==='signer'),l=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.owner'),m=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.service'),n=j['find'](r=>r['kind']==='query'&&r['query_name']==='progress.current'),o=j['find'](r=>r['kind']==='static_address'),p=j['find'](r=>r['kind']==='static_string');k&&l&&e({'code':'signer_is_submitted_object_owner','slot':l['object_identifier'],'description':describe('signer_is_submitted_object_owner'),'caller_constraint':!![],'evidence':f(i,['Signer','order.owner'])});k&&o&&e({'code':'signer_authorized_entity','description':describe('signer_authorized_entity'),'caller_constraint':!![],'evidence':f(i,['Signer'])});m&&o&&e({'code':'service_binding','slot':m['object_identifier'],'description':describe('service_binding'),'caller_constraint':![],'evidence':f(i,['order.service'])});if(n&&p){const r=n['object_identifier'];isOrderProgressWitness(n['convert_witness'])&&e({'code':'progress_node_state','slot':r,'description':describe('progress_node_state'),'caller_constraint':![],'evidence':f(i,['progress.current'])});}}if(h['type']['startsWith']('logic_as_u256')||h['type']==='calc_number_add'){const s=[h,...childNodes(h)]['map'](t=>flattenLeaf(t,b));if(s['some'](t=>t['kind']==='clock')&&s['some'](t=>t['kind']==='query'&&(t['query_name']==='progress.current_time'||t['query_name']==='progress.session.forward.time'))){const t=s['find'](u=>u['kind']==='query');e({'code':'time_lock','slot':t['object_identifier'],'description':describe('time_lock'),'caller_constraint':![],'evidence':f(i,['Clock',t['query_name']])});}}if(h['type']==='query'){const u=queryMeta(h['query']);if(u&&u['name']['startsWith']('repository.')){const v=h['object'];e({'code':'repository_crosscheck','slot':v?.['identifier'],'description':describe('repository_crosscheck'),'caller_constraint':![],'evidence':f(i,[u['name']])});}}childNodes(h)['forEach']((w,x)=>g(w,i+'/'+x));};return g(a,'/root'),c;}function findSessionQueries(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']);if(f&&(f['id']===0x4f6||f['id']===0x4f7))b['push'](e);}childNodes(d)['forEach']((g,h)=>c(g,e+'/'+h));};return c(a,'/root'),b;}function collectSlotUsages(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']),g=d['object'];f&&g&&typeof g['identifier']==='number'&&b['push']({'slot':g['identifier'],'path':e,'query_id':f['id'],'query_name':f['name'],...g['convert_witness']!==undefined?{'convert_witness':g['convert_witness']}:{}});}childNodes(d)['forEach']((h,j)=>c(h,e+'/'+j));};return c(a,'/root'),b;}function deriveReceiptRight(a,b){const c=b['find'](e=>e['code']==='progress_node_state'&&e['slot']===a),d=b['find'](e=>e['code']==='signer_is_submitted_object_owner'&&e['slot']===a);if(c||d)return{'object_type':'order','receive_entry':'owner-side\x20extraction\x20on\x20the\x20order','guarantee':'Delivered\x20funds\x20are\x20owned\x20by\x20the\x20submitted\x20Order;\x20only\x20its\x20current\x20owner\x20can\x20'+'extract\x20them\x20(&mut\x20Order\x20input),\x20and\x20coins\x20transfer\x20to\x20that\x20owner.'};return undefined;}function deriveBeneficialOwner(a,b){switch(a['kind']){case'entity':return'Fixed\x20entity\x20'+a['address'];case'signer':return'Transaction\x20caller\x20(Signer)\x20—\x20direct\x20wallet';case'submission':return b?'Owner\x20of\x20the\x20submitted\x20object\x20at\x20table['+a['identifier']+']\x20(object\x20receipt\x20=\x20owner\x20receipt)':'Address\x20submitted\x20at\x20table['+a['identifier']+']\x20(caller-provided)';}}function buildSlotModels(a,b,c,d){const e=[...new Set(c['map'](f=>f['spec'])['filter'](f=>f['kind']==='submission')['map'](f=>f['identifier']))];return e['map'](f=>{const g=a['find'](p=>p['identifier']===f),h=g?normalizeValueType(g['value_type']):undefined,i=h===ValueType['Address'],j=b['filter'](p=>p['slot']===f),k=c['filter'](p=>p['spec']['kind']==='submission'&&p['spec']['identifier']===f)['map'](p=>p['mode']??'Unknown'),l=d['filter'](p=>p['slot']===undefined||p['slot']===f),m=deriveReceiptRight(f,d),n=l['some'](p=>p['code']==='service_binding'||p['code']==='repository_crosscheck'||p['code']==='signer_permission_member'),o=[];if(h!==undefined&&!i)o['push']('RC-FIND-07');if(!n)o['push']('RC-FIND-02');if(m?.['object_type']==='order')o['push']('RC-FIND-03');return{'identifier':f,'externally_submitted':g?.['b_submission']??!![],...h!==undefined?{'declared_value_type':h}:{},'is_address':i,'usages':j,'recipient_modes':k,'constraints':l,...m?{'receipt':m}:{},'beneficial_owner':deriveBeneficialOwner({'kind':'submission','identifier':f},m),'assessment':{'address_typed':i,'scope_bound':n,'object_receipt':m?.['object_type']==='order'},'findings':o};});}function buildSlotFinding(a,b,c){const d=a['identifier'];switch(b){case'RC-FIND-07':return{'code':b,'severity':'medium','title':'Submission\x20slot\x20'+d+'\x20is\x20not\x20address-typed','explanation':'GuardIdentifier\x20recipients\x20require\x20an\x20address-typed\x20table\x20entry\x20'+'(enforced\x20at\x20allocator\x20registration\x20/\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','evidence_paths':c,'mitigation':'Set\x20the\x20slot\x20value_type\x20to\x20Address,\x20or\x20use\x20an\x20Entity\x20recipient.','unavoidable':![]};case'RC-FIND-02':return{'code':b,'severity':'high','title':'Submission\x20slot\x20'+d+'\x20has\x20no\x20scope\x20binding','explanation':'Nothing\x20constrains\x20which\x20submitted\x20objects/addresses\x20qualify:\x20no\x20'+'service\x20binding,\x20repository\x20cross-check\x20or\x20permission\x20membership.\x20A\x20caller\x20'+'can\x20submit\x20arbitrary\x20qualifying-by-other-conditions\x20inputs.','evidence_paths':c,'mitigation':'Add\x20a\x20constraint\x20binding\x20the\x20slot\x20(e.g.\x20order.service\x20==\x20host\x20service).','unavoidable':![]};case'RC-FIND-03':return{'code':b,'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','explanation':'The\x20submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20Allocation\x20being\x20settled\x20'+'(alloc\x20is\x20permissionless\x20and\x20allocation\x20context\x20is\x20not\x20a\x20Guard\x20input).\x20A\x20'+'caller\x20owning\x20ANY\x20qualifying\x20order\x20can\x20settle\x20OTHER\x20allocations;\x20funds\x20land\x20'+'at\x20the\x20submitted\x20order\x20and\x20are\x20receivable\x20by\x20its\x20owner.\x20Destination\x20is\x20safe\x20'+'(an\x20order\x20owner),\x20allocation\x20choice\x20is\x20the\x20residual.','evidence_paths':c,'mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20—\x20declare\x20that\x20any\x20qualifying\x20order\x20may\x20settle\x20'+'this\x20allocation\x20and\x20cap\x20the\x20exposure\x20(sharing\x20threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20—\x20use\x20a\x20fixed\x20Entity\x20(treasury)\x20recipient,\x20the\x20only\x20'+'exclusive\x20choice\x20on\x20the\x20automatic\x20order_allocators\x20route\x20(trust\x20shifts\x20to\x20'+'the\x20entity\x20operator);\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20—\x20abandon\x20automatic\x20order_allocators\x20and\x20attach\x20'+'a\x20per-order\x20Guard\x20pinning\x20the\x20order\x20id\x20(order.owner\x20==\x20constant),\x20the\x20'+'trustless\x20exclusive\x20route.','unavoidable':!![],'resolution_required':!![]};default:return{'code':b,'severity':'low','title':'Slot\x20'+d+'\x20finding\x20'+b,'explanation':'','evidence_paths':c,'mitigation':'','unavoidable':![]};}}function buildFindings(a,b){const c=[];let d=![],e=![];for(const f of b){const g=f['recipients']['flatMap'](h=>h['constraints'])['filter'](h=>h['caller_constraint']);if(g['length']>0x0)d=!![];if(f['slots']['some'](h=>h['assessment']['scope_bound']))e=!![];for(const h of f['recipients']){const i=h['constraints']['map'](j=>j['evidence']['path']);h['spec']['kind']==='signer'&&g['length']===0x0&&c['push']({'code':'RC-FIND-01','severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','explanation':'Funds\x20are\x20delivered\x20directly\x20to\x20the\x20transaction\x20caller,\x20but\x20the\x20Guard\x20'+'does\x20not\x20bind\x20the\x20Signer\x20to\x20an\x20authorized\x20identity.\x20Anyone\x20who\x20satisfies\x20the\x20'+'other\x20conditions\x20steals\x20the\x20funds.','evidence_paths':i,'mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.','unavoidable':![]});}for(const j of f['slots']){const k=j['constraints']['map'](l=>l['evidence']['path']);for(const l of j['findings']){c['push'](buildSlotFinding(j,l,k));}}a['trigger_source']==='service_order_allocators'&&f['recipients']['length']>0x0&&!f['recipients']['some'](m=>m['spec']['kind']==='submission')&&c['push']({'code':'RC-FIND-09','severity':'low','title':'Allocator\x20Guard\x20'+f['guard']+'\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','explanation':'Every\x20sharing\x20row\x20is\x20a\x20fixed\x20recipient\x20(Entity/Signer),\x20which\x20resolves\x20no\x20'+'submission.\x20The\x20Guard\x20therefore\x20cannot\x20read\x20the\x20paying\x20order\x20(order.*\x20queries\x20have\x20'+'no\x20binding\x20target),\x20and\x20the\x20allocation\x20pays\x20the\x20same\x20fixed\x20destinations\x20for\x20EVERY\x20order.\x20'+'This\x20is\x20often\x20intended\x20—\x20confirm\x20it\x20is.','evidence_paths':[],'mitigation':'If\x20the\x20Guard\x20should\x20distinguish\x20orders,\x20add\x20a\x20zero-share\x20{GuardIdentifier:\x200}\x20'+'anchor\x20row\x20(Rate\x200)\x20so\x20the\x20Identifier\x20slot\x20resolves\x20to\x20the\x20paying\x20order\x20'+'(pattern.allocator_order_anchor).\x20If\x20fixed-pay\x20is\x20intended,\x20no\x20action.','unavoidable':![]});}a['trigger_source']==='standalone'&&!d&&c['push']({'code':'RC-FIND-04','severity':'high','title':'Standalone\x20allocation\x20without\x20issuer\x20identity\x20constraint','explanation':'Standalone\x20allocations\x20have\x20no\x20Service/Arbitration\x20access-control\x20layer.\x20'+'Without\x20a\x20Signer/permission\x20binding\x20in\x20the\x20Guard,\x20anyone\x20can\x20trigger\x20distribution.','evidence_paths':[],'mitigation':'Bind\x20the\x20issuer\x20(Signer==owner/admin)\x20or\x20move\x20the\x20allocation\x20into\x20a\x20Service.','unavoidable':![]});c['push']({'code':'RC-FIND-06','severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','explanation':'Once\x20the\x20Guard\x27s\x20conditions\x20are\x20satisfiable,\x20anyone\x20can\x20trigger\x20settlement\x20of\x20an\x20'+'order\x27s\x20allocation.\x20With\x20Entity/object\x20recipients\x20this\x20affects\x20timing\x20only,\x20not\x20destination.','evidence_paths':[],'mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.','unavoidable':!![]});for(const [m,n]of Object['entries'](a['guards']??{})){const o=asNode(n['root']);if(!o)continue;for(const q of findSessionQueries(o)){c['push']({'code':'RC-FIND-05','severity':'medium','title':'Guard\x20'+m+'\x20uses\x20session-only\x20query\x20at\x20'+q,'explanation':'Queries\x201270/1271\x20read\x20the\x20active\x20session;\x20after\x20the\x20session\x20migrates\x20to\x20'+'history\x20the\x20query\x20aborts\x20(W_FIELD_NOT_FOUND)\x20and\x20the\x20Guard\x20permanently\x20fails.','evidence_paths':[q],'mitigation':'Use\x20progress.current_time\x20(1272)\x20or\x20history\x20queries\x20(1274-1280).','unavoidable':![]});}}for(const [s,t]of Object['entries'](a['guards']??{})){const u=(t['relies']??[])['filter'](v=>typeof v==='string'&&v);if(u['length']===0x0)continue;c['push']({'code':'RC-FIND-08','severity':'low','title':'Guard\x20'+s+'\x20relies\x20on\x20'+u['length']+'\x20sub-guard(s)\x20—\x20not\x20credited\x20by\x20this\x20audit','explanation':'Guard\x20composition\x20(relies,\x20one\x20level,\x20≤4,\x20'+((t['relies_logic_and']===![]?'OR':'AND')+'-logic)\x20may\x20carry\x20the\x20scope/signer\x20')+'constraints\x20in\x20the\x20relied\x20sub-guards.\x20This\x20audit\x20evaluates\x20only\x20the\x20guard\x27s\x20own\x20root:\x20'+'sub-guard\x20constraints\x20are\x20NOT\x20credited,\x20so\x20scope-binding\x20gaps\x20(RC-FIND-02)\x20may\x20be\x20'+'over-reported\x20and\x20sub-guard-only\x20conditions\x20stay\x20unverified.','evidence_paths':u,'mitigation':'Resolve\x20the\x20relied\x20sub-guards\x20and\x20verify\x20their\x20constraints\x20manually,\x20or\x20re-run\x20'+'with\x20the\x20sub-guard\x20defs\x20included\x20(read-side\x20resolvers\x20attach\x20them\x20automatically).','unavoidable':![]});}if(!e&&a['trigger_source']==='service_order_allocators'){}return c;}function buildPayoff(a,b){const c=a['recipients']['some'](h=>h['constraints']['some'](i=>i['caller_constraint'])),d=c?'Caller\x20must\x20satisfy\x20the\x20Guard\x27s\x20Signer/identity\x20binding':b==='standalone'?'Any\x20caller\x20(no\x20identity\x20binding)':'Any\x20caller\x20who\x20satisfies\x20the\x20Guard\x27s\x20object/state\x20conditions',e=a['recipients']['map'](h=>h['beneficial_owner'])['join'](';\x20')||'(none)',f={},g=a['recipients']['some'](h=>h['spec']['kind']==='signer'&&!c);return f['caller']=g?'gains':c?'conditional':'neutral',f['provider']=a['recipients']['some'](h=>h['spec']['kind']==='entity')?'gains':'conditional',f['customer']=a['recipients']['some'](h=>h['receipt']?.['object_type']==='order')?'conditional':'neutral',f['system']='neutral',{'caller_eligibility':d,'beneficial_recipient':e,'positions':f};}export const RECIPIENT_CONSTRAINT_VERSION='1.2.0';export function analyzeRecipientConstraints(a){const b=a['allocators']['map'](h=>{const i=a['guards']?.[h['guard']],j=asNode(i?.['root']),k=i?.['table']??[],l=j?extractConstraints(j,k):[],m=j?collectSlotUsages(j):[],n=h['sharing']['map'](q=>{const r=classifyRecipient(q['who']);if(!r)return{'spec':{'kind':'entity','address':'(unclassifiable)'},'constraints':l,'beneficial_owner':'Unclassifiable\x20recipient\x20—\x20check\x20allocator\x20config'};const t=r['kind']==='submission'?r['identifier']:undefined,u=t!==undefined?k['find'](w=>w['identifier']===t):undefined,v=t!==undefined?deriveReceiptRight(t,l):undefined;return{'spec':r,'slot_value_type':u?normalizeValueType(u['value_type']):undefined,'constraints':t!==undefined?l['filter'](w=>w['slot']===undefined||w['slot']===t):l,'receipt':v,'beneficial_owner':deriveBeneficialOwner(r,v)};}),o=buildSlotModels(k,m,h['sharing']['map'](q=>({'spec':classifyRecipient(q['who'])??{'kind':'entity','address':'(unclassifiable)'},'mode':q['mode']})),l),p={'guard':h['guard'],'recipients':n,'slots':o,'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return p['payoff']=buildPayoff(p,a['trigger_source']),p;}),c=buildFindings(a,b),d=c['some'](h=>h['severity']==='critical')?'critical':c['some'](h=>h['severity']==='high')?'high':c['some'](h=>h['severity']==='medium')?'medium':'low',e=!c['some'](h=>h['code']==='RC-FIND-01'),f=c['some'](h=>h['resolution_required']),g=[{'code':'RC-FIND-03','title':'Cross-allocation\x20settlement','detail':'Submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20settled\x20allocation;\x20destination\x20stays\x20at\x20an\x20order\x20owner.'},{'code':'RC-FIND-06','title':'Forced\x20settlement\x20timing','detail':'alloc\x20is\x20permissionless;\x20settlement\x20can\x20be\x20triggered\x20by\x20anyone\x20once\x20conditions\x20hold.'},{'code':'RC-RES-01','title':'Published\x20immutability','detail':'order_allocators,\x20Machine\x20and\x20Guards\x20are\x20immutable\x20after\x20publish.'},{'code':'RC-RES-03','title':'Off-chain\x20arbitration\x20backstop','detail':'No\x20on-chain\x20clawback;\x20post-incident\x20recovery\x20relies\x20on\x20arbitration.'}];return{'version':RECIPIENT_CONSTRAINT_VERSION,'scope':{'trigger_source':a['trigger_source'],'host_service':a['host_service'],'allocation':a['allocation']},'allocators':b,'findings':c,'unavoidable':g,'safe_destination':e,'resolution_required':f,'overall':d,'summary':'Analyzed\x20'+b['length']+'\x20allocator(s):\x20'+c['filter'](h=>!h['unavoidable'])['length']+'\x20actionable,\x20'+(c['filter'](h=>h['unavoidable'])['length']+'\x20structural\x20finding(s).\x20Safe\x20destination:\x20'+e+'.')+(''+(f?'\x20Resolution\x20REQUIRED:\x20at\x20least\x20one\x20residual\x20demands\x20an\x20explicit\x20design\x20decision\x20before\x20publish.':''))};}export function derivePayoffFromSharing(a,b,c){const d=asNode(c?.['root']),e=c?.['table']??[],f=d?extractConstraints(d,e):[],g=a['map'](i=>{const j=classifyRecipient(i['who'])??{'kind':'entity','address':'(unclassifiable)'},k=j['kind']==='submission'?j['identifier']:undefined,l=k!==undefined?e['find'](n=>n['identifier']===k):undefined,m=k!==undefined?deriveReceiptRight(k,f):undefined;return{'spec':j,'slot_value_type':l?normalizeValueType(l['value_type']):undefined,'constraints':k!==undefined?f['filter'](n=>n['slot']===undefined||n['slot']===k):f,'receipt':m,'beneficial_owner':deriveBeneficialOwner(j,m)};}),h={'guard':'','recipients':g,'slots':[],'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return buildPayoff(h,b);}function normalizeValueType(a){if(typeof a==='number')return a;const b={'bool':ValueType['Bool'],'address':ValueType['Address'],'string':ValueType['String'],'u64':ValueType['U64'],'u256':ValueType['U256']};return b[a['toLowerCase']()];}export function isUnboundSignerTheft(a){return a['recipient_is_signer']&&!a['caller_identity_constrained'];}export function canonicalDoctrine(a){switch(a){case'RC-FIND-01':return{'severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.'};case'RC-FIND-03':return{'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20with\x20capped\x20exposure\x20(threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20(treasury)\x20—\x20the\x20only\x20exclusive\x20choice\x20on\x20the\x20automatic\x20'+'order_allocators\x20route;\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20(order.owner\x20==\x20constant)\x20—\x20the\x20trustless\x20'+'exclusive\x20route.','resolution_required':!![]};case'RC-FIND-06':return{'severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.'};}}export const RECIPIENT_DESIGN_OPTIONS=[{'id':'entity','move_recipient':'Recipient::Entity(address)','semantics':'Funds\x20flow\x20to\x20a\x20fixed\x20address\x20(a\x20constrained\x20user\x20account\x20/\x20treasury).\x20'+'Destination\x20never\x20depends\x20on\x20the\x20caller.','required_constraints':['The\x20address\x20is\x20chosen\x20at\x20design\x20time\x20and\x20recorded\x20in\x20the\x20allocator\x20table.']},{'id':'submitted_object','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20the\x20object\x20submitted\x20under\x20protocol\x20context\x20(e.g.\x20the\x20order\x20being\x20settled).\x20'+'Receivable\x20only\x20by\x20that\x20object\x27s\x20owner\x20—\x20object\x20receipt\x20=\x20owner\x20receipt.','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(which\x20query/object\x20type\x20the\x20slot\x20carries).','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-02\x20/\x20RC-FIND-07'},{'id':'signer','move_recipient':'Recipient::Signer','semantics':'Funds\x20flow\x20to\x20the\x20caller\x20who\x20executes\x20the\x20permissionless\x20alloc.\x20'+'Safe\x20only\x20when\x20the\x20Guard\x20proves\x20exactly\x20who\x20the\x20caller\x20may\x20be.','required_constraints':['The\x20Guard\x20constrains\x20the\x20Signer\x20identity\x20(signer\x20==\x20a\x20fixed\x20address\x20or\x20a\x20derived\x20legitimate\x20owner).'],'finding_if_unmet':'RC-FIND-01'},{'id':'constrained_submission','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20an\x20object\x20address\x20supplied\x20by\x20the\x20signer,\x20but\x20the\x20Guard\x20constrains\x20'+'both\x20the\x20submission\x20scope\x20and\x20the\x20signer\x27s\x20relation\x20to\x20it\x20(e.g.\x20the\x20signer\x20owns\x20the\x20submitted\x20order).','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(object/query\x20type).','The\x20Guard\x20binds\x20the\x20signer\x20to\x20the\x20submitted\x20object.','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-01\x20/\x20RC-FIND-02\x20/\x20RC-FIND-07'}];export function recipientDesignGuidance(){return RECIPIENT_DESIGN_OPTIONS;}export const OBJECT_DRIVEABILITY=[{'object_type':'order','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20order','owner-side\x20object\x20extraction\x20from\x20the\x20order'],'anyone_drivable':!![],'funds_settle_to':'order.owner','rationale':'Order\x20is\x20a\x20shared\x20object\x20and\x20extraction\x20has\x20no\x20signer\x20gate;\x20'+'Receiving\x20is\x20restricted\x20to\x20objects\x20actually\x20delivered\x20to\x20that\x20order,\x20and\x20coins\x20settle\x20to\x20its\x20owner.'},{'object_type':'permission','receive_entries':['owner-side\x20coin\x20extraction\x20via\x20the\x20permission\x20object','owner-side\x20object\x20extraction\x20via\x20the\x20permission\x20object'],'anyone_drivable':!![],'funds_settle_to':'permission.owner','rationale':'Permission\x20is\x20the\x20final\x20authority;\x20anyone\x20can\x20drive\x20extraction\x20of\x20funds\x20sent\x20to\x20its\x20address,\x20but\x20the\x20destination\x20is\x20its\x20owner.'},{'object_type':'service','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20service','owner-side\x20object\x20extraction\x20from\x20the\x20service'],'anyone_drivable':![],'permission_index':0x13f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20319);\x20members\x20drive,\x20value\x20settles\x20to\x20the\x20organization\x20owner.'},{'object_type':'treasury','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20treasury','owner-side\x20object\x20extraction\x20from\x20the\x20treasury'],'anyone_drivable':![],'permission_index':0x101,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20257).'},{'object_type':'arbitration','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20arbitration','owner-side\x20object\x20extraction\x20from\x20the\x20arbitration'],'anyone_drivable':![],'permission_index':0x16f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20367).'},{'object_type':'machine','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20machine','owner-side\x20object\x20extraction\x20from\x20the\x20machine'],'anyone_drivable':![],'permission_index':0xcf,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20207).'},{'object_type':'progress','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20progress','owner-side\x20object\x20extraction\x20from\x20the\x20progress'],'anyone_drivable':![],'permission_index':0xe1,'funds_settle_to':'machine\x27s\x20permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20225),\x20scoped\x20to\x20the\x20Machine\x20permission.'},{'object_type':'demand','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20demand','owner-side\x20object\x20extraction\x20from\x20the\x20demand'],'anyone_drivable':![],'permission_index':0x197,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20407).'},{'object_type':'contact','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20contact','owner-side\x20object\x20extraction\x20from\x20the\x20contact'],'anyone_drivable':![],'permission_index':0x1c6,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20454).'}];export function driveabilityOf(a){return OBJECT_DRIVEABILITY['find'](b=>b['object_type']===a);}function rewardRecipientKind(a){if(typeof a==='string'){const e=a['toLowerCase']();if(e==='signer')return{'kind':'signer'};return{'kind':'entity'};}if(typeof a!=='object'||a===null)return{'kind':'entity'};const b=a,c=f=>typeof b[f]==='number'?b[f]:undefined,d=c('GuardIdentifier')??c('guard_identifier')??c('identifier');if(d!==undefined)return{'kind':'submission','slot':d};if(b['Signer']!==undefined||b['signer']!==undefined)return{'kind':'signer'};return{'kind':'entity'};}const SLOT_BINDING_CODES=new Set(['service_binding','progress_node_state','signer_is_submitted_object_owner','repository_crosscheck','signer_permission_member']);export function analyzeRewardClaimGuard(a){const {kind:b,slot:c}=rewardRecipientKind(a['recipient']),d={'entry_index':a['entry_index'],'guard':a['guard'],'recipient_kind':b,...c!==undefined?{'recipient_slot':c}:{},'guard_resolved':![],'constraint_codes':[],'recipient_slot_usages':0x0,'caller_identity_constrained':![],'viability':'unverifiable','reason':'Guard\x20table/root\x20not\x20fetched\x20with\x20the\x20topology\x20—\x20the\x20deciding\x20predicate\x20is\x20outside\x20the\x20evidence;\x20the\x20owner\x20must\x20disclose\x20the\x20full\x20guard\x20definitions.'},e=asNode(a['guard_def']?.['root']);if(!e)return d;const f=a['guard_def']?.['table']??[],g=extractConstraints(e,f);d['guard_resolved']=!![],d['constraint_codes']=g['map'](k=>k['code']),d['caller_identity_constrained']=g['some'](k=>k['caller_constraint']);if(b==='entity')return d['viability']='blocked',d['reason']='Payout\x20address\x20is\x20fixed\x20at\x20guard\x20registration\x20(Entity\x20recipient);\x20the\x20claim\x20path\x20cannot\x20redirect\x20it.',d;if(b==='signer')return d['caller_identity_constrained']?(d['viability']='blocked',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20but\x20the\x20guard\x20binds\x20the\x20caller\x20identity\x20—\x20only\x20the\x20authorized\x20party\x20can\x20claim.'):(d['viability']='viable',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20with\x20no\x20identity\x20binding\x20—\x20anyone\x20satisfying\x20the\x20remaining\x20conditions\x20claims\x20to\x20their\x20own\x20address.'),d;const h=c??-0x1,i=collectSlotUsages(e)['filter'](k=>k['slot']===h);d['recipient_slot_usages']=i['length'];const j=g['filter'](k=>k['slot']===h&&SLOT_BINDING_CODES['has'](k['code']));if(j['length']>0x0)d['viability']='blocked',d['reason']='Submitted\x20address\x20is\x20constrained\x20inside\x20the\x20guard\x20('+j['map'](k=>k['code'])['join'](',\x20')+')\x20—\x20a\x20passerby\x20cannot\x20fill\x20the\x20slot\x20with\x20an\x20arbitrary\x20address.';else i['length']>0x0?(d['viability']='conditional',d['reason']='The\x20guard\x20reads\x20the\x20submitted\x20slot\x20('+i['length']+'\x20query\x20usage(s))\x20but\x20no\x20recognized\x20scope/equality\x20constraint\x20was\x20matched\x20—\x20manual\x20predicate\x20review\x20required.'):(d['viability']='viable',d['reason']='No\x20guard\x20query\x20consumes\x20the\x20submitted\x20slot\x20—\x20the\x20predicate\x20cannot\x20constrain\x20the\x20payout\x20address;\x20any\x20passing\x20party\x20claims\x20to\x20their\x20own\x20address.');return d;}
@@ -2,7 +2,7 @@ import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD } from "./onchain-const
2
2
  export { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, };
3
3
  export type RewardPhase = "creation" | "guard_addition" | "guard_lock_mgmt" | "funds_replenish" | "claim" | "um_mgmt" | "owner_receive" | "description_update" | "permission_update";
4
4
  export interface RewardBuiltinPermissionEntry {
5
- index: 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157;
5
+ index: 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158;
6
6
  name: string;
7
7
  description: string;
8
8
  governed_operations: string[];
@@ -48,6 +48,7 @@ export declare const REWARD_RECEIVE: RewardBuiltinPermissionEntry;
48
48
  export declare const REWARD_GUARD_EXPIRATION_TIME_ADD: RewardBuiltinPermissionEntry;
49
49
  export declare const REWARD_OWNER_RECEIVE: RewardBuiltinPermissionEntry;
50
50
  export declare const REWARD_UM: RewardBuiltinPermissionEntry;
51
+ export declare const REWARD_WITHDRAW: RewardBuiltinPermissionEntry;
51
52
  export declare const REWARD_PERMISSIONS: RewardBuiltinPermissionEntry[];
52
53
  export interface RewardFieldEntry {
53
54
  name: string;
@@ -1 +1 @@
1
- import{MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD}from'./onchain-constants.js';export{MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD};export const REWARD_NEW={'index':0x96,'name':'REWARD_NEW','description':'Create\x20new\x20Reward<T>','governed_operations':['create\x20a\x20new\x20Reward\x20pool'],'sdk_exposed':!![]};export const REWARD_DESCRIPTION={'index':0x97,'name':'REWARD_DESCRIPTION','description':'Update\x20description','governed_operations':['update\x20the\x20Reward\x20description'],'sdk_exposed':!![]};export const REWARD_GUARD={'index':0x98,'name':'REWARD_GUARD','description':'Add\x20/\x20remove\x20expired\x20guards\x20(≤\x20MAX_GUARD_COUNT_REWARD=200)','governed_operations':['add\x20a\x20claim\x20guard\x20to\x20the\x20Reward','remove\x20expired\x20claim\x20guards'],'sdk_exposed':!![]};export const REWARD_COIN_ADD={'index':0x99,'name':'REWARD_COIN_ADD','description':'Deposit\x20Coin<T>\x20directly\x20into\x20Reward\x20balance\x20(joins\x20Balance<T>)','governed_operations':['deposit\x20Coin<T>\x20into\x20the\x20Reward\x20balance'],'sdk_exposed':!![]};export const REWARD_RECEIVE={'index':0x9a,'name':'REWARD_RECEIVE','description':'Receive\x20CoinWrapper<T>\x20into\x20the\x20balance\x20(unwrapped\x20with\x20balance\x20check)','governed_operations':['receive\x20a\x20CoinWrapper<T>\x20payment\x20into\x20the\x20balance'],'sdk_exposed':!![]};export const REWARD_GUARD_EXPIRATION_TIME_ADD={'index':0x9b,'name':'REWARD_GUARD_EXPIRATION_TIME_ADD','description':'Set\x20/\x20cancel\x20guard_not_added_expiration_time\x20(time-lock\x20on\x20new\x20guard\x20additions)','governed_operations':['set\x20or\x20cancel\x20the\x20time-lock\x20on\x20adding\x20new\x20guards'],'sdk_exposed':!![]};export const REWARD_OWNER_RECEIVE={'index':0x9c,'name':'REWARD_OWNER_RECEIVE','description':'Owner\x20receives\x20Receiving<K>\x20/\x20CoinWrapper<K>\x20at\x20terminal\x20state\x20(unwrap\x20→\x20owner)','governed_operations':['owner\x20receipt\x20of\x20payments\x20at\x20terminal\x20state\x20(unwrapped\x20to\x20the\x20owner)','owner\x20receipt\x20of\x20whole\x20objects\x20at\x20terminal\x20state'],'sdk_exposed':!![]};export const REWARD_UM={'index':0x9d,'name':'REWARD_UM','description':'Bind\x20/\x20unbind\x20Contact\x20(UM)\x20for\x20off-chain\x20coordination','governed_operations':['bind\x20a\x20Contact\x20as\x20the\x20UM\x20coordinator','unbind\x20the\x20UM\x20Contact'],'sdk_exposed':!![]};export const REWARD_PERMISSIONS=[REWARD_NEW,REWARD_DESCRIPTION,REWARD_GUARD,REWARD_COIN_ADD,REWARD_RECEIVE,REWARD_GUARD_EXPIRATION_TIME_ADD,REWARD_OWNER_RECEIVE,REWARD_UM];export const REWARD_FIELDS=[{'name':'id','move_type':'UID','mutability':'immutable','set_at_creation':!![],'constraint':'Object\x20UID;\x20assigned\x20at\x20creation.\x20Never\x20changes.'},{'name':'description','move_type':'String','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x97,'constraint':'Must\x20satisfy\x20common::DESCRIPTION.\x20Updated\x20via\x20permission\x20151.'},{'name':'guards','move_type':'vector<RewardGuard>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x98,'constraint':'vector::length\x20<\x20MAX_GUARD_COUNT\x20(200);\x20E_GUARD_COUNT_EXCEEDED\x20on\x20overflow.','related_errors':['E_GUARD_COUNT_EXCEEDED']},{'name':'balance','move_type':'Balance<T>','mutability':'runtime','set_at_creation':!![],'constraint':'Zero\x20at\x20creation\x20(balance::zero());\x20grows\x20via\x20coin_add/receive;\x20shrinks\x20via\x20claim\x20(split)\x20and\x20never\x20via\x20direct\x20withdraw.','related_errors':['E_INSUFFICIENT_BALANCE']},{'name':'guard_not_added_expiration_time','move_type':'Option<u64>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x9b,'constraint':'Option<timestamp_ms>.\x20When\x20Some(t):\x20guard_add\x20requires\x20clock\x20>\x20t\x20(E_GUARD_LOCKED_TIME).\x20When\x20None\x20or\x20t\x20<\x20now:\x20guards\x20can\x20be\x20added.','related_errors':['E_GUARD_LOCKED_TIME','E_GUARD_LOCKED_TIME_NOT_INCREASING','E_GUARD_LOCKED_TIME_INVALID']},{'name':'record','move_type':'ParentTable<address,\x20RecipientRecord>','mutability':'runtime','set_at_creation':!![],'constraint':'Per-recipient\x20claim\x20history.\x20Each\x20RecipientRecord.amount\x20vector\x20has\x20length\x20<\x20MAX_RECORD_COUNT\x20(5200);\x20E_RECORD_COUNT_EXCEEDED\x20on\x20overflow.','related_errors':['E_RECORD_COUNT_EXCEEDED']},{'name':'um','move_type':'Option<address>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x9d,'constraint':'Option<Contact\x20address>.\x20Binding\x20creates\x20an\x20object-linker\x20core\x20binding;\x20unbinding\x20disaffiliates.'},{'name':'permission','move_type':'address','mutability':'admin_mutable','set_at_creation':!![],'constraint':'Permission\x20object\x20address.\x20Updated\x20owner-only\x20(asserts\x20old.owner\x20==\x20sender);\x20the\x20change\x20is\x20registered\x20as\x20an\x20object-linker\x20affiliation\x20change.'}];export const REWARD_GUARD_CONSTRUCTORS=[{'constructor':'dynamic_recipient_dynamic_amount','recipient_type':'GuardIdentifier','amount_type':'GuardU64Identifier','params':{'recipient_param':'u8','amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['recipient\x20identifier\x20must\x20resolve\x20to\x20an\x20address\x20in\x20the\x20Passport\x20table\x20—\x20E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4)','amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Dynamic\x20recipient\x20+\x20dynamic\x20amount\x20—\x20both\x20extracted\x20from\x20Passport\x20at\x20claim\x20time\x20(e.g.\x20referral\x20rewards\x20where\x20referrer\x20and\x20amount\x20vary\x20per\x20claim).'},{'constructor':'dynamic_recipient_fixed_amount','recipient_type':'GuardIdentifier','amount_type':'Fixed','params':{'recipient_param':'u8','amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['recipient\x20identifier\x20must\x20resolve\x20to\x20an\x20address\x20in\x20the\x20Passport\x20table\x20—\x20E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Dynamic\x20recipient\x20+\x20fixed\x20amount\x20—\x20e.g.\x20first-order\x20reward\x20where\x20any\x20new\x20customer\x20claims\x20a\x20fixed\x201\x20WOW.'},{'constructor':'entity_recipient_dynamic_amount','recipient_type':'Entity','amount_type':'GuardU64Identifier','params':{'recipient_param':'address','amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Fixed\x20recipient\x20+\x20dynamic\x20amount\x20—\x20e.g.\x20tiered\x20loyalty\x20reward\x20where\x20amount\x20depends\x20on\x20Passport\x20submission\x20(tier\x20level).'},{'constructor':'entity_recipient_fixed_amount','recipient_type':'Entity','amount_type':'Fixed','params':{'recipient_param':'address','amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Fully\x20fixed\x20recipient\x20+\x20amount\x20—\x20simplest\x20configuration\x20(e.g.\x20specific\x20partner\x20bounty).'},{'constructor':'caller_recipient_dynamic_amount','recipient_type':'Signer','amount_type':'GuardU64Identifier','params':{'amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Caller\x20is\x20recipient\x20+\x20dynamic\x20amount\x20—\x20e.g.\x20self-service\x20claim\x20where\x20amount\x20depends\x20on\x20Passport\x20submission\x20(e.g.\x20cashback\x20rate).'},{'constructor':'caller_recipient_fixed_amount','recipient_type':'Signer','amount_type':'Fixed','params':{'amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Caller\x20is\x20recipient\x20+\x20fixed\x20amount\x20—\x20e.g.\x20flash\x20sale\x20where\x20any\x20eligible\x20caller\x20claims\x20a\x20fixed\x20reward.'}];export const REWARD_ERROR_CODES=[{'code':0x1,'name':'E_GUARD_LOCKED_TIME_NOT_INCREASING','description':'guard-lock\x20time\x20update:\x20new\x20time\x20<\x20current\x20clock\x20(must\x20be\x20≥\x20now)','trigger_operation':'guard-lock\x20time\x20update\x20(155)'},{'code':0x2,'name':'E_GUARD_EXPIRED','description':'guard_add\x20on\x20guard\x20with\x20expiration_time\x20<\x20now,\x20OR\x20claim\x20on\x20guard\x20with\x20expiration_time\x20<\x20now','trigger_operation':'guard_add\x20/\x20claim'},{'code':0x3,'name':'E_GUARD_COUNT_EXCEEDED','description':'guard_add\x20would\x20exceed\x20MAX_GUARD_COUNT=200\x20(only\x20on\x20NEW\x20guard,\x20not\x20on\x20update\x20of\x20existing)','trigger_operation':'guard_add'},{'code':0x4,'name':'E_RECIPIENT_IDENTIFIER_NOT_ADDRESS','description':'RewardGuard\x20constructor:\x20recipient\x20identifier\x20type\x20is\x20not\x20address\x20(GuardIdentifier\x20variant\x20only)','trigger_operation':'claim-guard\x20construction'},{'code':0x5,'name':'E_AMOUNT_NOT_U64','description':'RewardGuard\x20constructor:\x20amount\x20identifier\x20type\x20is\x20not\x20u64\x20(GuardU64Identifier\x20variant\x20only)','trigger_operation':'claim-guard\x20construction'},{'code':0x6,'name':'E_INSUFFICIENT_BALANCE','description':'claim:\x20balance\x20<\x20amount\x20(cannot\x20split\x20more\x20than\x20held)','trigger_operation':'claim'},{'code':0x7,'name':'E_GUARD_NOT_FOUND','description':'claim:\x20no\x20guard\x20in\x20self.guards\x20matches\x20the\x20supplied\x20guard\x20address','trigger_operation':'claim'},{'code':0x8,'name':'E_RECORD_COUNT_EXCEEDED','description':'claim:\x20recipient\x20already\x20has\x20MAX_RECORD_COUNT=5200\x20entries\x20(E_RECORD_COUNT_EXCEEDED)','trigger_operation':'claim'},{'code':0xa,'name':'E_GUARD_LOCKED_TIME','description':'guard_add\x20while\x20guard_not_added_expiration_time\x20is\x20Some\x20and\x20clock\x20≤\x20expiration_time','trigger_operation':'guard_add'},{'code':0xb,'name':'E_GUARD_LOCKED_TIME_INVALID','description':'guard-lock\x20time\x20update:\x20new\x20Some(t)\x20where\x20t\x20≤\x20now\x20(must\x20be\x20future)','trigger_operation':'guard-lock\x20time\x20update\x20(155)'},{'code':0xc,'name':'E_STORE_FROM_ID_NOT_COMPATIBLE','description':'RewardGuard\x20constructor:\x20store_from_id\x20identifier\x20type\x20is\x20not\x20number\x20or\x20address','trigger_operation':'claim-guard\x20construction'},{'code':0xd,'name':'E_CLAIM_ALREADY_MADE','description':'claim:\x20the\x20(recipient,\x20guard,\x20store_from\x20value)\x20once-slot\x20is\x20already\x20consumed\x20(MOV-PROTOCOL-1212\x20F-01\x20fix\x20—\x20replay\x20aborts,\x20the\x20pool\x20keeps\x20its\x20balance).\x20Empty\x20store_from\x20slot\x20=\x20once\x20per\x20(recipient,\x20guard);\x20a\x20store_from\x20value\x20pins\x20a\x20per-value\x20slot\x20(per-order\x20bounty)','trigger_operation':'claim'},{'code':0xe,'name':'E_CLAIM_RECIPIENT_NOT_SIGNER','description':'claim:\x20the\x20resolved\x20recipient\x20(from\x20guard\x20submissions\x20or\x20the\x20Entity\x20binding)\x20is\x20not\x20the\x20transaction\x20sender\x20(MOV-PROTOCOL-1212\x20B5\x20fix\x20—\x20an\x20attacker\x20cannot\x20route\x20a\x20reward\x20to\x20a\x20third\x20address).\x20Entity\x20flows\x20pass\x20because\x20the\x20SDK\x20replaces\x20the\x20sender\x20with\x20the\x20entity\x20account','trigger_operation':'claim'}];export const REWARD_SCENES=[{'id':'reward_first_order','name':'First-order\x20reward','industry':['universal','ecommerce','service','freelance'],'scenario':'New\x20customers\x20receive\x20a\x20fixed\x20reward\x20after\x20their\x20first\x20order.\x20Guard\x20verifies\x20order\x20ownership\x20+\x20first-time\x20status;\x20'+'Recipient=Signer\x20(caller\x20is\x20the\x20new\x20customer);\x20Amount=Fixed\x20(e.g.\x201\x20WOW).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin\x20(e.g.\x200x2::wow::WOW\x20or\x20a\x20custom\x20token)','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Signer\x20recipient\x20+\x20Fixed\x20amount\x20—\x20caller\x20claims\x20a\x20fixed\x20amount\x20(e.g.\x201\x20WOW)','Guard\x20verifies:\x20order_address.holder\x20==\x20signer\x20AND\x20order\x20is\x20the\x20first\x20order\x20(Repository\x20query)','expiration_time\x20bounds\x20the\x20campaign\x20window\x20(e.g.\x2030\x20days)','coin_add\x20deposits\x20the\x20campaign\x20budget\x20upfront\x20(e.g.\x20100\x20WOW\x20for\x20100\x20claims)'],'recommended_templates':['first_order']},{'id':'reward_referral','name':'Referral\x20viral\x20reward','industry':['universal','ecommerce','service','content'],'scenario':'Both\x20referrer\x20and\x20referee\x20receive\x20a\x20reward\x20when\x20the\x20referee\x20completes\x20a\x20first\x20order.\x20Two\x20guards:\x20one\x20for\x20referrer\x20(Entity),\x20one\x20for\x20referee\x20(Signer).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x2,'recipient_types_used':['Entity','Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':!![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Entity\x20recipient\x20+\x20Fixed\x20amount\x20for\x20the\x20referrer\x20(recipient\x20=\x20referrer\x20address)','Signer\x20recipient\x20+\x20Fixed\x20amount\x20for\x20the\x20referee\x20(caller\x20is\x20recipient)','Guard\x20verifies:\x20referrer\x20marked\x20in\x20Repository\x20AND\x20referee\x27s\x20order\x20completed','store_from_id\x20may\x20record\x20the\x20order\x20address\x20for\x20audit\x20trail'],'recommended_templates':['referral']},{'id':'reward_loyalty','name':'Loyalty\x20tiered\x20reward','industry':['universal','ecommerce','subscription','content'],'scenario':'Customers\x20unlock\x20higher\x20rewards\x20after\x20reaching\x20cumulative\x20spending\x20tiers.\x20Recipient=Signer;\x20Amount=GuardU64Identifier\x20(tier-dependent\x20amount\x20extracted\x20from\x20Passport).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['GuardU64Identifier'],'uses_expiration_time':![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Signer\x20recipient\x20+\x20identifier\x20amount\x20—\x20amount\x20is\x20dynamic,\x20extracted\x20from\x20Passport\x20submission\x20(tier\x20level\x20→\x20reward\x20amount)','Guard\x20verifies:\x20cumulative\x20spend\x20≥\x20tier\x20threshold\x20(Repository\x20query)','No\x20expiration_time\x20—\x20loyalty\x20is\x20perpetual\x20(until\x20deactivated\x20via\x20guard_remove_expired)','Guard\x20submission\x20value\x20type\x20MUST\x20be\x20u64\x20(E_AMOUNT_NOT_U64\x20otherwise)'],'recommended_templates':['loyalty']},{'id':'reward_flash_sale','name':'Limited-time\x20flash\x20sale\x20reward','industry':['universal','ecommerce','retail'],'scenario':'Time-bounded\x20reward\x20for\x20the\x20first\x20N\x20callers.\x20Recipient=Signer;\x20Amount=Fixed.\x20Guard\x20verifies\x20time\x20window\x20+\x20claim\x20count.','phases':['creation','guard_addition','funds_replenish','claim','guard_lock_mgmt'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_GUARD_EXPIRATION_TIME_ADD],'common_patterns':['Signer\x20recipient\x20+\x20Fixed\x20amount\x20—\x20fixed\x20amount\x20per\x20claim\x20(e.g.\x202\x20WOW)','expiration_time\x20bounds\x20the\x20flash\x20sale\x20window\x20(e.g.\x2048\x20hours)','the\x20guard-addition\x20time-lock\x20(155)\x20may\x20lock\x20further\x20guard\x20additions\x20during\x20the\x20sale','Budget\x20=\x20max_claims\x20×\x20amount;\x20coin_add\x20deposits\x20this\x20upfront'],'recommended_templates':['flash_sale']},{'id':'reward_bulk_discount','name':'Bulk\x20discount\x20/\x20cashback\x20reward','industry':['universal','ecommerce','wholesale','service'],'scenario':'Customer\x20receives\x20cashback\x20proportional\x20to\x20order\x20size.\x20Recipient=Signer\x20or\x20Entity\x20(order\x20holder);\x20Amount=GuardU64Identifier\x20(cashback\x20rate\x20from\x20Passport).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20payment\x20coin\x20type\x20(must\x20match\x20order\x20payment\x20for\x20clean\x20cashback)','typical_guard_count':0x1,'recipient_types_used':['Signer','Entity'],'amount_types_used':['GuardU64Identifier'],'uses_expiration_time':![],'uses_store_from_id':!![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_RECEIVE],'common_patterns':['Signer\x20recipient\x20+\x20identifier\x20amount\x20—\x20caller\x20claims\x20dynamic\x20amount\x20(cashback\x20=\x20order_amount\x20×\x20rate)','store_from_id\x20records\x20the\x20order\x20address\x20for\x20cross-reference\x20(audit\x20trail)','receive\x20(154)\x20may\x20be\x20used\x20to\x20accept\x20CoinWrapper<T>\x20refunds\x20that\x20replenish\x20the\x20balance','Guard\x20verifies:\x20order.completed\x20AND\x20order.service\x20==\x20this\x20Service'],'recommended_templates':['cashback']},{'id':'reward_milestone','name':'Service\x20milestone\x20reward','industry':['universal','ecommerce','content','subscription'],'scenario':'When\x20a\x20Service\x20reaches\x20a\x20milestone\x20(e.g.\x20100\x20orders),\x20early\x20supporters\x20receive\x20extra\x20rewards.\x20Recipient=Entity\x20(early\x20customer);\x20Amount=Fixed.','phases':['creation','guard_addition','funds_replenish','claim','guard_lock_mgmt'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x32,'recipient_types_used':['Entity'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_GUARD_EXPIRATION_TIME_ADD],'common_patterns':['Entity\x20recipient\x20+\x20Fixed\x20amount\x20for\x20each\x20early\x20customer\x20(recipient\x20=\x20customer\x20address)','Multiple\x20guards\x20(up\x20to\x2050\x20for\x2050\x20early\x20supporters)\x20—\x20well\x20within\x20MAX_GUARD_COUNT=200','Guard\x20verifies:\x20Service\x20order_count\x20>=\x20milestone\x20AND\x20claimer\x20is\x20in\x20early-customer\x20list','the\x20guard-addition\x20time-lock\x20(155)\x20may\x20lock\x20the\x20guard\x20list\x20after\x20milestone\x20setup'],'recommended_templates':['milestone']}];export const REWARD_LEDGER_VERSION='1.0.0';export function getScenesByPhase(a){return REWARD_SCENES['filter'](b=>b['phases']['includes'](a));}export function findSceneById(a){return REWARD_SCENES['find'](b=>b['id']===a);}export function getScenesByIndustry(a){return REWARD_SCENES['filter'](b=>b['industry']['includes'](a)||b['industry']['includes']('universal'));}export function getBuiltinPermissionByIndex(a){return REWARD_PERMISSIONS['find'](b=>b['index']===a);}export function isRewardBuiltinPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function getAllBuiltinPermissions(){return[...REWARD_PERMISSIONS];}export function getRewardScenesCount(){return REWARD_SCENES['length'];}export function getGuardConstructorSpec(a){return REWARD_GUARD_CONSTRUCTORS['find'](b=>b['constructor']===a);}export function resolveGuardConstructor(a,b){const c={'GuardIdentifier|GuardU64Identifier':'dynamic_recipient_dynamic_amount','GuardIdentifier|Fixed':'dynamic_recipient_fixed_amount','Entity|GuardU64Identifier':'entity_recipient_dynamic_amount','Entity|Fixed':'entity_recipient_fixed_amount','Signer|GuardU64Identifier':'caller_recipient_dynamic_amount','Signer|Fixed':'caller_recipient_fixed_amount'};return c[a+'|'+b];}export function getRewardErrorByCode(a){return REWARD_ERROR_CODES['find'](b=>b['code']===a);}export function getRewardErrorByName(a){return REWARD_ERROR_CODES['find'](b=>b['name']===a);}export function validateGuardCount(a){if(a>=MAX_GUARD_COUNT_REWARD)return{'ok':![],'violation':'Guard\x20count\x20'+a+'\x20would\x20exceed\x20MAX_GUARD_COUNT_REWARD\x20'+MAX_GUARD_COUNT_REWARD};return{'ok':!![]};}export function validateRecordCount(a){if(a>=MAX_RECORD_COUNT_REWARD)return{'ok':![],'violation':'Record\x20count\x20'+a+'\x20would\x20exceed\x20MAX_RECORD_COUNT_REWARD\x20'+MAX_RECORD_COUNT_REWARD+'\x20—\x20recipient\x20can\x20no\x20longer\x20claim'};return{'ok':!![]};}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['flash\x20sale','reward_flash_sale'],['flash_sale','reward_flash_sale'],['limited-time','reward_flash_sale'],['limited\x20time','reward_flash_sale'],['referral','reward_referral'],['viral','reward_referral'],['refer\x20a\x20friend','reward_referral'],['invite','reward_referral'],['loyalty','reward_loyalty'],['tiered','reward_loyalty'],['tier','reward_loyalty'],['repeat','reward_loyalty'],['cashback','reward_bulk_discount'],['bulk\x20discount','reward_bulk_discount'],['bulk_discount','reward_bulk_discount'],['wholesale','reward_bulk_discount'],['milestone','reward_milestone'],['early\x20supporter','reward_milestone'],['early\x20customer','reward_milestone'],['first\x20order','reward_first_order'],['first_order','reward_first_order'],['new\x20customer','reward_first_order'],['first-time','reward_first_order']];for(const [d,e]of c){if(b['includes'](d)){const f=findSceneById(e);if(f)return f;}}return undefined;}export const REWARD_CROSS_OBJECT_REFS=[{'object':'Permission','phase':'universal','relationship':'Reward.permission\x20(address;\x20borrowed\x20for\x20all\x20150-157\x20assertions)'},{'object':'Permission','phase':'permission_update','relationship':'permission\x20update:\x20owner-only\x20(asserts\x20old.owner\x20==\x20sender);\x20registered\x20as\x20an\x20object-linker\x20affiliation\x20change'},{'object':'Guard','phase':'guard_addition','relationship':'RewardGuard.guard\x20=\x20guard.id_address\x20(each\x20guard\x20registered\x20via\x20object-linker\x20core\x20binding)'},{'object':'Guard','phase':'claim','relationship':'claim:\x20iterates\x20self.guards\x20looking\x20for\x20guard.id_address\x20match;\x20E_GUARD_NOT_FOUND\x20if\x20no\x20match'},{'object':'Guard','phase':'claim','relationship':'claim:\x20the\x20guard\x20verification\x20result\x20validates\x20the\x20Passport\x20submission\x20data'},{'object':'Passport','phase':'claim','relationship':'claim:\x20the\x20claimant\x27s\x20Passport\x20submission\x20supplies\x20the\x20recipient\x20(address)\x20and/or\x20amount\x20(u64)\x20per\x20RewardGuard\x20variant'},{'object':'Passport','phase':'claim','relationship':'claim:\x20if\x20store_from_id\x20is\x20Some,\x20extracts\x20store-from\x20address\x20from\x20Passport\x20submission'},{'object':'Payment','phase':'funds_replenish','relationship':'receive\x20(154):\x20unwraps\x20Coin<T>\x20from\x20CoinWrapper<T>\x20(with\x20check)\x20and\x20joins\x20the\x20balance'},{'object':'Payment','phase':'owner_receive','relationship':'owner\x20receipt\x20(156):\x20unwraps\x20CoinWrapper<K>\x20and\x20forwards\x20it\x20to\x20the\x20Permission\x20owner'},{'object':'Repository','phase':'claim','relationship':'Guard\x20may\x20query\x20Repository\x20(e.g.\x20order\x20history\x20for\x20first-order\x20/\x20loyalty\x20verification)'},{'object':'Service','phase':'claim','relationship':'Guard\x20may\x20verify\x20order.service\x20==\x20this\x20Service\x20(cashback\x20/\x20first-order\x20scenarios)'},{'object':'Demand','phase':'guard_addition','relationship':'Guard\x20may\x20be\x20shared\x20with\x20Demand\x20(recommendation\x20filtering);\x20same\x20Guard\x20object\x20address\x20space'},{'object':'Allocation','phase':'owner_receive','relationship':'Terminal\x20Allocation\x20alloc\x20may\x20route\x20funds\x20back\x20to\x20Reward\x20(replenishment\x20loop)'},{'object':'Contact','phase':'um_mgmt','relationship':'UM\x20binding\x20(157):\x20binds\x20Contact\x20(UM)\x20for\x20off-chain\x20coordination;\x20creates\x20object-linker\x20core\x20binding'},{'object':'Coin','phase':'universal','relationship':'Reward<phantom\x20T>:\x20T\x20is\x20the\x20coin\x20type;\x20balance:\x20Balance<T>;\x20coin_add\x20expects\x20Coin<T>'}];
1
+ import{MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD}from'./onchain-constants.js';export{MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD};export const REWARD_NEW={'index':0x96,'name':'REWARD_NEW','description':'Create\x20new\x20Reward<T>','governed_operations':['create\x20a\x20new\x20Reward\x20pool'],'sdk_exposed':!![]};export const REWARD_DESCRIPTION={'index':0x97,'name':'REWARD_DESCRIPTION','description':'Update\x20description','governed_operations':['update\x20the\x20Reward\x20description'],'sdk_exposed':!![]};export const REWARD_GUARD={'index':0x98,'name':'REWARD_GUARD','description':'Add\x20/\x20remove\x20expired\x20guards\x20(≤\x20MAX_GUARD_COUNT_REWARD=200)','governed_operations':['add\x20a\x20claim\x20guard\x20to\x20the\x20Reward','remove\x20expired\x20claim\x20guards'],'sdk_exposed':!![]};export const REWARD_COIN_ADD={'index':0x99,'name':'REWARD_COIN_ADD','description':'Deposit\x20Coin<T>\x20directly\x20into\x20Reward\x20balance\x20(joins\x20Balance<T>)','governed_operations':['deposit\x20Coin<T>\x20into\x20the\x20Reward\x20balance'],'sdk_exposed':!![]};export const REWARD_RECEIVE={'index':0x9a,'name':'REWARD_RECEIVE','description':'Receive\x20CoinWrapper<T>\x20into\x20the\x20balance\x20(unwrapped\x20with\x20balance\x20check)','governed_operations':['receive\x20a\x20CoinWrapper<T>\x20payment\x20into\x20the\x20balance'],'sdk_exposed':!![]};export const REWARD_GUARD_EXPIRATION_TIME_ADD={'index':0x9b,'name':'REWARD_GUARD_EXPIRATION_TIME_ADD','description':'Set\x20/\x20cancel\x20guard_not_added_expiration_time\x20(time-lock\x20on\x20new\x20guard\x20additions)','governed_operations':['set\x20or\x20cancel\x20the\x20time-lock\x20on\x20adding\x20new\x20guards'],'sdk_exposed':!![]};export const REWARD_OWNER_RECEIVE={'index':0x9c,'name':'REWARD_OWNER_RECEIVE','description':'Owner\x20receives\x20Receiving<K>\x20/\x20CoinWrapper<K>\x20at\x20terminal\x20state\x20(unwrap\x20→\x20owner)','governed_operations':['owner\x20receipt\x20of\x20payments\x20at\x20terminal\x20state\x20(unwrapped\x20to\x20the\x20owner)','owner\x20receipt\x20of\x20whole\x20objects\x20at\x20terminal\x20state'],'sdk_exposed':!![]};export const REWARD_UM={'index':0x9d,'name':'REWARD_UM','description':'Bind\x20/\x20unbind\x20Contact\x20(UM)\x20for\x20off-chain\x20coordination','governed_operations':['bind\x20a\x20Contact\x20as\x20the\x20UM\x20coordinator','unbind\x20the\x20UM\x20Contact'],'sdk_exposed':!![]};export const REWARD_WITHDRAW={'index':0x9e,'name':'REWARD_WITHDRAW','description':'Withdraw\x20balance\x20from\x20the\x20Reward\x20to\x20the\x20tx\x20sender\x20inside\x20a\x20Payment\x20object\x20receipt\x20(ETS-B,\x20the\x20only\x20non-claim\x20exit;\x20blocked\x20while\x20the\x20declared\x20no-guard\x20window\x20guard_not_added_expiration_time\x20is\x20in\x20the\x20future)','governed_operations':['withdraw\x20an\x20amount\x20from\x20the\x20Reward\x20balance,\x20delivered\x20to\x20the\x20executing\x20account\x20inside\x20a\x20Payment\x20object\x20(the\x20on-chain\x20receipt;\x20unwrap\x20mode\x20pays\x20the\x20coin\x20out\x20in\x20the\x20same\x20transaction)\x20(fails\x20with\x20E_GUARD_LOCKED_TIME\x20while\x20guard_not_added_expiration_time\x20is\x20in\x20the\x20future)'],'sdk_exposed':!![]};export const REWARD_PERMISSIONS=[REWARD_NEW,REWARD_DESCRIPTION,REWARD_GUARD,REWARD_COIN_ADD,REWARD_RECEIVE,REWARD_GUARD_EXPIRATION_TIME_ADD,REWARD_OWNER_RECEIVE,REWARD_UM,REWARD_WITHDRAW];export const REWARD_FIELDS=[{'name':'id','move_type':'UID','mutability':'immutable','set_at_creation':!![],'constraint':'Object\x20UID;\x20assigned\x20at\x20creation.\x20Never\x20changes.'},{'name':'description','move_type':'String','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x97,'constraint':'Must\x20satisfy\x20common::DESCRIPTION.\x20Updated\x20via\x20permission\x20151.'},{'name':'guards','move_type':'vector<RewardGuard>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x98,'constraint':'vector::length\x20<\x20MAX_GUARD_COUNT\x20(200);\x20E_GUARD_COUNT_EXCEEDED\x20on\x20overflow.','related_errors':['E_GUARD_COUNT_EXCEEDED']},{'name':'balance','move_type':'Balance<T>','mutability':'runtime','set_at_creation':!![],'constraint':'Zero\x20at\x20creation\x20(balance::zero());\x20grows\x20via\x20coin_add/receive;\x20shrinks\x20via\x20claim\x20(split)\x20and\x20via\x20withdraw\x20(ETS-B,\x20funds\x20leave\x20inside\x20a\x20Payment\x20object\x20receipt,\x20only\x20when\x20the\x20no-guard\x20window\x20has\x20elapsed).','related_errors':['E_INSUFFICIENT_BALANCE','E_GUARD_LOCKED_TIME']},{'name':'guard_not_added_expiration_time','move_type':'Option<u64>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x9b,'constraint':'Option<timestamp_ms>.\x20When\x20Some(t):\x20guard_add\x20AND\x20withdraw\x20require\x20clock\x20>\x20t\x20(E_GUARD_LOCKED_TIME).\x20When\x20None\x20or\x20t\x20<\x20now:\x20guards\x20can\x20be\x20added\x20and\x20balance\x20withdrawn.','related_errors':['E_GUARD_LOCKED_TIME','E_GUARD_LOCKED_TIME_NOT_INCREASING','E_GUARD_LOCKED_TIME_INVALID']},{'name':'record','move_type':'ParentTable<address,\x20RecipientRecord>','mutability':'runtime','set_at_creation':!![],'constraint':'Per-recipient\x20claim\x20history.\x20Each\x20RecipientRecord.amount\x20vector\x20has\x20length\x20<\x20MAX_RECORD_COUNT\x20(5200);\x20E_RECORD_COUNT_EXCEEDED\x20on\x20overflow.','related_errors':['E_RECORD_COUNT_EXCEEDED']},{'name':'um','move_type':'Option<address>','mutability':'admin_mutable','set_at_creation':!![],'permission_index':0x9d,'constraint':'Option<Contact\x20address>.\x20Binding\x20creates\x20an\x20object-linker\x20core\x20binding;\x20unbinding\x20disaffiliates.'},{'name':'permission','move_type':'address','mutability':'admin_mutable','set_at_creation':!![],'constraint':'Permission\x20object\x20address.\x20Updated\x20owner-only\x20(asserts\x20old.owner\x20==\x20sender);\x20the\x20change\x20is\x20registered\x20as\x20an\x20object-linker\x20affiliation\x20change.'}];export const REWARD_GUARD_CONSTRUCTORS=[{'constructor':'dynamic_recipient_dynamic_amount','recipient_type':'GuardIdentifier','amount_type':'GuardU64Identifier','params':{'recipient_param':'u8','amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['recipient\x20identifier\x20must\x20resolve\x20to\x20an\x20address\x20in\x20the\x20Passport\x20table\x20—\x20E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4)','amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Dynamic\x20recipient\x20+\x20dynamic\x20amount\x20—\x20both\x20extracted\x20from\x20Passport\x20at\x20claim\x20time\x20(e.g.\x20referral\x20rewards\x20where\x20referrer\x20and\x20amount\x20vary\x20per\x20claim).'},{'constructor':'dynamic_recipient_fixed_amount','recipient_type':'GuardIdentifier','amount_type':'Fixed','params':{'recipient_param':'u8','amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['recipient\x20identifier\x20must\x20resolve\x20to\x20an\x20address\x20in\x20the\x20Passport\x20table\x20—\x20E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Dynamic\x20recipient\x20+\x20fixed\x20amount\x20—\x20e.g.\x20first-order\x20reward\x20where\x20any\x20new\x20customer\x20claims\x20a\x20fixed\x201\x20WOW.'},{'constructor':'entity_recipient_dynamic_amount','recipient_type':'Entity','amount_type':'GuardU64Identifier','params':{'recipient_param':'address','amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Fixed\x20recipient\x20+\x20dynamic\x20amount\x20—\x20e.g.\x20tiered\x20loyalty\x20reward\x20where\x20amount\x20depends\x20on\x20Passport\x20submission\x20(tier\x20level).'},{'constructor':'entity_recipient_fixed_amount','recipient_type':'Entity','amount_type':'Fixed','params':{'recipient_param':'address','amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Fully\x20fixed\x20recipient\x20+\x20amount\x20—\x20simplest\x20configuration\x20(e.g.\x20specific\x20partner\x20bounty).'},{'constructor':'caller_recipient_dynamic_amount','recipient_type':'Signer','amount_type':'GuardU64Identifier','params':{'amount_param':'u8','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['amount\x20identifier\x20must\x20resolve\x20to\x20a\x20u64\x20Passport\x20value\x20—\x20E_AMOUNT_NOT_U64\x20(5)','if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Caller\x20is\x20recipient\x20+\x20dynamic\x20amount\x20—\x20e.g.\x20self-service\x20claim\x20where\x20amount\x20depends\x20on\x20Passport\x20submission\x20(e.g.\x20cashback\x20rate).'},{'constructor':'caller_recipient_fixed_amount','recipient_type':'Signer','amount_type':'Fixed','params':{'amount_param':'u64','expiration_time':'Option<u64>','store_from_id':'Option<u8>'},'construction_checks':['if\x20store_from_id\x20is\x20Some:\x20its\x20identifier\x20must\x20be\x20number/address\x20compatible\x20—\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)'],'typical_use':'Caller\x20is\x20recipient\x20+\x20fixed\x20amount\x20—\x20e.g.\x20flash\x20sale\x20where\x20any\x20eligible\x20caller\x20claims\x20a\x20fixed\x20reward.'}];export const REWARD_ERROR_CODES=[{'code':0x1,'name':'E_GUARD_LOCKED_TIME_NOT_INCREASING','description':'guard-lock\x20time\x20update:\x20new\x20time\x20<\x20current\x20clock\x20(must\x20be\x20≥\x20now)','trigger_operation':'guard-lock\x20time\x20update\x20(155)'},{'code':0x2,'name':'E_GUARD_EXPIRED','description':'guard_add\x20on\x20guard\x20with\x20expiration_time\x20<\x20now,\x20OR\x20claim\x20on\x20guard\x20with\x20expiration_time\x20<\x20now','trigger_operation':'guard_add\x20/\x20claim'},{'code':0x3,'name':'E_GUARD_COUNT_EXCEEDED','description':'guard_add\x20would\x20exceed\x20MAX_GUARD_COUNT=200\x20(only\x20on\x20NEW\x20guard,\x20not\x20on\x20update\x20of\x20existing)','trigger_operation':'guard_add'},{'code':0x4,'name':'E_RECIPIENT_IDENTIFIER_NOT_ADDRESS','description':'RewardGuard\x20constructor:\x20recipient\x20identifier\x20type\x20is\x20not\x20address\x20(GuardIdentifier\x20variant\x20only)','trigger_operation':'claim-guard\x20construction'},{'code':0x5,'name':'E_AMOUNT_NOT_U64','description':'RewardGuard\x20constructor:\x20amount\x20identifier\x20type\x20is\x20not\x20u64\x20(GuardU64Identifier\x20variant\x20only)','trigger_operation':'claim-guard\x20construction'},{'code':0x6,'name':'E_INSUFFICIENT_BALANCE','description':'claim:\x20balance\x20<\x20amount\x20(cannot\x20split\x20more\x20than\x20held)','trigger_operation':'claim'},{'code':0x7,'name':'E_GUARD_NOT_FOUND','description':'claim:\x20no\x20guard\x20in\x20self.guards\x20matches\x20the\x20supplied\x20guard\x20address','trigger_operation':'claim'},{'code':0x8,'name':'E_RECORD_COUNT_EXCEEDED','description':'claim:\x20recipient\x20already\x20has\x20MAX_RECORD_COUNT=5200\x20entries\x20(E_RECORD_COUNT_EXCEEDED)','trigger_operation':'claim'},{'code':0xa,'name':'E_GUARD_LOCKED_TIME','description':'guard_add\x20/\x20withdraw\x20while\x20guard_not_added_expiration_time\x20is\x20Some\x20and\x20clock\x20≤\x20expiration_time','trigger_operation':'guard_add\x20/\x20withdraw'},{'code':0xb,'name':'E_GUARD_LOCKED_TIME_INVALID','description':'guard-lock\x20time\x20update:\x20new\x20Some(t)\x20where\x20t\x20≤\x20now\x20(must\x20be\x20future)','trigger_operation':'guard-lock\x20time\x20update\x20(155)'},{'code':0xc,'name':'E_STORE_FROM_ID_NOT_COMPATIBLE','description':'RewardGuard\x20constructor:\x20store_from_id\x20identifier\x20type\x20is\x20not\x20number\x20or\x20address','trigger_operation':'claim-guard\x20construction'},{'code':0xd,'name':'E_CLAIM_ALREADY_MADE','description':'claim:\x20the\x20(recipient,\x20guard,\x20store_from\x20value)\x20once-slot\x20is\x20already\x20consumed\x20(MOV-PROTOCOL-1212\x20F-01\x20fix\x20—\x20replay\x20aborts,\x20the\x20pool\x20keeps\x20its\x20balance).\x20Empty\x20store_from\x20slot\x20=\x20once\x20per\x20(recipient,\x20guard);\x20a\x20store_from\x20value\x20pins\x20a\x20per-value\x20slot\x20(per-order\x20bounty)','trigger_operation':'claim'},{'code':0xe,'name':'E_CLAIM_RECIPIENT_NOT_SIGNER','description':'claim:\x20the\x20resolved\x20recipient\x20(from\x20guard\x20submissions\x20or\x20the\x20Entity\x20binding)\x20is\x20not\x20the\x20transaction\x20sender\x20(MOV-PROTOCOL-1212\x20B5\x20fix\x20—\x20an\x20attacker\x20cannot\x20route\x20a\x20reward\x20to\x20a\x20third\x20address).\x20Entity\x20flows\x20pass\x20because\x20the\x20SDK\x20replaces\x20the\x20sender\x20with\x20the\x20entity\x20account','trigger_operation':'claim'}];export const REWARD_SCENES=[{'id':'reward_first_order','name':'First-order\x20reward','industry':['universal','ecommerce','service','freelance'],'scenario':'New\x20customers\x20receive\x20a\x20fixed\x20reward\x20after\x20their\x20first\x20order.\x20Guard\x20verifies\x20order\x20ownership\x20+\x20first-time\x20status;\x20'+'Recipient=Signer\x20(caller\x20is\x20the\x20new\x20customer);\x20Amount=Fixed\x20(e.g.\x201\x20WOW).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin\x20(e.g.\x200x2::wow::WOW\x20or\x20a\x20custom\x20token)','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Signer\x20recipient\x20+\x20Fixed\x20amount\x20—\x20caller\x20claims\x20a\x20fixed\x20amount\x20(e.g.\x201\x20WOW)','Guard\x20verifies:\x20order_address.holder\x20==\x20signer\x20AND\x20order\x20is\x20the\x20first\x20order\x20(Repository\x20query)','expiration_time\x20bounds\x20the\x20campaign\x20window\x20(e.g.\x2030\x20days)','coin_add\x20deposits\x20the\x20campaign\x20budget\x20upfront\x20(e.g.\x20100\x20WOW\x20for\x20100\x20claims)'],'recommended_templates':['first_order']},{'id':'reward_referral','name':'Referral\x20viral\x20reward','industry':['universal','ecommerce','service','content'],'scenario':'Both\x20referrer\x20and\x20referee\x20receive\x20a\x20reward\x20when\x20the\x20referee\x20completes\x20a\x20first\x20order.\x20Two\x20guards:\x20one\x20for\x20referrer\x20(Entity),\x20one\x20for\x20referee\x20(Signer).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x2,'recipient_types_used':['Entity','Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':!![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Entity\x20recipient\x20+\x20Fixed\x20amount\x20for\x20the\x20referrer\x20(recipient\x20=\x20referrer\x20address)','Signer\x20recipient\x20+\x20Fixed\x20amount\x20for\x20the\x20referee\x20(caller\x20is\x20recipient)','Guard\x20verifies:\x20referrer\x20marked\x20in\x20Repository\x20AND\x20referee\x27s\x20order\x20completed','store_from_id\x20may\x20record\x20the\x20order\x20address\x20for\x20audit\x20trail'],'recommended_templates':['referral']},{'id':'reward_loyalty','name':'Loyalty\x20tiered\x20reward','industry':['universal','ecommerce','subscription','content'],'scenario':'Customers\x20unlock\x20higher\x20rewards\x20after\x20reaching\x20cumulative\x20spending\x20tiers.\x20Recipient=Signer;\x20Amount=GuardU64Identifier\x20(tier-dependent\x20amount\x20extracted\x20from\x20Passport).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['GuardU64Identifier'],'uses_expiration_time':![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD],'common_patterns':['Signer\x20recipient\x20+\x20identifier\x20amount\x20—\x20amount\x20is\x20dynamic,\x20extracted\x20from\x20Passport\x20submission\x20(tier\x20level\x20→\x20reward\x20amount)','Guard\x20verifies:\x20cumulative\x20spend\x20≥\x20tier\x20threshold\x20(Repository\x20query)','No\x20expiration_time\x20—\x20loyalty\x20is\x20perpetual\x20(until\x20deactivated\x20via\x20guard_remove_expired)','Guard\x20submission\x20value\x20type\x20MUST\x20be\x20u64\x20(E_AMOUNT_NOT_U64\x20otherwise)'],'recommended_templates':['loyalty']},{'id':'reward_flash_sale','name':'Limited-time\x20flash\x20sale\x20reward','industry':['universal','ecommerce','retail'],'scenario':'Time-bounded\x20reward\x20for\x20the\x20first\x20N\x20callers.\x20Recipient=Signer;\x20Amount=Fixed.\x20Guard\x20verifies\x20time\x20window\x20+\x20claim\x20count.','phases':['creation','guard_addition','funds_replenish','claim','guard_lock_mgmt'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x1,'recipient_types_used':['Signer'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_GUARD_EXPIRATION_TIME_ADD],'common_patterns':['Signer\x20recipient\x20+\x20Fixed\x20amount\x20—\x20fixed\x20amount\x20per\x20claim\x20(e.g.\x202\x20WOW)','expiration_time\x20bounds\x20the\x20flash\x20sale\x20window\x20(e.g.\x2048\x20hours)','the\x20guard-addition\x20time-lock\x20(155)\x20may\x20lock\x20further\x20guard\x20additions\x20during\x20the\x20sale','Budget\x20=\x20max_claims\x20×\x20amount;\x20coin_add\x20deposits\x20this\x20upfront'],'recommended_templates':['flash_sale']},{'id':'reward_bulk_discount','name':'Bulk\x20discount\x20/\x20cashback\x20reward','industry':['universal','ecommerce','wholesale','service'],'scenario':'Customer\x20receives\x20cashback\x20proportional\x20to\x20order\x20size.\x20Recipient=Signer\x20or\x20Entity\x20(order\x20holder);\x20Amount=GuardU64Identifier\x20(cashback\x20rate\x20from\x20Passport).','phases':['creation','guard_addition','funds_replenish','claim'],'coin_type_note':'T\x20=\x20payment\x20coin\x20type\x20(must\x20match\x20order\x20payment\x20for\x20clean\x20cashback)','typical_guard_count':0x1,'recipient_types_used':['Signer','Entity'],'amount_types_used':['GuardU64Identifier'],'uses_expiration_time':![],'uses_store_from_id':!![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_RECEIVE],'common_patterns':['Signer\x20recipient\x20+\x20identifier\x20amount\x20—\x20caller\x20claims\x20dynamic\x20amount\x20(cashback\x20=\x20order_amount\x20×\x20rate)','store_from_id\x20records\x20the\x20order\x20address\x20for\x20cross-reference\x20(audit\x20trail)','receive\x20(154)\x20may\x20be\x20used\x20to\x20accept\x20CoinWrapper<T>\x20refunds\x20that\x20replenish\x20the\x20balance','Guard\x20verifies:\x20order.completed\x20AND\x20order.service\x20==\x20this\x20Service'],'recommended_templates':['cashback']},{'id':'reward_milestone','name':'Service\x20milestone\x20reward','industry':['universal','ecommerce','content','subscription'],'scenario':'When\x20a\x20Service\x20reaches\x20a\x20milestone\x20(e.g.\x20100\x20orders),\x20early\x20supporters\x20receive\x20extra\x20rewards.\x20Recipient=Entity\x20(early\x20customer);\x20Amount=Fixed.','phases':['creation','guard_addition','funds_replenish','claim','guard_lock_mgmt'],'coin_type_note':'T\x20=\x20project\x20reward\x20coin','typical_guard_count':0x32,'recipient_types_used':['Entity'],'amount_types_used':['Fixed'],'uses_expiration_time':!![],'uses_store_from_id':![],'builtin_indexes_consumed':[REWARD_NEW,REWARD_GUARD,REWARD_COIN_ADD,REWARD_GUARD_EXPIRATION_TIME_ADD],'common_patterns':['Entity\x20recipient\x20+\x20Fixed\x20amount\x20for\x20each\x20early\x20customer\x20(recipient\x20=\x20customer\x20address)','Multiple\x20guards\x20(up\x20to\x2050\x20for\x2050\x20early\x20supporters)\x20—\x20well\x20within\x20MAX_GUARD_COUNT=200','Guard\x20verifies:\x20Service\x20order_count\x20>=\x20milestone\x20AND\x20claimer\x20is\x20in\x20early-customer\x20list','the\x20guard-addition\x20time-lock\x20(155)\x20may\x20lock\x20the\x20guard\x20list\x20after\x20milestone\x20setup'],'recommended_templates':['milestone']}];export const REWARD_LEDGER_VERSION='1.0.0';export function getScenesByPhase(a){return REWARD_SCENES['filter'](b=>b['phases']['includes'](a));}export function findSceneById(a){return REWARD_SCENES['find'](b=>b['id']===a);}export function getScenesByIndustry(a){return REWARD_SCENES['filter'](b=>b['industry']['includes'](a)||b['industry']['includes']('universal'));}export function getBuiltinPermissionByIndex(a){return REWARD_PERMISSIONS['find'](b=>b['index']===a);}export function isRewardBuiltinPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function getAllBuiltinPermissions(){return[...REWARD_PERMISSIONS];}export function getRewardScenesCount(){return REWARD_SCENES['length'];}export function getGuardConstructorSpec(a){return REWARD_GUARD_CONSTRUCTORS['find'](b=>b['constructor']===a);}export function resolveGuardConstructor(a,b){const c={'GuardIdentifier|GuardU64Identifier':'dynamic_recipient_dynamic_amount','GuardIdentifier|Fixed':'dynamic_recipient_fixed_amount','Entity|GuardU64Identifier':'entity_recipient_dynamic_amount','Entity|Fixed':'entity_recipient_fixed_amount','Signer|GuardU64Identifier':'caller_recipient_dynamic_amount','Signer|Fixed':'caller_recipient_fixed_amount'};return c[a+'|'+b];}export function getRewardErrorByCode(a){return REWARD_ERROR_CODES['find'](b=>b['code']===a);}export function getRewardErrorByName(a){return REWARD_ERROR_CODES['find'](b=>b['name']===a);}export function validateGuardCount(a){if(a>=MAX_GUARD_COUNT_REWARD)return{'ok':![],'violation':'Guard\x20count\x20'+a+'\x20would\x20exceed\x20MAX_GUARD_COUNT_REWARD\x20'+MAX_GUARD_COUNT_REWARD};return{'ok':!![]};}export function validateRecordCount(a){if(a>=MAX_RECORD_COUNT_REWARD)return{'ok':![],'violation':'Record\x20count\x20'+a+'\x20would\x20exceed\x20MAX_RECORD_COUNT_REWARD\x20'+MAX_RECORD_COUNT_REWARD+'\x20—\x20recipient\x20can\x20no\x20longer\x20claim'};return{'ok':!![]};}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['flash\x20sale','reward_flash_sale'],['flash_sale','reward_flash_sale'],['limited-time','reward_flash_sale'],['limited\x20time','reward_flash_sale'],['referral','reward_referral'],['viral','reward_referral'],['refer\x20a\x20friend','reward_referral'],['invite','reward_referral'],['loyalty','reward_loyalty'],['tiered','reward_loyalty'],['tier','reward_loyalty'],['repeat','reward_loyalty'],['cashback','reward_bulk_discount'],['bulk\x20discount','reward_bulk_discount'],['bulk_discount','reward_bulk_discount'],['wholesale','reward_bulk_discount'],['milestone','reward_milestone'],['early\x20supporter','reward_milestone'],['early\x20customer','reward_milestone'],['first\x20order','reward_first_order'],['first_order','reward_first_order'],['new\x20customer','reward_first_order'],['first-time','reward_first_order']];for(const [d,e]of c){if(b['includes'](d)){const f=findSceneById(e);if(f)return f;}}return undefined;}export const REWARD_CROSS_OBJECT_REFS=[{'object':'Permission','phase':'universal','relationship':'Reward.permission\x20(address;\x20borrowed\x20for\x20all\x20150-157\x20assertions)'},{'object':'Permission','phase':'permission_update','relationship':'permission\x20update:\x20owner-only\x20(asserts\x20old.owner\x20==\x20sender);\x20registered\x20as\x20an\x20object-linker\x20affiliation\x20change'},{'object':'Guard','phase':'guard_addition','relationship':'RewardGuard.guard\x20=\x20guard.id_address\x20(each\x20guard\x20registered\x20via\x20object-linker\x20core\x20binding)'},{'object':'Guard','phase':'claim','relationship':'claim:\x20iterates\x20self.guards\x20looking\x20for\x20guard.id_address\x20match;\x20E_GUARD_NOT_FOUND\x20if\x20no\x20match'},{'object':'Guard','phase':'claim','relationship':'claim:\x20the\x20guard\x20verification\x20result\x20validates\x20the\x20Passport\x20submission\x20data'},{'object':'Passport','phase':'claim','relationship':'claim:\x20the\x20claimant\x27s\x20Passport\x20submission\x20supplies\x20the\x20recipient\x20(address)\x20and/or\x20amount\x20(u64)\x20per\x20RewardGuard\x20variant'},{'object':'Passport','phase':'claim','relationship':'claim:\x20if\x20store_from_id\x20is\x20Some,\x20extracts\x20store-from\x20address\x20from\x20Passport\x20submission'},{'object':'Payment','phase':'funds_replenish','relationship':'receive\x20(154):\x20unwraps\x20Coin<T>\x20from\x20CoinWrapper<T>\x20(with\x20check)\x20and\x20joins\x20the\x20balance'},{'object':'Payment','phase':'owner_receive','relationship':'owner\x20receipt\x20(156):\x20unwraps\x20CoinWrapper<K>\x20and\x20forwards\x20it\x20to\x20the\x20Permission\x20owner'},{'object':'Repository','phase':'claim','relationship':'Guard\x20may\x20query\x20Repository\x20(e.g.\x20order\x20history\x20for\x20first-order\x20/\x20loyalty\x20verification)'},{'object':'Service','phase':'claim','relationship':'Guard\x20may\x20verify\x20order.service\x20==\x20this\x20Service\x20(cashback\x20/\x20first-order\x20scenarios)'},{'object':'Demand','phase':'guard_addition','relationship':'Guard\x20may\x20be\x20shared\x20with\x20Demand\x20(recommendation\x20filtering);\x20same\x20Guard\x20object\x20address\x20space'},{'object':'Allocation','phase':'owner_receive','relationship':'Terminal\x20Allocation\x20alloc\x20may\x20route\x20funds\x20back\x20to\x20Reward\x20(replenishment\x20loop)'},{'object':'Contact','phase':'um_mgmt','relationship':'UM\x20binding\x20(157):\x20binds\x20Contact\x20(UM)\x20for\x20off-chain\x20coordination;\x20creates\x20object-linker\x20core\x20binding'},{'object':'Coin','phase':'universal','relationship':'Reward<phantom\x20T>:\x20T\x20is\x20the\x20coin\x20type;\x20balance:\x20Balance<T>;\x20coin_add\x20expects\x20Coin<T>'}];
@@ -1 +1 @@
1
- export const REWARD_TEMPLATES=[{'type':'first_order','name':'First-order\x20reward','description':'New\x20customers\x20receive\x20a\x20reward\x20after\x20their\x20first\x20order,\x20lowering\x20the\x20trial\x20barrier\x20and\x20boosting\x20conversion.','guardCondition':'Guard\x20verifies:\x20order_address.holder\x20==\x20current\x20claimer,\x20and\x20order.service\x20==\x20this\x20Service,\x20and\x20order\x20is\x20the\x20first\x20order\x20for\x20this\x20holder\x20(via\x20Repository\x20history\x20query)','amountRange':{'min':'0.1WOW','max':'5WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27100WOW\x27)','required':!![]}],'example':'A\x20new\x20customer\x20orders\x20a\x20photography\x20service\x20and\x20receives\x201\x20WOW\x20cashback\x20on\x20the\x20first\x20order,\x20lowering\x20the\x20first\x20trial\x20cost.','relevantGuardOps':['query','repository_read']},{'type':'referral','name':'Referral\x20viral\x20reward','description':'Existing\x20customers\x20refer\x20new\x20customers\x20to\x20place\x20an\x20order;\x20both\x20parties\x20receive\x20a\x20reward,\x20creating\x20a\x20word-of-mouth\x20flywheel.','guardCondition':'Guard\x20verifies:\x20referrer\x20address\x20is\x20marked\x20as\x20\x27referred_by\x27\x20in\x20the\x20Repository\x20review\x20table,\x20and\x20the\x20referee\x27s\x20order\x20is\x20completed\x20(Progress\x20reached\x20terminal\x20state)','amountRange':{'min':'0.5WOW','max':'10WOW'},'allocationStrategy':'proportional','parameters':[{'name':'referrer_reward','type':'string','description':'Referrer\x20reward\x20(e.g.,\x20\x272WOW\x27)','required':!![]},{'name':'referee_reward','type':'string','description':'Referee\x20reward\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'max_referrals','type':'number','description':'Max\x20referrals\x20per\x20person\x20(e.g.,\x2010)','required':![]}],'example':'Alice\x20refers\x20Bob\x20to\x20purchase\x20a\x20service;\x20after\x20Bob\x20completes\x20the\x20first\x20order,\x20Alice\x20gets\x202\x20WOW\x20and\x20Bob\x20gets\x201\x20WOW.','relevantGuardOps':['query','repository_read','repository_write']},{'type':'loyalty','name':'Loyalty\x20tiered\x20reward','description':'Customers\x20unlock\x20higher\x20rewards\x20after\x20reaching\x20cumulative\x20spending\x20tiers,\x20improving\x20repeat\x20rate\x20and\x20average\x20order\x20value.','guardCondition':'Guard\x20verifies:\x20via\x20Repository\x20query,\x20the\x20address\x27s\x20historical\x20order\x20count\x20>=\x20N,\x20where\x20N\x20is\x20the\x20current\x20tier\x20threshold','amountRange':{'min':'1WOW','max':'50WOW'},'allocationStrategy':'tiered','parameters':[{'name':'tier1_orders','type':'number','description':'Tier\x201\x20order\x20count\x20(e.g.,\x203)','required':!![]},{'name':'tier1_reward','type':'string','description':'Tier\x201\x20reward\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'tier2_orders','type':'number','description':'Tier\x202\x20order\x20count\x20(e.g.,\x2010)','required':!![]},{'name':'tier2_reward','type':'string','description':'Tier\x202\x20reward\x20(e.g.,\x20\x275WOW\x27)','required':!![]},{'name':'tier3_orders','type':'number','description':'Tier\x203\x20order\x20count\x20(e.g.,\x2030)','required':![]},{'name':'tier3_reward','type':'string','description':'Tier\x203\x20reward\x20(e.g.,\x20\x2720WOW\x27)','required':![]}],'example':'A\x20customer\x20with\x203\x20cumulative\x20orders\x20gets\x201\x20WOW,\x2010\x20orders\x20gets\x205\x20WOW,\x2030\x20orders\x20gets\x2020\x20WOW,\x20incentivizing\x20continued\x20spending.','relevantGuardOps':['query','repository_read']},{'type':'flash_sale','name':'Limited-time\x20flash\x20sale','description':'Provides\x20discounts\x20or\x20extra\x20rewards\x20within\x20a\x20limited\x20time\x20window,\x20creating\x20urgency\x20to\x20drive\x20instant\x20conversion.','guardCondition':'Guard\x20verifies:\x20current\x20block\x20time\x20is\x20within\x20[start_time,\x20end_time]\x20range\x20(Guard\x20time\x20condition)','amountRange':{'min':'0.1WOW','max':'20WOW'},'allocationStrategy':'fixed','parameters':[{'name':'start_time','type':'string','description':'Start\x20time\x20(Unix\x20timestamp)','required':!![]},{'name':'end_time','type':'string','description':'End\x20time\x20(Unix\x20timestamp)','required':!![]},{'name':'amount','type':'string','description':'Flash\x20sale\x20reward\x20amount','required':!![]},{'name':'max_claims','type':'number','description':'Max\x20claims\x20(e.g.,\x20100)','required':!![]}],'example':'Weekend\x2048-hour\x20flash\x20sale:\x20ordering\x20customers\x20get\x20an\x20extra\x202\x20WOW\x20cashback,\x20valid\x20for\x20the\x20first\x20100.','relevantGuardOps':['query','time_condition']},{'type':'cashback','name':'Spending\x20cashback','description':'Customers\x20receive\x20cashback\x20proportional\x20to\x20spending\x20after\x20completing\x20an\x20order,\x20improving\x20repeat\x20purchase\x20willingness.','guardCondition':'Guard\x20verifies:\x20order\x20has\x20reached\x20terminal\x20state\x20(Progress\x20completed),\x20and\x20order.service\x20==\x20this\x20Service','amountRange':{'min':'0.1WOW','max':'100WOW'},'allocationStrategy':'proportional','parameters':[{'name':'cashback_rate','type':'string','description':'Cashback\x20rate\x20(e.g.,\x20\x270.1\x27\x20=\x2010%)','required':!![]},{'name':'max_cashback','type':'string','description':'Max\x20cashback\x20per\x20order\x20(e.g.,\x20\x2710WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27500WOW\x27)','required':!![]}],'example':'A\x20customer\x20spends\x2010\x20WOW,\x20gets\x2010%\x20cashback\x20=\x201\x20WOW,\x20which\x20can\x20be\x20deducted\x20on\x20the\x20next\x20purchase.','relevantGuardOps':['query']},{'type':'milestone','name':'Milestone\x20reward','description':'When\x20a\x20Service\x20reaches\x20a\x20specific\x20milestone\x20(e.g.,\x20100\x20orders,\x201000\x20customers),\x20early\x20supporters\x20receive\x20extra\x20rewards.','guardCondition':'Guard\x20verifies:\x20Repository\x20query\x20shows\x20Service\x20cumulative\x20order\x20count\x20>=\x20milestone_threshold,\x20and\x20claimer\x20is\x20an\x20early\x20customer\x20(order_index\x20<\x20milestone)','amountRange':{'min':'1WOW','max':'100WOW'},'allocationStrategy':'fixed','parameters':[{'name':'milestone','type':'number','description':'Milestone\x20value\x20(e.g.,\x20100)','required':!![]},{'name':'reward_per_user','type':'string','description':'Reward\x20per\x20person\x20(e.g.,\x20\x275WOW\x27)','required':!![]},{'name':'max_recipients','type':'number','description':'Max\x20beneficiaries\x20(e.g.,\x2050)','required':!![]}],'example':'Service\x20reaches\x20the\x20100-order\x20milestone;\x20the\x20first\x2050\x20customers\x20each\x20receive\x205\x20WOW\x20extra\x20reward.','relevantGuardOps':['query','repository_read']},{'type':'wonder_praise','name':'Wonder-node\x20praise\x20reward\x20(post-completion\x20positive\x20feedback)','description':'Rewards\x20customers\x20who\x20advance\x20their\x20order\x20Progress\x20to\x20the\x20\x27wonder\x27\x20node\x20after\x20normal\x20completion\x20—\x20'+'a\x20user-driven\x20positive-feedback\x20mechanism.\x20The\x20machine\x20design\x20pattern\x20is:\x20'+'place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'After\x20the\x20order\x20reaches\x20\x27completed\x27\x20(terminal\x20business\x20state),\x20the\x20OrderHolder\x20'+'(namedOperator=\x27\x27)\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20'+'(negative\x20review).\x20The\x20Reward\x27s\x20claim_guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27\x20'+'AND\x20order.service\x20==\x20this\x20Service,\x20so\x20only\x20satisfied\x20customers\x20can\x20claim.\x20'+'This\x20creates\x20an\x20on-chain\x20reputation\x20signal\x20that\x20benefits\x20both\x20the\x20merchant\x20'+'(public\x20proof\x20of\x20quality)\x20and\x20the\x20customer\x20(monetary\x20reward\x20for\x20honest\x20feedback).','guardCondition':'Guard\x20verifies:\x20(1)\x20Progress.current\x20==\x20\x27wonder\x27\x20(customer\x20advanced\x20to\x20praise\x20node),\x20'+'(2)\x20Progress.task\x20==\x20order_address\x20AND\x20order.service\x20==\x20this\x20Service,\x20'+'(3)\x20Progress.machine\x20==\x20service.machine\x20(snapshot\x20match),\x20'+'(4)\x20claimer\x20is\x20the\x20order\x20holder\x20(order.holder\x20==\x20signer).\x20'+'Recommended\x20Guard\x20ops:\x20query\x20Progress\x20object,\x20query\x20Order\x20object,\x20'+'verify\x20Progress.current\x20field\x20equals\x20\x27wonder\x27.','amountRange':{'min':'0.1WOW','max':'20WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20per\x20praise\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27500WOW\x27)','required':!![]},{'name':'expiration_time','type':'number','description':'Claim\x20expiration\x20timestamp\x20(ms);\x200\x20=\x20no\x20expiration','required':![]},{'name':'max_claims_per_user','type':'number','description':'Max\x20claims\x20per\x20user\x20(default\x201,\x20prevents\x20duplicate\x20praise\x20rewards)','required':![]}],'example':'A\x20photography\x20service\x20machine:\x20place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20wonder.\x20'+'After\x20delivery,\x20the\x20customer\x20advances\x20Progress\x20to\x20\x27wonder\x27\x20if\x20satisfied.\x20'+'The\x20Reward\x27s\x20Guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27,\x20and\x20the\x20customer\x20claims\x201\x20WOW.\x20'+'Merchant\x20benefits\x20from\x20on-chain\x20proof\x20of\x20customer\x20satisfaction.','relevantGuardOps':['query','progress_node_check']},{'type':'wonder_feedback','name':'Wonder-node\x20feedback\x20collection\x20(covers\x20wonder\x20&\x20no_wonder)','description':'A\x20feedback-collection\x20Reward\x20that\x20pays\x20a\x20small\x20amount\x20for\x20EITHER\x20positive\x20(wonder)\x20OR\x20'+'negative\x20(no_wonder)\x20feedback,\x20encouraging\x20customers\x20to\x20leave\x20honest\x20reviews.\x20'+'The\x20machine\x20design\x20pattern\x20is\x20the\x20same\x20as\x20wonder_praise:\x20'+'place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'The\x20Reward\x27s\x20claim_guard\x20verifies\x20Progress.current\x20∈\x20{\x27wonder\x27,\x20\x27no_wonder\x27}\x20—\x20both\x20nodes\x20'+'trigger\x20the\x20reward.\x20This\x20is\x20useful\x20for\x20merchants\x20who\x20want\x20to\x20gather\x20feedback\x20signal\x20'+'regardless\x20of\x20sentiment,\x20e.g.,\x20for\x20product\x20improvement\x20or\x20public\x20reputation\x20metrics.\x20'+'Pair\x20with\x20a\x20Repository\x20that\x20records\x20the\x20feedback\x20node\x20for\x20historical\x20analysis.','guardCondition':'Guard\x20verifies:\x20(1)\x20Progress.current\x20∈\x20{\x27wonder\x27,\x20\x27no_wonder\x27},\x20'+'(2)\x20Progress.task\x20==\x20order_address\x20AND\x20order.service\x20==\x20this\x20Service,\x20'+'(3)\x20claimer\x20is\x20the\x20order\x20holder.\x20'+'The\x20Guard\x20should\x20query\x20the\x20Progress\x20object\x20and\x20check\x20that\x20current\x20node\x20is\x20one\x20of\x20the\x20'+'two\x20feedback\x20nodes.\x20Optional:\x20write\x20the\x20feedback\x20node\x20to\x20a\x20Repository\x20for\x20analytics.','amountRange':{'min':'0.05WOW','max':'5WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20per\x20feedback\x20(e.g.,\x20\x270.5WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27200WOW\x27)','required':!![]},{'name':'feedback_nodes','type':'string','description':'Comma-separated\x20list\x20of\x20feedback\x20node\x20names\x20(default:\x20\x27wonder,no_wonder\x27)','required':![]},{'name':'expiration_time','type':'number','description':'Claim\x20expiration\x20timestamp\x20(ms);\x200\x20=\x20no\x20expiration','required':![]}],'example':'A\x20freelance\x20design\x20service:\x20place_order\x20→\x20...\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'Customer\x20advances\x20to\x20\x27wonder\x27\x20(liked\x20the\x20work)\x20or\x20\x27no_wonder\x27\x20(didn\x27t\x20like\x20it).\x20'+'Both\x20trigger\x20a\x200.5\x20WOW\x20feedback\x20reward.\x20Merchant\x20tracks\x20the\x20wonder/no_wonder\x20ratio\x20'+'in\x20a\x20Repository\x20to\x20identify\x20quality\x20issues\x20and\x20improve\x20service.','relevantGuardOps':['query','progress_node_check','repository_write']}];const TEMPLATE_INDEX=new Map(REWARD_TEMPLATES['map'](a=>[a['type'],a]));export function getRewardTemplate(a){return TEMPLATE_INDEX['get'](a);}export function listRewardTemplates(){return REWARD_TEMPLATES;}export function suggestRewardTemplate(a){const b=a['toLowerCase']();if(b['includes']('wonder')||b['includes']('praise')||b['includes']('thumbs_up')||b['includes']('praise')||b['includes']('positive\x20review')||b['includes']('satisfaction\x20reward'))return getRewardTemplate('wonder_praise');if(b['includes']('feedback')||b['includes']('review\x20collection')||b['includes']('no_wonder')||b['includes']('thumbs_down')||b['includes']('complaint')||b['includes']('both\x20sentiment'))return getRewardTemplate('wonder_feedback');if(b['includes']('first\x20order')||b['includes']('new')||b['includes']('first'))return getRewardTemplate('first_order');if(b['includes']('referral')||b['includes']('viral'))return getRewardTemplate('referral');if(b['includes']('repeat')||b['includes']('loyalty'))return getRewardTemplate('loyalty');if(b['includes']('limited-time')||b['includes']('flash'))return getRewardTemplate('flash_sale');if(b['includes']('cashback'))return getRewardTemplate('cashback');if(b['includes']('milestone'))return getRewardTemplate('milestone');return undefined;}export const REWARD_TEMPLATES_VERSION=0x1;
1
+ export const REWARD_TEMPLATES=[{'type':'first_order','name':'First-order\x20reward','description':'New\x20customers\x20receive\x20a\x20reward\x20after\x20their\x20first\x20order,\x20lowering\x20the\x20trial\x20barrier\x20and\x20boosting\x20conversion.','guardCondition':'Guard\x20verifies:\x20order_address.holder\x20==\x20current\x20claimer,\x20and\x20order.service\x20==\x20this\x20Service,\x20and\x20order\x20is\x20the\x20first\x20order\x20for\x20this\x20holder\x20(via\x20Repository\x20history\x20query)','amountRange':{'min':'0.1WOW','max':'5WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27100WOW\x27)','required':!![]}],'example':'A\x20new\x20customer\x20orders\x20a\x20photography\x20service\x20and\x20receives\x201\x20WOW\x20cashback\x20on\x20the\x20first\x20order,\x20lowering\x20the\x20first\x20trial\x20cost.','relevantGuardOps':['query','repository_read']},{'type':'referral','name':'Referral\x20viral\x20reward','description':'Existing\x20customers\x20refer\x20new\x20customers\x20to\x20place\x20an\x20order;\x20both\x20parties\x20receive\x20a\x20reward,\x20creating\x20a\x20word-of-mouth\x20flywheel.','guardCondition':'Guard\x20verifies:\x20referrer\x20address\x20is\x20marked\x20as\x20\x27referred_by\x27\x20in\x20the\x20Repository\x20review\x20table,\x20and\x20the\x20referee\x27s\x20order\x20is\x20completed\x20(Progress\x20reached\x20terminal\x20state)','amountRange':{'min':'0.5WOW','max':'10WOW'},'allocationStrategy':'proportional','parameters':[{'name':'referrer_reward','type':'string','description':'Referrer\x20reward\x20(e.g.,\x20\x272WOW\x27)','required':!![]},{'name':'referee_reward','type':'string','description':'Referee\x20reward\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'max_referrals','type':'number','description':'Max\x20referrals\x20per\x20person\x20(e.g.,\x2010)','required':![]}],'example':'Alice\x20refers\x20Bob\x20to\x20purchase\x20a\x20service;\x20after\x20Bob\x20completes\x20the\x20first\x20order,\x20Alice\x20gets\x202\x20WOW\x20and\x20Bob\x20gets\x201\x20WOW.','relevantGuardOps':['query','repository_read','repository_write']},{'type':'loyalty','name':'Loyalty\x20tiered\x20reward','description':'Customers\x20unlock\x20higher\x20rewards\x20after\x20reaching\x20cumulative\x20spending\x20tiers,\x20improving\x20repeat\x20rate\x20and\x20average\x20order\x20value.','guardCondition':'Guard\x20verifies:\x20via\x20Repository\x20query,\x20the\x20address\x27s\x20historical\x20order\x20count\x20>=\x20N,\x20where\x20N\x20is\x20the\x20current\x20tier\x20threshold','amountRange':{'min':'1WOW','max':'50WOW'},'allocationStrategy':'tiered','parameters':[{'name':'tier1_orders','type':'number','description':'Tier\x201\x20order\x20count\x20(e.g.,\x203)','required':!![]},{'name':'tier1_reward','type':'string','description':'Tier\x201\x20reward\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'tier2_orders','type':'number','description':'Tier\x202\x20order\x20count\x20(e.g.,\x2010)','required':!![]},{'name':'tier2_reward','type':'string','description':'Tier\x202\x20reward\x20(e.g.,\x20\x275WOW\x27)','required':!![]},{'name':'tier3_orders','type':'number','description':'Tier\x203\x20order\x20count\x20(e.g.,\x2030)','required':![]},{'name':'tier3_reward','type':'string','description':'Tier\x203\x20reward\x20(e.g.,\x20\x2720WOW\x27)','required':![]}],'example':'A\x20customer\x20with\x203\x20cumulative\x20orders\x20gets\x201\x20WOW,\x2010\x20orders\x20gets\x205\x20WOW,\x2030\x20orders\x20gets\x2020\x20WOW,\x20incentivizing\x20continued\x20spending.','relevantGuardOps':['query','repository_read']},{'type':'flash_sale','name':'Limited-time\x20flash\x20sale','description':'Provides\x20discounts\x20or\x20extra\x20rewards\x20within\x20a\x20limited\x20time\x20window,\x20creating\x20urgency\x20to\x20drive\x20instant\x20conversion.','guardCondition':'Guard\x20verifies:\x20current\x20block\x20time\x20is\x20within\x20[start_time,\x20end_time]\x20range\x20(Guard\x20time\x20condition)','amountRange':{'min':'0.1WOW','max':'20WOW'},'allocationStrategy':'fixed','parameters':[{'name':'start_time','type':'string','description':'Start\x20time\x20(Unix\x20timestamp)','required':!![]},{'name':'end_time','type':'string','description':'End\x20time\x20(Unix\x20timestamp)','required':!![]},{'name':'amount','type':'string','description':'Flash\x20sale\x20reward\x20amount','required':!![]},{'name':'max_claims','type':'number','description':'Max\x20claims\x20(e.g.,\x20100)','required':!![]}],'example':'Weekend\x2048-hour\x20flash\x20sale:\x20ordering\x20customers\x20get\x20an\x20extra\x202\x20WOW\x20cashback,\x20valid\x20for\x20the\x20first\x20100.','relevantGuardOps':['query','time_condition']},{'type':'cashback','name':'Spending\x20cashback','description':'Customers\x20receive\x20cashback\x20proportional\x20to\x20spending\x20after\x20completing\x20an\x20order,\x20improving\x20repeat\x20purchase\x20willingness.','guardCondition':'Guard\x20verifies:\x20order\x20has\x20reached\x20terminal\x20state\x20(Progress\x20completed),\x20and\x20order.service\x20==\x20this\x20Service','amountRange':{'min':'0.1WOW','max':'100WOW'},'allocationStrategy':'proportional','parameters':[{'name':'cashback_rate','type':'string','description':'Cashback\x20rate\x20(e.g.,\x20\x270.1\x27\x20=\x2010%)','required':!![]},{'name':'max_cashback','type':'string','description':'Max\x20cashback\x20per\x20order\x20(e.g.,\x20\x2710WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27500WOW\x27)','required':!![]}],'example':'A\x20customer\x20spends\x2010\x20WOW,\x20gets\x2010%\x20cashback\x20=\x201\x20WOW,\x20which\x20can\x20be\x20deducted\x20on\x20the\x20next\x20purchase.','relevantGuardOps':['query']},{'type':'milestone','name':'Milestone\x20reward','description':'When\x20a\x20Service\x20reaches\x20a\x20specific\x20milestone\x20(e.g.,\x20100\x20orders,\x201000\x20customers),\x20early\x20supporters\x20receive\x20extra\x20rewards.','guardCondition':'Guard\x20verifies:\x20Repository\x20query\x20shows\x20Service\x20cumulative\x20order\x20count\x20>=\x20milestone_threshold,\x20and\x20claimer\x20is\x20an\x20early\x20customer\x20(order_index\x20<\x20milestone)','amountRange':{'min':'1WOW','max':'100WOW'},'allocationStrategy':'fixed','parameters':[{'name':'milestone','type':'number','description':'Milestone\x20value\x20(e.g.,\x20100)','required':!![]},{'name':'reward_per_user','type':'string','description':'Reward\x20per\x20person\x20(e.g.,\x20\x275WOW\x27)','required':!![]},{'name':'max_recipients','type':'number','description':'Max\x20beneficiaries\x20(e.g.,\x2050)','required':!![]}],'example':'Service\x20reaches\x20the\x20100-order\x20milestone;\x20the\x20first\x2050\x20customers\x20each\x20receive\x205\x20WOW\x20extra\x20reward.','relevantGuardOps':['query','repository_read']},{'type':'wonder_praise','name':'Wonder-node\x20praise\x20reward\x20(post-completion\x20positive\x20feedback)','description':'Rewards\x20customers\x20who\x20advance\x20their\x20order\x20Progress\x20to\x20the\x20\x27wonder\x27\x20node\x20after\x20normal\x20completion\x20—\x20'+'a\x20user-driven\x20positive-feedback\x20mechanism.\x20The\x20machine\x20design\x20pattern\x20is:\x20'+'place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'After\x20the\x20order\x20reaches\x20\x27completed\x27\x20(terminal\x20business\x20state),\x20the\x20OrderHolder\x20'+'(namedOperator=\x27\x27)\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20'+'(negative\x20review).\x20The\x20Reward\x27s\x20claim_guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27\x20'+'AND\x20order.service\x20==\x20this\x20Service,\x20so\x20only\x20satisfied\x20customers\x20can\x20claim.\x20'+'This\x20creates\x20an\x20on-chain\x20reputation\x20signal\x20that\x20benefits\x20both\x20the\x20merchant\x20'+'(public\x20proof\x20of\x20quality)\x20and\x20the\x20customer\x20(monetary\x20reward\x20for\x20honest\x20feedback).','guardCondition':'Guard\x20verifies:\x20(1)\x20Progress.current\x20==\x20\x27wonder\x27\x20(customer\x20advanced\x20to\x20praise\x20node),\x20'+'(2)\x20Progress.task\x20==\x20order_address\x20AND\x20order.service\x20==\x20this\x20Service,\x20'+'(3)\x20Progress.machine\x20==\x20service.machine\x20(snapshot\x20match),\x20'+'(4)\x20claimer\x20is\x20the\x20order\x20owner\x20(order.owner\x20==\x20signer).\x20'+'Recommended\x20Guard\x20ops:\x20query\x20Progress\x20object,\x20query\x20Order\x20object,\x20'+'verify\x20Progress.current\x20field\x20equals\x20\x27wonder\x27.','amountRange':{'min':'0.1WOW','max':'20WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20per\x20praise\x20(e.g.,\x20\x271WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27500WOW\x27)','required':!![]},{'name':'expiration_time','type':'number','description':'Claim\x20expiration\x20timestamp\x20(ms);\x200\x20=\x20no\x20expiration','required':![]},{'name':'max_claims_per_user','type':'number','description':'Max\x20claims\x20per\x20user\x20(default\x201,\x20prevents\x20duplicate\x20praise\x20rewards)','required':![]}],'example':'A\x20photography\x20service\x20machine:\x20place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20wonder.\x20'+'After\x20delivery,\x20the\x20customer\x20advances\x20Progress\x20to\x20\x27wonder\x27\x20if\x20satisfied.\x20'+'The\x20Reward\x27s\x20Guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27,\x20and\x20the\x20customer\x20claims\x201\x20WOW.\x20'+'Merchant\x20benefits\x20from\x20on-chain\x20proof\x20of\x20customer\x20satisfaction.','relevantGuardOps':['query','progress_node_check']},{'type':'wonder_feedback','name':'Wonder-node\x20feedback\x20collection\x20(covers\x20wonder\x20&\x20no_wonder)','description':'A\x20feedback-collection\x20Reward\x20that\x20pays\x20a\x20small\x20amount\x20for\x20EITHER\x20positive\x20(wonder)\x20OR\x20'+'negative\x20(no_wonder)\x20feedback,\x20encouraging\x20customers\x20to\x20leave\x20honest\x20reviews.\x20'+'The\x20machine\x20design\x20pattern\x20is\x20the\x20same\x20as\x20wonder_praise:\x20'+'place_order\x20→\x20booked\x20→\x20in_progress\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'The\x20Reward\x27s\x20claim_guard\x20verifies\x20Progress.current\x20∈\x20{\x27wonder\x27,\x20\x27no_wonder\x27}\x20—\x20both\x20nodes\x20'+'trigger\x20the\x20reward.\x20This\x20is\x20useful\x20for\x20merchants\x20who\x20want\x20to\x20gather\x20feedback\x20signal\x20'+'regardless\x20of\x20sentiment,\x20e.g.,\x20for\x20product\x20improvement\x20or\x20public\x20reputation\x20metrics.\x20'+'Pair\x20with\x20a\x20Repository\x20that\x20records\x20the\x20feedback\x20node\x20for\x20historical\x20analysis.','guardCondition':'Guard\x20verifies:\x20(1)\x20Progress.current\x20∈\x20{\x27wonder\x27,\x20\x27no_wonder\x27},\x20'+'(2)\x20Progress.task\x20==\x20order_address\x20AND\x20order.service\x20==\x20this\x20Service,\x20'+'(3)\x20claimer\x20is\x20the\x20order\x20holder.\x20'+'The\x20Guard\x20should\x20query\x20the\x20Progress\x20object\x20and\x20check\x20that\x20current\x20node\x20is\x20one\x20of\x20the\x20'+'two\x20feedback\x20nodes.\x20Optional:\x20write\x20the\x20feedback\x20node\x20to\x20a\x20Repository\x20for\x20analytics.','amountRange':{'min':'0.05WOW','max':'5WOW'},'allocationStrategy':'fixed','parameters':[{'name':'amount','type':'string','description':'Reward\x20amount\x20per\x20feedback\x20(e.g.,\x20\x270.5WOW\x27)','required':!![]},{'name':'budget','type':'string','description':'Total\x20budget\x20(e.g.,\x20\x27200WOW\x27)','required':!![]},{'name':'feedback_nodes','type':'string','description':'Comma-separated\x20list\x20of\x20feedback\x20node\x20names\x20(default:\x20\x27wonder,no_wonder\x27)','required':![]},{'name':'expiration_time','type':'number','description':'Claim\x20expiration\x20timestamp\x20(ms);\x200\x20=\x20no\x20expiration','required':![]}],'example':'A\x20freelance\x20design\x20service:\x20place_order\x20→\x20...\x20→\x20completed\x20→\x20(wonder\x20|\x20no_wonder).\x20'+'Customer\x20advances\x20to\x20\x27wonder\x27\x20(liked\x20the\x20work)\x20or\x20\x27no_wonder\x27\x20(didn\x27t\x20like\x20it).\x20'+'Both\x20trigger\x20a\x200.5\x20WOW\x20feedback\x20reward.\x20Merchant\x20tracks\x20the\x20wonder/no_wonder\x20ratio\x20'+'in\x20a\x20Repository\x20to\x20identify\x20quality\x20issues\x20and\x20improve\x20service.','relevantGuardOps':['query','progress_node_check','repository_write']}];const TEMPLATE_INDEX=new Map(REWARD_TEMPLATES['map'](a=>[a['type'],a]));export function getRewardTemplate(a){return TEMPLATE_INDEX['get'](a);}export function listRewardTemplates(){return REWARD_TEMPLATES;}export function suggestRewardTemplate(a){const b=a['toLowerCase']();if(b['includes']('wonder')||b['includes']('praise')||b['includes']('thumbs_up')||b['includes']('praise')||b['includes']('positive\x20review')||b['includes']('satisfaction\x20reward'))return getRewardTemplate('wonder_praise');if(b['includes']('feedback')||b['includes']('review\x20collection')||b['includes']('no_wonder')||b['includes']('thumbs_down')||b['includes']('complaint')||b['includes']('both\x20sentiment'))return getRewardTemplate('wonder_feedback');if(b['includes']('first\x20order')||b['includes']('new')||b['includes']('first'))return getRewardTemplate('first_order');if(b['includes']('referral')||b['includes']('viral'))return getRewardTemplate('referral');if(b['includes']('repeat')||b['includes']('loyalty'))return getRewardTemplate('loyalty');if(b['includes']('limited-time')||b['includes']('flash'))return getRewardTemplate('flash_sale');if(b['includes']('cashback'))return getRewardTemplate('cashback');if(b['includes']('milestone'))return getRewardTemplate('milestone');return undefined;}export const REWARD_TEMPLATES_VERSION=0x1;
@@ -30,8 +30,6 @@ export declare const DEFAULT_VALUE_WARNINGS: {
30
30
  };
31
31
  export declare const DEFAULT_AMOUNT_THRESHOLD: bigint;
32
32
  export declare function getAmountThreshold(): bigint;
33
- export declare const DEFAULT_FUND_COVERAGE_MIN = 1;
34
- export declare function getFundCoverageMin(): number;
35
33
  export declare function formatAmount(value: string | bigint): string;
36
34
  export declare function collectDefaultWarnings(env: any, data: any): string[];
37
35
  export declare const BRIDGE_FUND_OPERATION_TYPES: readonly string[];