Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy transaction hash #12297

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/brave_wallet/browser/brave_wallet_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ constexpr webui::LocalizedString kLocalizedStrings[] = {
{"braveWalletTransactionExplorerMissing",
IDS_BRAVE_WALLET_TRANSACTION_EXPLORER_MISSING},
{"braveWalletTransactionExplorer", IDS_BRAVE_WALLET_TRANSACTION_EXPLORER},
{"braveWalletTransactionCopyHash", IDS_BRAVE_WALLET_TRANSACTION_COPY_HASH},
{"braveWalletTransactionSpeedup", IDS_BRAVE_WALLET_TRANSACTION_SPEEDUP},
{"braveWalletTransactionCancel", IDS_BRAVE_WALLET_TRANSACTION_CANCEL},
{"braveWalletTransactionRetry", IDS_BRAVE_WALLET_TRANSACTION_RETRY},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { toProperCase } from '../../../utils/string-utils'
import { mojoTimeDeltaToJSDate, formatDateAsRelative } from '../../../utils/datetime-utils'
import Amount from '../../../utils/amount'
import { copyToClipboard } from '../../../utils/copy-to-clipboard'

// Hooks
import { useExplorer, useTransactionParser } from '../../../common/hooks'
Expand Down Expand Up @@ -105,6 +106,10 @@ const PortfolioTransactionItem = (props: Props) => {

const onClickViewOnBlockExplorer = useExplorer(selectedNetwork)

const onClickCopyTransactionHash = (transactionHash: string) => {
copyToClipboard(transactionHash)
}

const onClickRetryTransaction = () => {
onRetryTransaction(transaction)
}
Expand Down Expand Up @@ -336,7 +341,7 @@ const PortfolioTransactionItem = (props: Props) => {
</CoinsButton>
</TransactionFeesTooltip>

{transactionDetails.status !== BraveWallet.TransactionStatus.Rejected ? (
{(transactionDetails.status !== BraveWallet.TransactionStatus.Rejected && transactionDetails.status !== BraveWallet.TransactionStatus.Unapproved) ? (
<MoreButton onClick={onShowTransactionPopup}>
<MoreIcon />
</MoreButton>
Expand All @@ -346,13 +351,20 @@ const PortfolioTransactionItem = (props: Props) => {

{showTransactionPopup &&
<TransactionPopup>
{[BraveWallet.TransactionStatus.Approved, BraveWallet.TransactionStatus.Submitted, BraveWallet.TransactionStatus.Confirmed] &&
{[BraveWallet.TransactionStatus.Approved, BraveWallet.TransactionStatus.Submitted, BraveWallet.TransactionStatus.Confirmed].includes(transactionDetails.status) &&
<TransactionPopupItem
onClick={onClickViewOnBlockExplorer('tx', transaction.txHash)}
text={getLocale('braveWalletTransactionExplorer')}
/>
}

{[BraveWallet.TransactionStatus.Approved, BraveWallet.TransactionStatus.Submitted, BraveWallet.TransactionStatus.Confirmed].includes(transactionDetails.status) &&
<TransactionPopupItem
onClick={() => onClickCopyTransactionHash(transaction.txHash)}
text={getLocale('braveWalletTransactionCopyHash')}
/>
}

{[BraveWallet.TransactionStatus.Submitted, BraveWallet.TransactionStatus.Approved].includes(transactionDetails.status) &&
<TransactionPopupItem
onClick={onClickSpeedupTransaction}
Expand Down
1 change: 1 addition & 0 deletions components/brave_wallet_ui/stories/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ provideStrings({
braveWalletTransactionReceived: 'received',
braveWalletTransactionExplorerMissing: 'Block explorer URL is not available.',
braveWalletTransactionExplorer: 'View on block explorer',
braveWalletTransactionCopyHash: 'Copy transaction hash',
braveWalletTransactionSpeedup: 'Speedup transaction',
braveWalletTransactionCancel: 'Cancel transaction',
braveWalletTransactionRetry: 'Retry transaction',
Expand Down
1 change: 1 addition & 0 deletions components/resources/wallet_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
<message name="IDS_BRAVE_WALLET_TRANSACTION_RECEIVED" desc="Transaction received label">received</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_EXPLORER_MISSING" desc="Alert for when no block explorer is available">Block explorer URL is not available.</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_EXPLORER" desc="View on block explorer button">View on block explorer</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_COPY_HASH" desc="Copy transaction hash button">Copy transaction hash</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_SPEEDUP" desc="Speedup transaction button">Speedup transaction</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_CANCEL" desc="Cancel transaction button">Cancel transaction</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_RETRY" desc="Retry transaction button">Retry transaction</message>
Expand Down