@hanzo/ui-shadcn 5.7.2 → 5.7.4

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.
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- 'use strict';var l=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var l__namespace=/*#__PURE__*/_interopNamespace(l);var U=Object.defineProperty;var o=(e,n)=>U(e,"name",{value:n,configurable:true});var E=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.hanzo-test.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-test.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36965,evmChainID:36965,rpcEndpoint:"https://rpc.hanzo-dev.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-dev.network",currency:"AI"},{env:"local",label:"Local",networkID:31337,evmChainID:31337,rpcEndpoint:"http://localhost:9650/ext/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],V=o(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),h=o((e,n)=>e.find(a=>a.env===n),"networkByEnv"),O=/^https?:\/\/.+/;function w(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":O.test(e.rpcEndpoint)?O.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}o(w,"validateCustomNetwork");var y="hanzo.network",u=E,i={env:"mainnet"},z=false,C=new Set;function Z(e){if(e.length===0)throw new Error("configureNetworks: list must not be empty");u=e,g();}o(Z,"configureNetworks");var Y=o(()=>u,"getNetworks");function N(){if(!(z||typeof window>"u")){z=true;try{let e=window.localStorage.getItem(y);if(e){let n=JSON.parse(e);n&&typeof n.env=="string"&&(i=n);}}catch{}window.addEventListener("storage",e=>{if(e.key===y)try{let n=e.newValue?JSON.parse(e.newValue):null;n&&typeof n.env=="string"&&(i=n,g());}catch{}});}}o(N,"load");function H(){if(!(typeof window>"u"))try{window.localStorage.setItem(y,JSON.stringify(i));}catch{}}o(H,"persist");function g(){for(let e of C)e();}o(g,"emit");function I(){return N(),i.env==="custom"&&i.custom?i.custom:h(u,i.env)??u[0]}o(I,"getNetwork");function T(e){N();let n=h(u,e);if(!n)throw new Error(`selectNetwork: no '${e}' network configured`);return i={env:e},H(),g(),n}o(T,"selectNetwork");function M(e){N();let n={...e,env:"custom"},a=w(n);if(a)throw new Error(a);return i={env:"custom",custom:n},H(),g(),n}o(M,"selectCustomNetwork");function P(e){return N(),C.add(e),()=>C.delete(e)}o(P,"subscribeNetwork");function D(){return {network:l__namespace.useSyncExternalStore(P,I,I),networks:u,select:T,selectCustom:M}}o(D,"useNetwork");var S={mainnet:"bg-emerald-500",testnet:"bg-amber-500",devnet:"bg-sky-500",local:"bg-zinc-400",custom:"bg-violet-500"},_={label:"",chainID:"",rpcEndpoint:"",apiEndpoint:""};function F({onChange:e,className:n=""}){let{network:a,networks:B,select:W,selectCustom:$}=D(),[d,f]=l__namespace.useState(false),[K,v]=l__namespace.useState(false),[s,m]=l__namespace.useState(_),[R,x]=l__namespace.useState(null),b=l__namespace.useRef(null);l__namespace.useEffect(()=>{if(!d)return;let t=o(p=>{b.current&&!b.current.contains(p.target)&&f(false);},"onDown");return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[d]);let L=o(t=>{if(t==="custom"){v(true);return}let p=W(t);f(false),v(false),e?.(p);},"pick"),j=o(()=>{let t={label:s.label.trim()||"Custom",networkID:Number(s.chainID),evmChainID:Number(s.chainID),rpcEndpoint:s.rpcEndpoint.trim(),apiEndpoint:s.apiEndpoint.trim(),currency:a.currency},p=w({...t});if(p){x(p);return}let J=$(t);x(null),m(_),f(false),v(false),e?.(J);},"saveCustom"),k="w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring";return jsxRuntime.jsxs("div",{ref:b,className:`relative ${n}`,children:[jsxRuntime.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":d,onClick:()=>f(t=>!t),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 rounded-full ${S[a.env]}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"max-w-[9rem] truncate",children:a.label}),jsxRuntime.jsx("svg",{className:`h-3 w-3 text-muted-foreground transition-transform ${d?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),d&&jsxRuntime.jsxs("div",{role:"menu",className:"absolute right-0 z-50 mt-1.5 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md",children:[B.map(t=>jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a.env===t.env,onClick:()=>L(t.env),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${S[t.env]}`,"aria-hidden":true}),jsxRuntime.jsxs("span",{className:"flex-1",children:[jsxRuntime.jsx("span",{className:"block font-medium",children:t.label}),jsxRuntime.jsxs("span",{className:"block text-[10px] text-muted-foreground",children:["chain ",t.evmChainID," \xB7 ",t.rpcEndpoint.replace(/^https?:\/\//,"")]})]}),a.env===t.env&&jsxRuntime.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},t.env)),jsxRuntime.jsx("div",{className:"my-1 h-px bg-border",role:"separator"}),K?jsxRuntime.jsxs("form",{className:"space-y-1.5 p-2",onSubmit:t=>{t.preventDefault(),j();},children:[jsxRuntime.jsx("input",{className:k,placeholder:"Label (optional)",value:s.label,onChange:t=>m({...s,label:t.target.value})}),jsxRuntime.jsx("input",{className:k,placeholder:"Chain ID",inputMode:"numeric",value:s.chainID,onChange:t=>m({...s,chainID:t.target.value})}),jsxRuntime.jsx("input",{className:k,placeholder:"RPC endpoint (https://\u2026)",value:s.rpcEndpoint,onChange:t=>m({...s,rpcEndpoint:t.target.value})}),jsxRuntime.jsx("input",{className:k,placeholder:"API endpoint (https://\u2026)",value:s.apiEndpoint,onChange:t=>m({...s,apiEndpoint:t.target.value})}),R&&jsxRuntime.jsx("p",{className:"text-[10px] text-destructive",children:R}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-1.5 pt-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(false),x(null);},className:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",className:"rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90",children:"Connect"})]})]}):jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a.env==="custom",onClick:()=>L("custom"),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${S.custom}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"flex-1 font-medium",children:a.env==="custom"?a.label:"Custom\u2026"}),a.env==="custom"&&jsxRuntime.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]})]})]})}o(F,"NetworkSwitcher");
3
- exports.HANZO_NETWORKS=E;exports.NetworkSwitcher=F;exports.chainIdHex=V;exports.configureNetworks=Z;exports.getNetwork=I;exports.getNetworks=Y;exports.networkByEnv=h;exports.selectCustomNetwork=M;exports.selectNetwork=T;exports.subscribeNetwork=P;exports.useNetwork=D;exports.validateCustomNetwork=w;
2
+ 'use strict';var l=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var l__namespace=/*#__PURE__*/_interopNamespace(l);var V=Object.defineProperty;var o=(e,n)=>V(e,"name",{value:n,configurable:true});var y=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36962,evmChainID:36962,rpcEndpoint:"https://rpc.testnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.testnet.hanzo.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.devnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.devnet.hanzo.network",currency:"AI"},{env:"local",label:"Hanzo Local",networkID:1337,evmChainID:1337,rpcEndpoint:"http://localhost:9630/v1/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],Z=o(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),N=o((e,n)=>e.find(p=>p.env===n),"networkByEnv"),O=/^https?:\/\/.+/;function f(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":O.test(e.rpcEndpoint)?O.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}o(f,"validateCustomNetwork");var C="hanzo.network",d=y,i={env:"mainnet"},A=false,I=new Set;function Y(e){if(e.length===0)throw new Error("configureNetworks: list must not be empty");d=e,x();}o(Y,"configureNetworks");var F=o(()=>d,"getNetworks");function g(){if(!(A||typeof window>"u")){A=true;try{let e=window.localStorage.getItem(C);if(e){let n=JSON.parse(e);n&&typeof n.env=="string"&&(i=n);}}catch{}window.addEventListener("storage",e=>{if(e.key===C)try{let n=e.newValue?JSON.parse(e.newValue):null;n&&typeof n.env=="string"&&(i=n,x());}catch{}});}}o(g,"load");function T(){if(!(typeof window>"u"))try{window.localStorage.setItem(C,JSON.stringify(i));}catch{}}o(T,"persist");function x(){for(let e of I)e();}o(x,"emit");function D(){return g(),i.env==="custom"&&i.custom?i.custom:N(d,i.env)??d[0]}o(D,"getNetwork");function M(e){g();let n=N(d,e);if(!n)throw new Error(`selectNetwork: no '${e}' network configured`);return i={env:e},T(),x(),n}o(M,"selectNetwork");function P(e){g();let n={...e,env:"custom"},p=f(n);if(p)throw new Error(p);return i={env:"custom",custom:n},T(),x(),n}o(P,"selectCustomNetwork");function _(e){return g(),I.add(e),()=>I.delete(e)}o(_,"subscribeNetwork");function S(){return {network:l__namespace.useSyncExternalStore(_,D,D),networks:d,select:M,selectCustom:P}}o(S,"useNetwork");var R={mainnet:"bg-emerald-500",testnet:"bg-amber-500",devnet:"bg-sky-500",local:"bg-zinc-400",custom:"bg-violet-500"},$={label:"",chainID:"",rpcEndpoint:"",apiEndpoint:""};function G({onChange:e,menuSide:n="bottom",className:p=""}){let{network:s,networks:B,select:W,selectCustom:K}=S(),[m,v]=l__namespace.useState(false),[j,k]=l__namespace.useState(false),[a,w]=l__namespace.useState($),[L,b]=l__namespace.useState(null),E=l__namespace.useRef(null);l__namespace.useEffect(()=>{if(!m)return;let t=o(u=>{E.current&&!E.current.contains(u.target)&&v(false);},"onDown");return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[m]);let z=o(t=>{if(t==="custom"){k(true);return}let u=W(t);v(false),k(false),e?.(u);},"pick"),J=o(()=>{let t={label:a.label.trim()||"Custom",networkID:Number(a.chainID),evmChainID:Number(a.chainID),rpcEndpoint:a.rpcEndpoint.trim(),apiEndpoint:a.apiEndpoint.trim(),currency:s.currency},u=f({...t});if(u){b(u);return}let U=K(t);b(null),w($),v(false),k(false),e?.(U);},"saveCustom"),h="w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring";return jsxRuntime.jsxs("div",{ref:E,className:`relative ${p}`,children:[jsxRuntime.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":m,onClick:()=>v(t=>!t),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 rounded-full ${R[s.env]}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"max-w-[9rem] truncate",children:s.label}),jsxRuntime.jsx("svg",{className:`h-3 w-3 text-muted-foreground transition-transform ${m?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),m&&jsxRuntime.jsxs("div",{role:"menu",className:`absolute right-0 z-50 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md ${n==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:[B.map(t=>jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.env===t.env,onClick:()=>z(t.env),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${R[t.env]}`,"aria-hidden":true}),jsxRuntime.jsxs("span",{className:"flex-1",children:[jsxRuntime.jsx("span",{className:"block font-medium",children:t.label}),jsxRuntime.jsxs("span",{className:"block text-[10px] text-muted-foreground",children:["chain ",t.evmChainID," \xB7 ",t.rpcEndpoint.replace(/^https?:\/\//,"")]})]}),s.env===t.env&&jsxRuntime.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},t.env)),jsxRuntime.jsx("div",{className:"my-1 h-px bg-border",role:"separator"}),j?jsxRuntime.jsxs("form",{className:"space-y-1.5 p-2",onSubmit:t=>{t.preventDefault(),J();},children:[jsxRuntime.jsx("input",{className:h,placeholder:"Label (optional)",value:a.label,onChange:t=>w({...a,label:t.target.value})}),jsxRuntime.jsx("input",{className:h,placeholder:"Chain ID",inputMode:"numeric",value:a.chainID,onChange:t=>w({...a,chainID:t.target.value})}),jsxRuntime.jsx("input",{className:h,placeholder:"RPC endpoint (https://\u2026)",value:a.rpcEndpoint,onChange:t=>w({...a,rpcEndpoint:t.target.value})}),jsxRuntime.jsx("input",{className:h,placeholder:"API endpoint (https://\u2026)",value:a.apiEndpoint,onChange:t=>w({...a,apiEndpoint:t.target.value})}),L&&jsxRuntime.jsx("p",{className:"text-[10px] text-destructive",children:L}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-1.5 pt-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{k(false),b(null);},className:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",className:"rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90",children:"Connect"})]})]}):jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.env==="custom",onClick:()=>z("custom"),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${R.custom}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"flex-1 font-medium",children:s.env==="custom"?s.label:"Custom\u2026"}),s.env==="custom"&&jsxRuntime.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]})]})]})}o(G,"NetworkSwitcher");
3
+ exports.HANZO_NETWORKS=y;exports.NetworkSwitcher=G;exports.chainIdHex=Z;exports.configureNetworks=Y;exports.getNetwork=D;exports.getNetworks=F;exports.networkByEnv=N;exports.selectCustomNetwork=P;exports.selectNetwork=M;exports.subscribeNetwork=_;exports.useNetwork=S;exports.validateCustomNetwork=f;
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import*as l from'react';import {jsxs,jsx}from'react/jsx-runtime';var U=Object.defineProperty;var o=(e,n)=>U(e,"name",{value:n,configurable:true});var E=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.hanzo-test.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-test.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36965,evmChainID:36965,rpcEndpoint:"https://rpc.hanzo-dev.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-dev.network",currency:"AI"},{env:"local",label:"Local",networkID:31337,evmChainID:31337,rpcEndpoint:"http://localhost:9650/ext/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],V=o(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),h=o((e,n)=>e.find(a=>a.env===n),"networkByEnv"),O=/^https?:\/\/.+/;function w(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":O.test(e.rpcEndpoint)?O.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}o(w,"validateCustomNetwork");var y="hanzo.network",u=E,i={env:"mainnet"},z=false,C=new Set;function Z(e){if(e.length===0)throw new Error("configureNetworks: list must not be empty");u=e,g();}o(Z,"configureNetworks");var Y=o(()=>u,"getNetworks");function N(){if(!(z||typeof window>"u")){z=true;try{let e=window.localStorage.getItem(y);if(e){let n=JSON.parse(e);n&&typeof n.env=="string"&&(i=n);}}catch{}window.addEventListener("storage",e=>{if(e.key===y)try{let n=e.newValue?JSON.parse(e.newValue):null;n&&typeof n.env=="string"&&(i=n,g());}catch{}});}}o(N,"load");function H(){if(!(typeof window>"u"))try{window.localStorage.setItem(y,JSON.stringify(i));}catch{}}o(H,"persist");function g(){for(let e of C)e();}o(g,"emit");function I(){return N(),i.env==="custom"&&i.custom?i.custom:h(u,i.env)??u[0]}o(I,"getNetwork");function T(e){N();let n=h(u,e);if(!n)throw new Error(`selectNetwork: no '${e}' network configured`);return i={env:e},H(),g(),n}o(T,"selectNetwork");function M(e){N();let n={...e,env:"custom"},a=w(n);if(a)throw new Error(a);return i={env:"custom",custom:n},H(),g(),n}o(M,"selectCustomNetwork");function P(e){return N(),C.add(e),()=>C.delete(e)}o(P,"subscribeNetwork");function D(){return {network:l.useSyncExternalStore(P,I,I),networks:u,select:T,selectCustom:M}}o(D,"useNetwork");var S={mainnet:"bg-emerald-500",testnet:"bg-amber-500",devnet:"bg-sky-500",local:"bg-zinc-400",custom:"bg-violet-500"},_={label:"",chainID:"",rpcEndpoint:"",apiEndpoint:""};function F({onChange:e,className:n=""}){let{network:a,networks:B,select:W,selectCustom:$}=D(),[d,f]=l.useState(false),[K,v]=l.useState(false),[s,m]=l.useState(_),[R,x]=l.useState(null),b=l.useRef(null);l.useEffect(()=>{if(!d)return;let t=o(p=>{b.current&&!b.current.contains(p.target)&&f(false);},"onDown");return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[d]);let L=o(t=>{if(t==="custom"){v(true);return}let p=W(t);f(false),v(false),e?.(p);},"pick"),j=o(()=>{let t={label:s.label.trim()||"Custom",networkID:Number(s.chainID),evmChainID:Number(s.chainID),rpcEndpoint:s.rpcEndpoint.trim(),apiEndpoint:s.apiEndpoint.trim(),currency:a.currency},p=w({...t});if(p){x(p);return}let J=$(t);x(null),m(_),f(false),v(false),e?.(J);},"saveCustom"),k="w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring";return jsxs("div",{ref:b,className:`relative ${n}`,children:[jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":d,onClick:()=>f(t=>!t),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 rounded-full ${S[a.env]}`,"aria-hidden":true}),jsx("span",{className:"max-w-[9rem] truncate",children:a.label}),jsx("svg",{className:`h-3 w-3 text-muted-foreground transition-transform ${d?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),d&&jsxs("div",{role:"menu",className:"absolute right-0 z-50 mt-1.5 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md",children:[B.map(t=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a.env===t.env,onClick:()=>L(t.env),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${S[t.env]}`,"aria-hidden":true}),jsxs("span",{className:"flex-1",children:[jsx("span",{className:"block font-medium",children:t.label}),jsxs("span",{className:"block text-[10px] text-muted-foreground",children:["chain ",t.evmChainID," \xB7 ",t.rpcEndpoint.replace(/^https?:\/\//,"")]})]}),a.env===t.env&&jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},t.env)),jsx("div",{className:"my-1 h-px bg-border",role:"separator"}),K?jsxs("form",{className:"space-y-1.5 p-2",onSubmit:t=>{t.preventDefault(),j();},children:[jsx("input",{className:k,placeholder:"Label (optional)",value:s.label,onChange:t=>m({...s,label:t.target.value})}),jsx("input",{className:k,placeholder:"Chain ID",inputMode:"numeric",value:s.chainID,onChange:t=>m({...s,chainID:t.target.value})}),jsx("input",{className:k,placeholder:"RPC endpoint (https://\u2026)",value:s.rpcEndpoint,onChange:t=>m({...s,rpcEndpoint:t.target.value})}),jsx("input",{className:k,placeholder:"API endpoint (https://\u2026)",value:s.apiEndpoint,onChange:t=>m({...s,apiEndpoint:t.target.value})}),R&&jsx("p",{className:"text-[10px] text-destructive",children:R}),jsxs("div",{className:"flex justify-end gap-1.5 pt-0.5",children:[jsx("button",{type:"button",onClick:()=>{v(false),x(null);},className:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Cancel"}),jsx("button",{type:"submit",className:"rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90",children:"Connect"})]})]}):jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a.env==="custom",onClick:()=>L("custom"),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${S.custom}`,"aria-hidden":true}),jsx("span",{className:"flex-1 font-medium",children:a.env==="custom"?a.label:"Custom\u2026"}),a.env==="custom"&&jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]})]})]})}o(F,"NetworkSwitcher");
3
- export{E as HANZO_NETWORKS,F as NetworkSwitcher,V as chainIdHex,Z as configureNetworks,I as getNetwork,Y as getNetworks,h as networkByEnv,M as selectCustomNetwork,T as selectNetwork,P as subscribeNetwork,D as useNetwork,w as validateCustomNetwork};
2
+ import*as l from'react';import {jsxs,jsx}from'react/jsx-runtime';var V=Object.defineProperty;var o=(e,n)=>V(e,"name",{value:n,configurable:true});var y=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36962,evmChainID:36962,rpcEndpoint:"https://rpc.testnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.testnet.hanzo.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.devnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.devnet.hanzo.network",currency:"AI"},{env:"local",label:"Hanzo Local",networkID:1337,evmChainID:1337,rpcEndpoint:"http://localhost:9630/v1/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],Z=o(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),N=o((e,n)=>e.find(p=>p.env===n),"networkByEnv"),O=/^https?:\/\/.+/;function f(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":O.test(e.rpcEndpoint)?O.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}o(f,"validateCustomNetwork");var C="hanzo.network",d=y,i={env:"mainnet"},A=false,I=new Set;function Y(e){if(e.length===0)throw new Error("configureNetworks: list must not be empty");d=e,x();}o(Y,"configureNetworks");var F=o(()=>d,"getNetworks");function g(){if(!(A||typeof window>"u")){A=true;try{let e=window.localStorage.getItem(C);if(e){let n=JSON.parse(e);n&&typeof n.env=="string"&&(i=n);}}catch{}window.addEventListener("storage",e=>{if(e.key===C)try{let n=e.newValue?JSON.parse(e.newValue):null;n&&typeof n.env=="string"&&(i=n,x());}catch{}});}}o(g,"load");function T(){if(!(typeof window>"u"))try{window.localStorage.setItem(C,JSON.stringify(i));}catch{}}o(T,"persist");function x(){for(let e of I)e();}o(x,"emit");function D(){return g(),i.env==="custom"&&i.custom?i.custom:N(d,i.env)??d[0]}o(D,"getNetwork");function M(e){g();let n=N(d,e);if(!n)throw new Error(`selectNetwork: no '${e}' network configured`);return i={env:e},T(),x(),n}o(M,"selectNetwork");function P(e){g();let n={...e,env:"custom"},p=f(n);if(p)throw new Error(p);return i={env:"custom",custom:n},T(),x(),n}o(P,"selectCustomNetwork");function _(e){return g(),I.add(e),()=>I.delete(e)}o(_,"subscribeNetwork");function S(){return {network:l.useSyncExternalStore(_,D,D),networks:d,select:M,selectCustom:P}}o(S,"useNetwork");var R={mainnet:"bg-emerald-500",testnet:"bg-amber-500",devnet:"bg-sky-500",local:"bg-zinc-400",custom:"bg-violet-500"},$={label:"",chainID:"",rpcEndpoint:"",apiEndpoint:""};function G({onChange:e,menuSide:n="bottom",className:p=""}){let{network:s,networks:B,select:W,selectCustom:K}=S(),[m,v]=l.useState(false),[j,k]=l.useState(false),[a,w]=l.useState($),[L,b]=l.useState(null),E=l.useRef(null);l.useEffect(()=>{if(!m)return;let t=o(u=>{E.current&&!E.current.contains(u.target)&&v(false);},"onDown");return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[m]);let z=o(t=>{if(t==="custom"){k(true);return}let u=W(t);v(false),k(false),e?.(u);},"pick"),J=o(()=>{let t={label:a.label.trim()||"Custom",networkID:Number(a.chainID),evmChainID:Number(a.chainID),rpcEndpoint:a.rpcEndpoint.trim(),apiEndpoint:a.apiEndpoint.trim(),currency:s.currency},u=f({...t});if(u){b(u);return}let U=K(t);b(null),w($),v(false),k(false),e?.(U);},"saveCustom"),h="w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring";return jsxs("div",{ref:E,className:`relative ${p}`,children:[jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":m,onClick:()=>v(t=>!t),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 rounded-full ${R[s.env]}`,"aria-hidden":true}),jsx("span",{className:"max-w-[9rem] truncate",children:s.label}),jsx("svg",{className:`h-3 w-3 text-muted-foreground transition-transform ${m?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),m&&jsxs("div",{role:"menu",className:`absolute right-0 z-50 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md ${n==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:[B.map(t=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.env===t.env,onClick:()=>z(t.env),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${R[t.env]}`,"aria-hidden":true}),jsxs("span",{className:"flex-1",children:[jsx("span",{className:"block font-medium",children:t.label}),jsxs("span",{className:"block text-[10px] text-muted-foreground",children:["chain ",t.evmChainID," \xB7 ",t.rpcEndpoint.replace(/^https?:\/\//,"")]})]}),s.env===t.env&&jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},t.env)),jsx("div",{className:"my-1 h-px bg-border",role:"separator"}),j?jsxs("form",{className:"space-y-1.5 p-2",onSubmit:t=>{t.preventDefault(),J();},children:[jsx("input",{className:h,placeholder:"Label (optional)",value:a.label,onChange:t=>w({...a,label:t.target.value})}),jsx("input",{className:h,placeholder:"Chain ID",inputMode:"numeric",value:a.chainID,onChange:t=>w({...a,chainID:t.target.value})}),jsx("input",{className:h,placeholder:"RPC endpoint (https://\u2026)",value:a.rpcEndpoint,onChange:t=>w({...a,rpcEndpoint:t.target.value})}),jsx("input",{className:h,placeholder:"API endpoint (https://\u2026)",value:a.apiEndpoint,onChange:t=>w({...a,apiEndpoint:t.target.value})}),L&&jsx("p",{className:"text-[10px] text-destructive",children:L}),jsxs("div",{className:"flex justify-end gap-1.5 pt-0.5",children:[jsx("button",{type:"button",onClick:()=>{k(false),b(null);},className:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Cancel"}),jsx("button",{type:"submit",className:"rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90",children:"Connect"})]})]}):jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.env==="custom",onClick:()=>z("custom"),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${R.custom}`,"aria-hidden":true}),jsx("span",{className:"flex-1 font-medium",children:s.env==="custom"?s.label:"Custom\u2026"}),s.env==="custom"&&jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]})]})]})}o(G,"NetworkSwitcher");
3
+ export{y as HANZO_NETWORKS,G as NetworkSwitcher,Z as chainIdHex,Y as configureNetworks,D as getNetwork,F as getNetworks,N as networkByEnv,P as selectCustomNetwork,M as selectNetwork,_ as subscribeNetwork,S as useNetwork,f as validateCustomNetwork};
@@ -2,7 +2,9 @@ import { type Network } from './networks';
2
2
  export interface NetworkSwitcherProps {
3
3
  /** Called after the selection changes (endpoint rewiring is automatic). */
4
4
  onChange?: (network: Network) => void;
5
+ /** Where the menu opens relative to the trigger (headers: bottom; footers: top). */
6
+ menuSide?: 'top' | 'bottom';
5
7
  className?: string;
6
8
  }
7
- export declare function NetworkSwitcher({ onChange, className }: NetworkSwitcherProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function NetworkSwitcher({ onChange, menuSide, className }: NetworkSwitcherProps): import("react/jsx-runtime").JSX.Element;
8
10
  //# sourceMappingURL=NetworkSwitcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkSwitcher.d.ts","sourceRoot":"","sources":["../../../src/network/NetworkSwitcher.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAyB,KAAK,OAAO,EAAmB,MAAM,YAAY,CAAA;AAWjF,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAWD,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,oBAAoB,2CAuLjF"}
1
+ {"version":3,"file":"NetworkSwitcher.d.ts","sourceRoot":"","sources":["../../../src/network/NetworkSwitcher.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAyB,KAAK,OAAO,EAAmB,MAAM,YAAY,CAAA;AAWjF,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,oFAAoF;IACpF,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAWD,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,QAAmB,EAAE,SAAc,EAAE,EAAE,oBAAoB,2CAuLtG"}
@@ -21,7 +21,7 @@ const ENV_DOT = {
21
21
  custom: 'bg-violet-500',
22
22
  };
23
23
  const EMPTY_DRAFT = { label: '', chainID: '', rpcEndpoint: '', apiEndpoint: '' };
24
- export function NetworkSwitcher({ onChange, className = '' }) {
24
+ export function NetworkSwitcher({ onChange, menuSide = 'bottom', className = '' }) {
25
25
  const { network, networks, select, selectCustom } = useNetwork();
26
26
  const [open, setOpen] = React.useState(false);
27
27
  const [customOpen, setCustomOpen] = React.useState(false);
@@ -70,7 +70,7 @@ export function NetworkSwitcher({ onChange, className = '' }) {
70
70
  onChange?.(next);
71
71
  };
72
72
  const field = 'w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring';
73
- return (_jsxs("div", { ref: ref, className: `relative ${className}`, children: [_jsxs("button", { type: "button", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((v) => !v), className: "flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${ENV_DOT[network.env]}`, "aria-hidden": true }), _jsx("span", { className: "max-w-[9rem] truncate", children: network.label }), _jsx("svg", { className: `h-3 w-3 text-muted-foreground transition-transform ${open ? 'rotate-180' : ''}`, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) })] }), open && (_jsxs("div", { role: "menu", className: "absolute right-0 z-50 mt-1.5 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md", children: [networks.map((n) => (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": network.env === n.env, onClick: () => pick(n.env), className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 shrink-0 rounded-full ${ENV_DOT[n.env]}`, "aria-hidden": true }), _jsxs("span", { className: "flex-1", children: [_jsx("span", { className: "block font-medium", children: n.label }), _jsxs("span", { className: "block text-[10px] text-muted-foreground", children: ["chain ", n.evmChainID, " \u00B7 ", n.rpcEndpoint.replace(/^https?:\/\//, '')] })] }), network.env === n.env && (_jsx("svg", { className: "h-3.5 w-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }))] }, n.env))), _jsx("div", { className: "my-1 h-px bg-border", role: "separator" }), !customOpen ? (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": network.env === 'custom', onClick: () => pick('custom'), className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 shrink-0 rounded-full ${ENV_DOT.custom}`, "aria-hidden": true }), _jsx("span", { className: "flex-1 font-medium", children: network.env === 'custom' ? network.label : 'Custom…' }), network.env === 'custom' && (_jsx("svg", { className: "h-3.5 w-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }))] })) : (_jsxs("form", { className: "space-y-1.5 p-2", onSubmit: (e) => {
73
+ return (_jsxs("div", { ref: ref, className: `relative ${className}`, children: [_jsxs("button", { type: "button", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((v) => !v), className: "flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${ENV_DOT[network.env]}`, "aria-hidden": true }), _jsx("span", { className: "max-w-[9rem] truncate", children: network.label }), _jsx("svg", { className: `h-3 w-3 text-muted-foreground transition-transform ${open ? 'rotate-180' : ''}`, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) })] }), open && (_jsxs("div", { role: "menu", className: `absolute right-0 z-50 w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md ${menuSide === 'top' ? 'bottom-full mb-1.5' : 'top-full mt-1.5'}`, children: [networks.map((n) => (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": network.env === n.env, onClick: () => pick(n.env), className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 shrink-0 rounded-full ${ENV_DOT[n.env]}`, "aria-hidden": true }), _jsxs("span", { className: "flex-1", children: [_jsx("span", { className: "block font-medium", children: n.label }), _jsxs("span", { className: "block text-[10px] text-muted-foreground", children: ["chain ", n.evmChainID, " \u00B7 ", n.rpcEndpoint.replace(/^https?:\/\//, '')] })] }), network.env === n.env && (_jsx("svg", { className: "h-3.5 w-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }))] }, n.env))), _jsx("div", { className: "my-1 h-px bg-border", role: "separator" }), !customOpen ? (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": network.env === 'custom', onClick: () => pick('custom'), className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 shrink-0 rounded-full ${ENV_DOT.custom}`, "aria-hidden": true }), _jsx("span", { className: "flex-1 font-medium", children: network.env === 'custom' ? network.label : 'Custom…' }), network.env === 'custom' && (_jsx("svg", { className: "h-3.5 w-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": true, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }))] })) : (_jsxs("form", { className: "space-y-1.5 p-2", onSubmit: (e) => {
74
74
  e.preventDefault();
75
75
  saveCustom();
76
76
  }, children: [_jsx("input", { className: field, placeholder: "Label (optional)", value: draft.label, onChange: (e) => setDraft({ ...draft, label: e.target.value }) }), _jsx("input", { className: field, placeholder: "Chain ID", inputMode: "numeric", value: draft.chainID, onChange: (e) => setDraft({ ...draft, chainID: e.target.value }) }), _jsx("input", { className: field, placeholder: "RPC endpoint (https://\u2026)", value: draft.rpcEndpoint, onChange: (e) => setDraft({ ...draft, rpcEndpoint: e.target.value }) }), _jsx("input", { className: field, placeholder: "API endpoint (https://\u2026)", value: draft.apiEndpoint, onChange: (e) => setDraft({ ...draft, apiEndpoint: e.target.value }) }), error && _jsx("p", { className: "text-[10px] text-destructive", children: error }), _jsxs("div", { className: "flex justify-end gap-1.5 pt-0.5", children: [_jsx("button", { type: "button", onClick: () => {
@@ -6,10 +6,12 @@
6
6
  * (env, label, networkID, evmChainID, rpcEndpoint, apiEndpoint)
7
7
  *
8
8
  * Hanzo is a sovereign L1 — its primary networkID EQUALS its EVM chainID,
9
- * one ID per environment. Public environments share the one cloud API
10
- * (api.hanzo.ai); RPC + explorer are per-env fabrics (hanzo.network /
11
- * hanzo-test.network / hanzo-dev.network). `local` is a self-hosted node;
12
- * `custom` is user-supplied endpoints.
9
+ * one ID per environment. IDs + RPC hosts come from genesis
10
+ * (lux/genesis/configs/hanzo-*), byte-identical to `hanzo network list`
11
+ * and the console selector: mainnet 36963, testnet 36962, devnet 36964;
12
+ * local is the 1337 localnet convention. Public environments share the
13
+ * one cloud API (api.hanzo.ai); RPC + explorer are per-env fabrics
14
+ * (rpc[.testnet|.devnet].hanzo.network). `custom` is user-supplied.
13
15
  */
14
16
  export type NetworkEnv = 'mainnet' | 'testnet' | 'devnet' | 'local' | 'custom';
15
17
  export interface Network {
@@ -1 +1 @@
1
- {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../../src/network/networks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE9E,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,2EAA2E;AAC3E,eAAO,MAAM,cAAc,EAAE,SAAS,OAAO,EAwC5C,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,MAA0C,CAAA;AAElF,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GACvB,UAAU,SAAS,OAAO,EAAE,EAC5B,KAAK,UAAU,KACd,OAAO,GAAG,SAAgD,CAAA;AAI7D,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK/D"}
1
+ {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../../src/network/networks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE9E,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,2EAA2E;AAC3E,eAAO,MAAM,cAAc,EAAE,SAAS,OAAO,EAwC5C,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,MAA0C,CAAA;AAElF,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GACvB,UAAU,SAAS,OAAO,EAAE,EAC5B,KAAK,UAAU,KACd,OAAO,GAAG,SAAgD,CAAA;AAI7D,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK/D"}
@@ -6,10 +6,12 @@
6
6
  * (env, label, networkID, evmChainID, rpcEndpoint, apiEndpoint)
7
7
  *
8
8
  * Hanzo is a sovereign L1 — its primary networkID EQUALS its EVM chainID,
9
- * one ID per environment. Public environments share the one cloud API
10
- * (api.hanzo.ai); RPC + explorer are per-env fabrics (hanzo.network /
11
- * hanzo-test.network / hanzo-dev.network). `local` is a self-hosted node;
12
- * `custom` is user-supplied endpoints.
9
+ * one ID per environment. IDs + RPC hosts come from genesis
10
+ * (lux/genesis/configs/hanzo-*), byte-identical to `hanzo network list`
11
+ * and the console selector: mainnet 36963, testnet 36962, devnet 36964;
12
+ * local is the 1337 localnet convention. Public environments share the
13
+ * one cloud API (api.hanzo.ai); RPC + explorer are per-env fabrics
14
+ * (rpc[.testnet|.devnet].hanzo.network). `custom` is user-supplied.
13
15
  */
14
16
  /** Canonical hanzo.network environments (mirrors `hanzo network list`). */
15
17
  export const HANZO_NETWORKS = [
@@ -26,29 +28,29 @@ export const HANZO_NETWORKS = [
26
28
  {
27
29
  env: 'testnet',
28
30
  label: 'Hanzo Testnet',
29
- networkID: 36964,
30
- evmChainID: 36964,
31
- rpcEndpoint: 'https://rpc.hanzo-test.network',
31
+ networkID: 36962,
32
+ evmChainID: 36962,
33
+ rpcEndpoint: 'https://rpc.testnet.hanzo.network',
32
34
  apiEndpoint: 'https://api.hanzo.ai',
33
- explorerEndpoint: 'https://explorer.hanzo-test.network',
35
+ explorerEndpoint: 'https://explorer.testnet.hanzo.network',
34
36
  currency: 'AI',
35
37
  },
36
38
  {
37
39
  env: 'devnet',
38
40
  label: 'Hanzo Devnet',
39
- networkID: 36965,
40
- evmChainID: 36965,
41
- rpcEndpoint: 'https://rpc.hanzo-dev.network',
41
+ networkID: 36964,
42
+ evmChainID: 36964,
43
+ rpcEndpoint: 'https://rpc.devnet.hanzo.network',
42
44
  apiEndpoint: 'https://api.hanzo.ai',
43
- explorerEndpoint: 'https://explorer.hanzo-dev.network',
45
+ explorerEndpoint: 'https://explorer.devnet.hanzo.network',
44
46
  currency: 'AI',
45
47
  },
46
48
  {
47
49
  env: 'local',
48
- label: 'Local',
49
- networkID: 31337,
50
- evmChainID: 31337,
51
- rpcEndpoint: 'http://localhost:9650/ext/bc/C/rpc',
50
+ label: 'Hanzo Local',
51
+ networkID: 1337,
52
+ evmChainID: 1337,
53
+ rpcEndpoint: 'http://localhost:9630/v1/bc/C/rpc',
52
54
  apiEndpoint: 'http://localhost:3690',
53
55
  currency: 'AI',
54
56
  },
@@ -3,7 +3,9 @@ export interface WalletMenuProps {
3
3
  adapter: WalletAdapter;
4
4
  /** Connect (auto-provision on custodial surfaces) on first mount. */
5
5
  autoConnect?: boolean;
6
+ /** Where the menu opens relative to the trigger (headers: bottom; footers: top). */
7
+ menuSide?: 'top' | 'bottom';
6
8
  className?: string;
7
9
  }
8
- export declare function WalletMenu({ adapter, autoConnect, className }: WalletMenuProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function WalletMenu({ adapter, autoConnect, menuSide, className }: WalletMenuProps): import("react/jsx-runtime").JSX.Element;
9
11
  //# sourceMappingURL=WalletMenu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletMenu.d.ts","sourceRoot":"","sources":["../../../src/wallet/WalletMenu.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAgB,KAAK,aAAa,EAAoB,MAAM,SAAS,CAAA;AAU5E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,aAAa,CAAA;IACtB,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,WAAmB,EAAE,SAAc,EAAE,EAAE,eAAe,2CAgL3F"}
1
+ {"version":3,"file":"WalletMenu.d.ts","sourceRoot":"","sources":["../../../src/wallet/WalletMenu.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAgB,KAAK,aAAa,EAAoB,MAAM,SAAS,CAAA;AAU5E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,aAAa,CAAA;IACtB,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,WAAmB,EAAE,QAAmB,EAAE,SAAc,EAAE,EAAE,eAAe,2CAgLhH"}
@@ -12,7 +12,7 @@ import { shortAddress } from './types';
12
12
  function useWalletState(adapter) {
13
13
  return React.useSyncExternalStore(React.useCallback((cb) => adapter.subscribe(cb), [adapter]), adapter.getState, adapter.getState);
14
14
  }
15
- export function WalletMenu({ adapter, autoConnect = false, className = '' }) {
15
+ export function WalletMenu({ adapter, autoConnect = false, menuSide = 'bottom', className = '' }) {
16
16
  const state = useWalletState(adapter);
17
17
  const { network } = useNetwork();
18
18
  const [open, setOpen] = React.useState(false);
@@ -56,7 +56,7 @@ export function WalletMenu({ adapter, autoConnect = false, className = '' }) {
56
56
  }, disabled: state.status === 'connecting', className: "flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-60", children: [_jsx(WalletIcon, { className: "h-3.5 w-3.5" }), state.status === 'connecting' ? 'Connecting…' : 'Connect Wallet'] }), state.status === 'error' && state.error && (_jsx("p", { className: "absolute right-0 z-50 mt-1 w-56 rounded-md border border-border bg-popover p-2 text-[10px] text-destructive shadow-md", children: state.error }))] }));
57
57
  }
58
58
  const { account } = state;
59
- return (_jsxs("div", { ref: ref, className: `relative ${className}`, children: [_jsxs("button", { type: "button", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((v) => !v), className: "flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${mismatch ? 'bg-amber-500' : 'bg-emerald-500'}`, "aria-hidden": true }), _jsx("span", { className: "font-mono", children: shortAddress(account.address) }), account.pqPublicKey && (_jsx("span", { className: "rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500", children: "PQ" }))] }), open && (_jsxs("div", { role: "menu", className: "absolute right-0 z-50 mt-1.5 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md", children: [_jsxs("div", { className: "px-1 pb-2", children: [account.label && _jsx("p", { className: "text-xs font-semibold", children: account.label }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx("code", { className: "truncate font-mono text-[11px] text-muted-foreground", children: account.address }), _jsx("button", { type: "button", onClick: () => copy(account.address), className: "shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground", children: copied ? 'Copied' : 'Copy' })] })] }), account.pqPublicKey && (_jsxs("div", { className: "border-t border-border px-1 py-2", children: [_jsxs("p", { className: "flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: ["Post-quantum identity", _jsx("span", { className: "rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500", children: "ML-DSA-65" })] }), _jsx("code", { className: "block truncate font-mono text-[10px] text-muted-foreground", children: account.pqPublicKey }), account.pqNodeId && (_jsx("code", { className: "block truncate font-mono text-[10px] text-muted-foreground", children: account.pqNodeId }))] })), _jsxs("div", { className: "border-t border-border px-1 py-2 text-[11px]", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Network" }), _jsxs("span", { children: [network.label, " \u00B7 ", network.evmChainID] })] }), mismatch && adapter.ensureNetwork && (_jsxs("button", { type: "button", onClick: () => {
59
+ return (_jsxs("div", { ref: ref, className: `relative ${className}`, children: [_jsxs("button", { type: "button", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((v) => !v), className: "flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${mismatch ? 'bg-amber-500' : 'bg-emerald-500'}`, "aria-hidden": true }), _jsx("span", { className: "font-mono", children: shortAddress(account.address) }), account.pqPublicKey && (_jsx("span", { className: "rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500", children: "PQ" }))] }), open && (_jsxs("div", { role: "menu", className: `absolute right-0 z-50 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md ${menuSide === 'top' ? 'bottom-full mb-1.5' : 'top-full mt-1.5'}`, children: [_jsxs("div", { className: "px-1 pb-2", children: [account.label && _jsx("p", { className: "text-xs font-semibold", children: account.label }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx("code", { className: "truncate font-mono text-[11px] text-muted-foreground", children: account.address }), _jsx("button", { type: "button", onClick: () => copy(account.address), className: "shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground", children: copied ? 'Copied' : 'Copy' })] })] }), account.pqPublicKey && (_jsxs("div", { className: "border-t border-border px-1 py-2", children: [_jsxs("p", { className: "flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: ["Post-quantum identity", _jsx("span", { className: "rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500", children: "ML-DSA-65" })] }), _jsx("code", { className: "block truncate font-mono text-[10px] text-muted-foreground", children: account.pqPublicKey }), account.pqNodeId && (_jsx("code", { className: "block truncate font-mono text-[10px] text-muted-foreground", children: account.pqNodeId }))] })), _jsxs("div", { className: "border-t border-border px-1 py-2 text-[11px]", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Network" }), _jsxs("span", { children: [network.label, " \u00B7 ", network.evmChainID] })] }), mismatch && adapter.ensureNetwork && (_jsxs("button", { type: "button", onClick: () => {
60
60
  adapter.ensureNetwork?.(network).catch(() => {
61
61
  // Wallet refused the switch; state stays as-is.
62
62
  });
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- 'use strict';var d=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var d__namespace=/*#__PURE__*/_interopNamespace(d);var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:true});function g(e){return e.length>12?`${e.slice(0,6)}\u2026${e.slice(-4)}`:e}n(g,"shortAddress");var R=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.hanzo-test.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-test.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36965,evmChainID:36965,rpcEndpoint:"https://rpc.hanzo-dev.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-dev.network",currency:"AI"},{env:"local",label:"Local",networkID:31337,evmChainID:31337,rpcEndpoint:"http://localhost:9650/ext/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],N=n(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),k=n((e,t)=>e.find(c=>c.env===t),"networkByEnv"),D=/^https?:\/\/.+/;function P(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":D.test(e.rpcEndpoint)?D.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}n(P,"validateCustomNetwork");var y="hanzo.network",h=R,w={env:"mainnet"},z=false,E=new Set;function b(){if(!(z||typeof window>"u")){z=true;try{let e=window.localStorage.getItem(y);if(e){let t=JSON.parse(e);t&&typeof t.env=="string"&&(w=t);}}catch{}window.addEventListener("storage",e=>{if(e.key===y)try{let t=e.newValue?JSON.parse(e.newValue):null;t&&typeof t.env=="string"&&(w=t,I());}catch{}});}}n(b,"load");function H(){if(!(typeof window>"u"))try{window.localStorage.setItem(y,JSON.stringify(w));}catch{}}n(H,"persist");function I(){for(let e of E)e();}n(I,"emit");function x(){return b(),w.env==="custom"&&w.custom?w.custom:k(h,w.env)??h[0]}n(x,"getNetwork");function $(e){b();let t=k(h,e);if(!t)throw new Error(`selectNetwork: no '${e}' network configured`);return w={env:e},H(),I(),t}n($,"selectNetwork");function j(e){b();let t={...e,env:"custom"},c=P(t);if(c)throw new Error(c);return w={env:"custom",custom:t},H(),I(),t}n(j,"selectCustomNetwork");function K(e){return b(),E.add(e),()=>E.delete(e)}n(K,"subscribeNetwork");function M(){return {network:d__namespace.useSyncExternalStore(K,x,x),networks:h,select:$,selectCustom:j}}n(M,"useNetwork");function S(){return typeof window>"u"?null:window.ethereum??null}n(S,"injected");var T=n(()=>S()!==null,"walletAvailable");async function C(e,t){try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:N(t)}]});}catch(c){let o=c?.code;if(o!==4902&&o!==-32603)throw c;await e.request({method:"wallet_addEthereumChain",params:[{chainId:N(t),chainName:t.label,rpcUrls:[t.rpcEndpoint],nativeCurrency:{name:t.currency,symbol:t.currency,decimals:18},...t.explorerEndpoint?{blockExplorerUrls:[t.explorerEndpoint]}:{}}]});}}n(C,"ensureEvmNetwork");function U(e={}){let t=e.getNetwork??x,c=new Set,o={status:"disconnected",account:null,chainId:null,error:null},p=false,l=n(a=>{o={...o,...a};for(let r of c)r();},"set"),v=n(a=>{p||!a.on||(p=true,a.on("accountsChanged",(...r)=>{let m=r[0];m?.length?l({status:"ready",account:{address:m[0]},error:null}):l({status:"disconnected",account:null});}),a.on("chainChanged",(...r)=>{l({chainId:Number.parseInt(String(r[0]),16)||null});}));},"wire");return {getState:n(()=>o,"getState"),subscribe(a){return c.add(a),()=>c.delete(a)},async connect(){let a=S();if(!a)throw l({status:"error",error:"No browser wallet detected. Install MetaMask or a compatible wallet."}),new Error("No browser wallet detected.");l({status:"connecting",error:null});try{let r=await a.request({method:"eth_requestAccounts"});if(!r?.length)throw new Error("No accounts authorized.");await C(a,t());let m=await a.request({method:"eth_chainId"});v(a),l({status:"ready",account:{address:r[0]},chainId:Number.parseInt(m,16)||null});}catch(r){throw l({status:"error",error:r instanceof Error?r.message:String(r)}),r}},disconnect(){l({status:"disconnected",account:null,chainId:null,error:null});},async ensureNetwork(a){let r=S();if(!r)throw new Error("No browser wallet detected.");await C(r,a);}}}n(U,"injectedEvmAdapter");function V(e){return d__namespace.useSyncExternalStore(d__namespace.useCallback(t=>e.subscribe(t),[e]),e.getState,e.getState)}n(V,"useWalletState");function B({adapter:e,autoConnect:t=false,className:c=""}){let o=V(e),{network:p}=M(),[l,v]=d__namespace.useState(false),[a,r]=d__namespace.useState(false),m=d__namespace.useRef(null),A=d__namespace.useRef(false);d__namespace.useEffect(()=>{!t||A.current||o.status!=="disconnected"||(A.current=true,e.connect().catch(()=>{}));},[t,e,o.status]),d__namespace.useEffect(()=>{if(!l)return;let f=n(L=>{m.current&&!m.current.contains(L.target)&&v(false);},"onDown");return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]);let O=n(async f=>{try{await navigator.clipboard.writeText(f),r(!0),window.setTimeout(()=>r(!1),1500);}catch{}},"copy"),W=o.status==="ready"&&o.chainId!==null&&o.chainId!==p.evmChainID;if(o.status!=="ready"||!o.account)return jsxRuntime.jsxs("div",{ref:m,className:`relative ${c}`,children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.connect().catch(()=>{});},disabled:o.status==="connecting",className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-60",children:[jsxRuntime.jsx(J,{className:"h-3.5 w-3.5"}),o.status==="connecting"?"Connecting\u2026":"Connect Wallet"]}),o.status==="error"&&o.error&&jsxRuntime.jsx("p",{className:"absolute right-0 z-50 mt-1 w-56 rounded-md border border-border bg-popover p-2 text-[10px] text-destructive shadow-md",children:o.error})]});let{account:u}=o;return jsxRuntime.jsxs("div",{ref:m,className:`relative ${c}`,children:[jsxRuntime.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":l,onClick:()=>v(f=>!f),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 rounded-full ${W?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"font-mono",children:g(u.address)}),u.pqPublicKey&&jsxRuntime.jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500",children:"PQ"})]}),l&&jsxRuntime.jsxs("div",{role:"menu",className:"absolute right-0 z-50 mt-1.5 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md",children:[jsxRuntime.jsxs("div",{className:"px-1 pb-2",children:[u.label&&jsxRuntime.jsx("p",{className:"text-xs font-semibold",children:u.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("code",{className:"truncate font-mono text-[11px] text-muted-foreground",children:u.address}),jsxRuntime.jsx("button",{type:"button",onClick:()=>O(u.address),className:"shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:a?"Copied":"Copy"})]})]}),u.pqPublicKey&&jsxRuntime.jsxs("div",{className:"border-t border-border px-1 py-2",children:[jsxRuntime.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Post-quantum identity",jsxRuntime.jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500",children:"ML-DSA-65"})]}),jsxRuntime.jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqPublicKey}),u.pqNodeId&&jsxRuntime.jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqNodeId})]}),jsxRuntime.jsxs("div",{className:"border-t border-border px-1 py-2 text-[11px]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Network"}),jsxRuntime.jsxs("span",{children:[p.label," \xB7 ",p.evmChainID]})]}),W&&e.ensureNetwork&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.ensureNetwork?.(p).catch(()=>{});},className:"mt-1.5 w-full rounded-md bg-amber-500/15 px-2 py-1 text-[11px] font-medium text-amber-600 hover:bg-amber-500/25",children:["Wallet is on chain ",o.chainId," \u2014 switch to ",p.label]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-border px-1 pt-2",children:[p.explorerEndpoint?jsxRuntime.jsx("a",{href:`${p.explorerEndpoint.replace(/\/+$/,"")}/address/${u.address}`,target:"_blank",rel:"noreferrer",className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Explorer \u2197"}):jsxRuntime.jsx("span",{}),e.disconnect&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(false),e.disconnect?.();},className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Disconnect"})]})]})]})}n(B,"WalletMenu");function J({className:e=""}){return jsxRuntime.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"})})}n(J,"WalletIcon");
3
- exports.WalletMenu=B;exports.ensureEvmNetwork=C;exports.injectedEvmAdapter=U;exports.shortAddress=g;exports.walletAvailable=T;
2
+ 'use strict';var d=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var d__namespace=/*#__PURE__*/_interopNamespace(d);var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:true});function N(e){return e.length>12?`${e.slice(0,6)}\u2026${e.slice(-4)}`:e}n(N,"shortAddress");var z=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36962,evmChainID:36962,rpcEndpoint:"https://rpc.testnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.testnet.hanzo.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.devnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.devnet.hanzo.network",currency:"AI"},{env:"local",label:"Hanzo Local",networkID:1337,evmChainID:1337,rpcEndpoint:"http://localhost:9630/v1/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],k=n(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),y=n((e,t)=>e.find(l=>l.env===t),"networkByEnv"),R=/^https?:\/\/.+/;function P(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":R.test(e.rpcEndpoint)?R.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}n(P,"validateCustomNetwork");var E="hanzo.network",h=z,m={env:"mainnet"},H=false,I=new Set;function g(){if(!(H||typeof window>"u")){H=true;try{let e=window.localStorage.getItem(E);if(e){let t=JSON.parse(e);t&&typeof t.env=="string"&&(m=t);}}catch{}window.addEventListener("storage",e=>{if(e.key===E)try{let t=e.newValue?JSON.parse(e.newValue):null;t&&typeof t.env=="string"&&(m=t,S());}catch{}});}}n(g,"load");function M(){if(!(typeof window>"u"))try{window.localStorage.setItem(E,JSON.stringify(m));}catch{}}n(M,"persist");function S(){for(let e of I)e();}n(S,"emit");function x(){return g(),m.env==="custom"&&m.custom?m.custom:y(h,m.env)??h[0]}n(x,"getNetwork");function j(e){g();let t=y(h,e);if(!t)throw new Error(`selectNetwork: no '${e}' network configured`);return m={env:e},M(),S(),t}n(j,"selectNetwork");function K(e){g();let t={...e,env:"custom"},l=P(t);if(l)throw new Error(l);return m={env:"custom",custom:t},M(),S(),t}n(K,"selectCustomNetwork");function T(e){return g(),I.add(e),()=>I.delete(e)}n(T,"subscribeNetwork");function O(){return {network:d__namespace.useSyncExternalStore(T,x,x),networks:h,select:j,selectCustom:K}}n(O,"useNetwork");function C(){return typeof window>"u"?null:window.ethereum??null}n(C,"injected");var U=n(()=>C()!==null,"walletAvailable");async function A(e,t){try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:k(t)}]});}catch(l){let p=l?.code;if(p!==4902&&p!==-32603)throw l;await e.request({method:"wallet_addEthereumChain",params:[{chainId:k(t),chainName:t.label,rpcUrls:[t.rpcEndpoint],nativeCurrency:{name:t.currency,symbol:t.currency,decimals:18},...t.explorerEndpoint?{blockExplorerUrls:[t.explorerEndpoint]}:{}}]});}}n(A,"ensureEvmNetwork");function V(e={}){let t=e.getNetwork??x,l=new Set,p={status:"disconnected",account:null,chainId:null,error:null},a=false,c=n(o=>{p={...p,...o};for(let r of l)r();},"set"),f=n(o=>{a||!o.on||(a=true,o.on("accountsChanged",(...r)=>{let w=r[0];w?.length?c({status:"ready",account:{address:w[0]},error:null}):c({status:"disconnected",account:null});}),o.on("chainChanged",(...r)=>{c({chainId:Number.parseInt(String(r[0]),16)||null});}));},"wire");return {getState:n(()=>p,"getState"),subscribe(o){return l.add(o),()=>l.delete(o)},async connect(){let o=C();if(!o)throw c({status:"error",error:"No browser wallet detected. Install MetaMask or a compatible wallet."}),new Error("No browser wallet detected.");c({status:"connecting",error:null});try{let r=await o.request({method:"eth_requestAccounts"});if(!r?.length)throw new Error("No accounts authorized.");await A(o,t());let w=await o.request({method:"eth_chainId"});f(o),c({status:"ready",account:{address:r[0]},chainId:Number.parseInt(w,16)||null});}catch(r){throw c({status:"error",error:r instanceof Error?r.message:String(r)}),r}},disconnect(){c({status:"disconnected",account:null,chainId:null,error:null});},async ensureNetwork(o){let r=C();if(!r)throw new Error("No browser wallet detected.");await A(r,o);}}}n(V,"injectedEvmAdapter");function B(e){return d__namespace.useSyncExternalStore(d__namespace.useCallback(t=>e.subscribe(t),[e]),e.getState,e.getState)}n(B,"useWalletState");function J({adapter:e,autoConnect:t=false,menuSide:l="bottom",className:p=""}){let a=B(e),{network:c}=O(),[f,o]=d__namespace.useState(false),[r,w]=d__namespace.useState(false),b=d__namespace.useRef(null),W=d__namespace.useRef(false);d__namespace.useEffect(()=>{!t||W.current||a.status!=="disconnected"||(W.current=true,e.connect().catch(()=>{}));},[t,e,a.status]),d__namespace.useEffect(()=>{if(!f)return;let v=n($=>{b.current&&!b.current.contains($.target)&&o(false);},"onDown");return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[f]);let L=n(async v=>{try{await navigator.clipboard.writeText(v),w(!0),window.setTimeout(()=>w(!1),1500);}catch{}},"copy"),D=a.status==="ready"&&a.chainId!==null&&a.chainId!==c.evmChainID;if(a.status!=="ready"||!a.account)return jsxRuntime.jsxs("div",{ref:b,className:`relative ${p}`,children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.connect().catch(()=>{});},disabled:a.status==="connecting",className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-60",children:[jsxRuntime.jsx(Z,{className:"h-3.5 w-3.5"}),a.status==="connecting"?"Connecting\u2026":"Connect Wallet"]}),a.status==="error"&&a.error&&jsxRuntime.jsx("p",{className:"absolute right-0 z-50 mt-1 w-56 rounded-md border border-border bg-popover p-2 text-[10px] text-destructive shadow-md",children:a.error})]});let{account:u}=a;return jsxRuntime.jsxs("div",{ref:b,className:`relative ${p}`,children:[jsxRuntime.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":f,onClick:()=>o(v=>!v),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsxRuntime.jsx("span",{className:`h-2 w-2 rounded-full ${D?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":true}),jsxRuntime.jsx("span",{className:"font-mono",children:N(u.address)}),u.pqPublicKey&&jsxRuntime.jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500",children:"PQ"})]}),f&&jsxRuntime.jsxs("div",{role:"menu",className:`absolute right-0 z-50 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md ${l==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:[jsxRuntime.jsxs("div",{className:"px-1 pb-2",children:[u.label&&jsxRuntime.jsx("p",{className:"text-xs font-semibold",children:u.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("code",{className:"truncate font-mono text-[11px] text-muted-foreground",children:u.address}),jsxRuntime.jsx("button",{type:"button",onClick:()=>L(u.address),className:"shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:r?"Copied":"Copy"})]})]}),u.pqPublicKey&&jsxRuntime.jsxs("div",{className:"border-t border-border px-1 py-2",children:[jsxRuntime.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Post-quantum identity",jsxRuntime.jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500",children:"ML-DSA-65"})]}),jsxRuntime.jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqPublicKey}),u.pqNodeId&&jsxRuntime.jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqNodeId})]}),jsxRuntime.jsxs("div",{className:"border-t border-border px-1 py-2 text-[11px]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Network"}),jsxRuntime.jsxs("span",{children:[c.label," \xB7 ",c.evmChainID]})]}),D&&e.ensureNetwork&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.ensureNetwork?.(c).catch(()=>{});},className:"mt-1.5 w-full rounded-md bg-amber-500/15 px-2 py-1 text-[11px] font-medium text-amber-600 hover:bg-amber-500/25",children:["Wallet is on chain ",a.chainId," \u2014 switch to ",c.label]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-border px-1 pt-2",children:[c.explorerEndpoint?jsxRuntime.jsx("a",{href:`${c.explorerEndpoint.replace(/\/+$/,"")}/address/${u.address}`,target:"_blank",rel:"noreferrer",className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Explorer \u2197"}):jsxRuntime.jsx("span",{}),e.disconnect&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{o(false),e.disconnect?.();},className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Disconnect"})]})]})]})}n(J,"WalletMenu");function Z({className:e=""}){return jsxRuntime.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,"aria-hidden":true,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"})})}n(Z,"WalletIcon");
3
+ exports.WalletMenu=J;exports.ensureEvmNetwork=A;exports.injectedEvmAdapter=V;exports.shortAddress=N;exports.walletAvailable=U;
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import*as d from'react';import {jsxs,jsx}from'react/jsx-runtime';var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:true});function g(e){return e.length>12?`${e.slice(0,6)}\u2026${e.slice(-4)}`:e}n(g,"shortAddress");var R=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.hanzo-test.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-test.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36965,evmChainID:36965,rpcEndpoint:"https://rpc.hanzo-dev.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo-dev.network",currency:"AI"},{env:"local",label:"Local",networkID:31337,evmChainID:31337,rpcEndpoint:"http://localhost:9650/ext/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],N=n(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),k=n((e,t)=>e.find(c=>c.env===t),"networkByEnv"),D=/^https?:\/\/.+/;function P(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":D.test(e.rpcEndpoint)?D.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}n(P,"validateCustomNetwork");var y="hanzo.network",h=R,w={env:"mainnet"},z=false,E=new Set;function b(){if(!(z||typeof window>"u")){z=true;try{let e=window.localStorage.getItem(y);if(e){let t=JSON.parse(e);t&&typeof t.env=="string"&&(w=t);}}catch{}window.addEventListener("storage",e=>{if(e.key===y)try{let t=e.newValue?JSON.parse(e.newValue):null;t&&typeof t.env=="string"&&(w=t,I());}catch{}});}}n(b,"load");function H(){if(!(typeof window>"u"))try{window.localStorage.setItem(y,JSON.stringify(w));}catch{}}n(H,"persist");function I(){for(let e of E)e();}n(I,"emit");function x(){return b(),w.env==="custom"&&w.custom?w.custom:k(h,w.env)??h[0]}n(x,"getNetwork");function $(e){b();let t=k(h,e);if(!t)throw new Error(`selectNetwork: no '${e}' network configured`);return w={env:e},H(),I(),t}n($,"selectNetwork");function j(e){b();let t={...e,env:"custom"},c=P(t);if(c)throw new Error(c);return w={env:"custom",custom:t},H(),I(),t}n(j,"selectCustomNetwork");function K(e){return b(),E.add(e),()=>E.delete(e)}n(K,"subscribeNetwork");function M(){return {network:d.useSyncExternalStore(K,x,x),networks:h,select:$,selectCustom:j}}n(M,"useNetwork");function S(){return typeof window>"u"?null:window.ethereum??null}n(S,"injected");var T=n(()=>S()!==null,"walletAvailable");async function C(e,t){try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:N(t)}]});}catch(c){let o=c?.code;if(o!==4902&&o!==-32603)throw c;await e.request({method:"wallet_addEthereumChain",params:[{chainId:N(t),chainName:t.label,rpcUrls:[t.rpcEndpoint],nativeCurrency:{name:t.currency,symbol:t.currency,decimals:18},...t.explorerEndpoint?{blockExplorerUrls:[t.explorerEndpoint]}:{}}]});}}n(C,"ensureEvmNetwork");function U(e={}){let t=e.getNetwork??x,c=new Set,o={status:"disconnected",account:null,chainId:null,error:null},p=false,l=n(a=>{o={...o,...a};for(let r of c)r();},"set"),v=n(a=>{p||!a.on||(p=true,a.on("accountsChanged",(...r)=>{let m=r[0];m?.length?l({status:"ready",account:{address:m[0]},error:null}):l({status:"disconnected",account:null});}),a.on("chainChanged",(...r)=>{l({chainId:Number.parseInt(String(r[0]),16)||null});}));},"wire");return {getState:n(()=>o,"getState"),subscribe(a){return c.add(a),()=>c.delete(a)},async connect(){let a=S();if(!a)throw l({status:"error",error:"No browser wallet detected. Install MetaMask or a compatible wallet."}),new Error("No browser wallet detected.");l({status:"connecting",error:null});try{let r=await a.request({method:"eth_requestAccounts"});if(!r?.length)throw new Error("No accounts authorized.");await C(a,t());let m=await a.request({method:"eth_chainId"});v(a),l({status:"ready",account:{address:r[0]},chainId:Number.parseInt(m,16)||null});}catch(r){throw l({status:"error",error:r instanceof Error?r.message:String(r)}),r}},disconnect(){l({status:"disconnected",account:null,chainId:null,error:null});},async ensureNetwork(a){let r=S();if(!r)throw new Error("No browser wallet detected.");await C(r,a);}}}n(U,"injectedEvmAdapter");function V(e){return d.useSyncExternalStore(d.useCallback(t=>e.subscribe(t),[e]),e.getState,e.getState)}n(V,"useWalletState");function B({adapter:e,autoConnect:t=false,className:c=""}){let o=V(e),{network:p}=M(),[l,v]=d.useState(false),[a,r]=d.useState(false),m=d.useRef(null),A=d.useRef(false);d.useEffect(()=>{!t||A.current||o.status!=="disconnected"||(A.current=true,e.connect().catch(()=>{}));},[t,e,o.status]),d.useEffect(()=>{if(!l)return;let f=n(L=>{m.current&&!m.current.contains(L.target)&&v(false);},"onDown");return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]);let O=n(async f=>{try{await navigator.clipboard.writeText(f),r(!0),window.setTimeout(()=>r(!1),1500);}catch{}},"copy"),W=o.status==="ready"&&o.chainId!==null&&o.chainId!==p.evmChainID;if(o.status!=="ready"||!o.account)return jsxs("div",{ref:m,className:`relative ${c}`,children:[jsxs("button",{type:"button",onClick:()=>{e.connect().catch(()=>{});},disabled:o.status==="connecting",className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-60",children:[jsx(J,{className:"h-3.5 w-3.5"}),o.status==="connecting"?"Connecting\u2026":"Connect Wallet"]}),o.status==="error"&&o.error&&jsx("p",{className:"absolute right-0 z-50 mt-1 w-56 rounded-md border border-border bg-popover p-2 text-[10px] text-destructive shadow-md",children:o.error})]});let{account:u}=o;return jsxs("div",{ref:m,className:`relative ${c}`,children:[jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":l,onClick:()=>v(f=>!f),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 rounded-full ${W?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":true}),jsx("span",{className:"font-mono",children:g(u.address)}),u.pqPublicKey&&jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500",children:"PQ"})]}),l&&jsxs("div",{role:"menu",className:"absolute right-0 z-50 mt-1.5 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md",children:[jsxs("div",{className:"px-1 pb-2",children:[u.label&&jsx("p",{className:"text-xs font-semibold",children:u.label}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("code",{className:"truncate font-mono text-[11px] text-muted-foreground",children:u.address}),jsx("button",{type:"button",onClick:()=>O(u.address),className:"shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:a?"Copied":"Copy"})]})]}),u.pqPublicKey&&jsxs("div",{className:"border-t border-border px-1 py-2",children:[jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Post-quantum identity",jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500",children:"ML-DSA-65"})]}),jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqPublicKey}),u.pqNodeId&&jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqNodeId})]}),jsxs("div",{className:"border-t border-border px-1 py-2 text-[11px]",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-muted-foreground",children:"Network"}),jsxs("span",{children:[p.label," \xB7 ",p.evmChainID]})]}),W&&e.ensureNetwork&&jsxs("button",{type:"button",onClick:()=>{e.ensureNetwork?.(p).catch(()=>{});},className:"mt-1.5 w-full rounded-md bg-amber-500/15 px-2 py-1 text-[11px] font-medium text-amber-600 hover:bg-amber-500/25",children:["Wallet is on chain ",o.chainId," \u2014 switch to ",p.label]})]}),jsxs("div",{className:"flex items-center justify-between border-t border-border px-1 pt-2",children:[p.explorerEndpoint?jsx("a",{href:`${p.explorerEndpoint.replace(/\/+$/,"")}/address/${u.address}`,target:"_blank",rel:"noreferrer",className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Explorer \u2197"}):jsx("span",{}),e.disconnect&&jsx("button",{type:"button",onClick:()=>{v(false),e.disconnect?.();},className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Disconnect"})]})]})]})}n(B,"WalletMenu");function J({className:e=""}){return jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"})})}n(J,"WalletIcon");
3
- export{B as WalletMenu,C as ensureEvmNetwork,U as injectedEvmAdapter,g as shortAddress,T as walletAvailable};
2
+ import*as d from'react';import {jsxs,jsx}from'react/jsx-runtime';var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:true});function N(e){return e.length>12?`${e.slice(0,6)}\u2026${e.slice(-4)}`:e}n(N,"shortAddress");var z=[{env:"mainnet",label:"Hanzo Mainnet",networkID:36963,evmChainID:36963,rpcEndpoint:"https://rpc.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.hanzo.network",currency:"AI"},{env:"testnet",label:"Hanzo Testnet",networkID:36962,evmChainID:36962,rpcEndpoint:"https://rpc.testnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.testnet.hanzo.network",currency:"AI"},{env:"devnet",label:"Hanzo Devnet",networkID:36964,evmChainID:36964,rpcEndpoint:"https://rpc.devnet.hanzo.network",apiEndpoint:"https://api.hanzo.ai",explorerEndpoint:"https://explorer.devnet.hanzo.network",currency:"AI"},{env:"local",label:"Hanzo Local",networkID:1337,evmChainID:1337,rpcEndpoint:"http://localhost:9630/v1/bc/C/rpc",apiEndpoint:"http://localhost:3690",currency:"AI"}],k=n(e=>"0x"+e.evmChainID.toString(16),"chainIdHex"),y=n((e,t)=>e.find(l=>l.env===t),"networkByEnv"),R=/^https?:\/\/.+/;function P(e){return !Number.isInteger(e.evmChainID)||e.evmChainID<=0?"Chain ID must be a positive integer.":R.test(e.rpcEndpoint)?R.test(e.apiEndpoint)?null:"API endpoint must be an http(s) URL.":"RPC endpoint must be an http(s) URL."}n(P,"validateCustomNetwork");var E="hanzo.network",h=z,m={env:"mainnet"},H=false,I=new Set;function g(){if(!(H||typeof window>"u")){H=true;try{let e=window.localStorage.getItem(E);if(e){let t=JSON.parse(e);t&&typeof t.env=="string"&&(m=t);}}catch{}window.addEventListener("storage",e=>{if(e.key===E)try{let t=e.newValue?JSON.parse(e.newValue):null;t&&typeof t.env=="string"&&(m=t,S());}catch{}});}}n(g,"load");function M(){if(!(typeof window>"u"))try{window.localStorage.setItem(E,JSON.stringify(m));}catch{}}n(M,"persist");function S(){for(let e of I)e();}n(S,"emit");function x(){return g(),m.env==="custom"&&m.custom?m.custom:y(h,m.env)??h[0]}n(x,"getNetwork");function j(e){g();let t=y(h,e);if(!t)throw new Error(`selectNetwork: no '${e}' network configured`);return m={env:e},M(),S(),t}n(j,"selectNetwork");function K(e){g();let t={...e,env:"custom"},l=P(t);if(l)throw new Error(l);return m={env:"custom",custom:t},M(),S(),t}n(K,"selectCustomNetwork");function T(e){return g(),I.add(e),()=>I.delete(e)}n(T,"subscribeNetwork");function O(){return {network:d.useSyncExternalStore(T,x,x),networks:h,select:j,selectCustom:K}}n(O,"useNetwork");function C(){return typeof window>"u"?null:window.ethereum??null}n(C,"injected");var U=n(()=>C()!==null,"walletAvailable");async function A(e,t){try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:k(t)}]});}catch(l){let p=l?.code;if(p!==4902&&p!==-32603)throw l;await e.request({method:"wallet_addEthereumChain",params:[{chainId:k(t),chainName:t.label,rpcUrls:[t.rpcEndpoint],nativeCurrency:{name:t.currency,symbol:t.currency,decimals:18},...t.explorerEndpoint?{blockExplorerUrls:[t.explorerEndpoint]}:{}}]});}}n(A,"ensureEvmNetwork");function V(e={}){let t=e.getNetwork??x,l=new Set,p={status:"disconnected",account:null,chainId:null,error:null},a=false,c=n(o=>{p={...p,...o};for(let r of l)r();},"set"),f=n(o=>{a||!o.on||(a=true,o.on("accountsChanged",(...r)=>{let w=r[0];w?.length?c({status:"ready",account:{address:w[0]},error:null}):c({status:"disconnected",account:null});}),o.on("chainChanged",(...r)=>{c({chainId:Number.parseInt(String(r[0]),16)||null});}));},"wire");return {getState:n(()=>p,"getState"),subscribe(o){return l.add(o),()=>l.delete(o)},async connect(){let o=C();if(!o)throw c({status:"error",error:"No browser wallet detected. Install MetaMask or a compatible wallet."}),new Error("No browser wallet detected.");c({status:"connecting",error:null});try{let r=await o.request({method:"eth_requestAccounts"});if(!r?.length)throw new Error("No accounts authorized.");await A(o,t());let w=await o.request({method:"eth_chainId"});f(o),c({status:"ready",account:{address:r[0]},chainId:Number.parseInt(w,16)||null});}catch(r){throw c({status:"error",error:r instanceof Error?r.message:String(r)}),r}},disconnect(){c({status:"disconnected",account:null,chainId:null,error:null});},async ensureNetwork(o){let r=C();if(!r)throw new Error("No browser wallet detected.");await A(r,o);}}}n(V,"injectedEvmAdapter");function B(e){return d.useSyncExternalStore(d.useCallback(t=>e.subscribe(t),[e]),e.getState,e.getState)}n(B,"useWalletState");function J({adapter:e,autoConnect:t=false,menuSide:l="bottom",className:p=""}){let a=B(e),{network:c}=O(),[f,o]=d.useState(false),[r,w]=d.useState(false),b=d.useRef(null),W=d.useRef(false);d.useEffect(()=>{!t||W.current||a.status!=="disconnected"||(W.current=true,e.connect().catch(()=>{}));},[t,e,a.status]),d.useEffect(()=>{if(!f)return;let v=n($=>{b.current&&!b.current.contains($.target)&&o(false);},"onDown");return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[f]);let L=n(async v=>{try{await navigator.clipboard.writeText(v),w(!0),window.setTimeout(()=>w(!1),1500);}catch{}},"copy"),D=a.status==="ready"&&a.chainId!==null&&a.chainId!==c.evmChainID;if(a.status!=="ready"||!a.account)return jsxs("div",{ref:b,className:`relative ${p}`,children:[jsxs("button",{type:"button",onClick:()=>{e.connect().catch(()=>{});},disabled:a.status==="connecting",className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-60",children:[jsx(Z,{className:"h-3.5 w-3.5"}),a.status==="connecting"?"Connecting\u2026":"Connect Wallet"]}),a.status==="error"&&a.error&&jsx("p",{className:"absolute right-0 z-50 mt-1 w-56 rounded-md border border-border bg-popover p-2 text-[10px] text-destructive shadow-md",children:a.error})]});let{account:u}=a;return jsxs("div",{ref:b,className:`relative ${p}`,children:[jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":f,onClick:()=>o(v=>!v),className:"flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[jsx("span",{className:`h-2 w-2 rounded-full ${D?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":true}),jsx("span",{className:"font-mono",children:N(u.address)}),u.pqPublicKey&&jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-violet-500",children:"PQ"})]}),f&&jsxs("div",{role:"menu",className:`absolute right-0 z-50 w-72 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-md ${l==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:[jsxs("div",{className:"px-1 pb-2",children:[u.label&&jsx("p",{className:"text-xs font-semibold",children:u.label}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("code",{className:"truncate font-mono text-[11px] text-muted-foreground",children:u.address}),jsx("button",{type:"button",onClick:()=>L(u.address),className:"shrink-0 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:r?"Copied":"Copy"})]})]}),u.pqPublicKey&&jsxs("div",{className:"border-t border-border px-1 py-2",children:[jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Post-quantum identity",jsx("span",{className:"rounded bg-violet-500/15 px-1 py-px text-[9px] font-semibold text-violet-500",children:"ML-DSA-65"})]}),jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqPublicKey}),u.pqNodeId&&jsx("code",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:u.pqNodeId})]}),jsxs("div",{className:"border-t border-border px-1 py-2 text-[11px]",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-muted-foreground",children:"Network"}),jsxs("span",{children:[c.label," \xB7 ",c.evmChainID]})]}),D&&e.ensureNetwork&&jsxs("button",{type:"button",onClick:()=>{e.ensureNetwork?.(c).catch(()=>{});},className:"mt-1.5 w-full rounded-md bg-amber-500/15 px-2 py-1 text-[11px] font-medium text-amber-600 hover:bg-amber-500/25",children:["Wallet is on chain ",a.chainId," \u2014 switch to ",c.label]})]}),jsxs("div",{className:"flex items-center justify-between border-t border-border px-1 pt-2",children:[c.explorerEndpoint?jsx("a",{href:`${c.explorerEndpoint.replace(/\/+$/,"")}/address/${u.address}`,target:"_blank",rel:"noreferrer",className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Explorer \u2197"}):jsx("span",{}),e.disconnect&&jsx("button",{type:"button",onClick:()=>{o(false),e.disconnect?.();},className:"rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:"Disconnect"})]})]})]})}n(J,"WalletMenu");function Z({className:e=""}){return jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,"aria-hidden":true,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"})})}n(Z,"WalletIcon");
3
+ export{J as WalletMenu,A as ensureEvmNetwork,V as injectedEvmAdapter,N as shortAddress,U as walletAvailable};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/ui-shadcn",
3
- "version": "5.7.2",
3
+ "version": "5.7.4",
4
4
  "description": "Multi-framework UI library with React, Vue, Svelte, and React Native support. Based on shadcn/ui with comprehensive framework coverage. (Formerly @hanzo/ui \u22645.x; @hanzo/ui@8+ is the @hanzo/gui-based unified lib.)",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",