@wowok/agent-mcp 2.7.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/capability-manifest.d.ts +1 -82
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +6 -4
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +4 -5
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +6 -4
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +2 -3
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/registry.d.ts +3 -25
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +0 -68
- package/dist/goal/GoalEngine.d.ts +36 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/goal/types.d.ts +4 -0
- package/dist/knowledge/account-marks.d.ts +1 -0
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +13 -9
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-bindings.d.ts +21 -0
- package/dist/knowledge/guard-bindings.js +1 -0
- package/dist/knowledge/index.d.ts +5 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +2 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +43 -0
- package/dist/knowledge/scenario-topology.js +1 -0
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +35 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +1 -0
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.d.ts +2 -0
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/ScopeResolver.js +1 -1
- package/dist/monitor/SuggestionBridge.d.ts +38 -0
- package/dist/monitor/SuggestionBridge.js +1 -0
- package/dist/participation/arbitrator-interest.d.ts +20 -0
- package/dist/participation/arbitrator-interest.js +1 -0
- package/dist/participation/demander-interest.d.ts +23 -0
- package/dist/participation/demander-interest.js +1 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +20 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +30 -6
- package/dist/playbooks/service-build/mode-actions.js +1 -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.d.ts +2 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -0
- package/dist/playbooks/service-build/semantic-graph.d.ts +5 -1
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/relationship/derivation.d.ts +88 -0
- package/dist/relationship/derivation.js +1 -0
- package/dist/relationship/incentive.d.ts +38 -0
- package/dist/relationship/incentive.js +1 -0
- package/dist/relationship/index.d.ts +4 -0
- package/dist/relationship/index.js +1 -0
- package/dist/relationship/registry.d.ts +13 -0
- package/dist/relationship/registry.js +1 -0
- package/dist/relationship/types.d.ts +45 -0
- package/dist/relationship/types.js +1 -0
- package/dist/review/progress.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/bridge.d.ts +25 -3
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +40 -14
- package/dist/schema/goal/index.js +1 -1
- package/dist/schema/goal/planning.d.ts +6 -6
- package/dist/schema/industry-pack/index.d.ts +58 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +59 -1
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +19 -19
- package/dist/schema/local/index.d.ts +11 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +58 -16
- package/dist/schema/persona/index.d.ts +1 -1
- package/dist/schema/query/bi.d.ts +145 -16
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +2 -2
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +29 -0
- package/dist/schemas/account_operation.schema.json +6 -2
- package/dist/schemas/bridge_operation.output.json +24 -1
- package/dist/schemas/bridge_operation.schema.json +73 -1
- package/dist/schemas/goal_operation.schema.json +76 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +176 -1
- package/dist/schemas/industry_pack_operation.schema.json +19 -0
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +41 -41
- package/dist/schemas/onchain_operations_allocation.schema.json +4 -4
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +7 -7
- package/dist/schemas/onchain_operations_treasury.schema.json +6 -6
- package/dist/schemas/onchain_table_data.output.json +53 -0
- package/dist/schemas/query_toolkit.output.json +240 -7
- package/dist/schemas/query_toolkit.schema.json +53 -0
- package/dist/task/ProcessStore.d.ts +18 -1
- package/dist/task/ProcessStore.js +1 -1
- package/dist/task/types.d.ts +24 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +4 -3
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/package.json +2 -2
- package/dist/mode-market/index.d.ts +0 -3
- package/dist/mode-market/index.js +0 -1
- package/dist/mode-market/registry.d.ts +0 -53
- package/dist/mode-market/registry.js +0 -1
- package/dist/mode-market/review.d.ts +0 -27
- package/dist/mode-market/review.js +0 -1
- package/dist/mode-market/submission.d.ts +0 -25
- package/dist/mode-market/submission.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GasTokenType}from'@wowok/wowok';const GAS_TOKENS=[{'type':'0x2::wow::WOW','symbol':'WOW','decimals':0x9,'name':'Wowok\x20Token','description':'Default\x20platform\x20gas\x20token\x20for\x20all\x20WoWok\x20operations.\x201\x20WOW\x20=\x2010^9\x20MIST.\x20Available\x20on\x20testnet\x20and\x20mainnet.'}],TESTNET_TOKENS=[];function buildMainnetTokensFromSDK(){try{const {MAINNET_BRIDGE_CONFIG:a}=require('@wowok/wowok');if(!a?.['tokens'])return[];const b=new Set();return a['tokens']['filter'](c=>{if(b['has'](c['wowTypeTag']))return![];return b['add'](c['wowTypeTag']),!![];})['map'](c=>({'type':c['wowTypeTag'],'symbol':c['symbol'],'decimals':c['wowDecimals'],'name':c['symbol']+'\x20(Bridge)','description':c['description']??'Bridge\x20token\x20on\x20WOW\x20mainnet.\x20'+c['wowDecimals']+'\x20decimals.'}));}catch{return[];}}export const OFFICIAL_TOKEN_REGISTRY={'gas':GAS_TOKENS,'testnet':TESTNET_TOKENS,'mainnet':buildMainnetTokensFromSDK()};export function getRegistryForNetwork(a){return[...OFFICIAL_TOKEN_REGISTRY['gas'],...a==='testnet'?OFFICIAL_TOKEN_REGISTRY['testnet']:[],...a==='mainnet'?OFFICIAL_TOKEN_REGISTRY['mainnet']:[]];}export function findInRegistryByType(a,b){const c=OFFICIAL_TOKEN_REGISTRY['gas']['find'](e=>e['type']===a);if(c)return c;const d=getRegistryForNetwork(b);return d['find'](e=>e['type']===a);}export function findInRegistryBySymbol(a,b){const c=a['toLowerCase'](),d=OFFICIAL_TOKEN_REGISTRY['gas']['filter'](g=>g['symbol']['toLowerCase']()===c),e=getRegistryForNetwork(b),f=e['filter'](g=>g['symbol']['toLowerCase']()===c&&!d['some'](h=>h['type']===g['type']));return[...d,...f];}export async function resolveTokenByType(a,b){const c=findInRegistryByType(a,b);if(c)return{'type':c['type'],'symbol':c['symbol'],'decimals':c['decimals'],'name':c['name'],'source':'registry','verified':!![]};const d=cacheNet(b)+'::'+a,e=RESOLUTION_CACHE['get'](d);if(e)return e;try{const {TokenInfo:f}=await import('@wowok/wowok'),g=f['Instance'](),h=await g['fetch'](a,undefined,b);if(h){const i={'type':h['type'],'symbol':h['symbol']??'','decimals':h['decimals']??0x0,'name':h['name']??'','source':'cache','verified':![]};return RESOLUTION_CACHE['set'](d,i),i;}}catch{}return undefined;}export async function resolveTokensBySymbol(a,b,c){const d=[],e=findInRegistryBySymbol(a,b);for(const f of e){d['push']({'type':f['type'],'symbol':f['symbol'],'decimals':f['decimals'],'name':f['name'],'source':'registry','verified':!![]});}try{const {query_local_token_list:g}=await import('@wowok/wowok'),h=await g({'symbol':a});for(const i of h){if(d['some'](j=>j['type']===i['type']))continue;d['push']({'type':i['type'],'symbol':i['symbol']??'','decimals':i['decimals']??0x0,'name':i['name']??'','source':'cache','verified':![]});}}catch{}return c&&d['sort']((j,k)=>{if(j['type']===c)return-0x1;if(k['type']===c)return 0x1;if(j['verified']&&!k['verified'])return-0x1;if(!j['verified']&&k['verified'])return 0x1;return 0x0;}),d;}const AMOUNT_WITH_SYMBOL=/^(\d+(?:\.\d+)?)\s*([A-Za-z][A-Za-z0-9]*)$/;export function isAmountWithSymbol(a){if(typeof a!=='string')return![];const b=a['match'](AMOUNT_WITH_SYMBOL);if(!b)return![];const c=b[0x2];return c['length']>=0x2&&c['length']<=0xa;}export async function parseAmount(a,b,c){const d=a,e=await resolveTokenByType(b,c),f=e!==undefined,g=e?.['decimals']??0x9,h=e?.['symbol']??'',i=e?.['source']??'onchain',j=e?.['verified']??![];if(typeof a==='string'){const m=a['match'](AMOUNT_WITH_SYMBOL);if(m){if(!f)throw new Error('TOKEN\x20PRECISION\x20UNKNOWN\x20for\x20'+b+'\x20—\x20REFUSING\x20to\x20convert\x20\x22'+a+'\x22.\x20'+'The\x20token\x27s\x20decimals\x20could\x20not\x20be\x20resolved\x20from\x20the\x20official\x20registry,\x20local\x20cache,\x20'+'or\x20on-chain\x20metadata,\x20and\x20guessing\x20decimals\x20would\x20forge\x20a\x20wrong\x20on-chain\x20value.\x20'+'Retry\x20(the\x20on-chain\x20lookup\x20may\x20have\x20been\x20transient),\x20or\x20pass\x20a\x20pure\x20numeric\x20value\x20'+'in\x20smallest\x20units\x20only\x20if\x20you\x20are\x20certain\x20of\x20the\x20raw\x20u64\x20amount.\x20'+knownTokenSuggestions(c));const n=parseFloat(m[0x1]),o=m[0x2];if(h&&o['toLowerCase']()!==h['toLowerCase']())throw new Error('Amount\x20symbol\x20\x22'+o+'\x22\x20does\x20not\x20match\x20the\x20expected\x20token\x20symbol\x20\x22'+h+'\x22\x20'+('(type:\x20'+b+').\x20Either\x20use\x20the\x20correct\x20symbol\x20or\x20pass\x20a\x20pure\x20numeric\x20value\x20')+('in\x20smallest\x20units\x20(e.g.,\x20'+(n*Math['pow'](0xa,g))['toFixed'](0x0)+').'));const p=displayToSmallestUnit(n,g);return{'smallestUnit':p,'displayAmount':n+'\x20'+o,'originalInput':d,'tokenType':b,'tokenSymbol':h||o,'decimals':g,'converted':!![],'source':i,'verified':j,'precision_known':!![]};}}let k;try{k=BigInt(a);}catch{throw new Error('Invalid\x20amount:\x20\x22'+a+'\x22.\x20Expected\x20a\x20number,\x20a\x20numeric\x20string\x20(smallest\x20unit),\x20'+'or\x20a\x20display-format\x20string\x20like\x20\x222.5WOW\x22\x20(matching\x20the\x20token\x27s\x20symbol).');}const l=f?smallestToDisplay(k,g):k['toString']()+'\x20raw\x20smallest\x20units\x20(token\x20precision\x20unknown)';return{'smallestUnit':k,'displayAmount':f&&h?l+'\x20'+h:l,'originalInput':d,'tokenType':b,'tokenSymbol':h,'decimals':g,'converted':![],'source':i,'verified':j,'precision_known':f};}function displayToSmallestUnit(a,b){const c=a['toString'](),[d,e='']=c['split']('.'),f=e['padEnd'](b,'0')['slice'](0x0,b),g=d+f;return BigInt(g||'0');}export function smallestToDisplay(a,b){const c=a<0x0n?'-':'',d=a<0x0n?-a:a,e=BigInt(0xa)**BigInt(b),f=d/e,g=d%e;if(g===0x0n)return''+c+f['toString']();const h=g['toString']()['padStart'](b,'0')['replace'](/0+$/,'');return''+c+f['toString']()+'.'+h;}export function displayStringToSmallest(a,b){const c=a['trim']();if(!/^\d+(\.\d+)?$/['test'](c))throw new Error('Invalid\x20display\x20amount:\x20\x22'+a+'\x22.\x20Expected\x20a\x20non-negative\x20decimal\x20number\x20like\x20\x222.5\x22.');const [d,e='']=c['split']('.');if(e['length']>b)throw new Error('Too\x20many\x20decimal\x20places:\x20\x22'+a+'\x22\x20has\x20'+e['length']+',\x20but\x20this\x20token\x20supports\x20at\x20most\x20'+b+'\x20(decimals:\x20'+b+').');const f=e['padEnd'](b,'0');return BigInt(d+f);}export function generateFundConfirmation(a,b=[]){const d=b['length']>0x0,e=['MONEY\x20TRANSACTION\x20CONFIRMATION\x20REQUIRED',''];for(const f of a){const g=f['verified']?'\x20[VERIFIED]':'\x20[UNVERIFIED]',h='\x20(source:\x20'+f['source']+')';e['push']('\x20\x20•\x20'+f['context']+':\x20'+f['displayAmount']+g+h),f['converted']&&e['push']('\x20\x20\x20\x20(converted\x20from\x20display\x20format\x20to\x20smallest\x20unit)');}if(d){e['push']('','AMBIGUITY\x20WARNING\x20—\x20multiple\x20tokens\x20share\x20the\x20same\x20symbol:');for(const i of b){e['push']('\x20\x20Symbol\x20\x22'+i['symbol']+'\x22\x20matches:');for(const j of i['candidates']){const k=j['verified']?'\x20[VERIFIED]':'\x20[UNVERIFIED]';e['push']('\x20\x20\x20\x20-\x20type:\x20'+j['type']+',\x20decimals:\x20'+j['decimals']+k+'\x20(source:\x20'+j['source']+')');}e['push']('\x20\x20\x20\x20→\x20Specify\x20the\x20full\x20type\x20string\x20in\x20type_parameter\x20to\x20disambiguate.');}}return e['push']('','This\x20operation\x20involves\x20money.\x20Please\x20confirm\x20before\x20proceeding.'),{'requiresConfirmation':!![],'reason':d?'Money\x20transaction\x20with\x20ambiguous\x20token\x20symbol\x20—\x20user\x20must\x20specify\x20full\x20type':'Money\x20transaction\x20requires\x20user\x20confirmation','fields':a,'ambiguities':b,'message':e['join']('\x0a')};}function extractTokenType(a,b,c){if(a?.['object']&&typeof a['object']==='object'&&a['object']['type_parameter'])return a['object']['type_parameter'];if(b==='payment'&&a?.['type_parameter'])return a['type_parameter'];if(c)return c;return GasTokenType;}const MONETARY_FIELDS={'service':[{'path':'sales.sales','context':'Service\x20sale\x20price','isArray':!![],'amountField':'price'},{'path':'compensation_fund_add.balance','context':'Service\x20compensation\x20fund\x20deposit'},{'path':'order_new.buy.total_pay.balance','context':'Order\x20payment\x20amount'},{'path':'discount.discount_value','context':'Discount\x20value'}],'arbitration':[{'path':'dispute.fee.balance','context':'Arbitration\x20dispute\x20fee'},{'path':'fee','context':'Arbitration\x20fee'}],'reward':[{'path':'coin_add.balance','context':'Reward\x20coin\x20add'}],'treasury':[{'path':'deposit.coin.balance','context':'Treasury\x20deposit\x20amount'},{'path':'withdraw.amount.fixed','context':'Treasury\x20withdrawal\x20amount'}],'payment':[{'path':'revenue','context':'Payment\x20amount','isArray':!![],'amountField':'amount.balance'}],'allocation':[{'path':'coin.balance','context':'Allocation\x20funding\x20amount'}]};function getNestedValue(a,b){const c=b['split']('.');let d=a;for(const e of c){if(d==null)return undefined;d=d[e];}return d;}export async function processFundOperation(a,b,c,d){const e={'convertedData':a,'warnings':[],'errors':[],'confirmation':null},f=MONETARY_FIELDS[b];if(!f)return e;const g=extractTokenType(a,b,d?.['objectTokenType']),h=[],k=[],l=new Map();for(const m of f){const n=m['isArray']===!![],o=m['amountField'];if(n&&o){const p=getNestedValue(a,m['path']);if(Array['isArray'](p))for(let q=0x0;q<p['length'];q++){const r=p[q],s=o['split']('.');let t=r;for(let v=0x0;v<s['length']-0x1;v++){t=t?.[s[v]];if(t==null)break;}const u=s[s['length']-0x1];if(t&&t[u]!=null){const w=m['path']+'['+q+'].'+o;await processSingleField(t,u,w,m['context'],g,c,e,h,k,l);}}}else{const x=m['path']['lastIndexOf']('.'),y=x>=0x0?m['path']['slice'](0x0,x):'',z=x>=0x0?m['path']['slice'](x+0x1):m['path'],A=y?getNestedValue(a,y):a;A&&A[z]!=null&&await processSingleField(A,z,m['path'],m['context'],g,c,e,h,k,l);}}if(h['length']>0x0){e['confirmation']=generateFundConfirmation(h,k);const B=h['length'],C=h['some'](E=>!E['verified']),D=k['length']>0x0;D&&e['warnings']['push']('AMBIGUOUS\x20TOKEN:\x20'+k['length']+'\x20token\x20symbol(s)\x20have\x20multiple\x20candidates.\x20'+'User\x20must\x20specify\x20full\x20type\x20string\x20in\x20type_parameter\x20to\x20disambiguate.\x20'+'See\x20confirmation\x20message\x20for\x20details.'),C&&e['warnings']['push']('UNVERIFIED\x20TOKEN:\x20some\x20monetary\x20fields\x20use\x20tokens\x20not\x20in\x20the\x20official\x20registry.\x20'+'Precision\x20was\x20resolved\x20from\x20cache/on-chain.\x20Verify\x20the\x20token\x20type\x20before\x20proceeding.'),e['warnings']['push']('MONEY\x20CONFIRMATION:\x20'+B+'\x20monetary\x20field(s)\x20require\x20user\x20confirmation.\x20'+('Token\x20type:\x20'+g+'.\x20Use\x20env.confirmed=true\x20after\x20user\x20consent.'));}return e;}async function processSingleField(a,b,c,d,e,f,g,h,i,j){const k=a[b];if(k==null)return;try{const l=await parseAmount(k,e,f);if(!l['precision_known']){g['errors']['push']('FUND\x20INPUT\x20BLOCKED\x20at\x20'+c+':\x20token\x20precision\x20unavailable\x20for\x20'+e+'.\x20'+('The\x20raw\x20value\x20'+JSON['stringify'](k)+'\x20was\x20NOT\x20converted\x20or\x20confirmed.\x20')+'Retry\x20after\x20the\x20token\x20info\x20resolves\x20(registry\x20→\x20cache\x20→\x20on-chain),\x20'+('or\x20use\x20a\x20known\x20token.\x20'+knownTokenSuggestions(f)));return;}l['converted']&&(a[b]=l['smallestUnit']['toString']());h['push']({'path':c,'displayAmount':l['displayAmount'],'tokenType':l['tokenType'],'tokenSymbol':l['tokenSymbol'],'verified':l['verified'],'source':l['source'],'converted':l['converted'],'context':d});if(l['tokenSymbol']&&l['source']!=='registry'){const m=l['tokenSymbol']['toLowerCase']();let n=j['get'](m);if(!n){const o=await resolveTokensBySymbol(l['tokenSymbol'],f,e);o['length']>0x1&&(n=o,j['set'](m,n),i['push']({'symbol':l['tokenSymbol'],'candidates':n['map'](p=>({'type':p['type'],'decimals':p['decimals'],'source':p['source'],'verified':p['verified']}))}));}}}catch(p){g['errors']['push']('FUND\x20INPUT\x20BLOCKED\x20at\x20'+c+':\x20'+p['message']);}}export function generateSkillsHint(a){if(!a||!a['requiresConfirmation'])return null;const b=a['ambiguities']['length']>0x0;if(b)return'SKILLS\x20HINT:\x20This\x20money\x20transaction\x20has\x20ambiguous\x20token\x20symbols.\x20'+'If\x20the\x20wowok-safety\x20skill\x20is\x20installed,\x20it\x20can\x20guide\x20the\x20user\x20through\x20'+'interactive\x20disambiguation.\x20Otherwise,\x20the\x20MCP\x20fund\x20layer\x20has\x20already\x20'+'listed\x20all\x20candidates\x20in\x20the\x20confirmation\x20message\x20—\x20ask\x20the\x20user\x20to\x20'+'specify\x20the\x20full\x20token\x20type\x20string\x20in\x20type_parameter.';return'SKILLS\x20HINT:\x20This\x20money\x20transaction\x20requires\x20user\x20confirmation.\x20'+'If\x20the\x20wowok-safety\x20skill\x20is\x20installed,\x20it\x20provides\x20R1-R10\x20confirmation\x20'+'dialogue\x20scripts.\x20Otherwise,\x20present\x20the\x20confirmation\x20message\x20to\x20the\x20user\x20'+'and\x20proceed\x20only\x20after\x20explicit\x20consent\x20(env.confirmed=true).';}export async function formatChainValue(a,b,c){let d;try{d=BigInt(a)['toString']();}catch{d=String(a);}const e=await resolveTokenByType(b,c);if(e&&typeof e['decimals']==='number'){let f=d;try{f=smallestToDisplay(BigInt(d),e['decimals']);}catch{}const g=e['symbol']||'',h=g?f+'\x20'+g+'\x20(decimals:\x20'+e['decimals']+';\x201\x20'+g+'\x20=\x2010^'+e['decimals']+'\x20raw\x20units;\x20raw:\x20'+d+')':f+'\x20(decimals:\x20'+e['decimals']+';\x201\x20unit\x20=\x2010^'+e['decimals']+'\x20raw\x20units;\x20raw:\x20'+d+')';return{'raw':d,'display':f,'symbol':g||undefined,'decimals':e['decimals'],'token_type':b,'precision_known':!![],'text':h};}return{'raw':d,'display':d,'token_type':b,'precision_known':![],'text':d+'\x20raw\x20smallest\x20units\x20(token\x20precision\x20unavailable\x20for\x20'+b+'\x20—\x20'+'cannot\x20convert\x20to\x20unit\x20value.\x20Conversion\x20rule\x20once\x20decimals\x20N\x20is\x20known:\x20'+'unit\x20=\x20raw\x20/\x2010^N.\x20Re-run\x20the\x20query\x20to\x20retry\x20the\x20on-chain\x20precision\x20lookup.)'};}export function registryDisplayHint(a,b){if(!a)return undefined;const c=findInRegistryByType(a,b);if(!c)return undefined;return{'decimals':c['decimals'],'symbol':c['symbol']};}const RESOLUTION_CACHE=new Map(),OBJECT_TYPE_CACHE=new Map();function cacheNet(a){return a??'default';}function isCacheableObjectRef(a){return/^0x[0-9a-fA-F]{20,}$/['test'](a);}export function clearFundResolutionCaches(){RESOLUTION_CACHE['clear'](),OBJECT_TYPE_CACHE['clear']();}export function knownTokenSuggestions(a){const b=getRegistryForNetwork(a)['map'](c=>c['symbol']+'\x20('+c['type']+',\x20'+c['decimals']+'\x20decimals)');return b['length']>0x0?'Known\x20tokens:\x20'+b['join'](';\x20')+'.':'No\x20officially-known\x20tokens\x20on\x20this\x20network.';}export function formatAmountText(a,b,c){let d;try{d=BigInt(a)['toString']();}catch{d=String(a);}if(b===undefined)return d+'\x20smallest\x20units\x20(token\x20precision\x20unknown)';let e=d;try{e=smallestToDisplay(BigInt(d),b);}catch{}return c?e+'\x20'+c+'\x20(decimals:\x20'+b+';\x20raw:\x20'+d+')':e+'\x20(decimals:\x20'+b+';\x20raw:\x20'+d+')';}export async function convertTokenValue(a,b,c){const d=await resolveTokenByType(a,c),f=d?.['decimals'],g=d?.['symbol']||undefined,h={'token_type':a,'symbol':g,'decimals':f};if(b['raw']!==undefined){let j;try{j=BigInt(b['raw'])['toString']();}catch{return{...h,'precision_known':f!==undefined,'direction':'raw_to_unit','input':String(b['raw']),'output':'','error':'Invalid\x20raw\x20value:\x20\x22'+String(b['raw'])+'\x22\x20—\x20expected\x20a\x20non-negative\x20integer\x20(u64\x20smallest\x20units).','text':'Cannot\x20convert:\x20invalid\x20raw\x20value\x20\x22'+String(b['raw'])+'\x22.'};}if(f===undefined)return{...h,'precision_known':![],'direction':'raw_to_unit','input':j,'output':j,'text':j+'\x20raw\x20smallest\x20units\x20(token\x20precision\x20unavailable\x20for\x20'+a+'\x20—\x20'+'cannot\x20convert\x20to\x20unit\x20value.\x20Rule\x20once\x20decimals\x20N\x20is\x20known:\x20unit\x20=\x20raw\x20/\x2010^N.)'};let k=j;try{k=smallestToDisplay(BigInt(j),f);}catch{}return{...h,'precision_known':!![],'direction':'raw_to_unit','input':j,'output':k,'text':g?j+'\x20raw\x20=\x20'+k+'\x20'+g+'\x20(decimals:\x20'+f+';\x201\x20'+g+'\x20=\x2010^'+f+'\x20raw\x20units)':j+'\x20raw\x20=\x20'+k+'\x20(decimals:\x20'+f+';\x201\x20unit\x20=\x2010^'+f+'\x20raw\x20units)'};}const i=String(b['unit']??'')['trim']();if(f===undefined)return{...h,'precision_known':![],'direction':'unit_to_raw','input':i,'output':'','error':'Token\x20precision\x20unavailable\x20for\x20'+a+'\x20—\x20REFUSING\x20to\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units.\x20'+'Guessing\x20decimals\x20would\x20forge\x20a\x20wrong\x20on-chain\x20value.\x20Retry\x20after\x20the\x20precision\x20lookup\x20succeeds,\x20'+'or\x20check\x20the\x20token\x27s\x20coin\x20metadata.','text':'Cannot\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units:\x20token\x20precision\x20unknown\x20for\x20'+a+'.'};try{const l=displayStringToSmallest(i,f);return{...h,'precision_known':!![],'direction':'unit_to_raw','input':i,'output':l['toString'](),'text':g?i+'\x20'+g+'\x20=\x20'+l['toString']()+'\x20raw\x20smallest\x20units\x20(decimals:\x20'+f+';\x201\x20'+g+'\x20=\x2010^'+f+'\x20raw\x20units)':i+'\x20=\x20'+l['toString']()+'\x20raw\x20smallest\x20units\x20(decimals:\x20'+f+';\x201\x20unit\x20=\x2010^'+f+'\x20raw\x20units)'};}catch(m){const n=m instanceof Error?m['message']:String(m);return{...h,'precision_known':!![],'direction':'unit_to_raw','input':i,'output':'','error':n,'text':'Cannot\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units:\x20'+n};}}export const TOKEN_GENERIC_OBJECT_TYPES=['Treasury','Allocation','Arbitration','Arb','Payment','Reward','Service'];export function extractGenericTokenType(a){if(!a||typeof a!=='string')return undefined;const b=a['indexOf']('<');if(b<0x0)return undefined;let c=0x0;for(let d=b;d<a['length'];d++){const e=a[d];if(e==='<')c++;else{if(e==='>'){c--;if(c===0x0)return a['slice'](b+0x1,d)['trim']()||undefined;}}}return undefined;}export async function resolveObjectTokenType(a,b){if(!a||typeof a!=='string')return undefined;const c=isCacheableObjectRef(a),d=cacheNet(b)+'::'+a;if(c){const e=OBJECT_TYPE_CACHE['get'](d);if(e)return e;}try{const {query_objects:f}=await import('@wowok/wowok'),g=await f({'objects':[a],'network':b}),h=g?.['objects']?.[0x0];if(!h)return undefined;const i=h['type_raw']??h['content_raw']?.['type']??undefined,j={'tokenType':extractGenericTokenType(i),'objectType':h['type'],'typeRaw':i};if(c)OBJECT_TYPE_CACHE['set'](d,j);return j;}catch{return undefined;}}export async function resolveOperationObjectTokenType(a,b,c){if(!a)return undefined;if(a['object']&&typeof a['object']==='object'&&typeof a['object']['type_parameter']==='string')return a['object']['type_parameter'];if(b==='payment'&&typeof a['type_parameter']==='string')return a['type_parameter'];if(typeof a['object']==='string'&&a['object']['length']>0x0){const d=await resolveObjectTokenType(a['object'],c);return d?.['tokenType'];}return undefined;}const RECEIVE_TOKEN_FIELDS={'treasury':['receive'],'allocation':['received_coins'],'reward':['receive'],'service':['compensation_fund_receive'],'arbitration':['receive']},COIN_PARAM_FIELDS={'treasury':['deposit.coin'],'allocation':['coin'],'reward':['coin_add'],'arbitration':['dispute.fee'],'service':['compensation_fund_add','order_new.buy.total_pay']};export async function validateOperationTokenMatch(a,b,c,d){const e={'errors':[],'warnings':[],'objectTokenType':c};if(!a||!c)return e;const f=typeof a['object']==='string'?a['object']:'the\x20target\x20object',g=(h,i)=>'TOKEN\x20TYPE\x20MISMATCH\x20('+i+'):\x20'+f+'\x20only\x20accepts\x20'+c+'\x20'+('(its\x20generic\x20token\x20type\x20is\x20fixed\x20and\x20immutable),\x20but\x20'+h+'\x20was\x20provided.\x20')+('Use\x20'+c+'\x20for\x20this\x20operation,\x20or\x20target\x20a\x20different\x20object.');for(const h of RECEIVE_TOKEN_FIELDS[b]??[]){const i=a[h];i&&typeof i==='object'&&typeof i['token_type']==='string'&&i['token_type']!==c&&e['errors']['push'](g(i['token_type'],'field\x20\x27'+h+'.token_type\x27'));}for(const j of COIN_PARAM_FIELDS[b]??[]){const k=getNestedValue(a,j);if(k&&typeof k==='object'&&typeof k['coin']==='string'){const l=k['coin'],m=await resolveObjectTokenType(l,d);if(m?.['tokenType'])m['tokenType']!==c&&e['errors']['push'](g(m['tokenType'],'coin\x20\x27'+l+'\x27\x20at\x20\x27'+j+'\x27'));else m===undefined&&e['warnings']['push']('Could\x20not\x20resolve\x20coin\x20object\x20\x27'+l+'\x27\x20('+j+')\x20to\x20verify\x20its\x20token\x20type\x20'+('matches\x20'+c+'.\x20The\x20on-chain\x20type\x20check\x20will\x20reject\x20a\x20mismatch\x20at\x20execution.'));}}return e;}const OBJECT_MONEY_FIELDS={'Treasury':['balance','inflow','outflow'],'Allocation':['balance'],'Arbitration':['fee','balance'],'Reward':['balance'],'Service':['compensation_fund'],'Payment':['amount'],'Arb':['fee']};export async function annotateObjectMonetaryFields(a,b){if(!a||typeof a!=='object'||typeof a['type']!=='string')return;let c=extractGenericTokenType(a['type_raw']);const d={},e=async(f,g,h)=>{if(g===null||g===undefined)return;if(typeof g!=='string'&&typeof g!=='number'&&typeof g!=='bigint')return;d[f]=h?await formatChainValue(g,h,b):{'raw':String(g),'display':String(g),'token_type':'','precision_known':![],'text':String(g)+'\x20raw\x20smallest\x20units\x20(token\x20type\x20could\x20not\x20be\x20determined\x20for\x20this\x20field\x20—\x20'+'no\x20conversion\x20applied.\x20Showing\x20the\x20true\x20raw\x20value;\x20re-run\x20the\x20query\x20to\x20retry\x20resolution.)'};};if(!c&&(a['type']==='Order'||a['type']==='Discount')&&typeof a['service']==='string')try{const f=await resolveObjectTokenType(a['service'],b);c=f?.['tokenType'];}catch{}for(const g of OBJECT_MONEY_FIELDS[a['type']]??[]){await e(g,a[g],c);}switch(a['type']){case'Service':if(Array['isArray'](a['sales']))for(let h=0x0;h<a['sales']['length'];h++){await e('sales['+h+'].price',a['sales'][h]?.['price'],c);}break;case'Order':await e('amount',a['amount'],c);if(Array['isArray'](a['items']))for(let j=0x0;j<a['items']['length'];j++){await e('items['+j+'].price',a['items'][j]?.['price'],c);}break;case'Payment':if(Array['isArray'](a['record']))for(let k=0x0;k<a['record']['length'];k++){await e('record['+k+'].amount',a['record'][k]?.['amount'],c);}break;case'Reward':if(Array['isArray'](a['guards']))for(let l=0x0;l<a['guards']['length'];l++){const m=a['guards'][l]?.['amount'];m&&typeof m==='object'&&m['type']===0x1&&await e('guards['+l+'].amount.value',m['value'],c);}break;case'Arb':await e('indemnity.amount',a['indemnity']?.['amount'],c);break;case'Discount':await e('benchmark',a['benchmark'],c);a['discount_type']===0x1&&await e('off',a['off'],c);break;}Object['keys'](d)['length']>0x0&&(a['_money_display']=d);}const TABLE_ITEM_MONEY_FIELDS={'TableItem_TreasuryHistory':['amount'],'TableItem_RewardRecord':['total']};export async function resolveParentObjectTokenType(a,b){const c=await resolveObjectTokenType(a,b);if(!c)return undefined;if(c['objectType']&&TOKEN_GENERIC_OBJECT_TYPES['includes'](c['objectType']))return c['tokenType'];return undefined;}export async function annotateTableItemMonetaryFields(a,b,c){if(!a||typeof a!=='object'||typeof a['type']!=='string')return;const d={},e=async(f,g)=>{if(g===null||g===undefined)return;if(typeof g!=='string'&&typeof g!=='number'&&typeof g!=='bigint')return;d[f]=b?await formatChainValue(g,b,c):{'raw':String(g),'display':String(g),'token_type':'','precision_known':![],'text':String(g)+'\x20raw\x20smallest\x20units\x20(parent\x20object\x20token\x20type\x20could\x20not\x20'+'be\x20resolved\x20—\x20no\x20conversion\x20applied)'};};for(const f of TABLE_ITEM_MONEY_FIELDS[a['type']]??[]){await e(f,a[f]);}if(a['type']==='TableItem_RewardRecord'&&Array['isArray'](a['record']))for(let g=0x0;g<a['record']['length'];g++){await e('record['+g+'].amount',a['record'][g]?.['amount']);}Object['keys'](d)['length']>0x0&&(a['_money_display']=d);}export async function annotateEventMonetaryFields(a,b){if(!a||typeof a!=='object')return;const c=a['type']==='NewOrderEvent'||typeof a['type']==='string'&&a['type']['includes']('::order::NewOrderEvent');if(!c)return;const d=a['parsedJson_raw']??{},e=a['amount']??d['amount'];if(e===null||e===undefined)return;if(typeof e!=='string'&&typeof e!=='number'&&typeof e!=='bigint')return;let f;const g=a['service']??d['service'];if(typeof g==='string'&&g)try{f=(await resolveObjectTokenType(g,b))?.['tokenType'];}catch{}a['_money_display']={'amount':f?await formatChainValue(e,f,b):{'raw':String(e),'display':String(e),'token_type':'','precision_known':![],'text':String(e)+'\x20raw\x20smallest\x20units\x20(order\x27s\x20Service\x20token\x20type\x20could\x20not\x20be\x20'+'resolved\x20—\x20showing\x20the\x20true\x20raw\x20value;\x20re-run\x20the\x20query\x20to\x20retry.)'}};}export async function annotateEventsMonetaryFields(a,b){if(!Array['isArray'](a))return;for(const c of a){try{await annotateEventMonetaryFields(c,b);}catch{}}}export async function annotateBalanceChanges(a,b){if(!Array['isArray'](a))return;for(const c of a){try{const d=c?.['coin_type'],e=c?.['amount'];if(typeof d!=='string'||!d)continue;if(typeof e!=='string'&&typeof e!=='number'&&typeof e!=='bigint')continue;c['_money_display']={'amount':await formatChainValue(e,d,b)};}catch{}}}export async function prepareFundOperation(a,b,c){const d=await resolveOperationObjectTokenType(a,b,c),e=await validateOperationTokenMatch(a,b,d,c),f=await processFundOperation(a,b,c,{'objectTokenType':d});return{...f,'warnings':[...e['warnings'],...f['warnings']],'matchErrors':e['errors'],'blockingErrors':[...e['errors'],...f['errors']],'objectTokenType':d};}
|
|
1
|
+
import{GasTokenType,WOW_DECIMALS,MAINNET_BRIDGE_CONFIG,formatUnits,parseToUnits,extractGenericTypeArg}from'@wowok/wowok';const GAS_TOKENS=[{'type':GasTokenType,'symbol':'WOW','decimals':WOW_DECIMALS,'name':'Wowok\x20Token','description':'Default\x20platform\x20gas\x20token\x20for\x20all\x20WoWok\x20operations.\x201\x20WOW\x20=\x2010^'+WOW_DECIMALS+'\x20MIST.\x20Available\x20on\x20testnet\x20and\x20mainnet.'}],TESTNET_TOKENS=[];function buildMainnetTokensFromSDK(){const a=MAINNET_BRIDGE_CONFIG?.['tokens'];if(!Array['isArray'](a))return[];const b=new Set();return a['filter'](c=>{if(b['has'](c['wowTypeTag']))return![];return b['add'](c['wowTypeTag']),!![];})['map'](c=>{const d=c['wowTypeTag']['split']('::')['pop']()??c['symbol'];return{'type':c['wowTypeTag'],'symbol':d,'decimals':c['wowDecimals'],'name':c['symbol']+'\x20(Bridge)','description':c['description']??'Bridge\x20token\x20on\x20WOW\x20mainnet.\x20'+c['wowDecimals']+'\x20decimals.'};});}export const OFFICIAL_TOKEN_REGISTRY={'gas':GAS_TOKENS,'testnet':TESTNET_TOKENS,'mainnet':buildMainnetTokensFromSDK()};export function getRegistryForNetwork(a){return[...OFFICIAL_TOKEN_REGISTRY['gas'],...a==='testnet'?OFFICIAL_TOKEN_REGISTRY['testnet']:[],...a==='mainnet'?OFFICIAL_TOKEN_REGISTRY['mainnet']:[]];}export function findInRegistryByType(a,b){const c=OFFICIAL_TOKEN_REGISTRY['gas']['find'](e=>e['type']===a);if(c)return c;const d=getRegistryForNetwork(b);return d['find'](e=>e['type']===a);}export function findInRegistryBySymbol(a,b){const c=a['toLowerCase'](),d=OFFICIAL_TOKEN_REGISTRY['gas']['filter'](g=>g['symbol']['toLowerCase']()===c),e=getRegistryForNetwork(b),f=e['filter'](g=>g['symbol']['toLowerCase']()===c&&!d['some'](h=>h['type']===g['type']));return[...d,...f];}export async function resolveTokenByType(a,b){const c=findInRegistryByType(a,b);if(c)return{'type':c['type'],'symbol':c['symbol'],'decimals':c['decimals'],'name':c['name'],'source':'registry','verified':!![]};const d=b!==undefined,e=cacheNet(b)+'::'+a;if(d){const f=RESOLUTION_CACHE['get'](e);if(f)return f;}try{const {TokenInfo:g}=await import('@wowok/wowok'),h=g['Instance'](),i=await h['fetch'](a,undefined,b);if(i){const j={'type':i['type'],'symbol':i['symbol']??'','decimals':i['decimals'],'name':i['name']??'','source':'cache','verified':![]};if(d)RESOLUTION_CACHE['set'](e,j);return j;}}catch{}return undefined;}export async function resolveTokensBySymbol(a,b,c){const d=[],e=findInRegistryBySymbol(a,b);for(const f of e){d['push']({'type':f['type'],'symbol':f['symbol'],'decimals':f['decimals'],'name':f['name'],'source':'registry','verified':!![]});}try{const {query_local_token_list:g}=await import('@wowok/wowok'),h=await g({'symbol':a},b);for(const i of h){if(d['some'](j=>j['type']===i['type']))continue;d['push']({'type':i['type'],'symbol':i['symbol']??'','decimals':i['decimals']??0x0,'name':i['name']??'','source':'cache','verified':![]});}}catch{}return c&&d['sort']((j,k)=>{if(j['type']===c)return-0x1;if(k['type']===c)return 0x1;if(j['verified']&&!k['verified'])return-0x1;if(!j['verified']&&k['verified'])return 0x1;return 0x0;}),d;}const AMOUNT_WITH_SYMBOL=/^(\d+(?:\.\d+)?)\s*([A-Za-z][A-Za-z0-9]*)$/;export function isAmountWithSymbol(a){if(typeof a!=='string')return![];const b=a['match'](AMOUNT_WITH_SYMBOL);if(!b)return![];const c=b[0x2];return c['length']>=0x2&&c['length']<=0xa;}export async function parseAmount(a,b,c){const d=a,e=await resolveTokenByType(b,c),f=e!==undefined,g=e?.['decimals']??0x9,h=e?.['symbol']??'',i=e?.['source']??'onchain',j=e?.['verified']??![];if(typeof a==='string'){const m=a['match'](AMOUNT_WITH_SYMBOL);if(m){const n=m[0x1],o=m[0x2];if(!f){const q=await resolveTokensBySymbol(o,c);if(q['length']>0x0){const r=q['length']>0x1?'MULTIPLE\x20issuers':'an\x20issuer';throw new Error('TOKEN\x20CHOICE\x20REQUIRED:\x20\x22'+a+'\x22\x20uses\x20symbol\x20\x22'+o+'\x22\x20which\x20matches\x20'+r+'\x20'+('on\x20this\x20network'+(q['length']>0x1?'\x20('+q['length']+'\x20candidates\x20—\x20the\x20bare\x20symbol\x20is\x20ambiguous)':'')+'.\x20')+'The\x20operation\x20is\x20REFUSED\x20until\x20you\x20present\x20these\x20candidates\x20to\x20the\x20USER\x20and\x20let\x20the\x20user\x20choose\x20'+'(the\x20user\x20may\x20answer\x20by\x20the\x20candidate\x20NUMBER,\x20e.g.\x20\x222\x22,\x20or\x20by\x20pasting\x20the\x20full\x20type).\x20'+'Then\x20re-issue\x20the\x20operation\x20with\x20the\x20chosen\x20token\x27s\x20FULL\x20type\x20string\x20in\x20type_parameter\x20'+'(package::module::Name)\x20—\x20a\x20bare\x20symbol\x20cannot\x20identify\x20the\x20issuer,\x20and\x20you\x20must\x20NEVER\x20guess\x20one.\x0a'+('\x20\x20Candidates\x20for\x20symbol\x20\x22'+o+'\x22:\x0a')+formatTokenCandidates(q)+'\x0a'+'\x20\x20After\x20choosing,\x20also\x20verify\x20the\x20WOW\x20network\x20selection\x20is\x20correct.');}throw new Error('MISSING\x20TOKEN\x20INFO:\x20cannot\x20convert\x20\x22'+a+'\x22\x20for\x20token\x20type\x20'+b+'\x20—\x20'+'the\x20token\x27s\x20precision\x20(decimals)\x20could\x20not\x20be\x20resolved\x20from\x20the\x20official\x20'+('registry,\x20local\x20cache,\x20or\x20on-chain\x20metadata,\x20and\x20no\x20token\x20with\x20symbol\x20\x22'+o+'\x22\x20')+'is\x20known\x20on\x20this\x20network.\x20Converting\x20a\x20unit\x20value\x20without\x20decimals\x20would\x20forge\x20a\x20'+'wrong\x20on-chain\x20amount\x20and\x20risk\x20asset\x20loss,\x20so\x20the\x20operation\x20is\x20REFUSED.\x20'+precisionUnknownGuidance(b,c));}if(h&&o['toLowerCase']()!==h['toLowerCase']()){const s=await resolveTokensBySymbol(o,c);if(s['length']>0x0){const t=s['length']>0x1?'multiple\x20issuers':'an\x20issuer';throw new Error('TOKEN\x20CHOICE\x20REQUIRED:\x20the\x20amount\x20\x22'+a+'\x22\x20uses\x20symbol\x20\x22'+o+'\x22,\x20but\x20the\x20operation\x27s\x20'+('token\x20is\x20currently\x20\x22'+h+'\x22\x20(type:\x20'+b+').\x20\x22'+o+'\x22\x20matches\x20'+t+'\x20on\x20this\x20')+('network'+(s['length']>0x1?'\x20('+s['length']+'\x20candidates\x20—\x20the\x20bare\x20symbol\x20is\x20ambiguous)':'')+'.\x20')+'Present\x20these\x20candidates\x20to\x20the\x20USER\x20and\x20let\x20the\x20user\x20choose\x20(the\x20user\x20may\x20answer\x20by\x20the\x20candidate\x20'+'NUMBER,\x20e.g.\x20\x222\x22,\x20or\x20by\x20pasting\x20the\x20full\x20type),\x20then\x20re-issue\x20with\x20the\x20chosen\x20token\x27s\x20FULL\x20type\x20in\x20'+'type_parameter\x20(package::module::Name)\x20—\x20never\x20guess\x20an\x20issuer.\x20The\x20operation\x20was\x20NOT\x20executed.\x0a'+('\x20\x20Candidates\x20for\x20symbol\x20\x22'+o+'\x22:\x0a')+formatTokenCandidates(s)+'\x0a'+('\x20\x20If\x20\x22'+h+'\x22\x20('+b+')\x20was\x20intended\x20instead,\x20write\x20the\x20amount\x20with\x20that\x20symbol\x20(e.g.\x20\x22'+n+h+'\x22).'));}throw new Error('Amount\x20symbol\x20\x22'+o+'\x22\x20does\x20not\x20match\x20the\x20resolved\x20token\x20symbol\x20\x22'+h+'\x22\x20'+('(token\x20type:\x20'+b+'),\x20and\x20no\x20token\x20with\x20symbol\x20\x22'+o+'\x22\x20is\x20known\x20on\x20this\x20network.\x20')+('Either\x20write\x20the\x20amount\x20with\x20the\x20correct\x20symbol\x20(e.g.\x20\x22'+n+h+'\x22),\x20or\x20—\x20if\x20a\x20')+'DIFFERENT\x20token\x20was\x20intended\x20—\x20provide\x20that\x20token\x27s\x20FULL\x20type\x20in\x20package::module::Name\x20form\x20in\x20'+'type_parameter\x20(a\x20bare\x20symbol\x20cannot\x20be\x20resolved).\x20'+knownTokenSuggestions(c));}const p=parseToUnits(n,g);return{'smallestUnit':p,'displayAmount':n+'\x20'+o,'originalInput':d,'tokenType':b,'tokenSymbol':h||o,'decimals':g,'converted':!![],'source':i,'verified':j,'precision_known':!![]};}}if(typeof a==='number'&&!Number['isSafeInteger'](a))throw new Error('Amount\x20'+a+'\x20is\x20outside\x20the\x20safe\x20integer\x20range\x20(±2^53\x20=\x20±9007199254740991):\x20'+'JS\x20numbers\x20lose\x20integer\x20precision\x20beyond\x20this\x20point.\x20Pass\x20the\x20raw\x20u64\x20as\x20a\x20NUMERIC\x20'+'STRING\x20(e.g.\x20\x229000000000000000000\x22)\x20or\x20a\x20display\x20string\x20with\x20the\x20token\x20symbol\x20'+'(e.g.\x20\x222.5WOW\x22).');if(typeof a==='string'&&!/^\d+$/['test'](a['trim']()))throw new Error('Invalid\x20raw\x20amount:\x20\x22'+a+'\x22.\x20Smallest-unit\x20amounts\x20must\x20be\x20non-negative\x20integer\x20'+'strings\x20(e.g.\x20\x222500000000\x22).\x20Decimal\x20unit\x20values\x20must\x20carry\x20the\x20token\x20symbol\x20'+'(e.g.\x20\x222.5WOW\x22)\x20so\x20the\x20Fund\x20Processing\x20Layer\x20can\x20convert\x20them\x20with\x20the\x20token\x27s\x20decimals.');let k;try{k=BigInt(a);}catch{throw new Error('Invalid\x20amount:\x20\x22'+a+'\x22.\x20Expected\x20a\x20number,\x20a\x20numeric\x20string\x20(smallest\x20unit),\x20'+'or\x20a\x20display-format\x20string\x20like\x20\x222.5WOW\x22\x20(matching\x20the\x20token\x27s\x20symbol).');}const l=f?formatUnits(k,g):k['toString']()+'\x20raw\x20smallest\x20units\x20(token\x20precision\x20unknown)';return{'smallestUnit':k,'displayAmount':f&&h?l+'\x20'+h:l,'originalInput':d,'tokenType':b,'tokenSymbol':h,'decimals':g,'converted':![],'source':i,'verified':j,'precision_known':f};}function formatTokenCandidates(a,b){return a['map']((d,e)=>{const f=d['verified']?'\x20[VERIFIED\x20—\x20official\x20registry]':'\x20[UNVERIFIED\x20—\x20on-chain\x20metadata]',g=d['name']?'\x20\x22'+d['name']+'\x22':'',h=b&&d['type']===b?'\x20\x20<--\x20USED\x20BY\x20THIS\x20OPERATION\x20(the\x20pinned\x20token\x20—\x20verify\x20before\x20approving)':'';return'\x20\x20\x20\x20\x20\x20'+(e+0x1)+'.\x20'+(d['symbol']??'')+g+'\x20—\x20full\x20type:\x20'+d['type']+'\x20('+(d['decimals']??'?')+'\x20decimals'+f+(d['source']?',\x20source:\x20'+d['source']:'')+')'+h;})['join']('\x0a');}export function generateFundConfirmation(a,b=[]){const c=b['length']>0x0,d=a[0x0]?.['tokenType'],e=['MONEY\x20TRANSACTION\x20CONFIRMATION\x20REQUIRED',''];for(const f of a){const g=f['verified']?'VERIFIED\x20—\x20official\x20registry':'UNVERIFIED\x20—\x20cache/on-chain\x20metadata',h=f['tokenSymbol']||'(no\x20symbol)';e['push']('\x20\x20•\x20'+f['context']+':\x20'+f['displayAmount']),e['push']('\x20\x20\x20\x20\x20\x20token:\x20'+h+'\x20—\x20full\x20type:\x20'+f['tokenType']),e['push']('\x20\x20\x20\x20\x20\x20decimals:\x20'+f['decimals']+'\x20(1\x20'+h+'\x20=\x2010^'+f['decimals']+'\x20raw\x20units);\x20'+('raw\x20amount:\x20'+f['smallestUnit']+';\x20'+g+';\x20source:\x20'+f['source'])),f['converted']&&e['push']('\x20\x20\x20\x20\x20\x20(input\x20was\x20a\x20display\x20amount\x20—\x20converted\x20to\x20smallest\x20units\x20with\x20the\x20token\x27s\x20decimals)');}if(c){e['push']('','TOKEN\x20CANDIDATES\x20—\x20multiple\x20on-chain\x20issuers\x20share\x20the\x20same\x20symbol.','The\x20token\x20this\x20operation\x20is\x20actually\x20pinned\x20to\x20is\x20marked','\x22<--\x20USED\x20BY\x20THIS\x20OPERATION\x22.\x20Verify\x20it\x20is\x20the\x20intended\x20issuer','BEFORE\x20approving.\x20If\x20it\x20is\x20wrong,\x20do\x20NOT\x20approve\x20—\x20re-issue\x20the','operation\x20with\x20the\x20chosen\x20token\x27s\x20FULL\x20type\x20string','(package::module::Name)\x20in\x20type_parameter;\x20a\x20bare\x20symbol\x20can\x20never','identify\x20the\x20issuer.');for(const i of b){e['push']('\x20\x20Symbol\x20\x22'+i['symbol']+'\x22\x20matches\x20these\x20tokens:'),e['push'](formatTokenCandidates(i['candidates'],d));}}return e['push']('','This\x20operation\x20involves\x20money.\x20Please\x20confirm\x20before\x20proceeding.'),{'requiresConfirmation':!![],'reason':c?'Money\x20transaction\x20—\x20user\x20must\x20verify\x20the\x20pinned\x20token\x20among\x20same-symbol\x20candidates\x20before\x20approving':'Money\x20transaction\x20requires\x20user\x20confirmation','fields':a,'ambiguities':b,'message':e['join']('\x0a')};}function extractTokenType(a,b,c){if(a?.['object']&&typeof a['object']==='object'&&a['object']['type_parameter'])return a['object']['type_parameter'];if(b==='payment'&&a?.['type_parameter'])return a['type_parameter'];if(c)return c;return GasTokenType;}function isFixedAmount(a){return a?.['type']==='Fixed';}function isAmountModeSharing(a){return a?.['mode']==='Amount';}const MONETARY_FIELDS={'service':[{'path':'sales.sales.price','context':'Service\x20sale\x20price'},{'path':'compensation_fund_add.balance','context':'Service\x20compensation\x20fund\x20deposit'},{'path':'order_new.buy.total_pay.balance','context':'Order\x20payment\x20amount'},{'path':'discount.discount_value','context':'Discount\x20value'},{'path':'order_allocators.threshold','context':'Service\x20order\x20allocation\x20threshold'},{'path':'order_allocators.allocators.sharing.sharing','context':'Service\x20order\x20allocation\x20sharing\x20amount\x20(Amount\x20mode)','filter':isAmountModeSharing},{'path':'order_allocators.allocators.max','context':'Service\x20order\x20allocation\x20cap'}],'arbitration':[{'path':'dispute.fee.balance','context':'Arbitration\x20dispute\x20fee'},{'path':'fee','context':'Arbitration\x20fee'},{'path':'arbitration.indemnity','context':'Arbitration\x20verdict\x20indemnity'}],'reward':[{'path':'coin_add.balance','context':'Reward\x20coin\x20add'},{'path':'guard_add.amount.value','context':'Reward\x20guard\x20fixed\x20amount','filter':isFixedAmount}],'treasury':[{'path':'deposit.coin.balance','context':'Treasury\x20deposit\x20amount'},{'path':'withdraw.amount.fixed','context':'Treasury\x20withdrawal\x20amount'}],'payment':[{'path':'revenue.amount.balance','context':'Payment\x20amount'}],'allocation':[{'path':'coin.balance','context':'Allocation\x20funding\x20amount'},{'path':'allocators.threshold','context':'Allocation\x20threshold'},{'path':'allocators.allocators.sharing.sharing','context':'Allocation\x20sharing\x20amount\x20(Amount\x20mode)','filter':isAmountModeSharing},{'path':'allocators.allocators.max','context':'Allocation\x20cap'}]};function getNestedValue(a,b){const c=b['split']('.');let d=a;for(const e of c){if(d==null)return undefined;d=d[e];}return d;}function resolveMonetaryLeaves(a,b){const c=b['split']('.'),d=[],e=(f,g,h)=>{if(f==null)return;const j=c[g];if(g===c['length']-0x1){f[j]!=null&&d['push']({'parent':f,'key':j,'displayPath':h+j});return;}const k=f[j];if(Array['isArray'](k))for(let l=0x0;l<k['length'];l++){e(k[l],g+0x1,''+h+j+'['+l+'].');}else e(k,g+0x1,''+h+j+'.');};return e(a,0x0,''),d;}export async function processFundOperation(a,b,c,d){const e={'convertedData':a,'warnings':[],'errors':[],'confirmation':null},f=MONETARY_FIELDS[b];if(!f)return e;const g=extractTokenType(a,b,d?.['objectTokenType']),h=[],i=[],j=new Map();for(const k of f){const l=resolveMonetaryLeaves(a,k['path']);for(const m of l){if(k['filter']&&!k['filter'](m['parent']))continue;await processSingleField(m['parent'],m['key'],m['displayPath'],k['context'],g,c,e,h,i,j);}}if(h['length']>0x0){e['confirmation']=generateFundConfirmation(h,i);const n=h['length'],o=h['some'](q=>!q['verified']),p=i['length']>0x0;p&&e['warnings']['push']('TOKEN\x20CANDIDATES:\x20'+i['length']+'\x20token\x20symbol(s)\x20have\x20multiple\x20on-chain\x20issuers.\x20'+'The\x20confirmation\x20message\x20lists\x20every\x20candidate\x20with\x20full\x20details\x20and\x20marks\x20the\x20token\x20'+'pinned\x20by\x20this\x20operation.\x20Present\x20the\x20list\x20to\x20the\x20USER\x20and\x20verify\x20the\x20pinned\x20issuer\x20is\x20'+'the\x20intended\x20one\x20before\x20approving;\x20if\x20it\x20is\x20wrong,\x20do\x20NOT\x20proceed\x20—\x20re-issue\x20with\x20the\x20'+'chosen\x20token\x27s\x20FULL\x20type\x20string\x20(package::module::Name)\x20in\x20type_parameter.'),o&&e['warnings']['push']('UNVERIFIED\x20TOKEN:\x20some\x20monetary\x20fields\x20use\x20tokens\x20not\x20in\x20the\x20official\x20registry.\x20'+'Precision\x20was\x20resolved\x20from\x20cache/on-chain.\x20Verify\x20the\x20token\x20type\x20before\x20proceeding.'),e['warnings']['push']('MONEY\x20CONFIRMATION:\x20'+n+'\x20monetary\x20field(s)\x20require\x20user\x20confirmation.\x20'+('Token\x20type:\x20'+g+'.\x20Use\x20env.confirmed=true\x20after\x20user\x20consent.'));}return e;}async function processSingleField(a,b,c,d,e,f,g,h,i,j){const k=a[b];if(k==null)return;try{const l=await parseAmount(k,e,f);if(!l['precision_known']){g['errors']['push']('FUND\x20INPUT\x20BLOCKED\x20at\x20'+c+':\x20MISSING\x20TOKEN\x20INFO\x20for\x20'+e+'\x20—\x20'+('precision\x20(decimals)\x20could\x20not\x20be\x20resolved.\x20The\x20value\x20'+JSON['stringify'](k)+'\x20was\x20')+'NOT\x20converted,\x20confirmed,\x20or\x20submitted;\x20no\x20on-chain\x20action\x20was\x20taken.\x20'+precisionUnknownGuidance(e,f));return;}l['converted']&&(a[b]=l['smallestUnit']['toString']());h['push']({'path':c,'displayAmount':l['displayAmount'],'tokenType':l['tokenType'],'tokenSymbol':l['tokenSymbol'],'decimals':l['decimals'],'smallestUnit':l['smallestUnit']['toString'](),'verified':l['verified'],'source':l['source'],'converted':l['converted'],'context':d});if(l['tokenSymbol']){const m=l['tokenSymbol']['toLowerCase']();let n=j['get'](m);if(!n){const o=await resolveTokensBySymbol(l['tokenSymbol'],f,e);o['length']>0x1&&(n=o,j['set'](m,n),i['push']({'symbol':l['tokenSymbol'],'candidates':n['map'](p=>({'type':p['type'],'symbol':p['symbol'],'name':p['name'],'decimals':p['decimals'],'source':p['source'],'verified':p['verified']}))}));}}}catch(p){g['errors']['push']('FUND\x20INPUT\x20BLOCKED\x20at\x20'+c+':\x20'+p['message']);}}export function generateSkillsHint(a){if(!a||!a['requiresConfirmation'])return null;const b=a['ambiguities']['length']>0x0;if(b)return'SKILLS\x20HINT:\x20This\x20money\x20transaction\x20uses\x20a\x20token\x20symbol\x20shared\x20by\x20multiple\x20'+'on-chain\x20issuers.\x20The\x20confirmation\x20message\x20lists\x20ALL\x20candidates\x20with\x20full\x20'+'details\x20and\x20marks\x20the\x20token\x20pinned\x20by\x20this\x20operation.\x20Present\x20the\x20list\x20to\x20'+'the\x20user,\x20verify\x20the\x20pinned\x20issuer\x20is\x20the\x20intended\x20one,\x20and\x20proceed\x20only\x20'+'after\x20explicit\x20consent\x20(env.confirmed=true).\x20If\x20the\x20pinned\x20token\x20is\x20wrong,\x20'+'do\x20NOT\x20proceed\x20—\x20the\x20user\x20must\x20re-issue\x20with\x20the\x20chosen\x20token\x27s\x20FULL\x20type\x20'+'string\x20in\x20type_parameter;\x20never\x20guess\x20an\x20issuer\x20from\x20the\x20bare\x20symbol.';return'SKILLS\x20HINT:\x20This\x20money\x20transaction\x20requires\x20user\x20confirmation.\x20'+'If\x20the\x20wowok-safety\x20skill\x20is\x20installed,\x20it\x20provides\x20R1-R10\x20confirmation\x20'+'dialogue\x20scripts.\x20Otherwise,\x20present\x20the\x20confirmation\x20message\x20to\x20the\x20user\x20'+'and\x20proceed\x20only\x20after\x20explicit\x20consent\x20(env.confirmed=true).';}export async function formatChainValue(a,b,c){let d;try{d=BigInt(a)['toString']();}catch{d=String(a);}const e=await resolveTokenByType(b,c);if(e&&typeof e['decimals']==='number'){let f=d;try{f=formatUnits(BigInt(d),e['decimals']);}catch{}const g=e['symbol']||'',h=g?f+'\x20'+g+'\x20(decimals:\x20'+e['decimals']+';\x201\x20'+g+'\x20=\x2010^'+e['decimals']+'\x20raw\x20units;\x20raw:\x20'+d+')':f+'\x20(decimals:\x20'+e['decimals']+';\x201\x20unit\x20=\x2010^'+e['decimals']+'\x20raw\x20units;\x20raw:\x20'+d+')';return{'raw':d,'display':f,'symbol':g||undefined,'decimals':e['decimals'],'token_type':b,'precision_known':!![],'text':h};}return{'raw':d,'display':d,'token_type':b,'precision_known':![],'text':d+'\x20raw\x20smallest\x20units\x20—\x20RISK:\x20token\x20precision\x20unavailable\x20for\x20'+b+';\x20'+'this\x20is\x20the\x20true\x20on-chain\x20RAW\x20value,\x20NOT\x20a\x20unit\x20value,\x20and\x20its\x20magnitude\x20cannot\x20be\x20'+'verified\x20(unit\x20=\x20raw\x20/\x2010^N\x20once\x20decimals\x20N\x20are\x20known).\x20'+precisionUnknownRawSuffix()+'\x20'+precisionUnknownGuidance(b,c)};}export function registryDisplayHint(a,b){if(!a)return undefined;const c=findInRegistryByType(a,b);if(!c)return undefined;return{'decimals':c['decimals'],'symbol':c['symbol']};}const RESOLUTION_CACHE=new Map(),OBJECT_TYPE_CACHE=new Map();function cacheNet(a){return a??'default';}function isCacheableObjectRef(a){return/^0x[0-9a-fA-F]{20,}$/['test'](a);}export function clearFundResolutionCaches(){RESOLUTION_CACHE['clear'](),OBJECT_TYPE_CACHE['clear']();}export function knownTokenSuggestions(a){const b=getRegistryForNetwork(a)['map'](c=>c['symbol']+'\x20('+c['type']+',\x20'+c['decimals']+'\x20decimals)');return b['length']>0x0?'Known\x20tokens\x20on\x20this\x20network:\x20'+b['join'](';\x20')+'.':'No\x20officially-known\x20tokens\x20on\x20this\x20network.';}function precisionUnknownGuidance(a,b){const c=b?'network\x20'+b:'the\x20currently\x20selected\x20network';return'To\x20recover:\x20(1)\x20provide\x20the\x20token\x27s\x20FULL\x20type\x20in\x20package::module::Name\x20form\x20'+'(e.g.\x200xFULLPACKAGEID::usdt::USDT\x20—\x20a\x20bare\x20symbol\x20such\x20as\x20\x22USDT\x22\x20cannot\x20be\x20resolved)\x20'+'in\x20type_parameter,\x20so\x20the\x20on-chain\x20coin\x20metadata\x20can\x20be\x20looked\x20up;\x20'+('(2)\x20verify\x20the\x20WOW\x20NETWORK\x20selection\x20is\x20correct\x20—\x20the\x20token\x20may\x20not\x20exist\x20on\x20'+c+';\x20')+'(3)\x20retry,\x20as\x20the\x20on-chain\x20metadata\x20lookup\x20may\x20have\x20failed\x20transiently.\x20'+knownTokenSuggestions(b);}function precisionUnknownRawSuffix(){return'Magnitude\x20cannot\x20be\x20verified\x20—\x20verify\x20the\x20token\x20type\x20and\x20WOW\x20network,\x20then\x20re-run.';}export function formatAmountText(a,b,c){let d;try{d=BigInt(a)['toString']();}catch{d=String(a);}if(b===undefined)return d+'\x20smallest\x20units\x20(token\x20precision\x20unknown)';let e=d;try{e=formatUnits(BigInt(d),b);}catch{}return c?e+'\x20'+c+'\x20(decimals:\x20'+b+';\x20raw:\x20'+d+')':e+'\x20(decimals:\x20'+b+';\x20raw:\x20'+d+')';}export async function convertTokenValue(a,b,c){const d=await resolveTokenByType(a,c),f=d?.['decimals'],g=d?.['symbol']||undefined,h={'token_type':a,'symbol':g,'decimals':f};if(b['raw']!==undefined){let j;try{j=BigInt(b['raw'])['toString']();}catch{return{...h,'precision_known':f!==undefined,'direction':'raw_to_unit','input':String(b['raw']),'output':'','error':'Invalid\x20raw\x20value:\x20\x22'+String(b['raw'])+'\x22\x20—\x20expected\x20a\x20non-negative\x20integer\x20(u64\x20smallest\x20units).','text':'Cannot\x20convert:\x20invalid\x20raw\x20value\x20\x22'+String(b['raw'])+'\x22.'};}if(f===undefined)return{...h,'precision_known':![],'direction':'raw_to_unit','input':j,'output':j,'text':j+'\x20raw\x20smallest\x20units\x20—\x20RISK:\x20token\x20precision\x20unavailable\x20for\x20'+a+';\x20'+'this\x20is\x20the\x20true\x20on-chain\x20RAW\x20value,\x20NOT\x20a\x20unit\x20value,\x20and\x20its\x20magnitude\x20cannot\x20'+'be\x20verified\x20(unit\x20=\x20raw\x20/\x2010^N\x20once\x20decimals\x20N\x20are\x20known).\x20'+precisionUnknownRawSuffix()};let k=j;try{k=formatUnits(BigInt(j),f);}catch{}return{...h,'precision_known':!![],'direction':'raw_to_unit','input':j,'output':k,'text':g?j+'\x20raw\x20=\x20'+k+'\x20'+g+'\x20(decimals:\x20'+f+';\x201\x20'+g+'\x20=\x2010^'+f+'\x20raw\x20units)':j+'\x20raw\x20=\x20'+k+'\x20(decimals:\x20'+f+';\x201\x20unit\x20=\x2010^'+f+'\x20raw\x20units)'};}const i=String(b['unit']??'')['trim']();if(f===undefined)return{...h,'precision_known':![],'direction':'unit_to_raw','input':i,'output':'','error':'MISSING\x20TOKEN\x20INFO:\x20cannot\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units\x20for\x20token\x20type\x20'+a+'\x20—\x20'+'token\x20precision\x20(decimals)\x20is\x20unavailable.\x20Guessing\x20decimals\x20would\x20forge\x20a\x20wrong\x20on-chain\x20'+'value\x20and\x20risk\x20asset\x20loss,\x20so\x20the\x20conversion\x20is\x20REFUSED.\x20'+precisionUnknownGuidance(a,c),'text':'Cannot\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units:\x20token\x20precision\x20unknown\x20for\x20'+a+'.'};try{const l=parseToUnits(i,f);return{...h,'precision_known':!![],'direction':'unit_to_raw','input':i,'output':l['toString'](),'text':g?i+'\x20'+g+'\x20=\x20'+l['toString']()+'\x20raw\x20smallest\x20units\x20(decimals:\x20'+f+';\x201\x20'+g+'\x20=\x2010^'+f+'\x20raw\x20units)':i+'\x20=\x20'+l['toString']()+'\x20raw\x20smallest\x20units\x20(decimals:\x20'+f+';\x201\x20unit\x20=\x2010^'+f+'\x20raw\x20units)'};}catch(m){const n=m instanceof Error?m['message']:String(m);return{...h,'precision_known':!![],'direction':'unit_to_raw','input':i,'output':'','error':n,'text':'Cannot\x20convert\x20\x22'+i+'\x22\x20to\x20raw\x20units:\x20'+n};}}export const TOKEN_GENERIC_OBJECT_TYPES=['Treasury','Allocation','Arbitration','Arb','Payment','Reward','Service'];export const extractGenericTokenType=extractGenericTypeArg;export async function resolveObjectTokenType(a,b){if(!a||typeof a!=='string')return undefined;const c=isCacheableObjectRef(a)&&b!==undefined,d=cacheNet(b)+'::'+a;if(c){const e=OBJECT_TYPE_CACHE['get'](d);if(e)return e;}try{const {query_object_token_type:f}=await import('@wowok/wowok'),[g]=await f({'objects':[a],'network':b});if(!g?.['object'])return undefined;const h={'tokenType':g['coin_type'],'objectType':g['object_type'],'typeRaw':g['type_raw']};if(c)OBJECT_TYPE_CACHE['set'](d,h);return h;}catch{return undefined;}}export async function resolveOperationObjectTokenType(a,b,c){if(!a)return undefined;if(a['object']&&typeof a['object']==='object'&&typeof a['object']['type_parameter']==='string')return a['object']['type_parameter'];if(b==='payment'&&typeof a['type_parameter']==='string')return a['type_parameter'];if(typeof a['object']==='string'&&a['object']['length']>0x0){const d=await resolveObjectTokenType(a['object'],c);return d?.['tokenType'];}return undefined;}const RECEIVE_TOKEN_FIELDS={'treasury':['receive'],'allocation':['received_coins'],'reward':['receive'],'service':['compensation_fund_receive'],'arbitration':['receive']},COIN_PARAM_FIELDS={'treasury':['deposit.coin'],'allocation':['coin'],'reward':['coin_add'],'arbitration':['dispute.fee'],'service':['compensation_fund_add','order_new.buy.total_pay']};export async function validateOperationTokenMatch(a,b,c,d){const e={'errors':[],'warnings':[],'objectTokenType':c};if(!a||!c)return e;const f=typeof a['object']==='string'?a['object']:'the\x20target\x20object',g=(h,i)=>'TOKEN\x20TYPE\x20MISMATCH\x20('+i+'):\x20'+f+'\x20only\x20accepts\x20'+c+'\x20'+('(its\x20generic\x20token\x20type\x20is\x20fixed\x20and\x20immutable),\x20but\x20'+h+'\x20was\x20provided.\x20')+('Use\x20'+c+'\x20for\x20this\x20operation,\x20or\x20target\x20a\x20different\x20object.');for(const h of RECEIVE_TOKEN_FIELDS[b]??[]){const i=a[h];i&&typeof i==='object'&&typeof i['token_type']==='string'&&i['token_type']!==c&&e['errors']['push'](g(i['token_type'],'field\x20\x27'+h+'.token_type\x27'));}for(const j of COIN_PARAM_FIELDS[b]??[]){const k=getNestedValue(a,j);if(k&&typeof k==='object'&&typeof k['coin']==='string'){const l=k['coin'],m=await resolveObjectTokenType(l,d);if(m?.['tokenType'])m['tokenType']!==c&&e['errors']['push'](g(m['tokenType'],'coin\x20\x27'+l+'\x27\x20at\x20\x27'+j+'\x27'));else m===undefined&&e['warnings']['push']('Could\x20not\x20resolve\x20coin\x20object\x20\x27'+l+'\x27\x20('+j+')\x20to\x20verify\x20its\x20token\x20type\x20'+('matches\x20'+c+'.\x20The\x20on-chain\x20type\x20check\x20will\x20reject\x20a\x20mismatch\x20at\x20execution.'));}}return e;}const OBJECT_MONEY_FIELDS={'Treasury':['balance','inflow','outflow'],'Allocation':['balance'],'Arbitration':['fee','balance'],'Reward':['balance'],'Service':['compensation_fund'],'Payment':['amount'],'Arb':['fee']};export async function annotateObjectMonetaryFields(a,b){if(!a||typeof a!=='object'||typeof a['type']!=='string')return;let c=extractGenericTokenType(a['type_raw']);const d={},e=async(h,j,k)=>{if(j===null||j===undefined)return;if(typeof j!=='string'&&typeof j!=='number'&&typeof j!=='bigint')return;d[h]=k?await formatChainValue(j,k,b):{'raw':String(j),'display':String(j),'token_type':'','precision_known':![],'text':String(j)+'\x20raw\x20smallest\x20units\x20—\x20RISK:\x20token\x20type\x20could\x20not\x20be\x20determined\x20'+'for\x20this\x20field;\x20this\x20is\x20the\x20true\x20raw\x20value,\x20not\x20a\x20unit\x20value.\x20'+precisionUnknownRawSuffix()};};if(!c&&(a['type']==='Order'||a['type']==='Discount')&&typeof a['service']==='string')try{const h=await resolveObjectTokenType(a['service'],b);c=h?.['tokenType'];}catch{}const f=0x0,g=async(k,l,m)=>{await e(m+'threshold',k,c);if(!Array['isArray'](l))return;for(let n=0x0;n<l['length'];n++){const o=l[n];await e(m+'allocators['+n+'].fix',o?.['fix'],c);o?.['max']!==null&&o?.['max']!==undefined&&await e(m+'allocators['+n+'].max',o['max'],c);if(Array['isArray'](o?.['sharing']))for(let p=0x0;p<o['sharing']['length'];p++){o['sharing'][p]?.['mode']===f&&await e(m+'allocators['+n+'].sharing['+p+'].sharing',o['sharing'][p]['sharing'],c);}}};for(const j of OBJECT_MONEY_FIELDS[a['type']]??[]){await e(j,a[j],c);}switch(a['type']){case'Service':if(Array['isArray'](a['sales']))for(let k=0x0;k<a['sales']['length'];k++){await e('sales['+k+'].price',a['sales'][k]?.['price'],c);}await g(a['order_allocators']?.['threshold'],a['order_allocators']?.['allocators'],'order_allocators.');break;case'Allocation':await g(a['threshold'],a['allocators'],'');break;case'Order':await e('amount',a['amount'],c);if(Array['isArray'](a['items']))for(let l=0x0;l<a['items']['length'];l++){await e('items['+l+'].price',a['items'][l]?.['price'],c);}break;case'Payment':if(Array['isArray'](a['record']))for(let m=0x0;m<a['record']['length'];m++){await e('record['+m+'].amount',a['record'][m]?.['amount'],c);}break;case'Reward':if(Array['isArray'](a['guards']))for(let n=0x0;n<a['guards']['length'];n++){const o=a['guards'][n]?.['amount'];o&&typeof o==='object'&&o['type']===0x1&&await e('guards['+n+'].amount.value',o['value'],c);}break;case'Arb':await e('indemnity.amount',a['indemnity']?.['amount'],c);break;case'Discount':await e('benchmark',a['benchmark'],c);a['discount_type']===0x1&&await e('off',a['off'],c);break;}Object['keys'](d)['length']>0x0&&(a['_money_display']=d);}const TABLE_ITEM_MONEY_FIELDS={'TableItem_TreasuryHistory':['amount'],'TableItem_RewardRecord':['total']};export async function resolveParentObjectTokenType(a,b){const c=await resolveObjectTokenType(a,b);if(!c)return undefined;if(c['objectType']&&TOKEN_GENERIC_OBJECT_TYPES['includes'](c['objectType']))return c['tokenType'];return undefined;}export async function annotateTableItemMonetaryFields(a,b,c){if(!a||typeof a!=='object'||typeof a['type']!=='string')return;const d={},e=async(f,g)=>{if(g===null||g===undefined)return;if(typeof g!=='string'&&typeof g!=='number'&&typeof g!=='bigint')return;d[f]=b?await formatChainValue(g,b,c):{'raw':String(g),'display':String(g),'token_type':'','precision_known':![],'text':String(g)+'\x20raw\x20smallest\x20units\x20—\x20RISK:\x20parent\x20object\x20token\x20type\x20could\x20not\x20'+'be\x20resolved;\x20this\x20is\x20the\x20true\x20raw\x20value,\x20not\x20a\x20unit\x20value.\x20'+precisionUnknownRawSuffix()};};for(const f of TABLE_ITEM_MONEY_FIELDS[a['type']]??[]){await e(f,a[f]);}if(a['type']==='TableItem_RewardRecord'&&Array['isArray'](a['record']))for(let g=0x0;g<a['record']['length'];g++){await e('record['+g+'].amount',a['record'][g]?.['amount']);}Object['keys'](d)['length']>0x0&&(a['_money_display']=d);}const MONEY_EVENTS={'TreasuryEvent':{'tokenSource':'object','fields':['amount']},'RewardClaimEvent':{'tokenSource':'object','fields':['amount','total','balance_left']},'RewardFundEvent':{'tokenSource':'object','fields':['amount','balance']},'AllocationEvent':{'tokenSource':'object','fields':['amount']},'NewPaymentEvent':{'tokenSource':'object','fields':['amount'],'arrayFields':[['record','amount']]},'NewOrderEvent':{'tokenSource':'service','fields':['amount']},'ArbEvent':{'tokenSource':'object','fields':[],'optionFields':['indemnity_amount']}};export async function annotateEventMonetaryFields(a,b){if(!a||typeof a!=='object'||typeof a['type']!=='string')return;const c=a['type']['includes']('::')?a['type']['split']('::')['pop']():a['type'],d=c?MONEY_EVENTS[c]:undefined;if(!d)return;const e=a['parsedJson_raw']??{},g=m=>a[m]??e[m];let h;const j=g(d['tokenSource']);if(typeof j==='string'&&j)try{h=(await resolveObjectTokenType(j,b))?.['tokenType'];}catch{}const k={},l=async(m,n)=>{if(n===null||n===undefined)return;if(typeof n!=='string'&&typeof n!=='number'&&typeof n!=='bigint')return;k[m]=h?await formatChainValue(n,h,b):{'raw':String(n),'display':String(n),'token_type':'','precision_known':![],'text':String(n)+'\x20raw\x20smallest\x20units\x20—\x20RISK:\x20owning\x20object\x20token\x20type\x20could\x20not\x20'+'be\x20resolved;\x20this\x20is\x20the\x20true\x20raw\x20value,\x20not\x20a\x20unit\x20value.\x20'+precisionUnknownRawSuffix()};};for(const m of d['fields']){await l(m,g(m));}for(const n of d['optionFields']??[]){const o=g(n);o!==null&&o!==undefined&&await l(n,o);}for(const [p,q]of d['arrayFields']??[]){const r=g(p);if(Array['isArray'](r))for(let s=0x0;s<r['length'];s++){await l(p+'['+s+'].'+q,r[s]?.[q]);}}Object['keys'](k)['length']>0x0&&(a['_money_display']=k);}export async function annotateEventsMonetaryFields(a,b){if(!Array['isArray'](a))return;for(const c of a){try{await annotateEventMonetaryFields(c,b);}catch{}}}export async function annotateBalanceChanges(a,b){if(!Array['isArray'](a))return;for(const c of a){try{const d=c?.['coin_type'],e=c?.['amount'];if(typeof d!=='string'||!d)continue;if(typeof e!=='string'&&typeof e!=='number'&&typeof e!=='bigint')continue;c['_money_display']={'amount':await formatChainValue(e,d,b)};}catch{}}}export async function prepareFundOperation(a,b,c){const d=await resolveOperationObjectTokenType(a,b,c),e=await validateOperationTokenMatch(a,b,d,c),f=await processFundOperation(a,b,c,{'objectTokenType':d});return{...f,'warnings':[...e['warnings'],...f['warnings']],'matchErrors':e['errors'],'blockingErrors':[...e['errors'],...f['errors']],'objectTokenType':d};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function normAddr(a){if(!a)return'';const b=a['startsWith']('0x')?a['slice'](0x2):a;return b['toLowerCase']();}function isEmptyAddr(a){return a===null||a===undefined||String(a)['trim']()==='';}function balanceIsZero(a){if(a===null||a===undefined)return![];try{return BigInt(String(a))===0x0n;}catch{return![];}}async function fetchRefs(a,b,c){if(a['length']===0x0)return{'objects':[]};try{const d=await c['queryObjects'](a['map'](g=>g['object']),b),f=new Map();for(const g of d??[]){if(!g)continue;const h=normAddr(g?.['object']);if(h)f['set'](h,g);if(typeof g?.['query_name']==='string')f['set'](normAddr(g['query_name']),g);}return{'objects':a['map'](i=>f['get'](normAddr(i['object'])))};}catch(i){return{'objects':a['map'](()=>undefined),'queryError':'chain\x20query\x20failed:\x20'+(i instanceof Error?i['message']:String(i))};}}function typeMatches(a,b){const c=b?.['type'];if(!c)return!![];return String(c)['toLowerCase']()===a['type']['toLowerCase']();}function refsOfType(a,b){return a['objects']['filter'](c=>c['type']['toLowerCase']()===b['toLowerCase']());}async function checkPublishService(a,b,c){const d=refsOfType(a,'Service'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Service\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Service\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(l,j)){f['push']('Service\x20'+l['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(j?.['type']??'unknown')+')');return;}if(j['bPaused']!==![]){f['push']('Service\x20'+l['object']+'\x20is\x20paused\x20(bPaused='+String(j['bPaused'])+')');return;}e['push']('Service\x20'+l['object']+'\x20exists\x20and\x20is\x20not\x20paused');const m=Array['isArray'](j['sales'])?j['sales']:[];if(m['length']<0x1){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20purchasable\x20items\x20(sales\x20is\x20empty)');return;}e['push']('Service\x20'+l['object']+'\x20has\x20'+m['length']+'\x20purchasable\x20item(s)');if(isEmptyAddr(j['machine'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Machine\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Machine\x20bound\x20('+j['machine']+')');if(isEmptyAddr(j['permission'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Permission\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Permission\x20bound\x20('+j['permission']+')'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkPurchaseService(a,b,c){const d=refsOfType(a,'Order'),f=[],g=[];if(d['length']===0x0)return{'complete':![],'evidence':f,'missing':['no\x20Order\x20object\x20registered\x20on\x20the\x20goal']};const {objects:h,queryError:j}=await fetchRefs(d,b,c);if(j)g['push'](j);for(let k=0x0;k<h['length'];k++){const l=h[k],m=d[k];if(!l){if(!j)g['push']('Order\x20'+m['object']+'\x20not\x20found\x20on\x20chain');continue;}f['push']('Order\x20'+m['object']+'\x20exists');if(isEmptyAddr(l['progress'])){g['push']('Order\x20'+m['object']+'\x20has\x20no\x20Progress\x20object');continue;}const o=await fetchRefs([{'type':'Progress','object':String(l['progress'])}],b,c),q=o['objects'][0x0];if(o['queryError']){g['push'](o['queryError']);continue;}if(!q){g['push']('Progress\x20'+l['progress']+'\x20not\x20found\x20on\x20chain');continue;}const r=typeof q['current']==='string'?q['current']:'';let s=![];if(c['fetchMachineNodes']&&!isEmptyAddr(q['machine']))try{const v=await c['fetchMachineNodes'](String(q['machine']),b);if(v['length']===0x0)f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20machine\x20topology\x20empty\x20—\x20terminal\x20check\x20skipped'),s=!![];else{const w=new Set();for(const y of v){for(const z of y['pairs']??[]){if(z['prev_node'])w['add'](z['prev_node']);}}const x=v['some'](A=>A['name']===r);if(x&&!w['has'](r))f['push']('Progress\x20is\x20at\x20terminal\x20node\x20\x27'+r+'\x27'),s=!![];else!x?g['push']('Progress\x20node\x20\x27'+r+'\x27\x20not\x20found\x20in\x20machine\x20topology'):g['push']('Progress\x20node\x20\x27'+r+'\x27\x20is\x20not\x20terminal\x20(has\x20outgoing\x20forwards)');}}catch(A){f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20terminal\x20check\x20skipped:\x20'+(A instanceof Error?A['message']:String(A))),s=!![];}else f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27)'),s=!![];if(!s)continue;if(isEmptyAddr(l['allocation']))return f['push']('Order\x20'+m['object']+'\x20has\x20no\x20allocation\x20(nothing\x20to\x20settle)'),{'complete':!![],'evidence':f,'missing':g};if(!isEmptyAddr(l['claimed_by']))return f['push']('Order\x20'+m['object']+'\x20allocation\x20claimed\x20by\x20'+l['claimed_by']),{'complete':!![],'evidence':f,'missing':g};const t=await fetchRefs([{'type':'Allocation','object':String(l['allocation'])}],b,c);if(t['queryError']){g['push'](t['queryError']);continue;}const u=t['objects'][0x0];if(!u){g['push']('Allocation\x20'+l['allocation']+'\x20not\x20found\x20on\x20chain');continue;}if(balanceIsZero(u['balance']))return f['push']('Allocation\x20'+l['allocation']+'\x20balance\x20is\x20zero\x20(settled)'),{'complete':!![],'evidence':f,'missing':g};g['push']('Allocation\x20'+l['allocation']+'\x20still\x20holds\x20balance\x20'+String(u['balance']));}return{'complete':![],'evidence':f,'missing':g};}async function checkPublishDemand(a,b,c){const d=refsOfType(a,'Demand'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Demand\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Demand\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Demand\x20'+l['object']+'\x20exists');const m=Array['isArray'](j['rewards'])?j['rewards']:[];if(m['length']<0x1){f['push']('Demand\x20'+l['object']+'\x20has\x20no\x20rewards\x20bound');return;}e['push']('Demand\x20'+l['object']+'\x20has\x20'+m['length']+'\x20reward(s)\x20bound'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkRunArbitration(a,b,c){const d=refsOfType(a,'Arbitration'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Arbitration\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Arbitration\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Arbitration\x20'+l['object']+'\x20exists');if(j['bPaused']===!![]){f['push']('Arbitration\x20'+l['object']+'\x20is\x20paused');return;}e['push']('Arbitration\x20'+l['object']+'\x20is\x20not\x20paused');if(j['fee']===null||j['fee']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20fee\x20not\x20configured');return;}if(j['balance']===null||j['balance']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20balance\x20not\x20configured');return;}e['push']('Arbitration\x20'+l['object']+'\x20fee='+String(j['fee'])+'\x20balance='+String(j['balance'])),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkExistence(a,b,c){const d=[],e=[];if(a['objects']['length']===0x0)return{'complete':![],'evidence':d,'missing':['no\x20objects\x20registered\x20on\x20the\x20goal']};const {objects:f,queryError:g}=await fetchRefs(a['objects'],b,c);if(g)e['push'](g);return f['forEach']((h,j)=>{const k=a['objects'][j];if(!h){if(!g)e['push'](k['type']+'\x20'+k['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(k,h)){e['push'](k['type']+'\x20'+k['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(h?.['type']??'unknown')+')');return;}d['push'](k['type']+'\x20'+k['object']+'\x20exists');}),{'complete':e['length']===0x0,'evidence':d,'missing':e};}export const GOAL_COMPLETION_RULES={'publish_service':checkPublishService,'purchase_service':checkPurchaseService,'publish_demand':checkPublishDemand,'run_arbitration':checkRunArbitration,'fulfill_order':checkExistence,'capture_demand':checkExistence,'collaborate_flow':checkExistence,'supply_suborder':checkExistence,'dispute_resolution':checkExistence,'manage_assets':checkExistence};function defaultDeps(){return{'queryObjects':async(a,b)=>{const {
|
|
1
|
+
function normAddr(a){if(!a)return'';const b=a['startsWith']('0x')?a['slice'](0x2):a;return b['toLowerCase']();}function isEmptyAddr(a){return a===null||a===undefined||String(a)['trim']()==='';}function balanceIsZero(a){if(a===null||a===undefined)return![];try{return BigInt(String(a))===0x0n;}catch{return![];}}async function fetchRefs(a,b,c){if(a['length']===0x0)return{'objects':[]};try{const d=await c['queryObjects'](a['map'](g=>g['object']),b),f=new Map();for(const g of d??[]){if(!g)continue;const h=normAddr(g?.['object']);if(h)f['set'](h,g);if(typeof g?.['query_name']==='string')f['set'](normAddr(g['query_name']),g);}return{'objects':a['map'](i=>f['get'](normAddr(i['object'])))};}catch(i){return{'objects':a['map'](()=>undefined),'queryError':'chain\x20query\x20failed:\x20'+(i instanceof Error?i['message']:String(i))};}}function typeMatches(a,b){const c=b?.['type'];if(!c)return!![];return String(c)['toLowerCase']()===a['type']['toLowerCase']();}function refsOfType(a,b){return a['objects']['filter'](c=>c['type']['toLowerCase']()===b['toLowerCase']());}async function checkPublishService(a,b,c){const d=refsOfType(a,'Service'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Service\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Service\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(l,j)){f['push']('Service\x20'+l['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(j?.['type']??'unknown')+')');return;}if(j['bPaused']!==![]){f['push']('Service\x20'+l['object']+'\x20is\x20paused\x20(bPaused='+String(j['bPaused'])+')');return;}e['push']('Service\x20'+l['object']+'\x20exists\x20and\x20is\x20not\x20paused');const m=Array['isArray'](j['sales'])?j['sales']:[];if(m['length']<0x1){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20purchasable\x20items\x20(sales\x20is\x20empty)');return;}e['push']('Service\x20'+l['object']+'\x20has\x20'+m['length']+'\x20purchasable\x20item(s)');if(isEmptyAddr(j['machine'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Machine\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Machine\x20bound\x20('+j['machine']+')');if(isEmptyAddr(j['permission'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Permission\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Permission\x20bound\x20('+j['permission']+')'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkPurchaseService(a,b,c){const d=refsOfType(a,'Order'),f=[],g=[];if(d['length']===0x0)return{'complete':![],'evidence':f,'missing':['no\x20Order\x20object\x20registered\x20on\x20the\x20goal']};const {objects:h,queryError:j}=await fetchRefs(d,b,c);if(j)g['push'](j);for(let k=0x0;k<h['length'];k++){const l=h[k],m=d[k];if(!l){if(!j)g['push']('Order\x20'+m['object']+'\x20not\x20found\x20on\x20chain');continue;}f['push']('Order\x20'+m['object']+'\x20exists');if(isEmptyAddr(l['progress'])){g['push']('Order\x20'+m['object']+'\x20has\x20no\x20Progress\x20object');continue;}const o=await fetchRefs([{'type':'Progress','object':String(l['progress'])}],b,c),q=o['objects'][0x0];if(o['queryError']){g['push'](o['queryError']);continue;}if(!q){g['push']('Progress\x20'+l['progress']+'\x20not\x20found\x20on\x20chain');continue;}const r=typeof q['current']==='string'?q['current']:'';let s=![];if(c['fetchMachineNodes']&&!isEmptyAddr(q['machine']))try{const v=await c['fetchMachineNodes'](String(q['machine']),b);if(v['length']===0x0)f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20machine\x20topology\x20empty\x20—\x20terminal\x20check\x20skipped'),s=!![];else{const w=new Set();for(const y of v){for(const z of y['pairs']??[]){if(z['prev_node'])w['add'](z['prev_node']);}}const x=v['some'](A=>A['name']===r);if(x&&!w['has'](r))f['push']('Progress\x20is\x20at\x20terminal\x20node\x20\x27'+r+'\x27'),s=!![];else!x?g['push']('Progress\x20node\x20\x27'+r+'\x27\x20not\x20found\x20in\x20machine\x20topology'):g['push']('Progress\x20node\x20\x27'+r+'\x27\x20is\x20not\x20terminal\x20(has\x20outgoing\x20forwards)');}}catch(A){f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20terminal\x20check\x20skipped:\x20'+(A instanceof Error?A['message']:String(A))),s=!![];}else f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27)'),s=!![];if(!s)continue;if(isEmptyAddr(l['allocation']))return f['push']('Order\x20'+m['object']+'\x20has\x20no\x20allocation\x20(nothing\x20to\x20settle)'),{'complete':!![],'evidence':f,'missing':g};if(!isEmptyAddr(l['claimed_by']))return f['push']('Order\x20'+m['object']+'\x20allocation\x20claimed\x20by\x20'+l['claimed_by']),{'complete':!![],'evidence':f,'missing':g};const t=await fetchRefs([{'type':'Allocation','object':String(l['allocation'])}],b,c);if(t['queryError']){g['push'](t['queryError']);continue;}const u=t['objects'][0x0];if(!u){g['push']('Allocation\x20'+l['allocation']+'\x20not\x20found\x20on\x20chain');continue;}if(balanceIsZero(u['balance']))return f['push']('Allocation\x20'+l['allocation']+'\x20balance\x20is\x20zero\x20(settled)'),{'complete':!![],'evidence':f,'missing':g};g['push']('Allocation\x20'+l['allocation']+'\x20still\x20holds\x20balance\x20'+String(u['balance']));}return{'complete':![],'evidence':f,'missing':g};}async function checkPublishDemand(a,b,c){const d=refsOfType(a,'Demand'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Demand\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Demand\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Demand\x20'+l['object']+'\x20exists');const m=Array['isArray'](j['rewards'])?j['rewards']:[];if(m['length']<0x1){f['push']('Demand\x20'+l['object']+'\x20has\x20no\x20rewards\x20bound');return;}e['push']('Demand\x20'+l['object']+'\x20has\x20'+m['length']+'\x20reward(s)\x20bound'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkRunArbitration(a,b,c){const d=refsOfType(a,'Arbitration'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Arbitration\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Arbitration\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Arbitration\x20'+l['object']+'\x20exists');if(j['bPaused']===!![]){f['push']('Arbitration\x20'+l['object']+'\x20is\x20paused');return;}e['push']('Arbitration\x20'+l['object']+'\x20is\x20not\x20paused');if(j['fee']===null||j['fee']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20fee\x20not\x20configured');return;}if(j['balance']===null||j['balance']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20balance\x20not\x20configured');return;}e['push']('Arbitration\x20'+l['object']+'\x20fee='+String(j['fee'])+'\x20balance='+String(j['balance'])),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkExistence(a,b,c){const d=[],e=[];if(a['objects']['length']===0x0)return{'complete':![],'evidence':d,'missing':['no\x20objects\x20registered\x20on\x20the\x20goal']};const {objects:f,queryError:g}=await fetchRefs(a['objects'],b,c);if(g)e['push'](g);return f['forEach']((h,j)=>{const k=a['objects'][j];if(!h){if(!g)e['push'](k['type']+'\x20'+k['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(k,h)){e['push'](k['type']+'\x20'+k['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(h?.['type']??'unknown')+')');return;}d['push'](k['type']+'\x20'+k['object']+'\x20exists');}),{'complete':e['length']===0x0,'evidence':d,'missing':e};}export const GOAL_COMPLETION_RULES={'publish_service':checkPublishService,'purchase_service':checkPurchaseService,'publish_demand':checkPublishDemand,'run_arbitration':checkRunArbitration,'fulfill_order':checkExistence,'capture_demand':checkExistence,'collaborate_flow':checkExistence,'supply_suborder':checkExistence,'dispute_resolution':checkExistence,'manage_assets':checkExistence};function defaultDeps(){return{'queryObjects':async(a,b)=>{const {batchQueryObjectsByIds:c}=await import('./workflow-guidance.js');return c(a,b,![]);},'fetchMachineNodes':async(a,b)=>{const {fetchMachineNodes:c}=await import('./workflow-guidance.js');return c(a,b,![]);}};}export async function evaluateGoalCompletion(a,b,c){const d={...defaultDeps(),...c??{}},f=GOAL_COMPLETION_RULES[a['goal_type']]??checkExistence;try{return await f(a,b,d);}catch(g){return{'complete':![],'evidence':[],'missing':['completion\x20check\x20failed:\x20'+(g instanceof Error?g['message']:String(g))]};}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type GuardBoundObject = "Reward" | "Allocation" | "Demand" | "Treasury" | "Repository" | "Arbitration" | "MachineForward";
|
|
2
|
+
export type PresetKind = "recipient" | "amount" | "deadline" | "source" | "service" | "vote_weight" | "row_key" | "row_data" | "evidence";
|
|
3
|
+
export interface GuardPresetSlot {
|
|
4
|
+
id: string;
|
|
5
|
+
object: GuardBoundObject;
|
|
6
|
+
slot: string;
|
|
7
|
+
preset_kind: PresetKind;
|
|
8
|
+
submission_type: "address" | "u64" | "number" | "any";
|
|
9
|
+
asserted_at?: string;
|
|
10
|
+
consumed_at: string;
|
|
11
|
+
neutral: string;
|
|
12
|
+
creator: string;
|
|
13
|
+
user: string;
|
|
14
|
+
risk_hooks?: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const OWNER_RECEIVE_COGNITION: string;
|
|
17
|
+
export declare const GUARD_BINDING_REGISTRY: GuardPresetSlot[];
|
|
18
|
+
export declare const GUARD_BINDINGS_VERSION = "1.0.0";
|
|
19
|
+
export declare function getGuardBindingsByObject(object: GuardBoundObject): GuardPresetSlot[];
|
|
20
|
+
export declare function getGuardBinding(id: string): GuardPresetSlot | undefined;
|
|
21
|
+
export declare function summarizeGuardBinding(b: GuardPresetSlot): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const OWNER_RECEIVE_COGNITION='owner_receive\x20extracts\x20objects\x20RECEIVED\x20via\x20transfer\x20(Receiving<CoinWrapper<K>>\x20with\x20ANY\x20token\x20K,\x20'+'or\x20any\x20K:key+store\x20object\x20such\x20as\x20an\x20NFT)\x20and\x20sends\x20them\x20to\x20the\x20Permission\x20owner\x20—\x20it\x20never\x20touches\x20the\x20'+'object\x27s\x20balance\x20field.\x20The\x20balance\x20field\x27s\x20only\x20exits\x20are:\x20Reward\x20→\x20guard-gated\x20claim;\x20Treasury\x20→\x20'+'permission-gated\x20withdraw\x20/\x20guard-gated\x20external_withdraw.\x20receive(154)\x20is\x20what\x20joins\x20a\x20received\x20payment\x20'+'INTO\x20the\x20balance.';export const GUARD_BINDING_REGISTRY=[{'id':'reward.recipient.guard_identifier','object':'Reward','slot':'RewardGuard.recipient\x20=\x20Recipient::GuardIdentifier(identifier)','preset_kind':'recipient','submission_type':'address','asserted_at':'reward.move\x20L102-104\x20(is_identifier_address)','consumed_at':'reward.move\x20L154-156\x20(de_address\x20→\x20claim\x20payee)','neutral':'The\x20claim\x20payee\x20is\x20resolved\x20from\x20the\x20claimer\x27s\x20submission\x20for\x20this\x20identifier.','creator':'Design\x20lever:\x20dynamic\x20payee\x20—\x20the\x20guard\x20decides\x20who\x20gets\x20paid\x20(e.g.\x20reimbursement\x20to\x20the\x20address\x20the\x20'+'guard\x20derives,\x20proxy\x20claims).\x20Alternative\x20presets:\x20Entity\x20(fixed\x20payee)\x20or\x20Signer\x20(payer\x20=\x20the\x20tx\x20sender\x20who\x20passed\x20the\x20guard).','user':'Who\x20receives\x20the\x20reward\x20is\x20determined\x20by\x20the\x20submitted\x20address\x20for\x20this\x20slot\x20—\x20not\x20necessarily\x20you,\x20even\x20if\x20you\x20triggered\x20the\x20claim.','risk_hooks':['R-R-2-01']},{'id':'reward.amount.guard_u64_identifier','object':'Reward','slot':'RewardGuard.amount\x20=\x20Amount::GuardU64Identifier(identifier)','preset_kind':'amount','submission_type':'u64','asserted_at':'reward.move\x20L107-113\x20(submission\x20value\x20type\x20must\x20be\x20u64)','consumed_at':'reward.move\x20L165-168\x20(de_u64\x20→\x20claim\x20amount;\x20L174\x20asserts\x20amount\x20≤\x20balance)','neutral':'The\x20claim\x20amount\x20is\x20resolved\x20from\x20the\x20claimer\x27s\x20submission\x20for\x20this\x20identifier.','creator':'Design\x20lever:\x20credential-based\x20dynamic\x20amounts\x20(marketing:\x20submit\x20receipt\x20→\x20get\x20proportional\x20cashback;\x20'+'fund\x20recovery:\x20owner\x20escape\x20hatch\x20submits\x20the\x20FULL\x20remaining\x20balance\x20to\x20recover\x20100%).\x20'+'Alternative\x20preset:\x20Fixed(u64).','user':'You\x20claim\x20exactly\x20what\x20you\x20submit\x20(bounded\x20by\x20the\x20reward\x20balance)\x20—\x20check\x20whether\x20the\x20guard\x20validates\x20your\x20submitted\x20amount\x20against\x20other\x20evidence.','risk_hooks':['R-R-7-01']},{'id':'reward.expiration_time','object':'Reward','slot':'RewardGuard.expiration_time:\x20Option<u64>','preset_kind':'deadline','submission_type':'any','consumed_at':'reward.move\x20L147-150\x20(claim\x20asserts\x20clock\x20≤\x20expiration_time),\x20guard_add\x20L247-249','neutral':'Time\x20window\x20of\x20the\x20guard:\x20after\x20it\x20elapses\x20the\x20guard\x20no\x20longer\x20opens\x20(claim\x20aborts\x20E_GUARD_EXPIRED).','creator':'Dual\x20meaning\x20by\x20design:\x20for\x20MARKETING\x20guards\x20it\x20is\x20the\x20campaign\x20deadline;\x20for\x20an\x20OWNER\x20ESCAPE\x20guard\x20'+'(recipient=Signer,\x20amount=GuardU64Identifier)\x20it\x20is\x20the\x20FUND\x20LOCK\x20PERIOD\x20—\x20set\x20it\x20in\x20the\x20future\x20(e.g.\x2030\x20days)\x20'+'and\x20after\x20expiry\x20you\x20reclaim\x20the\x20residual\x20balance\x20by\x20submitting\x20the\x20full\x20amount\x20(R-R-7-01).','user':'This\x20is\x20your\x20claim\x20deadline\x20—\x20after\x20expiration_time\x20the\x20guard\x20cannot\x20be\x20claimed\x20and\x20is\x20removed\x20by\x20guard_remove_expired.','risk_hooks':['R-R-4-01']},{'id':'reward.store_from_id','object':'Reward','slot':'RewardGuard.store_from_id:\x20Option<u8>','preset_kind':'source','submission_type':'address','asserted_at':'reward.move\x20L36-38\x20/\x20reward.ts\x20schema\x20(address-compatible\x20identifier)','consumed_at':'reward.move\x20L175-178\x20(de_address_compatible\x20→\x20Record.store_from_id)','neutral':'Each\x20claim\x20record\x20is\x20tagged\x20with\x20an\x20origin\x20object\x20address\x20submitted\x20at\x20claim\x20time.','creator':'Audit\x20lever:\x20tie\x20every\x20payout\x20to\x20its\x20campaign/repo/order\x20source\x20—\x20the\x20Record\x20table\x20then\x20answers\x20\x27what\x20did\x20this\x20campaign\x20actually\x20pay\x20out\x27.','user':'Your\x20claim\x20is\x20permanently\x20tagged\x20with\x20the\x20source\x20you\x20submitted\x20—\x20use\x20it\x20to\x20prove\x20your\x20payout\x20came\x20from\x20a\x20specific\x20campaign.'},{'id':'allocation.who.guard_identifier','object':'Allocation','slot':'Sharing.who\x20=\x20Recipient::GuardIdentifier(identifier)','preset_kind':'recipient','submission_type':'address','asserted_at':'allocation.move\x20L150-151\x20(is_identifier_address)','consumed_at':'allocation.move\x20L232-233\x20(de_address\x20→\x20payout\x20recipient)','neutral':'The\x20revenue-split\x20payee\x20is\x20resolved\x20from\x20the\x20alloc\x20caller\x27s\x20submission.','creator':'Design\x20lever:\x20dynamic\x20split\x20counterparties\x20—\x20e.g.\x20the\x20guard\x20derives\x20\x27the\x20order\x27s\x20actual\x20supplier\x27\x20from\x20evidence.\x20'+'Alternatives:\x20Entity\x20(fixed\x20payee)\x20or\x20Signer\x20(payer\x20=\x20whoever\x20executes\x20the\x20guard-gated\x20alloc).','user':'The\x20split\x20payee\x20comes\x20from\x20the\x20submission\x20resolved\x20at\x20alloc\x20time\x20—\x20verify\x20the\x20guard\x20logic\x20to\x20know\x20who\x20it\x20resolves\x20to.'},{'id':'allocation.mode_and_sharing','object':'Allocation','slot':'Sharing\x20{\x20mode:\x20Amount|Rate|Surplus,\x20sharing:\x20u64\x20}','preset_kind':'amount','submission_type':'u64','asserted_at':'allocation.move\x20L173-177\x20(Rate\x20invariant:\x20without\x20Surplus\x20the\x20rates\x20must\x20sum\x20to\x20exactly\x2010000)','consumed_at':'allocation.move\x20L243-267\x20(alloc:\x20Amount\x20splits\x20a\x20fixed\x20value\x20/\x20Rate\x20computes\x20basis\x20points\x20of\x20the\x20payment\x20/\x20Surplus\x20takes\x20the\x20remainder)','neutral':'How\x20much\x20each\x20sharing\x20entry\x20receives\x20from\x20an\x20allocated\x20payment.','creator':'Design\x20lever:\x20fixed\x20amounts\x20(Amount),\x20proportional\x20splits\x20(Rate,\x20basis\x20points,\x20must\x20complete\x2010000\x20unless\x20a\x20Surplus\x20remainder\x20exists),\x20'+'or\x20residual\x20beneficiary\x20(Surplus\x20—\x20exactly\x20one,\x20takes\x20what\x20is\x20left).','user':'Your\x20Rate\x20sharing\x20is\x20in\x20basis\x20points\x20(3000\x20=\x2030%);\x20a\x20Surplus\x20entry\x20receives\x20whatever\x20the\x20other\x20entries\x20did\x20not\x20consume.'},{'id':'demand.service_identifier','object':'Demand','slot':'ServiceGuard.service_identifier:\x20Option<u8>','preset_kind':'service','submission_type':'address','consumed_at':'demand.move\x20L132-133\x20(de_address\x20→\x20the\x20service\x20being\x20presented)','neutral':'Which\x20service\x20a\x20presenter\x20is\x20presenting\x20for\x20is\x20resolved\x20from\x20their\x20passport\x20submission.','creator':'Design\x20lever:\x20qualification-gated\x20presentation\x20—\x20only\x20guards\x20that\x20resolve\x20to\x20approved\x20services\x20let\x20suppliers\x20present\x20'+'(e.g.\x20whitelist,\x20passport,\x20or\x20proof-of-capability\x20guards).','user':'You\x20may\x20only\x20present\x20the\x20service\x20your\x20submission\x20resolves\x20to\x20—\x20the\x20guard\x20defines\x20which\x20services\x20you\x20are\x20eligible\x20to\x20present.'},{'id':'treasury.deposit.identifier','object':'Treasury','slot':'AmountFromDepositGuard.identifier:\x20Option<u8>','preset_kind':'amount','submission_type':'number','asserted_at':'treasury.move\x20L138-141\x20(submission\x20value\x20type\x20must\x20be\x20a\x20number)','consumed_at':'treasury.move\x20L371-385\x20(de_number\x20→\x20deposit\x20amount;\x20excess\x20is\x20refunded\x20to\x20the\x20depositor)','neutral':'The\x20amount\x20actually\x20deposited\x20is\x20resolved\x20from\x20the\x20depositor\x27s\x20submission.','creator':'Design\x20lever:\x20guard-driven\x20external\x20inflow\x20—\x20outside\x20parties\x20deposit\x20against\x20a\x20guard\x20(e.g.\x20invoice-backed\x20payment:\x20'+'the\x20guard\x20validates\x20the\x20invoice,\x20the\x20submission\x20states\x20the\x20amount).','user':'You\x20deposit\x20the\x20amount\x20you\x20submit;\x20anything\x20beyond\x20it\x20is\x20transferred\x20back\x20to\x20you\x20in\x20the\x20same\x20call.'},{'id':'treasury.withdraw.identifier','object':'Treasury','slot':'AmountFromWithdrawGuard.identifier:\x20u8','preset_kind':'amount','submission_type':'number','consumed_at':'treasury.move\x20L409-410\x20(de_number\x20→\x20withdraw\x20amount,\x20asserted\x20≤\x20balance)','neutral':'The\x20amount\x20withdrawn\x20by\x20an\x20outside\x20party\x20is\x20resolved\x20from\x20their\x20submission.','creator':'Design\x20lever:\x20guard-driven\x20external\x20outflow\x20—\x20NOTE\x20this\x20is\x20a\x20PAYMENT\x20AUTHORIZATION:\x20whoever\x20satisfies\x20the\x20guard\x20can\x20'+'withdraw\x20up\x20to\x20the\x20balance.\x20Treat\x20the\x20guard\x20design\x20as\x20the\x20spending\x20boundary.','user':'You\x20receive\x20the\x20amount\x20you\x20submit\x20(bounded\x20by\x20the\x20treasury\x20balance).'},{'id':'treasury.store_from_id','object':'Treasury','slot':'AmountFrom{Deposit,Withdraw}Guard.store_from_id:\x20Option<u8>','preset_kind':'source','submission_type':'address','asserted_at':'treasury.move\x20L143-145\x20(is_identifier_address_compatible)','consumed_at':'treasury.move\x20L367-369\x20/\x20L412-414\x20(de_address_compatible\x20→\x20Record.store_from_id)','neutral':'Each\x20external\x20deposit/withdraw\x20record\x20is\x20tagged\x20with\x20a\x20submitted\x20origin\x20address.','creator':'Audit\x20lever:\x20reconcile\x20external\x20flows\x20against\x20their\x20origin\x20(invoice,\x20order,\x20campaign).','user':'Your\x20flow\x20is\x20permanently\x20tagged\x20with\x20the\x20source\x20you\x20submitted.'},{'id':'repository.id_from_submission','object':'Repository','slot':'PolicyGuard.id_from_submission:\x20Option<u8>','preset_kind':'row_key','submission_type':'address','asserted_at':'repository.move\x20L90-92\x20(is_identifier_address_compatible)','consumed_at':'repository.move\x20L346/L393\x20(submission_get\x20→\x20table\x20row\x20identity)','neutral':'Which\x20table\x20row\x20a\x20guarded\x20write\x20targets\x20is\x20resolved\x20from\x20the\x20writer\x27s\x20submission.','creator':'Design\x20lever:\x20dynamic\x20rows\x20—\x20or\x20pin\x20the\x20row\x20statically\x20via\x20PolicyRule.id_from\x20(which\x20then\x20takes\x20priority\x20over\x20this\x20slot).','user':'Your\x20write\x20lands\x20on\x20the\x20row\x20your\x20submitted\x20address\x20identifies.'},{'id':'repository.data_from_submission','object':'Repository','slot':'PolicyGuard.data_from_submission:\x20Option<u8>','preset_kind':'row_data','submission_type':'any','asserted_at':'repository.move\x20L93-96\x20(has_identifier\x20—\x20ANY\x20value\x20type\x20is\x20supported)','consumed_at':'repository.move\x20L350/L361/L215\x20(submission_get\x20→\x20the\x20value\x20written)','neutral':'The\x20value\x20written\x20into\x20the\x20row\x20IS\x20the\x20writer\x27s\x20submission\x20(any\x20type).','creator':'Design\x20lever:\x20the\x20guard\x20itself\x20becomes\x20the\x20data\x20format\x20—\x20reviews,\x20scores,\x20attestations\x20written\x20by\x20qualified\x20parties.\x20'+'The\x20write\x20policy\x27s\x20value_type\x20constrains\x20what\x20is\x20storable.','user':'What\x20you\x20submit\x20is\x20what\x20gets\x20stored\x20—\x20the\x20guard\x20decides\x20whether\x20your\x20data\x20qualifies,\x20not\x20the\x20object.'},{'id':'arbitration.vote_weight.guard_identifier','object':'Arbitration','slot':'VotingGuard.vote_weight\x20=\x20VoteValue::GuardIdentifier(identifier)','preset_kind':'vote_weight','submission_type':'number','asserted_at':'arbitration.move\x20L125-126\x20(submission\x20value\x20type\x20must\x20be\x20a\x20number)','consumed_at':'arbitration.move\x20L288-289\x20(de_number\x20→\x20ballot\x20weight)','neutral':'Each\x20voter\x27s\x20ballot\x20weight\x20is\x20resolved\x20from\x20their\x20own\x20submission.','creator':'Design\x20lever:\x20stake/role-weighted\x20voting\x20—\x20the\x20guard\x20derives\x20the\x20weight\x20(e.g.\x20token-balance\x20tier,\x20credential\x20level).\x20'+'Alternative\x20preset:\x20FixedValue(u32)\x20for\x20flat-weight\x20open\x20voting\x20(empty\x20voting_guard\x20=\x20everyone\x20can\x20vote).','user':'The\x20number\x20you\x20submit\x20IS\x20your\x20vote\x27s\x20weight\x20—\x20the\x20guard\x20defines\x20what\x20qualifies\x20you\x20to\x20claim\x20that\x20weight.'},{'id':'arbitration.usage_guard','object':'Arbitration','slot':'usage_guard:\x20Option<address>','preset_kind':'evidence','submission_type':'any','consumed_at':'arbitration.move\x20L264-276\x20(dispute:\x20without\x20a\x20passport\x20the\x20guard\x20must\x20be\x20None;\x20dispute_with_passport\x20verifies\x20it)','neutral':'Who\x20may\x20OPEN\x20a\x20dispute\x20at\x20this\x20arbitration\x20—\x20disputants\x20must\x20satisfy\x20this\x20guard.','creator':'Design\x20lever:\x20qualification\x20gate\x20for\x20disputants\x20(reputation/kyc/holding\x20guards)\x20—\x20keeps\x20frivolous\x20disputes\x20out.\x20'+'Set\x20to\x20None\x20for\x20open\x20access.','user':'To\x20open\x20a\x20dispute\x20at\x20this\x20arbitration\x20you\x20must\x20pass\x20its\x20usage_guard;\x20without\x20a\x20passport\x20the\x20arbitration\x20refuses\x20disputes\x20outright.'},{'id':'machine.forward.retained_submission','object':'MachineForward','slot':'ForwardGuard.retained_submission:\x20vector<u8>','preset_kind':'evidence','submission_type':'any','asserted_at':'machine.move\x20L80-81\x20(has_submissions\x20—\x20every\x20id\x20must\x20be\x20a\x20submission\x20slot\x20of\x20the\x20guard)','consumed_at':'progress.move\x20L471-474\x20(submissions_get\x20→\x20values\x20stored\x20into\x20the\x20session\x20history)','neutral':'Progressing\x20along\x20this\x20forward\x20REQUIRES\x20submitting\x20these\x20guard\x20slots;\x20the\x20submitted\x20values\x20are\x20persisted\x20into\x20the\x20workflow\x20session\x20history.','creator':'Design\x20lever:\x20evidence-carrying\x20workflow\x20steps\x20—\x20the\x20step\x20cannot\x20advance\x20without\x20the\x20proof,\x20and\x20the\x20proof\x20is\x20'+'permanently\x20recorded\x20in\x20the\x20session\x20(auditable\x20trail,\x20usable\x20later\x20by\x20downstream\x20guards/arb).','user':'You\x20cannot\x20advance\x20this\x20step\x20without\x20submitting\x20the\x20required\x20evidence\x20—\x20and\x20what\x20you\x20submit\x20becomes\x20part\x20of\x20the\x20on-chain\x20record.'}];export const GUARD_BINDINGS_VERSION='1.0.0';export function getGuardBindingsByObject(a){return GUARD_BINDING_REGISTRY['filter'](c=>c['object']===a);}export function getGuardBinding(a){return GUARD_BINDING_REGISTRY['find'](c=>c['id']===a);}export function summarizeGuardBinding(a){return'['+a['object']+']\x20'+a['slot']+'\x20—\x20creator:\x20'+a['creator']['split']('\x20—\x20')[0x0]+'\x20|\x20user:\x20'+a['user'];}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift } from "./glossary.js";
|
|
2
|
-
import { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, listLocalAccounts, accountCanExecuteForward, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext } from "./workflow-guidance.js";
|
|
2
|
+
import { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchServiceOrders, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, batchReadAddressKeyedFields, batchReadU64KeyedFields, listLocalAccounts, accountCanExecuteForward, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext } from "./workflow-guidance.js";
|
|
3
3
|
import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem } from "./safety-rules.js";
|
|
4
4
|
import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation } from "./tool-constraints.js";
|
|
5
5
|
import { PERMISSION_TYPES, GAME_ELEMENTS, getPermissionType, getGameElement, getGameElementsByType, PROCESS_MODEL_VERSION, type PermissionScope, type PermissionTypeDef, type GameElementType, type GameElementDef } from "./process-model.js";
|
|
@@ -19,6 +19,8 @@ import { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getN
|
|
|
19
19
|
import { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, type SemanticToSchemaRule, type SchemaToSemanticRule, type GuardConstraintRule } from "./guard-translation.js";
|
|
20
20
|
import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension } from "./guard-puzzle.js";
|
|
21
21
|
import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule } from "./guard-risk.js";
|
|
22
|
+
import { GUARD_BINDING_REGISTRY, GUARD_BINDINGS_VERSION, OWNER_RECEIVE_COGNITION, getGuardBindingsByObject, getGuardBinding, summarizeGuardBinding, type GuardBoundObject, type PresetKind, type GuardPresetSlot } from "./guard-bindings.js";
|
|
23
|
+
import { SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgesByObject, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField } from "./scenario-topology.js";
|
|
22
24
|
import { GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType } from "./guard-templates.js";
|
|
23
25
|
import { lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction } from "./guard-lint.js";
|
|
24
26
|
import { MACHINE_SCENES, MACHINE_LEDGER_VERSION, MACHINE_SCENES_COUNT, findScene as findMachineScene, getScenesByIndustry as getMachineScenesByIndustry, getScenesByPattern, inferSceneFromFlow, type MachineScene, type ParticipantRoleDef, type GuardRequirement } from "./machine-ledger.js";
|
|
@@ -124,7 +126,7 @@ export { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listInte
|
|
|
124
126
|
export { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, type GuardScene, };
|
|
125
127
|
export { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, type SemanticToSchemaRule, type SchemaToSemanticRule, type GuardConstraintRule, };
|
|
126
128
|
export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension, };
|
|
127
|
-
export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction, };
|
|
129
|
+
export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType, GUARD_BINDING_REGISTRY, GUARD_BINDINGS_VERSION, OWNER_RECEIVE_COGNITION, getGuardBindingsByObject, getGuardBinding, summarizeGuardBinding, type GuardBoundObject, type PresetKind, type GuardPresetSlot, SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgesByObject, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction, };
|
|
128
130
|
export { MACHINE_SCENES, MACHINE_LEDGER_VERSION, MACHINE_SCENES_COUNT, findMachineScene, getMachineScenesByIndustry, getScenesByPattern, inferSceneFromFlow, type MachineScene, type ParticipantRoleDef, type GuardRequirement, };
|
|
129
131
|
export { MACHINE_TEMPLATES, MACHINE_TEMPLATES_VERSION, MACHINE_TEMPLATES_COUNT, getAllMachineTemplates, getMachineTemplateById, getMachineTemplatesByScene, getMachineTemplatesByIndustry, suggestTemplateForIntent, walkDecisionTree, fillMachineTemplate, forkMachineTemplate, verifyTemplateSceneReferences, getReferencedGuardTemplateIds, getReferencedRiskIds, type MachineTemplate, type MachineTemplateParam, };
|
|
130
132
|
export { SEMANTIC_TO_MACHINE_RULES, MACHINE_CONSTRAINT_RULES, MACHINE_TRANSLATION_VERSION, MACHINE_PATTERNS_COUNT, MACHINE_CONSTRAINTS_COUNT, matchMachinePattern, identifyExecutionMode, identifyTopology, explainForwardPermission, getMachineConstraintsByCategory, getConstraintById, getOnChainMachineConstraints, getOffChainMachineConstraints, type SemanticToMachineRule, type MachineConstraintRule, };
|
|
@@ -492,7 +494,7 @@ export declare function getKnowledgeBase(): {
|
|
|
492
494
|
guard_design_patterns_count: number;
|
|
493
495
|
verifier_level_guidance_count: number;
|
|
494
496
|
};
|
|
495
|
-
export { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, listLocalAccounts, accountCanExecuteForward, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext, };
|
|
497
|
+
export { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchServiceOrders, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, batchReadAddressKeyedFields, batchReadU64KeyedFields, listLocalAccounts, accountCanExecuteForward, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext, };
|
|
496
498
|
export { buildWorkspaceLists, type WorkspaceListsResult, type WorkspaceListItem, } from "./workspace-lists.js";
|
|
497
499
|
export { resolveSupplyChainGraph, type SupplyChainGraph, type SupplyChainEdge, type SupplyChainService, type SupplyChainSubmission, } from "./supply-chain.js";
|
|
498
500
|
export { enumerateObjectOperations, operationCategoryOf, operationComplexityOf, isPermissionIndexType, type OperationCategory, type ComplexityLevel, type OperationComplexity, type WatchOperationDraft, } from "./operation-dictionary.js";
|