@origintrail-official/dkg-node-ui 10.0.13 → 10.0.15

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.
Files changed (46) hide show
  1. package/dist/chat-memory.d.ts +43 -2
  2. package/dist/chat-memory.d.ts.map +1 -1
  3. package/dist/chat-memory.js +31 -7
  4. package/dist/chat-memory.js.map +1 -1
  5. package/dist/db.d.ts +23 -16
  6. package/dist/db.d.ts.map +1 -1
  7. package/dist/db.js +217 -108
  8. package/dist/db.js.map +1 -1
  9. package/dist/gelf-push-worker.d.ts +1 -1
  10. package/dist/gelf-push-worker.d.ts.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/otlp-log-worker.d.ts +3 -5
  16. package/dist/otlp-log-worker.d.ts.map +1 -1
  17. package/dist/otlp-log-worker.js +7 -5
  18. package/dist/otlp-log-worker.js.map +1 -1
  19. package/dist/routine-log-retention.d.ts +40 -0
  20. package/dist/routine-log-retention.d.ts.map +1 -0
  21. package/dist/routine-log-retention.js +262 -0
  22. package/dist/routine-log-retention.js.map +1 -0
  23. package/dist/structured-logger.d.ts.map +1 -1
  24. package/dist/structured-logger.js.map +1 -1
  25. package/dist-ui/assets/{3d-force-graph-C9KowW4u.js → 3d-force-graph-CnBoK4hA.js} +1 -1
  26. package/dist-ui/assets/{AgentHub-BVrcom9_.js → AgentHub-BOUZTvCO.js} +1 -1
  27. package/dist-ui/assets/{AgentProfilePage-C9XaTt7j.js → AgentProfilePage-DpF722ai.js} +1 -1
  28. package/dist-ui/assets/{ApproveWalletsModal-BdR2mshx.js → ApproveWalletsModal-CYQqAWZs.js} +3 -3
  29. package/dist-ui/assets/{ConvictionDetailView-cao48GL1.js → ConvictionDetailView-DYsWNc9M.js} +1 -1
  30. package/dist-ui/assets/{Network-B3jCYzr5.js → Network-JVFsFYhR.js} +1 -1
  31. package/dist-ui/assets/{OnChainProvenanceCard-DboMX4Aq.js → OnChainProvenanceCard-DISbYKx1.js} +1 -1
  32. package/dist-ui/assets/{Operations-Dg1gfLXv.js → Operations-Cmt3YpaX.js} +1 -1
  33. package/dist-ui/assets/{PublishingConviction-Byp6t69e.js → PublishingConviction-L-wHlnRP.js} +1 -1
  34. package/dist-ui/assets/{Settings-CxI0SKeV.js → Settings-CvBKeoTW.js} +1 -1
  35. package/dist-ui/assets/{ccip-wJ3OMRuz.js → ccip-m-rmKwvf.js} +1 -1
  36. package/dist-ui/assets/index-BfrYentv.js +1645 -0
  37. package/dist-ui/assets/{index-5DS6xjw0.js → index-UAg6wmCv.js} +3 -3
  38. package/dist-ui/assets/index-VYV5TH6q.css +1 -0
  39. package/dist-ui/assets/{jsonld-32FQRO67-CDirPi8u.js → jsonld-32FQRO67-iGNyLix6.js} +2 -2
  40. package/dist-ui/assets/{jsonld-CwHW9UDN.js → jsonld-CDhTpz6H.js} +1 -1
  41. package/dist-ui/assets/{renderer-3d-2EVDZII7-BNXV6iSu.js → renderer-3d-2EVDZII7-BdEgi2VZ.js} +2 -2
  42. package/dist-ui/assets/{shikiHighlighter-C-LWPPSu.js → shikiHighlighter-Dhz3-Gg5.js} +1 -1
  43. package/dist-ui/index.html +2 -2
  44. package/package.json +5 -4
  45. package/dist-ui/assets/index-DOjsv0r7.css +0 -1
  46. package/dist-ui/assets/index-KoAnx9JE.js +0 -1661
@@ -1 +1 @@
1
- import{aI as E,aN as $,aH as B,ad as e,aE as j,aq as i,as as P,X as W,Y as I,M as L,Q as M,O as D,R as N,az as C,t as O,K as U,ay as w,U as H}from"./index-KoAnx9JE.js";function F(s,r){const t=(s??"").trim();if(!t)return"TRAC";const n=(r??"").includes(":")?(r??"").split(":")[1]:r??"";return n==="84532"||n==="11155111"||n==="31337"||n==="10200"||n==="20430"?/test/i.test(t)?t:`${t} (testnet)`:t}function T(s,r=2){if(s==null)return"—";let t;if(typeof s=="number")t=s;else{const n=String(s).trim();if(!/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(n))return"—";t=Number(n)}return Number.isFinite(t)?t.toFixed(r):"—"}function A(s){if(T(s)!=="—")return`Exact: ${s}`}const k="************",q=/[A-Za-z0-9_-]{16,}/g;function _(s){if(!s)return"";let r;try{r=new URL(s)}catch{return s.replace(q,k)}(r.username||r.password)&&(r.username="",r.password="");const t=r.pathname.split("/").map(n=>n.length<16?n:/^[A-Za-z0-9_-]+$/.test(n)?k:n);if(r.pathname=t.join("/"),r.search){const n=new URLSearchParams(r.search);for(const a of Array.from(n.keys()))/key|token|secret|auth/i.test(a)&&n.set(a,k);r.search=n.toString()}return r.toString()}function K(s){if(s==null)return"—";const r=s/100;return`${r%1===0?r.toFixed(0):r.toFixed(1)}%`}function Z(){E();const s=$(u=>u.openTab),{accounts:r,covered:t,bestCoveringDiscountBps:n,walletsInconclusive:a}=B(),l=r.length;return e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Publisher Conviction"})}),e.jsxs("div",{className:"card-body",children:[l===0?e.jsx("p",{className:"v10-pca-settings-line",children:"No tracked Publisher Conviction Account on this node."}):t?e.jsxs("p",{className:"v10-pca-settings-line",children:["This node’s approved publishing wallets use a ",e.jsx("strong",{children:K(n)})," discount."]}):a?e.jsx("p",{className:"v10-pca-settings-line",role:"status",children:"Couldn’t verify this node’s wallets — retry."}):e.jsxs("p",{className:"v10-pca-settings-line",children:["Tracking ",l," account",l===1?"":"s",", but none currently covers this node’s publishes."]}),e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>s({id:"conviction",label:"Publisher Conviction",closable:!0}),children:"Manage publisher conviction ->"})]})]})}function p({label:s,value:r,mono:t=!1}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{className:"settings-field-label",children:s}),e.jsx("div",{className:`settings-field-value${t?" mono":""}`,children:r})]})}function Q({rpcUrl:s}){const[r,t]=i.useState(!1),n=r?s:_(s);return e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("div",{className:"settings-field-label",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{children:"RPC"}),e.jsx("button",{type:"button",onClick:()=>t(a=>!a),style:{background:"none",border:"1px solid var(--border)",color:"var(--text-dim)",cursor:"pointer",fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:4},"aria-label":r?"Redact RPC URL":"Reveal RPC URL",title:r?"Hide the path-token (recommended for screen-shares)":"Show full URL — careful, may contain a tenant secret",children:r?"Redact":"Reveal"})]}),e.jsx("div",{className:"settings-field-value mono",style:{wordBreak:"break-all"},children:n})]})}function Y(){const{data:s}=j(D,[],6e4),[r,t]=i.useState(!1),[n,a]=i.useState(!1),[l,u]=i.useState(null),[m,o]=i.useState(!1),h=N.useRef(null),f=N.useRef(null);i.useEffect(()=>{s!=null&&t(s.enabled)},[s]);const g=i.useCallback(()=>{n||(u(null),r?(t(!1),a(!0),C(!1).catch(()=>{t(!0),u("Couldn’t update telemetry — try again.")}).finally(()=>a(!1))):o(!0))},[r,n]),y=i.useCallback(async()=>{var c;o(!1),u(null),t(!0),a(!0);try{await C(!0)}catch{t(!1),u("Couldn’t update telemetry — try again.")}finally{a(!1),(c=f.current)==null||c.focus()}},[]);return i.useEffect(()=>{var v;if(!m)return;const c=(v=h.current)==null?void 0:v.querySelector("button");c==null||c.focus();const d=S=>{var b;S.key==="Escape"&&(o(!1),(b=f.current)==null||b.focus())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[m]),e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Network Telemetry"})}),e.jsxs("div",{className:"card-body",children:[e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:16,lineHeight:1.6},children:"Local metrics are stored in SQLite and displayed in the Observability page."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"10px 0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:"Share telemetry with the network"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.5},children:"When enabled, metrics and logs are streamed to the OriginTrail network dashboard for network-wide diagnostics."})]}),e.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":r,"aria-busy":n,"aria-disabled":n,"aria-label":"Share telemetry with the network",onClick:g,style:{width:38,height:22,borderRadius:11,border:"none",flexShrink:0,background:r?"var(--green)":"var(--border)",transition:"background .2s",position:"relative",marginLeft:16,cursor:n?"wait":"pointer",opacity:n?.6:1},children:e.jsx("span",{style:{position:"absolute",top:3,left:r?19:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left .2s",display:"block"}})})]}),e.jsx("div",{"aria-live":"polite",children:l&&e.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:l})})]}),m&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,.55)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-label":"Enable Telemetry Streaming?",style:{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:12,padding:"24px 28px",maxWidth:440,width:"90%",boxShadow:"0 8px 32px rgba(0,0,0,.3)"},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16},children:"Enable Telemetry Streaming?"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:"When enabled, the following data is streamed to the OriginTrail team:"}),e.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 14px 18px",padding:0},children:[e.jsx("li",{children:"Operation logs (publish, query, sync, gossip events)"}),e.jsx("li",{children:"Performance metrics (durations, throughput, error rates)"}),e.jsx("li",{children:"Node identity (peer ID, node name, network)"})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:["The following data is ",e.jsx("strong",{style:{color:"var(--text)"},children:"NEVER"})," shared via telemetry:"]}),e.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 16px 18px",padding:0},children:[e.jsx("li",{children:"Private keys or wallet credentials"}),e.jsx("li",{children:"Authentication tokens or API keys"}),e.jsx("li",{children:"Private triple content or personal data"}),e.jsx("li",{children:"File system paths or environment variables"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:20,lineHeight:1.5},children:"You can disable streaming at any time from this page."}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:()=>{var c;o(!1),(c=f.current)==null||c.focus()},style:{padding:"7px 18px",borderRadius:7,fontSize:12,fontWeight:600,cursor:"pointer",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:y,style:{padding:"7px 18px",borderRadius:7,fontSize:12,fontWeight:700,cursor:"pointer",border:"1px solid rgba(74,222,128,.4)",background:"rgba(74,222,128,.1)",color:"var(--green)"},children:"Enable Streaming"})]})]})})]})}function G(){const{data:s}=j(O,[],3e4),{data:r}=j(U,[],6e4),[t,n]=i.useState(90),[a,l]=i.useState(!1),[u,m]=i.useState(null),[o,h]=i.useState(null),f=N.useRef(null);i.useEffect(()=>{r!=null&&r.retentionDays&&n(r.retentionDays)},[r]),i.useEffect(()=>{var d;o!=null&&((d=f.current)==null||d.focus())},[o]);const g=i.useCallback(async()=>{if(o==null)return;const d=o;l(!1),m(null),h(null);try{await w(d),n(d),l(!0),setTimeout(()=>l(!1),2e3)}catch{m("Couldn’t save retention — try again.")}},[o]),y=i.useCallback(d=>{m(null),d<t?(l(!1),h(d)):(l(!1),h(null),w(d).then(()=>{n(d),l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>m("Couldn’t save retention — try again.")))},[t]),c=(s==null?void 0:s.store_bytes)??null;return e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Local Data Retention"})}),e.jsxs("div",{className:"card-body",children:[e.jsx("label",{htmlFor:"retention-select",className:"settings-field-label",style:{display:"block",marginBottom:5},children:"Keep local data for"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("select",{id:"retention-select",className:"input",value:o??t,onChange:d=>y(Number(d.target.value)),style:{width:160},children:[e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:90,children:"90 days"}),e.jsx("option",{value:180,children:"180 days"}),e.jsx("option",{value:365,children:"365 days"})]}),e.jsx("span",{"aria-live":"polite",children:a&&e.jsx("span",{style:{fontSize:10,color:"var(--green)",fontWeight:600},children:"Saved"})}),c!=null&&e.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:["Store: ",H(c)]})]}),o!=null&&e.jsxs("div",{role:"group","aria-label":"Confirm retention reduction",style:{marginTop:8,padding:"10px 14px",borderRadius:8,background:"rgba(251,191,36,.06)",border:"1px solid rgba(251,191,36,.2)"},children:[e.jsxs("div",{style:{fontSize:11,color:"var(--amber)",fontWeight:600,marginBottom:4},children:["Reduce retention to ",o," days?"]}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["Operations, logs, and metrics older than ",o," days will be permanently deleted."]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{ref:f,type:"button",onClick:g,style:{padding:"5px 14px",borderRadius:6,fontSize:11,fontWeight:700,cursor:"pointer",border:"1px solid rgba(251,191,36,.4)",background:"rgba(251,191,36,.1)",color:"var(--amber)"},children:"Prune & Save"}),e.jsx("button",{type:"button",onClick:()=>h(null),style:{padding:"5px 14px",borderRadius:6,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)"},children:"Cancel"})]})]}),o==null&&e.jsx("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:4},children:"Operations and metric snapshots older than this are pruned automatically. Warning and error logs keep this window; high-volume routine logs also have a size safety cap."}),e.jsx("div",{"aria-live":"polite",children:u&&e.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:u})})]})]})}function V(s){const r=Math.floor(s/1e3);if(r<60)return`${r}s`;const t=Math.floor(r/60);if(t<60)return`${t}m ${r%60}s`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function X(s){return s.length<=12?s:`${s.slice(0,6)}…${s.slice(-4)}`}function J(s){if(!s)return"Unknown";const r=s.includes(":")?s.split(":")[1]:s;switch(r){case"84532":return"Base Sepolia (Testnet)";case"8453":return"Base (Mainnet)";case"1":return"Ethereum Mainnet";case"11155111":return"Sepolia (Testnet)";case"31337":return"Local (Hardhat)";default:return`Chain ${r}`}}function ne(){return e.jsxs("div",{className:"page-section",children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Settings"}),e.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:"Node configuration and preferences"})]}),e.jsx(ee,{})]})}function ee(){var g,y,c,d,v,S,b,R;const{data:s}=j(L,[],3e4),{data:r}=j(M,[],6e4),t=s,n=r,[a,l]=i.useState(!1),[u,m]=i.useState(!1),o=(t==null?void 0:t.connectedPeers)??0,h=(t==null?void 0:t.peerId)!=null,f=i.useCallback(async()=>{if(!a){l(!0),setTimeout(()=>l(!1),5e3);return}m(!0);try{await P()}catch{m(!1),l(!1)}},[a]);return e.jsxs("div",{className:"settings-stack",children:[e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Node Identity"})}),e.jsxs("div",{className:"card-body",children:[e.jsx(p,{label:"Name",value:(t==null?void 0:t.name)??"—"}),e.jsx(p,{label:"Peer ID",value:(t==null?void 0:t.peerId)??"—",mono:!0}),e.jsx(p,{label:"Role",value:(t==null?void 0:t.nodeRole)??"—"}),e.jsx(p,{label:"Network",value:(t==null?void 0:t.networkName)??(t!=null&&t.networkId?`Network ${t.networkId}`:"—")}),e.jsx(p,{label:"Store",value:(t==null?void 0:t.storeBackend)??"—",mono:!0}),e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:h?"var(--green-dim)":"rgba(248,113,113,.05)",border:`1px solid ${h?"rgba(74,222,128,.2)":"rgba(248,113,113,.2)"}`},children:[e.jsx("div",{className:"mono",style:{fontSize:10,color:h?"var(--green)":"var(--red)",fontWeight:700},children:h?"● ONLINE":"● OFFLINE"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:4},title:"Peers = unique remote nodes. Direct + Relayed counts are libp2p connections — a single peer can hold both a direct and a relayed link, so they sum to ≥ Peers, not exactly equal to it.",children:h?`${o} peer${o!==1?"s":""} · ${((g=t==null?void 0:t.connections)==null?void 0:g.direct)??0} direct, ${((y=t==null?void 0:t.connections)==null?void 0:y.relayed)??0} relayed link${(((c=t==null?void 0:t.connections)==null?void 0:c.relayed)??0)===1?"":"s"} · up ${V((t==null?void 0:t.uptimeMs)??0)}`:"Node is not responding"})]})]})]}),e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Blockchain Config"})}),e.jsxs("div",{className:"card-body",children:[e.jsx(p,{label:"Chain",value:J(n==null?void 0:n.chainId)}),((d=n==null?void 0:n.balances)==null?void 0:d.length)>0?n.balances.map((x,z)=>e.jsxs("div",{style:{marginBottom:10},children:[e.jsx(p,{label:n.balances.length>1?`Wallet ${z+1}`:"Operational Wallet",value:x.address,mono:!0}),e.jsxs("div",{style:{display:"flex",gap:16,marginTop:-6},children:[e.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:I(x.eth),children:[W(x.eth)," ETH"]}),e.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:A(x.trac),children:[T(x.trac)," ",F(x.symbol,n==null?void 0:n.chainId)]})]})]},x.address)):e.jsx(p,{label:"Operational Wallet",value:(v=n==null?void 0:n.wallets)!=null&&v[0]?X(n.wallets[0]):"—",mono:!0}),(n==null?void 0:n.rpcUrl)&&e.jsx(Q,{rpcUrl:n.rpcUrl}),n!=null&&n.error?e.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(248,113,113,.05)",border:"1px solid rgba(248,113,113,.2)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--red)",marginBottom:2},children:"⚠ Error"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:n.error})]}):(S=n==null?void 0:n.chainId)!=null&&S.includes("84532")||(b=n==null?void 0:n.chainId)!=null&&b.includes("31337")||(R=n==null?void 0:n.chainId)!=null&&R.includes("11155111")?e.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"var(--amber-dim)",border:"1px solid rgba(251,191,36,.2)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--amber)",marginBottom:2},children:"⚠ Testnet Mode"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"No real TRAC is spent. Perfect for development."})]}):null]})]}),e.jsx(Z,{}),e.jsx(Y,{}),e.jsx(G,{}),e.jsxs("section",{className:"card",style:{borderColor:"rgba(248,113,113,.2)",background:"rgba(248,113,113,.03)"},children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",style:{color:"var(--red)"},children:"Danger Zone"})}),e.jsx("div",{className:"card-body",children:e.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{onClick:f,disabled:u,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${a?"var(--red)":"rgba(251,191,36,.3)"}`,background:a?"rgba(248,113,113,.15)":"rgba(251,191,36,.07)",color:a?"var(--red)":"var(--amber)",fontSize:12,fontWeight:600,cursor:u?"not-allowed":"pointer",opacity:u?.5:1},children:u?"Shutting down…":a?"Confirm Shutdown":"Shutdown Node"}),e.jsx("span",{"aria-live":"polite",children:a&&e.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"Click again to confirm. The node process will terminate."})})]})})]})]})}export{ne as SettingsPage};
1
+ import{aI as E,aN as $,aH as B,ad as e,aE as j,aq as i,as as P,X as W,Y as I,M as L,Q as M,O as D,R as N,az as C,t as O,K as U,ay as w,U as H}from"./index-BfrYentv.js";function F(s,r){const t=(s??"").trim();if(!t)return"TRAC";const n=(r??"").includes(":")?(r??"").split(":")[1]:r??"";return n==="84532"||n==="11155111"||n==="31337"||n==="10200"||n==="20430"?/test/i.test(t)?t:`${t} (testnet)`:t}function T(s,r=2){if(s==null)return"—";let t;if(typeof s=="number")t=s;else{const n=String(s).trim();if(!/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(n))return"—";t=Number(n)}return Number.isFinite(t)?t.toFixed(r):"—"}function A(s){if(T(s)!=="—")return`Exact: ${s}`}const k="************",q=/[A-Za-z0-9_-]{16,}/g;function _(s){if(!s)return"";let r;try{r=new URL(s)}catch{return s.replace(q,k)}(r.username||r.password)&&(r.username="",r.password="");const t=r.pathname.split("/").map(n=>n.length<16?n:/^[A-Za-z0-9_-]+$/.test(n)?k:n);if(r.pathname=t.join("/"),r.search){const n=new URLSearchParams(r.search);for(const a of Array.from(n.keys()))/key|token|secret|auth/i.test(a)&&n.set(a,k);r.search=n.toString()}return r.toString()}function K(s){if(s==null)return"—";const r=s/100;return`${r%1===0?r.toFixed(0):r.toFixed(1)}%`}function Z(){E();const s=$(u=>u.openTab),{accounts:r,covered:t,bestCoveringDiscountBps:n,walletsInconclusive:a}=B(),l=r.length;return e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Publisher Conviction"})}),e.jsxs("div",{className:"card-body",children:[l===0?e.jsx("p",{className:"v10-pca-settings-line",children:"No tracked Publisher Conviction Account on this node."}):t?e.jsxs("p",{className:"v10-pca-settings-line",children:["This node’s approved publishing wallets use a ",e.jsx("strong",{children:K(n)})," discount."]}):a?e.jsx("p",{className:"v10-pca-settings-line",role:"status",children:"Couldn’t verify this node’s wallets — retry."}):e.jsxs("p",{className:"v10-pca-settings-line",children:["Tracking ",l," account",l===1?"":"s",", but none currently covers this node’s publishes."]}),e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>s({id:"conviction",label:"Publisher Conviction",closable:!0}),children:"Manage publisher conviction ->"})]})]})}function p({label:s,value:r,mono:t=!1}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{className:"settings-field-label",children:s}),e.jsx("div",{className:`settings-field-value${t?" mono":""}`,children:r})]})}function Q({rpcUrl:s}){const[r,t]=i.useState(!1),n=r?s:_(s);return e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("div",{className:"settings-field-label",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{children:"RPC"}),e.jsx("button",{type:"button",onClick:()=>t(a=>!a),style:{background:"none",border:"1px solid var(--border)",color:"var(--text-dim)",cursor:"pointer",fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:4},"aria-label":r?"Redact RPC URL":"Reveal RPC URL",title:r?"Hide the path-token (recommended for screen-shares)":"Show full URL — careful, may contain a tenant secret",children:r?"Redact":"Reveal"})]}),e.jsx("div",{className:"settings-field-value mono",style:{wordBreak:"break-all"},children:n})]})}function Y(){const{data:s}=j(D,[],6e4),[r,t]=i.useState(!1),[n,a]=i.useState(!1),[l,u]=i.useState(null),[m,o]=i.useState(!1),h=N.useRef(null),f=N.useRef(null);i.useEffect(()=>{s!=null&&t(s.enabled)},[s]);const g=i.useCallback(()=>{n||(u(null),r?(t(!1),a(!0),C(!1).catch(()=>{t(!0),u("Couldn’t update telemetry — try again.")}).finally(()=>a(!1))):o(!0))},[r,n]),y=i.useCallback(async()=>{var c;o(!1),u(null),t(!0),a(!0);try{await C(!0)}catch{t(!1),u("Couldn’t update telemetry — try again.")}finally{a(!1),(c=f.current)==null||c.focus()}},[]);return i.useEffect(()=>{var v;if(!m)return;const c=(v=h.current)==null?void 0:v.querySelector("button");c==null||c.focus();const d=S=>{var b;S.key==="Escape"&&(o(!1),(b=f.current)==null||b.focus())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[m]),e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Network Telemetry"})}),e.jsxs("div",{className:"card-body",children:[e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:16,lineHeight:1.6},children:"Local metrics are stored in SQLite and displayed in the Observability page."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"10px 0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:"Share telemetry with the network"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.5},children:"When enabled, metrics and logs are streamed to the OriginTrail network dashboard for network-wide diagnostics."})]}),e.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":r,"aria-busy":n,"aria-disabled":n,"aria-label":"Share telemetry with the network",onClick:g,style:{width:38,height:22,borderRadius:11,border:"none",flexShrink:0,background:r?"var(--green)":"var(--border)",transition:"background .2s",position:"relative",marginLeft:16,cursor:n?"wait":"pointer",opacity:n?.6:1},children:e.jsx("span",{style:{position:"absolute",top:3,left:r?19:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left .2s",display:"block"}})})]}),e.jsx("div",{"aria-live":"polite",children:l&&e.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:l})})]}),m&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,.55)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-label":"Enable Telemetry Streaming?",style:{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:12,padding:"24px 28px",maxWidth:440,width:"90%",boxShadow:"0 8px 32px rgba(0,0,0,.3)"},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16},children:"Enable Telemetry Streaming?"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:"When enabled, the following data is streamed to the OriginTrail team:"}),e.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 14px 18px",padding:0},children:[e.jsx("li",{children:"Operation logs (publish, query, sync, gossip events)"}),e.jsx("li",{children:"Performance metrics (durations, throughput, error rates)"}),e.jsx("li",{children:"Node identity (peer ID, node name, network)"})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:["The following data is ",e.jsx("strong",{style:{color:"var(--text)"},children:"NEVER"})," shared via telemetry:"]}),e.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 16px 18px",padding:0},children:[e.jsx("li",{children:"Private keys or wallet credentials"}),e.jsx("li",{children:"Authentication tokens or API keys"}),e.jsx("li",{children:"Private triple content or personal data"}),e.jsx("li",{children:"File system paths or environment variables"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:20,lineHeight:1.5},children:"You can disable streaming at any time from this page."}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:()=>{var c;o(!1),(c=f.current)==null||c.focus()},style:{padding:"7px 18px",borderRadius:7,fontSize:12,fontWeight:600,cursor:"pointer",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:y,style:{padding:"7px 18px",borderRadius:7,fontSize:12,fontWeight:700,cursor:"pointer",border:"1px solid rgba(74,222,128,.4)",background:"rgba(74,222,128,.1)",color:"var(--green)"},children:"Enable Streaming"})]})]})})]})}function G(){const{data:s}=j(O,[],3e4),{data:r}=j(U,[],6e4),[t,n]=i.useState(90),[a,l]=i.useState(!1),[u,m]=i.useState(null),[o,h]=i.useState(null),f=N.useRef(null);i.useEffect(()=>{r!=null&&r.retentionDays&&n(r.retentionDays)},[r]),i.useEffect(()=>{var d;o!=null&&((d=f.current)==null||d.focus())},[o]);const g=i.useCallback(async()=>{if(o==null)return;const d=o;l(!1),m(null),h(null);try{await w(d),n(d),l(!0),setTimeout(()=>l(!1),2e3)}catch{m("Couldn’t save retention — try again.")}},[o]),y=i.useCallback(d=>{m(null),d<t?(l(!1),h(d)):(l(!1),h(null),w(d).then(()=>{n(d),l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>m("Couldn’t save retention — try again.")))},[t]),c=(s==null?void 0:s.store_bytes)??null;return e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Local Data Retention"})}),e.jsxs("div",{className:"card-body",children:[e.jsx("label",{htmlFor:"retention-select",className:"settings-field-label",style:{display:"block",marginBottom:5},children:"Keep local data for"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("select",{id:"retention-select",className:"input",value:o??t,onChange:d=>y(Number(d.target.value)),style:{width:160},children:[e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:90,children:"90 days"}),e.jsx("option",{value:180,children:"180 days"}),e.jsx("option",{value:365,children:"365 days"})]}),e.jsx("span",{"aria-live":"polite",children:a&&e.jsx("span",{style:{fontSize:10,color:"var(--green)",fontWeight:600},children:"Saved"})}),c!=null&&e.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:["Store: ",H(c)]})]}),o!=null&&e.jsxs("div",{role:"group","aria-label":"Confirm retention reduction",style:{marginTop:8,padding:"10px 14px",borderRadius:8,background:"rgba(251,191,36,.06)",border:"1px solid rgba(251,191,36,.2)"},children:[e.jsxs("div",{style:{fontSize:11,color:"var(--amber)",fontWeight:600,marginBottom:4},children:["Reduce retention to ",o," days?"]}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["Operations, logs, and metrics older than ",o," days will be permanently deleted."]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{ref:f,type:"button",onClick:g,style:{padding:"5px 14px",borderRadius:6,fontSize:11,fontWeight:700,cursor:"pointer",border:"1px solid rgba(251,191,36,.4)",background:"rgba(251,191,36,.1)",color:"var(--amber)"},children:"Prune & Save"}),e.jsx("button",{type:"button",onClick:()=>h(null),style:{padding:"5px 14px",borderRadius:6,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)"},children:"Cancel"})]})]}),o==null&&e.jsx("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:4},children:"Operations and metric snapshots older than this are pruned automatically. Warning and error logs keep this window; high-volume routine logs also have a size safety cap."}),e.jsx("div",{"aria-live":"polite",children:u&&e.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:u})})]})]})}function V(s){const r=Math.floor(s/1e3);if(r<60)return`${r}s`;const t=Math.floor(r/60);if(t<60)return`${t}m ${r%60}s`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function X(s){return s.length<=12?s:`${s.slice(0,6)}…${s.slice(-4)}`}function J(s){if(!s)return"Unknown";const r=s.includes(":")?s.split(":")[1]:s;switch(r){case"84532":return"Base Sepolia (Testnet)";case"8453":return"Base (Mainnet)";case"1":return"Ethereum Mainnet";case"11155111":return"Sepolia (Testnet)";case"31337":return"Local (Hardhat)";default:return`Chain ${r}`}}function ne(){return e.jsxs("div",{className:"page-section",children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Settings"}),e.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:"Node configuration and preferences"})]}),e.jsx(ee,{})]})}function ee(){var g,y,c,d,v,S,b,R;const{data:s}=j(L,[],3e4),{data:r}=j(M,[],6e4),t=s,n=r,[a,l]=i.useState(!1),[u,m]=i.useState(!1),o=(t==null?void 0:t.connectedPeers)??0,h=(t==null?void 0:t.peerId)!=null,f=i.useCallback(async()=>{if(!a){l(!0),setTimeout(()=>l(!1),5e3);return}m(!0);try{await P()}catch{m(!1),l(!1)}},[a]);return e.jsxs("div",{className:"settings-stack",children:[e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Node Identity"})}),e.jsxs("div",{className:"card-body",children:[e.jsx(p,{label:"Name",value:(t==null?void 0:t.name)??"—"}),e.jsx(p,{label:"Peer ID",value:(t==null?void 0:t.peerId)??"—",mono:!0}),e.jsx(p,{label:"Role",value:(t==null?void 0:t.nodeRole)??"—"}),e.jsx(p,{label:"Network",value:(t==null?void 0:t.networkName)??(t!=null&&t.networkId?`Network ${t.networkId}`:"—")}),e.jsx(p,{label:"Store",value:(t==null?void 0:t.storeBackend)??"—",mono:!0}),e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:h?"var(--green-dim)":"rgba(248,113,113,.05)",border:`1px solid ${h?"rgba(74,222,128,.2)":"rgba(248,113,113,.2)"}`},children:[e.jsx("div",{className:"mono",style:{fontSize:10,color:h?"var(--green)":"var(--red)",fontWeight:700},children:h?"● ONLINE":"● OFFLINE"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:4},title:"Peers = unique remote nodes. Direct + Relayed counts are libp2p connections — a single peer can hold both a direct and a relayed link, so they sum to ≥ Peers, not exactly equal to it.",children:h?`${o} peer${o!==1?"s":""} · ${((g=t==null?void 0:t.connections)==null?void 0:g.direct)??0} direct, ${((y=t==null?void 0:t.connections)==null?void 0:y.relayed)??0} relayed link${(((c=t==null?void 0:t.connections)==null?void 0:c.relayed)??0)===1?"":"s"} · up ${V((t==null?void 0:t.uptimeMs)??0)}`:"Node is not responding"})]})]})]}),e.jsxs("section",{className:"card",children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",children:"Blockchain Config"})}),e.jsxs("div",{className:"card-body",children:[e.jsx(p,{label:"Chain",value:J(n==null?void 0:n.chainId)}),((d=n==null?void 0:n.balances)==null?void 0:d.length)>0?n.balances.map((x,z)=>e.jsxs("div",{style:{marginBottom:10},children:[e.jsx(p,{label:n.balances.length>1?`Wallet ${z+1}`:"Operational Wallet",value:x.address,mono:!0}),e.jsxs("div",{style:{display:"flex",gap:16,marginTop:-6},children:[e.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:I(x.eth),children:[W(x.eth)," ETH"]}),e.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:A(x.trac),children:[T(x.trac)," ",F(x.symbol,n==null?void 0:n.chainId)]})]})]},x.address)):e.jsx(p,{label:"Operational Wallet",value:(v=n==null?void 0:n.wallets)!=null&&v[0]?X(n.wallets[0]):"—",mono:!0}),(n==null?void 0:n.rpcUrl)&&e.jsx(Q,{rpcUrl:n.rpcUrl}),n!=null&&n.error?e.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(248,113,113,.05)",border:"1px solid rgba(248,113,113,.2)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--red)",marginBottom:2},children:"⚠ Error"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:n.error})]}):(S=n==null?void 0:n.chainId)!=null&&S.includes("84532")||(b=n==null?void 0:n.chainId)!=null&&b.includes("31337")||(R=n==null?void 0:n.chainId)!=null&&R.includes("11155111")?e.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"var(--amber-dim)",border:"1px solid rgba(251,191,36,.2)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--amber)",marginBottom:2},children:"⚠ Testnet Mode"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"No real TRAC is spent. Perfect for development."})]}):null]})]}),e.jsx(Z,{}),e.jsx(Y,{}),e.jsx(G,{}),e.jsxs("section",{className:"card",style:{borderColor:"rgba(248,113,113,.2)",background:"rgba(248,113,113,.03)"},children:[e.jsx("div",{className:"card-header",children:e.jsx("h2",{className:"card-title",style:{color:"var(--red)"},children:"Danger Zone"})}),e.jsx("div",{className:"card-body",children:e.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{onClick:f,disabled:u,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${a?"var(--red)":"rgba(251,191,36,.3)"}`,background:a?"rgba(248,113,113,.15)":"rgba(251,191,36,.07)",color:a?"var(--red)":"var(--amber)",fontSize:12,fontWeight:600,cursor:u?"not-allowed":"pointer",opacity:u?.5:1},children:u?"Shutting down…":a?"Confirm Shutdown":"Shutdown Node"}),e.jsx("span",{"aria-live":"polite",children:a&&e.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"Click again to confirm. The node process will terminate."})})]})})]})]})}export{ne as SettingsPage};
@@ -1 +1 @@
1
- import{B as u,n as b,y as k,j as R,p as M,s as S,r as $,h as A,i as T,l as C,m as w,o as E,b as p,q as G}from"./ApproveWalletsModal-BdR2mshx.js";import"./index-KoAnx9JE.js";class D extends u{constructor({callbackSelector:a,cause:t,data:f,extraData:e,sender:l,urls:i}){var o;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(o=t.metaMessages)!=null&&o.length?"":[],"Offchain Gateway Call:",i&&[" Gateway URL(s):",...i.map(n=>` ${b(n)}`)],` Sender: ${l}`,` Data: ${f}`,` Callback selector: ${a}`,` Extra data: ${e}`].flat(),name:"OffchainLookupError"})}}class j extends u{constructor({result:a,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${b(t)}`,`Response: ${k(a)}`],name:"OffchainLookupResponseMalformedError"})}}class B extends u{constructor({sender:a,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${a}`],name:"OffchainLookupSenderMismatchError"})}}const _="0x556f1830",P={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function F(c,{blockNumber:a,blockTag:t,data:f,requestOptions:e,to:l}){var s;const{args:i}=R({data:f,abi:[P]}),[o,n,d,m,y]=i,{ccipRead:h}=c,r=h&&typeof(h==null?void 0:h.request)=="function"?h.request:U;try{if(!M(l,o))throw new B({sender:o,to:l});const g=n.includes(S)?await $({data:d,ccipRequest:x=>r({...x,requestOptions:e})}):await r({data:d,requestOptions:e,sender:o,urls:n}),{data:L}=await A(c,{blockNumber:a,blockTag:t,data:T([m,C([{type:"bytes"},{type:"bytes"}],[g,y])]),requestOptions:e,to:l});return L}catch(g){throw(s=e==null?void 0:e.signal)!=null&&s.aborted?w(e.signal):E(g)?g:new D({callbackSelector:m,cause:g,data:f,extraData:y,sender:o,urls:n})}}async function U({data:c,requestOptions:a,sender:t,urls:f}){var l,i,o;let e=new Error("An unknown error occurred.");for(let n=0;n<f.length;n++){if((l=a==null?void 0:a.signal)!=null&&l.aborted)throw w(a.signal);const d=f[n],m=d.includes("{data}")?"GET":"POST",y=m==="POST"?{data:c,sender:t}:void 0,h=m==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(d.replace("{sender}",t.toLowerCase()).replace("{data}",c),{body:JSON.stringify(y),headers:h,method:m,...a!=null&&a.signal?{signal:a.signal}:{}});let s;if((i=r.headers.get("Content-Type"))!=null&&i.startsWith("application/json")?s=(await r.json()).data:s=await r.text(),!r.ok){e=new p({body:y,details:s!=null&&s.error?k(s.error):r.statusText,headers:r.headers,status:r.status,url:d});continue}if(!G(s)){e=new j({result:s,url:d});continue}return s}catch(r){if((o=a==null?void 0:a.signal)!=null&&o.aborted)throw w(a.signal);if(E(r))throw r;e=new p({body:y,details:r.message,url:d})}}throw e}export{U as ccipRequest,F as offchainLookup,P as offchainLookupAbiItem,_ as offchainLookupSignature};
1
+ import{B as u,n as b,y as k,j as R,p as M,s as S,r as $,h as A,i as T,l as C,m as w,o as E,b as p,q as G}from"./ApproveWalletsModal-CYQqAWZs.js";import"./index-BfrYentv.js";class D extends u{constructor({callbackSelector:a,cause:t,data:f,extraData:e,sender:l,urls:i}){var o;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(o=t.metaMessages)!=null&&o.length?"":[],"Offchain Gateway Call:",i&&[" Gateway URL(s):",...i.map(n=>` ${b(n)}`)],` Sender: ${l}`,` Data: ${f}`,` Callback selector: ${a}`,` Extra data: ${e}`].flat(),name:"OffchainLookupError"})}}class j extends u{constructor({result:a,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${b(t)}`,`Response: ${k(a)}`],name:"OffchainLookupResponseMalformedError"})}}class B extends u{constructor({sender:a,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${a}`],name:"OffchainLookupSenderMismatchError"})}}const _="0x556f1830",P={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function F(c,{blockNumber:a,blockTag:t,data:f,requestOptions:e,to:l}){var s;const{args:i}=R({data:f,abi:[P]}),[o,n,d,m,y]=i,{ccipRead:h}=c,r=h&&typeof(h==null?void 0:h.request)=="function"?h.request:U;try{if(!M(l,o))throw new B({sender:o,to:l});const g=n.includes(S)?await $({data:d,ccipRequest:x=>r({...x,requestOptions:e})}):await r({data:d,requestOptions:e,sender:o,urls:n}),{data:L}=await A(c,{blockNumber:a,blockTag:t,data:T([m,C([{type:"bytes"},{type:"bytes"}],[g,y])]),requestOptions:e,to:l});return L}catch(g){throw(s=e==null?void 0:e.signal)!=null&&s.aborted?w(e.signal):E(g)?g:new D({callbackSelector:m,cause:g,data:f,extraData:y,sender:o,urls:n})}}async function U({data:c,requestOptions:a,sender:t,urls:f}){var l,i,o;let e=new Error("An unknown error occurred.");for(let n=0;n<f.length;n++){if((l=a==null?void 0:a.signal)!=null&&l.aborted)throw w(a.signal);const d=f[n],m=d.includes("{data}")?"GET":"POST",y=m==="POST"?{data:c,sender:t}:void 0,h=m==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(d.replace("{sender}",t.toLowerCase()).replace("{data}",c),{body:JSON.stringify(y),headers:h,method:m,...a!=null&&a.signal?{signal:a.signal}:{}});let s;if((i=r.headers.get("Content-Type"))!=null&&i.startsWith("application/json")?s=(await r.json()).data:s=await r.text(),!r.ok){e=new p({body:y,details:s!=null&&s.error?k(s.error):r.statusText,headers:r.headers,status:r.status,url:d});continue}if(!G(s)){e=new j({result:s,url:d});continue}return s}catch(r){if((o=a==null?void 0:a.signal)!=null&&o.aborted)throw w(a.signal);if(E(r))throw r;e=new p({body:y,details:r.message,url:d})}}throw e}export{U as ccipRequest,F as offchainLookup,P as offchainLookupAbiItem,_ as offchainLookupSignature};