@oracle-agent/oracle 0.35.34 → 0.35.36
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/README.md +43 -8
- package/artifacts/specialist-packs/oracle-full-crypto.json +11 -0
- package/dist/address-book.mjs +2 -2
- package/dist/agent-sessions.mjs +8 -8
- package/dist/assets/profiles/canton-agent/SOUL.md +44 -0
- package/dist/assets/profiles/canton-agent/profile.json +30 -0
- package/dist/assets/profiles/oracle/SOUL.md +1 -0
- package/dist/assets/skills/oracle-canton/SKILL.md +49 -0
- package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/bin/desk-server.mjs +35 -35
- package/dist/bin/oracle-data-mcp.mjs +17 -17
- package/dist/bin/oracle-gateway.mjs +14 -14
- package/dist/bin/oracle-launch-radar-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-arb-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-shadow.mjs +4 -4
- package/dist/bin/oracle-public-server.mjs +4 -4
- package/dist/bin/oracle-route.mjs +8 -8
- package/dist/bin/oracle-scan.mjs +10 -10
- package/dist/bin/oracle.mjs +8 -6
- package/dist/cli/commands/agent-session.mjs +10 -10
- package/dist/cli/commands/airdrop.mjs +16 -0
- package/dist/cli/commands/chain.mjs +1 -1
- package/dist/cli/commands/chat.mjs +215 -204
- package/dist/cli/commands/doctor.mjs +5 -5
- package/dist/cli/commands/eval.mjs +151 -141
- package/dist/cli/commands/extension-policy.mjs +3 -3
- package/dist/cli/commands/farm.mjs +22 -22
- package/dist/cli/commands/mint.mjs +22 -0
- package/dist/cli/commands/model.mjs +219 -208
- package/dist/cli/commands/plugins.mjs +42 -39
- package/dist/cli/commands/quickstart.mjs +6 -6
- package/dist/cli/commands/session-vault.mjs +1 -1
- package/dist/cli/commands/sign.mjs +12 -12
- package/dist/cli/commands/signer.mjs +25 -23
- package/dist/cli/commands/snipe.mjs +6 -6
- package/dist/cli/commands/swap.mjs +12 -12
- package/dist/cli/commands/venues.mjs +2 -2
- package/dist/control/receipt-lineage.mjs +1 -0
- package/dist/data/desk-data.mjs +33 -33
- package/dist/data/providers/farming.mjs +2 -2
- package/dist/data/providers/lp-destination-discovery.mjs +4 -4
- package/dist/index.mjs +50 -49
- package/dist/launch-radar/index.mjs +4 -4
- package/dist/local-signer/anvil-attestation-worker.mjs +1 -1
- package/dist/local-signer/index.mjs +3 -3
- package/dist/local-signer/runtime.mjs +22 -20
- package/dist/router/index.mjs +3 -3
- package/dist/router/prepare-bridge.mjs +1 -1
- package/dist/scanner/index.mjs +4 -4
- package/dist/task.mjs +2 -2
- package/dist/teams/index.mjs +3 -1
- package/dist/tui/standalone-client.mjs +85 -75
- package/package.json +3 -2
- package/public/eval-report.json +6 -6
- package/public/oracle-splash/assets/desktop-app.jpg +0 -0
- package/public/oracle-splash/assets/hero/agent-session-poster.jpg +0 -0
- package/public/oracle-splash/assets/hero/agent-session.mp4 +0 -0
- package/public/oracle-splash/assets/hero/agent-session.webm +0 -0
- package/public/oracle-splash/assets/oracle-cli-v03535-poster.jpg +0 -0
- package/public/oracle-splash/assets/oracle-cli-v03535.gif +0 -0
- package/public/oracle-splash/assets/protocol-build-time.jpg +0 -0
- package/public/oracle-splash/downloads/index.html +2 -2
- package/public/oracle-splash/index.html +132 -54
- package/server.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{createHash as ct}from"node:crypto";import{types as M}from"node:util";import U from"node:net";import ot from"node:dns";var at=new Set(["localhost","metadata.google.internal","metadata.goog"]);function ee(e){let t=String(e).toLowerCase().split("%")[0];if((t.match(/::/g)||[]).length>1)return null;let r=s=>{if(!s)return[];let l=s.split(":"),f=l.at(-1);if(f?.includes(".")){let h=f.split(".").map(Number);if(h.length!==4||h.some(m=>!Number.isInteger(m)||m<0||m>255))return null;l.splice(l.length-1,1,(h[0]<<8|h[1]).toString(16),(h[2]<<8|h[3]).toString(16))}return l.some(h=>!/^[0-9a-f]{1,4}$/.test(h))?null:l.map(h=>Number.parseInt(h,16))},[n,o]=t.split("::"),a=r(n),i=r(o);if(!a||!i)return null;let c=t.includes("::"),u=8-a.length-i.length;if(!c&&u!==0||c&&u<1)return null;let d=[...a,...Array(Math.max(0,u)).fill(0),...i];return d.length!==8?null:Uint8Array.from(d.flatMap(s=>[s>>8,s&255]))}function ue(e,t,r){let n=Math.floor(r/8),o=r%8;for(let i=0;i<n;i+=1)if(e[i]!==t[i])return!1;if(!o)return!0;let a=255<<8-o;return(e[n]&a)===(t[n]&a)}function le(e){if(U.isIPv4(e)){let t=e.split(".").map(Number);return!(t[0]===0||t[0]===10||t[0]===127||t[0]>=224||t[0]===100&&t[1]>=64&&t[1]<=127||t[0]===169&&t[1]===254||t[0]===172&&t[1]>=16&&t[1]<=31||t[0]===192&&(t[1]===0||t[1]===2||t[1]===168)||t[0]===192&&t[1]===88&&t[2]===99||t[0]===198&&(t[1]===18||t[1]===19||t[1]===51)||t[0]===203&&t[1]===0&&t[2]===113)}if(U.isIPv6(e)){let t=ee(e);if(!t)return!1;let r=ee("::ffff:0:0");return ue(t,r,96)?le([...t.slice(12)].join(".")):ue(t,ee("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([o,a])=>ue(t,ee(o),a)):!1}return!1}function it(e){let t;try{t=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,error:`refused protocol ${t.protocol} (only http/https)`};let r=t.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(at.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let n=U.isIP(r);return n!==0&&!le(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:t,host:r,isLiteralIp:n!==0}}async function de(e,{lookupFn:t=ot.promises.lookup}={}){let r=it(e);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:U.isIPv6(r.host)?6:4}]};let n;try{n=await t(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(n)||n.length===0||n.some(o=>!le(o.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:n}}async function fe({requireUndici:e=!1,importUndici:t=()=>import("undici")}={}){let r,n;try{let l=await t();r=l.Agent,n=l.fetch}catch(l){if(e)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${l?.message||l}`);return null}if(typeof r!="function"||typeof n!="function"){if(e)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let o=l=>String(l).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),a=new Map,i=l=>(Array.isArray(l)?l:[l]).map(f=>typeof f=="string"?{address:f}:f).filter(f=>f&&f.address).map(f=>({address:f.address,family:f.family||(U.isIPv6(f.address)?6:4)})),c=(l,f,h)=>{a.set(o(l),i(typeof f=="string"?[{address:f,family:h}]:f))},u=l=>{let f=o(l);if(U.isIP(f))return[{address:f,family:U.isIPv6(f)?6:4}];let h=a.get(f);if(!h||!h.length)throw new Error(`refused: unpinned host ${l} during pinned fetch`);return h},d=new r({connect:{lookup(l,f,h){let m;try{m=u(l)}catch(p){return h(p)}return f?.all?h(null,m):h(null,m[0].address,m[0].family)}}}),s=st((l,f={})=>n(l,{...f,dispatcher:d}),c);return{dispatcher:d,fetch:s,pin:c,resolve:u,async close(){try{await d.destroy()}catch{}}}}var pe=Symbol.for("oracle.egressGuard.pinCapableFetch");function st(e,t){if(typeof e!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof t!="function")throw new Error("markPinCapableFetch: pin must be a function");return e[pe]=Object.freeze({pin:t}),e}function me(e){return typeof e=="function"&&typeof e[pe]?.pin=="function"}function Te(e,t,r){if(!me(e))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");e[pe].pin(t,r)}var ut=new Set([408,425,429,500,502,503,504]),Ie=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),lt=2,Oe=4e3,dt=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,ft=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,pt=AbortSignal.prototype.throwIfAborted,mt=EventTarget.prototype.addEventListener,_e=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,be=e=>e?dt.call(e):!1,ht=e=>e?ft.call(e):void 0,gt=new Set([301,302,303,307,308]),re=3,Hr=64*1024,F=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function A(e){return G(`HTTP JSON body refused: ${e}`)}function bt(e){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(t=>typeof M[t]=="function"&&M[t](e))}function wt(e){let t=[],r=0,n=0,o=0,a=0,i=new WeakSet,c=s=>{if(r+=Buffer.byteLength(s,"utf8"),r>F.bytes)throw A("serialized byte limit exceeded");t.push(s)},u=s=>{if(Buffer.byteLength(s,"utf8")>F.bytes)throw A("serialized byte limit exceeded");return JSON.stringify(s)},d=(s,l)=>{if(n+=1,n>F.nodes)throw A("node limit exceeded");if(l>F.depth)throw A("depth limit exceeded");if(s===null){c("null");return}if(typeof s=="string"){c(u(s));return}if(typeof s=="boolean"){c(s?"true":"false");return}if(typeof s=="number"){if(!Number.isFinite(s))throw A("non-finite number");c(Object.is(s,-0)?"0":String(s));return}if(typeof s!="object")throw A("unsupported non-JSON value");if(M.isProxy(s))throw A("proxy value");if(bt(s))throw A("unsupported exotic object");if(i.has(s))throw A("cyclic value");i.add(s);try{if(Object.getOwnPropertySymbols(s).length>0)throw A("symbol-keyed fields are unsupported");if(Array.isArray(s)){let m=Object.getPrototypeOf(s),p=0;for(;m!==null;){if(M.isProxy(m))throw A("proxy array prototype");if(p+=1,p>F.depth)throw A("array prototype depth limit exceeded");m=Object.getPrototypeOf(m)}if(s.length>F.arrayLength)throw A("array length limit exceeded");for(let y=0;y<s.length;y+=1){let P=Object.getOwnPropertyDescriptor(s,String(y));if(!P||!Object.hasOwn(P,"value")||P.enumerable!==!0)throw A("array entries must be dense enumerable own data")}let g=0;for(let y in s){if(a+=1,a>F.fields)throw A("enumeration limit exceeded");if(Object.hasOwn(s,y)&&(g+=1,g>s.length))throw A("named array fields are unsupported")}if(g!==s.length)throw A("array entries must be dense enumerable own data");c("[");for(let y=0;y<s.length;y+=1)y&&c(","),d(Object.getOwnPropertyDescriptor(s,String(y)).value,l+1);c("]");return}let f=Object.getPrototypeOf(s);if(f!==Object.prototype&&f!==null)throw A("non-plain object");let h=[];for(let m in s){if(a+=1,a>F.fields)throw A("enumeration limit exceeded");if(!Object.hasOwn(s,m))continue;if(o+=1,o>F.fields)throw A("field limit exceeded");let p=Object.getOwnPropertyDescriptor(s,m);if(!p||!Object.hasOwn(p,"value")||p.enumerable!==!0)throw A("object fields must be enumerable own data");h.push([m,p.value])}c("{");for(let m=0;m<h.length;m+=1)m&&c(","),c(u(h[m][0])),c(":"),d(h[m][1],l+1);c("}")}finally{i.delete(s)}};return d(e,0),t.join("")}function xt(e){let t=Object.create(null);if(e==null)return t;if(typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP headers must be an object");if(M.isProxy(e))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let n of Object.keys(e)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(n))throw new TypeError("HTTP header names must be valid tokens");let o=n.toLowerCase();if(r.has(o))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(o);let a=Object.getOwnPropertyDescriptor(e,n);if(!a||!Object.hasOwn(a,"value"))throw new TypeError("HTTP headers must contain own data properties");let i=a.value;if(i==null||["object","function","symbol"].includes(typeof i))throw new TypeError("HTTP header values must be scalar");t[n]=String(i)}return t}function yt(){return Object.assign(Object.create(null),{Accept:"application/json"})}function Et(e,t){if(!e)throw new Error(`HTTP redirect from ${t} missing Location`);let r=new URL(String(e),String(t));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${t} used unsupported protocol ${r.protocol}`);return r.toString()}function St(e,t){return new URL(String(e)).origin===new URL(String(t)).origin}var he=new Map,Pe=new WeakMap,Re=1;function te(e){if((typeof e!="object"||e===null)&&typeof e!="function")return`${typeof e}:${String(e)}`;let t=Pe.get(e);return t||(t=Re,Re+=1,Pe.set(e,t)),`reference:${t}`}var vt=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),At=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function Ne(e){if(!e||typeof e!="object"||Array.isArray(e)||!Object.hasOwn(e,"jsonrpc")||!Object.hasOwn(e,"method")||e.jsonrpc!=="2.0")return!1;let t=typeof e.method=="string"?e.method:"";return t?vt.has(t)||/^get[A-Z0-9_]/u.test(t)||/^is[A-Z0-9_]/u.test(t)||/^eth_get[A-Z0-9_]/u.test(t):!1}function Ce(e,t){if(e==="GET"&&t==null)return!0;if(e!=="POST"||t==null)return!1;let r=t;if(typeof t=="string")try{r=JSON.parse(t)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every(Ne);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return Ne(r);let n=Object.hasOwn(r,"type")?r.type:null;return typeof n=="string"&&At.has(n)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function Tt(e,t,r,n={},o=null){let a=ct("sha256"),i=(u,d)=>{let s=String(d);a.update(String(Buffer.byteLength(u,"utf8"))).update(":").update(u),a.update("=").update(String(Buffer.byteLength(s,"utf8"))).update(":").update(s).update(`
|
|
2
|
+
`)};i("method",e),i("url",t),Object.keys(r||{}).map((u,d)=>({name:u.toLowerCase(),order:d,value:String(r[u])})).sort((u,d)=>u.name.localeCompare(d.name)||u.order-d.order).forEach((u,d)=>{i(`header-name-${d}`,u.name),i(`header-value-${d}`,u.value)}),i("body",o??"-");for(let u of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])i(`context-${u}`,n[u]??"-");return a.digest("hex")}function It(e,t){let r=Number(t);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Oe):Math.min(250*2**e,Oe)+Math.floor(Math.random()*100)}var Ot=e=>new Promise(t=>setTimeout(t,e));function G(e,t={}){let r=new Error(e);return r.retryable=!1,Object.assign(r,t),r}function ge(e,t,r){return G(`HTTP response from ${e} exceeded maxResponseBytes ${r} (${t})`,{oversize:!0})}function q(e){try{let t=e?.body?.cancel?.();t&&typeof t.then=="function"&&t.catch(()=>{})}catch{}}function _t(e){return e?e.byteLength??e.length??0:0}async function Pt(e,t,{url:r,truncate:n=!1,onOversize:o}={}){if(t==null)return await e.text();let a=Number(e.headers?.get?.("content-length"));if(Number.isFinite(a)&&a>t&&(q(e),!n))throw ge(r,`content-length ${a}`,t);let i=e.body?.getReader?.();if(!i){let l=await e.text(),f=Buffer.byteLength(l,"utf8");if(f>t){if(!n)throw ge(r,`body ${f} bytes`,t);return Buffer.from(l,"utf8").subarray(0,t).toString("utf8")}return l}let c=[],u=0,d=!1;try{for(;;){let{value:l,done:f}=await i.read();if(f)break;if(l&&(c.push(Buffer.from(l)),u+=_t(l),u>t)){d=!0;break}}}finally{if(d)try{await i.cancel()}catch{}try{i.releaseLock?.()}catch{}}if(d&&(typeof o=="function"&&o(),!n))throw ge(r,`streamed ${u} bytes`,t);let s=Buffer.concat(c);return(d?s.subarray(0,t):s).toString("utf8")}function Rt(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}async function Nt(e,{fetchImpl:t,method:r,headers:n,body:o,timeoutMs:a,lookupFn:i,realFetch:c,untrustedUrl:u=!1,maxResponseBytes:d=null,sameOriginRedirectsOnly:s=!1,importUndici:l,validateResponse:f,signal:h,redirectPolicy:m="follow",maxRedirects:p=re}){let g=new AbortController,y=setTimeout(()=>g.abort(),a),P=h?_e?_e([h,g.signal]):h:g.signal,b=null,_=t,$=i?{lookupFn:i}:{};if(u&&!c&&!me(_))throw G(`HTTP refused ${e}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let W=async(x,{status:I=null}={})=>{let O=await de(x,$);if(!O.ok)throw G(I==null?`HTTP refused ${x}: ${O.error}`:`HTTP redirect to ${x} ${O.error}`,I==null?{}:{status:I});let B=new URL(x).hostname;if(c){if(b&&(await b.close(),b=null),!b)try{b=await fe({requireUndici:!0,...l?{importUndici:l}:{}})}catch(w){throw G(I==null?`HTTP refused ${x}: ${w?.message||w}`:`HTTP redirect to ${x} refused: ${w?.message||w}`,I==null?{}:{status:I})}b.pin(B,O.addresses),_=b.fetch}else Te(_,B,O.addresses);return O};try{let x=String(e),I=Object.assign(Object.create(null),n||{});u&&await W(x);for(let O=0;O<=p;O+=1){let B=Object.assign(Object.create(null),{method:r,headers:I,body:o,signal:P,redirect:"manual",dispatcher:void 0}),w=await _(x,B);if((m==="error"||p===0)&&w.status>=300&&w.status<400)throw q(w),G(`HTTP ${w.status} ${r} redirect refused`,{status:w.status,redirectRefused:!0});if(gt.has(w.status)){let N=s===!0&&r==="POST"&&[307,308].includes(w.status)&&Ce(r,o);if(r!=="GET"&&r!=="HEAD"&&!N){q(w);let T=new Error(`HTTP ${w.status} ${r} ${x} redirected non-idempotent request`);throw T.status=w.status,T}if(O===p)throw q(w),G(`HTTP ${w.status} ${r} redirect budget exhausted`,{status:w.status,redirectRefused:!0});let ve=w.headers?.get?.("location"),L;try{L=Et(ve,x)}catch(T){throw q(w),T}let j=!St(L,x);if(q(w),j&&r==="POST"){let T=new Error(`HTTP ${w.status} ${r} cross-origin redirect refused`);throw T.status=w.status,T}if(j&&s){let T=new Error(`HTTP ${w.status} ${r} cross-origin redirect refused`);throw T.status=w.status,T.retryable=!1,T}if(j&&(I=yt(I)),u)await W(L,{status:w.status});else if(j){let T=await de(L,$);if(!T.ok){let S=new Error(`HTTP redirect from ${x} ${T.error}`);throw S.status=w.status,S.retryable=!1,S}c&&T.addresses?.length&&(b||(b=await fe(l?{importUndici:l}:{})),b&&(b.pin(new URL(L).hostname,T.addresses),_=b.fetch))}x=L;continue}if(typeof f=="function")try{await f(w,{url:x})}catch(N){throw q(w),G(N?.message||String(N))}let R=await Pt(w,d,{url:x,onOversize:()=>g.abort()}),X=Rt(R);if(!w.ok){let N=new Error(`HTTP ${w.status} ${r} ${x}`);throw N.status=w.status,N.retryAfter=w.headers?.get?.("retry-after")??null,N.body=X??R.slice(0,300),N}return X??R}throw new Error(`HTTP redirect loop for ${e}`)}catch(x){if(g.signal.aborted&&!be(h)){let I=x&&(typeof x=="object"||typeof x=="function")&&!M.isProxy(x)?x:null,O=I?Object.getOwnPropertyDescriptor(I,"oversize"):null;if(!(O&&Object.hasOwn(O,"value")&&O.value===!0))try{if(!I)throw new TypeError("unsafe rejection");Object.defineProperties(I,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let w=new Error("HTTP request timed out");throw Object.defineProperties(w,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),w}}throw x}finally{clearTimeout(y),b&&await b.close()}}async function Le(e,t={}){if(t!=null&&typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP options must be an object");if(t!=null&&M.isProxy(t))throw new TypeError("HTTP options must not be a proxy");let r=new Set(["body","dedupe","fetchImpl","headers","importUndici","lookupFn","maxRedirects","maxResponseBytes","method","redirectPolicy","retries","sameOriginRedirectsOnly","signal","timeoutMs","untrustedUrl","validateResponse"]);if(t!=null){if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP options contain unknown fields");for(let S of Object.getOwnPropertyNames(t)){let E=Object.getOwnPropertyDescriptor(t,S);if(!(S==="toJSON"&&E&&Object.hasOwn(E,"value")&&E.value===void 0)){if(!r.has(S))throw new TypeError("HTTP options contain unknown fields");if(!E||!E.enumerable||!Object.hasOwn(E,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let n=S=>{if(t==null||!Object.hasOwn(t,S))return;let E=Object.getOwnPropertyDescriptor(t,S);if(!E||!Object.hasOwn(E,"value"))throw new TypeError("HTTP options must contain own data properties");return E.value};if(typeof e!="string"||e.length===0||e.length>8192)throw new TypeError("HTTP URL must be a bounded string");let o=n("method");if(o!==void 0&&(typeof o!="string"||!/^[A-Za-z]+$/u.test(o)))throw new TypeError("HTTP method must be a string token");let a=n("timeoutMs");if(a!==void 0&&(!Number.isInteger(a)||a<1||a>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let i=n("retries");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>10))throw new TypeError("HTTP retries must be a bounded integer");let c=n("redirectPolicy");if(c!==void 0&&c!=="follow"&&c!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let u=n("maxRedirects");if(u!==void 0&&(!Number.isInteger(u)||u<0||u>re))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${re}`);if(c==="error"&&u!==void 0&&u!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let d=c??"follow",s=d==="error"?0:u??re;for(let S of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let E=n(S);if(E!==void 0&&typeof E!="boolean")throw new TypeError(`HTTP ${S} must be boolean`)}let l=n("maxResponseBytes");if(l!==void 0&&(!Number.isInteger(l)||l<1||l>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let f=n("signal");if(f!==void 0){if(M.isProxy(f)||!(f instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{be(f)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let S of["importUndici","lookupFn","validateResponse"]){let E=n(S);if(E!==void 0&&typeof E!="function")throw new TypeError(`HTTP ${S} must be a function`)}let h=n("fetchImpl"),m=h||globalThis.fetch;if(typeof m!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let p=a??12e3,g=(o||"GET").toUpperCase(),y=n("headers"),P=xt(y),b=Object.assign(Object.create(null),P);Object.keys(b).some(S=>S.toLowerCase()==="accept")||(b.Accept="application/json");let _=n("body");_!=null&&typeof _!="string"&&(Object.keys(b).find(E=>E.toLowerCase()==="content-type")||(b["Content-Type"]="application/json"),_=wt(_));let $=i??lt,W=n("lookupFn"),x=!h,I=n("untrustedUrl")===!0,O=n("sameOriginRedirectsOnly")===!0,B=n("importUndici"),w=n("validateResponse"),R=f,X=l??null,N=async()=>{let S;for(let E=0;E<=$;E++){R&&pt.call(R);try{return await Nt(e,{fetchImpl:m,method:g,headers:b,body:_,timeoutMs:p,lookupFn:W,realFetch:x,untrustedUrl:I,maxResponseBytes:X,sameOriginRedirectsOnly:O,importUndici:B,validateResponse:w,signal:R,redirectPolicy:d,maxRedirects:s})}catch(D){S=D;let V=ce=>{if(!D||typeof D!="object"&&typeof D!="function"||M.isProxy(D))return;let Z=Object.getOwnPropertyDescriptor(D,ce);return Z&&Object.hasOwn(Z,"value")?Z.value:void 0},se=V("status"),et=V("oracleTimeout")===!0||V("name")==="AbortError"||V("name")==="TimeoutError"||be(R),tt=new Set([408,425,429]),rt=V("retryable")===!1?!1:se!=null?tt.has(se)||ut.has(se)&&Ie.has(g):!et&&Ie.has(g);if(E===$||!rt)throw D;let Ae=It(E,V("retryAfter"));R?await new Promise((ce,Z)=>{let nt=setTimeout(ce,Ae);mt.call(R,"abort",()=>{clearTimeout(nt),Z(ht(R)||new DOMException("Aborted","AbortError"))},{once:!0})}):await Ot(Ae)}}throw S};if(!(n("dedupe")!==!1&&!R&&Ce(g,_)))return N();let L=Tt(g,e,b,{untrustedUrl:I,maxResponseBytes:X,sameOriginRedirectsOnly:O,redirectPolicy:d,maxRedirects:s,timeoutMs:p,retries:$,fetchImpl:te(m),realFetch:x,lookupFn:te(W),importUndici:te(B),validateResponse:te(w)},_),j=he.get(L);if(j)return j;let T=N().finally(()=>he.delete(L));return he.set(L,T),T}var ke={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}},Ct=new Map(Object.values(ke).map(e=>[e.chainId,e]));function $e(e){return Ct.get(Number(e))||null}function Fe(e,t=process.env){let r=$e(e);if(!r)return null;for(let n of r.rpcEnv){let o=(t[n]||"").trim();if(o)return o}return null}import{Interface as Lt,getAddress as Zr}from"ethers";var Qr=new Lt(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var kt={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com"};function $t(e,{rpcUrl:t,env:r=process.env}={}){if(t)return t;let n=Fe(e,r);return n||kt[Number(e)]||null}var Ft=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function Mt(e){let t=String(e||""),r=t.toLowerCase();if(t!==t.trim()||!/^[a-zA-Z0-9_]+$/.test(t)||!Ft.test(r))throw new Error(`evm-rpc: ${t} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var Q=new Map,Me=new Map;function Bt(e){let t=new Error(e?.message||JSON.stringify(e));return t.code=e?.code,t}function Gt(e){if(e?.error)throw Bt(e.error);return e?.result}function Wt(e,t,r){return`${e}
|
|
3
|
+
${t}
|
|
4
|
+
${JSON.stringify(r??[])}`}async function jt(e,t,r){return Le(e,{method:"POST",body:t,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function C(e,t,r=[],n={}){let o=String(t||""),a=Mt(o),i=$t(e,n);if(!i)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);if(a==="eth_chainid"&&n.cacheChainId!==!1){let s=Me.get(i);if(s!=null)return s}let u=n.dedupe!==!1&&!n.signal?Wt(i,o,r):null;if(u&&Q.has(u))return Q.get(u);let d=(async()=>{let s=await jt(i,{jsonrpc:"2.0",id:1,method:t,params:r},n),l=Gt(s);return a==="eth_chainid"&&typeof l=="string"&&Me.set(i,l),l})();return u&&(Q.set(u,d),d.finally(()=>{Q.get(u)===d&&Q.delete(u)}).catch(()=>{})),d}var Dt=/^(0|[1-9][0-9]*)$/;function H(e,t,{required:r=!0,allowZero:n=!1}={}){if(e==null||e===""){if(r)throw new Error(`${t} required`);return null}let o;if(typeof e=="bigint")o=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);o=BigInt(e)}else if(typeof e=="string"){let a=e.trim();if(a.startsWith("0x")||a.startsWith("0X"))o=BigInt(a);else{if(!Dt.test(a))throw new Error(`${t} must be an integer wei string`);o=BigInt(a)}}else throw new Error(`${t} must be bigint, number, or integer string`);if(o<0n||!n&&o===0n)throw new Error(`${t} must be ${n?"non-negative":"positive"}`);return o}function Ut(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)throw new Error("chainId must be a positive integer");return t}function qt(e={}){return e.maxFeePerGas!=null?H(e.maxFeePerGas,"maxFeePerGas"):e.gasPrice!=null?H(e.gasPrice,"gasPrice"):null}function Be(e={}){try{let t=Ut(e.chainId??e.tx?.chainId),r=e.tx||e,n=e.policy||e,o=n.grant?.maxGasWei??e.grant?.maxGasWei,a=H(n.maxTotalGasWei??n.maxGasWei??o,"maxTotalGasWei"),i=H(r.gasLimit??r.gas,"gasLimit"),c=qt(r);if(c==null)throw new Error("maxFeePerGas or gasPrice required");let u=H(n.maxFeePerGasWei,"maxFeePerGasWei",{required:!1}),d=H(n.maxPriorityFeePerGasWei,"maxPriorityFeePerGasWei",{required:!1}),s=r.maxPriorityFeePerGas==null?null:H(r.maxPriorityFeePerGas,"maxPriorityFeePerGas"),l=i*c;return l>a?{ok:!1,status:"BLOCK",reason:`total gas ${l} exceeds cap ${a}`,chainId:t,totalGasWei:l.toString(),maxTotalGasWei:a.toString()}:u!=null&&c>u?{ok:!1,status:"BLOCK",reason:`unit fee ${c} exceeds cap ${u}`,chainId:t,unitFeeWei:c.toString(),maxFeePerGasWei:u.toString(),totalGasWei:l.toString(),maxTotalGasWei:a.toString()}:s!=null&&d!=null&&s>d?{ok:!1,status:"BLOCK",reason:`priority fee ${s} exceeds cap ${d}`,chainId:t,priorityFeeWei:s.toString(),maxPriorityFeePerGasWei:d.toString(),totalGasWei:l.toString(),maxTotalGasWei:a.toString()}:{ok:!0,status:"PASS",reason:"gas envelope within NFT mint gas-war caps",chainId:t,totalGasWei:l.toString(),maxTotalGasWei:a.toString(),unitFeeWei:c.toString(),maxFeePerGasWei:u?.toString()??null,priorityFeeWei:s?.toString()??null,maxPriorityFeePerGasWei:d?.toString()??null}}catch(t){return{ok:!1,status:"BLOCK",reason:String(t?.message||t)}}}var Ht=5,we=[50,75,90],Ge=Object.freeze({normal:{percentile:0,baseFeeMultiplier:2n,label:"normal"},fast:{percentile:1,baseFeeMultiplier:3n,label:"fast"},war:{percentile:2,baseFeeMultiplier:4n,label:"war"}});function z(e,t){if(e==null)return null;try{if(typeof e=="bigint")return e;if(typeof e=="number"){if(!Number.isFinite(e)||e<0)throw new Error("bad number");return BigInt(Math.floor(e))}let r=String(e).trim();return r.startsWith("0x"),BigInt(r)}catch{throw new Error(`${t} must be a non-negative integer (wei)`)}}function zt(e){let t=e.filter(r=>r!=null).sort((r,n)=>r<n?-1:r>n?1:0);return t.length?t[Math.floor(t.length/2)]:null}async function We(e={},t={}){let r=t.rpcCall||C,n=Number(e.chainId);if(!Number.isInteger(n))return{status:"error",error:"chainId is required",viable:!1};let o=Ge[e.urgency||"fast"];if(!o)return{status:"error",viable:!1,error:`urgency must be one of: ${Object.keys(Ge).join(", ")}`};let a,i,c,u;try{a=z(e.maxFeePerGasWei,"maxFeePerGasWei"),i=z(e.maxPriorityFeePerGasWei,"maxPriorityFeePerGasWei"),c=z(e.gasLimit,"gasLimit"),u=z(e.maxTotalGasWei,"maxTotalGasWei")}catch(x){return{status:"error",viable:!1,error:x.message}}let d,s;try{[d,s]=await Promise.all([r(n,"eth_feeHistory",[`0x${Ht.toString(16)}`,"pending",we],t),r(n,"eth_getBlockByNumber",["pending",!1],t)])}catch(x){return{status:"unavailable",viable:!1,error:x?.message||"fee history unavailable",notes:["could not read live fee data; refusing to guess a competitive bid"]}}let l=z(s?.baseFeePerGas,"baseFeePerGas")??z(d?.baseFeePerGas?.[d.baseFeePerGas.length-1],"baseFeePerGas");if(l==null)return{status:"unavailable",viable:!1,error:"chain did not report a baseFeePerGas (pre-EIP-1559?)",notes:["this pricer is EIP-1559 only"]};let h=(Array.isArray(d?.reward)?d.reward:[]).map(x=>{try{return z(x?.[o.percentile],"reward")}catch{return null}}).filter(x=>x!=null&&x>0n),m=zt(h),p=[];m==null&&p.push("no non-zero tips observed in recent blocks; using a 1 gwei floor");let g=m??1000000000n,y=l*o.baseFeeMultiplier+g,P=[];i!=null&&g>i&&(P.push({field:"maxPriorityFeePerGas",wanted:g.toString(),capped:i.toString()}),g=i,y=l*o.baseFeeMultiplier+g),a!=null&&y>a&&(P.push({field:"maxFeePerGas",wanted:y.toString(),capped:a.toString()}),y=a,g>y&&(g=y));let b=c!=null?c*y:null;u!=null&&b!=null&&b>u&&P.push({field:"totalGas",wanted:b.toString(),capped:u.toString()});let _=m==null||g>=m,$=u==null||b==null||b<=u,W=_&&$;return _||p.push(`tip cap ${g} is below the observed ${we[o.percentile]}th-percentile tip ${m}; this bid is unlikely to land`),$||p.push(`worst-case gas ${b} exceeds the ${u} total cap`),p.push("maxFeePerGas is a ceiling \u2014 unused headroom above basefee+tip is refunded, not spent"),{status:"ok",viable:W,chainId:n,urgency:o.label,baseFeePerGas:l.toString(),observedTip:m==null?null:m.toString(),percentile:we[o.percentile],maxFeePerGas:y.toString(),maxPriorityFeePerGas:g.toString(),worstCaseGasWei:b==null?null:b.toString(),clamps:P,notes:p}}var Vt=Object.freeze({"8da5cb5b":{name:"owner()",weight:"low",note:"contract has an owner"},f2fde38b:{name:"transferOwnership(address)",weight:"low",note:"ownership transferable"},"40c10f19":{name:"mint(address,uint256)",weight:"high",note:"owner can mint new supply"},a0712d68:{name:"mint(uint256)",weight:"high",note:"owner can mint new supply"},f9f92be4:{name:"blacklist(address)",weight:"high",note:"addresses can be blocked from selling"},e4997dc5:{name:"removeBlackList(address)",weight:"high",note:"blacklist machinery present"},"8456cb59":{name:"pause()",weight:"high",note:"transfers can be frozen"},"3f4ba83a":{name:"unpause()",weight:"high",note:"pausable transfers"},c0246668:{name:"setFee/excludeFromFee",weight:"high",note:"transfer fees can be changed"},"3659cfe6":{name:"upgradeTo(address)",weight:"high",note:"logic can be replaced entirely"},"4f1ef286":{name:"upgradeToAndCall(address,bytes)",weight:"high",note:"logic can be replaced entirely"}}),Jt=Object.freeze([{label:"eip1967",slot:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"},{label:"zeppelinos",slot:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"},{label:"eip1822",slot:"0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"}]),Kt=`0x${"0".repeat(64)}`;function Yt(e){return!e||e==="0x"||e===Kt}async function je(e={},t={}){let r=t.rpcCall||C,n=String(e.address||"").trim().toLowerCase(),o=Number(e.chainId);if(!/^0x[a-f0-9]{40}$/.test(n))return{status:"error",error:"address must be a 0x-prefixed EVM address",risk:"unknown-risk",findings:[],notes:[]};if(!Number.isInteger(o))return{status:"error",error:"chainId is required",risk:"unknown-risk",findings:[],notes:[]};let a;try{a=await r(o,"eth_getCode",[n,"latest"],t)}catch(p){return{address:n,chainId:o,status:"unavailable",error:p?.message||"eth_getCode failed",risk:"unknown-risk",findings:[],isProxy:!1,codeSize:0,notes:["could not read contract code; treat as unverified"]}}if(!a||a==="0x")return{address:n,chainId:o,status:"ok",risk:"high",findings:[{selector:"-",name:"no-code",weight:"high",note:"no contract deployed at this address"}],isProxy:!1,codeSize:0,notes:["nothing is deployed here \u2014 an approval or transfer to this address is unrecoverable"]};let i=[],c=[],u=a.slice(2).toLowerCase();for(let[p,g]of Object.entries(Vt))u.includes(p)&&c.push({selector:`0x${p}`,...g});let d=!1,s=null,l=null,f=await Promise.all(Jt.map(async({label:p,slot:g})=>{try{let y=await r(o,"eth_getStorageAt",[n,g,"latest"],t);return{label:p,word:y,error:null}}catch{return{label:p,word:null,error:`proxy slot (${p}) unreadable; proxy status uncertain`}}}));for(let p of f)p.error&&i.push(p.error),!d&&p.word&&!Yt(p.word)&&(d=!0,s=p.label,l=`0x${String(p.word).slice(-40)}`);d&&(c.push({selector:s,name:"proxy",weight:"high",note:"implementation is upgradeable \u2014 current behaviour is not a guarantee"}),i.push(`bytecode scan covers the proxy (${s}), not the implementation ${l} it delegates to`));let m=c.filter(p=>p.weight==="high").length>0?"high":c.length>0?"elevated":"unknown-risk";return m==="unknown-risk"&&i.push("no owner-power selectors found; this is weak evidence, not a safety guarantee"),{address:n,chainId:o,status:"ok",risk:m,findings:c,isProxy:d,proxyStandard:s,implementation:l,codeSize:Math.floor(u.length/2),notes:i}}var Xt="08c379a0",Zt="4e487b71",Qt=Object.freeze({1:"assertion failed",17:"arithmetic overflow or underflow",18:"division or modulo by zero",33:"invalid enum value",34:"invalid storage byte array encoding",49:"pop() on an empty array",50:"array index out of bounds",65:"out of memory",81:"call to an uninitialized function pointer"});function er(e){if(!e||e==="0x")return{kind:"empty",reason:"reverted without a reason (often a require with no message, or out of gas)"};let t=String(e).slice(2),r=t.slice(0,8);if(r===Xt)try{let n=parseInt(t.slice(72,136),16),o=t.slice(136,136+n*2);return{kind:"revert",reason:Buffer.from(o,"hex").toString("utf8"),selector:`0x${r}`}}catch{return{kind:"revert",reason:"Error(string) payload could not be decoded",selector:`0x${r}`}}if(r===Zt){let n=parseInt(t.slice(8,72),16);return{kind:"panic",code:n,reason:Qt[n]||`panic code 0x${n.toString(16)}`,selector:`0x${r}`}}return{kind:"custom",reason:`custom error ${`0x${r}`} (decoding needs the contract ABI)`,selector:`0x${r}`}}function tr(e){let t=[e?.data,e?.error?.data,e?.data?.data,e?.cause?.data,e?.body?.error?.data];for(let o of t){if(typeof o=="string"&&o.startsWith("0x")&&o.length>2)return o;if(typeof o?.data=="string"&&o.data.startsWith("0x")&&o.data.length>2)return o.data}let n=String(e?.message||"").match(/0x[0-9a-fA-F]{72,}/);return n?n[0]:null}function rr(e,t){if(t)return!0;let r=String(e?.message||"").toLowerCase();return!!/execution reverted|revert|invalid opcode|out of gas|stack underflow|insufficient funds for/.test(r)}function nr(e={}){let t={};return e.from&&(t.from=String(e.from).toLowerCase()),e.to&&(t.to=String(e.to).toLowerCase()),e.data&&e.data!=="0x"&&(t.data=e.data),e.value!=null&&String(e.value)!=="0"&&(t.value=`0x${BigInt(e.value).toString(16)}`),t}async function De(e={},t={}){let r=t.rpcCall||C,n=Number(e.chainId),o=e.tx||{};if(!Number.isInteger(n))return{status:"error",willRevert:null,error:"chainId is required"};if(!o.to||!/^0x[a-fA-F0-9]{40}$/.test(String(o.to)))return{status:"error",willRevert:null,error:"tx.to must be a valid address"};if(o.from&&!/^0x[a-fA-F0-9]{40}$/.test(String(o.from)))return{status:"error",willRevert:null,error:"tx.from must be a valid address"};let a=nr(o),i=[],c=null,u=!1,d=null;try{c=await r(n,"eth_call",[a,"pending"],t)}catch(m){let p=tr(m);if(!rr(m,!!p))return{status:"unavailable",willRevert:null,chainId:n,error:m?.message||"simulation unavailable",notes:["could not reach the node; this is NOT evidence the transaction would fail"]};u=!0,d=er(p),p||(d.reason="execution reverted (node did not return a reason payload)",d.kind="revert-no-data")}if(u)return{status:"ok",willRevert:!0,chainId:n,revert:d,summary:`would REVERT: ${d.reason}`,notes:["simulated against current chain state; signing this now would burn gas and fail"]};let s=null,l=null;if(e.estimateGas!==!1)try{let m=await r(n,"eth_estimateGas",[a,"pending"],t);s=BigInt(m);let p=BigInt(Math.max(0,Math.floor(e.gasBufferPercent??20)));l=s+s*p/100n,i.push(`gasLimit includes a ${p}% buffer over the ${s} estimate`)}catch(m){i.push(`gas estimation failed: ${m?.message||"unknown"}`)}i.push("a pass reflects CURRENT chain state \u2014 it is not a guarantee the transaction lands, and in a contested mint the state changes between blocks");let f=`0x${"0".repeat(64)}`,h=c===f;return h&&i.push("call did not revert but returned boolean false \u2014 some ERC-20s (e.g. USDC) signal failure this way instead of reverting"),{status:"ok",willRevert:!1,returnsFalse:h,chainId:n,returnData:c,gasEstimate:s==null?null:s.toString(),gasLimit:l==null?null:l.toString(),summary:h?"executes but returns FALSE \u2014 the contract is rejecting this operation":s?`would succeed, ~${s} gas`:"would succeed",notes:i}}var or=Object.freeze([{selector:"a0712d68",signature:"mint(uint256)",args:["quantity"]},{selector:"40c10f19",signature:"mint(address,uint256)",args:["to","quantity"]},{selector:"1249c58b",signature:"mint()",args:[]},{selector:"2db11544",signature:"publicMint(uint256)",args:["quantity"]},{selector:"efef39a1",signature:"purchase(uint256)",args:["quantity"]},{selector:"a6f2ae3a",signature:"buy()",args:[]}]);function ar(e){let t=BigInt(e).toString(16);if(t.length>64)throw new Error("value too large for a 32-byte word");return t.padStart(64,"0")}function ir(e){let t=String(e).toLowerCase().replace(/^0x/,"");if(!/^[a-f0-9]{40}$/.test(t))throw new Error(`invalid address: ${e}`);return t.padStart(64,"0")}function Ue(e,{minter:t,quantity:r}){let n=`0x${e.selector}`;for(let o of e.args)if(o==="to")n+=ir(t);else if(o==="quantity")n+=ar(r);else throw new Error(`unsupported mint argument: ${o}`);return n}function sr({address:e,chainId:t,minter:r,quantity:n,tx:o,nowMs:a,ttlMs:i=3e4}){if(!o?.gasLimit||!o?.maxFeePerGas)throw new Error("local-signer envelope requires gasLimit and maxFeePerGas");let c=Number(a??Date.now()),u=String(o.value??"0");return{version:1,surface:"evm-nft",action:"mint",provider:"nft-mint",owner:r,destination:e,contract:e,quantity:String(n),totalWei:u,slippageBps:0,expiresAtMs:c+Math.min(Math.max(Number(i)||3e4,1e3),6e4),fee:{oracleFeeBps:0},artifact:{chainId:t,owner:r,contract:e,quantity:String(n),totalWei:u,transactions:[{chainId:t,from:r,to:e,data:o.data,value:u,gasLimit:String(o.gasLimit),maxFeePerGas:String(o.maxFeePerGas),...o.maxPriorityFeePerGas!=null?{maxPriorityFeePerGas:String(o.maxPriorityFeePerGas),type:2}:{}}]}}}async function cr(e={},t={}){let r=t.rpcCall||C,n=String(e.address||"").trim().toLowerCase(),o=Number(e.chainId);if(!/^0x[a-f0-9]{40}$/.test(n))return{status:"error",error:"address must be a 0x-prefixed EVM address",found:[]};if(!Number.isInteger(o))return{status:"error",error:"chainId is required",found:[]};let a;try{a=await r(o,"eth_getCode",[n,"latest"],t)}catch(u){return{status:"unavailable",error:u?.message||"eth_getCode failed",found:[]}}if(!a||a==="0x")return{status:"ok",found:[],notes:["no contract deployed at this address"]};let i=a.slice(2).toLowerCase(),c=or.filter(u=>i.includes(u.selector));return{status:"ok",address:n,chainId:o,found:c,notes:c.length?[]:["no known public mint selector found; this contract may use a custom or allowlist-only entrypoint"]}}async function ne(e={},t={}){let r=String(e.contract||e.address||"").trim().toLowerCase(),n=Number(e.chainId),o=String(e.minter||e.from||"").trim().toLowerCase(),a=e.quantity==null?1:Number(e.quantity);if(!/^0x[a-f0-9]{40}$/.test(r))return{status:"error",error:"contract must be a 0x-prefixed EVM address"};if(!/^0x[a-f0-9]{40}$/.test(o))return{status:"error",error:"minter address is required"};if(!Number.isInteger(a)||a<1)return{status:"error",error:"quantity must be a positive integer"};if(!Number.isInteger(n))return{status:"error",error:"chainId is required"};let i=await cr({address:r,chainId:n},t);if(i.status!=="ok")return{status:i.status,error:i.error};if(!i.found.length)return{status:"unsupported",error:"no known public mint function found in this contract's bytecode",notes:i.notes};let c=e.signature?i.found.find(b=>b.signature===e.signature):i.found[0];if(!c)return{status:"error",error:`requested signature ${e.signature} not present in this contract`,available:i.found.map(b=>b.signature)};let u=i.found.length>1&&!e.signature,d=await je({address:r,chainId:n},t),s=null;if(e.simulate!==!1&&(s=await De({chainId:n,tx:{from:o,to:r,data:Ue(c,{minter:o,quantity:a}),value:e.valueWei},gasBufferPercent:e.gasBufferPercent},t),s.willRevert===!0&&e.ignoreRevert!==!0))return{status:"would-revert",error:`mint would revert: ${s.revert.reason}`,simulation:s,mintFunction:c.signature,notes:["signing this now would burn gas and fail; pass ignoreRevert to prepare anyway (e.g. a mint that has not opened yet)"]};let l=e.gasLimit??(s?.gasLimit?Number(s.gasLimit):null),f=await We({chainId:n,urgency:e.urgency||"war",gasLimit:l,maxFeePerGasWei:e.maxFeePerGasWei,maxPriorityFeePerGasWei:e.maxPriorityFeePerGasWei,maxTotalGasWei:e.maxTotalGasWei},t);if(f.status!=="ok")return{status:"unavailable",error:f.error,notes:f.notes};let h;try{h=Ue(c,{minter:o,quantity:a})}catch(b){return{status:"error",error:b.message}}let m={chainId:n,from:o,to:r,data:h,value:e.valueWei==null?"0":String(e.valueWei),gasLimit:l==null?null:String(l),maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas},p={ok:!0,skipped:!0,reason:"no gasLimit or cap supplied"};if(l!=null&&(e.maxTotalGasWei!=null||e.grant!=null)&&(p=Be({chainId:n,tx:{gasLimit:l,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas},policy:{maxTotalGasWei:e.maxTotalGasWei,maxFeePerGasWei:e.maxFeePerGasWei,maxPriorityFeePerGasWei:e.maxPriorityFeePerGasWei,grant:e.grant}}),!p.ok))return{status:"refused",error:`gas-war cap exceeded: ${p.reason||p.error}`,gas:f,capCheck:p};let g=[];u&&g.push(`contract exposes ${i.found.length} mint entrypoints (${i.found.map(b=>b.signature).join(", ")}); defaulted to ${c.signature} \u2014 pass signature to choose`),d.risk==="high"&&g.push(`contract risk HIGH: ${d.findings.map(b=>b.name).join(", ")}`),f.viable||g.push(f.notes[0]),p.skipped&&g.push("gas-war caps NOT enforced: supply gasLimit plus maxTotalGasWei or a grant");let y=null,P=null;try{y=sr({address:r,chainId:n,minter:o,quantity:a,tx:m,nowMs:t.nowMs,ttlMs:e.ttlMs??e.expiresInMs})}catch(b){P=String(b?.message||b).slice(0,200)}return{status:"ok",execution:y?"armed-local":"prepare-only",signed:y?"pending-local-signer":!1,broadcast:y?"pending-local-signer":!1,tx:m,localSignerEnvelope:y,localSignerBlockedReason:P,mintFunction:c.signature,alternatives:i.found.map(b=>b.signature),quantity:a,gas:f,simulation:s,contractRisk:{risk:d.risk,findings:d.findings,isProxy:d.isProxy},capCheck:p,warnings:g}}var hn=Object.freeze({READ:"read",PREPARE:"prepare",EXECUTE:"execute",AUTONOMOUS:"autonomous"});function qe(e=process.env){return String(e.ORACLE_AUTONOMOUS_TRADING??"").trim()==="1"}function ur(e={},{nowMs:t=Date.now()}={}){let r=[];if(!e||typeof e!="object")return{ok:!1,problems:["grant is required for execute mode"]};let n=String(e.contract||"").toLowerCase();if(/^0x[a-f0-9]{40}$/.test(n)||r.push("grant.contract must be an exact address"),Number.isInteger(Number(e.chainId))||r.push("grant.chainId is required"),e.maxTotalGasWei==null&&r.push("grant.maxTotalGasWei is required"),e.maxValueWei==null&&r.push("grant.maxValueWei is required (mint price ceiling)"),e.expiresAt!=null){let o=Number(e.expiresAt);Number.isFinite(o)?o<=t&&r.push("grant has expired"):r.push("grant.expiresAt must be a timestamp when supplied")}return{ok:r.length===0,problems:r,contract:n,chainId:Number(e.chainId)}}function He(e={},t={}){let n=e.actionMode==="execute"?"execute":e.actionMode||"alert_only",o=String(e.contract||"").trim().toLowerCase(),a=Number(e.chainId),i=[];if(!/^0x[a-f0-9]{40}$/.test(o))return{status:"error",error:"contract must be a 0x-prefixed EVM address"};if(!Number.isInteger(a))return{status:"error",error:"chainId is required"};if(n!=="alert_only"&&n!=="execute")return{status:"ok",actionMode:"alert_only",requestedMode:n,downgraded:!0,contract:o,chainId:a,quantity:e.quantity==null?1:Number(e.quantity),urgency:e.urgency||"war",grant:null,notes:[`unrecognized actionMode ${JSON.stringify(n)} \u2014 defaulted to alert_only; only the exact string "execute" arms a trigger`]};let c=n;if(n==="execute")if(!qe(t.env||process.env))c="alert_only",i.push("DOWNGRADED to alert_only: autonomous trading is off \u2014 set ORACLE_AUTONOMOUS_TRADING=1 to let a trigger fire unattended");else{let u=ur(e.grant,{nowMs:t.nowMs});u.ok?(u.contract!==o||u.chainId!==a)&&(c="alert_only",i.push("DOWNGRADED to alert_only: grant does not match this contract/chain \u2014 a grant authorizes one exact target")):(c="alert_only",i.push(`DOWNGRADED to alert_only: ${u.problems.join("; ")}`))}return c==="alert_only"?i.push("alert_only: Oracle will notify and prepare an artifact; you sign it"):i.push("ARMED until mint opens: this trigger will submit one prepared, capped mint automatically when the mint opens"),{status:"ok",actionMode:c,requestedMode:n,downgraded:c!==n,contract:o,chainId:a,quantity:e.quantity==null?1:Number(e.quantity),urgency:e.urgency||"war",grant:c==="execute"?e.grant:null,armedUntil:c==="execute"?"mint-opens":null,notes:i}}async function xe(e={},t={}){let r=t.rpcCall||C,n=String(e.contract||"").trim().toLowerCase(),o=Number(e.chainId);if(!/^0x[a-f0-9]{40}$/.test(n)||!Number.isInteger(o))return{status:"error",open:!1,error:"contract and chainId are required"};let a=[{selector:"0xeb8d2444",name:"saleIsActive()",openWhen:!0},{selector:"0x25fd90f3",name:"mintActive()",openWhen:!0},{selector:"0x68428a1b",name:"saleActive()",openWhen:!0},{selector:"0x22f3e2d4",name:"isActive()",openWhen:!0},{selector:"0x5c975abb",name:"paused()",openWhen:!1}];for(let i of a)try{let c=await r(o,"eth_call",[{to:n,data:i.selector},"latest"],t);if(c&&c!=="0x"){let u=BigInt(c)===1n;return{status:"ok",open:i.openWhen?u:!u,evidence:i.name,raw:c}}}catch{}return{status:"unknown",open:!1,notes:["no readable sale-state flag; cannot confirm the mint is open \u2014 will not fire on a guess"]}}async function ze(e={},t={}){if(e.status!=="ok")return{status:"error",error:"invalid trigger"};let r=await xe({contract:e.contract,chainId:e.chainId},t);if(!r.open)return{status:"waiting",open:!1,reason:r.notes?.[0]||`sale flag ${r.evidence||"unknown"} reports closed`};let n=await ne({contract:e.contract,chainId:e.chainId,minter:e.minter||t.minter,quantity:e.quantity,urgency:e.urgency,gasLimit:e.gasLimit??t.gasLimit,maxTotalGasWei:e.grant?.maxTotalGasWei??e.maxTotalGasWei??t.maxTotalGasWei,maxFeePerGasWei:e.maxFeePerGasWei??t.maxFeePerGasWei,maxPriorityFeePerGasWei:e.maxPriorityFeePerGasWei??t.maxPriorityFeePerGasWei,valueWei:e.valueWei??t.valueWei,grant:e.grant},t);if(n.status!=="ok")return{status:"blocked",open:!0,reason:n.error,prepared:n};if(e.actionMode==="execute"&&e.grant?.maxValueWei!=null){let o=BigInt(n.tx.value||"0");if(o>BigInt(e.grant.maxValueWei))return{status:"refused",open:!0,reason:`mint price ${o} exceeds granted maxValueWei ${e.grant.maxValueWei}`,prepared:n}}return{status:e.actionMode==="execute"?"fire":"alert",open:!0,actionMode:e.actionMode,prepared:n,signed:!1}}var Sn=Object.freeze([{selector:"0xeb8d2444",name:"saleIsActive()",openWhen:!0},{selector:"0x25fd90f3",name:"mintActive()",openWhen:!0},{selector:"0x68428a1b",name:"saleActive()",openWhen:!0},{selector:"0x22f3e2d4",name:"isActive()",openWhen:!0},{selector:"0x5c975abb",name:"paused()",openWhen:!1}]),v=Object.freeze({BUILDER_AUCTION:"builder-auction",OP_STACK_SEQUENCER:"op-stack-sequencer",NITRO_FCFS:"nitro-fcfs",HYPERBFT:"hyperbft",SOLANA_LEADER:"solana-leader",BITCOIN_FEE_RATE:"bitcoin-fee-rate"}),lr=Object.freeze({1:{chain:"Ethereum",regime:v.BUILDER_AUCTION},137:{chain:"Polygon",regime:v.BUILDER_AUCTION},56:{chain:"BNB Chain",regime:v.BUILDER_AUCTION},43114:{chain:"Avalanche C-Chain",regime:v.BUILDER_AUCTION},988:{chain:"Stable Mainnet",regime:v.BUILDER_AUCTION},8453:{chain:"Base",regime:v.OP_STACK_SEQUENCER},10:{chain:"OP Mainnet",regime:v.OP_STACK_SEQUENCER},7777777:{chain:"Zora",regime:v.OP_STACK_SEQUENCER},81457:{chain:"Blast",regime:v.OP_STACK_SEQUENCER},42161:{chain:"Arbitrum One",regime:v.NITRO_FCFS},4663:{chain:"Robinhood Chain",regime:v.NITRO_FCFS},2741:{chain:"Abstract",regime:v.NITRO_FCFS},999:{chain:"HyperEVM",regime:v.HYPERBFT}}),dr=Object.freeze({solana:{chain:"Solana",regime:v.SOLANA_LEADER},bitcoin:{chain:"Bitcoin",regime:v.BITCOIN_FEE_RATE},ordinals:{chain:"Bitcoin Ordinals",regime:v.BITCOIN_FEE_RATE}}),fr=Object.freeze({[v.BUILDER_AUCTION]:{ordering:"builder-auction",lever:"priority-fee",priorityFeeHelps:!0,latencyDecides:!1,privateRelayAvailable:!0,subSecondRace:!0,notes:["inclusion is bought through the block builder auction","priority fee is the lever that actually moves position","a private relay hides the transaction from the public mempool and avoids being front-run"]},[v.OP_STACK_SEQUENCER]:{ordering:"sequencer",lever:"priority-fee+latency",priorityFeeHelps:!0,latencyDecides:!0,privateRelayAvailable:!1,subSecondRace:!0,notes:["the sequencer mempool orders by effective gas price, so paying more does move you forward","arrival time still matters within a fee tier, so latency and fee are both live levers","there is no public builder auction to bid into and no private relay to hide in"]},[v.NITRO_FCFS]:{ordering:"sequencer",lever:"latency",priorityFeeHelps:!1,latencyDecides:!0,privateRelayAvailable:!1,subSecondRace:!0,notes:["Nitro timestamps by arrival order; fees do not reorder the sequencer queue","raw round-trip time is the only lever that changes position","co-locate near the sequencer endpoint rather than raising gas"]},[v.HYPERBFT]:{ordering:"consensus",lever:"latency",priorityFeeHelps:!1,latencyDecides:!0,privateRelayAvailable:!1,subSecondRace:!0,notes:["HyperBFT consensus orders transactions; there is no public builder auction to bid into","reaching a validator early is the lever, not paying more","block times are sub-second, so a slow RPC path costs whole blocks"]},[v.SOLANA_LEADER]:{ordering:"leader",lever:"priority-fee+latency",priorityFeeHelps:!0,latencyDecides:!0,privateRelayAvailable:!0,subSecondRace:!0,notes:["there is no mempool: transactions are sent to the current and next slot leaders","compute-unit price is the fee lever; Jito bundles are the private-inclusion path","landing depends on reaching the leader in time, so both levers are live"]},[v.BITCOIN_FEE_RATE]:{ordering:"fee-rate",lever:"fee-rate",priorityFeeHelps:!0,latencyDecides:!1,privateRelayAvailable:!1,subSecondRace:!1,notes:["inclusion is fee-rate against roughly ten-minute blocks, not a sub-second race","being milliseconds earlier does not change inclusion; sat/vB estimation does","a co-located executor buys nothing here \u2014 this is a fee-estimation problem"]}});function Ve(e){let t=e&&typeof e=="object"?e.chainId??e.family??e.chain:e,r=String(t??"").trim().toLowerCase(),n=dr[r]||lr[Number(t)];if(!n)return{chainId:Number.isInteger(Number(t))?Number(t):null,chain:null,regime:null,ordering:"unknown",lever:"unknown",priorityFeeHelps:null,latencyDecides:null,privateRelayAvailable:!1,subSecondRace:null,notes:["chain ordering not classified; treat inclusion strategy as unverified"]};let o=fr[n.regime];return{chainId:Number.isInteger(Number(t))?Number(t):null,chain:n.chain,regime:n.regime,...o,notes:[...o.notes]}}var Tn=Object.freeze({"0x02c88989":"setSaleIsActive(bool)","0x34918dfd":"flipSaleState()","0x5a67de07":"setSaleState(uint8)","0x3f4ba83a":"unpause()","0x16c38b3c":"setPaused(bool)","0xb66a0e5d":"startSale()","0xee1cc944":"setMintActive(bool)"});function pr(e){let t=Ve(e);return t.regime==="nitro-fcfs"?{visible:!1,reason:"Arbitrum orders at a private sequencer; there is no public pending pool to watch"}:t.regime==="op-stack-sequencer"?{visible:!1,reason:"the OP-stack sequencer holds pending transactions privately; public mempool watching will not see the opening transaction"}:t.regime==="solana-leader"?{visible:!1,reason:"Solana has no mempool; transactions go straight to the slot leader"}:t.regime==="hyperbft"?{visible:!1,reason:"HyperBFT orders through validator consensus; there is no public pending pool to watch"}:t.regime==="bitcoin-fee-rate"?{visible:!1,reason:"Bitcoin inclusion is fee-rate over ten-minute blocks, so there is no sub-second opening to detect"}:t.regime==="builder-auction"?{visible:!0,reason:"public mempool is observable, though private-relay transactions will not appear in it"}:{visible:!1,reason:"chain ordering not classified; mempool visibility unverified"}}function Je(e){let t=pr(e);return{chainId:Number(e),mempoolVisible:t.visible,reason:t.reason,fallback:t.visible?null:"poll sale state with probeMintOpenFast"}}import{existsSync as yr,readFileSync as Er}from"node:fs";import{request as Sr}from"node:http";import vr from"node:path";import oe from"node:fs";import mr from"node:os";import K from"node:path";import{fileURLToPath as hr}from"node:url";var gr=K.dirname(hr(import.meta.url)),Nn=K.resolve(gr,"../..");function Ke(){return process.env.ORACLE_FAKE_HOME||mr.homedir()}function br(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function ae(){return br()?process.env.ORACLE_CONFIG_DIR||K.join(Ke(),".config","oracle"):K.join(Ke(),".config","oracle")}function wr(){return K.join(ae(),"desk.json")}function xr(){return K.join(ae(),"env")}function J({force:e=!1}={}){if(J._done&&!e)return J._result||null;J._done=!0;let t={},r=(o,a)=>{if(a==null)return;let i=String(a).trim();i&&(process.env[o]!=null&&String(process.env[o]).trim()!==""||(process.env[o]=i,t[o]=i))};try{let o=xr();if(oe.existsSync(o))for(let a of oe.readFileSync(o,"utf8").split(/\r?\n/)){let i=a.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!i||i[2].startsWith("#"))continue;let c=i[2];(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),r(i[1],c)}}catch{}try{let o=wr();if(oe.existsSync(o)){let a=JSON.parse(oe.readFileSync(o,"utf8"));a&&typeof a=="object"&&(r("ORACLE_DESK_URL",a.deskUrl||a.dataUrl||a.url),r("ORACLE_DATA_URL",a.dataUrl||a.deskUrl||a.url),r("ORACLE_API_URL",a.apiUrl||a.dataUrl||a.deskUrl),r("ORACLE_PUBLIC_URL",a.publicUrl||a.deskUrl||a.dataUrl),r("ORACLE_EXEC_URL",a.execUrl),r("MAD_DESK_URL",a.deskUrl||a.dataUrl))}}catch{}let n=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return n&&(r("ORACLE_DESK_URL",n),r("ORACLE_DATA_URL",n),r("ORACLE_API_URL",n),r("ORACLE_PUBLIC_URL",n),r("MAD_DESK_URL",n)),J._result=Object.keys(t).length?t:null,J._result}try{J()}catch{}var Ar="http://127.0.0.1:9462";function Tr(e=process.env){let t=String(e.ORACLE_SIGNER_URL||Ar).replace(/\/$/,""),r;try{r=new URL(t)}catch{return null}return r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="::1"?null:r.origin}function Ir(e=process.env){if(e.ORACLE_SIGNER_TOKEN)return String(e.ORACLE_SIGNER_TOKEN);let t=vr.join(ae(),"signer","signer-token");return yr(t)?Er(t,"utf8").trim():null}function Or(e,{method:t="GET",body:r=null,env:n=process.env,timeoutMs:o=4e3}={}){let a=Tr(n),i=Ir(n);return!a||!i?Promise.resolve({ok:!1,error:"local signer is not running"}):new Promise(c=>{let u=new URL(e,a),d=r?Buffer.from(JSON.stringify(r)):null,s=Sr({hostname:u.hostname,port:u.port||80,path:u.pathname,method:t,timeout:o,headers:{authorization:`Bearer ${i}`,origin:a,...d?{"content-type":"application/json","content-length":d.length}:{}}},l=>{let f=[];l.on("data",h=>f.push(h)),l.on("end",()=>{let h=Buffer.concat(f).toString("utf8"),m={};try{m=h?JSON.parse(h):{}}catch{m={error:"signer refused"}}c({httpStatus:l.statusCode,...m})})});s.on("timeout",()=>{s.destroy(),c({ok:!1,error:"local signer timed out"})}),s.on("error",()=>c({ok:!1,error:"local signer is not running"})),d&&s.write(d),s.end()})}async function _r(e,t=process.env){if(!e||e.version!==1||!e.surface)throw new Error("queueOwnerAction: version-1 surface envelope required");return Or("/pending",{method:"POST",body:{artifact:e},env:t,timeoutMs:8e3})}async function Ye(e,t=process.env){let r=e?.localSignerEnvelope||e?.envelope;if(!r||r.version!==1||!r.surface)throw new Error("armPreparedAction: prepared.localSignerEnvelope v1 required");return _r(r,t)}import{Interface as Cr,MaxUint256 as xo,isAddress as yo,keccak256 as Eo,toUtf8Bytes as So}from"ethers";import{Interface as Rr,isAddress as Zn}from"ethers";import{isAddress as zn}from"ethers";var ro=new Rr(["function approve(address spender,uint256 amount) returns (bool)"]);import{Interface as Nr,isAddress as ao}from"ethers";var uo=new Nr(["function approve(address spender,uint256 amount) returns (bool)"]),lo=Object.freeze({42161:"0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41",43114:"0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2"});var _o=new Cr(["function approve(address spender,uint256 amount) returns (bool)"]);var Lr=new Set([10n,8453n,84532n,42161n,421614n,11155420n,7777777n]);function Xe(e){try{return Lr.has(BigInt(e))}catch{return!1}}var Qe=`oracle mint <watch|check|prepare> <contract> --chain <id> [options]
|
|
5
|
+
|
|
6
|
+
oracle mint check <contract> --chain <id> [--rpc-url <url>] [--json]
|
|
7
|
+
oracle mint prepare <contract> --chain <id> --minter <address> --max-total-gas-wei <wei> [--rpc-url <url>] [--queue] [--json]
|
|
8
|
+
oracle mint watch <contract> --chain <id> --minter <address> [--rpc-url <url>] [--queue] [--json]
|
|
9
|
+
|
|
10
|
+
Safe posture:
|
|
11
|
+
dry-run is the default; nothing is queued unless --queue is explicit
|
|
12
|
+
--queue sends one prepared envelope to the loopback local signer for owner approval
|
|
13
|
+
this command never signs or broadcasts
|
|
14
|
+
--execute, --arm, and --fire are refused because autonomous trigger attestation minting is not shipped
|
|
15
|
+
`,Ze=/^0x[0-9a-fA-F]{40}$/,kr=["--execute","--arm","--fire"];function k(e,t){let r=e.indexOf(t);return r>=0?e[r+1]:void 0}function $r(e){let t=e.reduce((o,a,i)=>a==="--rpc-url"?[...o,i]:o,[]);if(t.length===0)return;if(t.length!==1)throw new Error("--rpc-url must be specified exactly once");let r=String(e[t[0]+1]||"");if(r!==r.trim())throw new Error("--rpc-url must not contain surrounding whitespace");let n;try{n=new URL(r)}catch{throw new Error("--rpc-url must be an HTTP or HTTPS URL")}if(!["http:","https:"].includes(n.protocol))throw new Error("--rpc-url must be an HTTP or HTTPS URL");return r}function Y(e,t,{optional:r=!1,min:n=0}={}){if(r&&e==null)return;let o=String(e??"");if(!/^(0|[1-9][0-9]*)$/.test(o)||BigInt(o)<BigInt(n))throw new Error(`${t} must be an integer >= ${n}`);return o}function Fr(e,{requireMinter:t=!1}={}){let r=String(e[1]||"").trim().toLowerCase(),n=Number(k(e,"--chain")),o=String(k(e,"--minter")||"").trim().toLowerCase();if(!Ze.test(r))throw new Error("contract must be a 0x-prefixed EVM address");if(!Number.isSafeInteger(n)||n<=0)throw new Error("--chain must be a positive integer");if(t&&!Ze.test(o))throw new Error("--minter must be a 0x-prefixed EVM address");return{contract:r,chainId:n,...t?{minter:o}:{},quantity:Number(Y(k(e,"--quantity")??"1","quantity",{min:1})),urgency:k(e,"--urgency")||"war",signature:k(e,"--signature"),valueWei:Y(k(e,"--value-wei"),"valueWei",{optional:!0}),gasLimit:Y(k(e,"--gas-limit"),"gasLimit",{optional:!0,min:1}),maxTotalGasWei:Y(k(e,"--max-total-gas-wei"),"maxTotalGasWei",{optional:!0,min:1}),maxFeePerGasWei:Y(k(e,"--max-fee-per-gas-wei"),"maxFeePerGasWei",{optional:!0,min:1}),maxPriorityFeePerGasWei:Y(k(e,"--max-priority-fee-per-gas-wei"),"maxPriorityFeePerGasWei",{optional:!0})}}function Ee(e,t={}){return{...e,...t,broadcast:!1}}function Se(e,t,r){e.write(`${JSON.stringify(t,null,r?0:2)}
|
|
16
|
+
`)}var Mr={createTrigger:He,evaluateTrigger:ze,checkOpen:xe,prepare:ne,queuePrepared:Ye,mempoolSupport:Je,isRollup:Xe};async function Br(e=[],{out:t=process.stdout,err:r=process.stderr,env:n=process.env,deps:o={}}={}){let a=kr.find(s=>e.includes(s));if(a)return r.write(`oracle mint: ${a} refused; autonomous trigger attestation minting is not shipped
|
|
17
|
+
`),1;if(e.length===0||["--help","-h","help"].includes(e[0]))return t.write(Qe),0;let i={...Mr,...o},c=e[0],u=e.includes("--json"),d=e.includes("--queue");try{if(!["watch","check","prepare"].includes(c))return r.write(`oracle mint: unknown verb '${c}'. Try: oracle mint --help
|
|
18
|
+
`),1;let s=Fr(e,{requireMinter:c!=="check"}),l=$r(e),f={env:n,...l?{rpcUrl:l}:{}};if(d&&s.maxTotalGasWei==null)return r.write(`oracle mint: --max-total-gas-wei is required before --queue
|
|
19
|
+
`),1;if(d&&i.isRollup(s.chainId))return r.write(`oracle mint: queue refused on rollups because the prepared envelope does not yet carry required l1FeeWei and operatorFeeWei attestations
|
|
20
|
+
`),1;if(c==="check"){let g=await i.checkOpen({contract:s.contract,chainId:s.chainId},f);return Se(t,Ee({status:g.status,sale:g,mempool:i.mempoolSupport(s.chainId),queued:!1}),u),0}let h;if(c==="prepare"){let g=await i.prepare(s,f);h={status:g?.status||(g?.localSignerEnvelope?"ok":"error"),prepared:g,signed:!1}}else{let g=i.createTrigger({...s,actionMode:"alert_only"},{env:n});h=await i.evaluateTrigger(g,{...f,minter:s.minter,...s})}if(!d||!["alert","fire","ok"].includes(h?.status))return Se(t,Ee(h||{status:"error"},{queued:!1}),u),0;let m=h.prepared,p=await i.queuePrepared(m,n);return p?.ok!==!0?(r.write(`oracle mint: ${p?.error||"local signer refused the pending mint"}
|
|
21
|
+
`),1):(Se(t,Ee(h,{queued:!0,queue:p}),u),0)}catch(s){return r.write(`oracle mint: ${s?.message||s}
|
|
22
|
+
`),1}}var Go={name:"mint",summary:"evaluate and queue one bounded mint for local owner approval; never signs or broadcasts",usage:Qe,run:e=>Br(e.argv||[])};export{Go as default,Br as runMintCommand};
|