@wowok/agent-mcp 3.3.2 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +5 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +27 -3
- package/dist/composition/inflight.js +1 -1
- package/dist/config/judgment.d.ts +111 -1
- package/dist/config/judgment.js +1 -1
- package/dist/evaluation/arbitration-game.d.ts +4 -0
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/builtins/graph-service.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/game-strategy.d.ts +6 -0
- package/dist/evaluation/game-strategy.js +1 -1
- package/dist/evaluation/node-game.d.ts +7 -0
- package/dist/evaluation/node-game.js +1 -1
- package/dist/evaluation/value-risk.d.ts +8 -0
- package/dist/evaluation/value-risk.js +1 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facet-projection.js +1 -1
- package/dist/graph/onchain/facet-projection.spec.js +1 -1
- package/dist/graph/onchain/facts.d.ts +20 -0
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/facts.spec.js +1 -1
- package/dist/graph/onchain/object-held-receipts.d.ts +20 -0
- package/dist/graph/onchain/object-held-receipts.js +1 -0
- package/dist/graph/onchain/object-held-receipts.spec.d.ts +1 -0
- package/dist/graph/onchain/object-held-receipts.spec.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +1 -0
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/recover.d.ts +2 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +0 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +7 -0
- package/dist/knowledge/arb-fund-facts.js +1 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/judgment-baselines.json +502 -81
- package/dist/knowledge/baselines/rules/allocation.json +0 -14
- package/dist/knowledge/baselines/rules/graph.json +4 -4
- package/dist/knowledge/baselines/rules/plan.json +33 -3
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/game-scenarios.d.ts +21 -0
- package/dist/knowledge/game-scenarios.js +1 -0
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.js +1 -1
- package/dist/knowledge/guard-leg-map.d.ts +5 -0
- package/dist/knowledge/guard-leg-map.js +1 -0
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +4 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/order-ledger.d.ts +1 -1
- package/dist/knowledge/order-ledger.js +1 -1
- package/dist/knowledge/order-puzzle.d.ts +3 -0
- package/dist/knowledge/order-risk.d.ts +1 -1
- package/dist/knowledge/passport-ledger.d.ts +12 -0
- package/dist/knowledge/passport-ledger.js +1 -1
- package/dist/knowledge/payment-tracker.js +1 -1
- package/dist/knowledge/protocol-facts.d.ts +1 -0
- package/dist/knowledge/protocol-facts.js +1 -1
- package/dist/knowledge/recipient-constraint.d.ts +9 -0
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/repository-write-semantics.d.ts +1 -1
- package/dist/knowledge/repository-write-semantics.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +1 -0
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +14 -0
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +1 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +4 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +2 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/allocation-advice.d.ts +8 -1
- package/dist/participation/allocation-advice.js +1 -1
- package/dist/participation/game-context.d.ts +25 -0
- package/dist/participation/game-context.js +1 -0
- package/dist/participation/node-action-advisor.d.ts +64 -0
- package/dist/participation/node-action-advisor.js +1 -0
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +1 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +2 -2
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +13 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +8 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review/repository.js +1 -1
- package/dist/role/intent.d.ts +23 -0
- package/dist/role/intent.js +1 -0
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +4 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +3 -0
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +77 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +4 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +10 -0
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +14 -0
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/repository.d.ts +4 -0
- package/dist/schema/call/semantic.d.ts +6 -0
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +34 -0
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/keeper/index.d.ts +2 -0
- package/dist/schema/local/index.d.ts +43 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +2 -0
- package/dist/schema/operations.d.ts +30 -0
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +484 -0
- package/dist/schema/query/bi.d.ts +6 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +207 -48
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +15 -8
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/benchmark_migration_operation.output.json +8 -5
- package/dist/schemas/benchmark_migration_operation.schema.json +5 -4
- package/dist/schemas/bridge_operation.output.json +15 -8
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/keeper_operation.output.json +13 -8
- package/dist/schemas/local_cache_operation.output.json +36 -8
- package/dist/schemas/local_cache_operation.schema.json +16 -1
- package/dist/schemas/local_history_operation.output.json +15 -8
- package/dist/schemas/local_info_operation.output.json +15 -8
- package/dist/schemas/local_info_operation.schema.json +5 -1
- package/dist/schemas/local_mark_operation.output.json +15 -8
- package/dist/schemas/messenger_operation.output.json +13 -8
- package/dist/schemas/monitor_events.output.json +13 -8
- package/dist/schemas/monitor_subscription.output.json +13 -8
- package/dist/schemas/onchain_events.output.json +68 -19
- package/dist/schemas/onchain_events.schema.json +4 -0
- package/dist/schemas/onchain_operations.output.json +116 -28
- package/dist/schemas/onchain_operations.schema.json +246 -113
- package/dist/schemas/onchain_operations_allocation.schema.json +9 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +1 -1
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +99 -63
- package/dist/schemas/onchain_operations_machine.schema.json +10 -1
- package/dist/schemas/onchain_operations_order.schema.json +25 -3
- package/dist/schemas/onchain_operations_progress.schema.json +4 -4
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +5 -1
- package/dist/schemas/onchain_operations_reward.schema.json +4 -4
- package/dist/schemas/onchain_operations_service.schema.json +74 -16
- package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
- package/dist/schemas/onchain_table_data.output.json +18 -9
- package/dist/schemas/persona_operation.output.json +1387 -0
- package/dist/schemas/persona_operation.schema.json +219 -0
- package/dist/schemas/query_toolkit.output.json +113 -60
- package/dist/schemas/query_toolkit.schema.json +9 -1
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/schemas/wowok_buildin_info.output.json +259 -0
- package/dist/schemas/wowok_buildin_info.schema.json +121 -0
- package/dist/tools/build-fingerprint.d.ts +28 -0
- package/dist/tools/build-fingerprint.js +1 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain-name-registration.d.ts +11 -0
- package/dist/tools/handlers/onchain-name-registration.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +10 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +9 -13
- package/dist/tools/handlers/review-chain.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/upgrade-check.d.ts +1 -0
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{query_transaction}from'@wowok/wowok';import{batchQueryObjectsByIds}from'./sdk-batch.js';import{extractCoinType}from'./extract.js';const MAX_SCANNED_PAYMENTS=0x5,WRAPPER_TYPE_MARK='::payment::CoinWrapper<';function pickData(a){return a?.['data']??a??undefined;}function addrOf(a){return String(a?.['object']??a?.['data']?.['object']??'')['toLowerCase']();}function isOwnedByObject(a,b){if(!a||typeof a!=='object')return![];const c=a['ObjectOwner']??(a['$kind']==='ObjectOwner'?a['ObjectOwner']:undefined);return String(c??'')['toLowerCase']()===b;}function amountOf(a){const b=a?.['balance']?.['fields']?.['value']??a?.['content_raw']?.['fields']?.['balance']?.['fields']?.['value']??a?.['balance']?.['value']??a?.['content_raw']?.['fields']?.['balance'];return b==null?'0':String(b);}function paymentOf(a){const b=a?.['payment']??a?.['content_raw']?.['fields']?.['payment']??a?.['content_raw']?.['payment'];return String(b??'')['toLowerCase']();}function typeRawOf(a){return typeof a?.['type_raw']==='string'?a['type_raw']:typeof a?.['content_raw']?.['type']==='string'?a['content_raw']['type']:undefined;}export async function recoverObjectHeldReceipts(a,b){const c=String(a??'')['toLowerCase']();if(!c)return undefined;try{const d=await batchQueryObjectsByIds([c],b['network'],b['no_cache']),e=d['find'](s=>addrOf(s)===c)??d[0x0];if(!e)return undefined;const f=addrOf(e);if(!f)return undefined;const g=String(pickData(e)?.['allocation']??'')['toLowerCase']();if(!g)return undefined;const h=await batchQueryObjectsByIds([g],b['network'],b['no_cache']),i=h['find'](s=>addrOf(s)===g)??h[0x0],j=pickData(i)?.['payment'],k=Array['isArray'](j)?[...new Set(j['map'](s=>String(s??'')['toLowerCase']())['filter'](Boolean))]['slice'](-MAX_SCANNED_PAYMENTS):[];if(k['length']===0x0)return{'holder':f,'allocation':g,'payments_scanned':0x0,'receipts':[],'token_type':''};const l=await batchQueryObjectsByIds(k,b['network'],b['no_cache']),m=new Set(k),n=new Map();let o=0x0;for(const s of l){const t=String(s?.['previousTransaction']??'')['trim']();if(!t)continue;o++;try{const u=await query_transaction({'digest':t,'network':b['network'],'no_cache':b['no_cache']});for(const v of u?.['object_changes']??[]){if(v['type']!=='created')continue;const w=String(v['object_type']??'');if(!w['includes'](WRAPPER_TYPE_MARK))continue;const x=String(v['id']??'')['toLowerCase']();if(!x)continue;n['set'](x,{'version':v['version']!=null?String(v['version']):undefined,'digest':v['digest']!=null?String(v['digest']):undefined,'object_type':w});}}catch{}}if(n['size']===0x0)return{'holder':f,'allocation':g,'payments_scanned':o,'receipts':[],'token_type':''};const p=await batchQueryObjectsByIds([...n['keys']()],b['network'],b['no_cache']),q=[];let r='';for(const y of p){const z=addrOf(y);if(!z)continue;const A=n['get'](z);if(!A)continue;const B=typeRawOf(y)??A['object_type'];if(!B||!B['includes'](WRAPPER_TYPE_MARK))continue;const C=paymentOf(y);if(!m['has'](C))continue;if(!isOwnedByObject(y?.['owner'],f))continue;const D=String(y?.['version']??'');if(D&&A['version']&&D!==A['version'])continue;q['push']({'id':z,'payment':C,'amount':amountOf(y),'version':A['version']??(D||undefined),'digest':A['digest'],'type':B});if(!r)r=extractCoinType(B)??'';}return{'holder':f,'allocation':g,'payments_scanned':o,'receipts':q,'token_type':r};}catch{return undefined;}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describe,it,expect,vi,beforeEach}from'vitest';const {queryTransactionMock}=vi['hoisted'](()=>({'queryTransactionMock':vi['fn']()}));vi['mock']('./sdk-batch.js',()=>({'batchQueryObjectsByIds':vi['fn']()})),vi['mock']('@wowok/wowok',async a=>{const b=await a();return{...b,'query_transaction':queryTransactionMock};});import{batchQueryObjectsByIds}from'./sdk-batch.js';import{recoverObjectHeldReceipts}from'./object-held-receipts.js';const mockObjects=vi['mocked'](batchQueryObjectsByIds),ORDER='0xorder',ALLOC='0xalloc',PAY='0xpay',PAY_OTHER='0xpayother',WRAPPER='0xwrapper',WRAPPER_USER='0xwrapperuser',TX='0xtxd',WRAPPER_TYPE='0xpk::payment::CoinWrapper<0x2::wow::WOW>';function orderObj(){return{'object':ORDER,'type':'Order','allocation':ALLOC};}function allocObj(a=[PAY]){return{'object':ALLOC,'type':'Allocation','payment':a};}function payObj(a,b){return{'object':a,'type':'Payment','previousTransaction':b};}function wrapperObj(a,b={}){return{'object':a,'type_raw':WRAPPER_TYPE,'owner':{'ObjectOwner':ORDER},'version':'3','payment':PAY,'balance':{'type':'0x2::balance::Balance<0x2::wow::WOW>','fields':{'value':'500'}},...b};}function routeObjects(a){mockObjects['mockImplementation'](async b=>b['map'](c=>a[c])['filter'](c=>c!==undefined));}beforeEach(()=>{mockObjects['mockReset'](),queryTransactionMock['mockReset']();}),describe('recoverObjectHeldReceipts',()=>{it('recovers\x20the\x20wrapper\x20triples\x20from\x20the\x20allocation\x20transaction\x20effects',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX),[WRAPPER]:wrapperObj(WRAPPER)}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'DIGEST3'},{'id':'0xprogress','type':'created','object_type':'0xpk::order::Progress'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{'network':'testnet'});expect(a)['toBeDefined'](),expect(a['holder'])['toBe'](ORDER),expect(a['allocation'])['toBe'](ALLOC),expect(a['payments_scanned'])['toBe'](0x1),expect(a['token_type'])['toBe']('0x2::wow::WOW'),expect(a['receipts'])['toEqual']([{'id':WRAPPER,'payment':PAY,'amount':'500','version':'3','digest':'DIGEST3','type':WRAPPER_TYPE}]);}),it('drops\x20wrappers\x20owned\x20by\x20a\x20user\x20or\x20pointing\x20at\x20another\x20Payment',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj([PAY,PAY_OTHER]),[PAY]:payObj(PAY,TX),[PAY_OTHER]:payObj(PAY_OTHER,TX),[WRAPPER]:wrapperObj(WRAPPER),[WRAPPER_USER]:wrapperObj(WRAPPER_USER,{'owner':{'AddressOwner':'0xuser'}}),'0xwrapperother':wrapperObj('0xwrapperother',{'payment':'0xstranger'})}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D1'},{'id':WRAPPER_USER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D2'},{'id':'0xwrapperother','type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D3'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a['receipts']['map'](b=>b['id']))['toEqual']([WRAPPER]);}),it('excludes\x20a\x20wrapper\x20that\x20was\x20already\x20collected\x20(no\x20longer\x20resolves)',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX)}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D1'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['receipts'])['toEqual']([]);}),it('returns\x20undefined\x20when\x20the\x20holder\x20is\x20not\x20an\x20escrow\x20object',async()=>{routeObjects({'0xuser':{'object':'0xuser','type':'Order'}});const a=await recoverObjectHeldReceipts('0xuser',{});expect(a)['toBeUndefined']();}),it('skips\x20a\x20Payment\x20with\x20no\x20previousTransaction\x20and\x20reports\x20zero\x20scanned',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,undefined)});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['payments_scanned'])['toBe'](0x0),expect(a['receipts'])['toEqual']([]),expect(queryTransactionMock)['not']['toHaveBeenCalled']();}),it('fails\x20soft\x20when\x20the\x20transaction\x20read\x20throws',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX)}),queryTransactionMock['mockRejectedValue'](new Error('index\x20window\x20miss'));const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['payments_scanned'])['toBe'](0x1),expect(a['receipts'])['toEqual']([]);});});
|
|
@@ -17,6 +17,7 @@ export interface ParsedMachineNode {
|
|
|
17
17
|
export declare const QUERY_OBJECTS_BATCH = 50;
|
|
18
18
|
export declare function lastUnresolvedInputs(network?: string, noCache?: boolean): string[];
|
|
19
19
|
export declare function batchQueryObjectsByIds(ids: string[], network?: string, noCache?: boolean): Promise<any[]>;
|
|
20
|
+
export declare function batchQueryObjectsByRef(ids: string[], network?: string, noCache?: boolean): Promise<Map<string, any>>;
|
|
20
21
|
export interface TableFieldEntry {
|
|
21
22
|
key: string;
|
|
22
23
|
objectId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ObjectType,objectTypeFromAddress}from'@wowok/wowok';import{MAX_OBJECTS_PER_QUERY}from'./dataplane.js';import{SdkDataPlane}from'./sdk-dataplane.js';export const QUERY_OBJECTS_BATCH=MAX_OBJECTS_PER_QUERY;const planes=new Map();function batchPlane(a,b){const c=(a??'')+'|'+(b?0x1:0x0);let d=planes['get'](c);return!d&&(d=new SdkDataPlane(a??undefined,{'noCache':b}),planes['set'](c,d)),d;}export function lastUnresolvedInputs(a,b){return batchPlane(a,b)['unresolvedInputs'];}function parentToken(a){return String(a)['toLowerCase']();}export async function batchQueryObjectsByIds(a,b,c){const d=await batchPlane(b,c)['getObjects'](a);return[...d['values']()];}export async function fetchTableEntries(a,b){const {items:c,truncated:d}=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit'],'fetchValues':![]});return{'entries':c['map'](f=>({'key':f['key'],'objectId':f['objectId']})),'truncated':d};}export async function fetchAllFieldObjectIds(a,b,c){const {entries:d}=await fetchTableEntries(a,{'network':b,'noCache':c});return d['map'](f=>f['objectId']);}export async function batchQueryTableItems(a,b){const c=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit']});return{'items':c['items'],'truncated':c['truncated']};}export async function fetchMachineNodes(a,b,c){const d=await batchQueryObjectsByIds([a],b,c),e=d[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const {items:g}=await batchQueryTableItems(f,{'network':b,'noCache':c});return g['map'](h=>h['object'])['filter'](h=>h?.['type']==='TableItem_MachineNode')['map'](h=>{const i=h?.['data']??h,j=typeof i?.['name']==='string'?i['name']:'',k=Array['isArray'](i?.['value'])?i['value']:Array['isArray'](i?.['pairs'])?i['pairs']:[];if(!j)return null;return{'name':j,'pairs':k['map'](l=>({'prev_node':String(l?.['prev_node']??''),'threshold':Number(l?.['threshold']??0x0),'forwards':Array['isArray'](l?.['forwards'])?l['forwards']['map'](m=>{const n=typeof m?.['guard']==='object'&&m?.['guard']!==null?m['guard']['guard']??undefined:typeof m?.['guard']==='string'?m['guard']:undefined;return{'name':String(m?.['name']??''),'weight':Number(m?.['weight']??0x0),'namedOperator':m?.['namedOperator']!==undefined&&m?.['namedOperator']!==null?String(m['namedOperator']):undefined,'permissionIndex':m?.['permissionIndex']!==undefined&&m?.['permissionIndex']!==null?Number(m['permissionIndex']):undefined,'guard':n};}):[]}))};})['filter'](h=>h!==null);}export async function batchReadAddressKeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e);}export async function batchReadKeyedItems(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'strict':!![]});}export async function batchReadU64KeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f))['filter'](f=>f!==''&&Number['isFinite'](Number(f))))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'keyType':'u64'});}export const ENTITY_REGISTRAR_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aab';export const ENTITY_LINKER_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aaa';export async function batchFetchEntityRegistrar(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_REGISTRAR_OBJECT_ID,a,b,c);}catch{return new Map();}}export async function batchFetchEntityLinker(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_LINKER_OBJECT_ID,a,b,c);}catch{return new Map();}}export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_PERMISSION_ROLES={'OWNER':0x1,'ADMIN':0x2,'ENTITY':0x4};export async function batchFetchEntityPermission(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_PERMISSION_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byPermission':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['permission']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'permission':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byPermission':m});}return f;}export async function fetchEntityPermission(a,b,c){try{const d=await batchFetchEntityPermission([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export async function batchFetchEntityContact(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_CONTACT_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byContact':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=String(n?.['contact']??'')['toLowerCase'](),p=Number(n?.['time']??0x0);o&&(l['push']({'contact':o,'time':p}),m['set'](o,(m['get'](o)??0x0)||p));}f['set'](i,{'items':l,'byContact':m});}return f;}export async function fetchEntityContact(a,b,c){try{const d=await batchFetchEntityContact([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_ORDER_OBJECT_ID='0xaa8';export const ENTITY_ORDER_ROLES={'OWNER':0x1,'AGENT':0x2};export async function batchFetchEntityOrder(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_ORDER_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byOrder':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['order']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'order':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byOrder':m});}return f;}export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';export const LINKER_RING_LIMIT=0x1450;export function ringWindowSaturated(a){return a>=LINKER_RING_LIMIT;}export async function batchFetchObjectLinker(b,c,e,f){const g=new Map(),h=await batchReadKeyedItems(b,c,e,f);for(const i of new Set((c??[])['map'](j=>String(j)['toLowerCase']()))){g['set'](i,{'items':[],'byWho':new Map()});}for(const [j,k]of h){const l=k,m=[],n=new Map();for(const o of Array['isArray'](l?.['items'])?l['items']:[]){const p=String(o?.['who']??'')['toLowerCase'](),q=Number(o?.['time']??0x0);p&&(m['push']({'who':p,'time':q}),n['set'](p,q));}g['set'](j,{'items':m,'byWho':n});}return g;}export function batchFetchObjectLinkerCore(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function batchFetchObjectLinkerTx(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}async function fetchObjectLinker(a,b,c,d){try{const e=await batchFetchObjectLinker(a,[b],c,d);return e['get'](String(b)['toLowerCase']());}catch{return undefined;}}export function fetchObjectLinkerCore(a,b,c){return fetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function fetchObjectLinkerTx(a,b,c){return fetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}export async function fetchServiceOrders(a,b,c){const d=await fetchObjectLinkerTx(a,b,c);if(!d)return undefined;const e=ringWindowSaturated(d['items']['length']),f=d['items']['filter'](g=>objectTypeFromAddress(g['who'])===ObjectType['Order']);return{'items':f,'byWho':new Map(f['map'](g=>[g['who'],g['time']])),'ring_saturated':e};}export async function fetchPermissionContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0],g=f?.['data']??f,h=new Set((g?.['admin']??[])['map'](k=>String(k)['toLowerCase']())),i=new Map(),{items:j}=await batchQueryTableItems(a,{'network':b,'noCache':c});for(const k of j){const l=k['object'],m=l?.['data']??l;m?.['address']!=null&&Array['isArray'](m['perm'])&&i['set'](String(m['address'])['toLowerCase'](),new Set(m['perm']['map'](n=>Number(n))));}return{'admin':h,'table':i};}catch{return undefined;}}export async function fetchOrderContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0];if(f?.['type']!=='Order'&&f?.['data']?.['type']!=='Order')return undefined;const g=f?.['data']??f;return{'builder':String(g['builder']??g['owner']??''),'agent':new Set((g['agent']??[])['map'](h=>String(h)['toLowerCase']()))};}catch{return undefined;}}
|
|
1
|
+
import{ObjectType,objectTypeFromAddress,LocalMark}from'@wowok/wowok';import{MAX_OBJECTS_PER_QUERY}from'./dataplane.js';import{SdkDataPlane}from'./sdk-dataplane.js';export const QUERY_OBJECTS_BATCH=MAX_OBJECTS_PER_QUERY;const planes=new Map();function batchPlane(a,b){const c=(a??'')+'|'+(b?0x1:0x0);let d=planes['get'](c);return!d&&(d=new SdkDataPlane(a??undefined,{'noCache':b}),planes['set'](c,d)),d;}export function lastUnresolvedInputs(a,b){return batchPlane(a,b)['unresolvedInputs'];}function parentToken(a){return String(a)['toLowerCase']();}export async function batchQueryObjectsByIds(a,b,c){const d=await batchPlane(b,c)['getObjects'](a);return[...d['values']()];}export async function batchQueryObjectsByRef(a,b,c){const d=a['map'](h=>String(h)['toLowerCase']());let e=d['map'](()=>null);try{e=await LocalMark['Instance']()['get_many_address'](d);}catch{}const f=await batchQueryObjectsByIds(d,b,c),g=new Map();for(const h of f){const j=String(h?.['object']??'')['toLowerCase']();if(j==='')continue;for(let k=0x0;k<d['length'];k++){if(g['has'](d[k]))continue;const l=e[k]?String(e[k])['toLowerCase']():'';if(d[k]===j||l===j)g['set'](d[k],h);}}return g;}export async function fetchTableEntries(a,b){const {items:c,truncated:d}=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit'],'fetchValues':![]});return{'entries':c['map'](f=>({'key':f['key'],'objectId':f['objectId']})),'truncated':d};}export async function fetchAllFieldObjectIds(a,b,c){const {entries:d}=await fetchTableEntries(a,{'network':b,'noCache':c});return d['map'](f=>f['objectId']);}export async function batchQueryTableItems(a,b){const c=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit']});return{'items':c['items'],'truncated':c['truncated']};}export async function fetchMachineNodes(a,b,c){const d=await batchQueryObjectsByIds([a],b,c),e=d[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const {items:g}=await batchQueryTableItems(f,{'network':b,'noCache':c});return g['map'](h=>h['object'])['filter'](h=>h?.['type']==='TableItem_MachineNode')['map'](h=>{const i=h?.['data']??h,j=typeof i?.['name']==='string'?i['name']:'',k=Array['isArray'](i?.['value'])?i['value']:Array['isArray'](i?.['pairs'])?i['pairs']:[];if(!j)return null;return{'name':j,'pairs':k['map'](l=>({'prev_node':String(l?.['prev_node']??''),'threshold':Number(l?.['threshold']??0x0),'forwards':Array['isArray'](l?.['forwards'])?l['forwards']['map'](m=>{const n=typeof m?.['guard']==='object'&&m?.['guard']!==null?m['guard']['guard']??undefined:typeof m?.['guard']==='string'?m['guard']:undefined;return{'name':String(m?.['name']??''),'weight':Number(m?.['weight']??0x0),'namedOperator':m?.['namedOperator']!==undefined&&m?.['namedOperator']!==null?String(m['namedOperator']):undefined,'permissionIndex':m?.['permissionIndex']!==undefined&&m?.['permissionIndex']!==null?Number(m['permissionIndex']):undefined,'guard':n};}):[]}))};})['filter'](h=>h!==null);}export async function batchReadAddressKeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e);}export async function batchReadKeyedItems(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'strict':!![]});}export async function batchReadU64KeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f))['filter'](f=>f!==''&&Number['isFinite'](Number(f))))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'keyType':'u64'});}export const ENTITY_REGISTRAR_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aab';export const ENTITY_LINKER_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aaa';export async function batchFetchEntityRegistrar(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_REGISTRAR_OBJECT_ID,a,b,c);}catch{return new Map();}}export async function batchFetchEntityLinker(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_LINKER_OBJECT_ID,a,b,c);}catch{return new Map();}}export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_PERMISSION_ROLES={'OWNER':0x1,'ADMIN':0x2,'ENTITY':0x4};export async function batchFetchEntityPermission(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_PERMISSION_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byPermission':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['permission']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'permission':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byPermission':m});}return f;}export async function fetchEntityPermission(a,b,c){try{const d=await batchFetchEntityPermission([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export async function batchFetchEntityContact(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_CONTACT_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byContact':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=String(n?.['contact']??'')['toLowerCase'](),p=Number(n?.['time']??0x0);o&&(l['push']({'contact':o,'time':p}),m['set'](o,(m['get'](o)??0x0)||p));}f['set'](i,{'items':l,'byContact':m});}return f;}export async function fetchEntityContact(a,b,c){try{const d=await batchFetchEntityContact([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_ORDER_OBJECT_ID='0xaa8';export const ENTITY_ORDER_ROLES={'OWNER':0x1,'AGENT':0x2};export async function batchFetchEntityOrder(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_ORDER_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byOrder':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['order']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'order':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byOrder':m});}return f;}export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';export const LINKER_RING_LIMIT=0x1450;export function ringWindowSaturated(a){return a>=LINKER_RING_LIMIT;}export async function batchFetchObjectLinker(b,c,e,f){const g=new Map(),h=await batchReadKeyedItems(b,c,e,f);for(const i of new Set((c??[])['map'](j=>String(j)['toLowerCase']()))){g['set'](i,{'items':[],'byWho':new Map()});}for(const [j,k]of h){const l=k,m=[],n=new Map();for(const o of Array['isArray'](l?.['items'])?l['items']:[]){const p=String(o?.['who']??'')['toLowerCase'](),q=Number(o?.['time']??0x0);p&&(m['push']({'who':p,'time':q}),n['set'](p,q));}g['set'](j,{'items':m,'byWho':n});}return g;}export function batchFetchObjectLinkerCore(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function batchFetchObjectLinkerTx(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}async function fetchObjectLinker(a,b,c,d){try{const e=await batchFetchObjectLinker(a,[b],c,d);return e['get'](String(b)['toLowerCase']());}catch{return undefined;}}export function fetchObjectLinkerCore(a,b,c){return fetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function fetchObjectLinkerTx(a,b,c){return fetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}export async function fetchServiceOrders(a,b,c){const d=await fetchObjectLinkerTx(a,b,c);if(!d)return undefined;const e=ringWindowSaturated(d['items']['length']),f=d['items']['filter'](g=>objectTypeFromAddress(g['who'])===ObjectType['Order']);return{'items':f,'byWho':new Map(f['map'](g=>[g['who'],g['time']])),'ring_saturated':e};}export async function fetchPermissionContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0],g=f?.['data']??f,h=new Set((g?.['admin']??[])['map'](k=>String(k)['toLowerCase']())),i=new Map(),{items:j}=await batchQueryTableItems(a,{'network':b,'noCache':c});for(const k of j){const l=k['object'],m=l?.['data']??l;m?.['address']!=null&&Array['isArray'](m['perm'])&&i['set'](String(m['address'])['toLowerCase'](),new Set(m['perm']['map'](n=>Number(n))));}return{'admin':h,'table':i};}catch{return undefined;}}export async function fetchOrderContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0];if(f?.['type']!=='Order'&&f?.['data']?.['type']!=='Order')return undefined;const g=f?.['data']??f;return{'builder':String(g['builder']??g['owner']??''),'agent':new Set((g['agent']??[])['map'](h=>String(h)['toLowerCase']()))};}catch{return undefined;}}
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class Harness {
|
|
|
9
9
|
recover(errorCode: string, operationId: string, context?: {
|
|
10
10
|
operation_type?: string;
|
|
11
11
|
data?: Record<string, unknown>;
|
|
12
|
+
retryable?: boolean;
|
|
12
13
|
}): RecoveryAction;
|
|
13
14
|
resetRecovery(operationId: string): void;
|
|
14
15
|
getBackoffDelay(attempt: number): number;
|
|
@@ -10,8 +10,9 @@ export interface RecoveryRule {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const RECOVERY_RULES: Record<string, RecoveryRule>;
|
|
12
12
|
export declare function resetAttempts(operationId: string): void;
|
|
13
|
-
export declare function recover(errorCode: string, operationId: string,
|
|
13
|
+
export declare function recover(errorCode: string, operationId: string, context?: {
|
|
14
14
|
operation_type?: string;
|
|
15
15
|
data?: Record<string, unknown>;
|
|
16
|
+
retryable?: boolean;
|
|
16
17
|
}): RecoveryAction;
|
|
17
18
|
export declare function getBackoffDelay(attempt: number): number;
|
package/dist/harness/recover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'insufficient_gas':{'error_code':'insufficient_gas','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Gas\x20exhausted\x20—\x20the\x20transaction\x20failed\x20deterministically\x20and\x20did\x20NOT\x20commit\x20on-chain\x20(no\x20state\x20changed;\x20commit-state\x20verification\x20is\x20NOT\x20needed).\x201.\x20Raise\x20the\x20gas_budget\x20parameter\x20above\x20the\x20failed\x20transaction\x27s\x20gas_used\x202.\x20If\x20the\x20account\x20balance\x20cannot\x20cover\x20any\x20budget,\x20fund\x20the\x20signing\x20account\x20with\x20gas\x20tokens\x20first\x203.\x20Resubmit\x20as\x20a\x20FRESH\x20call\x20—\x20do\x20NOT\x20replay\x20the\x20same\x20transaction','user_prompt':'The\x20transaction\x20ran\x20out\x20of\x20gas\x20and\x20did\x20not\x20commit\x20on-chain.\x20Increase\x20the\x20gas\x20budget\x20(or\x20fund\x20the\x20account\x20with\x20gas)\x20and\x20submit\x20a\x20fresh\x20transaction\x20—\x20retrying\x20unchanged\x20will\x20fail\x20the\x20same\x20way.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'wip_storage_rejected':{'error_code':'wip_storage_rejected','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx\x20—\x20deterministic\x20client-side\x20fault,\x20retrying\x20unchanged\x20fails\x20identically).\x20400:\x20malformed\x20body\x20or\x20failed\x20WIP\x20validation\x20—\x20re-generate\x20via\x20wip_file\x20type=\x27generate\x27\x20401:\x20re-sign\x20with\x20a\x20fresh\x20nonce\x20inside\x20the\x20timestamp\x20window\x20403:\x20check\x20storage\x20service\x20configuration\x20404:\x20file\x20does\x20not\x20exist\x20—\x20re-upload\x20409:\x20quota\x20—\x20delete\x20old\x20files\x20via\x20wip_file\x20type=\x27list\x27\x20then\x20delete\x20413:\x20compress\x20images\x20(each\x20<=\x202MB,\x20total\x20<=\x2010MB)\x20and\x20regenerate','user_prompt':'The\x20WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx).\x20Fix\x20the\x20specific\x20fault\x20(re-generate/re-sign/re-upload\x20per\x20the\x20status\x20code)\x20and\x20retry\x20—\x20do\x20not\x20retry\x20unchanged.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once\x20—\x20for\x20a\x20FIRST-EVER\x20transaction\x20on\x20a\x20fresh\x20account\x20make\x20that\x20resubmission\x20with\x20env.no_auto_register=true\x20and\x20SAY\x20SO\x20(the\x20SDK\x20silently\x20appends\x20an\x20entity\x20registration\x20to\x20a\x20first\x20business\x20call;\x20if\x20that\x20appended\x20leg\x20was\x20the\x20failing\x20leg\x20the\x20skip\x20lets\x20the\x20call\x20through\x20—\x20ziroom-mn-261013\x20live\x20case;\x20if\x20the\x20resubmission\x20aborts,\x20the\x20envelope\x20now\x20names\x20the\x20abort\x20—\x20re-enable\x20auto\x20registration\x20and\x20retry).\x204.\x20If\x20the\x20reported\x20digest\x20does\x20not\x20resolve\x20or\x20the\x20failure\x20repeats,\x20STOP\x20looping\x20on\x20digest\x20checks\x20and\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20—\x20the\x20simulation\x20surfaces\x20the\x20real\x20failure\x20(exact\x20Move\x20abort)\x20without\x20gas\x20or\x20duplicate\x20risk.\x205.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x206.\x20M-K2\x20replay\x20discipline:\x20a\x20FAILED\x20receipt\x20is\x20final\x20—\x20its\x20digest\x20is\x20consumed\x20and\x20replaying\x20the\x20same\x20bytes\x20returns\x20the\x20same\x20failure\x20forever;\x20fix\x20the\x20cause\x20(usually\x20funding)\x20and\x20build\x20a\x20FRESH\x20transaction.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first\x205.\x20A\x20TIME-window\x20rejection\x20may\x20simply\x20be\x20EARLY:\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20to\x20probe\x20the\x20window\x20for\x20free\x20(guard\x20rejections\x20do\x20NOT\x20consume\x20the\x20total\x20retry\x20budget;\x20only\x20the\x20per-code\x20cap\x20of\x202\x20applies)','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.\x20A\x20time-window\x20rejection\x20may\x20simply\x20be\x20early:\x20probe\x20the\x20window\x20with\x20env.dry_run=true\x20(free\x20—\x20guard\x20rejections\x20do\x20not\x20consume\x20the\x20total\x20retry\x20budget).'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'move_abort_unmapped':{'error_code':'move_abort_unmapped','strategy':'stop','max_attempts':0x1,'automation':'manual','detail':'The\x20chain\x27s\x20business\x20logic\x20aborted\x20and\x20the\x20(module,\x20abort\x20code)\x20pair\x20has\x20no\x20local\x20mapping.\x20Read\x20the\x20module\x20and\x20abort\x20code\x20from\x20move_abort_info\x20/\x20the\x20message\x20(rendered\x20as\x20\x27abort\x20(N)\x27),\x20resolve\x20their\x20meaning\x20from\x20the\x20module\x27s\x20documentation\x20or\x20the\x20wowok-tools\x20Skill,\x20fix\x20the\x20business\x20cause,\x20and\x20issue\x20a\x20NEW\x20call.\x20Do\x20NOT\x20restart\x20the\x20server\x20and\x20do\x20NOT\x20retry\x20the\x20identical\x20call\x20—\x20it\x20aborts\x20deterministically.','user_prompt':'The\x20operation\x20was\x20rejected\x20by\x20the\x20chain\x27s\x20business\x20logic\x20and\x20its\x20abort\x20code\x20is\x20not\x20mapped\x20locally.\x20The\x20module\x20name\x20and\x20abort\x20code\x20in\x20the\x20error\x20are\x20authoritative\x20—\x20review\x20them\x20(and\x20the\x20object\x20state\x20via\x20query_toolkit)\x20before\x20adjusting\x20anything.'},'missing_data':{'error_code':'missing_data','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'A\x20guard\x20rule\x20read\x20a\x20keyed\x20table\x20row\x20that\x20does\x20NOT\x20exist\x20(repository.data\x20/\x20oracle\x20entry)\x20and\x20the\x20verifier\x20surfaced\x20it\x20as\x20a\x20location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20no\x20abort\x20code,\x20because\x20the\x20framework\x20cannot\x20express\x20\x27row\x20absent\x27\x20as\x20an\x20abort.\x20This\x20is\x20a\x20DATA\x20problem:\x201.\x20Identify\x20the\x20repository\x20and\x20key\x20the\x20guard\x20rule\x20reads\x20(guard2file\x20/\x20analyze_guard_semantics\x20on\x20the\x20guard\x20source)\x202.\x20Have\x20the\x20row\x27s\x20producer\x20write\x20it\x20(e.g.\x20an\x20oracle\x20timestamp\x20like\x20checkin_ts),\x20or\x20add\x20it\x20with\x20repository\x20data_add\x20(data_add.name\x20must\x20match\x20a\x20policy\x20rule\x20name)\x203.\x20Retry\x20the\x20SAME\x20call\x20unchanged\x20—\x20a\x20dry_run\x20that\x20turns\x20clean\x20after\x20the\x20row\x20exists\x20confirms\x20the\x20diagnosis','user_prompt':'A\x20guard\x20rule\x20references\x20a\x20data\x20row\x20that\x20has\x20not\x20been\x20written\x20yet\x20(location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20NOT\x20a\x20network\x20problem).\x20Identify\x20the\x20repository\x20row\x20the\x20guard\x20expects\x20(guard2file\x20/\x20analyze_guard_semantics),\x20write\x20it\x20with\x20repository\x20data_add\x20(or\x20let\x20its\x20producer\x20write\x20it),\x20then\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}const BUDGET_EXEMPT_CODES=new Set(['guard_rejected']);function getBudgetAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const [d,e]of b){if(!BUDGET_EXEMPT_CODES['has'](d))c+=e;}return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getBudgetAttempts(b),g=getAttemptCount(b,a);if(d['max_attempts']<=0x1||d['strategy']==='stop')return{'strategy':d['strategy'],'should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.\x20Attempts\x20recorded\x20for\x20this\x20operation\x20id:\x20'+([...(operationAttempts['get'](b)??new Map())['entries']()]['map'](([i,j])=>i+':'+j)['join'](',\x20')||'none')+'.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
1
|
+
export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation.\x20NOTE:\x20this\x20rule\x20is\x20for\x20the\x20SIGNING\x20ACCOUNT\x27s\x20wallet/gas\x20only\x20—\x20an\x20on-chain\x20POOL\x20shortage\x20(reward/allocation)\x20classifies\x20as\x20pool_shortage,\x20never\x20here','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'pool_shortage':{'error_code':'pool_shortage','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'An\x20on-chain\x20POOL\x20cannot\x20cover\x20the\x20operation\x20(reward.move:243\x20abort\x206\x20/\x20'+'allocation.move:509\x20abort\x207)\x20—\x20a\x20pool\x20funding\x20problem,\x20NOT\x20the\x20caller\x27s\x20wallet;\x20a\x20faucet\x20claim\x20will\x20NOT\x20help\x20and\x20re-sending\x20the\x20rail\x20unchanged\x20changes\x20nothing.\x201.\x20Reward\x20pool:\x20the\x20reward\x20ISSUER\x20tops\x20it\x20up\x20with\x20reward\x20coin_add\x20(permission\x20153)\x20—\x20the\x20claim\x20key\x20slot\x20is\x20written\x20BEFORE\x20the\x20balance\x20assert\x20and\x20the\x20abort\x20rolls\x20it\x20back,\x20so\x20NOTHING\x20was\x20consumed;\x20the\x20identical\x20claim\x20succeeds\x20after\x20the\x20top-up\x20(mainnet-proven,\x20T14).\x202.\x20Allocation\x20pool:\x20the\x20payer\x20side\x20funds\x20the\x20order/allocation\x20first\x20(order\x20renew,\x20payment\x20create\x20into\x20the\x20allocation),\x20then\x20re-runs\x20the\x20rail;\x20if\x20the\x20pool\x20is\x20drained\x20because\x20the\x20rail\x20ALREADY\x20paid\x20(balance\x200,\x20once-slot\x20consumed),\x20verify\x20via\x20the\x20Payment\x20record\x20instead\x20of\x20retrying.\x203.\x20As\x20the\x20BUYER:\x20report\x20the\x20shortage\x20to\x20the\x20merchant\x20—\x20never\x20fund\x20a\x20pool\x20you\x20do\x20not\x20own','user_prompt':'The\x20on-chain\x20pool\x20backing\x20this\x20operation\x20is\x20short\x20of\x20funds.\x20The\x20pool\x27s\x20owner\x20must\x20top\x20it\x20up\x20(reward\x20coin_add\x20/\x20allocation\x20funding)\x20—\x20a\x20faucet\x20claim\x20will\x20not\x20help.\x20As\x20the\x20buyer,\x20ask\x20the\x20merchant\x20to\x20fund\x20the\x20pool.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'insufficient_gas':{'error_code':'insufficient_gas','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Gas\x20exhausted\x20—\x20the\x20transaction\x20failed\x20deterministically\x20and\x20did\x20NOT\x20commit\x20on-chain\x20(no\x20state\x20changed;\x20commit-state\x20verification\x20is\x20NOT\x20needed).\x201.\x20Raise\x20the\x20gas_budget\x20parameter\x20above\x20the\x20failed\x20transaction\x27s\x20gas_used\x202.\x20If\x20the\x20account\x20balance\x20cannot\x20cover\x20any\x20budget,\x20fund\x20the\x20signing\x20account\x20with\x20gas\x20tokens\x20first\x203.\x20Resubmit\x20as\x20a\x20FRESH\x20call\x20—\x20do\x20NOT\x20replay\x20the\x20same\x20transaction','user_prompt':'The\x20transaction\x20ran\x20out\x20of\x20gas\x20and\x20did\x20not\x20commit\x20on-chain.\x20Increase\x20the\x20gas\x20budget\x20(or\x20fund\x20the\x20account\x20with\x20gas)\x20and\x20submit\x20a\x20fresh\x20transaction\x20—\x20retrying\x20unchanged\x20will\x20fail\x20the\x20same\x20way.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'wip_storage_rejected':{'error_code':'wip_storage_rejected','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx\x20—\x20deterministic\x20client-side\x20fault,\x20retrying\x20unchanged\x20fails\x20identically).\x20400:\x20malformed\x20body\x20or\x20failed\x20WIP\x20validation\x20—\x20re-generate\x20via\x20wip_file\x20type=\x27generate\x27\x20401:\x20re-sign\x20with\x20a\x20fresh\x20nonce\x20inside\x20the\x20timestamp\x20window\x20403:\x20check\x20storage\x20service\x20configuration\x20404:\x20file\x20does\x20not\x20exist\x20—\x20re-upload\x20409:\x20quota\x20—\x20delete\x20old\x20files\x20via\x20wip_file\x20type=\x27list\x27\x20then\x20delete\x20413:\x20compress\x20images\x20(each\x20<=\x202MB,\x20total\x20<=\x2010MB)\x20and\x20regenerate','user_prompt':'The\x20WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx).\x20Fix\x20the\x20specific\x20fault\x20(re-generate/re-sign/re-upload\x20per\x20the\x20status\x20code)\x20and\x20retry\x20—\x20do\x20not\x20retry\x20unchanged.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Transport\x20failure\x20(timeout\x20/\x20connection\x20reset\x20/\x20RPC\x20unreachable\x20/\x20HTTP\x205xx\x20gateway\x20error).\x20Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.\x20READS:\x20a\x20plain\x20retry\x20is\x20safe.\x20FUND-MOVING\x20WRITES:\x20before\x20any\x20resubmission,\x20verify\x20whether\x20the\x20previous\x20attempt\x20landed\x20(query\x20the\x20reported\x20digest\x20directly,\x20or\x20the\x20expected\x20object\x20via\x20the\x20sender\x27s\x20recent\x20on-chain\x20objects\x20/\x20onchain_events)\x20—\x20if\x20it\x20landed,\x20ADOPT\x20it\x20and\x20stop;\x20a\x20blind\x20backoff\x20retry\x20of\x20a\x20landed\x20write\x20moves\x20the\x20funds\x20a\x20second\x20time.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once\x20—\x20for\x20a\x20FIRST-EVER\x20transaction\x20on\x20a\x20fresh\x20account\x20make\x20that\x20resubmission\x20with\x20env.no_auto_register=true\x20and\x20SAY\x20SO\x20(the\x20SDK\x20silently\x20appends\x20an\x20entity\x20registration\x20to\x20a\x20first\x20business\x20call;\x20if\x20that\x20appended\x20leg\x20was\x20the\x20failing\x20leg\x20the\x20skip\x20lets\x20the\x20call\x20through\x20—\x20ziroom-mn-261013\x20live\x20case;\x20if\x20the\x20resubmission\x20aborts,\x20the\x20envelope\x20now\x20names\x20the\x20abort\x20—\x20re-enable\x20auto\x20registration\x20and\x20retry).\x204.\x20If\x20the\x20reported\x20digest\x20does\x20not\x20resolve\x20or\x20the\x20failure\x20repeats,\x20STOP\x20looping\x20on\x20digest\x20checks\x20and\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20—\x20the\x20simulation\x20surfaces\x20the\x20real\x20failure\x20(exact\x20Move\x20abort)\x20without\x20gas\x20or\x20duplicate\x20risk.\x205.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x206.\x20M-K2\x20replay\x20discipline:\x20a\x20FAILED\x20receipt\x20is\x20final\x20—\x20its\x20digest\x20is\x20consumed\x20and\x20replaying\x20the\x20same\x20bytes\x20returns\x20the\x20same\x20failure\x20forever;\x20fix\x20the\x20cause\x20(usually\x20funding)\x20and\x20build\x20a\x20FRESH\x20transaction.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first\x205.\x20A\x20TIME-window\x20rejection\x20may\x20simply\x20be\x20EARLY:\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20to\x20probe\x20the\x20window\x20for\x20free\x20(guard\x20rejections\x20do\x20NOT\x20consume\x20the\x20total\x20retry\x20budget;\x20only\x20the\x20per-code\x20cap\x20of\x202\x20applies)','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.\x20A\x20time-window\x20rejection\x20may\x20simply\x20be\x20early:\x20probe\x20the\x20window\x20with\x20env.dry_run=true\x20(free\x20—\x20guard\x20rejections\x20do\x20not\x20consume\x20the\x20total\x20retry\x20budget).'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'move_abort_unmapped':{'error_code':'move_abort_unmapped','strategy':'stop','max_attempts':0x1,'automation':'manual','detail':'The\x20chain\x27s\x20business\x20logic\x20aborted\x20and\x20the\x20(module,\x20abort\x20code)\x20pair\x20has\x20no\x20local\x20mapping.\x20Read\x20the\x20module\x20and\x20abort\x20code\x20from\x20move_abort_info\x20/\x20the\x20message\x20(rendered\x20as\x20\x27abort\x20(N)\x27),\x20resolve\x20their\x20meaning\x20from\x20the\x20module\x27s\x20documentation\x20or\x20the\x20wowok-tools\x20Skill,\x20fix\x20the\x20business\x20cause,\x20and\x20issue\x20a\x20NEW\x20call.\x20Do\x20NOT\x20restart\x20the\x20server\x20and\x20do\x20NOT\x20retry\x20the\x20identical\x20call\x20—\x20it\x20aborts\x20deterministically.','user_prompt':'The\x20operation\x20was\x20rejected\x20by\x20the\x20chain\x27s\x20business\x20logic\x20and\x20its\x20abort\x20code\x20is\x20not\x20mapped\x20locally.\x20The\x20module\x20name\x20and\x20abort\x20code\x20in\x20the\x20error\x20are\x20authoritative\x20—\x20review\x20them\x20(and\x20the\x20object\x20state\x20via\x20query_toolkit)\x20before\x20adjusting\x20anything.'},'missing_data':{'error_code':'missing_data','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'A\x20guard\x20rule\x20read\x20a\x20keyed\x20table\x20row\x20that\x20does\x20NOT\x20exist\x20(repository.data\x20/\x20oracle\x20entry)\x20and\x20the\x20verifier\x20surfaced\x20it\x20as\x20a\x20location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20no\x20abort\x20code,\x20because\x20the\x20framework\x20cannot\x20express\x20\x27row\x20absent\x27\x20as\x20an\x20abort.\x20This\x20is\x20a\x20DATA\x20problem:\x201.\x20Identify\x20the\x20repository\x20and\x20key\x20the\x20guard\x20rule\x20reads\x20(guard2file\x20/\x20analyze_guard_semantics\x20on\x20the\x20guard\x20source)\x202.\x20Have\x20the\x20row\x27s\x20producer\x20write\x20it\x20(e.g.\x20an\x20oracle\x20timestamp\x20like\x20checkin_ts),\x20or\x20add\x20it\x20with\x20repository\x20data_add\x20(data_add.name\x20must\x20match\x20a\x20policy\x20rule\x20name)\x203.\x20Retry\x20the\x20SAME\x20call\x20unchanged\x20—\x20a\x20dry_run\x20that\x20turns\x20clean\x20after\x20the\x20row\x20exists\x20confirms\x20the\x20diagnosis','user_prompt':'A\x20guard\x20rule\x20references\x20a\x20data\x20row\x20that\x20has\x20not\x20been\x20written\x20yet\x20(location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20NOT\x20a\x20network\x20problem).\x20Identify\x20the\x20repository\x20row\x20the\x20guard\x20expects\x20(guard2file\x20/\x20analyze_guard_semantics),\x20write\x20it\x20with\x20repository\x20data_add\x20(or\x20let\x20its\x20producer\x20write\x20it),\x20then\x20retry.'},'state_not_visible':{'error_code':'state_not_visible','strategy':'wait_and_retry','max_attempts':0x3,'automation':'full','detail':'The\x20state\x20this\x20call\x20needs\x20was\x20JUST\x20written\x20and\x20is\x20not\x20yet\x20visible\x20to\x20reads\x20(write-to-visibility\x20window),\x20or\x20it\x20does\x20not\x20exist\x20at\x20all.\x201.\x20If\x20a\x20write\x20on\x20this\x20order/machine\x20committed\x20within\x20the\x20last\x20few\x20seconds,\x20wait\x20500ms\x20(doubling\x20each\x20attempt)\x20and\x20replay\x20the\x20SAME\x20call\x20UNCHANGED\x20—\x20NEVER\x20edit\x20parameters\x20to\x20\x27fix\x27\x20a\x20visibility\x20window;\x20an\x20aborted\x20call\x20never\x20landed,\x20so\x20the\x20replay\x20cannot\x20double-spend.\x202.\x20If\x20the\x20fault\x20persists\x20past\x20~3\x20attempts\x20(or\x20nothing\x20was\x20just\x20written),\x20the\x20state\x20is\x20deterministically\x20ABSENT\x20—\x20stop\x20retrying:\x20for\x20a\x20forward-info\x20miss\x20query\x20the\x20Machine\x27s\x20node\x20table\x20(onchain_table_data\x20onchain_table_item_machine_node)\x20and\x20use\x20an\x20existing\x20node/next_node/forward\x20triple;\x20for\x20a\x20guard-read\x20repository\x20row\x20follow\x20the\x20missing_data\x20path\x20(write\x20the\x20row).','user_prompt':'A\x20just-committed\x20write\x20is\x20not\x20visible\x20to\x20this\x20read\x20yet.\x20The\x20same\x20call\x20will\x20be\x20replayed\x20after\x20a\x20short\x20wait\x20—\x20no\x20parameter\x20change\x20is\x20needed.\x20If\x20it\x20keeps\x20failing,\x20the\x20required\x20state\x20is\x20genuinely\x20missing\x20and\x20must\x20be\x20created\x20first.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}const BUDGET_EXEMPT_CODES=new Set(['guard_rejected']);function getBudgetAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const [d,e]of b){if(!BUDGET_EXEMPT_CODES['has'](d))c+=e;}return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getBudgetAttempts(b),g=getAttemptCount(b,a);if(d['max_attempts']<=0x1||d['strategy']==='stop')return{'strategy':d['strategy'],'should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.\x20Attempts\x20recorded\x20for\x20this\x20operation\x20id:\x20'+([...(operationAttempts['get'](b)??new Map())['entries']()]['map'](([j,k])=>j+':'+k)['join'](',\x20')||'none')+'.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a),i={'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};return i['should_retry']&&c?.['retryable']===![]&&a!=='guard_rejected'&&d['strategy']!=='fill_submission'&&d['strategy']!=='query_and_retry'&&(i['should_retry']=![],i['detail']+='\x20NON-RETRYABLE\x20CLASSIFICATION:\x20retrying\x20the\x20IDENTICAL\x20call\x20fails\x20identically\x20—\x20apply\x20the\x20strategy\x20above\x20to\x20fix\x20the\x20cause,\x20then\x20submit\x20a\x20FRESH\x20call.'),i;}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
|
|
@@ -45,7 +45,6 @@ export declare const ALLOCATION_ERROR_CODES: {
|
|
|
45
45
|
readonly ERECIPIENT_NOT_FOR_OBJECT: 15;
|
|
46
46
|
readonly E_ONCE_TRIGGERED: 16;
|
|
47
47
|
readonly EMIXED_RATE_BASES: 17;
|
|
48
|
-
readonly EFORMULA_DISABLED: 23;
|
|
49
48
|
readonly EFORMULA_SPEC_INVALID: 24;
|
|
50
49
|
};
|
|
51
50
|
export declare const ORDER_ALLOCATION_ALREADY_SPECIFIED = "E_ALLOCATION_ALREADY_SPECIFIED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const ALLOCATION_MODE_FORMULA=0x4;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11,'EFORMULA_DISABLED':0x17,'EFORMULA_SPEC_INVALID':0x18};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;case'Formula':return ALLOCATION_MODE_FORMULA;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';case ALLOCATION_MODE_FORMULA:return'Formula';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)\x20/\x204\x20(Formula)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'allocator\x20append\x20rejected:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding',0x17:'Formula\x20pricing\x20mode\x20(4)\x20used\x20while\x20the\x20protocol\x20feature\x20flag\x20enable_allocator_formula_pricing\x20is\x20off',0x18:'FormulaSpec\x20rejected:\x20selector\x20is\x20not\x20COUNT(0)/SUM(1),\x20allocator/slot\x20index\x20out\x20of\x20range,\x20or\x20the\x20target\x20sharing\x20slot\x20is\x20not\x20a\x20Formula\x20(mode\x204)\x20leg'};return b[a];}
|
|
1
|
+
import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const ALLOCATION_MODE_FORMULA=0x4;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11,'EFORMULA_SPEC_INVALID':0x18};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;case'Formula':return ALLOCATION_MODE_FORMULA;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';case ALLOCATION_MODE_FORMULA:return'Formula';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)\x20/\x204\x20(Formula)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'allocator\x20append\x20rejected:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding',0x18:'FormulaSpec\x20rejected:\x20selector\x20is\x20not\x20COUNT(0)/SUM(1),\x20allocator/slot\x20index\x20out\x20of\x20range,\x20or\x20the\x20target\x20sharing\x20slot\x20is\x20not\x20a\x20Formula\x20(mode\x204)\x20leg'};return b[a];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![],'F_A_16_rate_gross_sum_le_10000':!![],'F_A_17_no_mixed_rate_bases':!![],'F_A_18_formula_coefficient_le_10000':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const t of f['sharing']){!['Amount','Rate','Surplus','RateGross','Formula']['includes'](t['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+t['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](u=>u['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](u=>u['mode']==='Amount')['reduce']((u,v)=>u+Number(v['sharing']),0x0),i=f['sharing']['some'](u=>u['mode']==='RateGross'),j=f['sharing']['some'](u=>u['mode']==='Rate'),k=f['sharing']['some'](u=>u['mode']==='Formula'),l=i&&h===0x0&&j,n=f['sharing']['filter'](u=>u['mode']==='Rate'||l&&u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0),o=g>0x0;!(j&&i&&h>0x0)&&(!o&&n>0x0&&n!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+n+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'}),o&&n>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+n+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'}));const p=Number(c['threshold']);!k&&h>0x0&&h<p&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+h+'\x20<\x20threshold\x20'+p,'current_value':h,'limit':p,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&h>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+h+'\x20>\x20max\x20'+Number(f['max']),'current_value':h,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const q=f['sharing']['filter'](u=>u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0);if(i&&!j){if(q>RATE_TOTAL_FULL)b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});else{if(f['max']!=null){const u=Number(f['max']);h*RATE_TOTAL_FULL+q*u>u*RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20plan\x20overdraws\x20max:\x20fix\x20'+h+'×10000\x20+\x20rateSum\x20'+q+'×'+u+'\x20>\x20'+u+'×10000','related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}else h>0x0&&q>=RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20with\x20fixed\x20total\x20'+h+'\x20and\x20no\x20max\x20must\x20be\x20<\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}}j&&i&&h>0x0&&b['push']({'constraint_id':'F-A-17','severity':'high','message':'Allocator\x20'+f['guard']+'\x20mixes\x20NET\x20Rate\x20and\x20RateGross\x20with\x20a\x20fixed\x20Amount\x20total\x20('+h+')\x20—\x20abort\x20EMIXED_RATE_BASES','related_move_error':'EMIXED_RATE_BASES\x20(17)'});for(const v of f['sharing']['filter'](w=>w['mode']==='Formula')){const w=Number(v['sharing']);Number['isFinite'](w)&&w>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-18','severity':'high','message':'Allocator\x20'+f['guard']+'\x20Formula\x20coefficient\x20'+w+'\x20>\x20'+RATE_TOTAL_FULL+'\x20(basis-point\x20ceiling,\x20ERATE_EXCEEDS_10000)','current_value':w,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}const r=f['sharing']['find'](x=>typeof x['who']==='object'&&'GuardIdentifier'in x['who']);if(r){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'NET\x20Rate:\x20total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix;\x20RateGross:\x20total_rates\x20=\x20max\x20(if\x20max)\x20else\x20balance\x20(fix\x20NOT\x20removed)'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/RateGross/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'sweep\x20the\x20remainder\x20to\x20surplus_recipient\x20(if\x20any)\x20—\x20uncapped:\x20the\x20whole\x20remaining\x20pool;\x20max-capped:\x20topped\x20up\x20to\x20the\x20cap'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|
|
1
|
+
import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![],'F_A_16_rate_gross_sum_le_10000':!![],'F_A_17_no_mixed_rate_bases':!![],'F_A_18_formula_coefficient_le_10000':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const t of f['sharing']){!['Amount','Rate','Surplus','RateGross','Formula']['includes'](t['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+t['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](u=>u['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](u=>u['mode']==='Amount')['reduce']((u,v)=>u+Number(v['sharing']),0x0),i=f['sharing']['some'](u=>u['mode']==='RateGross'),j=f['sharing']['some'](u=>u['mode']==='Rate'),k=f['sharing']['some'](u=>u['mode']==='Formula'),l=i&&h===0x0&&j,n=f['sharing']['filter'](u=>u['mode']==='Rate'||l&&u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0),o=g>0x0;!(j&&i&&h>0x0)&&(!o&&n>0x0&&n!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+n+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'}),o&&n>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+n+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'}));const p=Number(c['threshold']);!k&&h>0x0&&h<p&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+h+'\x20<\x20threshold\x20'+p,'current_value':h,'limit':p,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&h>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+h+'\x20>\x20max\x20'+Number(f['max']),'current_value':h,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const q=f['sharing']['filter'](u=>u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0);if(i&&!j){if(q>RATE_TOTAL_FULL)b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});else{if(f['max']!=null){const u=Number(f['max']);h*RATE_TOTAL_FULL+q*u>u*RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20plan\x20overdraws\x20max:\x20fix\x20'+h+'×10000\x20+\x20rateSum\x20'+q+'×'+u+'\x20>\x20'+u+'×10000','related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}else h>0x0&&q>=RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20with\x20fixed\x20total\x20'+h+'\x20and\x20no\x20max\x20must\x20be\x20<\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}}j&&i&&h>0x0&&b['push']({'constraint_id':'F-A-17','severity':'high','message':'Allocator\x20'+f['guard']+'\x20mixes\x20NET\x20Rate\x20and\x20RateGross\x20with\x20a\x20fixed\x20Amount\x20total\x20('+h+')\x20—\x20abort\x20EMIXED_RATE_BASES','related_move_error':'EMIXED_RATE_BASES\x20(17)'});for(const v of f['sharing']['filter'](w=>w['mode']==='Formula')){const w=Number(v['sharing']);Number['isFinite'](w)&&w>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-18','severity':'high','message':'Allocator\x20'+f['guard']+'\x20Formula\x20coefficient\x20'+w+'\x20>\x20'+RATE_TOTAL_FULL+'\x20(basis-point\x20ceiling,\x20ERATE_EXCEEDS_10000)','current_value':w,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}const r=f['sharing']['find'](x=>typeof x['who']==='object'&&'GuardIdentifier'in x['who']);if(r){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'NET\x20Rate:\x20total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix;\x20RateGross:\x20total_rates\x20=\x20max\x20(if\x20max)\x20else\x20balance\x20(fix\x20NOT\x20removed)'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/RateGross/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'sweep\x20the\x20remainder\x20to\x20surplus_recipient\x20(if\x20any)\x20—\x20uncapped:\x20the\x20whole\x20remaining\x20pool;\x20max-capped:\x20topped\x20up\x20to\x20the\x20cap'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20when\x20payment_info.for_object\x20is\x20Some,\x20a\x20GuardIdentifier\x20submission\x20must\x20equal\x20it\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015).\x20A\x20MATCH\x20is\x20the\x20deliberate\x20order-anchored\x20refund\x20shape:\x20the\x20share\x20is\x20paid\x20to\x20the\x20bound\x20Order\x20object\x20and\x20the\x20Order\x27s\x20owner-claim\x20entry\x20extracts\x20it\x20to\x20order.owner.\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
|