@tuwaio/nova-transactions 1.0.0-fix-integrate-orbit-alpha.6.0264e04 → 1.0.0-fix-integrate-orbit-alpha.7.37786c4

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.
@@ -1,4 +1,4 @@
1
- import {createContext,useContext,useState,useRef,useMemo,useCallback,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMediaQuery,deepMerge,cn,Dialog,DialogContent,DialogHeader,DialogTitle,DialogClose,CloseIcon,textCenterEllipsis,useCopyToClipboard}from'@tuwaio/nova-core';import {TransactionStatus,selectAllTransactionsByActiveWallet,TransactionTracker}from'@tuwaio/pulsar-core';import {toast,ToastContainer}from'react-toastify';import {XMarkIcon,ClockIcon,ArrowPathIcon,ExclamationCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,CheckIcon,DocumentDuplicateIcon,XCircleIcon,ArrowTopRightOnSquareIcon}from'@heroicons/react/24/solid';import {Web3Icon}from'@bgd-labs/react-web3-icons';import {getChainName}from'@bgd-labs/react-web3-icons/dist/utils';import {selectAdapterByKey,setChainId,OrbitAdapter}from'@tuwaio/orbit-core';import Lt from'dayjs';import io from'dayjs/plugin/relativeTime';import Co from'ethereum-blockies-base64';var V={walletModal:{title:"Wallet & Transactions",header:{notConnected:"Wallet not connected",avatarAlt:"Avatar for"},history:{title:"Transactions History",connectWalletTitle:"Connect Wallet",connectWalletMessage:"Please connect your wallet to see your past activity.",noTransactionsTitle:"No Transactions Yet",noTransactionsMessage:"Once you interact with the app, your transaction history will appear here."}},toast:{openWalletInfo:"Open wallet info"},statuses:{pending:"Pending",success:"Success",failed:"Failed",reverted:"Reverted",replaced:"Replaced",unknown:"Unknown",confirmationsLabel:"Confirmations"},hashLabels:{gelato:"Gelato Task ID",safe:"Safe Tx Hash",original:"Original Tx Hash",replaced:"Replaced Tx Hash",default:"Tx Hash",recentBlockhash:"Recent Blockhash",solana:"Signature"},txInfo:{started:"Started",network:"Network",slot:"Slot"},txError:{title:"Error",copied:"Copied!"},trackingModal:{title:"Transaction Overview",processing:"Processing...",close:"Close",walletInfo:"Wallet Info",retry:"Retry",progressIndicator:{created:"Created",processing:"Processing",succeed:"Succeed"}},trackedTxButton:{loading:"Processing...",succeed:"Success",failed:"Failed",replaced:"Replaced"},actions:{copy:"Copy address",viewOnExplorer:"View on explorer",close:"Close",cancel:"Cancel",speedUp:"Speed up"}};var dt=createContext(V),ut=({labels:t,children:e})=>jsx(dt.Provider,{value:t,children:e}),u=()=>useContext(dt);function U({label:t,hash:e,explorerUrl:a,variant:o="default",className:s}){let{isCopied:n,copy:l}=useCopyToClipboard(),{actions:c,txError:p}=u(),r=cn("flex items-center justify-between",{"text-sm":o==="default","text-xs":o==="compact"},s),i=cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":o==="default","font-medium text-[var(--tuwa-text-secondary)]":o==="compact"}),d=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:r,children:[t&&jsxs("span",{className:i,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[a?jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-x-1 text-[var(--tuwa-text-accent)] transition-colors hover:underline",title:c.viewOnExplorer,"aria-label":c.viewOnExplorer,children:[d,jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):jsx("span",{className:"text-[var(--tuwa-text-primary)]",children:d}),jsx("button",{type:"button",onClick:()=>l(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:n?p.copied:c.copy,"aria-label":n?p.copied:c.copy,children:n?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var ft={[TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[TransactionStatus.Replaced]:{index:3,colorClass:"text-[var(--tuwa-text-secondary)]"},default:{index:0,colorClass:"text-[var(--tuwa-text-primary)]"}};function B({txStatus:t,source:e,fallback:a,variant:o,className:s,applyColor:n=false}){let l,c="";if(typeof e=="string")l=e;else if(Array.isArray(e)){let i=ft[t||"default"]??ft.default;l=e[i.index],n&&(c=i.colorClass);}else l=a;return l?jsx("div",{className:cn(o==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]",c,s),children:l}):null}function Tt({closeToast:t}){let{actions:e}=u();return jsx("button",{type:"button",onClick:t,"aria-label":e.close,title:e.close,className:cn("absolute top-2 right-2 cursor-pointer rounded-full p-1","text-[var(--tuwa-text-tertiary)] transition-colors","hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]"),children:jsx(XMarkIcon,{className:"h-5 w-5"})})}function W({tx:t,adapter:e,variant:a="toast",className:o,renderHashLink:s,confirmations:n}){let{hashLabels:l,statuses:c}=u(),p=selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!p)return null;let r=f=>s?s(f):jsx(U,{...f}),i=a==="toast"?"mt-2 flex w-full flex-col gap-y-2 border-t border-[var(--tuwa-border-primary)] pt-2":"flex w-full flex-col gap-y-2",d=l[String(t.tracker)],T=d?r({label:d,hash:t.txKey,variant:t.tracker!==TransactionTracker.Solana?"compact":"default",explorerUrl:p.getExplorerTxUrl&&t.tracker===TransactionTracker.Solana?p?.getExplorerTxUrl(t):void 0}):null,v=(()=>{let f=t.hash,g=t.replacedTxHash;return !f&&!g?null:g?jsxs(Fragment,{children:[f&&r({label:l.original,hash:f,variant:"compact"}),typeof p.getExplorerTxUrl<"u"&&r({label:l.replaced,hash:g,explorerUrl:p.getExplorerTxUrl(t)})]}):f&&typeof p.getExplorerTxUrl<"u"&&r({label:l.default,hash:f,explorerUrl:p.getExplorerTxUrl(t)})})(),b=d&&d!==l.default&&t.txKey!==t.hash;return jsxs("div",{className:cn(i,o),children:[b&&T,v,typeof n=="number"&&jsxs("p",{className:"text-xs text-[var(--tuwa-text-tertiary)]",children:[c.confirmationsLabel,": ",n]})]})}var fe=t=>({Pending:{label:t.pending,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[TransactionStatus.Success]:{label:t.success,Icon:CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[TransactionStatus.Failed]:{label:t.failed,Icon:XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[TransactionStatus.Replaced]:{label:t.replaced,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",iconClasses:"text-[var(--tuwa-info-icon)]"}});function $({tx:t,className:e}){let{statuses:a}=u(),o=useMemo(()=>fe(a),[a]),s="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",n=t.pending?"Pending":t.status,l=n?o[n]:null;if(!l)return jsx("div",{className:cn(s,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??a.unknown});let{label:c,Icon:p,badgeClasses:r,iconClasses:i}=l;return jsxs("div",{className:cn(s,r,e),children:[jsx(p,{className:cn("h-4 w-4",i)}),c]})}var be=({onClick:t,children:e})=>jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:e}),we=({onClick:t,children:e})=>jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:e}),Ce=({onClick:t,children:e})=>jsx("button",{className:"cursor-pointer rounded-md bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] px-3 py-1 text-xs font-bold text-[var(--tuwa-text-on-accent)] shadow-lg transition-all duration-200 ease-in-out hover:shadow-xl hover:from-[var(--tuwa-button-gradient-from-hover)] hover:to-[var(--tuwa-button-gradient-to-hover)] active:scale-95",onClick:t,type:"button",children:e});function wt({openWalletInfoModal:t,tx:e,icon:a,className:o,customization:s,connectedWalletAddress:n,adapter:l}){let{actions:c,toast:p}=u(),r=selectAdapterByKey({adapterKey:e.adapter,adapter:l}),i=!!(e.tracker==="ethereum"&&e.pending&&r?.speedUpTxAction&&r?.cancelTxAction&&e.from.toLowerCase()===n?.toLowerCase()),d=()=>{i&&r.cancelTxAction(e);},T=()=>{i&&r.speedUpTxAction(e);},{StatusAwareText:v=B,TransactionKey:b=W,StatusBadge:f=$,SpeedUpButton:g=be,CancelButton:h=we,WalletInfoButton:x=Ce}=s?.components??{};return jsxs("div",{className:cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",o),children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-[40px] flex-shrink-0",title:getChainName(setChainId(e.chainId)),children:a??jsx(Web3Icon,{className:"w-full h-full",chainId:setChainId(e.chainId)})}),jsxs("div",{className:"flex-1",children:[jsx(v,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsx(v,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[jsx(b,{adapter:l,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsx(f,{tx:e}),i?jsxs("div",{className:"flex items-center gap-4",children:[jsx(g,{onClick:T,children:c.speedUp}),jsx(h,{onClick:d,children:c.cancel})]}):t&&!!n&&jsx(x,{onClick:t,children:p.openWalletInfo})]})]})]})}function Nt({adapter:t,onClose:e,onOpenWalletInfo:a,className:o,customization:s,transactionsPool:n,executeTxAction:l,initialTx:c,connectedWalletAddress:p}){let r=useMemo(()=>c?.lastTxKey?n[c.lastTxKey]:void 0,[n,c]),i=r??c,d=c?.withTrackedModal&&!r||(r?.isTrackedModalOpen??false),{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}=useMemo(()=>{let R=r?.status,Xt=c?.isInitializing??false,Gt=r?.pending??false;return {isProcessing:Xt||Gt,isSucceed:R===TransactionStatus.Success,isFailed:r?.isError||!!c?.errorMessage,isReplaced:R===TransactionStatus.Replaced}},[r,c]),g=useMemo(()=>i?selectAdapterByKey({adapterKey:i.adapter,adapter:t}):void 0,[i,t]),h=!!(b&&i&&c?.actionFunction&&l),x=!!(g?.speedUpTxAction&&g?.cancelTxAction&&r?.pending&&r.tracker==="ethereum"),L=()=>{if(!h||!g?.retryTxAction)return;let R={adapter:i.adapter,type:i.type,desiredChainID:"desiredChainID"in i?i.desiredChainID:i.chainId,actionFunction:c?.actionFunction,title:i.title,description:i.description,payload:i.payload,withTrackedModal:true};g.retryTxAction({tx:R,txKey:r?.txKey??"",onClose:e,executeTxAction:l});},w=()=>{x&&r&&g.cancelTxAction(r);},y=()=>{x&&r&&g.speedUpTxAction(r);},k=s?.components?.Header,z=s?.components?.Footer,it=s?.components?.StatusVisual,lt=s?.components?.ProgressIndicator,ct=s?.components?.InfoBlock,pt=s?.components?.ErrorBlock;return i?jsx(Dialog,{open:d,onOpenChange:R=>!R&&e(r?.txKey),children:jsx(DialogContent,{className:cn("max-w-md",s?.modalProps?.className),...s?.modalProps,children:jsxs("div",{className:cn("relative flex w-full flex-col",o),children:[k?jsx(k,{onClose:()=>e(r?.txKey),title:jsx(Pt,{tx:i})}):jsx(Be,{onClose:()=>e(r?.txKey),title:jsx(Pt,{tx:i})}),jsxs("main",{className:"flex flex-col gap-4 p-4",children:[it?jsx(it,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}):jsx(At,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}),lt?jsx(lt,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}):jsx(St,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}),ct?jsx(ct,{tx:i,adapter:t}):jsx(kt,{tx:i,adapter:t}),pt?jsx(pt,{error:r?.errorMessage||c?.errorMessage}):jsx(It,{error:r?.errorMessage||c?.errorMessage})]}),z?jsx(z,{onClose:()=>e(r?.txKey),onOpenWalletInfo:a,isProcessing:T,isFailed:b,canReplace:x,onRetry:h?L:void 0,onSpeedUp:x?y:void 0,onCancel:x?w:void 0,connectedWalletAddress:p}):jsx(Me,{onClose:()=>e(r?.txKey),onOpenWalletInfo:a,isProcessing:T,isFailed:b,canReplace:x,onRetry:h?L:void 0,onSpeedUp:x?y:void 0,onCancel:x?w:void 0,connectedWalletAddress:p})]})})}):null}function Pt({tx:t}){return jsx(B,{txStatus:"status"in t?t.status:void 0,source:t.title,fallback:t.type,variant:"title",className:"text-lg"})}var Be=({onClose:t,title:e})=>{let{actions:a}=u();return jsxs(DialogHeader,{children:[jsx(DialogTitle,{children:e}),jsx(DialogClose,{asChild:true,children:jsx("button",{type:"button",onClick:()=>t(),"aria-label":a.close,className:`cursor-pointer rounded-full p-1
1
+ import {createContext,useContext,useState,useRef,useMemo,useCallback,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMediaQuery,deepMerge,cn,Dialog,DialogContent,DialogHeader,DialogTitle,DialogClose,CloseIcon,textCenterEllipsis,useCopyToClipboard}from'@tuwaio/nova-core';import {TransactionStatus,selectAllTransactionsByActiveWallet,TransactionTracker}from'@tuwaio/pulsar-core';import {toast,ToastContainer}from'react-toastify';import {XMarkIcon,ClockIcon,ArrowPathIcon,ExclamationCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,CheckIcon,DocumentDuplicateIcon,XCircleIcon,ArrowTopRightOnSquareIcon}from'@heroicons/react/24/solid';import {Web3Icon}from'@bgd-labs/react-web3-icons';import {getChainName}from'@bgd-labs/react-web3-icons/dist/utils';import {selectAdapterByKey,setChainId,OrbitAdapter}from'@tuwaio/orbit-core';import Lt from'dayjs';import io from'dayjs/plugin/relativeTime';import Co from'ethereum-blockies-base64';var V={walletModal:{title:"Wallet & Transactions",header:{notConnected:"Wallet not connected",avatarAlt:"Avatar for"},history:{title:"Transactions History",connectWalletTitle:"Connect Wallet",connectWalletMessage:"Please connect your wallet to see your past activity.",noTransactionsTitle:"No Transactions Yet",noTransactionsMessage:"Once you interact with the app, your transaction history will appear here."}},toast:{openWalletInfo:"Open wallet info"},statuses:{pending:"Pending",success:"Success",failed:"Failed",reverted:"Reverted",replaced:"Replaced",unknown:"Unknown",confirmationsLabel:"Confirmations"},hashLabels:{gelato:"Gelato Task ID",safe:"Safe Tx Hash",original:"Original Tx Hash",replaced:"Replaced Tx Hash",default:"Tx Hash",recentBlockhash:"Recent Blockhash",solana:"Signature"},txInfo:{started:"Started",network:"Network",slot:"Slot"},txError:{title:"Error",copied:"Copied!"},trackingModal:{title:"Transaction Overview",processing:"Processing...",close:"Close",walletInfo:"Wallet Info",retry:"Retry",progressIndicator:{created:"Created",processing:"Processing",succeed:"Succeed"}},trackedTxButton:{loading:"Processing...",succeed:"Success",failed:"Failed",replaced:"Replaced"},actions:{copy:"Copy address",viewOnExplorer:"View on explorer",close:"Close",cancel:"Cancel",speedUp:"Speed up"}};var dt=createContext(V),ut=({labels:t,children:e})=>jsx(dt.Provider,{value:t,children:e}),u=()=>useContext(dt);function U({label:t,hash:e,explorerUrl:a,variant:o="default",className:s}){let{isCopied:n,copy:l}=useCopyToClipboard(),{actions:c,txError:p}=u(),r=cn("flex items-center justify-between",{"text-sm":o==="default","text-xs":o==="compact"},s),i=cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":o==="default","font-medium text-[var(--tuwa-text-secondary)]":o==="compact"}),d=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:r,children:[t&&jsxs("span",{className:i,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[a?jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-x-1 text-[var(--tuwa-text-accent)] transition-colors hover:underline",title:c.viewOnExplorer,"aria-label":c.viewOnExplorer,children:[d,jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):jsx("span",{className:"text-[var(--tuwa-text-primary)]",children:d}),jsx("button",{type:"button",onClick:()=>l(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:n?p.copied:c.copy,"aria-label":n?p.copied:c.copy,children:n?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var ft={[TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[TransactionStatus.Replaced]:{index:3,colorClass:"text-[var(--tuwa-text-secondary)]"},default:{index:0,colorClass:"text-[var(--tuwa-text-primary)]"}};function B({txStatus:t,source:e,fallback:a,variant:o,className:s,applyColor:n=false}){let l,c="";if(typeof e=="string")l=e;else if(Array.isArray(e)){let i=ft[t||"default"]??ft.default;l=e[i.index],n&&(c=i.colorClass);}else l=a;return l?jsx("div",{className:cn(o==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]",c,s),children:l}):null}function Tt({closeToast:t}){let{actions:e}=u();return jsx("button",{type:"button",onClick:t,"aria-label":e.close,title:e.close,className:cn("absolute top-2 right-2 cursor-pointer rounded-full p-1","text-[var(--tuwa-text-tertiary)] transition-colors","hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]"),children:jsx(XMarkIcon,{className:"h-5 w-5"})})}function W({tx:t,adapter:e,variant:a="toast",className:o,renderHashLink:s,confirmations:n}){let{hashLabels:l,statuses:c}=u(),p=selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!p)return null;let r=f=>s?s(f):jsx(U,{...f}),i=a==="toast"?"mt-2 flex w-full flex-col gap-y-2 border-t border-[var(--tuwa-border-primary)] pt-2":"flex w-full flex-col gap-y-2",d=l[String(t.tracker)],T=d?r({label:d,hash:t.txKey,variant:t.tracker!==TransactionTracker.Solana?"compact":"default",explorerUrl:p.getExplorerTxUrl&&t.tracker===TransactionTracker.Solana?p?.getExplorerTxUrl(t):void 0}):null,v=(()=>{let f=t.hash,g=t.replacedTxHash;return !f&&!g?null:g?jsxs(Fragment,{children:[f&&r({label:l.original,hash:f,variant:"compact"}),typeof p.getExplorerTxUrl<"u"&&r({label:l.replaced,hash:g,explorerUrl:p.getExplorerTxUrl(t)})]}):f&&typeof p.getExplorerTxUrl<"u"&&r({label:l.default,hash:f,explorerUrl:p.getExplorerTxUrl(t)})})(),b=d&&d!==l.default&&t.txKey!==t.hash;return jsxs("div",{className:cn(i,o),children:[b&&T,v,typeof n=="number"&&jsxs("p",{className:"text-xs text-[var(--tuwa-text-tertiary)]",children:[c.confirmationsLabel,": ",n]})]})}var fe=t=>({Pending:{label:t.pending,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[TransactionStatus.Success]:{label:t.success,Icon:CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[TransactionStatus.Failed]:{label:t.failed,Icon:XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[TransactionStatus.Replaced]:{label:t.replaced,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",iconClasses:"text-[var(--tuwa-info-icon)]"}});function $({tx:t,className:e}){let{statuses:a}=u(),o=useMemo(()=>fe(a),[a]),s="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",n=t.pending?"Pending":t.status,l=n?o[n]:null;if(!l)return jsx("div",{className:cn(s,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??a.unknown});let{label:c,Icon:p,badgeClasses:r,iconClasses:i}=l;return jsxs("div",{className:cn(s,r,e),children:[jsx(p,{className:cn("h-4 w-4",i)}),c]})}var be=({onClick:t,children:e})=>jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:e}),we=({onClick:t,children:e})=>jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:e}),Ce=({onClick:t,children:e})=>jsx("button",{className:"cursor-pointer rounded-md bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] px-3 py-1 text-xs font-bold text-[var(--tuwa-text-on-accent)] shadow-lg transition-all duration-200 ease-in-out hover:shadow-xl hover:from-[var(--tuwa-button-gradient-from-hover)] hover:to-[var(--tuwa-button-gradient-to-hover)] active:scale-95",onClick:t,type:"button",children:e});function wt({openWalletInfoModal:t,tx:e,icon:a,className:o,customization:s,connectedWalletAddress:n,adapter:l}){let{actions:c,toast:p}=u(),r=selectAdapterByKey({adapterKey:e.adapter,adapter:l}),i=!!(e.tracker==="ethereum"&&e.pending&&r?.speedUpTxAction&&r?.cancelTxAction&&e.from.toLowerCase()===n?.toLowerCase()),d=()=>{i&&r.cancelTxAction(e);},T=()=>{i&&r.speedUpTxAction(e);},{StatusAwareText:v=B,TransactionKey:b=W,StatusBadge:f=$,SpeedUpButton:g=be,CancelButton:h=we,WalletInfoButton:x=Ce}=s?.components??{};return jsxs("div",{className:cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",o),children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-[40px] flex-shrink-0 [&>img]:w-full [&>img]:h-auto",title:getChainName(setChainId(e.chainId)),children:a??jsx(Web3Icon,{chainId:setChainId(e.chainId)})}),jsxs("div",{className:"flex-1",children:[jsx(v,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsx(v,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[jsx(b,{adapter:l,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsx(f,{tx:e}),i?jsxs("div",{className:"flex items-center gap-4",children:[jsx(g,{onClick:T,children:c.speedUp}),jsx(h,{onClick:d,children:c.cancel})]}):t&&!!n&&jsx(x,{onClick:t,children:p.openWalletInfo})]})]})]})}function Nt({adapter:t,onClose:e,onOpenWalletInfo:a,className:o,customization:s,transactionsPool:n,executeTxAction:l,initialTx:c,connectedWalletAddress:p}){let r=useMemo(()=>c?.lastTxKey?n[c.lastTxKey]:void 0,[n,c]),i=r??c,d=c?.withTrackedModal&&!r||(r?.isTrackedModalOpen??false),{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}=useMemo(()=>{let R=r?.status,Xt=c?.isInitializing??false,Gt=r?.pending??false;return {isProcessing:Xt||Gt,isSucceed:R===TransactionStatus.Success,isFailed:r?.isError||!!c?.errorMessage,isReplaced:R===TransactionStatus.Replaced}},[r,c]),g=useMemo(()=>i?selectAdapterByKey({adapterKey:i.adapter,adapter:t}):void 0,[i,t]),h=!!(b&&i&&c?.actionFunction&&l),x=!!(g?.speedUpTxAction&&g?.cancelTxAction&&r?.pending&&r.tracker==="ethereum"),L=()=>{if(!h||!g?.retryTxAction)return;let R={adapter:i.adapter,type:i.type,desiredChainID:"desiredChainID"in i?i.desiredChainID:i.chainId,actionFunction:c?.actionFunction,title:i.title,description:i.description,payload:i.payload,withTrackedModal:true};g.retryTxAction({tx:R,txKey:r?.txKey??"",onClose:e,executeTxAction:l});},w=()=>{x&&r&&g.cancelTxAction(r);},y=()=>{x&&r&&g.speedUpTxAction(r);},k=s?.components?.Header,z=s?.components?.Footer,it=s?.components?.StatusVisual,lt=s?.components?.ProgressIndicator,ct=s?.components?.InfoBlock,pt=s?.components?.ErrorBlock;return i?jsx(Dialog,{open:d,onOpenChange:R=>!R&&e(r?.txKey),children:jsx(DialogContent,{className:cn("max-w-md",s?.modalProps?.className),...s?.modalProps,children:jsxs("div",{className:cn("relative flex w-full flex-col",o),children:[k?jsx(k,{onClose:()=>e(r?.txKey),title:jsx(Pt,{tx:i})}):jsx(Be,{onClose:()=>e(r?.txKey),title:jsx(Pt,{tx:i})}),jsxs("main",{className:"flex flex-col gap-4 p-4",children:[it?jsx(it,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}):jsx(At,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}),lt?jsx(lt,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}):jsx(St,{isProcessing:T,isSucceed:v,isFailed:b,isReplaced:f}),ct?jsx(ct,{tx:i,adapter:t}):jsx(kt,{tx:i,adapter:t}),pt?jsx(pt,{error:r?.errorMessage||c?.errorMessage}):jsx(It,{error:r?.errorMessage||c?.errorMessage})]}),z?jsx(z,{onClose:()=>e(r?.txKey),onOpenWalletInfo:a,isProcessing:T,isFailed:b,canReplace:x,onRetry:h?L:void 0,onSpeedUp:x?y:void 0,onCancel:x?w:void 0,connectedWalletAddress:p}):jsx(Me,{onClose:()=>e(r?.txKey),onOpenWalletInfo:a,isProcessing:T,isFailed:b,canReplace:x,onRetry:h?L:void 0,onSpeedUp:x?y:void 0,onCancel:x?w:void 0,connectedWalletAddress:p})]})})}):null}function Pt({tx:t}){return jsx(B,{txStatus:"status"in t?t.status:void 0,source:t.title,fallback:t.type,variant:"title",className:"text-lg"})}var Be=({onClose:t,title:e})=>{let{actions:a}=u();return jsxs(DialogHeader,{children:[jsx(DialogTitle,{children:e}),jsx(DialogClose,{asChild:true,children:jsx("button",{type:"button",onClick:()=>t(),"aria-label":a.close,className:`cursor-pointer rounded-full p-1
2
2
  text-[var(--tuwa-text-tertiary)] transition-colors
3
3
  hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]`,children:jsx(CloseIcon,{})})})]})},Me=({onClose:t,onOpenWalletInfo:e,isProcessing:a,onRetry:o,onSpeedUp:s,onCancel:n,canReplace:l,isFailed:c,connectedWalletAddress:p})=>{let{trackingModal:r,actions:i}=u(),d=()=>c&&o?jsx("button",{type:"button",onClick:o,className:`cursor-pointer rounded-md
4
4
  bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)]