@spicenet-io/spiceflow-ui 1.10.21 → 1.10.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -25,7 +25,7 @@
25
25
  from { transform: rotate(0deg); }
26
26
  to { transform: rotate(360deg); }
27
27
  }
28
- `})]}),h&&e.jsx(hs,{message:h.message,type:h.type,linkText:h.linkText,linkUrl:h.linkUrl,onClose:()=>m(null)})]})},xs=({address:t,supportedChains:o,enabled:a=!0,refetchInterval:n})=>{const[s,l]=r.useState([]),[c,i]=r.useState(!1),[g,x]=r.useState(null),[u,d]=r.useState(!1),S=r.useRef(!1),F=r.useRef(!1),A=o?JSON.stringify([...o].sort()):"",y=r.useCallback(async(k=!1)=>{if(!t||!a){l([]),d(!1),S.current=!1;return}if(!F.current){F.current=!0,!S.current&&!k&&i(!0),x(null);try{const C=await fetch(`${qt}/spicedeposit/${t}`);if(!C.ok)throw new Error(`Failed to fetch balance: ${C.status}`);const f=await C.json();if(f.success&&f.data?.tokens&&Array.isArray(f.data.tokens)){const b=new Map;f.data.tokens.forEach(m=>{const I=m.chainId,j=m.tokenAddress,M=m.amount;if(o&&!o.includes(I))return;const L=BigInt(M||"0");if(L>BigInt(0)){const G=we(I),ee=j.toLowerCase()==="0x0"||j.toLowerCase()==="0x0000000000000000000000000000000000000000"||j.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",X=ee?"0x0000000000000000000000000000000000000000":j.toLowerCase();let O=18,U="TOKEN",Y=j.slice(0,6)+"..."+j.slice(-4),B;if(ee)O=G?.nativeCurrency?.decimals||18,U=G?.nativeCurrency?.symbol||"ETH",Y=G?.nativeCurrency?.name||"Native Token";else{const R=G?.supportedTokens?.find(z=>z.address.toLowerCase()===j.toLowerCase());R&&(O=R.decimals,U=R.symbol,Y=R.name,B=R.logoURI)}const q=parseFloat((Number(L)/Math.pow(10,O)).toFixed(6));if(q>0){const R=`${X}-${I}`,z=b.get(R);if(z){const W=z.balance+L,te=parseFloat((Number(W)/Math.pow(10,O)).toFixed(6));b.set(R,{...z,balance:W,balanceFormatted:te})}else b.set(R,{address:X,symbol:U,name:Y,decimals:O,chainId:I,balance:L,balanceFormatted:q,balanceUsd:0,isNative:ee,logoURI:B})}}});const h=Array.from(b.values());l(h),d(h.length>0),S.current=!0}else l([]),d(!1)}catch(C){const f=C instanceof Error?C.message:"Failed to fetch balance";x(f),console.error("Error fetching Spice assets:",C),S.current||(l([]),d(!1))}finally{i(!1),F.current=!1}}},[t,a,A]);r.useEffect(()=>{a&&t&&(S.current=!1,y(!1))},[t,a,A]),r.useEffect(()=>{if(!a||!t||!n)return;const k=setInterval(()=>{y(!0)},n);return()=>clearInterval(k)},[t,a,n,A]);const p=r.useCallback(k=>s.filter(C=>C.chainId===k),[s]),w=r.useCallback(async()=>{await y(!0)},[y]);return{assets:s,loading:c,error:g,hasBalance:u,refetch:w,getAssetsByChain:p}},gs=({isSuccess:t,type:o,chainName:a,explorerUrl:n,txHash:s})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${o.toUpperCase()} CONFIRMED`:`${o.toUpperCase()} FAILED`}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",a]})]})]}),n&&s&&e.jsxs("a",{href:`${n}/tx/${s}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e.jsx("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),Pt=({isOpen:t,onClose:o,onComplete:a,type:n,results:s,chainName:l="Network",explorerUrl:c,theme:i,styles:g,intentStatus:x,onRetry:u,onNewTx:d,onRetryTx:S,asOverlay:F=!1,isProcessing:A=!1})=>{const y=i||ce.createTheme("light"),[p,w]=r.useState(!1),[k,C]=r.useState(!0),[f,b]=r.useState(null),[h,m]=r.useState(null);r.useEffect(()=>{!t&&!x&&w(!1)},[t,x]);const I=()=>{w(!0),setTimeout(()=>{a?.()},300)},j=()=>{C(!k)};if(x){const{steps:G,overallStatus:ee}=x,X=ee==="processing",O=ee==="success",U=ee==="failed",Y=G.find(z=>z.transactionHash),B=l!=="Network"?l:G[0]?.chainName||l,q=c||(Y?Dt(Y.chainId,Y.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),R=e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:j,children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:g?.fontFamily||y.typography.fontFamily},children:[X?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:k?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!X&&e.jsx("button",{onClick:o,onMouseEnter:()=>b("close"),onMouseLeave:()=>{b(null),m(null)},onMouseDown:()=>m("close"),onMouseUp:()=>m(null),style:{background:h==="close"?"#f3f4f6":f==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:f==="close"||h==="close"?"#374151":"#6b7280",transform:h==="close"?"scale(0.9)":f==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{style:{marginBottom:"16px"},children:X?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:y.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",B]})]})]}):e.jsx(gs,{isSuccess:O,type:n,chainName:B,explorerUrl:q,txHash:Y?.transactionHash})}),e.jsx("style",{children:`
28
+ `})]}),h&&e.jsx(hs,{message:h.message,type:h.type,linkText:h.linkText,linkUrl:h.linkUrl,onClose:()=>m(null)})]})},xs=({address:t,supportedChains:o,enabled:a=!0,refetchInterval:n})=>{const[s,l]=r.useState([]),[c,i]=r.useState(!1),[g,x]=r.useState(null),[u,d]=r.useState(!1),S=r.useRef(!1),F=r.useRef(!1),A=o?JSON.stringify([...o].sort()):"",y=r.useCallback(async(k=!1)=>{if(!t||!a){l([]),d(!1),S.current=!1;return}if(!F.current){F.current=!0,!S.current&&!k&&i(!0),x(null);try{const C=await fetch(`${qt}/spicedeposit/${t}`);if(!C.ok)throw new Error(`Failed to fetch balance: ${C.status}`);const f=await C.json();if(f.success&&f.data?.tokens&&Array.isArray(f.data.tokens)){const b=new Map;f.data.tokens.forEach(m=>{const I=m.chainId,j=m.tokenAddress,M=m.amount;if(o&&!o.includes(I))return;const L=BigInt(M||"0");if(L>BigInt(0)){const G=we(I),ee=j.toLowerCase()==="0x0"||j.toLowerCase()==="0x0000000000000000000000000000000000000000"||j.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",X=ee?"0x0000000000000000000000000000000000000000":j.toLowerCase();let O=18,U="TOKEN",Y=j.slice(0,6)+"..."+j.slice(-4),B;if(ee)O=G?.nativeCurrency?.decimals||18,U=G?.nativeCurrency?.symbol||"ETH",Y=G?.nativeCurrency?.name||"Native Token";else{const R=G?.supportedTokens?.find(z=>z.address.toLowerCase()===j.toLowerCase());R&&(O=R.decimals,U=R.symbol,Y=R.name,B=R.logoURI)}const q=parseFloat((Number(L)/Math.pow(10,O)).toFixed(6));if(q>0){const R=`${X}-${I}`,z=b.get(R);if(z){const W=z.balance+L,te=parseFloat((Number(W)/Math.pow(10,O)).toFixed(6));b.set(R,{...z,balance:W,balanceFormatted:te})}else b.set(R,{address:X,symbol:U,name:Y,decimals:O,chainId:I,balance:L,balanceFormatted:q,balanceUsd:0,isNative:ee,logoURI:B})}}});const h=Array.from(b.values());l(h),d(h.length>0),S.current=!0}else l([]),d(!1)}catch(C){const f=C instanceof Error?C.message:"Failed to fetch balance";x(f),console.error("Error fetching Spice assets:",C),S.current||(l([]),d(!1))}finally{i(!1),F.current=!1}}},[t,a,A]);r.useEffect(()=>{a&&t&&(S.current=!1,y(!1))},[t,a,A]),r.useEffect(()=>{if(!a||!t||!n)return;const k=setInterval(()=>{y(!0)},n);return()=>clearInterval(k)},[t,a,n,A]);const p=r.useCallback(k=>s.filter(C=>C.chainId===k),[s]),w=r.useCallback(async()=>{await y(!0)},[y]);return{assets:s,loading:c,error:g,hasBalance:u,refetch:w,getAssetsByChain:p}},gs=({isSuccess:t,type:o,chainName:a,explorerUrl:n,txHash:s})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${o.toUpperCase()} CONFIRMED`:`${o.toUpperCase()} FAILED`}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",a]})]})]}),n&&s&&e.jsxs("a",{href:`${n}/tx/${s}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e.jsx("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),Pt=({isOpen:t,onClose:o,onComplete:a,type:n,results:s,chainName:l="Network",explorerUrl:c,theme:i,styles:g,intentStatus:x,onRetry:u,onNewTx:d,onRetryTx:S,asOverlay:F=!1,isProcessing:A=!1})=>{const y=i||ce.createTheme("light"),[p,w]=r.useState(!1),[k,C]=r.useState(!0),[f,b]=r.useState(null),[h,m]=r.useState(null);r.useEffect(()=>{!t&&!x&&w(!1)},[t,x]);const I=()=>{w(!0),setTimeout(()=>{a?.(),o()},300)},j=()=>{C(!k)};if(x){const{steps:G,overallStatus:ee}=x,X=ee==="processing",O=ee==="success",U=ee==="failed",Y=G.find(z=>z.transactionHash),B=l!=="Network"?l:G[0]?.chainName||l,q=c||(Y?Dt(Y.chainId,Y.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),R=e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:j,children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:g?.fontFamily||y.typography.fontFamily},children:[X?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:k?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!X&&e.jsx("button",{onClick:o,onMouseEnter:()=>b("close"),onMouseLeave:()=>{b(null),m(null)},onMouseDown:()=>m("close"),onMouseUp:()=>m(null),style:{background:h==="close"?"#f3f4f6":f==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:f==="close"||h==="close"?"#374151":"#6b7280",transform:h==="close"?"scale(0.9)":f==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{style:{marginBottom:"16px"},children:X?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:y.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",B]})]})]}):e.jsx(gs,{isSuccess:O,type:n,chainName:B,explorerUrl:q,txHash:Y?.transactionHash})}),e.jsx("style",{children:`
29
29
  @keyframes spin {
30
30
  from { transform: rotate(0deg); }
31
31
  to { transform: rotate(360deg); }
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ import{defineChain as mo,createPublicClient as yo,http as xo,isAddress as eo,get
25
25
  from { transform: rotate(0deg); }
26
26
  to { transform: rotate(360deg); }
27
27
  }
28
- `})]}),h&&e(zo,{message:h.message,type:h.type,linkText:h.linkText,linkUrl:h.linkUrl,onClose:()=>y(null)})]})},Vo=({address:t,supportedChains:r,enabled:i=!0,refetchInterval:n})=>{const[o,l]=x([]),[c,a]=x(!1),[f,g]=x(null),[u,d]=x(!1),k=Me(!1),v=Me(!1),w=r?JSON.stringify([...r].sort()):"",b=ne(async(S=!1)=>{if(!t||!i){l([]),d(!1),k.current=!1;return}if(!v.current){v.current=!0,!k.current&&!S&&a(!0),g(null);try{const A=await fetch(`${so}/spicedeposit/${t}`);if(!A.ok)throw new Error(`Failed to fetch balance: ${A.status}`);const m=await A.json();if(m.success&&m.data?.tokens&&Array.isArray(m.data.tokens)){const C=new Map;m.data.tokens.forEach(y=>{const F=y.chainId,W=y.tokenAddress,H=y.amount;if(r&&!r.includes(F))return;const Q=BigInt(H||"0");if(Q>BigInt(0)){const K=we(F),oe=W.toLowerCase()==="0x0"||W.toLowerCase()==="0x0000000000000000000000000000000000000000"||W.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",$=oe?"0x0000000000000000000000000000000000000000":W.toLowerCase();let X=18,T="TOKEN",j=W.slice(0,6)+"..."+W.slice(-4),R;if(oe)X=K?.nativeCurrency?.decimals||18,T=K?.nativeCurrency?.symbol||"ETH",j=K?.nativeCurrency?.name||"Native Token";else{const L=K?.supportedTokens?.find(N=>N.address.toLowerCase()===W.toLowerCase());L&&(X=L.decimals,T=L.symbol,j=L.name,R=L.logoURI)}const P=parseFloat((Number(Q)/Math.pow(10,X)).toFixed(6));if(P>0){const L=`${$}-${F}`,N=C.get(L);if(N){const D=N.balance+Q,re=parseFloat((Number(D)/Math.pow(10,X)).toFixed(6));C.set(L,{...N,balance:D,balanceFormatted:re})}else C.set(L,{address:$,symbol:T,name:j,decimals:X,chainId:F,balance:Q,balanceFormatted:P,balanceUsd:0,isNative:oe,logoURI:R})}}});const h=Array.from(C.values());l(h),d(h.length>0),k.current=!0}else l([]),d(!1)}catch(A){const m=A instanceof Error?A.message:"Failed to fetch balance";g(m),console.error("Error fetching Spice assets:",A),k.current||(l([]),d(!1))}finally{a(!1),v.current=!1}}},[t,i,w]);_(()=>{i&&t&&(k.current=!1,b(!1))},[t,i,w]),_(()=>{if(!i||!t||!n)return;const S=setInterval(()=>{b(!0)},n);return()=>clearInterval(S)},[t,i,n,w]);const p=ne(S=>o.filter(A=>A.chainId===S),[o]),I=ne(async()=>{await b(!0)},[b]);return{assets:o,loading:c,error:f,hasBalance:u,refetch:I,getAssetsByChain:p}},No=({isSuccess:t,type:r,chainName:i,explorerUrl:n,txHash:o})=>s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[s("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),s("div",{children:[e("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${r.toUpperCase()} CONFIRMED`:`${r.toUpperCase()} FAILED`}),s("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",i]})]})]}),n&&o&&s("a",{href:`${n}/tx/${o}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",s("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),lo=({isOpen:t,onClose:r,onComplete:i,type:n,results:o,chainName:l="Network",explorerUrl:c,theme:a,styles:f,intentStatus:g,onRetry:u,onNewTx:d,onRetryTx:k,asOverlay:v=!1,isProcessing:w=!1})=>{const b=a||De("light"),[p,I]=x(!1),[S,A]=x(!0),[m,C]=x(null),[h,y]=x(null);_(()=>{!t&&!g&&I(!1)},[t,g]);const F=()=>{I(!0),setTimeout(()=>{i?.()},300)},W=()=>{A(!S)};if(g){const{steps:K,overallStatus:oe}=g,$=oe==="processing",X=oe==="success",T=oe==="failed",j=K.find(N=>N.transactionHash),R=l!=="Network"?l:K[0]?.chainName||l,P=c||(j?Jt(j.chainId,j.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),L=s(je,{children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[s("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:W,children:[s("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:f?.fontFamily||b.typography.fontFamily},children:[$?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:S?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!$&&e("button",{onClick:r,onMouseEnter:()=>C("close"),onMouseLeave:()=>{C(null),y(null)},onMouseDown:()=>y("close"),onMouseUp:()=>y(null),style:{background:h==="close"?"#f3f4f6":m==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:m==="close"||h==="close"?"#374151":"#6b7280",transform:h==="close"?"scale(0.9)":m==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e("div",{style:{marginBottom:"16px"},children:$?s("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:b.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),s("div",{children:[e("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),s("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",R]})]})]}):e(No,{isSuccess:X,type:n,chainName:R,explorerUrl:P,txHash:j?.transactionHash})}),e("style",{children:`
28
+ `})]}),h&&e(zo,{message:h.message,type:h.type,linkText:h.linkText,linkUrl:h.linkUrl,onClose:()=>y(null)})]})},Vo=({address:t,supportedChains:r,enabled:i=!0,refetchInterval:n})=>{const[o,l]=x([]),[c,a]=x(!1),[f,g]=x(null),[u,d]=x(!1),k=Me(!1),v=Me(!1),w=r?JSON.stringify([...r].sort()):"",b=ne(async(S=!1)=>{if(!t||!i){l([]),d(!1),k.current=!1;return}if(!v.current){v.current=!0,!k.current&&!S&&a(!0),g(null);try{const A=await fetch(`${so}/spicedeposit/${t}`);if(!A.ok)throw new Error(`Failed to fetch balance: ${A.status}`);const m=await A.json();if(m.success&&m.data?.tokens&&Array.isArray(m.data.tokens)){const C=new Map;m.data.tokens.forEach(y=>{const F=y.chainId,W=y.tokenAddress,H=y.amount;if(r&&!r.includes(F))return;const Q=BigInt(H||"0");if(Q>BigInt(0)){const K=we(F),oe=W.toLowerCase()==="0x0"||W.toLowerCase()==="0x0000000000000000000000000000000000000000"||W.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",$=oe?"0x0000000000000000000000000000000000000000":W.toLowerCase();let X=18,T="TOKEN",j=W.slice(0,6)+"..."+W.slice(-4),R;if(oe)X=K?.nativeCurrency?.decimals||18,T=K?.nativeCurrency?.symbol||"ETH",j=K?.nativeCurrency?.name||"Native Token";else{const L=K?.supportedTokens?.find(N=>N.address.toLowerCase()===W.toLowerCase());L&&(X=L.decimals,T=L.symbol,j=L.name,R=L.logoURI)}const P=parseFloat((Number(Q)/Math.pow(10,X)).toFixed(6));if(P>0){const L=`${$}-${F}`,N=C.get(L);if(N){const D=N.balance+Q,re=parseFloat((Number(D)/Math.pow(10,X)).toFixed(6));C.set(L,{...N,balance:D,balanceFormatted:re})}else C.set(L,{address:$,symbol:T,name:j,decimals:X,chainId:F,balance:Q,balanceFormatted:P,balanceUsd:0,isNative:oe,logoURI:R})}}});const h=Array.from(C.values());l(h),d(h.length>0),k.current=!0}else l([]),d(!1)}catch(A){const m=A instanceof Error?A.message:"Failed to fetch balance";g(m),console.error("Error fetching Spice assets:",A),k.current||(l([]),d(!1))}finally{a(!1),v.current=!1}}},[t,i,w]);_(()=>{i&&t&&(k.current=!1,b(!1))},[t,i,w]),_(()=>{if(!i||!t||!n)return;const S=setInterval(()=>{b(!0)},n);return()=>clearInterval(S)},[t,i,n,w]);const p=ne(S=>o.filter(A=>A.chainId===S),[o]),I=ne(async()=>{await b(!0)},[b]);return{assets:o,loading:c,error:f,hasBalance:u,refetch:I,getAssetsByChain:p}},No=({isSuccess:t,type:r,chainName:i,explorerUrl:n,txHash:o})=>s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[s("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),s("div",{children:[e("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${r.toUpperCase()} CONFIRMED`:`${r.toUpperCase()} FAILED`}),s("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",i]})]})]}),n&&o&&s("a",{href:`${n}/tx/${o}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",s("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),lo=({isOpen:t,onClose:r,onComplete:i,type:n,results:o,chainName:l="Network",explorerUrl:c,theme:a,styles:f,intentStatus:g,onRetry:u,onNewTx:d,onRetryTx:k,asOverlay:v=!1,isProcessing:w=!1})=>{const b=a||De("light"),[p,I]=x(!1),[S,A]=x(!0),[m,C]=x(null),[h,y]=x(null);_(()=>{!t&&!g&&I(!1)},[t,g]);const F=()=>{I(!0),setTimeout(()=>{i?.(),r()},300)},W=()=>{A(!S)};if(g){const{steps:K,overallStatus:oe}=g,$=oe==="processing",X=oe==="success",T=oe==="failed",j=K.find(N=>N.transactionHash),R=l!=="Network"?l:K[0]?.chainName||l,P=c||(j?Jt(j.chainId,j.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),L=s(je,{children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[s("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:W,children:[s("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:f?.fontFamily||b.typography.fontFamily},children:[$?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:S?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!$&&e("button",{onClick:r,onMouseEnter:()=>C("close"),onMouseLeave:()=>{C(null),y(null)},onMouseDown:()=>y("close"),onMouseUp:()=>y(null),style:{background:h==="close"?"#f3f4f6":m==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:m==="close"||h==="close"?"#374151":"#6b7280",transform:h==="close"?"scale(0.9)":m==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e("div",{style:{marginBottom:"16px"},children:$?s("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:b.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),s("div",{children:[e("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),s("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",R]})]})]}):e(No,{isSuccess:X,type:n,chainName:R,explorerUrl:P,txHash:j?.transactionHash})}),e("style",{children:`
29
29
  @keyframes spin {
30
30
  from { transform: rotate(0deg); }
31
31
  to { transform: rotate(360deg); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.10.21",
3
+ "version": "1.10.22",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",