Skip to content

Commit

Permalink
chore: consolidate tx confirmation panels (#21188)
Browse files Browse the repository at this point in the history
* chore: consolidate tx confirmation panels

* chore: combine transaction-info components

* chore: combine transaction-detail components

* fix: allow rows to wrap content

* fix: allow tx confirm to-from row to wrap

* chore: remove max-width prop from column component
  • Loading branch information
josheleonard committed Jan 17, 2024
1 parent 85d26e2 commit 0b8c9ae
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 1,698 deletions.
46 changes: 21 additions & 25 deletions components/brave_wallet_ui/common/hooks/use-pending-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import {
accountHasInsufficientFundsForGas,
accountHasInsufficientFundsForTransaction,
getTransactionGasFee,
isSolanaTransaction,
parseTransactionWithPrices,
findTransactionToken,
isEthereumTransaction
isEthereumTransaction,
isZCashTransaction,
isBitcoinTransaction
} from '../../utils/tx-utils'
import { makeNetworkAsset } from '../../options/asset-options'

Expand Down Expand Up @@ -292,7 +293,7 @@ export const usePendingTransactions = () => {
sellTokenBalance: sellTokenBalance || '',
tx: transactionInfo
})
: undefined
: false
}, [
gasFee,
nativeBalance,
Expand Down Expand Up @@ -334,23 +335,18 @@ export const usePendingTransactions = () => {
const isERC721TransferFrom =
transactionInfo?.txType === BraveWallet.TransactionType.ERC721TransferFrom

const isSolanaTxn = transactionInfo && isSolanaTransaction(transactionInfo)
const isSolanaDappTransaction =
transactionInfo?.txType &&
[
BraveWallet.TransactionType.SolanaDappSignAndSendTransaction,
BraveWallet.TransactionType.SolanaDappSignTransaction
].includes(transactionInfo.txType)
const isSolanaDappTransaction = transactionInfo?.txType
? [
BraveWallet.TransactionType.SolanaDappSignAndSendTransaction,
BraveWallet.TransactionType.SolanaDappSignTransaction
].includes(transactionInfo.txType)
: false

const isAssociatedTokenAccountCreation =
transactionInfo?.txType ===
BraveWallet.TransactionType
.SolanaSPLTokenTransferWithAssociatedTokenAccountCreation

const isFilecoinTransaction =
transactionInfo?.txType === BraveWallet.TransactionType.Other &&
transactionInfo?.txDataUnion?.filTxData

// methods
const onEditAllowanceSave = React.useCallback(
(allowance: string) => {
Expand Down Expand Up @@ -516,14 +512,12 @@ export const usePendingTransactions = () => {
return true
}

return (
!!transactionDetails?.sameAddressError ||
!!transactionDetails?.contractAddressError ||
insufficientFundsForGasError === undefined ||
insufficientFundsError === undefined ||
!!insufficientFundsForGasError ||
!!insufficientFundsError ||
!!transactionDetails?.missingGasLimitError
return Boolean(
transactionDetails?.sameAddressError ||
transactionDetails?.contractAddressError ||
insufficientFundsForGasError ||
insufficientFundsError ||
transactionDetails?.missingGasLimitError
)
}, [
transactionDetails,
Expand Down Expand Up @@ -615,9 +609,9 @@ export const usePendingTransactions = () => {
isERC721SafeTransferFrom,
isERC721TransferFrom,
isSolanaDappTransaction,
isSolanaTransaction: isSolanaTxn,
isSolanaTransaction: transactionDetails?.isSolanaTransaction || false,
isAssociatedTokenAccountCreation,
isFilecoinTransaction,
isFilecoinTransaction: transactionDetails?.isFilecoinTransaction || false,
onEditAllowanceSave,
queueNextTransaction,
rejectAllTransactions,
Expand All @@ -638,6 +632,8 @@ export const usePendingTransactions = () => {
onConfirm,
onReject,
insufficientFundsError,
insufficientFundsForGasError
insufficientFundsForGasError,
isZCashTransaction: isZCashTransaction(transactionInfo),
isBitcoinTransaction: isBitcoinTransaction(transactionInfo)
}
}

This file was deleted.

Loading

0 comments on commit 0b8c9ae

Please sign in to comment.