PageSourceSearch

https://spectre-trading.vercel.app/assets/UdHistorySection-DqKChD5r.js

js spectre-trading.vercel.app collected 2026-10-03 07:48:18 UTC 11,013 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./react-vendor-Cjx5hKTv.js";import{c as P,a1 as T}from"./main-gwQ4tnu2.js";import"./vendor-shared-CLcXU_4U.js";import"./buffer-polyfill-CzILmVLF.js";import"./vendor-zustand-CgOpt4rM.js";const p={ethereum:{name:"Ethereum",icon:"ETH",color:"#627eea",explorer:"https://etherscan.io/tx/",native:"https://assets.coingecko.com/coins/images/279/small/ethereum.png"},bsc:{name:"BSC",icon:"BNB",color:"#F3BA2F",explorer:"https://bscscan.com/tx/",native:"https://assets.coingecko.com/coins/images/825/small/bnb-icon2_2x.png"},polygon:{name:"Polygon",icon:"MATIC",color:"#8247E5",explorer:"https://polygonscan.com/tx/",native:"https://assets.coingecko.com/coins/images/4713/small/polygon.png"},arbitrum:{name:"Arbitrum",icon:"ARB",color:"#28A0F0",explorer:"https://arbiscan.io/tx/",native:"https://assets.coingecko.com/coins/images/279/small/ethereum.png"},base:{name:"Base",icon:"BASE",color:"#0052FF",explorer:"https://basescan.org/tx/",native:"https://assets.coingecko.com/coins/images/279/small/ethereum.png"},solana:{name:"Solana",icon:"SOL",color:"#9945FF",explorer:"https://solscan.io/tx/",native:"https://assets.coingecko.com/coins/images/4128/small/solana.png"}};function U(r,s){if(!r)return"";const o=new Date(r),i=new Date-o,d=Math.floor(i/6e4);if(d<1)return s("trade.dashboard.history.justNow","Just now");if(d<60)return s("trade.dashboard.history.minAgo","{{n}}m ago",{n:d});const l=Math.floor(d/60);if(l<24)return s("trade.dashboard.history.hrAgo","{{n}}h ago",{n:l});const u=Math.floor(l/24);return u<7?s("trade.dashboard.history.dayAgo","{{n}}d ago",{n:u}):o.toLocaleDateString(T(),{month:"short",day:"numeric"})}function z(r){if(!r)return"";const s=new Date(r);return isNaN(s)?"":s.toLocaleString(T(),{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function j({logo:r,symbol:s,native:o}){const[n,i]=c.useState(!1),d=!n&&r?r:!n&&o?o:null;return d?e.jsx("img",{className:"ud-history-tok-logo",src:d,alt:s||"",loading:"lazy",onError:()=>i(!0)}):e.jsx("span",{className:"ud-history-tok-logo ud-history-tok-logo--fallback",children:(s||"?").charAt(0)})}function A(r){return!r||r.length<12?r||"":`${r.slice(0,6)}...${r.slice(-4)}`}const x="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",y="So11111111111111111111111111111111111111112";function M(r,s,o){return s||(r?String(r).toLowerCase()===x||r==="native"?p[o]?.icon||"ETH":r===y?"SOL":`${String(r).slice(0,4)}…${String(r).slice(-4)}`:"?")}function F(r,s,o){if(r==null||r==="")return"";const n=Number.isFinite(s)?s:o==="solana"?9:18;let i;try{i=Number(r)/10**n}
1catch{return String(r)}return Number.isFinite(i)?i===0?"0":i>=1e9?`${(i/1e9).toLocaleString(void 0,{maximumFractionDigits:2})}B`:i>=1e6?`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}M`:i>=1e3?i.toLocaleString(void 0,{maximumFractionDigits:2}):i>=1?i.toLocaleString(void 0,{maximumFractionDigits:4}):i>=1e-4?i.toLocaleString(void 0,{maximumFractionDigits:6}):i.toPrecision(2):String(r)}function R(r){if(r==null||r==="")return"";const s=Number(r);return Number.isFinite(s)?s===0?"0":s>=1e9?`${(s/1e9).toLocaleString(void 0,{maximumFractionDigits:2})}B`:s>=1e6?`${(s/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}M`:s>=1e3?s.toLocaleString(void 0,{maximumFractionDigits:2}):s>=1?s.toLocaleString(void 0,{maximumFractionDigits:4}):s>=1e-4?s.toLocaleString(void 0,{maximumFractionDigits:6}):s.toPrecision(2):String(r)}function G(r){if(r.side==="buy"||r.side==="sell")return r.side;const s=String(r.inputToken||"").toLowerCase(),o=String(r.outputToken||"").toLowerCase(),n=(i,d)=>i===x||d==="native"||d===y;return n(s,r.inputToken)?"buy":n(o,r.outputToken)?"sell":null}function Q({getSwapHistory:r,triggerCopyToast:s}){const o=P(),[n,i]=c.useState([]),[d,l]=c.useState(!0),[u,N]=c.useState(!1),[C,v]=c.useState(!1),m=20;c.useEffect(()=>{let t=!1;async function h(){l(!0);try{const a=await r(m,0);if(t)return;i(a||[]),v((a||[]).length>=m)}catch{t||i([])}finally{t||l(!1)}}return h(),()=>{t=!0}},[r]);const D=c.useCallback(async()=>{N(!0);try{const t=await r(m,n.length);i(h=>[...h,...t||[]]),v((t||[]).length>=m)}catch{}finally{N(!1)}},[r,n.length]),H=c.useCallback(t=>{navigator.clipboard.writeText(t).catch(()=>{}),s?.(o("trade.dashboard.history.hashCopied","Transaction hash copied"))},[s,o]),E=c.useCallback(t=>{navigator.clipboard.writeText(t).catch(()=>{}),s?.(o("trade.dashboard.history.addressCopied","Address copied"))},[s,o]);return d?e.jsxs("div",{className:"ud-card ud-history",children:[e.jsx("div",{className:"ud-card-header-row",children:e.jsx("h2",{className:"ud-card-title",children:o("trade.dashboard.nav.history","Trade History")})}),e.jsx("div",{className:"ud-history-list",children:[0,1,2].map(t=>e.jsxs("div",{className:"ud-history-row ud-history-shimmer",style:{animationDelay:`${t*100}ms`},children:[e.jsx("div",{className:"ud-history-shimmer-chain"}),e.jsxs("div",{className:"ud-history-shimmer-details",children:[e.jsx("div",{className:"ud-history-shimmer-line wide"}),e.jsx("div",{className:"ud-history-shimmer-line narrow"})]}),e.jsx("div",{className:"ud-history-shimmer-amount"})]},t))})]}):n.length?e.jsxs("div",{className:"ud-card ud-history",children:[e.jsxs("div",{className:"ud-card-header-row",children:[e.jsx("h2",{className:"ud-card-title",children:o("trade.dashboard.nav.history","Trade History")}),e.jsx("span",{className:"ud-history-count",children:o("trade.dashboard.history.count",n.length!==1?"{{count}} transactions":"{{count}} transaction",{count:n.length})})]}),e.jsx("div",{className:"ud-history-list",children:n.map((t,h)=>{const a=p[t.chainId]||p.ethereum,k=M(t.inputToken,t.inputSymbol,t.chainId),b=M(t.outputToken,t.outputSymbol,t.chainId),B=F(t.inputAmount,t.inputDecimals,t.chainId),I=F(t.outputAmount,t.outputDecimals,t.chainId),g=G(t),L=t.type==="withdraw",$=L&&String(t.inputToken||"").toUpperCase()===String(a.icon||"").toUpperCase(),S=Number.isFinite(Number(t.usd))&&Number(t.usd)>0?`$${Number(t.usd).toLocaleString(void 0,{maximumFractionDigits:2})}`:null,V=String(t.inputToken||"").toLowerCase()===x||t.inputToken==="native"||t.inputToken===y,_=String(t.outputToken||"").toLowerCase()===x||t.outputToken==="native"||t.outputToken===y,W=U(t.timestamp,o),f=z(t.timestamp);return e.jsxs("div",{className:"ud-history-row",children:[e.jsx("div",{className:"ud-history-chain-badge",style:{"--chain-color":a.color},title:a.name,children:e.jsx("img",{className:"ud-history-chain-logo",src:a.native,alt:a.name,loading:"lazy",onError:O=>{O.currentTarget.style.display="none"}})}),e.jsxs("div",{className:"ud-history-details",children:[e.jsx("div",{className:"ud-history-tokens",children:L?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ud-history-side ud-history-side--withdraw",children:o("trade.dashboard.history.withdraw","Withdraw")}),e.jsxs("span",{className:"ud-history-leg",children:[e.jsx(j,{logo:null,symbol:t.inputToken,native:$?a.native:null}),e.jsx("span",{className:"ud-history-token-amount",children:R(t.inputAmount)}),e.jsx("span",{className:"ud-history-token-symbol",children:t.inputToken})]}),t.toAddress&&e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"ud-history-arrow",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",width:"13",height:"13",children:e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})}),e.jsxs("button",{type:"button",className:"ud-history-leg ud-history-dest",title:o("trade.dashboard.history.copyValue","Copy {{value}}",{value:t.toAddress}),onClick:()=>E(t.toAddress),children:[A(t.toAddress),e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",width:"11",height:"11","aria-hidden":"true",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})]})]}):e.jsxs(e.Fragment,{children:[g&&e.jsx("span",{className:`ud-history-side ud-history-side--${g}`,children:g==="buy"?o("trade.dashboard.history.buy","Buy"):o("trade.dashboard.history.sell","Sell")}),e.jsxs("span",{className:"ud-history-leg",children:[e.jsx(j,{logo:t.input
1Logo,symbol:k,native:V?a.native:null}),e.jsx("span",{className:"ud-history-token-amount",children:B}),e.jsx("span",{className:"ud-history-token-symbol",children:k})]}),e.jsx("svg",{className:"ud-history-arrow",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",width:"13",height:"13",children:e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})}),e.jsxs("span",{className:"ud-history-leg",children:[e.jsx(j,{logo:t.outputLogo,symbol:b,native:_?a.native:null}),e.jsx("span",{className:"ud-history-token-amount",children:I}),e.jsx("span",{className:"ud-history-token-symbol",children:b})]})]})}),e.jsxs("div",{className:"ud-history-meta",children:[e.jsx("span",{className:"ud-history-time",title:f,children:W}),f&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ud-history-sep"}),e.jsx("span",{className:"ud-history-date",children:f})]}),t.txHash&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ud-history-sep"}),e.jsx("button",{className:"ud-history-hash",onClick:()=>H(t.txHash),title:o("trade.dashboard.history.copyHash","Copy transaction hash"),children:A(t.txHash)})]})]})]}),e.jsxs("div",{className:"ud-history-right",children:[S&&e.jsx("span",{className:"ud-history-usd",children:S}),t.txHash&&e.jsx("a",{href:`${a.explorer}${t.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"ud-history-explorer",title:o("trade.dashboard.history.viewExplorer","View on {{chain}} explorer",{chain:a.name}),children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",width:"15",height:"15",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 3h6v6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10 14L21 3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]},t.txHash||h)})}),C&&e.jsx("button",{className:"ud-history-load-more",onClick:D,disabled:u,children:u?e.jsx("span",{className:"ud-history-load-more-shimmer"}):o("trade.dashboard.history.loadMore","Load more")})]}):e.jsxs("div",{className:"ud-card ud-history",children:[e.jsx("div",{className:"ud-card-header-row",children:e.jsx("h2",{className:"ud-card-title",children:o("trade.dashboard.nav.history","Trade History")})}),e.jsxs("div",{className:"ud-history-empty",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",width:"32",height:"32",children:[e.jsx("path",{d:"M7 16V4M7 4L3 8M7 4l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M17 8v12M17 20l4-4M17 20l-4-4",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("p",{children:o("trade.dashboard.history.empty","No transactions yet")}),e.jsx("span",{children:o("trade.dashboard.history.emptyHint","Your trades and withdrawals will appear here")})]})]})}export{Q as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.