UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

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