-
Notifications
You must be signed in to change notification settings - Fork 363
Components support eip3770 prefixes #2896
Changes from all commits
8d7d3ee
9e256b3
a39cf15
aee9dd2
9a9e79d
a45999b
b1b0632
644b2ad
b53afb3
5e9dbd9
2dd13f3
c44d55d
98b2b7a
01e7fca
c07aa71
9e38627
82624fb
8261959
7df7897
0520004
cb51b39
572817e
d01319c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import PrefixedEthHashInfo from '.' | ||
import { render, screen } from 'src/utils/test-utils' | ||
|
||
const hash = '0x69904ff6d6100799344E5C9A2806936318F6ba4f' | ||
jest.mock('src/routes/routes', () => { | ||
const original = jest.requireActual('src/routes/routes') | ||
return { | ||
...original, | ||
extractShortChainName: () => 'arb', | ||
} | ||
}) | ||
|
||
describe('<PrefixedEthHashInfo>', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you not also add a test to check that copying also works? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The copy functionality is abstracted by the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Answering the comment) I think I have covered all the address visualizations in the UI. The ones I haven't prefixed I comment in #2896 (comment) . Said this, I will ask QA to help me spotting any edge case that I might have missed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could still render the component, click copy and see what is in the clipboard, no? Did you test it in SRC? |
||
it('Renders PrefixedEthHashInfo without shortName', () => { | ||
const customState = { | ||
appearance: { | ||
showShortName: false, | ||
}, | ||
} | ||
|
||
render(<PrefixedEthHashInfo hash={hash} />, customState) | ||
|
||
expect(screen.queryByText('arb:')).not.toBeInTheDocument() | ||
expect(screen.getByText(hash)).toBeInTheDocument() | ||
}) | ||
|
||
it('Renders PrefixedEthHashInfo with shortName', () => { | ||
const customState = { | ||
appearance: { | ||
showShortName: true, | ||
}, | ||
} | ||
|
||
render(<PrefixedEthHashInfo hash={hash} />, customState) | ||
|
||
expect(screen.queryByText('arb:')).toBeInTheDocument() | ||
expect(screen.getByText(hash)).toBeInTheDocument() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { EthHashInfo } from '@gnosis.pm/safe-react-components' | ||
import { ReactElement } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { copyShortNameSelector, showShortNameSelector } from 'src/logic/appearance/selectors' | ||
import { extractShortChainName } from 'src/routes/routes' | ||
|
||
type Props = Omit<Parameters<typeof EthHashInfo>[0], 'shouldShowShortName' | 'shouldCopyShortName'> | ||
|
||
const PrefixedEthHashInfo = ({ hash, ...rest }: Props): ReactElement => { | ||
const showChainPrefix = useSelector(showShortNameSelector) | ||
const copyChainPrefix = useSelector(copyShortNameSelector) | ||
|
||
return ( | ||
<EthHashInfo | ||
hash={hash} | ||
shortName={extractShortChainName()} | ||
shouldShowShortName={showChainPrefix} | ||
shouldCopyShortName={copyChainPrefix} | ||
{...rest} | ||
/> | ||
) | ||
} | ||
|
||
export default PrefixedEthHashInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CopyToClipboardBtn is used in two other places, should we also create a wrapper for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was implementing a wrapper for it called
CopyAddressToClipboardBtn
but theCopyToClipboardBtn
is only copying an address in theSafeHeader
component.Is it worthy to implement the wrapper afterall?