UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

4 lines (3 loc) 2.4 kB
"use strict";var e=require("react/jsx-runtime"),t=require("styled-components"),r=require("viem"),i=require("./ethers-DZGJ4Y5i.js"),s=require("./getFormattedUsdFromLamports-Mu2fqwL2.js"),n=require("./transaction-DjF5X-by.js"),a=require("./useActiveWallet-BOX8xCn9.js");let l=/*#__PURE__*/t.styled.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-3cd56c8a-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),o=/*#__PURE__*/t.styled.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-3cd56c8a-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),c=/*#__PURE__*/t.styled.span.withConfig({displayName:"TinyLessThan",componentId:"sc-3cd56c8a-2"})(["font-size:10px;"]),d=/*#__PURE__*/t.styled.span.withConfig({displayName:"FlexCenter",componentId:"sc-3cd56c8a-3"})(["display:flex;align-items:center;"]);function m(e,t){return`https://explorer.solana.com/account/${e}?chain=${t}`}let p=/*#__PURE__*/t.styled.a.withConfig({displayName:"StyledLink",componentId:"sc-dd6c0f9f-0"})(["&:hover{text-decoration:underline;}"]);exports.HeaderPriceDisplay=({weiQuantities:t,tokenPrice:r,tokenSymbol:s})=>{let n=i.sumWeiQuantities(t),a=r?i.getDollarsFromWei(n,r):void 0,o=i.getNativeCurrencyFromWei(n,s);/*#__PURE__*/return e.jsx(l,{children:a||o})},exports.PriceDisplay=({weiQuantities:t,tokenPrice:r,tokenSymbol:s})=>{let n=i.sumWeiQuantities(t),a=r?i.getDollarsFromWei(n,r):void 0,m=i.getNativeCurrencyFromWei(n,s);/*#__PURE__*/return e.jsx(l,{children:a?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(o,{children:"USD"}),"<$0.01"===a? /*#__PURE__*/e.jsxs(d,{children:[/*#__PURE__*/e.jsx(c,{children:"<"}),"$0.01"]}):a]}):m})},exports.SolanaPriceDisplay=({quantities:t,tokenPrice:i,tokenSymbol:a="SOL",tokenDecimals:o=9})=>{let m=t.reduce(((e,t)=>e+t),0n),p=i&&"SOL"===a&&9===o?s.getFormattedUsdFromLamports(m,i):void 0,h="SOL"===a&&9===o?n.getNativeCurrencyFromLamports(m):`${r.formatUnits(m,o)} ${a}`;/*#__PURE__*/return e.jsx(l,{children:p?/*#__PURE__*/e.jsx(e.Fragment,{children:"<$0.01"===p? /*#__PURE__*/e.jsxs(d,{children:[/*#__PURE__*/e.jsx(c,{children:"<"}),"$0.01"]}):p}):h})},exports.WalletLink=t=>/*#__PURE__*/e.jsx(p,{href:"ethereum"===t.chainType?i.getBlockExplorerUrlForAddress(t.chainId,t.walletAddress):m(t.walletAddress,t.chainId),target:"_blank",children:a.formatWalletAddress(t.walletAddress)});