Conversation
| const blockExplorerLink = (address: string, blockExplorer?: string): string => | ||
| `${blockExplorer || 'https://etherscan.io/'}address/${address}`; | ||
|
|
||
| export const useAddress = (props: AddressProps): AddressResult => { |
There was a problem hiding this comment.
I would add tsdocs comments similar to eth-hooks. It helps create automated documentation later. https://scaffold-eth.github.io/eth-hooks/docs/api/modules/Hooks. @stevenpslade
| import { useResolveEnsName } from 'eth-hooks/dapps'; | ||
| import { TEthersProvider } from 'eth-hooks/models'; | ||
|
|
||
| export interface AddressProps { |
There was a problem hiding this comment.
Can we prefix interfaces with I and types with T. it was the standard in eth hooks
| const [ensName] = useResolveEnsName(props.ensProvider, address); | ||
| const explorerLink = blockExplorerLink(address, props.blockExplorer); | ||
|
|
||
| const shortAddress = address ? `${address.substring(0, 5)}...${address.substring(address.length - 4)}` : ''; |
There was a problem hiding this comment.
i think we should check validity of address using ethers.utils
There was a problem hiding this comment.
if invalid, return that in shortAddress
| const shortAddress = address ? `${address.substring(0, 5)}...${address.substring(address.length - 4)}` : ''; | ||
|
|
||
| return { | ||
| shortAddress, |
There was a problem hiding this comment.
shortAddress can be called addressForDisplay
| const blockExplorerLink = (address: string, blockExplorer?: string): string => | ||
| `${blockExplorer || 'https://etherscan.io/'}address/${address}`; | ||
|
|
||
| export const useAddress = (props: AddressProps): AddressResult => { |
There was a problem hiding this comment.
maybe the hook should be called useAddressForDisplay?
ShravanSunder
left a comment
There was a problem hiding this comment.
The test should mock all the eth-hooks hooks and check if it works. maybe one case for invalid address, undefined address and valid address.
Part of Migrate Components and TS-ify
This PR is migrating the Address component from eth-components and Typescript-ifying it.