@@ -39,6 +39,10 @@ import type { BridgeMode } from '@/api/types';
3939
4040type RechargeStep = 'connect' | 'swap' | 'confirm' | 'processing' | 'success' ;
4141
42+ function normalizeIdForCompare ( value : string | undefined ) : string {
43+ return value ?. trim ( ) . toLowerCase ( ) ?? '' ;
44+ }
45+
4246const TOKEN_COLORS : Record < string , string > = {
4347 ETH : 'bg-indigo-600' ,
4448 BSC : 'bg-yellow-600' ,
@@ -229,6 +233,17 @@ export default function App() {
229233
230234 const handleConfirm = useCallback ( async ( ) => {
231235 if ( ! externalAccount || ! internalAccount || ! selectedOption ) return ;
236+ const expectedExternalChain = normalizeChainId ( selectedOption . externalChain ) ;
237+ if ( normalizeIdForCompare ( externalAccount . chain ) !== normalizeIdForCompare ( expectedExternalChain ) ) {
238+ setError ( t ( 'error.accountChainMismatch' ) ) ;
239+ setRechargeStep ( 'connect' ) ;
240+ return ;
241+ }
242+ if ( normalizeIdForCompare ( internalAccount . chain ) !== normalizeIdForCompare ( selectedOption . internalChain ) ) {
243+ setError ( t ( 'error.accountChainMismatch' ) ) ;
244+ setRechargeStep ( 'connect' ) ;
245+ return ;
246+ }
232247 const tokenAddress = selectedOption . externalInfo . contract ?. trim ( ) ;
233248 let effectiveExternalDecimals = resolvedExternalDecimals ;
234249 if ( tokenAddress && effectiveExternalDecimals === undefined ) {
@@ -283,6 +298,15 @@ export default function App() {
283298 forgeHook . reset ( ) ;
284299 } , [ forgeHook ] ) ;
285300
301+ const handleReconnectAccounts = useCallback ( ( ) => {
302+ setExternalAccount ( null ) ;
303+ setInternalAccount ( null ) ;
304+ setAmount ( '' ) ;
305+ setError ( null ) ;
306+ forgeHook . reset ( ) ;
307+ setRechargeStep ( 'connect' ) ;
308+ } , [ forgeHook ] ) ;
309+
286310 // Group options by external chain for picker
287311 const groupedOptions = useMemo ( ( ) => {
288312 const groups : Record < string , ForgeOption [ ] > = { } ;
@@ -577,14 +601,24 @@ export default function App() {
577601 ) }
578602
579603 < div className = "mt-auto pt-4" >
580- < Button
581- data-testid = "preview-button"
582- className = "h-12 w-full"
583- onClick = { handlePreview }
584- disabled = { ! amount || parseFloat ( amount ) <= 0 }
585- >
586- { t ( 'forge.preview' ) }
587- </ Button >
604+ < div className = "space-y-2" >
605+ < Button
606+ data-testid = "preview-button"
607+ className = "h-12 w-full"
608+ onClick = { handlePreview }
609+ disabled = { ! amount || parseFloat ( amount ) <= 0 }
610+ >
611+ { t ( 'forge.preview' ) }
612+ </ Button >
613+ < Button
614+ variant = "ghost"
615+ className = "h-10 w-full"
616+ data-testid = "reconnect-button"
617+ onClick = { handleReconnectAccounts }
618+ >
619+ { t ( 'forge.changeWallets' ) }
620+ </ Button >
621+ </ div >
588622 </ div >
589623 </ motion . div >
590624 ) }
@@ -636,6 +670,20 @@ export default function App() {
636670
637671 < Card >
638672 < CardContent className = "space-y-3 py-4 text-sm" >
673+ < div className = "flex justify-between" >
674+ < span className = "text-muted-foreground" > { t ( 'forge.sender' ) } </ span >
675+ < span className = "max-w-36 truncate font-mono text-xs" >
676+ { externalAccount ?. address }
677+ </ span >
678+ </ div >
679+ < Separator />
680+ < div className = "flex justify-between" >
681+ < span className = "text-muted-foreground" > { t ( 'forge.receiver' ) } </ span >
682+ < span className = "max-w-36 truncate font-mono text-xs" >
683+ { internalAccount ?. address }
684+ </ span >
685+ </ div >
686+ < Separator />
639687 < div className = "flex justify-between" >
640688 < span className = "text-muted-foreground" > { t ( 'forge.ratio' ) } </ span >
641689 < span > { t ( 'forge.ratioValue' ) } </ span >
@@ -677,14 +725,24 @@ export default function App() {
677725 </ Card >
678726
679727 < div className = "mt-auto pt-4" >
680- < Button
681- data-testid = "confirm-button"
682- className = "h-12 w-full"
683- onClick = { handleConfirm }
684- disabled = { loading }
685- >
686- { t ( 'forge.confirm' ) }
687- </ Button >
728+ < div className = "space-y-2" >
729+ < Button
730+ data-testid = "confirm-button"
731+ className = "h-12 w-full"
732+ onClick = { handleConfirm }
733+ disabled = { loading }
734+ >
735+ { t ( 'forge.confirm' ) }
736+ </ Button >
737+ < Button
738+ variant = "ghost"
739+ className = "h-10 w-full"
740+ data-testid = "reconnect-button"
741+ onClick = { handleReconnectAccounts }
742+ >
743+ { t ( 'forge.changeWallets' ) }
744+ </ Button >
745+ </ div >
688746 </ div >
689747 </ motion . div >
690748 ) }
0 commit comments