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

Display 8/8 address chars during signing instead of 4/4 #914

Merged
merged 4 commits into from
Jun 29, 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BigNumber from 'bignumber.js'
import svg from '../../../../../../../../../../resources/svg'
import link from '../../../../../../../../../../resources/link'

import { ApprovalType } from '../../../../../../../../../../resources/constants'
import { ADDRESS_DISPLAY_CHARS, ApprovalType } from '../../../../../../../../../../resources/constants'

const numberRegex = /\.0+$|(\.[0-9]*[1-9])0+$/
const MAX_HEX = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
Expand Down Expand Up @@ -64,7 +64,7 @@ class TokenSpend extends React.Component {
} else {
amount = '0x' + custom.integerValue().toString(16)
}

this.setState({ mode: 'custom', amount, customInput: value })
}
}
Expand Down Expand Up @@ -139,7 +139,7 @@ class TokenSpend extends React.Component {
} : {}}
onClick={() => {
this.props.onApprove(
this.props.req,
this.props.req,
ApprovalType.TokenSpendApproval,
{ amount: this.state.amount }
)
Expand Down Expand Up @@ -174,7 +174,7 @@ class TokenSpend extends React.Component {
{symbol}
</div>
{this.state.mode === 'custom' ? (
<input
<input
autoFocus
type='text'
aria-label='Custom Amount'
Expand All @@ -190,7 +190,7 @@ class TokenSpend extends React.Component {
/>
) : (
<div>
<div
<div
className='approveTokenSpendAmountNoInput'
role='textbox'
style={inputLock ? { cursor: 'default' } : null}
Expand All @@ -199,7 +199,7 @@ class TokenSpend extends React.Component {
}}
>
<div className='approveTokenSpendAmountNoInputNumber'>{displayAmount.number}</div>
<div className='approveTokenSpendAmountNoInputSymbol'>{displayAmount.symbol}</div>
<div className='approveTokenSpendAmountNoInputSymbol'>{displayAmount.symbol}</div>
</div>
</div>
)}
Expand All @@ -214,7 +214,7 @@ class TokenSpend extends React.Component {
>
Requested
</div>
<div
<div
className={this.state.mode === 'unlimited' ? 'approveTokenSpendPresetButton approveTokenSpendPresetButtonSelected' : 'approveTokenSpendPresetButton'}
role='button'
onClick={() => {
Expand All @@ -225,7 +225,7 @@ class TokenSpend extends React.Component {
<span className='approveTokenSpendPresetButtonInfinity'>{'Unlimited'}</span>
</div>
{!inputLock ? (
<div
<div
className={this.state.mode === 'custom' ? 'approveTokenSpendPresetButton approveTokenSpendPresetButtonSelected' : 'approveTokenSpendPresetButton'}
role='button'
onClick={() => {
Expand All @@ -245,18 +245,21 @@ class TokenSpend extends React.Component {
{data.spender ? (
<div className='approveTokenSpendSpenderAddress'>
<div className='approveTokenSpendSpenderAddressLarge'>
{data.spender.substring(0, 6)}
{
// 0x prefix plus leading characters of address
data.spender.substring(0, 2 + ADDRESS_DISPLAY_CHARS)
}
{svg.octicon('kebab-horizontal', { height: 15 })}
{data.spender.substr(data.contract.length - 4)}
{data.spender.substr(data.contract.length - ADDRESS_DISPLAY_CHARS)}
</div>
<div
className='approveTokenSpendSpenderAddressFull'
<div
className='approveTokenSpendSpenderAddressFull'
onClick={() => {
link.send('tray:clipboardData', data.spender)
this.setState({ copyTokenRequester: true })
setTimeout(() => {
this.setState({ copyTokenRequester: false })
}, 1000)
}, 1000)
}}
>
{this.state.copyTokenRequester ? 'ADDRESS COPIED' : data.spender}
Expand All @@ -270,14 +273,14 @@ class TokenSpend extends React.Component {
<div className='approveTokenSpendTokenSymbol'>
{symbol}
</div>
<div
<div
className='approveTokenSpendTokenContract'
onClick={() => {
link.send('tray:clipboardData', data.contract)
this.setState({ copyTokenContract: true })
setTimeout(() => {
this.setState({ copyTokenContract: false })
}, 1000)
}, 1000)
}}
>
{this.state.copyTokenContract ? 'ADDRESS COPIED' : data.contract}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import Restore from 'react-restore'
import { ADDRESS_DISPLAY_CHARS } from '../../../../../../../../resources/constants'

import link from '../../../../../../../../resources/link'
import svg from '../../../../../../../../resources/svg'
Expand Down Expand Up @@ -38,9 +39,9 @@ class TxRecipient extends React.Component {
<div className='_txRecipientSlice _txRecipientValue'>
{ensName
? <span>{ensName}</span>
: <span>{address.substring(0, 6)}{svg.octicon('kebab-horizontal', { height: 15 })}{address.substring(address.length - 4)}</span>
: <span>{address.substring(0, 2 + ADDRESS_DISPLAY_CHARS)}{svg.octicon('kebab-horizontal', { height: 15 })}{address.substring(address.length - ADDRESS_DISPLAY_CHARS)}</span>
}
{req.decodedData && req.decodedData.contractName ? (
{req.decodedData && req.decodedData.contractName ? (
<span className={'_txRecipientContract'}>{(() => {
if (req.decodedData.contractName.length > 11) return `${req.decodedData.contractName.substr(0, 9)}..`
return req.decodedData.contractName
Expand Down
5 changes: 5 additions & 0 deletions resources/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ export enum ApprovalType {
GasLimitApproval = 'approveGasLimit',
TokenSpendApproval = 'approveTokenSpend'
}

const ADDRESS_DISPLAY_CHARS = 8
export {
ADDRESS_DISPLAY_CHARS
}