UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

167 lines (162 loc) 27.8 kB
"use strict";var e=require("react/jsx-runtime"),r=require("@heroicons/react/24/outline"),s=require("react"),n=require("styled-components"),i=require("@privy-io/js-sdk-core"),l=require("./ModalHeader-BCPQgekO.js"),o=require("./Value-mhPsfsxe.js"),t=require("./Row-CMqYn75Q.js"),a=require("./ErrorMessage-BfTVyue9.js"),d=require("./LabelXs-C8rLnCfU.js"),c=require("./Subtitle-CR8zM7ZJ.js"),x=require("./Title-ifTy35V5.js"),h=require("./Address-CHKhHgKJ.js"),u=require("./WalletInfoCard-CHdyZdLe.js"),j=require("./context-D-ZJYjUg.js"),m=require("./useActiveWallet-Cn6zOXx5.js"),p=require("./LoadingSkeleton-BoyADunQ.js"),g=require("viem"),b=require("./shared-DBm7PUrg.js"),w=require("./Checkbox-DzxHC5tk.js"),f=require("./ErrorBanner-dOLclNms.js"),y=require("./WarningBanner-COl_Q0K3.js"),S=require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),k=require("@heroicons/react/24/outline/ClipboardDocumentIcon"),v=require("@heroicons/react/24/outline/ExclamationCircleIcon"),L=require("./internal-context-BJv4f_bO.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var R=/*#__PURE__*/A(S),I=/*#__PURE__*/A(k),T=/*#__PURE__*/A(v);const V=n.styled(o.LabelSm)` cursor: pointer; display: inline-flex; gap: 8px; align-items: center; color: var(--privy-color-accent); svg { fill: var(--privy-color-accent); } `;var C=({iconUrl:r,value:s,symbol:n,usdValue:i,nftName:l,nftCount:o,decimals:t,$isLoading:a})=>{if(a)/*#__PURE__*/return e.jsx(M,{$isLoading:a});let d=s&&i&&t?function(e,r,s){let n=parseFloat(e),i=parseFloat(s);if(0===n||0===i||Number.isNaN(n)||Number.isNaN(i))return e;let l=Math.ceil(-Math.log10(.01/(i/n))),o=Math.pow(10,l=Math.max(l=Math.min(l,r),1)),t=+(Math.floor(n*o)/o).toFixed(l).replace(/\.?0+$/,"");return Intl.NumberFormat(void 0,{maximumFractionDigits:r}).format(t)}(s,t,i):s;/*#__PURE__*/return e.jsxs("div",{children:[/*#__PURE__*/e.jsxs(M,{$isLoading:a,children:[r&&/*#__PURE__*/e.jsx($,{src:r,alt:"Token icon"}),o&&o>1?o+"x":void 0," ",l,d," ",n]}),i&&/*#__PURE__*/e.jsxs(F,{$isLoading:a,children:["$",i]})]})};let M=n.styled.span` color: var(--privy-color-foreground); font-size: 0.875rem; font-weight: 500; line-height: 1.375rem; word-break: break-all; text-align: right; display: flex; justify-content: flex-end; ${p.LoadingSkeleton} `;const F=n.styled.span` color: var(--privy-color-foreground-2); font-size: 12px; font-weight: 400; line-height: 18px; word-break: break-all; text-align: right; display: flex; justify-content: flex-end; ${p.LoadingSkeleton} `;let $=n.styled.img` height: 14px; width: 14px; margin-right: 4px; object-fit: contain; `;const E=r=>{let{chain:s,transactionDetails:n,isTokenContractInfoLoading:i,symbol:l}=r,{action:a,functionName:d}=n;/*#__PURE__*/return e.jsx(b.Box,{children:/*#__PURE__*/e.jsxs(t.Rows,{children:["transaction"!==a&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Action"}),/*#__PURE__*/e.jsx(o.Value,{children:d})]}),"mint"===d&&"args"in n&&n.args.filter((e=>e)).map(((r,n)=>/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:`Param ${n}`}),/*#__PURE__*/e.jsx(o.Value,{children:"string"==typeof r&&g.isAddress(r)?/*#__PURE__*/e.jsx(h.Address,{address:r,url:s?.blockExplorers?.default?.url,showCopyIcon:!1}):r?.toString()})]},n))),"setApprovalForAll"===d&&n.operator&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Operator"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:n.operator,url:s?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===d&&void 0!==n.approved&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Set approval to"}),/*#__PURE__*/e.jsx(o.Value,{children:n.approved?"true":"false"})]}),"transfer"===d||"transferFrom"===d||"safeTransferFrom"===d||"approve"===d?/*#__PURE__*/e.jsxs(e.Fragment,{children:["formattedAmount"in n&&n.formattedAmount&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount"}),/*#__PURE__*/e.jsxs(o.Value,{$isLoading:i,children:[n.formattedAmount," ",l]})]}),"tokenId"in n&&n.tokenId&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token ID"}),/*#__PURE__*/e.jsx(o.Value,{children:n.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===d&&/*#__PURE__*/e.jsxs(e.Fragment,{children:["amounts"in n&&n.amounts&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amounts"}),/*#__PURE__*/e.jsx(o.Value,{children:n.amounts.join(", ")})]}),"tokenIds"in n&&n.tokenIds&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token IDs"}),/*#__PURE__*/e.jsx(o.Value,{children:n.tokenIds.join(", ")})]})]}),"approve"===d&&n.spender&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Spender"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:n.spender,url:s?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===d||"safeTransferFrom"===d||"safeBatchTransferFrom"===d)&&n.transferFrom&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Transferring from"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:n.transferFrom,url:s?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===d||"safeTransferFrom"===d||"safeBatchTransferFrom"===d)&&n.transferTo&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Transferring to"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:n.transferTo,url:s?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})},q=({variant:r,setPreventMaliciousTransaction:s,colorScheme:n="light",preventMaliciousTransaction:i})=>"warn"===r?/*#__PURE__*/e.jsx(D,{children:/*#__PURE__*/e.jsxs(y.WarningBanner,{theme:n,children:[/*#__PURE__*/e.jsx("span",{style:{fontWeight:"500"},children:"Warning: Suspicious transaction"}),/*#__PURE__*/e.jsx("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})}):"error"===r?/*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(D,{children:[/*#__PURE__*/e.jsx(f.ErrorBanner,{theme:n,children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx("strong",{children:"This is a malicious transaction"}),/*#__PURE__*/e.jsx("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})}),/*#__PURE__*/e.jsxs(O,{children:[/*#__PURE__*/e.jsx(w.Checkbox,{color:"var(--privy-color-error)",checked:!i,readOnly:!0,onClick:()=>s(!i)}),/*#__PURE__*/e.jsx("span",{children:"I understand and want to proceed anyways."})]})]})}):null;let D=n.styled.div` margin-top: 1.5rem; `,O=n.styled.div` display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; `;const N=({transactionIndex:e,maxIndex:r})=>"number"!=typeof e||0===r?"":` (${e+1} / ${r+1})`;let B=n.styled(u.WalletInfoCard)` ${e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;"} `,P=n.styled(t.Rows)` margin-top: 0.5rem; border: 1px solid var(--privy-color-foreground-4); border-radius: var(--privy-border-radius-sm); padding: 0.5rem; `,X="There was an error preparing your transaction. Your transaction request will likely fail.",W=n.styled.div` display: flex; width: 100%; justify-content: center; max-height: 40px; > img { object-fit: contain; border-radius: var(--privy-border-radius-sm); } `,z=n.styled.span` display: inline-flex; align-items: center; gap: 0.3rem; `,H=n.styled.span` font-size: 14px; font-weight: 500; color: var(--privy-color-foreground); `;let U=()=>/*#__PURE__*/e.jsxs(Y,{children:[/*#__PURE__*/e.jsx(Z,{}),/*#__PURE__*/e.jsx(K,{})]});let G=n.styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; `,J=n.styled.span` color: var(--privy-color-foreground); text-align: center; font-size: 1.125rem; font-weight: 500; line-height: 1.25rem; /* 111.111% */ text-align: center; margin: 10px; `,Q=n.styled.span` margin-top: 4px; margin-bottom: 10px; color: var(--privy-color-foreground-3); text-align: center; font-size: 0.875rem; font-style: normal; font-weight: 400; line-height: 20px; /* 142.857% */ letter-spacing: -0.008px; `,Y=n.styled.div` position: relative; width: 60px; height: 60px; margin: 10px; display: flex; justify-content: center; align-items: center; `,K=n.styled(T.default)` position: absolute; width: 35px; height: 35px; color: var(--privy-color-error); `,Z=n.styled.div` position: absolute; width: 60px; height: 60px; border-radius: 50%; background-color: var(--privy-color-error); opacity: 0.1; `,_=n.styled(l.PrimaryButton)` && { margin-top: 24px; } transition: color 350ms ease, background-color 350ms ease; `,ee=n.styled.span` width: 100%; text-align: left; font-size: 0.825rem; color: var(--privy-color-foreground); padding: 4px; `,re=n.styled.div` width: 100%; margin: 5px; display: flex; flex-direction: column; justify-content: center; align-items: center; `,se=n.styled.text` position: relative; width: 100%; padding: 5px; font-size: 0.8rem; color: var(--privy-color-foreground-3); text-align: left; word-wrap: break-word; `,ne=n.styled.span` position: relative; width: 100%; background-color: var(--privy-color-background-2); padding: 8px 12px; border-radius: 10px; margin-top: 5px; font-size: 14px; color: var(--privy-color-foreground-3); text-align: left; word-wrap: break-word; ${e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }"} `,ie=n.styled(I.default)` position: absolute; top: 13px; right: 13px; width: 24px; height: 24px; `,le=n.styled(R.default)` position: absolute; top: 13px; right: 13px; width: 24px; height: 24px; `,oe=({clicked:r})=>r?/*#__PURE__*/e.jsx(le,{}):/*#__PURE__*/e.jsx(ie,{});exports.SendSolanaTransactionScreenView=({img:n,title:u,subtitle:p,cta:g,instructions:b,network:w,blockExplorerUrl:f,isMissingFunds:y,submitError:S,parseError:k,total:v,swap:L,transactingWalletAddress:A,fee:R,balance:I,disabled:T,isSubmitting:C,isPreparing:M,isTokenPriceLoading:F,onClick:$,onClose:E,onBack:q,isSponsored:D})=>{let O=M||F,[N,U]=s.useState(!1),G=j.useAppConfig();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{onClose:E,backFn:q}),n&&/*#__PURE__*/e.jsx(W,{children:n}),/*#__PURE__*/e.jsx(x.Title,{style:{marginTop:n?"1.5rem":0},children:u}),/*#__PURE__*/e.jsx(c.Subtitle,{children:p}),/*#__PURE__*/e.jsxs(t.Rows,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(v||O)&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount"}),/*#__PURE__*/e.jsx(o.Value,{$isLoading:O,children:v})]}),L&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Swap"}),/*#__PURE__*/e.jsx(o.Value,{children:L})]}),w&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Network"}),/*#__PURE__*/e.jsx(o.Value,{children:w})]}),(R||O||void 0!==D)&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(o.Value,{$isLoading:O,children:D&&!O?/*#__PURE__*/e.jsxs(z,{children:[/*#__PURE__*/e.jsxs(H,{children:["Sponsored by ",G.name]}),/*#__PURE__*/e.jsx(r.BoltIcon,{height:16,width:16})]}):R})]})]}),/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(V,{onClick:()=>U((e=>!e)),children:[/*#__PURE__*/e.jsx("span",{children:"Advanced"}),/*#__PURE__*/e.jsx(r.ChevronDownIcon,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:N?"rotate(180deg)":void 0}})]})}),N&&/*#__PURE__*/e.jsx(e.Fragment,{children:b.map(((r,s)=>"sol-transfer"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Transfer ",r.withSeed?"with seed":""]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount"}),/*#__PURE__*/e.jsxs(o.Value,{children:[i.formatTokenAmount({amount:r.value,decimals:r.token.decimals})," ",r.token.symbol]})]}),!!r.toAccount&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Destination"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.toAccount,url:f})})]})]},s):"spl-transfer"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Transfer ",r.token.symbol]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount"}),/*#__PURE__*/e.jsx(o.Value,{children:r.value.toString()})]}),!!r.fromAta&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Source"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.fromAta,url:f})})]}),!!r.toAta&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Destination"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.toAta,url:f})})]}),!!r.token.address&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.token.address,url:f})})]})]},s):"ata-creation"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsx(d.LabelXs,{children:"Create token account"})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Program ID"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.program,url:f})})]}),!!r.owner&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Owner"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.owner,url:f})})]})]},s):"create-account"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Create account ",r.withSeed?"with seed":""]})}),!!r.account&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Account"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.account,url:f})})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount"}),/*#__PURE__*/e.jsxs(o.Value,{children:[i.formatTokenAmount({amount:r.value,decimals:9})," SOL"]})]})]},s):"spl-init-account"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsx(d.LabelXs,{children:"Initialize token account"})}),!!r.account&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Account"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.account,url:f})})]}),!!r.mint&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Mint"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mint,url:f})})]}),!!r.owner&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Owner"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.owner,url:f})})]})]},s):"spl-close-account"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsx(d.LabelXs,{children:"Close token account"})}),!!r.source&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Source"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.source,url:f})})]}),!!r.destination&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Destination"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.destination,url:f})})]}),!!r.owner&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Owner"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.owner,url:f})})]})]},s):"spl-sync-native"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsx(d.LabelXs,{children:"Sync native"})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Program ID"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.program,url:f})})]})]},s):"raydium-swap-base-input"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Raydium swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount in"}),/*#__PURE__*/e.jsx(o.Value,{children:r.amountIn.toString()})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Minimum amount out"}),/*#__PURE__*/e.jsx(o.Value,{children:r.minimumAmountOut.toString()})]}),r.mintIn&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token in"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintIn,url:f})})]}),r.mintOut&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token out"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintOut,url:f})})]})]},s):"raydium-swap-base-output"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Raydium swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Max amount in"}),/*#__PURE__*/e.jsx(o.Value,{children:r.maxAmountIn.toString()})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount out"}),/*#__PURE__*/e.jsx(o.Value,{children:r.amountOut.toString()})]}),r.mintIn&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token in"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintIn,url:f})})]}),r.mintOut&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token out"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintOut,url:f})})]})]},s):"jupiter-swap-shared-accounts-route"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Jupiter swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"In amount"}),/*#__PURE__*/e.jsx(o.Value,{children:r.inAmount.toString()})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Quoted out amount"}),/*#__PURE__*/e.jsx(o.Value,{children:r.quotedOutAmount.toString()})]}),r.mintIn&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token in"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintIn,url:f})})]}),r.mintOut&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token out"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintOut,url:f})})]})]},s):"jupiter-swap-exact-out-route"===r.type?/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(d.LabelXs,{children:["Jupiter swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Quoted in amount"}),/*#__PURE__*/e.jsx(o.Value,{children:r.quotedInAmount.toString()})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Amount out"}),/*#__PURE__*/e.jsx(o.Value,{children:r.outAmount.toString()})]}),r.mintIn&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token in"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintIn,url:f})})]}),r.mintOut&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token out"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.mintOut,url:f})})]})]},s):/*#__PURE__*/e.jsxs(P,{children:[/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Program ID"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:r.program,url:f})})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Data"}),/*#__PURE__*/e.jsx(o.Value,{children:r.discriminator})]})]},s)))}),/*#__PURE__*/e.jsx(m.Grow,{}),S?/*#__PURE__*/e.jsx(a.ErrorMessage,{style:{marginTop:"2rem"},children:S.message}):k?/*#__PURE__*/e.jsx(a.ErrorMessage,{style:{marginTop:"2rem"},children:X}):null,/*#__PURE__*/e.jsx(B,{$useSmallMargins:!(!k&&!S),title:"",address:A,balance:I,errMsg:M||k||S||!y?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e.jsx(l.PrimaryButton,{style:{marginTop:"1rem"},loading:C,disabled:T||M,onClick:$,children:g}),/*#__PURE__*/e.jsx(l.BlobbyFooter,{})]})},exports.SendTransactionScreenView=({img:n,submitError:i,prepareError:d,onClose:u,action:p,title:g,subtitle:b,to:w,tokenAddress:f,network:y,missingFunds:S,fee:k,from:v,cta:L,disabled:A,chain:R,isSubmitting:I,isPreparing:T,isTokenPriceLoading:M,isTokenContractInfoLoading:F,isSponsored:$,symbol:D,balance:O,onClick:P,transactionDetails:U,transactionIndex:G,maxIndex:J,onBack:Q,chainName:Y,validation:K,hasScanDetails:Z,setIsScanDetailsOpen:_,preventMaliciousTransaction:ee,setPreventMaliciousTransaction:re,tokensSent:se,tokensReceived:ne,isScanning:ie,isCancellable:le,functionName:oe})=>{let{showTransactionDetails:te,setShowTransactionDetails:ae,hasMoreDetails:de,isErc20Ish:ce}=(e=>{let[r,n]=s.useState(!1),i=!0,l=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(i=!1),i&&(l=Object.entries(e||{}).some((([e,r])=>r&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:r,setShowTransactionDetails:n,hasMoreDetails:i&&l,isErc20Ish:e?.isErc20Ish}})(U),xe=j.useAppConfig(),he=ce&&F||T||M||ie;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{onClose:u,backFn:Q}),n&&/*#__PURE__*/e.jsx(W,{children:n}),/*#__PURE__*/e.jsxs(x.Title,{style:{marginTop:n?"1.5rem":0},children:[g,/*#__PURE__*/e.jsx(N,{maxIndex:J,transactionIndex:G})]}),/*#__PURE__*/e.jsx(c.Subtitle,{children:b}),/*#__PURE__*/e.jsxs(t.Rows,{style:{marginTop:"2rem"},children:[(!!se[0]||he)&&/*#__PURE__*/e.jsxs(t.Row,{children:[ne.length>0?/*#__PURE__*/e.jsx(o.LabelSm,{children:"Send"}):/*#__PURE__*/e.jsx(o.LabelSm,{children:"approve"===p?"Approval amount":"Amount"}),/*#__PURE__*/e.jsx("div",{className:"flex flex-col",children:se.map(((r,s)=>/*#__PURE__*/e.jsx(C,{iconUrl:r.iconUrl,value:"setApprovalForAll"===oe?"All":r.value,usdValue:r.usdValue,symbol:r.symbol,nftName:r.nftName,nftCount:r.nftCount,decimals:r.decimals},s)))})]}),ne.length>0&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Receive"}),/*#__PURE__*/e.jsx("div",{className:"flex flex-col",children:ne.map(((r,s)=>/*#__PURE__*/e.jsx(C,{iconUrl:r.iconUrl,value:r.value,usdValue:r.usdValue,symbol:r.symbol,nftName:r.nftName,nftCount:r.nftCount,decimals:r.decimals},s)))})]}),U&&"spender"in U&&U?.spender?/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Spender"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:U.spender,url:R?.blockExplorers?.default?.url})})]}):null,w&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"To"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:w,url:R?.blockExplorers?.default?.url,showCopyIcon:!0})})]}),f&&/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Token address"}),/*#__PURE__*/e.jsx(o.Value,{children:/*#__PURE__*/e.jsx(h.Address,{address:f,url:R?.blockExplorers?.default?.url})})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Network"}),/*#__PURE__*/e.jsx(o.Value,{children:y})]}),/*#__PURE__*/e.jsxs(t.Row,{children:[/*#__PURE__*/e.jsx(o.LabelSm,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(o.Value,{$isLoading:T||M||void 0===$,children:$?/*#__PURE__*/e.jsxs(z,{children:[/*#__PURE__*/e.jsxs(H,{children:["Sponsored by ",xe.name]}),/*#__PURE__*/e.jsx(r.BoltIcon,{height:16,width:16})]}):k})]}),de&&!Z&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(t.Row,{className:"cursor-pointer",onClick:()=>ae(!te),children:/*#__PURE__*/e.jsxs(o.LabelSmPrimary,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/e.jsx(r.ChevronDownIcon,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:te?"rotate(180deg)":void 0}})]})}),te&&U&&/*#__PURE__*/e.jsx(E,{action:p,chain:R,transactionDetails:U,isTokenContractInfoLoading:F,symbol:D})]}),Z&&/*#__PURE__*/e.jsx(t.Row,{children:/*#__PURE__*/e.jsxs(V,{onClick:()=>_(!0),children:[/*#__PURE__*/e.jsx("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/e.jsx(r.ArrowRightIcon,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/e.jsx(m.Grow,{}),i?/*#__PURE__*/e.jsx(a.ErrorMessage,{style:{marginTop:"2rem"},children:i.message}):d&&0===G? /*#__PURE__*/e.jsx(a.ErrorMessage,{style:{marginTop:"2rem"},children:d.shortMessage??X}):null,/*#__PURE__*/e.jsx(q,{variant:K,preventMaliciousTransaction:ee,setPreventMaliciousTransaction:re}),/*#__PURE__*/e.jsx(B,{$useSmallMargins:!(!d&&!i&&"warn"!==K&&"error"!==K),address:v,balance:O,errMsg:T||d||i||!S?void 0:`Add funds on ${R?.name??Y} to complete transaction.`}),/*#__PURE__*/e.jsx(l.PrimaryButton,{style:{marginTop:"1rem"},loading:I,disabled:A||T,onClick:P,children:L}),le&&/*#__PURE__*/e.jsx(l.EmbeddedButton,{style:{marginTop:"1rem"},onClick:u,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e.jsx(l.BlobbyFooter,{})]})},exports.TransactionErrorView=({transactionError:r,chainId:n,onClose:i,onRetry:o,chainType:t,transactionHash:a})=>{let{chains:d}=L.usePrivyInternal(),[c,x]=s.useState(!1),{errorCode:h,errorMessage:u}=((e,r)=>{if("ethereum"===r)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let s=e.txSignature,n=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let r=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));r&&(n=r)}return{transactionHash:s,errorMessage:n}})(r,t),j=(({chains:e,chainId:r,chainType:s,transactionHash:n})=>"ethereum"===s?e.find((e=>e.id===r))?.blockExplorers?.default.url??"https://etherscan.io":function(e,r){return`https://explorer.solana.com/tx/${e}?chain=${r}`}(n||"",r))({chains:d,chainId:n,chainType:t,transactionHash:a});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{onClose:i}),/*#__PURE__*/e.jsxs(G,{children:[/*#__PURE__*/e.jsx(U,{}),/*#__PURE__*/e.jsx(J,{children:h}),/*#__PURE__*/e.jsx(Q,{children:"Please try again."}),/*#__PURE__*/e.jsxs(re,{children:[/*#__PURE__*/e.jsx(ee,{children:"Error message"}),/*#__PURE__*/e.jsx(ne,{$clickable:!1,children:u})]}),a&&/*#__PURE__*/e.jsxs(re,{children:[/*#__PURE__*/e.jsx(ee,{children:"Transaction hash"}),/*#__PURE__*/e.jsxs(se,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e.jsx("u",{children:/*#__PURE__*/e.jsx("a",{href:j,children:"block explorer"})}),"."]}),/*#__PURE__*/e.jsxs(ne,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(a),x(!0)},children:[a,/*#__PURE__*/e.jsx(oe,{clicked:c})]})]}),/*#__PURE__*/e.jsx(_,{onClick:()=>o({resetNonce:!!a}),children:"Retry transaction"})]}),/*#__PURE__*/e.jsx(l.ModalFooter,{})]})};