mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Hide Copy Tx ID and block explorer link for txns w/o hash (#6928)
This commit is contained in:
parent
948b6ca80b
commit
2761cc5a2d
@ -78,4 +78,73 @@ describe('TransactionListItemDetails Component', () => {
|
|||||||
assert.ok(wrapper.hasClass('transaction-list-item-details'))
|
assert.ok(wrapper.hasClass('transaction-list-item-details'))
|
||||||
assert.equal(wrapper.find(Button).length, 3)
|
assert.equal(wrapper.find(Button).length, 3)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should disable the Copy Tx ID and View In Etherscan buttons when tx hash is missing', () => {
|
||||||
|
const transaction = {
|
||||||
|
history: [],
|
||||||
|
id: 1,
|
||||||
|
status: 'confirmed',
|
||||||
|
txParams: {
|
||||||
|
from: '0x1',
|
||||||
|
gas: '0x5208',
|
||||||
|
gasPrice: '0x3b9aca00',
|
||||||
|
nonce: '0xa4',
|
||||||
|
to: '0x2',
|
||||||
|
value: '0x2386f26fc10000',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const transactionGroup = {
|
||||||
|
transactions: [transaction],
|
||||||
|
primaryTransaction: transaction,
|
||||||
|
initialTransaction: transaction,
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = shallow(
|
||||||
|
<TransactionListItemDetails
|
||||||
|
transactionGroup={transactionGroup}
|
||||||
|
/>,
|
||||||
|
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.ok(wrapper.hasClass('transaction-list-item-details'))
|
||||||
|
const buttons = wrapper.find(Button)
|
||||||
|
assert.strictEqual(buttons.at(0).prop('disabled'), true)
|
||||||
|
assert.strictEqual(buttons.at(1).prop('disabled'), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render functional Copy Tx ID and View In Etherscan buttons when tx hash exists', () => {
|
||||||
|
const transaction = {
|
||||||
|
history: [],
|
||||||
|
id: 1,
|
||||||
|
status: 'confirmed',
|
||||||
|
hash: '0xaa',
|
||||||
|
txParams: {
|
||||||
|
from: '0x1',
|
||||||
|
gas: '0x5208',
|
||||||
|
gasPrice: '0x3b9aca00',
|
||||||
|
nonce: '0xa4',
|
||||||
|
to: '0x2',
|
||||||
|
value: '0x2386f26fc10000',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const transactionGroup = {
|
||||||
|
transactions: [transaction],
|
||||||
|
primaryTransaction: transaction,
|
||||||
|
initialTransaction: transaction,
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = shallow(
|
||||||
|
<TransactionListItemDetails
|
||||||
|
transactionGroup={transactionGroup}
|
||||||
|
/>,
|
||||||
|
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.ok(wrapper.hasClass('transaction-list-item-details'))
|
||||||
|
const buttons = wrapper.find(Button)
|
||||||
|
assert.strictEqual(buttons.at(0).prop('disabled'), false)
|
||||||
|
assert.strictEqual(buttons.at(1).prop('disabled'), false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -128,7 +128,7 @@ export default class TransactionListItemDetails extends PureComponent {
|
|||||||
rpcPrefs: { blockExplorerUrl } = {},
|
rpcPrefs: { blockExplorerUrl } = {},
|
||||||
} = this.props
|
} = this.props
|
||||||
const { primaryTransaction: transaction } = transactionGroup
|
const { primaryTransaction: transaction } = transactionGroup
|
||||||
const { txParams: { to, from } = {} } = transaction
|
const { hash, txParams: { to, from } = {} } = transaction
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="transaction-list-item-details">
|
<div className="transaction-list-item-details">
|
||||||
@ -152,6 +152,7 @@ export default class TransactionListItemDetails extends PureComponent {
|
|||||||
type="raised"
|
type="raised"
|
||||||
onClick={this.handleCopyTxId}
|
onClick={this.handleCopyTxId}
|
||||||
className="transaction-list-item-details__header-button"
|
className="transaction-list-item-details__header-button"
|
||||||
|
disabled={!hash}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className="transaction-list-item-details__header-button__copy-icon"
|
className="transaction-list-item-details__header-button__copy-icon"
|
||||||
@ -164,6 +165,7 @@ export default class TransactionListItemDetails extends PureComponent {
|
|||||||
type="raised"
|
type="raised"
|
||||||
onClick={this.handleEtherscanClick}
|
onClick={this.handleEtherscanClick}
|
||||||
className="transaction-list-item-details__header-button"
|
className="transaction-list-item-details__header-button"
|
||||||
|
disabled={!hash}
|
||||||
>
|
>
|
||||||
<img src="/images/arrow-popout.svg" />
|
<img src="/images/arrow-popout.svg" />
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user