veriq-client 0.1.0 → 0.1.2

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import {a}from'./chunk-AYDF3IFZ.js';import {z as z$1}from'zod';var g={INVALID_PROOF:-32010,ROOT_UNAVAILABLE:-32011,UNSUPPORTED_VERIFICATION:-32012,PRIVACY_UNAVAILABLE:-32013,POLICY_UNSATISFIABLE:-32014,PROVIDER_TIMEOUT:-32015,ALL_PROVIDERS_FAILED:-32016,INVALID_REQUEST:-32602,INTERNAL_ERROR:-32603},A={ENGINE_UNREACHABLE:-1,SCHEMA_MISMATCH:-2},Ue="http://127.0.0.1:8547",he={INVALID_PROOF:"Every attempted proof failed verification against the pinned state root.",ROOT_UNAVAILABLE:"No trusted root: the light client is not synced and dev mode is off.",UNSUPPORTED_VERIFICATION:"This method or block tag cannot be proven under the chosen policy.",PRIVACY_UNAVAILABLE:"Privacy is required but no private-transport provider is healthy. Nothing was sent.",POLICY_UNSATISFIABLE:'The policy contradicts itself, e.g. "latest" blocks with verification required.',PROVIDER_TIMEOUT:"The shared deadline ran out before any provider returned a valid proof.",ALL_PROVIDERS_FAILED:"Every eligible provider failed or was cooling down.",INVALID_REQUEST:"The request parameters are malformed (bad address, slot or policy).",INTERNAL_ERROR:"The engine could not complete the request because an internal service is unavailable."},je={INVALID_PROOF:"Every provider sent a proof that does not match the finalized root. Add an honest provider or wait for cooldowns.",ROOT_UNAVAILABLE:"The light client hasn't synced a finalized root yet. Wait ~1 min or check /health.",UNSUPPORTED_VERIFICATION:"Veriq can't prove this method or block tag. Use blockTag 'finalized' or verification 'preferred'.",PRIVACY_UNAVAILABLE:"No private-transport provider is healthy. Use privacy 'preferred' or 'off'.",POLICY_UNSATISFIABLE:"latest + verification=required can't be proven. Use blockPolicy 'finalized'.",PROVIDER_TIMEOUT:"No valid proof arrived before the deadline. Raise timeoutMs or check provider health.",ALL_PROVIDERS_FAILED:"Every provider failed or is cooling down. Check veriq health for breaker states.",INVALID_REQUEST:"Check the address (0x + 40 hex), slot (0x + up to 64 hex) and policy fields.",INTERNAL_ERROR:"Retry shortly; if the error persists, check the engine health endpoint.",ENGINE_UNREACHABLE:`No Veriq engine at ${Ue}. Start it with: cd backend && cargo run -p veriq-server`,SCHEMA_MISMATCH:"The engine answered with a shape this SDK does not understand. Make sure SDK and engine versions match.",UNKNOWN:"Unexpected engine error. Check the engine logs."},H=class H extends Error{constructor(t,n,o={}){super(n,o.cause===void 0?void 0:{cause:o.cause}),this.name=new.target.name,this.code=t,this.codeName=be(t),this.hint=o.hint??je[this.codeName],o.data!==void 0&&(this.data=o.data);let s=o.receiptId??He(o.data);s!==void 0&&(this.receiptId=s);}get meaning(){return this.codeName in he?he[this.codeName]:this.message}toString(){return `VeriqError[${this.code} ${this.codeName}]: ${this.message} \u2014 ${this.hint}`}};a(H,"VeriqError");var h=H,z=class z extends h{};a(z,"InvalidProofError");var q=z,F=class F extends h{};a(F,"RootUnavailableError");var _=F,B=class B extends h{};a(B,"UnsupportedVerificationError");var S=B,G=class G extends h{};a(G,"PrivacyUnavailableError");var U=G,W=class W extends h{};a(W,"PolicyUnsatisfiableError");var j=W,Y=class Y extends h{};a(Y,"ProviderTimeoutError");var T=Y,K=class K extends h{};a(K,"AllProvidersFailedError");var M=K,Q=class Q extends h{};a(Q,"InvalidRequestError");var I=Q,J=class J extends h{};a(J,"InternalError");var D=J,Z=class Z extends h{};a(Z,"EngineUnreachableError");var O=Z,X=class X extends h{constructor(t,n={}){super(A.SCHEMA_MISMATCH,t.join("; "),n),this.issues=t;}};a(X,"VeriqSchemaError");var x=X,Me={[g.INVALID_PROOF]:q,[g.ROOT_UNAVAILABLE]:_,[g.UNSUPPORTED_VERIFICATION]:S,[g.PRIVACY_UNAVAILABLE]:U,[g.POLICY_UNSATISFIABLE]:j,[g.PROVIDER_TIMEOUT]:T,[g.ALL_PROVIDERS_FAILED]:M,[g.INVALID_REQUEST]:I,[g.INTERNAL_ERROR]:D,[A.ENGINE_UNREACHABLE]:O},De={...g,...A};function be(e){for(let[t,n]of Object.entries(De))if(n===e)return t;return "UNKNOWN"}a(be,"nameForCode");function Nt(e){let t=be(e);return t in g?t:void 0}a(Nt,"errorNameForCode");function He(e){if(e&&typeof e=="object"&&"receiptId"in e&&typeof e.receiptId=="string")return e.receiptId}a(He,"receiptIdFrom");function Re(e){let t=Me[e.code]??h;return new t(e.code,e.message,{data:e.data})}a(Re,"errorFromRpc");function kt(e){return e instanceof h}a(kt,"isVeriqError");var N=Object.freeze({verification:"required",privacy:"off",consistency:"single",blockPolicy:"finalized",timeoutMs:8e3}),ze=Object.freeze({...N,consistency:"compare"}),Fe=Object.freeze({...N,privacy:"required"}),Be=Object.freeze({verification:"preferred",privacy:"off",consistency:"single",blockPolicy:"finalized",timeoutMs:8e3}),Pt={verifiedFinalized:N,verifiedCompare:ze,privateVerified:Fe,devUnverified:Be};var ee="expected 0x-hex",ye=a(e=>z$1.string({required_error:ee,invalid_type_error:ee}).regex(e?new RegExp(`^0x[0-9a-fA-F]{${e*2}}$`):/^0x[0-9a-fA-F]+$/,e?`expected 0x-hex (${e} bytes)`:ee),"hex"),b=z$1.number({required_error:"expected a number"}).int().nonnegative(),re=ye(32),Ge=z$1.enum(["verified","unverified","unsupported"]),xe=z$1.enum(["local-light-client","fixture","untrusted-rpc"]),We=z$1.enum(["local-engine","remote-engine","browser"]),Ye=z$1.enum(["account-proof","storage-proof","code-hash"]),Ee=z$1.enum(["direct","ohttp","anyone-socks"]),Ke=z$1.enum(["not-run","agree","divergent"]),Qe=z$1.object({requestId:z$1.string(),method:z$1.string(),requestBinding:z$1.string(),resultBinding:z$1.string()}),Je=z$1.object({number:b,hash:re,stateRoot:re,finalized:z$1.boolean()}),Ze=z$1.object({source:z$1.string().nullable().default(null),checkpoint:z$1.string().nullable().default(null),checkpointSource:z$1.string().nullable().default(null)}),Xe=z$1.object({status:Ge,rootSource:xe,verifierLocation:We,mechanisms:z$1.array(Ye),bootstrap:Ze}),et=z$1.object({transport:Ee,mechanism:z$1.string().nullable().default(null)}),tt=z$1.enum(["success","transport-failure","provider-error","invalid-proof"]),rt=z$1.object({provider:z$1.string(),outcome:tt,elapsedMs:b,failureReason:z$1.string().nullish()}),nt=z$1.object({comparison:Ke,providersTried:b,providerLabel:z$1.string().nullable().default(null),attempts:z$1.array(rt).default([])}),ot=z$1.object({observedAt:b,ageSeconds:b,pinned:z$1.boolean()}),it=z$1.object({code:z$1.string(),message:z$1.string()}),k=z$1.object({identity:Qe,block:Je,verification:Xe,privacy:et,routing:nt,freshness:ot,warnings:z$1.array(it).default([])}),st=z$1.enum(["required","preferred","disabled"]),ve=z$1.enum(["finalized","latest"]),Se=z$1.object({verification:st,privacy:z$1.enum(["required","preferred","off"]),consistency:z$1.enum(["single","compare"]),blockPolicy:ve,timeoutMs:z$1.number().int().min(1).max(12e4)}),ne={success:"ok","invalid-proof":"INVALID_PROOF","transport-failure":"transport_error","provider-error":"PROVIDER_ERROR"};function at(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e,n=typeof t.outcome=="string"?ne[t.outcome]??t.outcome:t.outcome,o=t.reason??t.failureReason;return {provider:t.provider,outcome:n,elapsedMs:t.elapsedMs,...o!=null?{reason:o}:{}}}a(at,"normalizeAttempt");var Te=z$1.preprocess(at,z$1.object({provider:z$1.string(),outcome:z$1.string(),elapsedMs:z$1.number().nonnegative(),reason:z$1.string().nullish()})),ct=z$1.object({code:z$1.number().int(),message:z$1.string(),data:z$1.unknown().optional()}),Ie=z$1.object({value:ye(),receipt:k,attempts:z$1.array(Te).default([])}),oe=z$1.object({id:z$1.string(),createdAt:z$1.number(),method:z$1.string(),params:z$1.object({address:z$1.string().optional(),slot:z$1.string().optional()}),value:z$1.string().nullish(),blockNumber:b.nullish(),receipt:k.nullish(),error:ct.nullish(),attempts:z$1.array(Te).default([])}),Oe=z$1.object({receipts:z$1.array(oe)}),pt=z$1.enum(["closed","open","half-open"]),ie=z$1.object({name:z$1.string(),chainOk:z$1.boolean(),proofSupport:z$1.boolean(),eip1898:z$1.boolean(),transport:Ee.default("direct"),breaker:z$1.object({state:pt,cooldownUntil:z$1.number().nullish(),reason:z$1.string().nullish()}),successRate:z$1.number().min(0).max(1).nullish(),lastError:z$1.string().nullish()}),lt=z$1.object({synced:z$1.boolean(),finalizedNumber:b.nullish(),finalizedHash:re.nullish(),lagSeconds:b.nullish(),lastUpdateUnix:b.nullish(),headNumber:b.nullish(),checkpoint:z$1.string().nullish(),checkpointSource:z$1.string().nullish()}),ut=z$1.object({ok:z$1.boolean().default(true),chainId:z$1.number().int().optional(),bind:z$1.string().optional(),rootSource:xe.nullable(),devMode:z$1.boolean().default(false),providers:z$1.array(ie),providerCount:z$1.number().int().nonnegative(),lightClient:lt,error:z$1.object({code:z$1.string(),message:z$1.string()}).nullish()}),te=a(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj");function dt(e){if(!te(e))return e;let t=Array.isArray(e.providers)?e.providers:[],n=typeof e.providers=="number"?e.providers:t.length;if(te(e.lightClient))return {rootSource:null,providerCount:n,...e,providers:t};let o=te(e.bootstrap)?e.bootstrap:{},s=typeof e.rootSource=="string"?e.rootSource:null;return {ok:e.status===void 0?true:e.status==="ok",...typeof e.bind=="string"?{bind:e.bind}:{},rootSource:s,devMode:s==="untrusted-rpc",providers:t,providerCount:n,lightClient:{synced:e.synced===true,finalizedNumber:e.finalizedNumber??null,finalizedHash:e.finalizedHash??null,lagSeconds:e.lagSeconds??null,lastUpdateUnix:e.lastUpdateUnix??null,headNumber:e.headNumber??null,checkpoint:o.checkpoint??null,checkpointSource:o.checkpointSource??null},error:typeof e.error=="string"?{code:e.error,message:typeof e.message=="string"?e.message:""}:null}}a(dt,"normalizeHealth");var Ae=z$1.preprocess(dt,ut),Ne=z$1.object({methods:z$1.array(z$1.string()),verifiedMethods:z$1.array(z$1.string()).default([]),blockPolicies:z$1.array(ve).default(["finalized"]),privacy:z$1.boolean().default(false)}).passthrough();function ft(e,t){let n=e;for(let o of t){if(n===null||typeof n!="object")return;n=n[o];}return n}a(ft,"valueAt");function mt(e){return e===void 0?"undefined":typeof e=="string"?JSON.stringify(e.length>24?`${e.slice(0,24)}\u2026`:e):e===null||typeof e!="object"?String(e):Array.isArray(e)?"array":"object"}a(mt,"show");function w(e,t,n){return e.issues.map(o=>{let s=[n,...o.path].join("."),p=mt(ft(t,o.path)),u=o.message;return o.code==="invalid_type"&&o.message==="Required"?u=`expected ${o.expected}`:o.code==="invalid_type"&&o.message.startsWith("Expected")?u=`expected ${o.expected}`:o.code==="invalid_enum_value"&&(u=`expected one of ${o.options.join(" | ")}`),`${s}: ${u}, got ${p}`})}a(w,"formatIssues");var gt=1;function ht(e){return e.split(/[?#]/)[0]??e}a(ht,"safeUrl");function se(e,t,n){let o=ht(e.url)||"/";return new O(A.ENGINE_UNREACHABLE,`Could not reach the Veriq engine at ${o}: ${t}`,{hint:`No Veriq engine at ${o}. Start it with: cd backend && cargo run -p veriq-server`,cause:n})}a(se,"unreachable");async function ke(e,t,n,o,s){let p=new AbortController,u=false,m=setTimeout(()=>{u=true,p.abort();},o.timeoutMs),d=a(()=>p.abort(),"onAbort");o.signal?.addEventListener("abort",d,{once:true});let a$1=Date.now();try{let c;try{c=await e.fetch(t,{...n,signal:p.signal});}catch(f){throw u?new T(g.PROVIDER_TIMEOUT,`No answer from the engine within ${o.timeoutMs} ms (client-side timeout)`,{hint:"The engine did not answer in time. Raise timeoutMs, or check that the engine is healthy with: veriq health",cause:f}):o.signal?.aborted?f:se(e,f instanceof Error?f.message:String(f),f)}let l;try{l=await c.json();}catch(f){throw se(e,`HTTP ${c.status} with a non-JSON body. Is this a Veriq engine?`,f)}if(!c.ok&&!(l&&typeof l=="object"&&"error"in l))throw se(e,`HTTP ${c.status}`);return l}finally{clearTimeout(m),o.signal?.removeEventListener("abort",d),e.debug&&console.debug(`[veriq] ${s} ${Date.now()-a$1} ms`);}}a(ke,"send");async function E(e,t,n,o){let s=await ke(e,e.url||"/",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:gt++,method:t,params:n})},o,t);if(!s||typeof s!="object")throw new x([`response: expected a JSON-RPC object, got ${typeof s}`]);if("error"in s&&s.error&&typeof s.error=="object"){let p=s.error;if(typeof p.code=="number")throw Re({code:p.code,message:typeof p.message=="string"?p.message:"engine error",data:p.data})}if(!("result"in s))throw new x(["response.result: expected a value, got undefined"]);return s.result}a(E,"rpcCall");function $(e,t,n){return ke(e,`${e.url}${t}`,{method:"GET"},n,`GET ${t.split("?")[0]}`)}a($,"httpGet");function R(e,t,n){let o=e.safeParse(t);if(!o.success)throw new x(w(o.error,t,n));return o.data}a(R,"parseWith");function we(e,t){return e?.[t]??"latest"}a(we,"blockTag");function ae(e,t={}){let n=t.policy??e.policy,o=t.strict??n.verification==="required",s,p=a(c=>{s=c,t.onReceipt?.(c);},"record"),u=a((c,l)=>{if(l==="finalized")return true;if(o)throw new S(g.UNSUPPORTED_VERIFICATION,`${c} at block "${typeof l=="string"?l:"custom"}" can't be proven; only "finalized" can`,{hint:"Pass blockTag: 'finalized' (viem defaults to 'latest')."});return false},"verifiedPath");async function m({method:c,params:l}){if(c==="eth_getBalance"&&u(c,we(l,1))){let f=await e.readBalance({address:String(l?.[0]),policy:n});return p(f.receipt),`0x${f.value.toString(16)}`}if(c==="eth_getStorageAt"&&u(c,we(l,2))){let f=await e.readStorage({address:String(l?.[0]),slot:String(l?.[1]),policy:n});return p(f.receipt),f.value}return e.request(c,l?[...l]:[])}a(m,"request");let d=m,a$1=a((()=>({config:{key:"veriq",name:"Veriq",request:d,retryCount:0,type:"veriq"},request:d,value:{get lastReceipt(){return s}}})),"transport");return Object.defineProperty(a$1,"lastReceipt",{get:a(()=>s,"get"),enumerable:true}),a$1}a(ae,"createTransport");var $e="http://127.0.0.1:8547",Rt=/^0x[0-9a-fA-F]{40}$/,yt=/^0x[0-9a-fA-F]{1,64}$/;function Pe(e){return e.routing.attempts.map(t=>({provider:t.provider,outcome:ne[t.outcome]??t.outcome,elapsedMs:t.elapsedMs,...t.failureReason?{reason:t.failureReason}:{}}))}a(Pe,"attemptsFromReceipt");function le(e){return new I(g.INVALID_REQUEST,e)}a(le,"invalid");function ce(e){if(typeof e!="string"||!Rt.test(e))throw le("address must be 0x followed by 40 hex characters")}a(ce,"assertAddress");function Ce(e){if(typeof e!="string"||!yt.test(e))throw le("slot must be 0x followed by 1 to 64 hex characters")}a(Ce,"assertSlot");function pe(e){let t=Se.safeParse(e);if(!t.success)throw le(w(t.error,e,"policy").join("; "))}a(pe,"assertPolicy");function Ve(e={}){let t=(e.url??$e).replace(/\/$/,""),n=e.policy??N;pe(n);let o=e.fetch??((a,c)=>globalThis.fetch(a,c)),s={url:t,fetch:o,debug:e.debug??false},p=a(a=>e.timeoutMs??a.timeoutMs+1e3,"readTimeout"),u={timeoutMs:e.timeoutMs??5e3};async function m(a,c,l,f){pe(l);let y=await E(s,a,[...c,l],{timeoutMs:p(l),...f?{signal:f}:{}}),v=R(Ie,y,"result");return {...v,attempts:v.attempts.length?v.attempts:Pe(v.receipt)}}a(m,"read");let d={url:t,policy:n,async readBalance({address:a,policy:c=n,signal:l}){ce(a);let f=await m("veriq_readBalance",[a],c,l);return {value:BigInt(f.value),receipt:f.receipt,verified:f.receipt.verification.status==="verified",attempts:f.attempts}},async readStorage({address:a,slot:c,policy:l=n,signal:f}){ce(a),Ce(c);let y=await m("veriq_readStorage",[a,c],l,f);return {value:`0x${BigInt(y.value).toString(16).padStart(64,"0")}`,receipt:y.receipt,verified:y.receipt.verification.status==="verified",attempts:y.attempts}},async getReceipt(a){let c=await E(s,"veriq_getReceipt",[a],u),l=c&&typeof c=="object"&&"receipt"in c&&!("identity"in c)?c.receipt:c;return R(k,l,"receipt")},async getReceiptRecord(a){return R(oe,await $(s,`/receipts/${encodeURIComponent(a)}`,u),"record")},async listReceipts(a=50){return R(Oe,await $(s,`/receipts?limit=${a}`,u),"receipts").receipts},async health(){return R(Ae,await $(s,"/health",u),"health")},async providers(){let a=await E(s,"veriq_getProviderHealth",[],u),c=a&&typeof a=="object"&&"providers"in a?a.providers:a;return R(z$1.array(ie),c,"providers")},async capabilities(){return R(Ne,await E(s,"veriq_getCapabilities",[],u),"capabilities")},transport:a(a=>ae(d,a),"transport"),withPolicy:a(a=>Ve({...e,policy:a}),"withPolicy"),request:a((a,c=[])=>E(s,a,c,{timeoutMs:p(n)}),"request")};return Object.freeze(d)}a(Ve,"createVeriq");var Le=10n**18n;function qe(e,t={}){let n=t.decimals??4,o=t.symbol===false?"":" ETH",s=typeof e=="bigint"?e:BigInt(e),p=s<0n,u=p?-s:s,m=u/Le,d=(u%Le).toString().padStart(18,"0").slice(0,n).replace(/0+$/,"");if(m===0n&&d===""&&u>0n)return `${p?">-":"<"}0.${"0".repeat(Math.max(0,n-1))}1${o}`;let a=m.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");return `${p?"-":""}${a}${d?`.${d}`:""}${o}`}a(qe,"formatEth");function P(e,t=4,n=4){let o=e.startsWith("0x")?t+2:t;return e.length<=o+n+1?e:`${e.slice(0,o)}\u2026${e.slice(-n)}`}a(P,"shortHash");function ue(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}a(ue,"formatNumber");function de(e){switch(e){case "local-light-client":return "local light client (Helios)";case "fixture":return "fixture (tests only)";case "untrusted-rpc":return "untrusted RPC (DEV MODE)"}}a(de,"rootSourceLabel");function xt(e){return "identity"in e?{receipt:e,attempts:[]}:{receipt:e.receipt,...e.value!==void 0?{value:e.value}:{},attempts:e.attempts??[]}}a(xt,"split");function Et(e){return e==="verified"?"ok":e==="unverified"?"warn":"lav"}a(Et,"statusTone");function vt(e,t){if(t===void 0)return "";if(/storage/i.test(e.identity.method)){let n=typeof t=="bigint"?t:BigInt(t);return n<10n**15n?n.toString():P(`0x${n.toString(16)}`)}return qe(t)}a(vt,"formatValue");function C(e){let{receipt:t,value:n,attempts:o}=xt(e),s=[{label:"block",value:`#${ue(t.block.number)} ${P(t.block.hash)}${t.block.finalized?"":" (not finalized)"}`},{label:"stateRoot",value:P(t.block.stateRoot)},{label:"root",value:de(t.verification.rootSource),tone:t.verification.rootSource==="untrusted-rpc"?"warn":"ink"}],p=o.reduce((d,a)=>d+a.elapsedMs,0),u=o.length||t.routing.providersTried,m=[t.routing.providerLabel??"\u2014",`${u} attempt${u===1?"":"s"}`,...o.length?[`${Math.round(p)} ms`]:[]].join(" \xB7 ");s.push({label:"provider",value:m});for(let d of o)d.outcome!=="ok"&&s.push({label:"rejected",value:`${d.provider} ${d.outcome}`,tone:"err"});t.routing.comparison!=="not-run"&&s.push({label:"compare",value:t.routing.comparison,tone:t.routing.comparison==="agree"?"ok":"warn"});for(let d of t.warnings)s.push({label:"warning",value:d.code,tone:"warn"});return {status:t.verification.status,value:vt(t,n),rows:s}}a(C,"receiptRows");function St(e){let{status:t,value:n,rows:o}=C(e);return [`${t.toUpperCase()}${n?` ${n}`:""}`,...o.map(s=>`${s.label.padEnd(10)} ${s.value}`)].join(`
2
- `)}a(St,"formatReceipt");function fe(e){let t=e.lightClient,n=t.finalizedNumber!=null&&t.headNumber!=null?`${t.headNumber-t.finalizedNumber} blocks behind head`:"",o=[{label:"engine",value:`${e.ok?"online":`degraded${e.error?` \xB7 ${e.error.code}`:""}`}${e.bind?` \xB7 ${e.bind}`:""}`,tone:e.ok?"ok":"warn"},{label:"root",value:e.rootSource?de(e.rootSource):"none yet (light client not synced)",tone:!e.rootSource||e.devMode||e.rootSource==="untrusted-rpc"?"warn":"ink"},{label:"light",value:t.synced?"synced":"not synced",tone:t.synced?"ok":"warn"},{label:"finalized",value:t.finalizedNumber!=null?`#${ue(t.finalizedNumber)}${n?` \xB7 ${n}`:""}`:"\u2014"}],s=e.providers.map(p=>[p.name,p.chainOk?"yes":"no",p.proofSupport?"yes":"no",p.eip1898?"yes":"no",p.breaker.state,p.transport]);return e.providers.length===0&&o.push({label:"providers",value:`${e.providerCount} configured`,tone:"ink"}),{engine:o,providers:s}}a(fe,"healthRows");var Tt={ink:null,muted:[91,91,102],lav:[156,149,214],border:[156,149,214],title:[107,98,181],ok:[47,158,110],warn:[183,121,31],err:[194,65,91]};function _e(e){return globalThis.process?.env?.[e]}a(_e,"env");function L(){return _e("NO_COLOR")!==void 0?false:_e("FORCE_COLOR")!==void 0?true:globalThis.process?.stdout?.isTTY===true}a(L,"supportsColor");function ge(e){return (t,n,o=false)=>{let s=Tt[t];return !e||!s&&!o?n:`${o?"\x1B[1m":""}${s?`\x1B[38;2;${s[0]};${s[1]};${s[2]}m`:""}${n}\x1B[0m`}}a(ge,"painter");function me(e,t,n){let o=Math.max(e.length+6,...t.map(m=>m.plain.length))+4,s=`${n("border","\u256D\u2500 ")}${n("title",e,true)}${n("border",` ${"\u2500".repeat(o-e.length-3)}\u256E`)}`,p=t.map(m=>`${n("border","\u2502")} ${m.painted}${" ".repeat(o-m.plain.length-1)}${n("border","\u2502")}`),u=n("border",`\u2570${"\u2500".repeat(o)}\u256F`);return [s,...p,u].join(`
3
- `)}a(me,"box");var V=11;function It(e,t={}){let n=ge(t.color??L()),{status:o,value:s,rows:p}=C(e),u=o==="verified"?"ok":o==="unverified"?"warn":"lav",m=`\u25CF ${o.toUpperCase()}`,d=" ".repeat(Math.max(2,22-m.length)),a=[{plain:`${m}${d}${s}`,painted:`${n(u,m,true)}${d}${n("ink",s,true)}`},...p.map(c=>({plain:`${c.label.padEnd(V)}${c.value}`,painted:`${n("muted",c.label.padEnd(V))}${n(c.tone??"ink",c.value)}`}))];return me("Veriq \xB7 Trust Receipt",a,n)}a(It,"prettyReceipt");function Ot(e,t={}){let n=ge(t.color??L()),{engine:o,providers:s}=fe(e),p=o.map(a=>({plain:`${a.label.padEnd(V)}${a.value}`,painted:`${n("muted",a.label.padEnd(V))}${n(a.tone??"ink",a.value)}`})),u=["provider","chain","proof","1898","breaker","transport"],m=u.map((a,c)=>Math.max(a.length,...s.map(l=>(l[c]??"").length))+2),d=a(a=>a.map((c,l)=>c.padEnd(m[l]??0)).join("").trimEnd(),"fmt");if(s.length===0)return me("Veriq \xB7 Engine health",p,n);p.push({plain:"",painted:""}),p.push({plain:d(u),painted:n("muted",d(u))});for(let a of s){let c=d(a),l=a[1]==="no"||a[2]==="no"||a[4]!=="closed";p.push({plain:c,painted:n(l?"err":"ink",c)});}return me("Veriq \xB7 Engine health",p,n)}a(Ot,"prettyHealth");function At(e,t={}){let n=ge(t.color??L());return `${n("err",`\u2715 ${e.name} [${e.code} ${e.codeName}]`,true)}
1
+ import {a}from'./chunk-AYDF3IFZ.js';import {z}from'zod';var R={INVALID_PROOF:-32010,ROOT_UNAVAILABLE:-32011,UNSUPPORTED_VERIFICATION:-32012,PRIVACY_UNAVAILABLE:-32013,POLICY_UNSATISFIABLE:-32014,PROVIDER_TIMEOUT:-32015,ALL_PROVIDERS_FAILED:-32016,ROOT_MISMATCH:-32017,INVALID_REQUEST:-32602,INTERNAL_ERROR:-32603},L={ENGINE_UNREACHABLE:-1,SCHEMA_MISMATCH:-2,CHAIN_MISMATCH:-3},Pt="http://127.0.0.1:8547",nt={INVALID_PROOF:"Every attempted proof failed verification against the pinned state root.",ROOT_UNAVAILABLE:"No trusted root: the light client is not synced and dev mode is off.",UNSUPPORTED_VERIFICATION:"This method or block tag cannot be proven under the chosen policy.",PRIVACY_UNAVAILABLE:"Privacy is required but no private-transport provider is healthy. Nothing was sent.",POLICY_UNSATISFIABLE:'The policy contradicts itself, e.g. "latest" blocks with verification required.',PROVIDER_TIMEOUT:"The shared deadline ran out before any provider returned a valid proof.",ALL_PROVIDERS_FAILED:"Every eligible provider failed or was cooling down.",ROOT_MISMATCH:"Two trusted light clients (engine and browser) report different roots for the same finalized block.",INVALID_REQUEST:"The request parameters are malformed (bad address, slot or policy).",INTERNAL_ERROR:"The engine could not complete the request because an internal service is unavailable."},Nt={INVALID_PROOF:"Every provider sent a proof that does not match the finalized root. Add an honest provider or wait for cooldowns.",ROOT_UNAVAILABLE:"The light client hasn't synced a finalized root yet. Wait ~1 min or check /health.",UNSUPPORTED_VERIFICATION:"Veriq can't prove this method or block tag. Use blockTag 'finalized' or verification 'preferred'.",PRIVACY_UNAVAILABLE:"No private-transport provider is healthy. Use privacy 'preferred' or 'off'.",POLICY_UNSATISFIABLE:"latest + verification=required can't be proven. Use blockPolicy 'finalized'.",PROVIDER_TIMEOUT:"No valid proof arrived before the deadline. Raise timeoutMs or check provider health.",ALL_PROVIDERS_FAILED:"Every provider failed or is cooling down. Check veriq health for breaker states.",ROOT_MISMATCH:"Nothing was verified. One light client follows a wrong chain or a bad checkpoint: check both checkpoints and consensus APIs.",INVALID_REQUEST:"Check the address (0x + 40 hex), slot (0x + up to 64 hex) and policy fields.",INTERNAL_ERROR:"Retry shortly; if the error persists, check the engine health endpoint.",ENGINE_UNREACHABLE:`No Veriq engine at ${Pt}. Start it with: cd backend && cargo run -p veriq-server`,SCHEMA_MISMATCH:"The engine answered with a shape this SDK does not understand. Make sure SDK and engine versions match.",CHAIN_MISMATCH:"The engine serves another chain than this reader reads. Point the client at an engine started with the matching VERIQ_NETWORK.",UNKNOWN:"Unexpected engine error. Check the engine logs."},xe=class xe extends Error{constructor(t,r,i={}){super(r,i.cause===void 0?void 0:{cause:i.cause}),this.name=new.target.name,this.code=t,this.codeName=ot(t),this.hint=i.hint??Nt[this.codeName],i.data!==void 0&&(this.data=i.data);let s=i.receiptId??Ct(i.data);s!==void 0&&(this.receiptId=s);}get meaning(){return this.codeName in nt?nt[this.codeName]:this.message}toString(){return `VeriqError[${this.code} ${this.codeName}]: ${this.message} \u2014 ${this.hint}`}};a(xe,"VeriqError");var S=xe,Ee=class Ee extends S{};a(Ee,"InvalidProofError");var B=Ee,Se=class Se extends S{};a(Se,"RootUnavailableError");var J=Se,Ie=class Ie extends S{};a(Ie,"UnsupportedVerificationError");var X=Ie,Ae=class Ae extends S{};a(Ae,"PrivacyUnavailableError");var W=Ae,ke=class ke extends S{};a(ke,"PolicyUnsatisfiableError");var ve=ke,Te=class Te extends S{};a(Te,"ProviderTimeoutError");var Z=Te,Oe=class Oe extends S{};a(Oe,"AllProvidersFailedError");var ee=Oe,Pe=class Pe extends S{};a(Pe,"RootMismatchError");var te=Pe,Ne=class Ne extends S{};a(Ne,"InvalidRequestError");var C=Ne,_e=class _e extends S{};a(_e,"InternalError");var re=_e,$e=class $e extends S{};a($e,"ChainMismatchError");var ne=$e,Ce=class Ce extends S{};a(Ce,"EngineUnreachableError");var D=Ce,Ve=class Ve extends S{constructor(t,r={}){super(L.SCHEMA_MISMATCH,t.join("; "),r),this.issues=t;}};a(Ve,"VeriqSchemaError");var G=Ve,_t={[R.INVALID_PROOF]:B,[R.ROOT_UNAVAILABLE]:J,[R.UNSUPPORTED_VERIFICATION]:X,[R.PRIVACY_UNAVAILABLE]:W,[R.POLICY_UNSATISFIABLE]:ve,[R.PROVIDER_TIMEOUT]:Z,[R.ALL_PROVIDERS_FAILED]:ee,[R.ROOT_MISMATCH]:te,[R.INVALID_REQUEST]:C,[R.INTERNAL_ERROR]:re,[L.ENGINE_UNREACHABLE]:D,[L.CHAIN_MISMATCH]:ne},$t={...R,...L};function ot(e){for(let[t,r]of Object.entries($t))if(r===e)return t;return "UNKNOWN"}a(ot,"nameForCode");function Dr(e){let t=ot(e);return t in R?t:void 0}a(Dr,"errorNameForCode");function Ct(e){if(e&&typeof e=="object"&&"receiptId"in e&&typeof e.receiptId=="string")return e.receiptId}a(Ct,"receiptIdFrom");function it(e){let t=_t[e.code]??S;return new t(e.code,e.message,{data:e.data})}a(it,"errorFromRpc");function qr(e){return e instanceof S}a(qr,"isVeriqError");var oe=Object.freeze({verification:"required",privacy:"off",consistency:"single",blockPolicy:"finalized",timeoutMs:8e3}),Vt=Object.freeze({...oe,consistency:"compare"}),Lt=Object.freeze({...oe,privacy:"required"}),Dt=Object.freeze({verification:"preferred",privacy:"off",consistency:"single",blockPolicy:"finalized",timeoutMs:8e3}),Br={verifiedFinalized:oe,verifiedCompare:Vt,privateVerified:Lt,devUnverified:Dt};var Le="expected 0x-hex",ie=a(e=>z.string({required_error:Le,invalid_type_error:Le}).regex(e?new RegExp(`^0x[0-9a-fA-F]{${e*2}}$`):/^0x[0-9a-fA-F]+$/,e?`expected 0x-hex (${e} bytes)`:Le),"hex"),N=z.number({required_error:"expected a number"}).int().nonnegative(),U=ie(32),qt=z.enum(["verified","unverified","unsupported"]),st=z.enum(["local-light-client","fixture","untrusted-rpc"]),Mt=z.enum(["local-engine","remote-engine","browser"]),Ht=z.enum(["account-proof","storage-proof","code-hash"]),at=z.enum(["direct","ohttp","anyone-socks","anon-rpc"]),Bt=z.enum(["not-run","agree","divergent"]),Ut=z.object({requestId:z.string(),method:z.string(),requestBinding:z.string(),resultBinding:z.string()}),jt=z.object({number:N,hash:U,stateRoot:U,finalized:z.boolean(),chainId:N.optional()}),zt=z.object({source:z.string().nullable().default(null),checkpoint:z.string().nullable().default(null),checkpointSource:z.string().nullable().default(null)}),Ft=z.object({status:qt,rootSource:st,verifierLocation:Mt,mechanisms:z.array(Ht),bootstrap:zt}),Wt=z.object({transport:at,mechanism:z.string().nullable().default(null)}),Gt=z.enum(["success","transport-failure","provider-error","invalid-proof"]),Kt=z.object({provider:z.string(),outcome:Gt,elapsedMs:N,failureReason:z.string().nullish()}),Yt=z.object({comparison:Bt,providersTried:N,providerLabel:z.string().nullable().default(null),attempts:z.array(Kt).default([])}),Qt=z.object({observedAt:N,ageSeconds:N,pinned:z.boolean()}),Jt=z.object({code:z.string(),message:z.string()}),q=z.object({identity:Ut,block:jt,verification:Ft,privacy:Wt,routing:Yt,freshness:Qt,warnings:z.array(Jt).default([])}),Xt=z.enum(["required","preferred","disabled"]),ct=z.enum(["finalized","latest"]),lt=z.object({verification:Xt,privacy:z.enum(["required","preferred","off"]),consistency:z.enum(["single","compare"]),blockPolicy:ct,timeoutMs:z.number().int().min(1).max(12e4)}),qe={success:"ok","invalid-proof":"INVALID_PROOF","transport-failure":"transport_error","provider-error":"PROVIDER_ERROR"};function Zt(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e,r=typeof t.outcome=="string"?qe[t.outcome]??t.outcome:t.outcome,i=t.reason??t.failureReason;return {provider:t.provider,outcome:r,elapsedMs:t.elapsedMs,...i!=null?{reason:i}:{}}}a(Zt,"normalizeAttempt");var ut=z.preprocess(Zt,z.object({provider:z.string(),outcome:z.string(),elapsedMs:z.number().nonnegative(),reason:z.string().nullish()})),er=z.object({code:z.number().int(),message:z.string(),data:z.unknown().optional()}),Me=z.object({value:ie(),receipt:q,attempts:z.array(ut).default([])}),dt=z.object({number:z.number().int().nonnegative(),hash:U,stateRoot:U,rootSource:z.string(),verified:z.boolean(),chainId:z.number().int().positive().optional()}),He=z.object({id:z.string(),createdAt:z.number(),method:z.string(),params:z.object({address:z.string().optional(),slot:z.string().optional()}),value:z.string().nullish(),blockNumber:N.nullish(),receipt:q.nullish(),error:er.nullish(),attempts:z.array(ut).default([])}),pt=z.object({receipts:z.array(He)}),tr=z.enum(["closed","open","half-open"]),Be=z.object({name:z.string(),chainOk:z.boolean(),proofSupport:z.boolean(),eip1898:z.boolean(),transport:at.default("direct"),breaker:z.object({state:tr,cooldownUntil:z.number().nullish(),reason:z.string().nullish()}),successRate:z.number().min(0).max(1).nullish(),lastError:z.string().nullish()}),rr=z.object({synced:z.boolean(),finalizedNumber:N.nullish(),finalizedHash:U.nullish(),lagSeconds:N.nullish(),lastUpdateUnix:N.nullish(),headNumber:N.nullish(),checkpoint:z.string().nullish(),checkpointSource:z.string().nullish()}),nr=z.object({ok:z.boolean().default(true),chainId:z.number().int().optional(),bind:z.string().optional(),rootSource:st.nullable(),devMode:z.boolean().default(false),providers:z.array(Be),providerCount:z.number().int().nonnegative(),lightClient:rr,error:z.object({code:z.string(),message:z.string()}).nullish()}),De=a(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj");function or(e){if(!De(e))return e;let t=Array.isArray(e.providers)?e.providers:[],r=typeof e.providers=="number"?e.providers:t.length;if(De(e.lightClient))return {rootSource:null,providerCount:r,...e,providers:t};let i=De(e.bootstrap)?e.bootstrap:{},s=typeof e.rootSource=="string"?e.rootSource:null;return {ok:e.status===void 0?true:e.status==="ok",...typeof e.bind=="string"?{bind:e.bind}:{},rootSource:s,devMode:s==="untrusted-rpc",providers:t,providerCount:r,lightClient:{synced:e.synced===true,finalizedNumber:e.finalizedNumber??null,finalizedHash:e.finalizedHash??null,lagSeconds:e.lagSeconds??null,lastUpdateUnix:e.lastUpdateUnix??null,headNumber:e.headNumber??null,checkpoint:i.checkpoint??null,checkpointSource:i.checkpointSource??null},error:typeof e.error=="string"?{code:e.error,message:typeof e.message=="string"?e.message:""}:null}}a(or,"normalizeHealth");var ft=z.preprocess(or,nr),gt=z.object({methods:z.array(z.string()),verifiedMethods:z.array(z.string()).default([]),blockPolicies:z.array(ct).default(["finalized"]),privacy:z.boolean().default(false)}).passthrough(),ir=z.union([z.object({status:z.enum(["normal-eoa","contract","revoked","invalid-designator"])}),z.object({status:z.literal("delegated"),delegate:ie(20)}),z.enum(["normal-eoa","delegated","contract","revoked","invalid-designator"])]),sr=z.enum(["normal-eoa","smart-contract","delegation-detected","delegation-revoked","unverified-delegate","delegate-code-verified","potential-risk","security-assessment-unavailable"]),mt=z.object({address:ie(20),status:ir,isDelegated:z.boolean(),delegateAddress:ie(20).nullish(),codeHash:U,delegateCodeHash:U.nullish(),securityClassification:sr,blockNumber:N.optional(),verified:z.boolean().default(true),receipt:q});function ar(e,t){let r=e;for(let i of t){if(r===null||typeof r!="object")return;r=r[i];}return r}a(ar,"valueAt");function cr(e){return e===void 0?"undefined":typeof e=="string"?JSON.stringify(e.length>24?`${e.slice(0,24)}\u2026`:e):e===null||typeof e!="object"?String(e):Array.isArray(e)?"array":"object"}a(cr,"show");function le(e,t,r){return e.issues.map(i=>{let s=[r,...i.path].join("."),l=cr(ar(t,i.path)),u=i.message;return i.code==="invalid_type"&&i.message==="Required"?u=`expected ${i.expected}`:i.code==="invalid_type"&&i.message.startsWith("Expected")?u=`expected ${i.expected}`:i.code==="invalid_enum_value"&&(u=`expected one of ${i.options.join(" | ")}`),`${s}: ${u}, got ${l}`})}a(le,"formatIssues");var lr=1;function ur(e){return e.split(/[?#]/)[0]??e}a(ur,"safeUrl");function Ue(e,t,r){let i=ur(e.url)||"/";return new D(L.ENGINE_UNREACHABLE,`Could not reach the Veriq engine at ${i}: ${t}`,{hint:`No Veriq engine at ${i}. Start it with: cd backend && cargo run -p veriq-server`,cause:r})}a(Ue,"unreachable");async function ht(e,t,r,i,s){let l=new AbortController,u=false,h=setTimeout(()=>{u=true,l.abort();},i.timeoutMs),g=a(()=>l.abort(),"onAbort");i.signal?.addEventListener("abort",g,{once:true});let a$1=Date.now();try{let c;try{c=await e.fetch(t,{...r,signal:l.signal});}catch(m){throw u?new Z(R.PROVIDER_TIMEOUT,`No answer from the engine within ${i.timeoutMs} ms (client-side timeout)`,{hint:"The engine did not answer in time. Raise timeoutMs, or check that the engine is healthy with: veriq health",cause:m}):i.signal?.aborted?m:Ue(e,m instanceof Error?m.message:String(m),m)}let d;try{d=await c.json();}catch(m){throw Ue(e,`HTTP ${c.status} with a non-JSON body. Is this a Veriq engine?`,m)}if(!c.ok&&!(d&&typeof d=="object"&&"error"in d))throw Ue(e,`HTTP ${c.status}`);return d}finally{clearTimeout(h),i.signal?.removeEventListener("abort",g),e.debug&&console.debug(`[veriq] ${s} ${Date.now()-a$1} ms`);}}a(ht,"send");async function V(e,t,r,i){return (await je(e,t,r,i)).result}a(V,"rpcCall");async function je(e,t,r,i){let s=await ht(e,e.url||"/",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:lr++,method:t,params:r})},i,t);if(!s||typeof s!="object")throw new G([`response: expected a JSON-RPC object, got ${typeof s}`]);if("error"in s&&s.error&&typeof s.error=="object"){let l=s.error;if(typeof l.code=="number")throw it({code:l.code,message:typeof l.message=="string"?l.message:"engine error",data:l.data})}if(!("result"in s))throw new G(["response.result: expected a value, got undefined"]);return "veriq"in s&&s.veriq!=null?{result:s.result,veriq:s.veriq}:{result:s.result}}a(je,"rpcEnvelope");function ue(e,t,r){return ht(e,`${e.url}${t}`,{method:"GET"},r,`GET ${t.split("?")[0]}`)}a(ue,"httpGet");function _(e,t,r){let i=e.safeParse(t);if(!i.success)throw new G(le(i.error,t,r));return i.data}a(_,"parseWith");function ze(e,t){return e?.[t]??"latest"}a(ze,"blockTag");function Fe(e,t={}){let r=t.policy??e.policy,i=t.strict??r.verification==="required",s,l=a(c=>{s=c,t.onReceipt?.(c);},"record"),u=a((c,d)=>{if(d==="finalized")return true;if(i)throw new X(R.UNSUPPORTED_VERIFICATION,`${c} at block "${typeof d=="string"?d:"custom"}" can't be proven; only "finalized" can`,{hint:"Pass blockTag: 'finalized' (viem defaults to 'latest')."});return false},"verifiedPath");async function h({method:c,params:d}){if(c==="eth_getBalance"&&u(c,ze(d,1))){let T=await e.readBalance({address:String(d?.[0]),policy:r});return l(T.receipt),`0x${T.value.toString(16)}`}if(c==="eth_getStorageAt"&&u(c,ze(d,2))){let T=await e.readStorage({address:String(d?.[0]),slot:String(d?.[1]),policy:r});return l(T.receipt),T.value}if((c==="eth_getTransactionCount"||c==="eth_getCode")&&u(c,ze(d,1))){let{result:T,receipt:$}=await e.requestWithReceipt(c,d?[...d]:[]);return $&&l($),T}let{result:m,receipt:E}=await e.requestWithReceipt(c,d?[...d]:[]);return E&&l(E),m}a(h,"request");let g=h,a$1=a((()=>({config:{key:"veriq",name:"Veriq",request:g,retryCount:0,type:"veriq"},request:g,value:{get lastReceipt(){return s}}})),"transport");return Object.defineProperty(a$1,"lastReceipt",{get:a(()=>s,"get"),enumerable:true}),a$1}a(Fe,"createTransport");var Rt="http://127.0.0.1:8547",pr=/^0x[0-9a-fA-F]{40}$/,fr=/^0x[0-9a-fA-F]{1,64}$/;function ae(e){return e.routing.attempts.map(t=>({provider:t.provider,outcome:qe[t.outcome]??t.outcome,elapsedMs:t.elapsedMs,...t.failureReason?{reason:t.failureReason}:{}}))}a(ae,"attemptsFromReceipt");function de(e){return new C(R.INVALID_REQUEST,e)}a(de,"invalid");function M(e){if(typeof e!="string"||!pr.test(e))throw de("address must be 0x followed by 40 hex characters")}a(M,"assertAddress");function ce(e){if(typeof e!="string"||!fr.test(e))throw de("slot must be 0x followed by 1 to 64 hex characters")}a(ce,"assertSlot");function se(e){let t=lt.safeParse(e);if(!t.success)throw de(le(t.error,e,"policy").join("; "))}a(se,"assertPolicy");function bt(e={}){let t=(e.url??Rt).replace(/\/$/,""),r=e.policy??oe;se(r);let i=e.fetch??((a,c)=>globalThis.fetch(a,c)),s={url:t,fetch:i,debug:e.debug??false},l=a(a=>e.timeoutMs??a.timeoutMs+1e3,"readTimeout"),u={timeoutMs:e.timeoutMs??5e3};async function h(a,c,d,m){se(d);let E=await V(s,a,[...c,d],{timeoutMs:l(d),...m?{signal:m}:{}}),T=_(Me,E,"result");return {...T,attempts:T.attempts.length?T.attempts:ae(T.receipt)}}a(h,"read");let g={url:t,policy:r,async readBalance({address:a,policy:c=r,signal:d}){M(a);let m=await h("veriq_readBalance",[a],c,d);return {value:BigInt(m.value),receipt:m.receipt,verified:m.receipt.verification.status==="verified",attempts:m.attempts}},async readStorage({address:a,slot:c,policy:d=r,signal:m}){M(a),ce(c);let E=await h("veriq_readStorage",[a,c],d,m);return {value:`0x${BigInt(E.value).toString(16).padStart(64,"0")}`,receipt:E.receipt,verified:E.receipt.verification.status==="verified",attempts:E.attempts}},async getDelegation({address:a,policy:c=r,signal:d}){M(a),se(c);let m=await V(s,"veriq_getDelegation",[a,c],{timeoutMs:l(c),...d?{signal:d}:{}});return _(mt,m,"delegation")},async getReceipt(a){let c=await V(s,"veriq_getReceipt",[a],u),d=c&&typeof c=="object"&&"receipt"in c&&!("identity"in c)?c.receipt:c;return _(q,d,"receipt")},async getReceiptRecord(a){return _(He,await ue(s,`/receipts/${encodeURIComponent(a)}`,u),"record")},async listReceipts(a=50){return _(pt,await ue(s,`/receipts?limit=${a}`,u),"receipts").receipts},async health(){return _(ft,await ue(s,"/health",u),"health")},async providers(){let a=await V(s,"veriq_getProviderHealth",[],u),c=a&&typeof a=="object"&&"providers"in a?a.providers:a;return _(z.array(Be),c,"providers")},async getRoot(){return _(dt,await V(s,"veriq_getRoot",[],u),"root")},async verifyProof(a,c=r){if(se(c),M(a.address),a.kind==="storage"){if(a.slot===void 0)throw de("a storage proof needs a slot");ce(a.slot);}let{slot:d,elapsedMs:m,...E}=a,T={...E,...a.kind==="storage"?{slot:d}:{},...m===void 0?{}:{elapsedMs:m}},$=await V(s,"veriq_verifyProof",[T,c],{timeoutMs:l(c)}),z=_(Me,$,"result");return {value:z.value,receipt:z.receipt,verified:z.receipt.verification.status==="verified",attempts:ae(z.receipt)}},async capabilities(){return _(gt,await V(s,"veriq_getCapabilities",[],u),"capabilities")},transport:a(a=>Fe(g,a),"transport"),withPolicy:a(a=>bt({...e,policy:a}),"withPolicy"),request:a((a,c=[])=>V(s,a,c,{timeoutMs:l(r)}),"request"),async requestWithReceipt(a,c=[]){let{result:d,veriq:m}=await je(s,a,c,{timeoutMs:l(r)});return {result:d,receipt:m===void 0?void 0:_(q,m,"veriq")}}};return Object.freeze(g)}a(bt,"createVeriq");var gr="0xef0100",cn=23,ln=48,mr="0x0000000000000000000000000000000000000000";function hr(e){let t=e.toLowerCase(),r=t.startsWith("0x")?t:`0x${t}`;if(r==="0x"||r.length<=2)return {isDesignator:false,delegate:null,isRevoked:false,isMalformed:false};if(!r.startsWith(gr))return {isDesignator:false,delegate:null,isRevoked:false,isMalformed:false};if(r.length!==48)return {isDesignator:false,delegate:null,isRevoked:false,isMalformed:true};let i=`0x${r.slice(8)}`,s=i===mr;return {isDesignator:!s,delegate:s?null:i,isRevoked:s,isMalformed:false}}a(hr,"parseDelegationDesignator");function yt(e){let t=hr(e);if(t.isMalformed)return {status:{status:"invalid-designator"},isDelegated:false,delegateAddress:null};if(t.isRevoked)return {status:{status:"revoked"},isDelegated:false,delegateAddress:null};if(t.isDesignator&&t.delegate)return {status:{status:"delegated",delegate:t.delegate},isDelegated:true,delegateAddress:t.delegate};let r=e.startsWith("0x")?e:`0x${e}`;return r==="0x"||r.length<=2?{status:{status:"normal-eoa"},isDelegated:false,delegateAddress:null}:{status:{status:"contract"},isDelegated:false,delegateAddress:null}}a(yt,"classifyAccountCode");var St={1:["nym","tor"],11155111:["nox"]};function It(e,t){let r=St[e];if(!r)throw new W(R.PRIVACY_UNAVAILABLE,`no private network is known for chain ${e}`);if(!r.includes(t))throw new W(R.PRIVACY_UNAVAILABLE,`"${t}" does not carry chain ${e}; use ${r.map(i=>`"${i}"`).join(" or ")}`,{hint:"The private network follows the chain: Nox on Sepolia, Nym or Tor on mainnet. Nothing was sent."})}a(It,"assertNetworkForChain");var wt=/^[A-Za-z0-9_.-]{1,64}$/,Rr=1,vt=160,br=new Set(["localhost","127.0.0.1","[::1]"]),yr=1500,xt=/^0x[0-9a-fA-F]{64}$/,wr={balance:["account-proof"],nonce:["account-proof"],storage:["account-proof","storage-proof"],code:["account-proof","code-hash"]},We=class We extends Error{constructor(r,i){super(r);this.code=i;}};a(We,"UpstreamError");var H=We,j=a(e=>new C(R.INVALID_REQUEST,e),"invalid");function vr(e){if(!Array.isArray(e.providers)||e.providers.length===0)throw j("createPrivateReader needs at least one provider");if(typeof e.network!="string"||!wt.test(e.network))throw j("network must be 1-64 letters, digits, '_', '-' or '.'");let t=new Set;e.providers.forEach((r,i)=>{if(typeof r.label!="string"||!wt.test(r.label))throw j(`providers[${i}].label must be 1-64 letters, digits, '_', '-' or '.'`);if(t.has(r.label))throw j(`provider label "${r.label}" is used twice`);t.add(r.label);let s;try{s=new URL(r.url);}catch{throw j(`provider "${r.label}": url is not a valid URL`)}let l=s.protocol==="http:"&&br.has(s.hostname);if(s.protocol!=="https:"&&!(e.allowInsecureLoopback&&l))throw j(`provider "${r.label}": url must be https`)});}a(vr,"validateOptions");function xr(e){let t=new Set;for(let{url:r}of e){t.add(r);try{let i=new URL(r);t.add(`${i.origin}${i.pathname}`);for(let s of i.pathname.split("/"))s.length>=8&&t.add(s);for(let s of i.searchParams.values())s.length>=8&&t.add(s);i.username&&t.add(i.username),i.password&&t.add(i.password);}catch{}}return [...t].sort((r,i)=>i.length-r.length)}a(xr,"secretsOf");function Et(e,t){let r=e;for(let i of t)r=r.split(i).join("<redacted>");return r=r.replace(/\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>]+/gi,"<url>"),r=r.replace(/\s+/g," ").trim(),r.length>vt?`${r.slice(0,vt)}\u2026`:r}a(Et,"sanitize");function Er(e){return e instanceof H?e.code===-32602||e.code===-32e3||/unknown block|header not found|block not found/i.test(e.message):false}a(Er,"blockRefused");function Sr(e,t,r){if(e==="code")return t.toLowerCase()===r.toLowerCase();try{return BigInt(t)===BigInt(r)}catch{return false}}a(Sr,"sameValue");function Ir(e){return e instanceof C&&/veriq_getRoot/.test(e.message)}a(Ir,"rootMoved");function Ar(e,t){vr(t),t.chainId!==void 0&&It(t.chainId,t.network);let r=t.timeoutMs??3e4,i=t.providers.map(p=>({...p})),s=xr(i),l=t.alignTimeoutMs??3e4;async function u(p){let f;try{f=await p.finalized();}catch{return null}return !f||!Number.isSafeInteger(f.number)||!xt.test(f.hash)||!xt.test(f.stateRoot)?null:{number:f.number,hash:f.hash,stateRoot:f.stateRoot}}a(u,"browserFinalized");async function h(){let p=await e.getRoot(),f=p.chainId??11155111;if(t.chainId!==void 0&&f!==t.chainId)throw new ne(L.CHAIN_MISMATCH,`the engine serves chain ${f}, this reader reads chain ${t.chainId}; nothing was read`);return p}a(h,"engineRoot");let g=null;function a$1(){let p=t.verifier;return p?(g??(g=(async()=>{try{return {verifier:typeof p=="function"?await p():p}}catch(f){return {unavailable:f instanceof Error?f.message:String(f)}}})()),g):Promise.resolve(null)}a(a$1,"browserVerifier");async function c(p){let f=t.lightClient;if(!f)return {root:await h()};let y=Date.now()+l;for(;;){let[b,w]=await Promise.all([h().then(x=>({root:x}),x=>({error:x})),u(f)]);if("error"in b){if(b.error instanceof D&&w&&p)return {root:{...w,rootSource:"local-light-client",verified:true},browser:w,engineDown:true};throw b.error}let v=b.root;if(!w)return {root:v};if(w.number===v.number){let x=a((P,I)=>P.toLowerCase()===I.toLowerCase(),"same");if(!x(w.hash,v.hash)||!x(w.stateRoot,v.stateRoot))throw new te(R.ROOT_MISMATCH,`finalized block #${v.number}: the browser light client has ${w.hash} (state root ${w.stateRoot}), the engine has ${v.hash} (state root ${v.stateRoot}); nothing was read`);return {root:v,browser:w}}if(Date.now()>=y)throw new J(R.ROOT_UNAVAILABLE,`the browser light client is at finalized block #${w.number} and the engine at #${v.number}; they did not agree within ${Math.round(l/1e3)} s`,{hint:"One light client is not following finality. Check the engine /health and the browser light client status."});await new Promise(x=>setTimeout(x,yr));}}a(c,"pinRoot");let d=new Set,m=1;async function E(p,f,y){let b=m++,w=new AbortController,v,x=new Promise((I,A)=>{v=setTimeout(()=>{w.abort(),A(new H(`no answer within ${r} ms`,void 0));},r);}),P=(async()=>{let I,A;try{I=await t.fetch(p.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:b,method:f,params:y}),signal:w.signal}),A=await I.json();}catch(k){let F=k instanceof Error?k.message:String(k);throw new H(Et(F||"request failed",s),void 0)}if(A&&typeof A=="object"&&A.error){let k=typeof A.error.message=="string"?A.error.message:"provider error",F=typeof A.error.code=="number"?A.error.code:void 0;throw new H(Et(k,s),F)}if(!A||typeof A!="object"||!("result"in A))throw new H(`HTTP ${I.status} without a JSON-RPC result`,void 0);if(A.id!==b)throw new H("JSON-RPC answer has the wrong id",void 0);return A.result})();try{return await Promise.race([P,x])}finally{clearTimeout(v);}}a(E,"upstream");async function T(p,f,y,b){if(!d.has(p.label))try{return await E(p,f,[...y,{blockHash:b.hash}])}catch(w){if(!Er(w))throw w;w.code===-32602&&d.add(p.label);}return E(p,f,[...y,`0x${b.number.toString(16)}`])}a(T,"atBlock");async function $(p,f,y,b){if(M(f),p==="storage"){if(y===void 0)throw j("readStorage needs a slot");ce(y);}let w=await a$1(),v=w&&"verifier"in w?w.verifier:null,x=[],P=a(k=>`${k.label}@anon-rpc:${t.network}`,"attemptLabel"),I;for(let k of i)for(let F=0;;F++){let{root:Y,browser:he,engineDown:Ot}=await c(v!==null),Re=Date.now(),be,ye;try{be=await T(k,"eth_getProof",[f,y===void 0?[]:[y]],Y),p==="code"&&(ye=await T(k,"eth_getCode",[f],Y));}catch(O){I=O,x.push({provider:P(k),outcome:"transport-failure",elapsedMs:Date.now()-Re,failureReason:"provider request failed"});break}let Q=null;if(v){let O=v.verifyRead({stateRoot:Y.stateRoot,address:f,kind:p,...y===void 0?{}:{slot:y},proof:be,...p==="code"?{code:ye}:{}});if(!O.ok){if(O.code==="INVALID_PROOF"){I=new B(R.INVALID_PROOF,`${k.label}: rejected in the browser, the engine was not asked: ${O.error}`),x.push({provider:P(k),outcome:"invalid-proof",elapsedMs:Date.now()-Re,failureReason:"INVALID_PROOF: provider attempt failed"});break}throw new C(R.INVALID_REQUEST,`the browser verifier refused the read: ${O.error}`)}Q=O.value;}let we=Date.now()-Re,tt={kind:p,address:f,...y===void 0?{}:{slot:y},blockHash:Y.hash,proof:be,...p==="code"?{code:ye}:{},provider:k.label,network:t.network,elapsedMs:we,...he?{browserRoot:he}:{},...v?{verifier:"browser"}:t.verifier?{verifier:"unavailable"}:{}},rt=a(()=>(x.push({provider:P(k),outcome:"success",elapsedMs:we}),z(v,tt,Q,Y,x,b)),"localOnly");if(Ot)return rt();try{let O=await e.verifyProof(tt,b);if(Q!==null&&!Sr(p,Q,O.value))throw new re(R.INTERNAL_ERROR,"the browser verifier and the engine proved different values from the same proof; nothing was returned");return O}catch(O){if(O instanceof D&&Q!==null&&he)return rt();if(I=O,O instanceof B&&x.push({provider:P(k),outcome:"invalid-proof",elapsedMs:we,failureReason:"INVALID_PROOF: provider attempt failed"}),Ir(O)){if(F<Rr)continue;throw new C(R.INVALID_REQUEST,`the finalized block moved again while fetching through ${t.network}; nothing was verified`,{cause:O,hint:"Retry the read. The provider or network is slower than the finalized block moves."})}if(O instanceof B)break;throw O}}if(I instanceof S)throw I;let A=I instanceof Error?I.message:"no answer";throw new ee(R.ALL_PROVIDERS_FAILED,`no provider answered through ${t.network} (${i.length} tried): ${A}`,{hint:"The anonymizing network may still be connecting, or the providers refuse browser requests (CORS)."})}a($,"read");function z(p,f,y,b,w,v){let x="veriq_verifyProof",P=v?[f,v]:[f],I=[{code:"LOCAL_ONLY",message:`the engine could not be reached: this value was verified in the browser against its own light client (synced over ${t.network}); the engine did not see or store this receipt`},{code:"BROWSER_LIGHT_CLIENT",message:`a light client in the browser, synced over ${t.network}, produced this finalized block and state root`}];v?.consistency==="compare"&&I.push({code:"COMPARE_UNAVAILABLE",message:"a client-fetched proof comes from one provider; nothing was compared"});let A=Math.floor(Date.now()/1e3),k=q.parse({identity:{requestId:`local-${Date.now().toString(16)}-${Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}`,method:x,requestBinding:p.binding(x,P),resultBinding:p.binding(x,y)},block:{number:b.number,hash:b.hash,stateRoot:b.stateRoot,finalized:true,...t.chainId!==void 0?{chainId:t.chainId}:{}},verification:{status:"verified",rootSource:"local-light-client",verifierLocation:"browser",mechanisms:wr[f.kind],bootstrap:{source:"browser-light-client",checkpoint:null,checkpointSource:null}},privacy:{transport:"anon-rpc",mechanism:t.network},routing:{comparison:"not-run",providersTried:w.length,providerLabel:`${f.provider}@anon-rpc:${t.network}`,attempts:w},freshness:{observedAt:A,ageSeconds:0,pinned:true},warnings:I});return {value:y,receipt:k,verified:true,attempts:ae(k)}}a(z,"localResult");let et=a(p=>({...p,value:BigInt(p.value)}),"word");return {readBalance:a(async({address:p,policy:f})=>et(await $("balance",p,void 0,f)),"readBalance"),readNonce:a(async({address:p,policy:f})=>et(await $("nonce",p,void 0,f)),"readNonce"),readStorage:a(async({address:p,slot:f,policy:y})=>{let b=await $("storage",p,f,y);return {...b,value:`0x${BigInt(b.value).toString(16).padStart(64,"0")}`}},"readStorage"),readCode:a(({address:p,policy:f})=>$("code",p,void 0,f),"readCode"),getDelegation:a(async({address:p,policy:f})=>{M(p);let y=await $("code",p,void 0,f),b=yt(y.value),w=b.isDelegated,v=b.delegateAddress,x={...y.receipt,warnings:[...y.receipt.warnings]},P;b.status.status==="normal-eoa"?P="normal-eoa":b.status.status==="delegated"?(P="delegation-detected",v&&x.warnings.push({code:"EIP7702_DELEGATION_DETECTED",message:`EIP-7702 delegation active: calls execute code from ${v}`})):b.status.status==="revoked"?(P="delegation-revoked",x.warnings.push({code:"EIP7702_DELEGATION_REVOKED",message:"EIP-7702 delegation cleared: account was previously delegated but is now empty"})):b.status.status==="contract"?P="smart-contract":(P="potential-risk",x.warnings.push({code:"EIP7702_INVALID_DESIGNATOR",message:"Account code begins with 0xef0100 but has invalid length or malformed encoding"}));let I=y.receipt.identity.resultBinding||`0x${"0".repeat(64)}`;return {address:p,status:b.status,isDelegated:w,delegateAddress:v,codeHash:I,securityClassification:P,blockNumber:y.receipt.block.number,verified:y.verified,receipt:x}},"getDelegation")}}a(Ar,"createPrivateReader");var Ge=2,Ke=class Ke extends S{constructor(t,r){super(R.INTERNAL_ERROR,t,{cause:r,hint:"The browser verifier did not load; the engine still verifies every proof."});}};a(Ke,"VerifierUnavailableError");var K=Ke;async function kr(e){if(typeof e=="string"||e instanceof URL){let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.arrayBuffer()}return typeof Response<"u"&&e instanceof Response?e.arrayBuffer():e}a(kr,"bytesOf");async function Tr(e){let t;try{let u=await kr(e);t=(u instanceof WebAssembly.Module?await WebAssembly.instantiate(u,{}):(await WebAssembly.instantiate(u,{})).instance).exports;}catch(u){let h=u instanceof Error?u.message:String(u);throw new K(`the browser verifier could not be loaded: ${h}`,u)}let r=typeof t.veriq_abi_version=="function"?t.veriq_abi_version():1;if(r!==Ge||typeof t.veriq_verify_read!="function")throw new K(`the browser verifier speaks ABI ${r}, this SDK needs ${Ge}`);let i=new TextEncoder,s=new TextDecoder;function l(u,h){let g=i.encode(JSON.stringify(h)),a=t.veriq_alloc(g.length);new Uint8Array(t.memory.buffer,a,g.length).set(g);let c;try{c=u(a,g.length);}finally{t.veriq_free(a,g.length);}let d=Number(c>>32n),m=Number(c&0xffffffffn),E=s.decode(new Uint8Array(t.memory.buffer,d,m).slice());return t.veriq_free(d,m),JSON.parse(E)}return a(l,"call"),{abiVersion:r,verifyRead(u){let{stateRoot:h,address:g,kind:a,slot:c,proof:d,code:m}=u,E=l(t.veriq_verify_read,{stateRoot:h,address:g,kind:a,slot:c,proof:d,code:m});return E.ok===true&&typeof E.value=="string"?{ok:true,value:E.value}:{ok:false,code:String(E.code??"INTERNAL_ERROR"),error:String(E.error??"verification failed")}},binding(u,h){let g=l(t.veriq_binding,{method:u,value:h});if(g.ok!==true||typeof g.binding!="string")throw new K(`binding failed: ${String(g.error)}`);return g.binding}}}a(Tr,"loadVerifier");var At=10n**18n;function kt(e,t={}){let r=t.decimals??4,i=t.symbol===false?"":" ETH",s=typeof e=="bigint"?e:BigInt(e),l=s<0n,u=l?-s:s,h=u/At,g=(u%At).toString().padStart(18,"0").slice(0,r).replace(/0+$/,"");if(h===0n&&g===""&&u>0n)return `${l?">-":"<"}0.${"0".repeat(Math.max(0,r-1))}1${i}`;let a=h.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");return `${l?"-":""}${a}${g?`.${g}`:""}${i}`}a(kt,"formatEth");function pe(e,t=4,r=4){let i=e.startsWith("0x")?t+2:t;return e.length<=i+r+1?e:`${e.slice(0,i)}\u2026${e.slice(-r)}`}a(pe,"shortHash");function Ye(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}a(Ye,"formatNumber");function Qe(e){switch(e){case "local-light-client":return "local light client (Helios)";case "fixture":return "fixture (tests only)";case "untrusted-rpc":return "untrusted RPC (DEV MODE)"}}a(Qe,"rootSourceLabel");function Or(e){return "identity"in e?{receipt:e,attempts:[]}:{receipt:e.receipt,...e.value!==void 0?{value:e.value}:{},attempts:e.attempts??[]}}a(Or,"split");function Pr(e){return e==="verified"?"ok":e==="unverified"?"warn":"lav"}a(Pr,"statusTone");function Nr(e,t){if(t===void 0)return "";if(/storage/i.test(e.identity.method)){let r=typeof t=="bigint"?t:BigInt(t);return r<10n**15n?r.toString():pe(`0x${r.toString(16)}`)}return kt(t)}a(Nr,"formatValue");function fe(e){let{receipt:t,value:r,attempts:i}=Or(e),s=[{label:"block",value:`#${Ye(t.block.number)} ${pe(t.block.hash)}${t.block.finalized?"":" (not finalized)"}`},{label:"stateRoot",value:pe(t.block.stateRoot)},{label:"root",value:Qe(t.verification.rootSource),tone:t.verification.rootSource==="untrusted-rpc"?"warn":"ink"}],l=i.reduce((g,a)=>g+a.elapsedMs,0),u=i.length||t.routing.providersTried,h=[t.routing.providerLabel??"\u2014",`${u} attempt${u===1?"":"s"}`,...i.length?[`${Math.round(l)} ms`]:[]].join(" \xB7 ");s.push({label:"provider",value:h});for(let g of i)g.outcome!=="ok"&&s.push({label:"rejected",value:`${g.provider} ${g.outcome}`,tone:"err"});t.routing.comparison!=="not-run"&&s.push({label:"compare",value:t.routing.comparison,tone:t.routing.comparison==="agree"?"ok":"warn"});for(let g of t.warnings)s.push({label:"warning",value:g.code,tone:"warn"});return {status:t.verification.status,value:Nr(t,r),rows:s}}a(fe,"receiptRows");function _r(e){let{status:t,value:r,rows:i}=fe(e);return [`${t.toUpperCase()}${r?` ${r}`:""}`,...i.map(s=>`${s.label.padEnd(10)} ${s.value}`)].join(`
2
+ `)}a(_r,"formatReceipt");function Je(e){let t=e.lightClient,r=t.finalizedNumber!=null&&t.headNumber!=null?`${t.headNumber-t.finalizedNumber} blocks behind head`:"",i=[{label:"engine",value:`${e.ok?"online":`degraded${e.error?` \xB7 ${e.error.code}`:""}`}${e.bind?` \xB7 ${e.bind}`:""}`,tone:e.ok?"ok":"warn"},{label:"root",value:e.rootSource?Qe(e.rootSource):"none yet (light client not synced)",tone:!e.rootSource||e.devMode||e.rootSource==="untrusted-rpc"?"warn":"ink"},{label:"light",value:t.synced?"synced":"not synced",tone:t.synced?"ok":"warn"},{label:"finalized",value:t.finalizedNumber!=null?`#${Ye(t.finalizedNumber)}${r?` \xB7 ${r}`:""}`:"\u2014"}],s=e.providers.map(l=>[l.name,l.chainOk?"yes":"no",l.proofSupport?"yes":"no",l.eip1898?"yes":"no",l.breaker.state,l.transport]);return e.providers.length===0&&i.push({label:"providers",value:`${e.providerCount} configured`,tone:"ink"}),{engine:i,providers:s}}a(Je,"healthRows");var $r={ink:null,muted:[91,91,102],lav:[156,149,214],border:[156,149,214],title:[107,98,181],ok:[47,158,110],warn:[183,121,31],err:[194,65,91]};function Tt(e){return globalThis.process?.env?.[e]}a(Tt,"env");function me(){return Tt("NO_COLOR")!==void 0?false:Tt("FORCE_COLOR")!==void 0?true:globalThis.process?.stdout?.isTTY===true}a(me,"supportsColor");function Ze(e){return (t,r,i=false)=>{let s=$r[t];return !e||!s&&!i?r:`${i?"\x1B[1m":""}${s?`\x1B[38;2;${s[0]};${s[1]};${s[2]}m`:""}${r}\x1B[0m`}}a(Ze,"painter");function Xe(e,t,r){let i=Math.max(e.length+6,...t.map(h=>h.plain.length))+4,s=`${r("border","\u256D\u2500 ")}${r("title",e,true)}${r("border",` ${"\u2500".repeat(i-e.length-3)}\u256E`)}`,l=t.map(h=>`${r("border","\u2502")} ${h.painted}${" ".repeat(i-h.plain.length-1)}${r("border","\u2502")}`),u=r("border",`\u2570${"\u2500".repeat(i)}\u256F`);return [s,...l,u].join(`
3
+ `)}a(Xe,"box");var ge=11;function Cr(e,t={}){let r=Ze(t.color??me()),{status:i,value:s,rows:l}=fe(e),u=i==="verified"?"ok":i==="unverified"?"warn":"lav",h=`\u25CF ${i.toUpperCase()}`,g=" ".repeat(Math.max(2,22-h.length)),a=[{plain:`${h}${g}${s}`,painted:`${r(u,h,true)}${g}${r("ink",s,true)}`},...l.map(c=>({plain:`${c.label.padEnd(ge)}${c.value}`,painted:`${r("muted",c.label.padEnd(ge))}${r(c.tone??"ink",c.value)}`}))];return Xe("Veriq \xB7 Trust Receipt",a,r)}a(Cr,"prettyReceipt");function Vr(e,t={}){let r=Ze(t.color??me()),{engine:i,providers:s}=Je(e),l=i.map(a=>({plain:`${a.label.padEnd(ge)}${a.value}`,painted:`${r("muted",a.label.padEnd(ge))}${r(a.tone??"ink",a.value)}`})),u=["provider","chain","proof","1898","breaker","transport"],h=u.map((a,c)=>Math.max(a.length,...s.map(d=>(d[c]??"").length))+2),g=a(a=>a.map((c,d)=>c.padEnd(h[d]??0)).join("").trimEnd(),"fmt");if(s.length===0)return Xe("Veriq \xB7 Engine health",l,r);l.push({plain:"",painted:""}),l.push({plain:g(u),painted:r("muted",g(u))});for(let a of s){let c=g(a),d=a[1]==="no"||a[2]==="no"||a[4]!=="closed";l.push({plain:c,painted:r(d?"err":"ink",c)});}return Xe("Veriq \xB7 Engine health",l,r)}a(Vr,"prettyHealth");function Lr(e,t={}){let r=Ze(t.color??me());return `${r("err",`\u2715 ${e.name} [${e.code} ${e.codeName}]`,true)}
4
4
  ${e.message}
5
- ${n("muted",`\u2192 ${e.hint}`)}`}a(At,"prettyError");export{M as AllProvidersFailedError,tt as AttemptOutcomeSchema,Te as AttemptSchema,ve as BlockPolicySchema,Je as BlockSchema,Ze as BootstrapSchema,pt as BreakerStateSchema,A as CLIENT_CODES,Ne as CapabilitiesSchema,Ke as ComparisonSchema,$e as DEFAULT_ENGINE_URL,Me as ERROR_CLASSES,g as ERROR_CODES,je as ERROR_HINTS,he as ERROR_MEANINGS,Ae as EngineHealthSchema,O as EngineUnreachableError,ot as FreshnessSchema,re as Hex32Schema,Qe as IdentitySchema,D as InternalError,q as InvalidProofError,I as InvalidRequestError,lt as LightClientStatusSchema,Ye as MechanismSchema,ne as OUTCOME_LABEL,Se as PolicySchema,j as PolicyUnsatisfiableError,et as PrivacySchema,U as PrivacyUnavailableError,ie as ProviderHealthSchema,T as ProviderTimeoutError,Ie as ReadResultSchema,Oe as ReceiptListSchema,oe as ReceiptRecordSchema,xe as RootSourceSchema,_ as RootUnavailableError,rt as RoutingAttemptSchema,nt as RoutingSchema,ct as RpcErrorSchema,Ee as TransportKindSchema,k as TrustReceiptSchema,S as UnsupportedVerificationError,st as VerificationPolicySchema,Xe as VerificationSchema,Ge as VerificationStatusSchema,We as VerifierLocationSchema,h as VeriqError,x as VeriqSchemaError,it as WarningSchema,ce as assertAddress,pe as assertPolicy,Ce as assertSlot,Pe as attemptsFromReceipt,ae as createTransport,Ve as createVeriq,Be as devUnverified,Re as errorFromRpc,Nt as errorNameForCode,qe as formatEth,w as formatIssues,ue as formatNumber,St as formatReceipt,fe as healthRows,kt as isVeriqError,Pt as presets,At as prettyError,Ot as prettyHealth,It as prettyReceipt,Fe as privateVerified,C as receiptRows,de as rootSourceLabel,P as shortHash,Et as statusTone,L as supportsColor,ze as verifiedCompare,N as verifiedFinalized};//# sourceMappingURL=index.js.map
5
+ ${r("muted",`\u2192 ${e.hint}`)}`}a(Lr,"prettyError");export{ee as AllProvidersFailedError,Gt as AttemptOutcomeSchema,ut as AttemptSchema,ct as BlockPolicySchema,jt as BlockSchema,zt as BootstrapSchema,tr as BreakerStateSchema,L as CLIENT_CODES,gt as CapabilitiesSchema,ne as ChainMismatchError,Bt as ComparisonSchema,Rt as DEFAULT_ENGINE_URL,cn as DESIGNATOR_BYTE_LENGTH,ln as DESIGNATOR_HEX_LENGTH,mt as DelegationResultSchema,sr as DelegationSecurityClassificationSchema,ir as DelegationStatusSchema,gr as EIP7702_PREFIX,_t as ERROR_CLASSES,R as ERROR_CODES,Nt as ERROR_HINTS,nt as ERROR_MEANINGS,ft as EngineHealthSchema,D as EngineUnreachableError,Qt as FreshnessSchema,U as Hex32Schema,Ut as IdentitySchema,re as InternalError,B as InvalidProofError,C as InvalidRequestError,rr as LightClientStatusSchema,Ht as MechanismSchema,qe as OUTCOME_LABEL,St as PRIVATE_NETWORKS,lt as PolicySchema,ve as PolicyUnsatisfiableError,Wt as PrivacySchema,W as PrivacyUnavailableError,Be as ProviderHealthSchema,Z as ProviderTimeoutError,Me as ReadResultSchema,pt as ReceiptListSchema,He as ReceiptRecordSchema,dt as RootInfoSchema,te as RootMismatchError,st as RootSourceSchema,J as RootUnavailableError,Kt as RoutingAttemptSchema,Yt as RoutingSchema,er as RpcErrorSchema,at as TransportKindSchema,q as TrustReceiptSchema,X as UnsupportedVerificationError,Ge as VERIFIER_ABI_VERSION,Xt as VerificationPolicySchema,Ft as VerificationSchema,qt as VerificationStatusSchema,Mt as VerifierLocationSchema,K as VerifierUnavailableError,S as VeriqError,G as VeriqSchemaError,Jt as WarningSchema,mr as ZERO_ADDRESS,M as assertAddress,It as assertNetworkForChain,se as assertPolicy,ce as assertSlot,ae as attemptsFromReceipt,yt as classifyAccountCode,Ar as createPrivateReader,Fe as createTransport,bt as createVeriq,Dt as devUnverified,it as errorFromRpc,Dr as errorNameForCode,kt as formatEth,le as formatIssues,Ye as formatNumber,_r as formatReceipt,Je as healthRows,qr as isVeriqError,Tr as loadVerifier,hr as parseDelegationDesignator,Br as presets,Lr as prettyError,Vr as prettyHealth,Cr as prettyReceipt,Lt as privateVerified,fe as receiptRows,Qe as rootSourceLabel,pe as shortHash,Pr as statusTone,me as supportsColor,Vt as verifiedCompare,oe as verifiedFinalized};//# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map