Skip to content

Commit

Permalink
fix(wallet): Speedup Transaction (uplift to 1.74.x) (#27047)
Browse files Browse the repository at this point in the history
Merge pull request #26967 from brave/fix-wallet-speedup-transaction

fix(wallet): Speedup Transaction
  • Loading branch information
Douglashdaniel authored Dec 18, 2024
1 parent 0d92594 commit 16b06b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,56 @@
// You can obtain one at https://mozilla.org/MPL/2.0/.
import * as React from 'react'
import Button from '@brave/leo/react/button'
import { useDispatch } from 'react-redux'

// Actions
import * as WalletPanelActions from '../../../../panel/actions/wallet_panel_actions'

// Utils
import { getLocale } from '$web-common/locale'
import { getCoinFromTxDataUnion } from '../../../../utils/network-utils'

// Types
import { SerializableTransactionInfo } from '../../../../constants/types'

// Hooks
import {
useSpeedupTransactionMutation //
} from '../../../../common/slices/api.slice'

// Styled Components
import { Alert } from './common.style'

interface Props {
onSpeedUp?: () => void
transaction: SerializableTransactionInfo
}

export const SpeedUpAlert = (props: Props) => {
const { onSpeedUp } = props
const { transaction } = props

// Computed
const txCoinType = getCoinFromTxDataUnion(transaction.txDataUnion)

// Hooks
const [speedupTx] = useSpeedupTransactionMutation()
const dispatch = useDispatch()

// Methods
const onClickSpeedUpTransaction = () => {
speedupTx({
coinType: txCoinType,
chainId: transaction.chainId,
transactionId: transaction.id
})
dispatch(WalletPanelActions.setSelectedTransactionId(undefined))
}

return (
<Alert
type='info'
mode='simple'
>
<Alert type='info'>
{getLocale('braveWalletTransactionTakingLongTime')}
<div slot='content-after'>
<Button
onClick={onSpeedUp}
onClick={onClickSpeedUpTransaction}
kind='outline'
size='tiny'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const TransactionSubmittedOrSigned = (props: Props) => {
padding='0px 24px'
>
{txCoinType === BraveWallet.CoinType.ETH && showSpeedUpAlert ? (
<SpeedUpAlert />
<SpeedUpAlert transaction={transaction} />
) : (
<VerticalSpace space='114px' />
)}
Expand Down

0 comments on commit 16b06b7

Please sign in to comment.