@tuwaio/nova-transactions 1.0.0-fix-integrate-orbit-alpha.6.0264e04 → 1.0.0-fix-integrate-orbit-alpha.8.2a0be00
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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +15 -141
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.css
CHANGED
|
@@ -657,6 +657,16 @@
|
|
|
657
657
|
opacity: 70%;
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
+
.\[\&\>img\]\:h-auto {
|
|
661
|
+
&>img {
|
|
662
|
+
height: auto;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
.\[\&\>img\]\:w-full {
|
|
666
|
+
&>img {
|
|
667
|
+
width: 100%;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
660
670
|
}
|
|
661
671
|
/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */
|
|
662
672
|
@layer properties;
|
|
@@ -721,9 +731,6 @@
|
|
|
721
731
|
--tw-translate-y: -50%;
|
|
722
732
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
723
733
|
}
|
|
724
|
-
.animate-in {
|
|
725
|
-
animation: enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none);
|
|
726
|
-
}
|
|
727
734
|
.resize {
|
|
728
735
|
resize: both;
|
|
729
736
|
}
|
|
@@ -832,27 +839,20 @@
|
|
|
832
839
|
--tw-backdrop-saturate: saturate(150%);
|
|
833
840
|
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
|
|
834
841
|
}
|
|
842
|
+
.transition {
|
|
843
|
+
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events;
|
|
844
|
+
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
|
845
|
+
transition-duration: var(--tw-duration, 150ms);
|
|
846
|
+
}
|
|
835
847
|
.transition-colors {
|
|
836
848
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
|
837
849
|
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
|
838
850
|
transition-duration: var(--tw-duration, 150ms);
|
|
839
851
|
}
|
|
840
|
-
.duration-350 {
|
|
841
|
-
--tw-duration: 350ms;
|
|
842
|
-
transition-duration: 350ms;
|
|
843
|
-
}
|
|
844
|
-
.fade-in-0 {
|
|
845
|
-
--tw-enter-opacity: calc(0/100);
|
|
846
|
-
--tw-enter-opacity: 0;
|
|
847
|
-
}
|
|
848
852
|
.outline-none {
|
|
849
853
|
--tw-outline-style: none;
|
|
850
854
|
outline-style: none;
|
|
851
855
|
}
|
|
852
|
-
.zoom-in-95 {
|
|
853
|
-
--tw-enter-scale: calc(95*1%);
|
|
854
|
-
--tw-enter-scale: .95;
|
|
855
|
-
}
|
|
856
856
|
.sm\:flex-row {
|
|
857
857
|
@media (width >= 40rem) {
|
|
858
858
|
flex-direction: row;
|
|
@@ -873,90 +873,6 @@
|
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
}
|
|
876
|
-
@property --tw-animation-delay {
|
|
877
|
-
syntax: "*";
|
|
878
|
-
inherits: false;
|
|
879
|
-
initial-value: 0s;
|
|
880
|
-
}
|
|
881
|
-
@property --tw-animation-direction {
|
|
882
|
-
syntax: "*";
|
|
883
|
-
inherits: false;
|
|
884
|
-
initial-value: normal;
|
|
885
|
-
}
|
|
886
|
-
@property --tw-animation-duration {
|
|
887
|
-
syntax: "*";
|
|
888
|
-
inherits: false;
|
|
889
|
-
}
|
|
890
|
-
@property --tw-animation-fill-mode {
|
|
891
|
-
syntax: "*";
|
|
892
|
-
inherits: false;
|
|
893
|
-
initial-value: none;
|
|
894
|
-
}
|
|
895
|
-
@property --tw-animation-iteration-count {
|
|
896
|
-
syntax: "*";
|
|
897
|
-
inherits: false;
|
|
898
|
-
initial-value: 1;
|
|
899
|
-
}
|
|
900
|
-
@property --tw-enter-blur {
|
|
901
|
-
syntax: "*";
|
|
902
|
-
inherits: false;
|
|
903
|
-
initial-value: 0;
|
|
904
|
-
}
|
|
905
|
-
@property --tw-enter-opacity {
|
|
906
|
-
syntax: "*";
|
|
907
|
-
inherits: false;
|
|
908
|
-
initial-value: 1;
|
|
909
|
-
}
|
|
910
|
-
@property --tw-enter-rotate {
|
|
911
|
-
syntax: "*";
|
|
912
|
-
inherits: false;
|
|
913
|
-
initial-value: 0;
|
|
914
|
-
}
|
|
915
|
-
@property --tw-enter-scale {
|
|
916
|
-
syntax: "*";
|
|
917
|
-
inherits: false;
|
|
918
|
-
initial-value: 1;
|
|
919
|
-
}
|
|
920
|
-
@property --tw-enter-translate-x {
|
|
921
|
-
syntax: "*";
|
|
922
|
-
inherits: false;
|
|
923
|
-
initial-value: 0;
|
|
924
|
-
}
|
|
925
|
-
@property --tw-enter-translate-y {
|
|
926
|
-
syntax: "*";
|
|
927
|
-
inherits: false;
|
|
928
|
-
initial-value: 0;
|
|
929
|
-
}
|
|
930
|
-
@property --tw-exit-blur {
|
|
931
|
-
syntax: "*";
|
|
932
|
-
inherits: false;
|
|
933
|
-
initial-value: 0;
|
|
934
|
-
}
|
|
935
|
-
@property --tw-exit-opacity {
|
|
936
|
-
syntax: "*";
|
|
937
|
-
inherits: false;
|
|
938
|
-
initial-value: 1;
|
|
939
|
-
}
|
|
940
|
-
@property --tw-exit-rotate {
|
|
941
|
-
syntax: "*";
|
|
942
|
-
inherits: false;
|
|
943
|
-
initial-value: 0;
|
|
944
|
-
}
|
|
945
|
-
@property --tw-exit-scale {
|
|
946
|
-
syntax: "*";
|
|
947
|
-
inherits: false;
|
|
948
|
-
initial-value: 1;
|
|
949
|
-
}
|
|
950
|
-
@property --tw-exit-translate-x {
|
|
951
|
-
syntax: "*";
|
|
952
|
-
inherits: false;
|
|
953
|
-
initial-value: 0;
|
|
954
|
-
}
|
|
955
|
-
@property --tw-exit-translate-y {
|
|
956
|
-
syntax: "*";
|
|
957
|
-
inherits: false;
|
|
958
|
-
initial-value: 0;
|
|
959
|
-
}
|
|
960
876
|
:root {
|
|
961
877
|
--tuwa-success-bg: oklch(96.2% 0.044 156.743);
|
|
962
878
|
--tuwa-success-text: oklch(52.7% 0.154 150.069);
|
|
@@ -1077,13 +993,6 @@
|
|
|
1077
993
|
inherits: false;
|
|
1078
994
|
initial-value: 0;
|
|
1079
995
|
}
|
|
1080
|
-
@keyframes enter {
|
|
1081
|
-
from {
|
|
1082
|
-
opacity: var(--tw-enter-opacity,1);
|
|
1083
|
-
transform: translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0)scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1))rotate(var(--tw-enter-rotate,0));
|
|
1084
|
-
filter: blur(var(--tw-enter-blur,0));
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
996
|
@layer properties {
|
|
1088
997
|
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
1089
998
|
*, ::before, ::after, ::backdrop {
|
|
@@ -1117,25 +1026,7 @@
|
|
|
1117
1026
|
--tw-backdrop-opacity: initial;
|
|
1118
1027
|
--tw-backdrop-saturate: initial;
|
|
1119
1028
|
--tw-backdrop-sepia: initial;
|
|
1120
|
-
--tw-duration: initial;
|
|
1121
1029
|
--tw-space-x-reverse: 0;
|
|
1122
|
-
--tw-animation-delay: 0s;
|
|
1123
|
-
--tw-animation-direction: normal;
|
|
1124
|
-
--tw-animation-duration: initial;
|
|
1125
|
-
--tw-animation-fill-mode: none;
|
|
1126
|
-
--tw-animation-iteration-count: 1;
|
|
1127
|
-
--tw-enter-blur: 0;
|
|
1128
|
-
--tw-enter-opacity: 1;
|
|
1129
|
-
--tw-enter-rotate: 0;
|
|
1130
|
-
--tw-enter-scale: 1;
|
|
1131
|
-
--tw-enter-translate-x: 0;
|
|
1132
|
-
--tw-enter-translate-y: 0;
|
|
1133
|
-
--tw-exit-blur: 0;
|
|
1134
|
-
--tw-exit-opacity: 1;
|
|
1135
|
-
--tw-exit-rotate: 0;
|
|
1136
|
-
--tw-exit-scale: 1;
|
|
1137
|
-
--tw-exit-translate-x: 0;
|
|
1138
|
-
--tw-exit-translate-y: 0;
|
|
1139
1030
|
}
|
|
1140
1031
|
}
|
|
1141
1032
|
}
|
|
@@ -1324,23 +1215,6 @@
|
|
|
1324
1215
|
--tw-scale-x: 1;
|
|
1325
1216
|
--tw-scale-y: 1;
|
|
1326
1217
|
--tw-scale-z: 1;
|
|
1327
|
-
--tw-animation-delay: 0s;
|
|
1328
|
-
--tw-animation-direction: normal;
|
|
1329
|
-
--tw-animation-duration: initial;
|
|
1330
|
-
--tw-animation-fill-mode: none;
|
|
1331
|
-
--tw-animation-iteration-count: 1;
|
|
1332
|
-
--tw-enter-blur: 0;
|
|
1333
|
-
--tw-enter-opacity: 1;
|
|
1334
|
-
--tw-enter-rotate: 0;
|
|
1335
|
-
--tw-enter-scale: 1;
|
|
1336
|
-
--tw-enter-translate-x: 0;
|
|
1337
|
-
--tw-enter-translate-y: 0;
|
|
1338
|
-
--tw-exit-blur: 0;
|
|
1339
|
-
--tw-exit-opacity: 1;
|
|
1340
|
-
--tw-exit-rotate: 0;
|
|
1341
|
-
--tw-exit-scale: 1;
|
|
1342
|
-
--tw-exit-translate-x: 0;
|
|
1343
|
-
--tw-exit-translate-y: 0;
|
|
1344
1218
|
--tw-translate-x: 0;
|
|
1345
1219
|
--tw-translate-y: 0;
|
|
1346
1220
|
--tw-translate-z: 0;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ArrowTopRightOnSquareIcon,CheckIcon,DocumentDuplicateIcon,XMarkIcon,ArrowPathIcon,XCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,ClockIcon,ExclamationCircleIcon}from'@heroicons/react/24/solid';import {useCopyToClipboard,cn,textCenterEllipsis,Dialog,DialogContent,DialogHeader,DialogTitle,DialogClose,CloseIcon}from'@tuwaio/nova-core';import {createContext,useContext,useMemo,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {TransactionStatus,TransactionTracker,selectAllTransactionsByActiveWallet}from'@tuwaio/pulsar-core';import'react-toastify';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 Mt from'dayjs';import lo from'dayjs/plugin/relativeTime';import So from'ethereum-blockies-base64';var Y={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 Gt=createContext(Y);var u=()=>useContext(Gt);({[TransactionStatus.Success]:"success",[TransactionStatus.Failed]:"error",[TransactionStatus.Replaced]:"info"});function U({label:t,hash:e,explorerUrl:o,variant:r="default",className:s}){let{isCopied:n,copy:l}=useCopyToClipboard(),{actions:c,txError:p}=u(),a=cn("flex items-center justify-between",{"text-sm":r==="default","text-xs":r==="compact"},s),i=cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":r==="default","font-medium text-[var(--tuwa-text-secondary)]":r==="compact"}),d=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:a,children:[t&&jsxs("span",{className:i,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[o?jsxs("a",{href:o,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 xt={[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:o,variant:r,className:s,applyColor:n=false}){let l,c="";if(typeof e=="string")l=e;else if(Array.isArray(e)){let i=xt[t||"default"]??xt.default;l=e[i.index],n&&(c=i.colorClass);}else l=o;return l?jsx("div",{className:cn(r==="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 Yt({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:o="toast",className:r,renderHashLink:s,confirmations:n}){let{hashLabels:l,statuses:c}=u(),p=selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!p)return null;let a=x=>s?s(x):jsx(U,{...x}),i=o==="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)],g=d?a({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,f=(()=>{let x=t.hash,y=t.replacedTxHash;return !x&&!y?null:y?jsxs(Fragment,{children:[x&&a({label:l.original,hash:x,variant:"compact"}),typeof p.getExplorerTxUrl<"u"&&a({label:l.replaced,hash:y,explorerUrl:p.getExplorerTxUrl(t)})]}):x&&typeof p.getExplorerTxUrl<"u"&&a({label:l.default,hash:x,explorerUrl:p.getExplorerTxUrl(t)})})(),v=d&&d!==l.default&&t.txKey!==t.hash;return jsxs("div",{className:cn(i,r),children:[v&&g,f,typeof n=="number"&&jsxs("p",{className:"text-xs text-[var(--tuwa-text-tertiary)]",children:[c.confirmationsLabel,": ",n]})]})}var xe=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:o}=u(),r=useMemo(()=>xe(o),[o]),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?r[n]:null;if(!l)return jsx("div",{className:cn(s,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.unknown});let{label:c,Icon:p,badgeClasses:a,iconClasses:i}=l;return jsxs("div",{className:cn(s,a,e),children:[jsx(p,{className:cn("h-4 w-4",i)}),c]})}var we=({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}),Ce=({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}),he=({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 qt({openWalletInfoModal:t,tx:e,icon:o,className:r,customization:s,connectedWalletAddress:n,adapter:l}){let{actions:c,toast:p}=u(),a=selectAdapterByKey({adapterKey:e.adapter,adapter:l}),i=!!(e.tracker==="ethereum"&&e.pending&&a?.speedUpTxAction&&a?.cancelTxAction&&e.from.toLowerCase()===n?.toLowerCase()),d=()=>{i&&a.cancelTxAction(e);},g=()=>{i&&a.speedUpTxAction(e);},{StatusAwareText:f=B,TransactionKey:v=W,StatusBadge:x=_,SpeedUpButton:y=we,CancelButton:P=Ce,WalletInfoButton:T=he}=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",r),children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-[40px] flex-shrink-0",title:getChainName(setChainId(e.chainId)),children:o??jsx(Web3Icon,{className:"w-full h-full",chainId:setChainId(e.chainId)})}),jsxs("div",{className:"flex-1",children:[jsx(f,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsx(f,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[jsx(v,{adapter:l,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsx(x,{tx:e}),i?jsxs("div",{className:"flex items-center gap-4",children:[jsx(y,{onClick:g,children:c.speedUp}),jsx(P,{onClick:d,children:c.cancel})]}):t&&!!n&&jsx(T,{onClick:t,children:p.openWalletInfo})]})]})]})}function Qt({adapter:t,onClose:e,onOpenWalletInfo:o,className:r,customization:s,transactionsPool:n,executeTxAction:l,initialTx:c,connectedWalletAddress:p}){let a=useMemo(()=>c?.lastTxKey?n[c.lastTxKey]:void 0,[n,c]),i=a??c,d=c?.withTrackedModal&&!a||(a?.isTrackedModalOpen??false),{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}=useMemo(()=>{let R=a?.status,_t=c?.isInitializing??false,$t=a?.pending??false;return {isProcessing:_t||$t,isSucceed:R===TransactionStatus.Success,isFailed:a?.isError||!!c?.errorMessage,isReplaced:R===TransactionStatus.Replaced}},[a,c]),y=useMemo(()=>i?selectAdapterByKey({adapterKey:i.adapter,adapter:t}):void 0,[i,t]),P=!!(v&&i&&c?.actionFunction&&l),T=!!(y?.speedUpTxAction&&y?.cancelTxAction&&a?.pending&&a.tracker==="ethereum"),L=()=>{if(!P||!y?.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};y.retryTxAction({tx:R,txKey:a?.txKey??"",onClose:e,executeTxAction:l});},N=()=>{T&&a&&y.cancelTxAction(a);},A=()=>{T&&a&&y.speedUpTxAction(a);},z=s?.components?.Header,ct=s?.components?.Footer,pt=s?.components?.StatusVisual,dt=s?.components?.ProgressIndicator,ut=s?.components?.InfoBlock,mt=s?.components?.ErrorBlock;return i?jsx(Dialog,{open:d,onOpenChange:R=>!R&&e(a?.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",r),children:[z?jsx(z,{onClose:()=>e(a?.txKey),title:jsx(ht,{tx:i})}):jsx(Me,{onClose:()=>e(a?.txKey),title:jsx(ht,{tx:i})}),jsxs("main",{className:"flex flex-col gap-4 p-4",children:[pt?jsx(pt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}):jsx(kt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}),dt?jsx(dt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}):jsx(It,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}),ut?jsx(ut,{tx:i,adapter:t}):jsx(Nt,{tx:i,adapter:t}),mt?jsx(mt,{error:a?.errorMessage||c?.errorMessage}):jsx(Pt,{error:a?.errorMessage||c?.errorMessage})]}),ct?jsx(ct,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:g,isFailed:v,canReplace:T,onRetry:P?L:void 0,onSpeedUp:T?A:void 0,onCancel:T?N:void 0,connectedWalletAddress:p}):jsx(He,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:g,isFailed:v,canReplace:T,onRetry:P?L:void 0,onSpeedUp:T?A:void 0,onCancel:T?N:void 0,connectedWalletAddress:p})]})})}):null}function ht({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 Me=({onClose:t,title:e})=>{let{actions:o}=u();return jsxs(DialogHeader,{children:[jsx(DialogTitle,{children:e}),jsx(DialogClose,{asChild:true,children:jsx("button",{type:"button",onClick:()=>t(),"aria-label":o.close,className:`cursor-pointer rounded-full p-1
|
|
1
|
+
import {ArrowTopRightOnSquareIcon,CheckIcon,DocumentDuplicateIcon,XMarkIcon,ArrowPathIcon,XCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,ClockIcon,ExclamationCircleIcon}from'@heroicons/react/24/solid';import {useCopyToClipboard,cn,textCenterEllipsis,Dialog,DialogContent,DialogHeader,DialogTitle,DialogClose,CloseIcon}from'@tuwaio/nova-core';import {createContext,useContext,useMemo,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {TransactionStatus,TransactionTracker,selectAllTransactionsByActiveWallet}from'@tuwaio/pulsar-core';import'react-toastify';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 Mt from'dayjs';import lo from'dayjs/plugin/relativeTime';import So from'ethereum-blockies-base64';var Y={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 Gt=createContext(Y);var u=()=>useContext(Gt);({[TransactionStatus.Success]:"success",[TransactionStatus.Failed]:"error",[TransactionStatus.Replaced]:"info"});function U({label:t,hash:e,explorerUrl:o,variant:r="default",className:s}){let{isCopied:n,copy:l}=useCopyToClipboard(),{actions:c,txError:p}=u(),a=cn("flex items-center justify-between",{"text-sm":r==="default","text-xs":r==="compact"},s),i=cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":r==="default","font-medium text-[var(--tuwa-text-secondary)]":r==="compact"}),d=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:a,children:[t&&jsxs("span",{className:i,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[o?jsxs("a",{href:o,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 xt={[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:o,variant:r,className:s,applyColor:n=false}){let l,c="";if(typeof e=="string")l=e;else if(Array.isArray(e)){let i=xt[t||"default"]??xt.default;l=e[i.index],n&&(c=i.colorClass);}else l=o;return l?jsx("div",{className:cn(r==="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 Yt({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:o="toast",className:r,renderHashLink:s,confirmations:n}){let{hashLabels:l,statuses:c}=u(),p=selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!p)return null;let a=x=>s?s(x):jsx(U,{...x}),i=o==="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)],g=d?a({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,f=(()=>{let x=t.hash,y=t.replacedTxHash;return !x&&!y?null:y?jsxs(Fragment,{children:[x&&a({label:l.original,hash:x,variant:"compact"}),typeof p.getExplorerTxUrl<"u"&&a({label:l.replaced,hash:y,explorerUrl:p.getExplorerTxUrl(t)})]}):x&&typeof p.getExplorerTxUrl<"u"&&a({label:l.default,hash:x,explorerUrl:p.getExplorerTxUrl(t)})})(),v=d&&d!==l.default&&t.txKey!==t.hash;return jsxs("div",{className:cn(i,r),children:[v&&g,f,typeof n=="number"&&jsxs("p",{className:"text-xs text-[var(--tuwa-text-tertiary)]",children:[c.confirmationsLabel,": ",n]})]})}var xe=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:o}=u(),r=useMemo(()=>xe(o),[o]),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?r[n]:null;if(!l)return jsx("div",{className:cn(s,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.unknown});let{label:c,Icon:p,badgeClasses:a,iconClasses:i}=l;return jsxs("div",{className:cn(s,a,e),children:[jsx(p,{className:cn("h-4 w-4",i)}),c]})}var we=({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}),Ce=({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}),he=({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 qt({openWalletInfoModal:t,tx:e,icon:o,className:r,customization:s,connectedWalletAddress:n,adapter:l}){let{actions:c,toast:p}=u(),a=selectAdapterByKey({adapterKey:e.adapter,adapter:l}),i=!!(e.tracker==="ethereum"&&e.pending&&a?.speedUpTxAction&&a?.cancelTxAction&&e.from.toLowerCase()===n?.toLowerCase()),d=()=>{i&&a.cancelTxAction(e);},g=()=>{i&&a.speedUpTxAction(e);},{StatusAwareText:f=B,TransactionKey:v=W,StatusBadge:x=_,SpeedUpButton:y=we,CancelButton:P=Ce,WalletInfoButton:T=he}=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",r),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:o??jsx(Web3Icon,{chainId:setChainId(e.chainId)})}),jsxs("div",{className:"flex-1",children:[jsx(f,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsx(f,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[jsx(v,{adapter:l,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsx(x,{tx:e}),i?jsxs("div",{className:"flex items-center gap-4",children:[jsx(y,{onClick:g,children:c.speedUp}),jsx(P,{onClick:d,children:c.cancel})]}):t&&!!n&&jsx(T,{onClick:t,children:p.openWalletInfo})]})]})]})}function Qt({adapter:t,onClose:e,onOpenWalletInfo:o,className:r,customization:s,transactionsPool:n,executeTxAction:l,initialTx:c,connectedWalletAddress:p}){let a=useMemo(()=>c?.lastTxKey?n[c.lastTxKey]:void 0,[n,c]),i=a??c,d=c?.withTrackedModal&&!a||(a?.isTrackedModalOpen??false),{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}=useMemo(()=>{let R=a?.status,_t=c?.isInitializing??false,$t=a?.pending??false;return {isProcessing:_t||$t,isSucceed:R===TransactionStatus.Success,isFailed:a?.isError||!!c?.errorMessage,isReplaced:R===TransactionStatus.Replaced}},[a,c]),y=useMemo(()=>i?selectAdapterByKey({adapterKey:i.adapter,adapter:t}):void 0,[i,t]),P=!!(v&&i&&c?.actionFunction&&l),T=!!(y?.speedUpTxAction&&y?.cancelTxAction&&a?.pending&&a.tracker==="ethereum"),L=()=>{if(!P||!y?.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};y.retryTxAction({tx:R,txKey:a?.txKey??"",onClose:e,executeTxAction:l});},N=()=>{T&&a&&y.cancelTxAction(a);},A=()=>{T&&a&&y.speedUpTxAction(a);},z=s?.components?.Header,ct=s?.components?.Footer,pt=s?.components?.StatusVisual,dt=s?.components?.ProgressIndicator,ut=s?.components?.InfoBlock,mt=s?.components?.ErrorBlock;return i?jsx(Dialog,{open:d,onOpenChange:R=>!R&&e(a?.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",r),children:[z?jsx(z,{onClose:()=>e(a?.txKey),title:jsx(ht,{tx:i})}):jsx(Me,{onClose:()=>e(a?.txKey),title:jsx(ht,{tx:i})}),jsxs("main",{className:"flex flex-col gap-4 p-4",children:[pt?jsx(pt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}):jsx(kt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}),dt?jsx(dt,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}):jsx(It,{isProcessing:g,isSucceed:f,isFailed:v,isReplaced:x}),ut?jsx(ut,{tx:i,adapter:t}):jsx(Nt,{tx:i,adapter:t}),mt?jsx(mt,{error:a?.errorMessage||c?.errorMessage}):jsx(Pt,{error:a?.errorMessage||c?.errorMessage})]}),ct?jsx(ct,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:g,isFailed:v,canReplace:T,onRetry:P?L:void 0,onSpeedUp:T?A:void 0,onCancel:T?N:void 0,connectedWalletAddress:p}):jsx(He,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:g,isFailed:v,canReplace:T,onRetry:P?L:void 0,onSpeedUp:T?A:void 0,onCancel:T?N:void 0,connectedWalletAddress:p})]})})}):null}function ht({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 Me=({onClose:t,title:e})=>{let{actions:o}=u();return jsxs(DialogHeader,{children:[jsx(DialogTitle,{children:e}),jsx(DialogClose,{asChild:true,children:jsx("button",{type:"button",onClick:()=>t(),"aria-label":o.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,{})})})]})},He=({onClose:t,onOpenWalletInfo:e,isProcessing:o,onRetry:r,onSpeedUp:s,onCancel:n,canReplace:l,isFailed:c,connectedWalletAddress:p})=>{let{trackingModal:a,actions:i}=u(),d=()=>c&&r?jsx("button",{type:"button",onClick:r,className:`cursor-pointer rounded-md
|
|
4
4
|
bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)]
|