@origintrail-official/dkg-node-ui 10.0.18 → 10.0.20
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/chain-cursor-stores.d.ts +17 -0
- package/dist/chain-cursor-stores.d.ts.map +1 -1
- package/dist/chain-cursor-stores.js +37 -0
- package/dist/chain-cursor-stores.js.map +1 -1
- package/dist/chain-event-log-store.d.ts +31 -0
- package/dist/chain-event-log-store.d.ts.map +1 -1
- package/dist/chain-event-log-store.js +87 -13
- package/dist/chain-event-log-store.js.map +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +27 -1
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist-ui/assets/{3d-force-graph-DGF2sXeK.js → 3d-force-graph-CehOGxux.js} +1 -1
- package/dist-ui/assets/{ActivityFeed-DNatshHL.js → ActivityFeed-BE4MTD8M.js} +1 -1
- package/dist-ui/assets/{AgentHub-lOm96XuE.js → AgentHub-CT6UhLF2.js} +1 -1
- package/dist-ui/assets/{AgentProfilePage-BRtazufK.js → AgentProfilePage-ygi-GXKM.js} +1 -1
- package/dist-ui/assets/{ApproveWalletsModal-BMtRgndO.js → ApproveWalletsModal-YFfDrGth.js} +3 -3
- package/dist-ui/assets/{ContextGraphPrimitives-CBc6kvmp.js → ContextGraphPrimitives-Dh-w2D_i.js} +1 -1
- package/dist-ui/assets/{ConvictionDetailView-DOTYSm7p.js → ConvictionDetailView-CfRmqqDD.js} +2 -2
- package/dist-ui/assets/MemoryLayerView-DL0zLYAQ.js +2 -0
- package/dist-ui/assets/{MemoryStackView-Bol2eMyq.js → MemoryStackView-BsV_JnOe.js} +1 -1
- package/dist-ui/assets/{Network-B49IxpAj.js → Network-BkxRENe4.js} +1 -1
- package/dist-ui/assets/{OnChainProvenanceCard-BpUoHg4b.js → OnChainProvenanceCard-CnnkMMNI.js} +1 -1
- package/dist-ui/assets/{Operations-BCQ545Yk.js → Operations-BaWWLSUw.js} +1 -1
- package/dist-ui/assets/{ProjectView-BaQQSy8L.js → ProjectView-BJmZ5f62.js} +31 -31
- package/dist-ui/assets/{PublishingConviction-B5nWRsUP.js → PublishingConviction-CKB6JBYk.js} +2 -2
- package/dist-ui/assets/{Settings-DeZKX_Ry.js → Settings-DXGMPiJk.js} +1 -1
- package/dist-ui/assets/{browserWalletTransaction-B6wyaMOV.js → browserWalletTransaction-BdmrJpK1.js} +3 -3
- package/dist-ui/assets/{ccip-B_vQl40F.js → ccip-BNYiIkjs.js} +1 -1
- package/dist-ui/assets/{index-CT-LdpBE.js → index-DK8XzE3T.js} +92 -92
- package/dist-ui/assets/{index-DHd3qhAk.js → index-DOGXDQkQ.js} +3 -3
- package/dist-ui/assets/{jsonld-32FQRO67-BYu8pE-5.js → jsonld-32FQRO67-Ca-KnQfb.js} +2 -2
- package/dist-ui/assets/{jsonld-Crm5iwcE.js → jsonld-mRC9FbFR.js} +1 -1
- package/dist-ui/assets/{renderer-3d-2EVDZII7-C2z5aUgo.js → renderer-3d-2EVDZII7-AEMBPIY7.js} +2 -2
- package/dist-ui/assets/{shikiHighlighter-DW1fRfBU.js → shikiHighlighter-CUQ07vzt.js} +1 -1
- package/dist-ui/assets/{useEntityOnChainReceipt-0Ub24t6e.js → useEntityOnChainReceipt-C8NHlPPN.js} +1 -1
- package/dist-ui/assets/{useProjectActivity-CLza3psq.js → useProjectActivity-CVFCfbMj.js} +1 -1
- package/dist-ui/index.html +1 -1
- package/package.json +3 -3
- package/dist-ui/assets/MemoryLayerView-DDFI2ngR.js +0 -2
package/dist-ui/assets/{PublishingConviction-B5nWRsUP.js → PublishingConviction-CKB6JBYk.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{bc as i,a7 as ie,aI as de,bJ as _,by as ee,ai as pe,b4 as ue,a3 as ge,aJ as xe,bN as D,aO as e,ar as be,aq as ne,aw as fe,aZ as Ce,aM as je,ao as Ne,ap as ye,w as ke,B as Ae,bv as Pe,bL as Ie,aN as Se,bH as Ee,aK as ce,N as X,aW as Te,b7 as Re}from"./index-CT-LdpBE.js";import{S as We,E as $e}from"./ContextGraphPrimitives-CBc6kvmp.js";import{L as Oe,e as K,Q as Me,P as ae}from"./browserWalletTransaction-B6wyaMOV.js";import{p as oe,H as Be,o as Fe,P as De,r as Le,b as Ue,C as Ge,a as _e}from"./ApproveWalletsModal-BMtRgndO.js";function Ve(){const[t,s]=i.useState("loading"),[c,l]=i.useState(0);return i.useEffect(()=>{let h=!0;return s("loading"),ie("0").then(()=>{h&&s("available")}).catch(d=>{h&&s(de(d)?"unavailable":"available")}),()=>{h=!1}},[c]),{status:t,recheck:()=>l(h=>h+1)}}function qe(t){const{accountId:s,relation:c,...l}=t;return l}function He(t,s){return t===s?t:"both"}function Ke(){const t=_(n=>n.trackedIds),s=_(n=>n.trackAccount),{data:c,loading:l,refresh:h}=ee(async()=>{let n=!1;const p=await pe().catch(()=>(n=!0,null));typeof(p==null?void 0:p.error)=="string"&&p.error.length>0&&(n=!0);const o=(p==null?void 0:p.wallets)??[],v=(await Promise.all(o.map(async g=>{const N=await ue(g).catch(()=>(n=!0,null));return N!=null&&N.accountId?{accountId:N.accountId,wallet:g}:null}))).filter(g=>g!=null);let u=[],C=!1;try{u=(await ge({hydrate:!0})).accounts}catch(g){de(g)&&!xe(g)?u=[]:C=!0}return{agentPairs:v,mine:u,ownedError:C,agentError:n}},[],0),d=i.useMemo(()=>{const n=new Map;for(const p of(c==null?void 0:c.mine)??[])n.set(p.accountId,{accountId:p.accountId,relation:p.relation,basics:qe(p)});for(const p of(c==null?void 0:c.agentPairs)??[]){const o=n.get(p.accountId);o?(o.relation=He(o.relation,"agent"),o.agentWallet||(o.agentWallet=p.wallet)):n.set(p.accountId,{accountId:p.accountId,relation:"agent",agentWallet:p.wallet})}return[...n.values()]},[c]);i.useEffect(()=>{for(const n of d)(n.relation==="agent"||n.relation==="both")&&!t.includes(n.accountId)&&s(n.accountId)},[d,t,s]);const x=i.useMemo(()=>d.filter(n=>!t.includes(n.accountId)),[d,t]);return{discovered:d,untracked:x,ownedError:(c==null?void 0:c.ownedError)??!1,agentError:(c==null?void 0:c.agentError)??!1,loading:l,refresh:h}}function Ye(){const t=D(n=>n.address),s=D(n=>n.bootstrap),[c,l]=i.useState({loading:!1,error:null,ids:[]}),[h,d]=i.useState(0);i.useEffect(()=>{let n=!1;async function p(o,v){var u;l(C=>({...C,loading:!0,error:null}));try{if(!((u=o.rpcUrls)!=null&&u.length))throw new Error("No PCA RPC endpoints were provided.");const C=Oe(o.chainId,o.rpcUrls),g=o.nft,N=v,T=await C.readContract({address:g,abi:oe,functionName:"balanceOf",args:[N]}),S=[],m=typeof T=="bigint"?T:BigInt(String(T));for(let y=0n;y<m;y+=1n){const k=await C.readContract({address:g,abi:oe,functionName:"tokenOfOwnerByIndex",args:[N,y]});S.push((typeof k=="bigint"?k:BigInt(String(k))).toString())}if(n)return;l({loading:!1,error:null,ids:S})}catch(C){if(n)return;l({loading:!1,error:(C==null?void 0:C.message)??"Could not read connected-wallet PCAs.",ids:[]})}}return!t||!s?(l({loading:!1,error:null,ids:[]}),()=>{n=!0}):(p(s,t),()=>{n=!0})},[t,s,h]);const x=i.useCallback(()=>d(n=>n+1),[]);return{ids:c.ids,loading:c.loading,error:c.error,refresh:x}}function re(t){if(typeof t!="number"||!Number.isFinite(t))return"—";const s=t/100;return`${s%1===0?s.toFixed(0):s.toFixed(1)}%`}function te({account:t,blockExplorerUrl:s,nowSec:c,onManage:l,onApproveWallets:h,onUseForPublishing:d,onRemove:x,onRetry:n,onSwitchNetwork:p,view:o}){const{accountId:v,snapshot:u,notFound:C,classification:g,ownerIsPrimaryWallet:N}=t;if(C)return e.jsx("div",{className:"card v10-pca-card","data-state":"not-found","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body v10-pca-card-error",children:[e.jsxs("p",{children:["PCA #",v," no longer exists on-chain."]}),x&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>x(v),children:"Remove from tracked"})]})});if(!u)return e.jsx("div",{className:"card v10-pca-card","data-state":"error","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body v10-pca-card-error",children:[e.jsxs("p",{children:["Couldn’t load PCA #",v,"."]}),n&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>n(v),children:"Retry"})]})});const T=be(u.expiresAtTimestamp,c),S=s?`${s}/address/${u.owner}`:void 0,m=t.ownerMode??(N?"daemon":"external"),y=m==="wallet"&&!!t.walletWrongNetwork,k=Fe(m,y),b=t.connectedWallet,R=m==="daemon"?void 0:m==="wallet"?y?"Wrong network - switch the connected wallet to this node's PCA network.":"Connected wallet will sign this owner action.":b?`Connected as ${b}; switch to ${u.owner} to manage PCA #${v}.`:`Connect owner wallet ${u.owner} to manage PCA #${v}.`,W=e.jsxs("div",{className:"v10-pca-card-title",children:[e.jsxs("span",{className:"v10-pca-card-id",children:["PCA #",v]}),e.jsxs("span",{className:"badge badge-info v10-pca-card-discount",children:["◉ ",re(u.discountBps)," discount"]}),m==="wallet"&&e.jsx("span",{className:"badge badge-info",children:"✎ wallet-managed"}),m==="external"&&e.jsx("span",{className:"badge badge-warn",children:"tracked external"}),e.jsx("span",{className:"v10-pca-card-spacer"}),t.health&&e.jsx(Be,{state:t.health})]}),A=e.jsxs("div",{className:"v10-pca-card-owner",children:[e.jsx("span",{className:"v10-pca-card-owner-lbl",children:"Owner"}),e.jsx(K,{address:u.owner,trailing:S?e.jsx("a",{className:"v10-pca-card-explorer",href:S,target:"_blank",rel:"noreferrer","aria-label":`View owner ${u.owner} on the block explorer`,children:"↗"}):void 0})]}),U=m==="daemon"?"Daemon-managed: owner actions use this node’s primary operational wallet.":m==="wallet"?"Wallet-managed: owner actions are signed by the connected wallet.":b?`Read-only here: connected as ${b}; switch to the owner wallet to manage.`:"Read-only here: connect the owner wallet to manage this PCA.";if(o==="coverage"?!1:o==="owner"?!0:g==="owned"||m==="wallet"||m==="external"&&t.approvedCount===0){const q=t.approvedCount>0,$=t.probesInconclusive;return e.jsx("div",{className:"card v10-pca-card","data-state":"owned","data-owner-mode":m,"data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body",children:[W,e.jsx(We,{items:[{id:"committed",label:"Committed",value:`${ne(u.committedTRACTrac)} TRAC`},{id:"buffer",label:"Top-up buffer",value:`${ne(u.topUpBufferTrac)} TRAC`},{id:"per-epoch",label:"Per-epoch allowance",value:`${fe(u.baseEpochAllowance)} TRAC`},{id:"wallets",label:"Publishing wallets",value:`${u.agentCount} / 100`}]}),A,m==="daemon"?e.jsxs("p",{className:"v10-pca-card-owner-note",children:["This is the node’s operational wallet — who ",e.jsx("strong",{children:"signs"}),", not who’s covered."]}):e.jsx("p",{className:"v10-pca-card-owner-note",children:U}),y&&e.jsxs("p",{className:"v10-pca-card-warn",role:"alert",children:["Wrong network. Reads still work, but wallet-owner writes are disabled until the wallet is switched."," ",p&&e.jsx("button",{type:"button",className:"v10-pca-inline-btn",onClick:p,children:"Switch network"})]}),m==="external"&&e.jsx("p",{className:"v10-pca-card-warn",children:b?`Connected as ${b} - switch to ${u.owner} to manage PCA #${v}.`:`Connect ${u.owner} to manage PCA #${v}.`}),$?e.jsx("p",{className:"v10-pca-card-warn",children:"⚠ Couldn’t verify which of this node’s wallets are approved — retry. Until then, whether this account discounts your publishes is unconfirmed."}):q?null:e.jsx("p",{className:"v10-pca-card-warn",children:"⚠ 0 of this node’s wallets are approved here — it discounts nothing yet. Approve this node’s operational wallets to start saving."}),e.jsxs("p",{className:"v10-pca-card-meta",children:[T,e.jsx("span",{className:"v10-pca-card-meta-sep",children:" · "}),e.jsxs("span",{title:`Expiry epoch ${u.expiresAtEpoch}`,children:["epoch ",u.expiresAtEpoch," ⓘ"]})]}),e.jsxs("div",{className:"v10-pca-card-actions",children:[l&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>l(v),children:m==="external"?"View details":"Manage"}),m==="external"?x&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>x(v),children:"Stop tracking"}):e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>h==null?void 0:h(v),disabled:!k||!h,title:R,children:"Approve wallets"})]})]})})}const L=t.walletCount>0&&t.approvedCount===t.walletCount,B=t.probesInconclusive;return e.jsx("div",{className:"card v10-pca-card","data-state":"approved","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body",children:[e.jsxs("div",{className:"v10-pca-card-title",children:[e.jsxs("span",{className:"v10-pca-card-id",children:["PCA #",v]}),e.jsx("span",{className:"v10-pca-card-sponsor",children:"(approved for this node)"}),e.jsxs("span",{className:"badge badge-info v10-pca-card-discount",children:["◉ ",re(u.discountBps)]}),e.jsx("span",{className:"v10-pca-card-spacer"}),B?e.jsx("span",{className:"badge badge-warn",children:"⚠ couldn’t verify approvals"}):!L&&t.walletCount>0?e.jsxs("span",{className:"badge badge-warn",children:["⚠ ",t.approvedCount," of ",t.walletCount," wallets approved"]}):null]}),A,e.jsxs("p",{className:"v10-pca-card-meta",children:[T,e.jsx("span",{className:"v10-pca-card-meta-sep",children:" · "}),e.jsxs("span",{title:`Expiry epoch ${u.expiresAtEpoch}`,children:["epoch ",u.expiresAtEpoch," ⓘ"]})]}),e.jsx("p",{className:"v10-pca-card-summary",children:B?"Approval coverage could not be fully verified.":`${t.approvedCount} of ${t.walletCount} node publishing wallet${t.walletCount===1?"":"s"} approved.`}),B?e.jsx("p",{className:"v10-pca-card-warn",children:"Couldn’t verify which wallets are approved — retry."}):!L&&t.walletCount>0?e.jsx("p",{className:"v10-pca-card-warn",children:"Publishes from the un-approved wallet(s) will quietly pay the direct cost."}):null,e.jsxs("div",{className:"v10-pca-card-actions",children:[l&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>l(v),children:"View details"}),d&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>d(v),children:"Use for publishing"})]})]})})}const Je={84532:"https://www.alchemy.com/faucets/base-sepolia",11155111:"https://www.alchemy.com/faucets/ethereum-sepolia",10200:"https://faucet.chiadochain.net/"};function ze(t){if(t==null)return;const s=String(t),c=s.includes(":")?s.split(":").pop():s;return Je[c]}function Qe(t){switch(t.outcome){case"covers":return{text:"approved",tone:"success"};case"uncovered":return{text:"approved, but that PCA is expired, swept, or out of budget - publishes will not get the discount",tone:"warn"};case"unregistered":return{text:"not approved - ask the PCA owner to approve it",tone:"danger"};case"inconclusive":return{text:"unknown",tone:"neutral"}}}function Ze({onClose:t}){const{data:s,loading:c,error:l,refresh:h}=ee(pe,[],0),d=(s==null?void 0:s.wallets)??[],x=(s==null?void 0:s.balances)??[],n=typeof(s==null?void 0:s.error)=="string"&&s.error.length>0?s.error:null,p=l||n,o=(s==null?void 0:s.chainId)??null,v=Ce(o),u=je(o)?ze(o):void 0,C=_(r=>r.trackAccount),{copied:g,copy:N}=Me(),T=d.join(","),{data:S}=ee(async()=>{const r=(s==null?void 0:s.wallets)??[];if(r.length===0)return[];const w=await Promise.all(r.map(j=>ue(j).then(f=>f.accountId).catch(()=>null)));return Array.from(new Set(w.filter(j=>j!=null)))},[T],0),[m,y]=i.useState(""),[k,b]=i.useState(!1),[R,W]=i.useState(null),[A,U]=i.useState(null),V=r=>{var w;return(w=x.find(j=>{var f;return((f=j.address)==null?void 0:f.toLowerCase())===r.toLowerCase()}))==null?void 0:w.eth},L=r=>{const w=V(r);return w!=null&&Number(w)>0},B=async()=>{var w;const r=m.trim();if(!/^\d+$/.test(r)){W("Enter the numeric PCA ID the owner gave you.");return}b(!0),W(null);try{const j=await Promise.all(d.map(f=>ie(r,f,{extended:!0}).then(O=>({wallet:f,coverage:ke(O)})).catch(()=>({wallet:f,coverage:{outcome:"inconclusive",registered:null,adapterUnsupported:!1}}))));if(j.length>0&&j.every(f=>f.coverage.outcome==="inconclusive")){const f=j.every(O=>O.coverage.outcome==="inconclusive"&&O.coverage.adapterUnsupported);W(f?"PCA approval isn’t verifiable on this chain’s adapter — not supported here. You can still publish without a discount.":`Couldn’t check approval on PCA #${r} right now — the chain lookup failed. Retry.`),U(null);return}j.some(f=>f.coverage.registered===!0)&&C(r),U({accountId:r,rows:j})}catch(j){W(((w=Ae(j,{accountId:r}))==null?void 0:w.message)??"Couldn’t check approval.")}finally{b(!1)}},q=(A==null?void 0:A.rows.filter(r=>r.coverage.registered===!0).length)??0,$=!!A&&A.rows.some(r=>r.coverage.outcome==="covers"&&L(r.wallet));return e.jsxs(De,{onClose:t,testId:"pca-get-sponsored",title:"Get added to a PCA",subtitle:"Share this node's operational publishing wallets with the PCA owner. They approve them; this node still pays its own gas.",children:[e.jsxs("div",{className:"v10-modal-body v10-pca-get-added-body",children:[e.jsxs("section",{className:"v10-pca-detail-section",children:[e.jsx("h3",{className:"v10-pca-detail-section-title",children:"Your operational wallets (signers / msg.sender)"}),e.jsx("div",{className:"v10-pca-detail-agentlist",children:c&&!s?e.jsx("p",{className:"v10-pca-handshake-empty",role:"status",children:"Loading your wallets…"}):p&&d.length===0?e.jsxs("p",{className:"v10-modal-error",role:"alert",children:["Couldn’t load your wallets."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>h(),children:"Retry"})]}):d.length===0?e.jsx("p",{className:"v10-pca-handshake-empty",children:"No operational wallets detected on this node."}):d.map(r=>{const w=V(r),j=L(r);return e.jsx(K,{address:r,gas:w!=null?e.jsxs("span",{title:ye(w),children:["gas ",Ne(w)," ",v," ",j?"✓":"⚠ fund to publish"]}):void 0},r)})}),d.length>0&&e.jsx("button",{type:"button",className:"v10-pca-handshake-copyall",onClick:()=>N(d.join(`
|
|
2
|
-
`)),"aria-label":g?"Copied all wallets":"Copy all wallet addresses",children:g?"Copied":`Copy all ${d.length}`}),e.jsxs("p",{className:"v10-pca-detail-hint",children:["Share ",e.jsx("strong",{children:"all"})," wallets (the node rotates its signer per publish) or pin to one. Share the exact address - a typo can be approved by the PCA owner but never match your real signer."]})]}),e.jsxs("div",{className:"v10-modal-warning",children:["⚠ Gas is always on you. The PCA covers the TRAC publishing fee — never your gas. Fund each wallet with native ",v,".",u?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open faucet ↗"})," (testnet only)"]}):e.jsxs(e.Fragment,{children:[" ","Fund with native ",v," from your wallet."]})]}),e.jsxs("section",{className:"v10-pca-detail-section",children:[e.jsx("h3",{className:"v10-pca-detail-section-title",children:"Can't find it automatically?"}),e.jsx("p",{className:"v10-pca-detail-hint",children:"If the PCA owner gives you an account id, check it here to track whether this node's wallets are covered."}),S&&S.length>0&&e.jsxs("div",{className:"v10-pca-discovered-check",role:"status","data-testid":"pca-sponsor-discovered",children:["◉ We found your wallet(s) already approved on ",S.map(r=>`PCA #${r}`).join(", "),"."," ",e.jsxs("button",{type:"button",className:"v10-pca-card-btn compact",onClick:()=>y(S[0]),children:["Check PCA #",S[0]]})]}),e.jsxs("div",{className:"v10-pca-detail-form",children:[e.jsx("input",{className:"v10-form-input",type:"text",value:m,onChange:r=>y(r.target.value),placeholder:"PCA ID from owner (e.g. 7)","aria-label":"PCA ID from owner"}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:B,disabled:k,children:k?"Checking…":"Check approval"})]}),R&&e.jsx("p",{className:"v10-modal-error",role:"alert",children:R}),A&&e.jsxs("div",{className:"v10-pca-approve-results",role:"status","aria-live":"polite",children:[e.jsxs("p",{className:"v10-pca-approve-summary",children:["Approved on PCA #",A.accountId,": ",q," of ",A.rows.length," wallets ✓"]}),A.rows.map(r=>{const w=Qe(r.coverage);return e.jsx(K,{address:r.wallet,status:w.text,statusTone:w.tone},r.wallet)})]})]}),$&&e.jsxs("div",{className:"v10-pca-create-success",role:"status",children:["Ready: at least 1 wallet is approved and gas-funded - this node can publish under PCA #",A.accountId,"."," ","Publish from any context graph — the discount applies automatically to your approved wallets."]})]}),e.jsx("div",{className:"v10-modal-footer",children:e.jsx("button",{type:"button",className:"v10-modal-btn",onClick:t,children:"Close"})})]})}function Xe(){const t=Pe(a=>a.nodeStatus),s=(t==null?void 0:t.nodeRole)==="core"||(t==null?void 0:t.nodeRole)==="edge"?t.nodeRole:void 0,c=(t==null?void 0:t.blockExplorerUrl)??null,l=Ie(a=>a.openTab),h=_(a=>a.trackAccount),d=_(a=>a.untrackAccount),x=_(a=>a.setScope),n=D(a=>a.setBootstrap),p=D(a=>a.initWallet);D(a=>a.bootstrap);const o=D(a=>a.address),v=D(a=>Se(a)),u=D(a=>a.switchToExpectedChain),[C,g]=i.useState({status:"idle",error:null}),N=Ye(),[T,S]=i.useState(0),m=Ee(3e4,N.ids),{accounts:y,loading:k,refresh:b,walletsInconclusive:R}=m,W=m.wallets[0];i.useEffect(()=>{let a=!1;async function E(){g({status:"loading",error:null});try{const I=await Te();if(a)return;x(Re(I)),n(I),p(),g({status:"ready",error:null})}catch(I){if(a)return;g({status:"error",error:(I==null?void 0:I.message)??"Could not bootstrap wallet contract reads."}),p()}}return E(),()=>{a=!0}},[T,p,x,n]);const{untracked:A,ownedError:U,agentError:V,refresh:L}=Ke(),B=U||V,[q,$]=i.useState(!1),[r,w]=i.useState(null),[j,f]=i.useState(!1),[O,se]=i.useState(null),P=i.useMemo(()=>y.map(a=>{var I;const E=Le({owner:(I=a.snapshot)==null?void 0:I.owner,primaryWallet:W,connectedWallet:o,walletWrongNetwork:v});return{...a,ownerMode:E.mode,primaryWallet:W,connectedWallet:o,walletWrongNetwork:E.mode==="wallet"&&E.wrongNetwork}}),[y,o,W,v]);i.useEffect(()=>{!O||k||P.some(a=>a.accountId===O)&&se(null)},[P,k,O]);const Y=i.useMemo(()=>P.filter(a=>a.ownerMode==="daemon"),[P]),J=i.useMemo(()=>P.filter(a=>a.ownerMode==="wallet"),[P]),z=i.useMemo(()=>P.filter(a=>a.ownerMode==="external"&&a.snapshot&&a.approvedCount===0),[P]),Q=i.useMemo(()=>P.filter(a=>a.approvedCount>0||!a.snapshot&&!a.notFound),[P]),G=a=>l({id:`conviction:${a}`,label:`PCA #${a}`,closable:!0}),he=i.useMemo(()=>[...Y,...J],[Y,J]),Z=i.useMemo(()=>m.wallets.map(a=>{const E=P.find(M=>M.snapshot&&ce(M.snapshot)&&M.walletProbes.some(F=>X(F.wallet,a)&&F.registered===!0));if(E!=null&&E.snapshot)return{wallet:a,status:`covered by PCA #${E.accountId}`,tone:"success"};const I=P.find(M=>M.snapshot&&!ce(M.snapshot)&&M.walletProbes.some(F=>X(F.wallet,a)&&F.registered===!0));return I!=null&&I.snapshot?{wallet:a,status:`approved on inactive PCA #${I.accountId}`,tone:"warn"}:R||P.some(M=>M.walletProbes.some(F=>X(F.wallet,a)&&F.registered==null))?{wallet:a,status:"unknown - retry wallet/PCA read",tone:"warn"}:k&&y.length===0?{wallet:a,status:"checking",tone:"neutral"}:{wallet:a,status:"direct cost",tone:"danger"}}),[y.length,P,k,m.wallets,R]),ve=Z.some(a=>a.tone==="success"),me=i.useCallback(()=>S(a=>a+1),[]),H=i.useCallback(()=>{u()},[u]),we=i.useCallback(a=>{se(a),h(a)},[h]);return e.jsxs("div",{className:"v10-pca-overview","data-testid":"pca-landing",children:[e.jsxs("header",{className:"v10-pca-overview-head",children:[e.jsxs("div",{className:"v10-pca-overview-titlerow",children:[e.jsx("h2",{className:"v10-pca-overview-title",children:"Publisher Conviction"}),s&&e.jsxs("span",{className:"badge v10-pca-role-chip",children:["Node role: ",s]})]}),e.jsx("p",{className:"v10-pca-overview-explainer",children:s==="edge"?"Publisher Conviction Accounts let publishers dedicate TRAC spend in advance and receive a publishing discount by tier: 0%, 10%, 20%, 30%, 40%, 50%, or 75%, based on the committed amount. Nodes can create their own PCA or get added to an existing PCA by sharing operational publishing wallets with the PCA owner. You still pay gas; the PCA covers only the TRAC publishing fee for approved wallets.":"A Publisher Conviction Account (PCA) lets you lock TRAC up front and approve publishing wallets to publish at a discount. The discount applies to the wallet that signs the publish (on-chain msg.sender), not a peerId, admin wallet, or author identity."})]}),e.jsxs("section",{className:"v10-pca-section v10-pca-coverage-summary","data-testid":"pca-coverage-summary",children:[e.jsxs("div",{className:"v10-pca-section-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"v10-pca-section-title",children:"This node's publishing wallet coverage"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"The discount follows the operational wallet that signs a publish."})]}),e.jsxs("div",{className:"v10-pca-overview-cta-group",children:[e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>f(!0),children:"Get added to a PCA"}),e.jsx("button",{type:"button",className:"v10-pca-card-btn","data-testid":"pca-create-btn",onClick:()=>$(!0),children:"+ Create PCA"})]})]}),Z.length>0?e.jsx("div",{className:"v10-pca-wallet-list",children:Z.map(a=>e.jsx(K,{address:a.wallet,status:a.status,statusTone:a.tone},a.wallet))}):R?e.jsxs("p",{className:"v10-pca-overview-caveat",role:"status",children:["Couldn't read this node's wallets, so coverage can't be confirmed."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>b(),children:"Retry"})]}):e.jsx("p",{className:"v10-pca-overview-caveat",children:"No operational publishing wallets were reported by this node."}),!ve&&!k&&!R&&!B&&e.jsx("p",{className:"v10-pca-inline-status",role:"status",children:"No PCA discount is active for this node yet. Publishes from direct-cost wallets use the signing wallet."}),!k&&Q.length>0&&e.jsxs("div",{className:"v10-pca-linked-pcas","data-testid":"pca-approved-section",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-account-group-title",children:"PCAs linked to this node"}),e.jsx("span",{className:"v10-pca-account-group-count",children:Q.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Account summaries for PCAs that approve at least one of this node's publishing wallets. Wallet coverage above is the source of truth for publish discounts."}),e.jsx("div",{className:"v10-pca-card-grid v10-pca-card-grid-compact",children:Q.map(a=>e.jsx(te,{account:a,view:"coverage",blockExplorerUrl:c,onManage:G,onApproveWallets:E=>w({accountId:E,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:H},`approved-${a.accountId}`))})]})]}),k&&y.length===0?e.jsxs("div",{className:"v10-pca-card-grid",children:[e.jsx("div",{className:"card v10-pca-card v10-pca-card-skeleton","aria-hidden":"true"}),e.jsx("div",{className:"card v10-pca-card v10-pca-card-skeleton","aria-hidden":"true"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"v10-pca-section","data-testid":"pca-owned-section",children:[e.jsxs("div",{className:"v10-pca-section-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"v10-pca-section-title",children:"Owned by me"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Connect an owner wallet to discover and manage wallet-owned PCAs. Node-owned PCAs use the daemon wallet."})]}),e.jsx("div",{className:"v10-pca-overview-cta-group",children:e.jsx("button",{type:"button",className:"v10-pca-card-btn","data-testid":"pca-create-owned-btn",onClick:()=>$(!0),children:"+ Create PCA"})})]}),e.jsx("div",{className:"v10-pca-overview-wallet",children:e.jsx(Ue,{className:"compact",testId:"pca-wallet-connect"})}),he.length>0?e.jsxs("div",{className:"v10-pca-owned-groups",children:[e.jsx(le,{title:"This node (hot wallet)",description:"Daemon-owned PCAs. Owner writes use the node daemon.",accounts:Y,blockExplorerUrl:c,onManage:G,onApproveWallets:a=>w({accountId:a,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:H}),e.jsx(le,{title:o?`${ae(o)} (connected)`:"Connected wallet",description:"Wallet-managed PCAs. Owner writes are signed by the connected wallet.",accounts:J,blockExplorerUrl:c,onManage:G,onApproveWallets:a=>w({accountId:a,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:H})]}):R?null:e.jsx("p",{className:"v10-pca-inline-status",children:"No owned PCAs are tracked yet."})]}),e.jsxs("section",{className:"v10-pca-section","data-testid":"pca-tracked-external-section",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-section-title",children:"Tracked external accounts"}),e.jsx("span",{className:"v10-pca-account-group-count",children:z.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Read-only PCA records you track manually. Connect the owner wallet to manage one."}),z.length>0?e.jsx("div",{className:"v10-pca-card-grid",children:z.map(a=>e.jsx(te,{account:a,view:"owner",blockExplorerUrl:c,onManage:G,onRemove:d,onRetry:()=>b(),onSwitchNetwork:H},`external-${a.accountId}`))}):e.jsx("p",{className:"v10-pca-inline-status",children:"No external PCAs are tracked manually."}),e.jsx(aa,{onTrack:we})]})]}),O&&e.jsxs("p",{className:"v10-pca-track-status",role:"status","data-testid":"pca-track-status",children:["Checking PCA #",O,". It will appear here when the chain read returns."]}),B&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-discovered-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Couldn't verify this node's Publisher Conviction Accounts; approved PCA coverage may still exist."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>L(),children:"Retry"})]})}),C.status==="error"&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-wallet-bootstrap-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Note: Couldn't load wallet contract bootstrap, so connected-wallet PCA discovery is paused."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:me,children:"Retry"})]})}),N.error&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-wallet-discovery-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Note: Couldn't read PCAs owned by the connected wallet. Existing tracked PCAs are still shown."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:N.refresh,children:"Retry"})]})}),N.loading&&o&&e.jsxs("p",{className:"v10-pca-overview-caveat",role:"status",children:["Reading PCAs owned by ",ae(o),"..."]}),e.jsx(ea,{items:A,onTrack:h,onManage:G}),q&&e.jsx(Ge,{onClose:()=>{$(!1),b()},onApproveOwnWallets:a=>{$(!1),w({accountId:a,mode:"self",selfCoverage:!0})},onManage:a=>{$(!1),G(a)},onGetSponsored:()=>{$(!1),f(!0)}}),r&&e.jsx(_e,{accountId:r.accountId,initialMode:r.mode,selfCoverage:r.selfCoverage,onClose:()=>{w(null),b()}}),j&&e.jsx(Ze,{onClose:()=>{f(!1),b()}})]})}function ea({items:t,onTrack:s,onManage:c}){return t.length===0?null:e.jsxs("section",{className:"v10-pca-discovered","data-testid":"pca-discovered-strip",children:[e.jsx("h3",{className:"v10-pca-discovered-title",children:"Discovered - not tracked here"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Found on-chain for this node's wallets or the connected wallet. Track to show them in the grid above."}),t.map(l=>{var d;const h=(d=l.basics)==null?void 0:d.discountBps;return e.jsxs("div",{className:"v10-pca-discovered-row","data-testid":"pca-discovered-row",children:[e.jsxs("span",{className:"v10-pca-discovered-label",children:[e.jsxs("button",{type:"button",className:"v10-notif-cg-link",onClick:()=>c(l.accountId),children:["PCA #",l.accountId]})," ","-"," ",l.relation==="agent"?`your wallet ${l.agentWallet?ae(l.agentWallet):""} is approved here`:l.relation==="both"?"you own this; your wallet is approved here":"you own this account",(l.relation==="agent"||l.relation==="both")&&typeof h=="number"&&h>0&&e.jsxs("span",{className:"badge badge-info",children:[" ",(h/100).toFixed(h%100===0?0:1),"%"]})]}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary","data-testid":"pca-discovered-track",onClick:()=>s(l.accountId),children:"Track"})]},l.accountId)})]})}function le({title:t,description:s,accounts:c,blockExplorerUrl:l,onManage:h,onApproveWallets:d,onRemove:x,onRetry:n,onSwitchNetwork:p}){return c.length===0?null:e.jsxs("section",{className:"v10-pca-account-group",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-account-group-title",children:t}),e.jsx("span",{className:"v10-pca-account-group-count",children:c.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:s}),e.jsx("div",{className:"v10-pca-card-grid",children:c.map(o=>e.jsx(te,{account:o,view:"owner",blockExplorerUrl:l,onManage:h,onApproveWallets:d,onRemove:x,onRetry:n,onSwitchNetwork:p},o.accountId))})]})}function aa({onTrack:t}){const[s,c]=i.useState(!1),[l,h]=i.useState(""),[d,x]=i.useState(null),n=i.useId(),p=()=>{const o=l.trim();if(!/^\d+$/.test(o)){x("Enter a numeric account id.");return}t(o),h(""),x(null),c(!1)};return e.jsxs("div",{className:"v10-pca-track",children:[e.jsx("button",{type:"button",className:"v10-pca-track-toggle","data-testid":"pca-track-toggle","aria-expanded":s,"aria-controls":n,onClick:()=>c(o=>!o),children:"Track PCA by ID"}),s&&e.jsxs("div",{id:n,className:"v10-pca-track-panel",children:[e.jsx("input",{type:"text",className:"v10-form-input","data-testid":"pca-track-input",value:l,onChange:o=>h(o.target.value),placeholder:"Account id (e.g. 7)","aria-label":"Account id to track",onKeyDown:o=>{o.key==="Enter"&&p()}}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary","data-testid":"pca-track-submit",onClick:p,children:"Track"}),d&&e.jsx("p",{className:"v10-pca-crux-error",role:"alert",children:d})]})]})}const ta="https://docs.origintrail.io/";function la(){const{status:t,recheck:s}=Ve();return e.jsx("div",{"data-testid":"pca-view",children:t==="loading"?e.jsx("div",{className:"lazy-spinner",children:"Loading publisher conviction..."}):t==="unavailable"?e.jsx("div",{className:"v10-pca-unavailable","data-testid":"pca-unavailable",children:e.jsx($e,{tone:"neutral",title:"Publisher conviction isn't available on this network",description:"This deployment's chain adapter doesn't support Publisher Conviction Accounts yet.",actions:[{label:"Recheck",onClick:s,variant:"primary",testId:"pca-recheck-btn"},{label:"Learn more",onClick:()=>window.open(ta,"_blank","noopener")}]})}):e.jsx(Xe,{})})}export{la as PublishingConvictionPage};
|
|
1
|
+
import{bd as i,a7 as ie,aI as de,bK as _,bz as ee,ai as pe,b5 as ue,a3 as ge,aJ as xe,bO as D,aO as e,ar as be,aq as ne,aw as fe,aZ as Ce,aM as je,ao as Ne,ap as ye,w as ke,B as Ae,bw as Pe,bM as Ie,aN as Se,bI as Ee,aK as ce,N as X,aW as Te,b8 as Re}from"./index-DK8XzE3T.js";import{S as We,E as $e}from"./ContextGraphPrimitives-Dh-w2D_i.js";import{L as Oe,e as Y,Q as Me,P as ae}from"./browserWalletTransaction-BdmrJpK1.js";import{p as oe,H as Be,o as Fe,P as De,r as Ue,b as Le,C as Ge,a as _e}from"./ApproveWalletsModal-YFfDrGth.js";function Ke(){const[t,s]=i.useState("loading"),[c,l]=i.useState(0);return i.useEffect(()=>{let h=!0;return s("loading"),ie("0").then(()=>{h&&s("available")}).catch(d=>{h&&s(de(d)?"unavailable":"available")}),()=>{h=!1}},[c]),{status:t,recheck:()=>l(h=>h+1)}}function Ve(t){const{accountId:s,relation:c,...l}=t;return l}function qe(t,s){return t===s?t:"both"}function Ye(){const t=_(n=>n.trackedIds),s=_(n=>n.trackAccount),{data:c,loading:l,refresh:h}=ee(async()=>{let n=!1;const p=await pe().catch(()=>(n=!0,null));typeof(p==null?void 0:p.error)=="string"&&p.error.length>0&&(n=!0);const o=(p==null?void 0:p.wallets)??[],v=(await Promise.all(o.map(async g=>{const N=await ue(g).catch(()=>(n=!0,null));return N!=null&&N.accountId?{accountId:N.accountId,wallet:g}:null}))).filter(g=>g!=null);let u=[],C=!1;try{u=(await ge({hydrate:!0})).accounts}catch(g){de(g)&&!xe(g)?u=[]:C=!0}return{agentPairs:v,mine:u,ownedError:C,agentError:n}},[],0),d=i.useMemo(()=>{const n=new Map;for(const p of(c==null?void 0:c.mine)??[])n.set(p.accountId,{accountId:p.accountId,relation:p.relation,basics:Ve(p)});for(const p of(c==null?void 0:c.agentPairs)??[]){const o=n.get(p.accountId);o?(o.relation=qe(o.relation,"agent"),o.agentWallet||(o.agentWallet=p.wallet)):n.set(p.accountId,{accountId:p.accountId,relation:"agent",agentWallet:p.wallet})}return[...n.values()]},[c]);i.useEffect(()=>{for(const n of d)(n.relation==="agent"||n.relation==="both")&&!t.includes(n.accountId)&&s(n.accountId)},[d,t,s]);const x=i.useMemo(()=>d.filter(n=>!t.includes(n.accountId)),[d,t]);return{discovered:d,untracked:x,ownedError:(c==null?void 0:c.ownedError)??!1,agentError:(c==null?void 0:c.agentError)??!1,loading:l,refresh:h}}function ze(){const t=D(n=>n.address),s=D(n=>n.bootstrap),[c,l]=i.useState({loading:!1,error:null,ids:[]}),[h,d]=i.useState(0);i.useEffect(()=>{let n=!1;async function p(o,v){var u;l(C=>({...C,loading:!0,error:null}));try{if(!((u=o.rpcUrls)!=null&&u.length))throw new Error("No PCA RPC endpoints were provided.");const C=Oe(o.chainId,o.rpcUrls),g=o.nft,N=v,T=await C.readContract({address:g,abi:oe,functionName:"balanceOf",args:[N]}),S=[],m=typeof T=="bigint"?T:BigInt(String(T));for(let y=0n;y<m;y+=1n){const k=await C.readContract({address:g,abi:oe,functionName:"tokenOfOwnerByIndex",args:[N,y]});S.push((typeof k=="bigint"?k:BigInt(String(k))).toString())}if(n)return;l({loading:!1,error:null,ids:S})}catch(C){if(n)return;l({loading:!1,error:(C==null?void 0:C.message)??"Could not read connected-wallet PCAs.",ids:[]})}}return!t||!s?(l({loading:!1,error:null,ids:[]}),()=>{n=!0}):(p(s,t),()=>{n=!0})},[t,s,h]);const x=i.useCallback(()=>d(n=>n+1),[]);return{ids:c.ids,loading:c.loading,error:c.error,refresh:x}}function re(t){if(typeof t!="number"||!Number.isFinite(t))return"—";const s=t/100;return`${s%1===0?s.toFixed(0):s.toFixed(1)}%`}function te({account:t,blockExplorerUrl:s,nowSec:c,onManage:l,onApproveWallets:h,onUseForPublishing:d,onRemove:x,onRetry:n,onSwitchNetwork:p,view:o}){const{accountId:v,snapshot:u,notFound:C,classification:g,ownerIsPrimaryWallet:N}=t;if(C)return e.jsx("div",{className:"card v10-pca-card","data-state":"not-found","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body v10-pca-card-error",children:[e.jsxs("p",{children:["PCA #",v," no longer exists on-chain."]}),x&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>x(v),children:"Remove from tracked"})]})});if(!u)return e.jsx("div",{className:"card v10-pca-card","data-state":"error","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body v10-pca-card-error",children:[e.jsxs("p",{children:["Couldn’t load PCA #",v,"."]}),n&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>n(v),children:"Retry"})]})});const T=be(u.expiresAtTimestamp,c),S=s?`${s}/address/${u.owner}`:void 0,m=t.ownerMode??(N?"daemon":"external"),y=m==="wallet"&&!!t.walletWrongNetwork,k=Fe(m,y),b=t.connectedWallet,R=m==="daemon"?void 0:m==="wallet"?y?"Wrong network - switch the connected wallet to this node's PCA network.":"Connected wallet will sign this owner action.":b?`Connected as ${b}; switch to ${u.owner} to manage PCA #${v}.`:`Connect owner wallet ${u.owner} to manage PCA #${v}.`,W=e.jsxs("div",{className:"v10-pca-card-title",children:[e.jsxs("span",{className:"v10-pca-card-id",children:["PCA #",v]}),e.jsxs("span",{className:"badge badge-info v10-pca-card-discount",children:["◉ ",re(u.discountBps)," discount"]}),m==="wallet"&&e.jsx("span",{className:"badge badge-info",children:"✎ wallet-managed"}),m==="external"&&e.jsx("span",{className:"badge badge-warn",children:"tracked external"}),e.jsx("span",{className:"v10-pca-card-spacer"}),t.health&&e.jsx(Be,{state:t.health})]}),A=e.jsxs("div",{className:"v10-pca-card-owner",children:[e.jsx("span",{className:"v10-pca-card-owner-lbl",children:"Owner"}),e.jsx(Y,{address:u.owner,trailing:S?e.jsx("a",{className:"v10-pca-card-explorer",href:S,target:"_blank",rel:"noreferrer","aria-label":`View owner ${u.owner} on the block explorer`,children:"↗"}):void 0})]}),L=m==="daemon"?"Daemon-managed: owner actions use this node’s primary operational wallet.":m==="wallet"?"Wallet-managed: owner actions are signed by the connected wallet.":b?`Read-only here: connected as ${b}; switch to the owner wallet to manage.`:"Read-only here: connect the owner wallet to manage this PCA.";if(o==="coverage"?!1:o==="owner"?!0:g==="owned"||m==="wallet"||m==="external"&&t.approvedCount===0){const V=t.approvedCount>0,$=t.probesInconclusive;return e.jsx("div",{className:"card v10-pca-card","data-state":"owned","data-owner-mode":m,"data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body",children:[W,e.jsx(We,{items:[{id:"committed",label:"Committed",value:`${ne(u.committedTRACTrac)} TRAC`},{id:"buffer",label:"Top-up buffer",value:`${ne(u.topUpBufferTrac)} TRAC`},{id:"per-epoch",label:"Per-epoch allowance",value:`${fe(u.baseEpochAllowance)} TRAC`},{id:"wallets",label:"Publishing wallets",value:`${u.agentCount} / 100`}]}),A,m==="daemon"?e.jsxs("p",{className:"v10-pca-card-owner-note",children:["This is the node’s operational wallet — who ",e.jsx("strong",{children:"signs"}),", not who’s covered."]}):e.jsx("p",{className:"v10-pca-card-owner-note",children:L}),y&&e.jsxs("p",{className:"v10-pca-card-warn",role:"alert",children:["Wrong network. Reads still work, but wallet-owner writes are disabled until the wallet is switched."," ",p&&e.jsx("button",{type:"button",className:"v10-pca-inline-btn",onClick:p,children:"Switch network"})]}),m==="external"&&e.jsx("p",{className:"v10-pca-card-warn",children:b?`Connected as ${b} - switch to ${u.owner} to manage PCA #${v}.`:`Connect ${u.owner} to manage PCA #${v}.`}),$?e.jsx("p",{className:"v10-pca-card-warn",children:"⚠ Couldn’t verify which of this node’s wallets are approved — retry. Until then, whether this account discounts your publishes is unconfirmed."}):V?null:e.jsx("p",{className:"v10-pca-card-warn",children:"⚠ 0 of this node’s wallets are approved here — it discounts nothing yet. Approve this node’s operational wallets to start saving."}),e.jsxs("p",{className:"v10-pca-card-meta",children:[T,e.jsx("span",{className:"v10-pca-card-meta-sep",children:" · "}),e.jsxs("span",{title:`Expiry epoch ${u.expiresAtEpoch}`,children:["epoch ",u.expiresAtEpoch," ⓘ"]})]}),e.jsxs("div",{className:"v10-pca-card-actions",children:[l&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>l(v),children:m==="external"?"View details":"Manage"}),m==="external"?x&&e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>x(v),children:"Stop tracking"}):e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>h==null?void 0:h(v),disabled:!k||!h,title:R,children:"Approve wallets"})]})]})})}const U=t.walletCount>0&&t.approvedCount===t.walletCount,B=t.probesInconclusive;return e.jsx("div",{className:"card v10-pca-card","data-state":"approved","data-account":v,"data-testid":"pca-account-card",children:e.jsxs("div",{className:"card-body",children:[e.jsxs("div",{className:"v10-pca-card-title",children:[e.jsxs("span",{className:"v10-pca-card-id",children:["PCA #",v]}),e.jsx("span",{className:"v10-pca-card-sponsor",children:"(approved for this node)"}),e.jsxs("span",{className:"badge badge-info v10-pca-card-discount",children:["◉ ",re(u.discountBps)]}),e.jsx("span",{className:"v10-pca-card-spacer"}),B?e.jsx("span",{className:"badge badge-warn",children:"⚠ couldn’t verify approvals"}):!U&&t.walletCount>0?e.jsxs("span",{className:"badge badge-warn",children:["⚠ ",t.approvedCount," of ",t.walletCount," wallets approved"]}):null]}),A,e.jsxs("p",{className:"v10-pca-card-meta",children:[T,e.jsx("span",{className:"v10-pca-card-meta-sep",children:" · "}),e.jsxs("span",{title:`Expiry epoch ${u.expiresAtEpoch}`,children:["epoch ",u.expiresAtEpoch," ⓘ"]})]}),e.jsx("p",{className:"v10-pca-card-summary",children:B?"Approval coverage could not be fully verified.":`${t.approvedCount} of ${t.walletCount} node publishing wallet${t.walletCount===1?"":"s"} approved.`}),B?e.jsx("p",{className:"v10-pca-card-warn",children:"Couldn’t verify which wallets are approved — retry."}):!U&&t.walletCount>0?e.jsx("p",{className:"v10-pca-card-warn",children:"Publishes from the un-approved wallet(s) will quietly pay the direct cost."}):null,e.jsxs("div",{className:"v10-pca-card-actions",children:[l&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>l(v),children:"View details"}),d&&e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>d(v),children:"Use for publishing"})]})]})})}const He={84532:"https://www.alchemy.com/faucets/base-sepolia",11155111:"https://www.alchemy.com/faucets/ethereum-sepolia",10200:"https://faucet.chiadochain.net/"};function Je(t){if(t==null)return;const s=String(t),c=s.includes(":")?s.split(":").pop():s;return He[c]}function Qe(t){switch(t.outcome){case"covers":return{text:"approved",tone:"success"};case"uncovered":return{text:"approved, but that PCA is expired, swept, or out of budget - publishes will not get the discount",tone:"warn"};case"unregistered":return{text:"not approved - ask the PCA owner to approve it",tone:"danger"};case"inconclusive":return{text:"unknown",tone:"neutral"}}}function Ze({onClose:t}){const{data:s,loading:c,error:l,refresh:h}=ee(pe,[],0),d=(s==null?void 0:s.wallets)??[],x=(s==null?void 0:s.balances)??[],n=typeof(s==null?void 0:s.error)=="string"&&s.error.length>0?s.error:null,p=l||n,o=(s==null?void 0:s.chainId)??null,v=Ce(o),u=je(o)?Je(o):void 0,C=_(r=>r.trackAccount),{copied:g,copy:N}=Me(),T=d.join(","),{data:S}=ee(async()=>{const r=(s==null?void 0:s.wallets)??[];if(r.length===0)return[];const w=await Promise.all(r.map(j=>ue(j).then(f=>f.accountId).catch(()=>null)));return Array.from(new Set(w.filter(j=>j!=null)))},[T],0),[m,y]=i.useState(""),[k,b]=i.useState(!1),[R,W]=i.useState(null),[A,L]=i.useState(null),K=r=>{var w;return(w=x.find(j=>{var f;return((f=j.address)==null?void 0:f.toLowerCase())===r.toLowerCase()}))==null?void 0:w.eth},U=r=>{const w=K(r);return w!=null&&Number(w)>0},B=async()=>{var w;const r=m.trim();if(!/^\d+$/.test(r)){W("Enter the numeric PCA ID the owner gave you.");return}b(!0),W(null);try{const j=await Promise.all(d.map(f=>ie(r,f,{extended:!0}).then(O=>({wallet:f,coverage:ke(O)})).catch(()=>({wallet:f,coverage:{outcome:"inconclusive",registered:null,adapterUnsupported:!1}}))));if(j.length>0&&j.every(f=>f.coverage.outcome==="inconclusive")){const f=j.every(O=>O.coverage.outcome==="inconclusive"&&O.coverage.adapterUnsupported);W(f?"PCA approval isn’t verifiable on this chain’s adapter — not supported here. You can still publish without a discount.":`Couldn’t check approval on PCA #${r} right now — the chain lookup failed. Retry.`),L(null);return}j.some(f=>f.coverage.registered===!0)&&C(r),L({accountId:r,rows:j})}catch(j){W(((w=Ae(j,{accountId:r}))==null?void 0:w.message)??"Couldn’t check approval.")}finally{b(!1)}},V=(A==null?void 0:A.rows.filter(r=>r.coverage.registered===!0).length)??0,$=!!A&&A.rows.some(r=>r.coverage.outcome==="covers"&&U(r.wallet));return e.jsxs(De,{onClose:t,testId:"pca-get-sponsored",title:"Get added to a PCA",subtitle:"Share this node's operational publishing wallets with the PCA owner. They approve them; this node still pays its own gas.",children:[e.jsxs("div",{className:"v10-modal-body v10-pca-get-added-body",children:[e.jsxs("section",{className:"v10-pca-detail-section",children:[e.jsx("h3",{className:"v10-pca-detail-section-title",children:"Your operational wallets (signers / msg.sender)"}),e.jsx("div",{className:"v10-pca-detail-agentlist",children:c&&!s?e.jsx("p",{className:"v10-pca-handshake-empty",role:"status",children:"Loading your wallets…"}):p&&d.length===0?e.jsxs("p",{className:"v10-modal-error",role:"alert",children:["Couldn’t load your wallets."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>h(),children:"Retry"})]}):d.length===0?e.jsx("p",{className:"v10-pca-handshake-empty",children:"No operational wallets detected on this node."}):d.map(r=>{const w=K(r),j=U(r);return e.jsx(Y,{address:r,gas:w!=null?e.jsxs("span",{title:ye(w),children:["gas ",Ne(w)," ",v," ",j?"✓":"⚠ fund to publish"]}):void 0},r)})}),d.length>0&&e.jsx("button",{type:"button",className:"v10-pca-handshake-copyall",onClick:()=>N(d.join(`
|
|
2
|
+
`)),"aria-label":g?"Copied all wallets":"Copy all wallet addresses",children:g?"Copied":`Copy all ${d.length}`}),e.jsxs("p",{className:"v10-pca-detail-hint",children:["Share ",e.jsx("strong",{children:"all"})," wallets (the node rotates its signer per publish) or pin to one. Share the exact address - a typo can be approved by the PCA owner but never match your real signer."]})]}),e.jsxs("div",{className:"v10-modal-warning",children:["⚠ Gas is always on you. The PCA covers the TRAC publishing fee — never your gas. Fund each wallet with native ",v,".",u?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open faucet ↗"})," (testnet only)"]}):e.jsxs(e.Fragment,{children:[" ","Fund with native ",v," from your wallet."]})]}),e.jsxs("section",{className:"v10-pca-detail-section",children:[e.jsx("h3",{className:"v10-pca-detail-section-title",children:"Can't find it automatically?"}),e.jsx("p",{className:"v10-pca-detail-hint",children:"If the PCA owner gives you an account id, check it here to track whether this node's wallets are covered."}),S&&S.length>0&&e.jsxs("div",{className:"v10-pca-discovered-check",role:"status","data-testid":"pca-sponsor-discovered",children:["◉ We found your wallet(s) already approved on ",S.map(r=>`PCA #${r}`).join(", "),"."," ",e.jsxs("button",{type:"button",className:"v10-pca-card-btn compact",onClick:()=>y(S[0]),children:["Check PCA #",S[0]]})]}),e.jsxs("div",{className:"v10-pca-detail-form",children:[e.jsx("input",{className:"v10-form-input",type:"text",value:m,onChange:r=>y(r.target.value),placeholder:"PCA ID from owner (e.g. 7)","aria-label":"PCA ID from owner"}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:B,disabled:k,children:k?"Checking…":"Check approval"})]}),R&&e.jsx("p",{className:"v10-modal-error",role:"alert",children:R}),A&&e.jsxs("div",{className:"v10-pca-approve-results",role:"status","aria-live":"polite",children:[e.jsxs("p",{className:"v10-pca-approve-summary",children:["Approved on PCA #",A.accountId,": ",V," of ",A.rows.length," wallets ✓"]}),A.rows.map(r=>{const w=Qe(r.coverage);return e.jsx(Y,{address:r.wallet,status:w.text,statusTone:w.tone},r.wallet)})]})]}),$&&e.jsxs("div",{className:"v10-pca-create-success",role:"status",children:["Ready: at least 1 wallet is approved and gas-funded - this node can publish under PCA #",A.accountId,"."," ","Publish from any context graph — the discount applies automatically to your approved wallets."]})]}),e.jsx("div",{className:"v10-modal-footer",children:e.jsx("button",{type:"button",className:"v10-modal-btn",onClick:t,children:"Close"})})]})}function Xe(){const t=Pe(a=>a.nodeStatus),s=(t==null?void 0:t.nodeRole)==="core"||(t==null?void 0:t.nodeRole)==="edge"?t.nodeRole:void 0,c=(t==null?void 0:t.blockExplorerUrl)??null,l=Ie(a=>a.openTab),h=_(a=>a.trackAccount),d=_(a=>a.untrackAccount),x=_(a=>a.setScope),n=D(a=>a.setBootstrap),p=D(a=>a.initWallet);D(a=>a.bootstrap);const o=D(a=>a.address),v=D(a=>Se(a)),u=D(a=>a.switchToExpectedChain),[C,g]=i.useState({status:"idle",error:null}),N=ze(),[T,S]=i.useState(0),m=Ee(3e4,N.ids),{accounts:y,loading:k,refresh:b,walletsInconclusive:R}=m,W=m.wallets[0];i.useEffect(()=>{let a=!1;async function E(){g({status:"loading",error:null});try{const I=await Te();if(a)return;x(Re(I)),n(I),p(),g({status:"ready",error:null})}catch(I){if(a)return;g({status:"error",error:(I==null?void 0:I.message)??"Could not bootstrap wallet contract reads."}),p()}}return E(),()=>{a=!0}},[T,p,x,n]);const{untracked:A,ownedError:L,agentError:K,refresh:U}=Ye(),B=L||K,[V,$]=i.useState(!1),[r,w]=i.useState(null),[j,f]=i.useState(!1),[O,se]=i.useState(null),P=i.useMemo(()=>y.map(a=>{var I;const E=Ue({owner:(I=a.snapshot)==null?void 0:I.owner,primaryWallet:W,connectedWallet:o,walletWrongNetwork:v});return{...a,ownerMode:E.mode,primaryWallet:W,connectedWallet:o,walletWrongNetwork:E.mode==="wallet"&&E.wrongNetwork}}),[y,o,W,v]);i.useEffect(()=>{!O||k||P.some(a=>a.accountId===O)&&se(null)},[P,k,O]);const z=i.useMemo(()=>P.filter(a=>a.ownerMode==="daemon"),[P]),H=i.useMemo(()=>P.filter(a=>a.ownerMode==="wallet"),[P]),J=i.useMemo(()=>P.filter(a=>a.ownerMode==="external"&&a.snapshot&&a.approvedCount===0),[P]),Q=i.useMemo(()=>P.filter(a=>a.approvedCount>0||!a.snapshot&&!a.notFound),[P]),G=a=>l({id:`conviction:${a}`,label:`PCA #${a}`,closable:!0}),he=i.useMemo(()=>[...z,...H],[z,H]),Z=i.useMemo(()=>m.wallets.map(a=>{const E=P.find(M=>M.snapshot&&ce(M.snapshot)&&M.walletProbes.some(F=>X(F.wallet,a)&&F.registered===!0));if(E!=null&&E.snapshot)return{wallet:a,status:`covered by PCA #${E.accountId}`,tone:"success"};const I=P.find(M=>M.snapshot&&!ce(M.snapshot)&&M.walletProbes.some(F=>X(F.wallet,a)&&F.registered===!0));return I!=null&&I.snapshot?{wallet:a,status:`approved on inactive PCA #${I.accountId}`,tone:"warn"}:R||P.some(M=>M.walletProbes.some(F=>X(F.wallet,a)&&F.registered==null))?{wallet:a,status:"unknown - retry wallet/PCA read",tone:"warn"}:k&&y.length===0?{wallet:a,status:"checking",tone:"neutral"}:{wallet:a,status:"direct cost",tone:"danger"}}),[y.length,P,k,m.wallets,R]),ve=Z.some(a=>a.tone==="success"),me=i.useCallback(()=>S(a=>a+1),[]),q=i.useCallback(()=>{u()},[u]),we=i.useCallback(a=>{se(a),h(a)},[h]);return e.jsxs("div",{className:"v10-pca-overview","data-testid":"pca-landing",children:[e.jsxs("header",{className:"v10-pca-overview-head",children:[e.jsxs("div",{className:"v10-pca-overview-titlerow",children:[e.jsx("h2",{className:"v10-pca-overview-title",children:"Publisher Conviction"}),s&&e.jsxs("span",{className:"badge v10-pca-role-chip",children:["Node role: ",s]})]}),e.jsx("p",{className:"v10-pca-overview-explainer",children:s==="edge"?"Publisher Conviction Accounts let publishers dedicate TRAC spend in advance and receive a publishing discount by tier: 0%, 10%, 20%, 30%, 40%, 50%, or 75%, based on the committed amount. Nodes can create their own PCA or get added to an existing PCA by sharing operational publishing wallets with the PCA owner. You still pay gas; the PCA covers only the TRAC publishing fee for approved wallets.":"A Publisher Conviction Account (PCA) lets you lock TRAC up front and approve publishing wallets to publish at a discount. The discount applies to the wallet that signs the publish (on-chain msg.sender), not a peerId, admin wallet, or author identity."})]}),e.jsxs("section",{className:"v10-pca-section v10-pca-coverage-summary","data-testid":"pca-coverage-summary",children:[e.jsxs("div",{className:"v10-pca-section-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"v10-pca-section-title",children:"This node's publishing wallet coverage"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"The discount follows the operational wallet that signs a publish."})]}),e.jsxs("div",{className:"v10-pca-overview-cta-group",children:[e.jsx("button",{type:"button",className:"v10-pca-card-btn primary",onClick:()=>f(!0),children:"Get added to a PCA"}),e.jsx("button",{type:"button",className:"v10-pca-card-btn","data-testid":"pca-create-btn",onClick:()=>$(!0),children:"+ Create PCA"})]})]}),Z.length>0?e.jsx("div",{className:"v10-pca-wallet-list",children:Z.map(a=>e.jsx(Y,{address:a.wallet,status:a.status,statusTone:a.tone},a.wallet))}):R?e.jsxs("p",{className:"v10-pca-overview-caveat",role:"status",children:["Couldn't read this node's wallets, so coverage can't be confirmed."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>b(),children:"Retry"})]}):e.jsx("p",{className:"v10-pca-overview-caveat",children:"No operational publishing wallets were reported by this node."}),!ve&&!k&&!R&&!B&&e.jsx("p",{className:"v10-pca-inline-status",role:"status",children:"No PCA discount is active for this node yet. Publishes from direct-cost wallets use the signing wallet."}),!k&&Q.length>0&&e.jsxs("div",{className:"v10-pca-linked-pcas","data-testid":"pca-approved-section",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-account-group-title",children:"PCAs linked to this node"}),e.jsx("span",{className:"v10-pca-account-group-count",children:Q.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Account summaries for PCAs that approve at least one of this node's publishing wallets. Wallet coverage above is the source of truth for publish discounts."}),e.jsx("div",{className:"v10-pca-card-grid v10-pca-card-grid-compact",children:Q.map(a=>e.jsx(te,{account:a,view:"coverage",blockExplorerUrl:c,onManage:G,onApproveWallets:E=>w({accountId:E,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:q},`approved-${a.accountId}`))})]})]}),k&&y.length===0?e.jsxs("div",{className:"v10-pca-card-grid",children:[e.jsx("div",{className:"card v10-pca-card v10-pca-card-skeleton","aria-hidden":"true"}),e.jsx("div",{className:"card v10-pca-card v10-pca-card-skeleton","aria-hidden":"true"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"v10-pca-section","data-testid":"pca-owned-section",children:[e.jsxs("div",{className:"v10-pca-section-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"v10-pca-section-title",children:"Owned by me"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Connect an owner wallet to discover and manage wallet-owned PCAs. Node-owned PCAs use the daemon wallet."})]}),e.jsx("div",{className:"v10-pca-overview-cta-group",children:e.jsx("button",{type:"button",className:"v10-pca-card-btn","data-testid":"pca-create-owned-btn",onClick:()=>$(!0),children:"+ Create PCA"})})]}),e.jsx("div",{className:"v10-pca-overview-wallet",children:e.jsx(Le,{className:"compact",testId:"pca-wallet-connect"})}),he.length>0?e.jsxs("div",{className:"v10-pca-owned-groups",children:[e.jsx(le,{title:"This node (hot wallet)",description:"Daemon-owned PCAs. Owner writes use the node daemon.",accounts:z,blockExplorerUrl:c,onManage:G,onApproveWallets:a=>w({accountId:a,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:q}),e.jsx(le,{title:o?`${ae(o)} (connected)`:"Connected wallet",description:"Wallet-managed PCAs. Owner writes are signed by the connected wallet.",accounts:H,blockExplorerUrl:c,onManage:G,onApproveWallets:a=>w({accountId:a,mode:"sponsor"}),onRemove:d,onRetry:()=>b(),onSwitchNetwork:q})]}):R?null:e.jsx("p",{className:"v10-pca-inline-status",children:"No owned PCAs are tracked yet."})]}),e.jsxs("section",{className:"v10-pca-section","data-testid":"pca-tracked-external-section",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-section-title",children:"Tracked external accounts"}),e.jsx("span",{className:"v10-pca-account-group-count",children:J.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Read-only PCA records you track manually. Connect the owner wallet to manage one."}),J.length>0?e.jsx("div",{className:"v10-pca-card-grid",children:J.map(a=>e.jsx(te,{account:a,view:"owner",blockExplorerUrl:c,onManage:G,onRemove:d,onRetry:()=>b(),onSwitchNetwork:q},`external-${a.accountId}`))}):e.jsx("p",{className:"v10-pca-inline-status",children:"No external PCAs are tracked manually."}),e.jsx(aa,{onTrack:we})]})]}),O&&e.jsxs("p",{className:"v10-pca-track-status",role:"status","data-testid":"pca-track-status",children:["Checking PCA #",O,". It will appear here when the chain read returns."]}),B&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-discovered-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Couldn't verify this node's Publisher Conviction Accounts; approved PCA coverage may still exist."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>U(),children:"Retry"})]})}),C.status==="error"&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-wallet-bootstrap-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Note: Couldn't load wallet contract bootstrap, so connected-wallet PCA discovery is paused."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:me,children:"Retry"})]})}),N.error&&e.jsx("section",{className:"v10-pca-discovered","data-testid":"pca-wallet-discovery-error",role:"status",children:e.jsxs("p",{className:"v10-pca-overview-caveat",children:["Note: Couldn't read PCAs owned by the connected wallet. Existing tracked PCAs are still shown."," ",e.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:N.refresh,children:"Retry"})]})}),N.loading&&o&&e.jsxs("p",{className:"v10-pca-overview-caveat",role:"status",children:["Reading PCAs owned by ",ae(o),"..."]}),e.jsx(ea,{items:A,onTrack:h,onManage:G}),V&&e.jsx(Ge,{onClose:()=>{$(!1),b()},onApproveOwnWallets:a=>{$(!1),w({accountId:a,mode:"self",selfCoverage:!0})},onManage:a=>{$(!1),G(a)},onGetSponsored:()=>{$(!1),f(!0)}}),r&&e.jsx(_e,{accountId:r.accountId,initialMode:r.mode,selfCoverage:r.selfCoverage,onClose:()=>{w(null),b()}}),j&&e.jsx(Ze,{onClose:()=>{f(!1),b()}})]})}function ea({items:t,onTrack:s,onManage:c}){return t.length===0?null:e.jsxs("section",{className:"v10-pca-discovered","data-testid":"pca-discovered-strip",children:[e.jsx("h3",{className:"v10-pca-discovered-title",children:"Discovered - not tracked here"}),e.jsx("p",{className:"v10-pca-overview-caveat",children:"Found on-chain for this node's wallets or the connected wallet. Track to show them in the grid above."}),t.map(l=>{var d;const h=(d=l.basics)==null?void 0:d.discountBps;return e.jsxs("div",{className:"v10-pca-discovered-row","data-testid":"pca-discovered-row",children:[e.jsxs("span",{className:"v10-pca-discovered-label",children:[e.jsxs("button",{type:"button",className:"v10-notif-cg-link",onClick:()=>c(l.accountId),children:["PCA #",l.accountId]})," ","-"," ",l.relation==="agent"?`your wallet ${l.agentWallet?ae(l.agentWallet):""} is approved here`:l.relation==="both"?"you own this; your wallet is approved here":"you own this account",(l.relation==="agent"||l.relation==="both")&&typeof h=="number"&&h>0&&e.jsxs("span",{className:"badge badge-info",children:[" ",(h/100).toFixed(h%100===0?0:1),"%"]})]}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary","data-testid":"pca-discovered-track",onClick:()=>s(l.accountId),children:"Track"})]},l.accountId)})]})}function le({title:t,description:s,accounts:c,blockExplorerUrl:l,onManage:h,onApproveWallets:d,onRemove:x,onRetry:n,onSwitchNetwork:p}){return c.length===0?null:e.jsxs("section",{className:"v10-pca-account-group",children:[e.jsxs("div",{className:"v10-pca-account-group-head",children:[e.jsx("h3",{className:"v10-pca-account-group-title",children:t}),e.jsx("span",{className:"v10-pca-account-group-count",children:c.length})]}),e.jsx("p",{className:"v10-pca-overview-caveat",children:s}),e.jsx("div",{className:"v10-pca-card-grid",children:c.map(o=>e.jsx(te,{account:o,view:"owner",blockExplorerUrl:l,onManage:h,onApproveWallets:d,onRemove:x,onRetry:n,onSwitchNetwork:p},o.accountId))})]})}function aa({onTrack:t}){const[s,c]=i.useState(!1),[l,h]=i.useState(""),[d,x]=i.useState(null),n=i.useId(),p=()=>{const o=l.trim();if(!/^\d+$/.test(o)){x("Enter a numeric account id.");return}t(o),h(""),x(null),c(!1)};return e.jsxs("div",{className:"v10-pca-track",children:[e.jsx("button",{type:"button",className:"v10-pca-track-toggle","data-testid":"pca-track-toggle","aria-expanded":s,"aria-controls":n,onClick:()=>c(o=>!o),children:"Track PCA by ID"}),s&&e.jsxs("div",{id:n,className:"v10-pca-track-panel",children:[e.jsx("input",{type:"text",className:"v10-form-input","data-testid":"pca-track-input",value:l,onChange:o=>h(o.target.value),placeholder:"Account id (e.g. 7)","aria-label":"Account id to track",onKeyDown:o=>{o.key==="Enter"&&p()}}),e.jsx("button",{type:"button",className:"v10-pca-card-btn primary","data-testid":"pca-track-submit",onClick:p,children:"Track"}),d&&e.jsx("p",{className:"v10-pca-crux-error",role:"alert",children:d})]})]})}const ta="https://docs.origintrail.io/";function la(){const{status:t,recheck:s}=Ke();return e.jsx("div",{"data-testid":"pca-view",children:t==="loading"?e.jsx("div",{className:"lazy-spinner",children:"Loading publisher conviction..."}):t==="unavailable"?e.jsx("div",{className:"v10-pca-unavailable","data-testid":"pca-unavailable",children:e.jsx($e,{tone:"neutral",title:"Publisher conviction isn't available on this network",description:"This deployment's chain adapter doesn't support Publisher Conviction Accounts yet.",actions:[{label:"Recheck",onClick:s,variant:"primary",testId:"pca-recheck-btn"},{label:"Learn more",onClick:()=>window.open(ta,"_blank","noopener")}]})}):e.jsx(Xe,{})})}export{la as PublishingConvictionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ye=Object.defineProperty;var fe=(t,e,n)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var K=(t,e,n)=>fe(t,typeof e!="symbol"?e+"":e,n);import{ax as oe,H as le,bI as ge,bL as be,bH as ve,aO as a,N as R,bN as Q,b1 as xe,bc as y,by as E,af as we,ai as je,bk as Ne,ao as ke,ap as Se,ah as Ce,R as G,bt as X,a1 as Te,ae as Ie,bs as ee,am as Ae}from"./index-CT-LdpBE.js";import{e as Re,A as Ee,m as de,x as Pe,I as We,K as F,M as Le,h as Oe,v as $e,J as ze,j as _e,a as Be,g as Me,U as He,i as Ue,D as De,R as te,E as Ke,O as Fe,L as qe,t as Ye,o as Ve,d as ne,f as Qe,b as Ge,W as Ze}from"./browserWalletTransaction-B6wyaMOV.js";const Je="IDENTITY_WALLET_MANAGEMENT_UNAVAILABLE",Xe="OPERATIONAL_WALLET_MANAGEMENT_UNAVAILABLE";class U extends Error{constructor(n,i){super(`${i} from ${n}`);K(this,"code","IDENTITY_WALLET_API_DECODE_ERROR");K(this,"endpoint");this.name="IdentityWalletApiDecodeError",this.endpoint=n,Object.setPrototypeOf(this,U.prototype)}}function et(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.address=="string"&&typeof e.isAdmin=="boolean"&&typeof e.isPrimary=="boolean"&&(typeof e.registered=="boolean"||e.registered===null)}function tt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.identityId=="string"&&typeof e.hasProfile=="boolean"&&typeof e.adminKeyConfigured=="boolean"&&typeof e.canManage=="boolean"&&Array.isArray(e.wallets)&&e.wallets.every(et)}const nt=async()=>{var e;const t="/api/operational-wallets";try{const n=await oe(t);if(!tt(n))throw new U(t,"Invalid operational-wallet snapshot");return{available:!0,snapshot:n}}catch(n){if(n instanceof le&&n.status===503&&((e=n.body)==null?void 0:e.code)===Xe)return{available:!1};throw n}};function at(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t,n=typeof e.chainId=="number"&&Number.isFinite(e.chainId)||typeof e.chainId=="string"&&/(\d+)\s*$/.test(e.chainId);return typeof e.profile=="string"&&typeof e.identity=="string"&&typeof e.storage=="string"&&n&&Array.isArray(e.rpcUrls)&&e.rpcUrls.every(i=>typeof i=="string")&&(e.walletRpcUrls===void 0||Array.isArray(e.walletRpcUrls)&&e.walletRpcUrls.every(i=>typeof i=="string"))}const it=async()=>{var e;const t="/api/identity-wallets/contracts";try{const n=await oe(t);if(!at(n))throw new U(t,"Invalid identity-wallet contracts response");return n}catch(n){if(n instanceof le&&n.status===503&&((e=n.body)==null?void 0:e.code)===Je)return null;throw n}};function rt(t,e){const n=(t??"").trim();if(!n)return"TRAC";const i=(e??"").includes(":")?(e??"").split(":")[1]:e??"";return i==="84532"||i==="11155111"||i==="31337"||i==="10200"||i==="20430"?/test/i.test(n)?n:`${n} (testnet)`:n}function ce(t,e=2){if(t==null)return"—";let n;if(typeof t=="number")n=t;else{const i=String(t).trim();if(!/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(i))return"—";n=Number(i)}return Number.isFinite(n)?n.toFixed(e):"—"}function st(t){if(ce(t)!=="—")return`Exact: ${t}`}const q="************",ot=/[A-Za-z0-9_-]{16,}/g;function lt(t){if(!t)return"";let e;try{e=new URL(t)}catch{return t.replace(ot,q)}(e.username||e.password)&&(e.username="",e.password="");const n=e.pathname.split("/").map(i=>i.length<16?i:/^[A-Za-z0-9_-]+$/.test(i)?q:i);if(e.pathname=n.join("/"),e.search){const i=new URLSearchParams(e.search);for(const s of Array.from(i.keys()))/key|token|secret|auth/i.test(s)&&i.set(s,q);e.search=i.toString()}return e.toString()}function dt(t){if(t==null)return"—";const e=t/100;return`${e%1===0?e.toFixed(0):e.toFixed(1)}%`}function ct(){ge();const t=be(l=>l.openTab),{accounts:e,covered:n,bestCoveringDiscountBps:i,walletsInconclusive:s}=ve(),r=e.length;return a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Publisher Conviction"})}),a.jsxs("div",{className:"card-body",children:[r===0?a.jsx("p",{className:"v10-pca-settings-line",children:"No tracked Publisher Conviction Account on this node."}):n?a.jsxs("p",{className:"v10-pca-settings-line",children:["This node’s approved publishing wallets use a ",a.jsx("strong",{children:dt(i)})," discount."]}):s?a.jsx("p",{className:"v10-pca-settings-line",role:"status",children:"Couldn’t verify this node’s wallets — retry."}):a.jsxs("p",{className:"v10-pca-settings-line",children:["Tracking ",r," account",r===1?"":"s",", but none currently covers this node’s publishes."]}),a.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>t({id:"conviction",label:"Publisher Conviction",closable:!0}),children:"Manage publisher conviction ->"})]})]})}function ut({wallets:t,summary:e,writesEnabled:n,onRemove:i}){return t.length===0?null:a.jsxs("div",{className:"v10-identity-wallet-known",children:[a.jsx("p",{className:"v10-identity-wallet-subtitle",children:"Wallets known to this node"}),a.jsx("div",{className:"v10-identity-wallet-list",children:t.map(s=>{const r=e==null?void 0:e.addresses.find(o=>R(o.address,s.address)),l=[s.isPrimary?"primary":null,(r==null?void 0:r.operational)===!0||s.registered===!0?"operational":null,(r==null?void 0:r.admin)===!0?"admin":null,s.registered===null?"chain status unknown":null].filter(Boolean).join(" · ")||"not registered";return a.jsx(Re,{address:s.address,status:l,statusTone:s.registered===null?"warn":r!=null&&r.operational||r!=null&&r.admin?"success":"danger",trailing:a.jsxs("span",{className:"v10-identity-wallet-row-actions",children:[((r==null?void 0:r.operational)===!0||s.registered===!0)&&a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact","data-testid":`remove-operational-${s.address}`,onClick:()=>i("operational",s.address),disabled:!n||s.isPrimary,title:s.isPrimary?"The primary operational wallet cannot be removed.":void 0,children:"Remove operational"}),(r==null?void 0:r.admin)===!0&&a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact","data-testid":`remove-admin-${s.address}`,onClick:()=>i("admin",s.address),disabled:!n||((e==null?void 0:e.adminCount)??0)<=1,title:((e==null?void 0:e.adminCount)??0)<=1?"Add a replacement admin before removing the final admin key.":void 0,children:"Remove admin"})]})},s.address)})})]})}const mt={operational:{title:"Operational keys",label:"Operational wallet address",description:"These wallets sign publishes. Registering an address does not copy its private key into this node; it must already be present in the node's operational wallet pool to participate in rotation.",addAction:"add-operational",removeAction:"remove-operational",addLabel:"Register operational",removeLabel:"Remove operational"},admin:{title:"Admin keys",label:"Admin wallet address",description:"Admin addresses are stored on-chain as hashes, so they cannot be enumerated back into addresses. Enter the exact address when rotating an old key. The contract never allows the final admin key to be removed.",addAction:"add-admin",removeAction:"remove-admin",addLabel:"Register admin",removeLabel:"Remove admin"}};function ae({role:t,value:e,writesEnabled:n,finalAdmin:i,onChange:s,onSubmit:r,onRemove:l}){const o=mt[t],d=`identity-${t}-address`,u=!e.trim();return a.jsxs("div",{className:"v10-identity-wallet-card","data-testid":`${t}-wallet-editor`,children:[a.jsx("h4",{children:o.title}),a.jsx("p",{children:o.description}),a.jsx("label",{htmlFor:d,children:o.label}),a.jsx("input",{id:d,className:"v10-form-input mono",value:e,onChange:g=>s(g.target.value),placeholder:"0x…",autoComplete:"off",spellCheck:!1}),a.jsxs("div",{className:"v10-identity-wallet-actions",children:[a.jsx("button",{type:"button",className:"v10-identity-wallet-btn primary","data-testid":o.addAction,onClick:()=>r(o.addAction,e),disabled:!n||u,children:o.addLabel}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn","data-testid":o.removeAction,onClick:()=>l(t,e),disabled:!n||u||!!i,children:o.removeLabel})]})]})}function ht(t,e){if(t.length!==e.length)throw new Ee({expectedLength:t.length,givenLength:e.length});const n=[];for(let i=0;i<t.length;i++){const s=t[i],r=e[i];n.push(ue(s,r))}return de(n)}function ue(t,e,n=!1){if(t==="address"){const l=e;if(!Pe(l))throw new We({address:l});return F(l.toLowerCase(),{size:n?32:null})}if(t==="string")return Le(e);if(t==="bytes")return e;if(t==="bool")return F(Oe(e),{size:n?32:1});const i=t.match($e);if(i){const[l,o,d="256"]=i,u=Number.parseInt(d,10)/8;return ze(e,{size:n?32:u,signed:o==="int"})}const s=t.match(_e);if(s){const[l,o]=s;if(Number.parseInt(o,10)!==(e.length-2)/2)throw new Be({expectedSize:Number.parseInt(o,10),givenSize:(e.length-2)/2});return F(e,{dir:"right",size:n?32:null})}const r=t.match(Me);if(r&&Array.isArray(e)){const[l,o]=r,d=[];for(let u=0;u<e.length;u++)d.push(ue(o,e[u],!0));return d.length===0?"0x":de(d)}throw new He(t)}const pt=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"address[]",name:"operationalWallets",type:"address[]"}],name:"addOperationalWallets",outputs:[],stateMutability:"nonpayable",type:"function"}],yt=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"key",type:"bytes32"},{internalType:"uint256",name:"keyPurpose",type:"uint256"},{internalType:"uint256",name:"keyType",type:"uint256"}],name:"addKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"key",type:"bytes32"}],name:"removeKey",outputs:[],stateMutability:"nonpayable",type:"function"}],ft=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"_key",type:"bytes32"},{internalType:"uint256",name:"_purpose",type:"uint256"}],name:"keyHasPurpose",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"uint256",name:"_purpose",type:"uint256"}],name:"getKeysByPurpose",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"}],A=1n,M=2n,gt=1n,bt=pt,Y=yt,me=ft,vt=(1n<<72n)-1n;class f extends Error{constructor(e){super(e),this.name="IdentityWalletActionError"}}function N(t,e){return Ue(t,e,n=>new f(n))}function P(t){const e=typeof t=="bigint"?t.toString():t.trim();if(!/^\d+$/.test(e))throw new f("Node identityId must be a non-negative integer.");const n=BigInt(e);if(n<=0n||n>vt)throw new f("Node identityId must be between 1 and the uint72 maximum.");return n}function L(t){const e=N(t,"Wallet address");return De(ht(["address"],[e]))}function he(t){return{profile:N(t.profile,"profile contract"),identity:N(t.identity,"identity contract"),storage:N(t.storage,"identityStorage contract")}}const pe={error:t=>new f(t),unavailableError:t=>new f(t),abortedError:t=>new f(t),messages:{disconnected:"Connect an existing admin wallet before signing.",wrongNetwork:"Switch the connected wallet to this node's network.",providerChanged:"Wallet provider changed before the signature prompt. Reconnect and retry.",addressChanged:"Connected wallet changed before the signature prompt. Reconnect the admin wallet.",networkChanged:"Wallet network changed before the signature prompt. Switch back and retry.",accountChanged:"Wallet account changed before the signature prompt. Reconnect the admin wallet."}};function _(t){if(!t.bootstrap)throw new f("This node does not expose identity-wallet contracts yet. Upgrade the daemon and reload the page.");const e=t.getWalletState??(()=>{const{provider:r,address:l,chainId:o}=Q.getState();return{provider:r,address:l,chainId:o}}),n={bootstrap:t.bootstrap,getWalletState:e,...t.publicClientFor?{publicClientFor:t.publicClientFor}:{},...t.walletClientFromProvider?{walletClientFromProvider:t.walletClientFromProvider}:{}},i=Ke(n,pe),s=he(t.bootstrap);return{...i,runtimeDeps:n,signer:i.account,profile:s.profile,identity:s.identity,identityStorage:s.storage}}async function W(t,e,n,i,s){return!!await t.readContract({address:e,abi:me,functionName:"keyHasPurpose",args:[n,L(i),s]})}async function O(t,e,n,i){return await t.readContract({address:e,abi:me,functionName:"getKeysByPurpose",args:[n,i]})}function $(t){return new Set(t.map(e=>e.toLowerCase()))}function z(t,e){return t.has(L(e).toLowerCase())}async function xt(t,e,n,i){const s=P(n),r=he(t).storage,l=[...new Map(i.map(h=>{const b=N(h,"Wallet address");return[b.toLowerCase(),b]})).values()],[o,d]=await Promise.all([O(e,r,s,A),O(e,r,s,M)]),u=$(o),g=$(d);return{adminCount:o.length,operationalCount:d.length,addresses:l.map(h=>({address:h,admin:z(u,h),operational:z(g,h)}))}}async function ie(t,e){if(!await W(t.publicClient,t.identityStorage,e,t.signer,A))throw new f(`Connected wallet ${t.signer} is not an admin key for identity ${e}. Connect an existing admin wallet.`)}function re(t,e,n){if(!z(n,t.signer))throw new f(`Connected wallet ${t.signer} is not an admin key for identity ${e}. Connect an existing admin wallet.`)}function wt(t){return t.blockNumber==null?void 0:Number(t.blockNumber)}async function B(t,e,n,i,s){const{hash:r,receipt:l}=await Fe(t,t.runtimeDeps,pe,s,"action",{signing:()=>{var o;return(o=e.onProgress)==null?void 0:o.call(e,{action:n,state:"signing"})},submitted:o=>{var d;return(d=e.onProgress)==null?void 0:d.call(e,{action:n,state:"submitted",txHash:o})},confirmed:o=>{var d;return(d=e.onProgress)==null?void 0:d.call(e,{action:n,state:"confirmed",txHash:o})},failed:(o,d)=>{var u;return(u=e.onProgress)==null?void 0:u.call(e,{action:n,state:"failed",txHash:d,error:o})}});return{action:n,address:i,txHash:l.transactionHash??r,blockNumber:wt(l)}}function jt(t){return{async addOperational(e,n){const i=P(e),s=N(n,"Operational wallet");if(R(s,te))throw new f("Operational wallet cannot be the zero address.");const r=_(t);await ie(r,i);const[l,o]=await Promise.all([W(r.publicClient,r.identityStorage,i,s,M),W(r.publicClient,r.identityStorage,i,s,A)]);if(l)throw new f(`${s} is already an operational key.`);if(o)throw new f(`${s} is already an admin key and cannot also be operational.`);return B(r,t,"add-operational",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.profile,abi:bt,functionName:"addOperationalWallets",args:[i,[s]]}))},async removeOperational(e,n,i){const s=P(e),r=N(n,"Operational wallet");if(!i)throw new f("Primary operational wallet metadata is required before removing an operational key.");const l=N(i,"Primary operational wallet");if(R(r,l))throw new f("The primary operational wallet cannot be removed because it anchors this node's on-chain identity.");const o=_(t),[d,u]=await Promise.all([O(o.publicClient,o.identityStorage,s,A),O(o.publicClient,o.identityStorage,s,M)]);if(re(o,s,$(d)),!z($(u),r))throw new f(`${r} is not an operational key for identity ${s}.`);if(u.length<=1)throw new f("The final operational key cannot be removed.");return B(o,t,"remove-operational",r,g=>g.writeContract({account:o.account,chain:o.chain,address:o.identity,abi:Y,functionName:"removeKey",args:[s,L(r)]}))},async addAdmin(e,n){const i=P(e),s=N(n,"Admin wallet");if(R(s,te))throw new f("Admin wallet cannot be the zero address.");const r=_(t);await ie(r,i);const[l,o]=await Promise.all([W(r.publicClient,r.identityStorage,i,s,A),W(r.publicClient,r.identityStorage,i,s,M)]);if(l)throw new f(`${s} is already an admin key.`);if(o)throw new f(`${s} is already an operational key and cannot also be an admin.`);return B(r,t,"add-admin",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.identity,abi:Y,functionName:"addKey",args:[i,L(s),A,gt]}))},async removeAdmin(e,n){const i=P(e),s=N(n,"Admin wallet"),r=_(t),l=await O(r.publicClient,r.identityStorage,i,A),o=$(l);if(re(r,i,o),!z(o,s))throw new f(`${s} is not an admin key for identity ${i}.`);if(l.length<=1)throw new f("The final admin key cannot be removed. Add its replacement first.");return B(r,t,"remove-admin",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.identity,abi:Y,functionName:"removeKey",args:[i,L(s)]}))}}}const H={"add-operational":{role:"operational",verb:"add",label:"Operational wallet registered"},"remove-operational":{role:"operational",verb:"remove",label:"Operational wallet removed"},"add-admin":{role:"admin",verb:"add",label:"Admin wallet registered"},"remove-admin":{role:"admin",verb:"remove",label:"Admin wallet removed"}},Nt={inputs:{operational:"",admin:""},removal:null,transaction:{status:"idle"}};function kt(t,e){switch(e.type){case"input":return{...t,inputs:{...t.inputs,[e.role]:e.value}};case"request-removal":return{...t,removal:e.removal,transaction:{status:"idle"}};case"cancel-removal":return{...t,removal:null};case"signing":return{...t,transaction:{status:"signing",action:e.action,address:e.address}};case"submitted":return{...t,transaction:{status:"submitted",action:e.action,address:e.address,txHash:e.txHash}};case"succeeded":{const n=H[e.completed.action];return{...t,inputs:n.verb==="add"?{...t.inputs,[n.role]:""}:t.inputs,removal:null,transaction:{status:"succeeded",completed:e.completed}}}case"failed":return{...t,transaction:{status:"failed",message:e.message,completed:e.completed}}}}function se(t,e){try{return Ye(t.trim())}catch{throw new f(`${e} must be a valid EVM address.`)}}function V(t){if(t instanceof f)return t.message;const e=Ve(t,"action");return e.kind==="rejected"?"You rejected the transaction. No identity key was changed.":e.message}function St(t){if(t instanceof ne)return t.txHash;if(t instanceof Qe&&t.cause instanceof ne)return t.cause.txHash}async function Ct(t,e,n,i,s){const r=jt(t);switch(e){case"add-operational":return r.addOperational(n,i);case"remove-operational":return r.removeOperational(n,i,s);case"add-admin":return r.addAdmin(n,i);case"remove-admin":return r.removeAdmin(n,i)}}async function Tt(){const[t,e]=await Promise.all([nt(),it()]);return t.available?e?{status:"ready",snapshot:t.snapshot,bootstrap:e}:{status:"unavailable",reason:"identity-contracts",snapshot:t.snapshot}:{status:"unavailable",reason:"operational-wallets",snapshot:null}}function It(){const t=E(Tt,[],0);return{state:y.useMemo(()=>t.error?{status:"error",message:t.error}:t.data??{status:"loading"},[t.data,t.error]),refresh:t.refresh}}function At({data:t,bootstrap:e,primaryAddress:n,refreshQuery:i,reloadSummary:s}){const[r,l]=y.useReducer(kt,Nt),o=r.transaction.status==="signing"||r.transaction.status==="submitted",d=y.useCallback(async(h,b)=>{let m;try{m=se(b,H[h].role==="admin"?"Admin wallet":"Operational wallet")}catch(p){l({type:"failed",message:V(p)});return}if(!(t!=null&&t.hasProfile)){l({type:"failed",message:"This node does not have an on-chain identity profile."});return}if(!e){l({type:"failed",message:"This node does not expose identity-wallet contracts yet. Upgrade the daemon and reload the page."});return}l({type:"signing",action:h,address:m});try{const p=await Ct({bootstrap:e,onProgress:v=>{v.state==="submitted"&&v.txHash?l({type:"submitted",action:h,address:m,txHash:v.txHash}):v.state==="signing"&&l({type:"signing",action:h,address:m})}},h,t.identityId,m,n);l({type:"succeeded",completed:{action:h,address:p.address,txHash:p.txHash,confirmed:!0}}),i(),s()}catch(p){const v=St(p);l({type:"failed",message:V(p),completed:v?{action:h,address:m,txHash:v,confirmed:!1}:void 0})}},[e,t==null?void 0:t.hasProfile,t==null?void 0:t.identityId,n,i,s]),u=y.useCallback((h,b)=>{try{const m=se(b,h==="admin"?"Admin wallet":"Operational wallet");if(h==="operational"&&n&&R(m,n))throw new f("The primary operational wallet cannot be removed because it anchors this node's on-chain identity.");l({type:"request-removal",removal:{role:h,address:m}})}catch(m){l({type:"failed",message:V(m)})}},[n]),g=y.useCallback(()=>{r.removal&&d(r.removal.role==="admin"?"remove-admin":"remove-operational",r.removal.address)},[r.removal,d]);return{inputs:r.inputs,setInput:(h,b)=>l({type:"input",role:h,value:b}),removal:r.removal,requestRemoval:u,cancelRemoval:()=>l({type:"cancel-removal"}),confirmRemoval:g,submit:d,transaction:r.transaction,transactionPending:o}}function Rt(){var k;const t=It(),e=t.state.status==="ready"||t.state.status==="unavailable"?t.state.snapshot:null,n=t.state.status==="ready"?t.state.bootstrap:null,i=Q(c=>c.address),s=Q(c=>c.chainId),r=!!(n&&s!==xe(n.chainId)),[l,o]=y.useState({status:"idle"}),[d,u]=y.useReducer(c=>c+1,0),g=y.useMemo(()=>{const c=[...(e==null?void 0:e.wallets.map(T=>T.address))??[]];return i&&c.push(i),c},[i,e]),h=g.join("|").toLowerCase();y.useEffect(()=>{let c=!1;if(!(e!=null&&e.hasProfile)||!n){o({status:"idle"});return}o({status:"loading"});const T=qe(n.chainId,n.rpcUrls);return xt(n,T,e.identityId,g).then(x=>{c||o({status:"ready",value:x})}).catch(x=>{c||o({status:"error",message:(x==null?void 0:x.message)??"Could not read identity keys from chain."})}),()=>{c=!0}},[n,e==null?void 0:e.hasProfile,e==null?void 0:e.identityId,h,d]);const b=l.status==="ready"?l.value:null,m=b==null?void 0:b.addresses.find(c=>R(c.address,i)),p=(m==null?void 0:m.admin)===!0,v=((k=e==null?void 0:e.wallets.find(c=>c.isPrimary))==null?void 0:k.address)??null,j=At({data:e,bootstrap:n,primaryAddress:v,refreshQuery:t.refresh,reloadSummary:u}),w=!!(t.state.status==="ready"&&(e!=null&&e.hasProfile)&&i&&p&&!r&&!j.transactionPending);return{query:t.state,refreshQuery:t.refresh,connected:i,wrongNetwork:r,summary:l,reloadSummary:u,connectedIsAdmin:p,writesEnabled:w,...j}}function Et({blockExplorerUrl:t}){const e=Rt(),{query:n,refreshQuery:i,connected:s,wrongNetwork:r,summary:l,reloadSummary:o,connectedIsAdmin:d,writesEnabled:u,inputs:g,setInput:h,removal:b,requestRemoval:m,cancelRemoval:p,confirmRemoval:v,submit:j,transaction:w,transactionPending:k}=e,c=n.status==="ready"||n.status==="unavailable"?n.snapshot:null,T=n.status==="ready"?n.bootstrap:null,x=l.status==="ready"?l.value:null,S=w.status==="succeeded"||w.status==="failed"?w.completed:void 0,Z=w.status==="failed"?w.message:null,J=S&&t?`${t.replace(/\/$/,"")}/tx/${S.txHash}`:null;return a.jsxs("section",{className:"card v10-identity-wallets","data-testid":"identity-wallets-section",children:[a.jsxs("div",{className:"card-header v10-identity-wallet-header",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"card-title",children:"Node Identity Wallets"}),a.jsxs("p",{className:"v10-identity-wallet-description",children:["Register and rotate operational or admin keys for node identity"," ",c!=null&&c.hasProfile?c.identityId:"—",". Every change is signed by the connected admin wallet; its private key never enters the node."]})]}),a.jsxs("div",{className:"v10-identity-wallet-counts","aria-label":"Identity wallet counts",children:[a.jsxs("span",{className:"badge badge-info",children:[(x==null?void 0:x.operationalCount)??"—"," operational"]}),a.jsxs("span",{className:"badge badge-info",children:[(x==null?void 0:x.adminCount)??"—"," admin"]})]})]}),a.jsxs("div",{className:"card-body",children:[a.jsxs("div",{className:"v10-identity-wallet-signer",children:[s?a.jsx(Ge,{bootstrap:T??void 0,className:"v10-identity-wallet-pill",testId:"identity-wallet-pill"}):a.jsx(Ze,{className:"compact v10-identity-wallet-connect",testId:"identity-wallet-connect"}),s&&l.status==="ready"&&a.jsx("span",{className:`badge ${d?"badge-success":"badge-warn"}`,children:d?"authorized admin signer":"not an admin for this identity"})]}),n.status==="loading"&&a.jsx("p",{className:"v10-identity-wallet-status",role:"status",children:"Loading node identity wallets…"}),n.status==="error"&&a.jsxs("p",{className:"v10-modal-warning",role:"alert",children:["Couldn't load identity wallet management: ",n.message,"."," ",a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact",onClick:i,children:"Retry"})]}),c&&!c.hasProfile&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"This node does not have an on-chain identity profile yet."}),n.status==="unavailable"&&n.reason==="operational-wallets"&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Identity wallet management requires a node version that exposes the operational-wallet snapshot."}),(c==null?void 0:c.hasProfile)&&n.status==="unavailable"&&n.reason==="identity-contracts"&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Identity wallet management requires a node version that exposes the Profile, Identity, and IdentityStorage addresses."}),r&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Switch the connected wallet to this node's network to manage identity keys."}),l.status==="error"&&a.jsxs("p",{className:"v10-modal-warning",role:"alert",children:["Couldn't verify identity keys: ",l.message," ",a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact",onClick:o,children:"Retry"})]}),a.jsx(ut,{wallets:(c==null?void 0:c.wallets)??[],summary:x,writesEnabled:u,onRemove:m}),a.jsxs("div",{className:"v10-identity-wallet-grid",children:[a.jsx(ae,{role:"operational",value:g.operational,writesEnabled:u,onChange:I=>h("operational",I),onSubmit:(I,D)=>void j(I,D),onRemove:m}),a.jsx(ae,{role:"admin",value:g.admin,writesEnabled:u,finalAdmin:((x==null?void 0:x.adminCount)??0)<=1,onChange:I=>h("admin",I),onSubmit:(I,D)=>void j(I,D),onRemove:m})]}),b&&a.jsxs("div",{className:"v10-modal-warning v10-identity-wallet-confirm",role:"alertdialog","aria-label":"Confirm key removal",children:[a.jsxs("span",{children:["Remove ",b.address," as an ",b.role," key from identity ",c==null?void 0:c.identityId,"? This takes effect on-chain immediately."]}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn",onClick:v,disabled:k,children:"Yes, remove"}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn",onClick:p,disabled:k,children:"Cancel"})]}),k&&a.jsx("p",{className:"v10-identity-wallet-status",role:"status",children:w.status==="submitted"?"Transaction submitted — waiting for on-chain confirmation…":"Confirm the identity-key transaction on your wallet device…"}),Z&&a.jsx("p",{className:"v10-modal-error",role:"alert",children:Z}),S&&a.jsxs("div",{className:"v10-identity-wallet-status",role:"status","data-testid":"identity-wallet-result",children:[S.confirmed?`✓ ${H[S.action].label}: ${S.address}. `:`Transaction broadcast for ${S.address}, but confirmation is unknown. Check it before retrying. `,J&&a.jsx("a",{href:J,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}),S.confirmed&&H[S.action].role==="operational"&&a.jsx("span",{children:" Restart the node before relying on the updated operational signer rotation."})]})]})]})}function C({label:t,value:e,mono:n=!1}){return a.jsxs("div",{style:{marginBottom:14},children:[a.jsx("div",{className:"settings-field-label",children:t}),a.jsx("div",{className:`settings-field-value${n?" mono":""}`,children:e})]})}function Pt({rpcUrl:t}){const[e,n]=y.useState(!1),i=e?t:lt(t);return a.jsxs("div",{style:{marginBottom:14},children:[a.jsxs("div",{className:"settings-field-label",style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{children:"RPC"}),a.jsx("button",{type:"button",onClick:()=>n(s=>!s),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":e?"Redact RPC URL":"Reveal RPC URL",title:e?"Hide the path-token (recommended for screen-shares)":"Show full URL — careful, may contain a tenant secret",children:e?"Redact":"Reveal"})]}),a.jsx("div",{className:"settings-field-value mono",style:{wordBreak:"break-all"},children:i})]})}function Wt(){const{data:t}=E(Ce,[],6e4),[e,n]=y.useState(!1),[i,s]=y.useState(!1),[r,l]=y.useState(null),[o,d]=y.useState(!1),u=G.useRef(null),g=G.useRef(null);y.useEffect(()=>{t!=null&&n(t.enabled)},[t]);const h=y.useCallback(()=>{i||(l(null),e?(n(!1),s(!0),X(!1).catch(()=>{n(!0),l("Couldn’t update telemetry — try again.")}).finally(()=>s(!1))):d(!0))},[e,i]),b=y.useCallback(async()=>{var m;d(!1),l(null),n(!0),s(!0);try{await X(!0)}catch{n(!1),l("Couldn’t update telemetry — try again.")}finally{s(!1),(m=g.current)==null||m.focus()}},[]);return y.useEffect(()=>{var v;if(!o)return;const m=(v=u.current)==null?void 0:v.querySelector("button");m==null||m.focus();const p=j=>{var w;j.key==="Escape"&&(d(!1),(w=g.current)==null||w.focus())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[o]),a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Network Telemetry"})}),a.jsxs("div",{className:"card-body",children:[a.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."}),a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"10px 0"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:12,fontWeight:600},children:"Share telemetry with the network"}),a.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."})]}),a.jsx("button",{ref:g,type:"button",role:"switch","aria-checked":e,"aria-busy":i,"aria-disabled":i,"aria-label":"Share telemetry with the network",onClick:h,style:{width:38,height:22,borderRadius:11,border:"none",flexShrink:0,background:e?"var(--green)":"var(--border)",transition:"background .2s",position:"relative",marginLeft:16,cursor:i?"wait":"pointer",opacity:i?.6:1},children:a.jsx("span",{style:{position:"absolute",top:3,left:e?19:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left .2s",display:"block"}})})]}),a.jsx("div",{"aria-live":"polite",children:r&&a.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:r})})]}),o&&a.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,.55)",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsxs("div",{ref:u,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:[a.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16},children:"Enable Telemetry Streaming?"}),a.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:"}),a.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 14px 18px",padding:0},children:[a.jsx("li",{children:"Operation logs (publish, query, sync, gossip events)"}),a.jsx("li",{children:"Performance metrics (durations, throughput, error rates)"}),a.jsx("li",{children:"Node identity (peer ID, node name, network)"})]}),a.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:["The following data is ",a.jsx("strong",{style:{color:"var(--text)"},children:"NEVER"})," shared via telemetry:"]}),a.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 16px 18px",padding:0},children:[a.jsx("li",{children:"Private keys or wallet credentials"}),a.jsx("li",{children:"Authentication tokens or API keys"}),a.jsx("li",{children:"Private triple content or personal data"}),a.jsx("li",{children:"File system paths or environment variables"})]}),a.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."}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[a.jsx("button",{type:"button",onClick:()=>{var m;d(!1),(m=g.current)==null||m.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"}),a.jsx("button",{type:"button",onClick:b,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 Lt(){const{data:t}=E(Te,[],3e4),{data:e}=E(Ie,[],6e4),[n,i]=y.useState(90),[s,r]=y.useState(!1),[l,o]=y.useState(null),[d,u]=y.useState(null),g=G.useRef(null);y.useEffect(()=>{e!=null&&e.retentionDays&&i(e.retentionDays)},[e]),y.useEffect(()=>{var p;d!=null&&((p=g.current)==null||p.focus())},[d]);const h=y.useCallback(async()=>{if(d==null)return;const p=d;r(!1),o(null),u(null);try{await ee(p),i(p),r(!0),setTimeout(()=>r(!1),2e3)}catch{o("Couldn’t save retention — try again.")}},[d]),b=y.useCallback(p=>{o(null),p<n?(r(!1),u(p)):(r(!1),u(null),ee(p).then(()=>{i(p),r(!0),setTimeout(()=>r(!1),2e3)}).catch(()=>o("Couldn’t save retention — try again.")))},[n]),m=(t==null?void 0:t.store_bytes)??null;return a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Local Data Retention"})}),a.jsxs("div",{className:"card-body",children:[a.jsx("label",{htmlFor:"retention-select",className:"settings-field-label",style:{display:"block",marginBottom:5},children:"Keep local data for"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsxs("select",{id:"retention-select",className:"input",value:d??n,onChange:p=>b(Number(p.target.value)),style:{width:160},children:[a.jsx("option",{value:7,children:"7 days"}),a.jsx("option",{value:30,children:"30 days"}),a.jsx("option",{value:90,children:"90 days"}),a.jsx("option",{value:180,children:"180 days"}),a.jsx("option",{value:365,children:"365 days"})]}),a.jsx("span",{"aria-live":"polite",children:s&&a.jsx("span",{style:{fontSize:10,color:"var(--green)",fontWeight:600},children:"Saved"})}),m!=null&&a.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:["Store: ",Ae(m)]})]}),d!=null&&a.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:[a.jsxs("div",{style:{fontSize:11,color:"var(--amber)",fontWeight:600,marginBottom:4},children:["Reduce retention to ",d," days?"]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["Operations, logs, and metrics older than ",d," days will be permanently deleted."]}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("button",{ref:g,type:"button",onClick:h,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"}),a.jsx("button",{type:"button",onClick:()=>u(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"})]})]}),d==null&&a.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."}),a.jsx("div",{"aria-live":"polite",children:l&&a.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:l})})]})]})}function Ot(t){const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60);if(n<60)return`${n}m ${e%60}s`;const i=Math.floor(n/60);return i<24?`${i}h ${n%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $t(t){return t.length<=12?t:`${t.slice(0,6)}…${t.slice(-4)}`}function zt(t){if(!t)return"Unknown";const e=t.includes(":")?t.split(":")[1]:t;switch(e){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 ${e}`}}function Ut(){return a.jsxs("div",{className:"page-section",children:[a.jsxs("div",{style:{marginBottom:20},children:[a.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Settings"}),a.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:"Node configuration and preferences"})]}),a.jsx(_t,{})]})}function _t(){var h,b,m,p,v,j,w,k;const{data:t}=E(we,[],3e4),{data:e}=E(je,[],6e4),n=t,i=e,[s,r]=y.useState(!1),[l,o]=y.useState(!1),d=(n==null?void 0:n.connectedPeers)??0,u=(n==null?void 0:n.peerId)!=null,g=y.useCallback(async()=>{if(!s){r(!0),setTimeout(()=>r(!1),5e3);return}o(!0);try{await Ne()}catch{o(!1),r(!1)}},[s]);return a.jsxs("div",{className:"settings-stack",children:[a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Node Identity"})}),a.jsxs("div",{className:"card-body",children:[a.jsx(C,{label:"Name",value:(n==null?void 0:n.name)??"—"}),a.jsx(C,{label:"Peer ID",value:(n==null?void 0:n.peerId)??"—",mono:!0}),a.jsx(C,{label:"Role",value:(n==null?void 0:n.nodeRole)??"—"}),a.jsx(C,{label:"Network",value:(n==null?void 0:n.networkName)??(n!=null&&n.networkId?`Network ${n.networkId}`:"—")}),a.jsx(C,{label:"Store",value:(n==null?void 0:n.storeBackend)??"—",mono:!0}),a.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:u?"var(--green-dim)":"rgba(248,113,113,.05)",border:`1px solid ${u?"rgba(74,222,128,.2)":"rgba(248,113,113,.2)"}`},children:[a.jsx("div",{className:"mono",style:{fontSize:10,color:u?"var(--green)":"var(--red)",fontWeight:700},children:u?"● ONLINE":"● OFFLINE"}),a.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:u?`${d} peer${d!==1?"s":""} · ${((h=n==null?void 0:n.connections)==null?void 0:h.direct)??0} direct, ${((b=n==null?void 0:n.connections)==null?void 0:b.relayed)??0} relayed link${(((m=n==null?void 0:n.connections)==null?void 0:m.relayed)??0)===1?"":"s"} · up ${Ot((n==null?void 0:n.uptimeMs)??0)}`:"Node is not responding"})]})]})]}),a.jsx(Et,{blockExplorerUrl:(n==null?void 0:n.blockExplorerUrl)??null}),a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Blockchain Config"})}),a.jsxs("div",{className:"card-body",children:[a.jsx(C,{label:"Chain",value:zt(i==null?void 0:i.chainId)}),((p=i==null?void 0:i.balances)==null?void 0:p.length)>0?i.balances.map((c,T)=>a.jsxs("div",{style:{marginBottom:10},children:[a.jsx(C,{label:i.balances.length>1?`Wallet ${T+1}`:"Operational Wallet",value:c.address,mono:!0}),a.jsxs("div",{style:{display:"flex",gap:16,marginTop:-6},children:[a.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:Se(c.eth),children:[ke(c.eth)," ETH"]}),a.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:st(c.trac),children:[ce(c.trac)," ",rt(c.symbol,i==null?void 0:i.chainId)]})]})]},c.address)):a.jsx(C,{label:"Operational Wallet",value:(v=i==null?void 0:i.wallets)!=null&&v[0]?$t(i.wallets[0]):"—",mono:!0}),(i==null?void 0:i.rpcUrl)&&a.jsx(Pt,{rpcUrl:i.rpcUrl}),i!=null&&i.error?a.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(248,113,113,.05)",border:"1px solid rgba(248,113,113,.2)"},children:[a.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--red)",marginBottom:2},children:"⚠ Error"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:i.error})]}):(j=i==null?void 0:i.chainId)!=null&&j.includes("84532")||(w=i==null?void 0:i.chainId)!=null&&w.includes("31337")||(k=i==null?void 0:i.chainId)!=null&&k.includes("11155111")?a.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"var(--amber-dim)",border:"1px solid rgba(251,191,36,.2)"},children:[a.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--amber)",marginBottom:2},children:"⚠ Testnet Mode"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"No real TRAC is spent. Perfect for development."})]}):null]})]}),a.jsx(ct,{}),a.jsx(Wt,{}),a.jsx(Lt,{}),a.jsxs("section",{className:"card",style:{borderColor:"rgba(248,113,113,.2)",background:"rgba(248,113,113,.03)"},children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",style:{color:"var(--red)"},children:"Danger Zone"})}),a.jsx("div",{className:"card-body",children:a.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[a.jsx("button",{onClick:g,disabled:l,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${s?"var(--red)":"rgba(251,191,36,.3)"}`,background:s?"rgba(248,113,113,.15)":"rgba(251,191,36,.07)",color:s?"var(--red)":"var(--amber)",fontSize:12,fontWeight:600,cursor:l?"not-allowed":"pointer",opacity:l?.5:1},children:l?"Shutting down…":s?"Confirm Shutdown":"Shutdown Node"}),a.jsx("span",{"aria-live":"polite",children:s&&a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"Click again to confirm. The node process will terminate."})})]})})]})]})}export{Ut as SettingsPage};
|
|
1
|
+
var ye=Object.defineProperty;var fe=(t,e,n)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var K=(t,e,n)=>fe(t,typeof e!="symbol"?e+"":e,n);import{ax as oe,H as le,bJ as ge,bM as be,bI as ve,aO as a,N as R,bO as Q,b1 as xe,bd as y,bz as E,af as we,ai as je,bl as Ne,ao as ke,ap as Se,ah as Ce,R as G,bu as X,a1 as Te,ae as Ie,bt as ee,am as Ae}from"./index-DK8XzE3T.js";import{e as Re,A as Ee,m as de,x as Pe,I as We,K as F,M as Le,h as Oe,v as $e,J as ze,j as _e,a as Be,g as Me,U as He,i as Ue,D as De,R as te,E as Ke,O as Fe,L as qe,t as Ye,o as Ve,d as ne,f as Qe,b as Ge,W as Ze}from"./browserWalletTransaction-BdmrJpK1.js";const Je="IDENTITY_WALLET_MANAGEMENT_UNAVAILABLE",Xe="OPERATIONAL_WALLET_MANAGEMENT_UNAVAILABLE";class U extends Error{constructor(n,i){super(`${i} from ${n}`);K(this,"code","IDENTITY_WALLET_API_DECODE_ERROR");K(this,"endpoint");this.name="IdentityWalletApiDecodeError",this.endpoint=n,Object.setPrototypeOf(this,U.prototype)}}function et(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.address=="string"&&typeof e.isAdmin=="boolean"&&typeof e.isPrimary=="boolean"&&(typeof e.registered=="boolean"||e.registered===null)}function tt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.identityId=="string"&&typeof e.hasProfile=="boolean"&&typeof e.adminKeyConfigured=="boolean"&&typeof e.canManage=="boolean"&&Array.isArray(e.wallets)&&e.wallets.every(et)}const nt=async()=>{var e;const t="/api/operational-wallets";try{const n=await oe(t);if(!tt(n))throw new U(t,"Invalid operational-wallet snapshot");return{available:!0,snapshot:n}}catch(n){if(n instanceof le&&n.status===503&&((e=n.body)==null?void 0:e.code)===Xe)return{available:!1};throw n}};function at(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t,n=typeof e.chainId=="number"&&Number.isFinite(e.chainId)||typeof e.chainId=="string"&&/(\d+)\s*$/.test(e.chainId);return typeof e.profile=="string"&&typeof e.identity=="string"&&typeof e.storage=="string"&&n&&Array.isArray(e.rpcUrls)&&e.rpcUrls.every(i=>typeof i=="string")&&(e.walletRpcUrls===void 0||Array.isArray(e.walletRpcUrls)&&e.walletRpcUrls.every(i=>typeof i=="string"))}const it=async()=>{var e;const t="/api/identity-wallets/contracts";try{const n=await oe(t);if(!at(n))throw new U(t,"Invalid identity-wallet contracts response");return n}catch(n){if(n instanceof le&&n.status===503&&((e=n.body)==null?void 0:e.code)===Je)return null;throw n}};function rt(t,e){const n=(t??"").trim();if(!n)return"TRAC";const i=(e??"").includes(":")?(e??"").split(":")[1]:e??"";return i==="84532"||i==="11155111"||i==="31337"||i==="10200"||i==="20430"?/test/i.test(n)?n:`${n} (testnet)`:n}function ce(t,e=2){if(t==null)return"—";let n;if(typeof t=="number")n=t;else{const i=String(t).trim();if(!/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(i))return"—";n=Number(i)}return Number.isFinite(n)?n.toFixed(e):"—"}function st(t){if(ce(t)!=="—")return`Exact: ${t}`}const q="************",ot=/[A-Za-z0-9_-]{16,}/g;function lt(t){if(!t)return"";let e;try{e=new URL(t)}catch{return t.replace(ot,q)}(e.username||e.password)&&(e.username="",e.password="");const n=e.pathname.split("/").map(i=>i.length<16?i:/^[A-Za-z0-9_-]+$/.test(i)?q:i);if(e.pathname=n.join("/"),e.search){const i=new URLSearchParams(e.search);for(const s of Array.from(i.keys()))/key|token|secret|auth/i.test(s)&&i.set(s,q);e.search=i.toString()}return e.toString()}function dt(t){if(t==null)return"—";const e=t/100;return`${e%1===0?e.toFixed(0):e.toFixed(1)}%`}function ct(){ge();const t=be(l=>l.openTab),{accounts:e,covered:n,bestCoveringDiscountBps:i,walletsInconclusive:s}=ve(),r=e.length;return a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Publisher Conviction"})}),a.jsxs("div",{className:"card-body",children:[r===0?a.jsx("p",{className:"v10-pca-settings-line",children:"No tracked Publisher Conviction Account on this node."}):n?a.jsxs("p",{className:"v10-pca-settings-line",children:["This node’s approved publishing wallets use a ",a.jsx("strong",{children:dt(i)})," discount."]}):s?a.jsx("p",{className:"v10-pca-settings-line",role:"status",children:"Couldn’t verify this node’s wallets — retry."}):a.jsxs("p",{className:"v10-pca-settings-line",children:["Tracking ",r," account",r===1?"":"s",", but none currently covers this node’s publishes."]}),a.jsx("button",{type:"button",className:"v10-pca-card-btn",onClick:()=>t({id:"conviction",label:"Publisher Conviction",closable:!0}),children:"Manage publisher conviction ->"})]})]})}function ut({wallets:t,summary:e,writesEnabled:n,onRemove:i}){return t.length===0?null:a.jsxs("div",{className:"v10-identity-wallet-known",children:[a.jsx("p",{className:"v10-identity-wallet-subtitle",children:"Wallets known to this node"}),a.jsx("div",{className:"v10-identity-wallet-list",children:t.map(s=>{const r=e==null?void 0:e.addresses.find(o=>R(o.address,s.address)),l=[s.isPrimary?"primary":null,(r==null?void 0:r.operational)===!0||s.registered===!0?"operational":null,(r==null?void 0:r.admin)===!0?"admin":null,s.registered===null?"chain status unknown":null].filter(Boolean).join(" · ")||"not registered";return a.jsx(Re,{address:s.address,status:l,statusTone:s.registered===null?"warn":r!=null&&r.operational||r!=null&&r.admin?"success":"danger",trailing:a.jsxs("span",{className:"v10-identity-wallet-row-actions",children:[((r==null?void 0:r.operational)===!0||s.registered===!0)&&a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact","data-testid":`remove-operational-${s.address}`,onClick:()=>i("operational",s.address),disabled:!n||s.isPrimary,title:s.isPrimary?"The primary operational wallet cannot be removed.":void 0,children:"Remove operational"}),(r==null?void 0:r.admin)===!0&&a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact","data-testid":`remove-admin-${s.address}`,onClick:()=>i("admin",s.address),disabled:!n||((e==null?void 0:e.adminCount)??0)<=1,title:((e==null?void 0:e.adminCount)??0)<=1?"Add a replacement admin before removing the final admin key.":void 0,children:"Remove admin"})]})},s.address)})})]})}const mt={operational:{title:"Operational keys",label:"Operational wallet address",description:"These wallets sign publishes. Registering an address does not copy its private key into this node; it must already be present in the node's operational wallet pool to participate in rotation.",addAction:"add-operational",removeAction:"remove-operational",addLabel:"Register operational",removeLabel:"Remove operational"},admin:{title:"Admin keys",label:"Admin wallet address",description:"Admin addresses are stored on-chain as hashes, so they cannot be enumerated back into addresses. Enter the exact address when rotating an old key. The contract never allows the final admin key to be removed.",addAction:"add-admin",removeAction:"remove-admin",addLabel:"Register admin",removeLabel:"Remove admin"}};function ae({role:t,value:e,writesEnabled:n,finalAdmin:i,onChange:s,onSubmit:r,onRemove:l}){const o=mt[t],d=`identity-${t}-address`,u=!e.trim();return a.jsxs("div",{className:"v10-identity-wallet-card","data-testid":`${t}-wallet-editor`,children:[a.jsx("h4",{children:o.title}),a.jsx("p",{children:o.description}),a.jsx("label",{htmlFor:d,children:o.label}),a.jsx("input",{id:d,className:"v10-form-input mono",value:e,onChange:g=>s(g.target.value),placeholder:"0x…",autoComplete:"off",spellCheck:!1}),a.jsxs("div",{className:"v10-identity-wallet-actions",children:[a.jsx("button",{type:"button",className:"v10-identity-wallet-btn primary","data-testid":o.addAction,onClick:()=>r(o.addAction,e),disabled:!n||u,children:o.addLabel}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn","data-testid":o.removeAction,onClick:()=>l(t,e),disabled:!n||u||!!i,children:o.removeLabel})]})]})}function ht(t,e){if(t.length!==e.length)throw new Ee({expectedLength:t.length,givenLength:e.length});const n=[];for(let i=0;i<t.length;i++){const s=t[i],r=e[i];n.push(ue(s,r))}return de(n)}function ue(t,e,n=!1){if(t==="address"){const l=e;if(!Pe(l))throw new We({address:l});return F(l.toLowerCase(),{size:n?32:null})}if(t==="string")return Le(e);if(t==="bytes")return e;if(t==="bool")return F(Oe(e),{size:n?32:1});const i=t.match($e);if(i){const[l,o,d="256"]=i,u=Number.parseInt(d,10)/8;return ze(e,{size:n?32:u,signed:o==="int"})}const s=t.match(_e);if(s){const[l,o]=s;if(Number.parseInt(o,10)!==(e.length-2)/2)throw new Be({expectedSize:Number.parseInt(o,10),givenSize:(e.length-2)/2});return F(e,{dir:"right",size:n?32:null})}const r=t.match(Me);if(r&&Array.isArray(e)){const[l,o]=r,d=[];for(let u=0;u<e.length;u++)d.push(ue(o,e[u],!0));return d.length===0?"0x":de(d)}throw new He(t)}const pt=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"address[]",name:"operationalWallets",type:"address[]"}],name:"addOperationalWallets",outputs:[],stateMutability:"nonpayable",type:"function"}],yt=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"key",type:"bytes32"},{internalType:"uint256",name:"keyPurpose",type:"uint256"},{internalType:"uint256",name:"keyType",type:"uint256"}],name:"addKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"key",type:"bytes32"}],name:"removeKey",outputs:[],stateMutability:"nonpayable",type:"function"}],ft=[{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"bytes32",name:"_key",type:"bytes32"},{internalType:"uint256",name:"_purpose",type:"uint256"}],name:"keyHasPurpose",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint72",name:"identityId",type:"uint72"},{internalType:"uint256",name:"_purpose",type:"uint256"}],name:"getKeysByPurpose",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"}],A=1n,M=2n,gt=1n,bt=pt,Y=yt,me=ft,vt=(1n<<72n)-1n;class f extends Error{constructor(e){super(e),this.name="IdentityWalletActionError"}}function N(t,e){return Ue(t,e,n=>new f(n))}function P(t){const e=typeof t=="bigint"?t.toString():t.trim();if(!/^\d+$/.test(e))throw new f("Node identityId must be a non-negative integer.");const n=BigInt(e);if(n<=0n||n>vt)throw new f("Node identityId must be between 1 and the uint72 maximum.");return n}function L(t){const e=N(t,"Wallet address");return De(ht(["address"],[e]))}function he(t){return{profile:N(t.profile,"profile contract"),identity:N(t.identity,"identity contract"),storage:N(t.storage,"identityStorage contract")}}const pe={error:t=>new f(t),unavailableError:t=>new f(t),abortedError:t=>new f(t),messages:{disconnected:"Connect an existing admin wallet before signing.",wrongNetwork:"Switch the connected wallet to this node's network.",providerChanged:"Wallet provider changed before the signature prompt. Reconnect and retry.",addressChanged:"Connected wallet changed before the signature prompt. Reconnect the admin wallet.",networkChanged:"Wallet network changed before the signature prompt. Switch back and retry.",accountChanged:"Wallet account changed before the signature prompt. Reconnect the admin wallet."}};function _(t){if(!t.bootstrap)throw new f("This node does not expose identity-wallet contracts yet. Upgrade the daemon and reload the page.");const e=t.getWalletState??(()=>{const{provider:r,address:l,chainId:o}=Q.getState();return{provider:r,address:l,chainId:o}}),n={bootstrap:t.bootstrap,getWalletState:e,...t.publicClientFor?{publicClientFor:t.publicClientFor}:{},...t.walletClientFromProvider?{walletClientFromProvider:t.walletClientFromProvider}:{}},i=Ke(n,pe),s=he(t.bootstrap);return{...i,runtimeDeps:n,signer:i.account,profile:s.profile,identity:s.identity,identityStorage:s.storage}}async function W(t,e,n,i,s){return!!await t.readContract({address:e,abi:me,functionName:"keyHasPurpose",args:[n,L(i),s]})}async function O(t,e,n,i){return await t.readContract({address:e,abi:me,functionName:"getKeysByPurpose",args:[n,i]})}function $(t){return new Set(t.map(e=>e.toLowerCase()))}function z(t,e){return t.has(L(e).toLowerCase())}async function xt(t,e,n,i){const s=P(n),r=he(t).storage,l=[...new Map(i.map(h=>{const b=N(h,"Wallet address");return[b.toLowerCase(),b]})).values()],[o,d]=await Promise.all([O(e,r,s,A),O(e,r,s,M)]),u=$(o),g=$(d);return{adminCount:o.length,operationalCount:d.length,addresses:l.map(h=>({address:h,admin:z(u,h),operational:z(g,h)}))}}async function ie(t,e){if(!await W(t.publicClient,t.identityStorage,e,t.signer,A))throw new f(`Connected wallet ${t.signer} is not an admin key for identity ${e}. Connect an existing admin wallet.`)}function re(t,e,n){if(!z(n,t.signer))throw new f(`Connected wallet ${t.signer} is not an admin key for identity ${e}. Connect an existing admin wallet.`)}function wt(t){return t.blockNumber==null?void 0:Number(t.blockNumber)}async function B(t,e,n,i,s){const{hash:r,receipt:l}=await Fe(t,t.runtimeDeps,pe,s,"action",{signing:()=>{var o;return(o=e.onProgress)==null?void 0:o.call(e,{action:n,state:"signing"})},submitted:o=>{var d;return(d=e.onProgress)==null?void 0:d.call(e,{action:n,state:"submitted",txHash:o})},confirmed:o=>{var d;return(d=e.onProgress)==null?void 0:d.call(e,{action:n,state:"confirmed",txHash:o})},failed:(o,d)=>{var u;return(u=e.onProgress)==null?void 0:u.call(e,{action:n,state:"failed",txHash:d,error:o})}});return{action:n,address:i,txHash:l.transactionHash??r,blockNumber:wt(l)}}function jt(t){return{async addOperational(e,n){const i=P(e),s=N(n,"Operational wallet");if(R(s,te))throw new f("Operational wallet cannot be the zero address.");const r=_(t);await ie(r,i);const[l,o]=await Promise.all([W(r.publicClient,r.identityStorage,i,s,M),W(r.publicClient,r.identityStorage,i,s,A)]);if(l)throw new f(`${s} is already an operational key.`);if(o)throw new f(`${s} is already an admin key and cannot also be operational.`);return B(r,t,"add-operational",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.profile,abi:bt,functionName:"addOperationalWallets",args:[i,[s]]}))},async removeOperational(e,n,i){const s=P(e),r=N(n,"Operational wallet");if(!i)throw new f("Primary operational wallet metadata is required before removing an operational key.");const l=N(i,"Primary operational wallet");if(R(r,l))throw new f("The primary operational wallet cannot be removed because it anchors this node's on-chain identity.");const o=_(t),[d,u]=await Promise.all([O(o.publicClient,o.identityStorage,s,A),O(o.publicClient,o.identityStorage,s,M)]);if(re(o,s,$(d)),!z($(u),r))throw new f(`${r} is not an operational key for identity ${s}.`);if(u.length<=1)throw new f("The final operational key cannot be removed.");return B(o,t,"remove-operational",r,g=>g.writeContract({account:o.account,chain:o.chain,address:o.identity,abi:Y,functionName:"removeKey",args:[s,L(r)]}))},async addAdmin(e,n){const i=P(e),s=N(n,"Admin wallet");if(R(s,te))throw new f("Admin wallet cannot be the zero address.");const r=_(t);await ie(r,i);const[l,o]=await Promise.all([W(r.publicClient,r.identityStorage,i,s,A),W(r.publicClient,r.identityStorage,i,s,M)]);if(l)throw new f(`${s} is already an admin key.`);if(o)throw new f(`${s} is already an operational key and cannot also be an admin.`);return B(r,t,"add-admin",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.identity,abi:Y,functionName:"addKey",args:[i,L(s),A,gt]}))},async removeAdmin(e,n){const i=P(e),s=N(n,"Admin wallet"),r=_(t),l=await O(r.publicClient,r.identityStorage,i,A),o=$(l);if(re(r,i,o),!z(o,s))throw new f(`${s} is not an admin key for identity ${i}.`);if(l.length<=1)throw new f("The final admin key cannot be removed. Add its replacement first.");return B(r,t,"remove-admin",s,d=>d.writeContract({account:r.account,chain:r.chain,address:r.identity,abi:Y,functionName:"removeKey",args:[i,L(s)]}))}}}const H={"add-operational":{role:"operational",verb:"add",label:"Operational wallet registered"},"remove-operational":{role:"operational",verb:"remove",label:"Operational wallet removed"},"add-admin":{role:"admin",verb:"add",label:"Admin wallet registered"},"remove-admin":{role:"admin",verb:"remove",label:"Admin wallet removed"}},Nt={inputs:{operational:"",admin:""},removal:null,transaction:{status:"idle"}};function kt(t,e){switch(e.type){case"input":return{...t,inputs:{...t.inputs,[e.role]:e.value}};case"request-removal":return{...t,removal:e.removal,transaction:{status:"idle"}};case"cancel-removal":return{...t,removal:null};case"signing":return{...t,transaction:{status:"signing",action:e.action,address:e.address}};case"submitted":return{...t,transaction:{status:"submitted",action:e.action,address:e.address,txHash:e.txHash}};case"succeeded":{const n=H[e.completed.action];return{...t,inputs:n.verb==="add"?{...t.inputs,[n.role]:""}:t.inputs,removal:null,transaction:{status:"succeeded",completed:e.completed}}}case"failed":return{...t,transaction:{status:"failed",message:e.message,completed:e.completed}}}}function se(t,e){try{return Ye(t.trim())}catch{throw new f(`${e} must be a valid EVM address.`)}}function V(t){if(t instanceof f)return t.message;const e=Ve(t,"action");return e.kind==="rejected"?"You rejected the transaction. No identity key was changed.":e.message}function St(t){if(t instanceof ne)return t.txHash;if(t instanceof Qe&&t.cause instanceof ne)return t.cause.txHash}async function Ct(t,e,n,i,s){const r=jt(t);switch(e){case"add-operational":return r.addOperational(n,i);case"remove-operational":return r.removeOperational(n,i,s);case"add-admin":return r.addAdmin(n,i);case"remove-admin":return r.removeAdmin(n,i)}}async function Tt(){const[t,e]=await Promise.all([nt(),it()]);return t.available?e?{status:"ready",snapshot:t.snapshot,bootstrap:e}:{status:"unavailable",reason:"identity-contracts",snapshot:t.snapshot}:{status:"unavailable",reason:"operational-wallets",snapshot:null}}function It(){const t=E(Tt,[],0);return{state:y.useMemo(()=>t.error?{status:"error",message:t.error}:t.data??{status:"loading"},[t.data,t.error]),refresh:t.refresh}}function At({data:t,bootstrap:e,primaryAddress:n,refreshQuery:i,reloadSummary:s}){const[r,l]=y.useReducer(kt,Nt),o=r.transaction.status==="signing"||r.transaction.status==="submitted",d=y.useCallback(async(h,b)=>{let m;try{m=se(b,H[h].role==="admin"?"Admin wallet":"Operational wallet")}catch(p){l({type:"failed",message:V(p)});return}if(!(t!=null&&t.hasProfile)){l({type:"failed",message:"This node does not have an on-chain identity profile."});return}if(!e){l({type:"failed",message:"This node does not expose identity-wallet contracts yet. Upgrade the daemon and reload the page."});return}l({type:"signing",action:h,address:m});try{const p=await Ct({bootstrap:e,onProgress:v=>{v.state==="submitted"&&v.txHash?l({type:"submitted",action:h,address:m,txHash:v.txHash}):v.state==="signing"&&l({type:"signing",action:h,address:m})}},h,t.identityId,m,n);l({type:"succeeded",completed:{action:h,address:p.address,txHash:p.txHash,confirmed:!0}}),i(),s()}catch(p){const v=St(p);l({type:"failed",message:V(p),completed:v?{action:h,address:m,txHash:v,confirmed:!1}:void 0})}},[e,t==null?void 0:t.hasProfile,t==null?void 0:t.identityId,n,i,s]),u=y.useCallback((h,b)=>{try{const m=se(b,h==="admin"?"Admin wallet":"Operational wallet");if(h==="operational"&&n&&R(m,n))throw new f("The primary operational wallet cannot be removed because it anchors this node's on-chain identity.");l({type:"request-removal",removal:{role:h,address:m}})}catch(m){l({type:"failed",message:V(m)})}},[n]),g=y.useCallback(()=>{r.removal&&d(r.removal.role==="admin"?"remove-admin":"remove-operational",r.removal.address)},[r.removal,d]);return{inputs:r.inputs,setInput:(h,b)=>l({type:"input",role:h,value:b}),removal:r.removal,requestRemoval:u,cancelRemoval:()=>l({type:"cancel-removal"}),confirmRemoval:g,submit:d,transaction:r.transaction,transactionPending:o}}function Rt(){var k;const t=It(),e=t.state.status==="ready"||t.state.status==="unavailable"?t.state.snapshot:null,n=t.state.status==="ready"?t.state.bootstrap:null,i=Q(c=>c.address),s=Q(c=>c.chainId),r=!!(n&&s!==xe(n.chainId)),[l,o]=y.useState({status:"idle"}),[d,u]=y.useReducer(c=>c+1,0),g=y.useMemo(()=>{const c=[...(e==null?void 0:e.wallets.map(T=>T.address))??[]];return i&&c.push(i),c},[i,e]),h=g.join("|").toLowerCase();y.useEffect(()=>{let c=!1;if(!(e!=null&&e.hasProfile)||!n){o({status:"idle"});return}o({status:"loading"});const T=qe(n.chainId,n.rpcUrls);return xt(n,T,e.identityId,g).then(x=>{c||o({status:"ready",value:x})}).catch(x=>{c||o({status:"error",message:(x==null?void 0:x.message)??"Could not read identity keys from chain."})}),()=>{c=!0}},[n,e==null?void 0:e.hasProfile,e==null?void 0:e.identityId,h,d]);const b=l.status==="ready"?l.value:null,m=b==null?void 0:b.addresses.find(c=>R(c.address,i)),p=(m==null?void 0:m.admin)===!0,v=((k=e==null?void 0:e.wallets.find(c=>c.isPrimary))==null?void 0:k.address)??null,j=At({data:e,bootstrap:n,primaryAddress:v,refreshQuery:t.refresh,reloadSummary:u}),w=!!(t.state.status==="ready"&&(e!=null&&e.hasProfile)&&i&&p&&!r&&!j.transactionPending);return{query:t.state,refreshQuery:t.refresh,connected:i,wrongNetwork:r,summary:l,reloadSummary:u,connectedIsAdmin:p,writesEnabled:w,...j}}function Et({blockExplorerUrl:t}){const e=Rt(),{query:n,refreshQuery:i,connected:s,wrongNetwork:r,summary:l,reloadSummary:o,connectedIsAdmin:d,writesEnabled:u,inputs:g,setInput:h,removal:b,requestRemoval:m,cancelRemoval:p,confirmRemoval:v,submit:j,transaction:w,transactionPending:k}=e,c=n.status==="ready"||n.status==="unavailable"?n.snapshot:null,T=n.status==="ready"?n.bootstrap:null,x=l.status==="ready"?l.value:null,S=w.status==="succeeded"||w.status==="failed"?w.completed:void 0,Z=w.status==="failed"?w.message:null,J=S&&t?`${t.replace(/\/$/,"")}/tx/${S.txHash}`:null;return a.jsxs("section",{className:"card v10-identity-wallets","data-testid":"identity-wallets-section",children:[a.jsxs("div",{className:"card-header v10-identity-wallet-header",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"card-title",children:"Node Identity Wallets"}),a.jsxs("p",{className:"v10-identity-wallet-description",children:["Register and rotate operational or admin keys for node identity"," ",c!=null&&c.hasProfile?c.identityId:"—",". Every change is signed by the connected admin wallet; its private key never enters the node."]})]}),a.jsxs("div",{className:"v10-identity-wallet-counts","aria-label":"Identity wallet counts",children:[a.jsxs("span",{className:"badge badge-info",children:[(x==null?void 0:x.operationalCount)??"—"," operational"]}),a.jsxs("span",{className:"badge badge-info",children:[(x==null?void 0:x.adminCount)??"—"," admin"]})]})]}),a.jsxs("div",{className:"card-body",children:[a.jsxs("div",{className:"v10-identity-wallet-signer",children:[s?a.jsx(Ge,{bootstrap:T??void 0,className:"v10-identity-wallet-pill",testId:"identity-wallet-pill"}):a.jsx(Ze,{className:"compact v10-identity-wallet-connect",testId:"identity-wallet-connect"}),s&&l.status==="ready"&&a.jsx("span",{className:`badge ${d?"badge-success":"badge-warn"}`,children:d?"authorized admin signer":"not an admin for this identity"})]}),n.status==="loading"&&a.jsx("p",{className:"v10-identity-wallet-status",role:"status",children:"Loading node identity wallets…"}),n.status==="error"&&a.jsxs("p",{className:"v10-modal-warning",role:"alert",children:["Couldn't load identity wallet management: ",n.message,"."," ",a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact",onClick:i,children:"Retry"})]}),c&&!c.hasProfile&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"This node does not have an on-chain identity profile yet."}),n.status==="unavailable"&&n.reason==="operational-wallets"&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Identity wallet management requires a node version that exposes the operational-wallet snapshot."}),(c==null?void 0:c.hasProfile)&&n.status==="unavailable"&&n.reason==="identity-contracts"&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Identity wallet management requires a node version that exposes the Profile, Identity, and IdentityStorage addresses."}),r&&a.jsx("p",{className:"v10-modal-warning",role:"status",children:"Switch the connected wallet to this node's network to manage identity keys."}),l.status==="error"&&a.jsxs("p",{className:"v10-modal-warning",role:"alert",children:["Couldn't verify identity keys: ",l.message," ",a.jsx("button",{type:"button",className:"v10-identity-wallet-btn compact",onClick:o,children:"Retry"})]}),a.jsx(ut,{wallets:(c==null?void 0:c.wallets)??[],summary:x,writesEnabled:u,onRemove:m}),a.jsxs("div",{className:"v10-identity-wallet-grid",children:[a.jsx(ae,{role:"operational",value:g.operational,writesEnabled:u,onChange:I=>h("operational",I),onSubmit:(I,D)=>void j(I,D),onRemove:m}),a.jsx(ae,{role:"admin",value:g.admin,writesEnabled:u,finalAdmin:((x==null?void 0:x.adminCount)??0)<=1,onChange:I=>h("admin",I),onSubmit:(I,D)=>void j(I,D),onRemove:m})]}),b&&a.jsxs("div",{className:"v10-modal-warning v10-identity-wallet-confirm",role:"alertdialog","aria-label":"Confirm key removal",children:[a.jsxs("span",{children:["Remove ",b.address," as an ",b.role," key from identity ",c==null?void 0:c.identityId,"? This takes effect on-chain immediately."]}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn",onClick:v,disabled:k,children:"Yes, remove"}),a.jsx("button",{type:"button",className:"v10-identity-wallet-btn",onClick:p,disabled:k,children:"Cancel"})]}),k&&a.jsx("p",{className:"v10-identity-wallet-status",role:"status",children:w.status==="submitted"?"Transaction submitted — waiting for on-chain confirmation…":"Confirm the identity-key transaction on your wallet device…"}),Z&&a.jsx("p",{className:"v10-modal-error",role:"alert",children:Z}),S&&a.jsxs("div",{className:"v10-identity-wallet-status",role:"status","data-testid":"identity-wallet-result",children:[S.confirmed?`✓ ${H[S.action].label}: ${S.address}. `:`Transaction broadcast for ${S.address}, but confirmation is unknown. Check it before retrying. `,J&&a.jsx("a",{href:J,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}),S.confirmed&&H[S.action].role==="operational"&&a.jsx("span",{children:" Restart the node before relying on the updated operational signer rotation."})]})]})]})}function C({label:t,value:e,mono:n=!1}){return a.jsxs("div",{style:{marginBottom:14},children:[a.jsx("div",{className:"settings-field-label",children:t}),a.jsx("div",{className:`settings-field-value${n?" mono":""}`,children:e})]})}function Pt({rpcUrl:t}){const[e,n]=y.useState(!1),i=e?t:lt(t);return a.jsxs("div",{style:{marginBottom:14},children:[a.jsxs("div",{className:"settings-field-label",style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{children:"RPC"}),a.jsx("button",{type:"button",onClick:()=>n(s=>!s),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":e?"Redact RPC URL":"Reveal RPC URL",title:e?"Hide the path-token (recommended for screen-shares)":"Show full URL — careful, may contain a tenant secret",children:e?"Redact":"Reveal"})]}),a.jsx("div",{className:"settings-field-value mono",style:{wordBreak:"break-all"},children:i})]})}function Wt(){const{data:t}=E(Ce,[],6e4),[e,n]=y.useState(!1),[i,s]=y.useState(!1),[r,l]=y.useState(null),[o,d]=y.useState(!1),u=G.useRef(null),g=G.useRef(null);y.useEffect(()=>{t!=null&&n(t.enabled)},[t]);const h=y.useCallback(()=>{i||(l(null),e?(n(!1),s(!0),X(!1).catch(()=>{n(!0),l("Couldn’t update telemetry — try again.")}).finally(()=>s(!1))):d(!0))},[e,i]),b=y.useCallback(async()=>{var m;d(!1),l(null),n(!0),s(!0);try{await X(!0)}catch{n(!1),l("Couldn’t update telemetry — try again.")}finally{s(!1),(m=g.current)==null||m.focus()}},[]);return y.useEffect(()=>{var v;if(!o)return;const m=(v=u.current)==null?void 0:v.querySelector("button");m==null||m.focus();const p=j=>{var w;j.key==="Escape"&&(d(!1),(w=g.current)==null||w.focus())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[o]),a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Network Telemetry"})}),a.jsxs("div",{className:"card-body",children:[a.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."}),a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"10px 0"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:12,fontWeight:600},children:"Share telemetry with the network"}),a.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."})]}),a.jsx("button",{ref:g,type:"button",role:"switch","aria-checked":e,"aria-busy":i,"aria-disabled":i,"aria-label":"Share telemetry with the network",onClick:h,style:{width:38,height:22,borderRadius:11,border:"none",flexShrink:0,background:e?"var(--green)":"var(--border)",transition:"background .2s",position:"relative",marginLeft:16,cursor:i?"wait":"pointer",opacity:i?.6:1},children:a.jsx("span",{style:{position:"absolute",top:3,left:e?19:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left .2s",display:"block"}})})]}),a.jsx("div",{"aria-live":"polite",children:r&&a.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:r})})]}),o&&a.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,.55)",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsxs("div",{ref:u,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:[a.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16},children:"Enable Telemetry Streaming?"}),a.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:"}),a.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 14px 18px",padding:0},children:[a.jsx("li",{children:"Operation logs (publish, query, sync, gossip events)"}),a.jsx("li",{children:"Performance metrics (durations, throughput, error rates)"}),a.jsx("li",{children:"Node identity (peer ID, node name, network)"})]}),a.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.7,marginBottom:12},children:["The following data is ",a.jsx("strong",{style:{color:"var(--text)"},children:"NEVER"})," shared via telemetry:"]}),a.jsxs("ul",{style:{fontSize:12,color:"var(--text)",lineHeight:1.8,margin:"0 0 16px 18px",padding:0},children:[a.jsx("li",{children:"Private keys or wallet credentials"}),a.jsx("li",{children:"Authentication tokens or API keys"}),a.jsx("li",{children:"Private triple content or personal data"}),a.jsx("li",{children:"File system paths or environment variables"})]}),a.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."}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[a.jsx("button",{type:"button",onClick:()=>{var m;d(!1),(m=g.current)==null||m.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"}),a.jsx("button",{type:"button",onClick:b,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 Lt(){const{data:t}=E(Te,[],3e4),{data:e}=E(Ie,[],6e4),[n,i]=y.useState(90),[s,r]=y.useState(!1),[l,o]=y.useState(null),[d,u]=y.useState(null),g=G.useRef(null);y.useEffect(()=>{e!=null&&e.retentionDays&&i(e.retentionDays)},[e]),y.useEffect(()=>{var p;d!=null&&((p=g.current)==null||p.focus())},[d]);const h=y.useCallback(async()=>{if(d==null)return;const p=d;r(!1),o(null),u(null);try{await ee(p),i(p),r(!0),setTimeout(()=>r(!1),2e3)}catch{o("Couldn’t save retention — try again.")}},[d]),b=y.useCallback(p=>{o(null),p<n?(r(!1),u(p)):(r(!1),u(null),ee(p).then(()=>{i(p),r(!0),setTimeout(()=>r(!1),2e3)}).catch(()=>o("Couldn’t save retention — try again.")))},[n]),m=(t==null?void 0:t.store_bytes)??null;return a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Local Data Retention"})}),a.jsxs("div",{className:"card-body",children:[a.jsx("label",{htmlFor:"retention-select",className:"settings-field-label",style:{display:"block",marginBottom:5},children:"Keep local data for"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsxs("select",{id:"retention-select",className:"input",value:d??n,onChange:p=>b(Number(p.target.value)),style:{width:160},children:[a.jsx("option",{value:7,children:"7 days"}),a.jsx("option",{value:30,children:"30 days"}),a.jsx("option",{value:90,children:"90 days"}),a.jsx("option",{value:180,children:"180 days"}),a.jsx("option",{value:365,children:"365 days"})]}),a.jsx("span",{"aria-live":"polite",children:s&&a.jsx("span",{style:{fontSize:10,color:"var(--green)",fontWeight:600},children:"Saved"})}),m!=null&&a.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:["Store: ",Ae(m)]})]}),d!=null&&a.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:[a.jsxs("div",{style:{fontSize:11,color:"var(--amber)",fontWeight:600,marginBottom:4},children:["Reduce retention to ",d," days?"]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["Operations, logs, and metrics older than ",d," days will be permanently deleted."]}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("button",{ref:g,type:"button",onClick:h,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"}),a.jsx("button",{type:"button",onClick:()=>u(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"})]})]}),d==null&&a.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."}),a.jsx("div",{"aria-live":"polite",children:l&&a.jsx("div",{style:{fontSize:11,color:"var(--red)",marginTop:4},children:l})})]})]})}function Ot(t){const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60);if(n<60)return`${n}m ${e%60}s`;const i=Math.floor(n/60);return i<24?`${i}h ${n%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $t(t){return t.length<=12?t:`${t.slice(0,6)}…${t.slice(-4)}`}function zt(t){if(!t)return"Unknown";const e=t.includes(":")?t.split(":")[1]:t;switch(e){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 ${e}`}}function Ut(){return a.jsxs("div",{className:"page-section",children:[a.jsxs("div",{style:{marginBottom:20},children:[a.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Settings"}),a.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:"Node configuration and preferences"})]}),a.jsx(_t,{})]})}function _t(){var h,b,m,p,v,j,w,k;const{data:t}=E(we,[],3e4),{data:e}=E(je,[],6e4),n=t,i=e,[s,r]=y.useState(!1),[l,o]=y.useState(!1),d=(n==null?void 0:n.connectedPeers)??0,u=(n==null?void 0:n.peerId)!=null,g=y.useCallback(async()=>{if(!s){r(!0),setTimeout(()=>r(!1),5e3);return}o(!0);try{await Ne()}catch{o(!1),r(!1)}},[s]);return a.jsxs("div",{className:"settings-stack",children:[a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Node Identity"})}),a.jsxs("div",{className:"card-body",children:[a.jsx(C,{label:"Name",value:(n==null?void 0:n.name)??"—"}),a.jsx(C,{label:"Peer ID",value:(n==null?void 0:n.peerId)??"—",mono:!0}),a.jsx(C,{label:"Role",value:(n==null?void 0:n.nodeRole)??"—"}),a.jsx(C,{label:"Network",value:(n==null?void 0:n.networkName)??(n!=null&&n.networkId?`Network ${n.networkId}`:"—")}),a.jsx(C,{label:"Store",value:(n==null?void 0:n.storeBackend)??"—",mono:!0}),a.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:u?"var(--green-dim)":"rgba(248,113,113,.05)",border:`1px solid ${u?"rgba(74,222,128,.2)":"rgba(248,113,113,.2)"}`},children:[a.jsx("div",{className:"mono",style:{fontSize:10,color:u?"var(--green)":"var(--red)",fontWeight:700},children:u?"● ONLINE":"● OFFLINE"}),a.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:u?`${d} peer${d!==1?"s":""} · ${((h=n==null?void 0:n.connections)==null?void 0:h.direct)??0} direct, ${((b=n==null?void 0:n.connections)==null?void 0:b.relayed)??0} relayed link${(((m=n==null?void 0:n.connections)==null?void 0:m.relayed)??0)===1?"":"s"} · up ${Ot((n==null?void 0:n.uptimeMs)??0)}`:"Node is not responding"})]})]})]}),a.jsx(Et,{blockExplorerUrl:(n==null?void 0:n.blockExplorerUrl)??null}),a.jsxs("section",{className:"card",children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",children:"Blockchain Config"})}),a.jsxs("div",{className:"card-body",children:[a.jsx(C,{label:"Chain",value:zt(i==null?void 0:i.chainId)}),((p=i==null?void 0:i.balances)==null?void 0:p.length)>0?i.balances.map((c,T)=>a.jsxs("div",{style:{marginBottom:10},children:[a.jsx(C,{label:i.balances.length>1?`Wallet ${T+1}`:"Operational Wallet",value:c.address,mono:!0}),a.jsxs("div",{style:{display:"flex",gap:16,marginTop:-6},children:[a.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:Se(c.eth),children:[ke(c.eth)," ETH"]}),a.jsxs("span",{className:"mono",style:{fontSize:11,color:"var(--text-muted)"},title:st(c.trac),children:[ce(c.trac)," ",rt(c.symbol,i==null?void 0:i.chainId)]})]})]},c.address)):a.jsx(C,{label:"Operational Wallet",value:(v=i==null?void 0:i.wallets)!=null&&v[0]?$t(i.wallets[0]):"—",mono:!0}),(i==null?void 0:i.rpcUrl)&&a.jsx(Pt,{rpcUrl:i.rpcUrl}),i!=null&&i.error?a.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(248,113,113,.05)",border:"1px solid rgba(248,113,113,.2)"},children:[a.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--red)",marginBottom:2},children:"⚠ Error"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:i.error})]}):(j=i==null?void 0:i.chainId)!=null&&j.includes("84532")||(w=i==null?void 0:i.chainId)!=null&&w.includes("31337")||(k=i==null?void 0:i.chainId)!=null&&k.includes("11155111")?a.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"var(--amber-dim)",border:"1px solid rgba(251,191,36,.2)"},children:[a.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--amber)",marginBottom:2},children:"⚠ Testnet Mode"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"No real TRAC is spent. Perfect for development."})]}):null]})]}),a.jsx(ct,{}),a.jsx(Wt,{}),a.jsx(Lt,{}),a.jsxs("section",{className:"card",style:{borderColor:"rgba(248,113,113,.2)",background:"rgba(248,113,113,.03)"},children:[a.jsx("div",{className:"card-header",children:a.jsx("h2",{className:"card-title",style:{color:"var(--red)"},children:"Danger Zone"})}),a.jsx("div",{className:"card-body",children:a.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[a.jsx("button",{onClick:g,disabled:l,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${s?"var(--red)":"rgba(251,191,36,.3)"}`,background:s?"rgba(248,113,113,.15)":"rgba(251,191,36,.07)",color:s?"var(--red)":"var(--amber)",fontSize:12,fontWeight:600,cursor:l?"not-allowed":"pointer",opacity:l?.5:1},children:l?"Shutting down…":s?"Confirm Shutdown":"Shutdown Node"}),a.jsx("span",{"aria-live":"polite",children:s&&a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"Click again to confirm. The node process will terminate."})})]})})]})]})}export{Ut as SettingsPage};
|