@oracle-agent/oracle 0.35.9 → 0.35.11
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/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/bin/oracle-public-server.mjs +5 -5
- package/dist/clear-sign/erc7730.mjs +1 -0
- package/dist/cli/commands/chat.mjs +180 -180
- package/dist/cli/commands/clear-sign.mjs +10 -0
- package/dist/cli/commands/doctor.mjs +11 -8
- package/dist/cli/commands/eval.mjs +73 -73
- package/dist/cli/commands/model.mjs +184 -184
- package/dist/cli/commands/sign.mjs +10 -10
- package/dist/cli/commands/signer.mjs +16 -16
- package/dist/cli/commands/venues.mjs +2 -2
- package/dist/local-signer/anvil-attestation-worker.mjs +1 -1
- package/dist/local-signer/runtime.mjs +13 -13
- package/package.json +2 -1
- package/public/eval-report.json +80 -0
- package/public/oracle-splash/index.html +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as k,readdirSync as M,existsSync as D}from"node:fs";import{dirname as F,join as N}from"node:path";import{fileURLToPath as U}from"node:url";import{Interface as C,MaxUint256 as y,isAddress as R,keccak256 as $e,toUtf8Bytes as Oe}from"ethers";import{Interface as _,isAddress as ue}from"ethers";import{isAddress as ne}from"ethers";var pe=new _(["function approve(address spender,uint256 amount) returns (bool)"]);import{Interface as $,isAddress as be}from"ethers";var Ee=new $(["function approve(address spender,uint256 amount) returns (bool)"]),Se=Object.freeze({42161:"0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41",43114:"0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2"});function O(e,t="value"){if(typeof e=="number"){if(!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(Math.abs(e)>Number.MAX_SAFE_INTEGER)throw new Error(`${t} exceeds safe integer precision \u2014 pass it as a decimal string or BigInt so the exact value is preserved`);if(Number.isInteger(e)&&!Number.isSafeInteger(e))throw new Error(`${t} exceeds safe integer precision \u2014 pass it as a decimal string or BigInt so the exact value is preserved`);return String(e)}if(typeof e=="string"){if(e!==e.trim())throw new Error(`${t} must be a number or decimal string`);return e}throw new Error(`${t} must be a number or decimal string`)}function x(e,t="amount"){if(typeof e=="bigint")return e;if(typeof e=="number"){if(!Number.isInteger(e))throw new Error(`${t} must be an integer`);if(!Number.isSafeInteger(e))throw new Error(`${t} exceeds safe integer precision \u2014 pass it as a decimal string or BigInt so the exact value is preserved`);return BigInt(e)}let r=O(e,t);if(r==="")throw new Error(`${t} is required`);if(!/^-?\d+$/.test(r)&&!/^0x[0-9a-fA-F]+$/.test(r))throw new Error(`${t} must be an integer in decimal or 0x-hex form, got ${JSON.stringify(r)}`);try{return BigInt(r)}catch{throw new Error(`${t} must be an integer, got ${JSON.stringify(r)}`)}}var qe=new C(["function approve(address spender,uint256 amount) returns (bool)"]);function E(e,t){let r=String(e||"").trim();if(!R(r))throw new Error(`${t} must be an address`);return r.toLowerCase()}function B(e,t="approval amount",{allowZero:r=!1}={}){let a=x(e,t);if(r?a<0n:a<=0n)throw new Error(`${t} must be positive`);if(a>=y)throw new Error("unlimited approvals are refused; use an exact bounded amount");return a.toString()}var L=new Set(["0x095ea7b3","0x39509351","0x61f49ed6","0xeb5625d9","0xf9255c1f","0x87517c45","0xd505accf","0x8fcbaf0c","0x2b67b570","0x2a2d80d1"]),q=new Set(["0x39509351","0xf9255c1f"]);function g(e){let t=String(e||"").toLowerCase();return t.length<10?!1:L.has(t.slice(0,10))}function S(e){if(!g(e))throw new Error("approval calldata required");let t=String(e||"").toLowerCase(),r=t.slice(0,10),a=t.slice(10).match(/.{1,64}/g)||[],n=o=>a[o]?"0x"+a[o].slice(24):null,i=o=>a[o]?BigInt("0x"+a[o]):null,s=null,c=null,u=null;switch(r){case"0x095ea7b3":case"0x39509351":s=n(0),c=i(1);break;case"0x61f49ed6":case"0xeb5625d9":case"0xf9255c1f":u=n(0),s=n(1),c=i(2);break;case"0xd505accf":s=n(1),c=i(2);break;case"0x8fcbaf0c":{s=n(1),c=i(4)===0n?0n:(1n<<256n)-1n;break}case"0x87517c45":u=n(0),s=n(1),c=i(2);break;default:throw new Error(`approval selector ${r} is recognised but not decodable; refusing to bound it`)}if(s==null||c==null)throw new Error("invalid approve calldata");return{spender:E(s,"approval spender"),token:u==null?null:E(u,"approval token"),amount:B(c,"approval amount",{allowZero:!0}),selector:r,additive:q.has(r)}}var je=1,j=F(U(import.meta.url)),H=N(j,"descriptors"),G=/^0x[0-9a-f]{8}/,V=/^0x[0-9a-fA-F]{40}$/;function P(e=H){if(!D(e))return[];let t=[];for(let r of M(e).filter(a=>a.endsWith(".json")).sort()){let a=k(N(e,r),"utf8"),n;try{n=JSON.parse(a)}catch(i){throw new Error(`clear-sign descriptor ${r} is not valid JSON: ${i.message}`)}t.push({file:r,doc:n})}return t}function J(e,{to:t=null,chainId:r=null}={},a=P()){let n=String(e||"").toLowerCase(),i=G.test(n)?n.slice(0,10):null;if(!i)return null;let s=t&&V.test(String(t))?String(t).toLowerCase():null;for(let{file:c,doc:u}of a){let o=u?.display?.formats||{};for(let[d,f]of Object.entries(o)){if(String(f?.$selector||"").toLowerCase()!==i)continue;let l=u?.context?.contract?.deployments||[],m=l.length===0,p=l.some(w=>(r==null||Number(w.chainId)===Number(r))&&s&&String(w.address||"").toLowerCase()===s);if(m||p)return{file:c,signature:d,format:f,doc:u,selector:i,generic:m}}}return null}function I(e,t){let r=e.slice(t*64,t*64+64);return r.length===64?r:null}function W(e,t){let r=I(e,t);return r?`0x${r.slice(24)}`:null}function v(e,t){let r=I(e,t);return r?BigInt(`0x${r}`).toString():null}var X=(1n<<256n)-1n;function A(e){if(e==null)return"unknown";let t=BigInt(e);return t>=X/2n?"UNLIMITED":t.toString()}function He(e,{to:t=null,chainId:r=null}={},a=void 0){let n=J(e,{to:t,chainId:r},a);if(!n)return null;let i=String(e||"").toLowerCase(),s=i.slice(10),c=[],u=[];for(let o of n.format.fields||[]){if(o.visible==="never")continue;let d=o.$wordIndex,f=null;Number.isInteger(d)&&(f=o.format==="addressName"||o.format==="raw-address"?W(s,d):o.format==="amount"||o.format==="tokenAmount"?A(v(s,d)):v(s,d)),f!=null&&(u.push({label:o.label,value:f}),c.push(`${o.label}: ${f}`))}if(g(i)){let o=null,d=null;try{o=S(i)}catch(f){let l=String(f?.message||f);if(/unlimited approvals are refused/i.test(l))d="ORACLE POLICY: unlimited approval \u2014 Oracle refuses to prepare this; bound the amount";else return{ok:!1,refused:`descriptor matched but reviewed decoder refused: ${l}`,intent:n.format.intent}}if(o){let f=u.find(p=>/spender/i.test(p.label))?.value?.toLowerCase();if(f&&o.spender&&f!==o.spender.toLowerCase())return{ok:!1,refused:"descriptor spender disagrees with reviewed decoder",intent:n.format.intent};let l=u.find(p=>/amount|allowance/i.test(p.label))?.value,m=A(o.amount);if(l!=null&&o.amount!=null&&String(l)!==m)return{ok:!1,refused:"descriptor amount disagrees with reviewed decoder",intent:n.format.intent}}return d&&c.push(d),{ok:!0,intent:n.format.intent,signature:n.signature,selector:n.selector,descriptor:n.file,generic:n.generic,fields:u,lines:c,...d?{policyNote:d}:{}}}return{ok:!0,intent:n.format.intent,signature:n.signature,selector:n.selector,descriptor:n.file,generic:n.generic,fields:u,lines:c}}export{je as CLEAR_SIGN_VERSION,H as DESCRIPTOR_DIR,He as clearSignPreview,P as loadBundledDescriptors,J as matchDescriptor};
|