@@ -15,11 +15,17 @@ import {
15
15
} from '../../../helpers/constants/routes' ;
16
16
import { setDefaultHomeActiveTabName } from '../../../store/actions' ;
17
17
import { startPollingForBridgeTxStatus } from '../../../ducks/bridge-status/actions' ;
18
- import { isHardwareWallet } from '../../../selectors' ;
18
+ import {
19
+ getMemoizedUnapprovedTemplatedConfirmations ,
20
+ getSelectedInternalAccount ,
21
+ isHardwareWallet ,
22
+ } from '../../../selectors' ;
19
23
import { getQuoteRequest } from '../../../ducks/bridge/selectors' ;
20
24
import { CHAIN_IDS } from '../../../../shared/constants/network' ;
21
25
import { getCurrentChainId } from '../../../../shared/modules/selectors/networks' ;
22
26
import { setWasTxDeclined } from '../../../ducks/bridge/actions' ;
27
+ import { getMultichainIsSolana } from '../../../selectors/multichain' ;
28
+ import { useMultichainSelector } from '../../../hooks/useMultichainSelector' ;
23
29
import useAddToken from './useAddToken' ;
24
30
import useHandleApprovalTx from './useHandleApprovalTx' ;
25
31
import useHandleBridgeTx from './useHandleBridgeTx' ;
@@ -57,9 +63,41 @@ export default function useSubmitBridgeTransaction() {
57
63
const hardwareWalletUsed = useSelector ( isHardwareWallet ) ;
58
64
const { slippage } = useSelector ( getQuoteRequest ) ;
59
65
66
+ const isSolana = useSelector ( getMultichainIsSolana ) ;
67
+ const unapprovedTemplatedConfirmations = useSelector (
68
+ getMemoizedUnapprovedTemplatedConfirmations ,
69
+ ) ;
70
+ const selectedAccount = useMultichainSelector ( getSelectedInternalAccount ) ;
71
+ // Navigate to confirmation page on submit
72
+ // We don't need this since only one approval is required
73
+ /*
74
+ useEffect(() => {
75
+ const templatedSnapApproval = unapprovedTemplatedConfirmations.find(
76
+ (approval) => {
77
+ return (
78
+ approval.type === 'snap_dialog' &&
79
+ selectedAccount.metadata.snap &&
80
+ selectedAccount.metadata.snap.id === approval.origin &&
81
+ isMultichainWalletSnap(selectedAccount.metadata.snap.id)
82
+ );
83
+ },
84
+ );
85
+
86
+ if (templatedSnapApproval) {
87
+ history.push(`${CONFIRMATION_V_NEXT_ROUTE}/${templatedSnapApproval.id}`);
88
+ }
89
+ }, [unapprovedTemplatedConfirmations, history, selectedAccount]);
90
+ */
91
+
60
92
const submitBridgeTransaction = async (
61
93
quoteResponse : QuoteResponse & QuoteMetadata ,
62
94
) => {
95
+ if ( isSolana ) {
96
+ console . log ( '=======submitting this trade' , quoteResponse . trade ) ;
97
+ await handleBridgeTx ( { quoteResponse, approvalTxId : undefined } ) ;
98
+ // TODO fetch the tx status afterwards and mabe show the tx in the activity tab
99
+ return ;
100
+ }
63
101
if ( hardwareWalletUsed ) {
64
102
history . push ( `${ CROSS_CHAIN_SWAP_ROUTE } ${ AWAITING_SIGNATURES_ROUTE } ` ) ;
65
103
}
0 commit comments