1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

address locked MetaMask account use case

This commit is contained in:
Matthias Kretschmann 2019-07-10 20:27:06 +02:00
parent 0befc3a597
commit 57db99049f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 66 additions and 47 deletions

View File

@ -8,6 +8,10 @@
> div:first-of-type { > div:first-of-type {
flex: 0 0 80%; flex: 0 0 80%;
}
}
.accountId {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -15,6 +19,10 @@
font-size: $font-size-small; font-size: $font-size-small;
font-weight: 700; font-weight: 700;
} }
.unlock {
font-size: $font-size-small !important; // stylelint-disable-line
margin-left: $spacer / 2;
} }
.accountType { .accountType {
@ -77,4 +85,5 @@
display: inline-block; display: inline-block;
margin-right: $spacer / 3; margin-right: $spacer / 3;
margin-left: 0; margin-left: 0;
border: 1px solid $brand-grey-lighter;
} }

View File

@ -5,36 +5,58 @@ import styles from './Account.module.scss'
import WalletSelector from '../organisms/WalletSelector' import WalletSelector from '../organisms/WalletSelector'
import content from '../../data/web3message.json' import content from '../../data/web3message.json'
import { ReactComponent as Caret } from '../../img/caret.svg' import { ReactComponent as Caret } from '../../img/caret.svg'
import { User } from '../../context'
import Button from './Button'
export default class Account extends PureComponent< export default class Account extends PureComponent<
{ {},
account: string { isAccountInfoOpen: boolean }
isBurner: boolean
extended?: boolean
},
{ isAccountOpen: boolean }
> { > {
public static contextType = User
public state = { public state = {
isAccountOpen: false isAccountInfoOpen: false
} }
private toggleAccountInfo() { private toggleAccountInfo() {
this.setState({ isAccountOpen: !this.state.isAccountOpen }) this.setState({ isAccountInfoOpen: !this.state.isAccountInfoOpen })
} }
public render() { public render() {
const { account, isBurner, extended } = this.props const { account, isBurner, loginMetamask } = this.context
const { isAccountInfoOpen } = this.state
const seedphrase = localStorage.getItem('seedphrase') as string const seedphrase = localStorage.getItem('seedphrase') as string
const blockies = account && toDataUrl(account) const blockies = account && toDataUrl(account)
return account && blockies ? (
return (
<div className={styles.account}> <div className={styles.account}>
{account ? (
<>
<img <img
className={styles.blockies} className={styles.blockies}
src={blockies} src={blockies}
alt="Blockies" alt="Blockies"
/> />
<Dotdotdot clamp={2}>{account}</Dotdotdot> <Dotdotdot className={styles.accountId} clamp={2}>
{account}
</Dotdotdot>
</>
) : (
<>
<span className={styles.blockies} />
<em className={styles.noAccount}>
No account selected
</em>
<Button
link
className={styles.unlock}
onClick={() => loginMetamask()}
>
Unlock Account
</Button>
</>
)}
<div className={styles.accountType}> <div className={styles.accountType}>
{isBurner ? ( {isBurner ? (
<button <button
@ -43,9 +65,7 @@ export default class Account extends PureComponent<
title="Show More Account Info" title="Show More Account Info"
> >
<Caret <Caret
className={ className={isAccountInfoOpen ? styles.open : ''}
this.state.isAccountOpen ? styles.open : ''
}
/>{' '} />{' '}
Burner Wallet Burner Wallet
</button> </button>
@ -55,7 +75,7 @@ export default class Account extends PureComponent<
<WalletSelector /> <WalletSelector />
</div> </div>
{isBurner && this.state.isAccountOpen && ( {isBurner && isAccountInfoOpen && (
<div className={styles.seedphrase}> <div className={styles.seedphrase}>
<code>{seedphrase}</code> <code>{seedphrase}</code>
<p className={styles.seedphraseHelp}> <p className={styles.seedphraseHelp}>
@ -64,8 +84,6 @@ export default class Account extends PureComponent<
</div> </div>
)} )}
</div> </div>
) : (
<em>No account selected</em>
) )
} }
} }

View File

@ -41,9 +41,12 @@ $popoverWidth: 18rem;
} }
button { button {
svg,
&:last-child {
display: none; display: none;
} }
} }
}
.balance { .balance {
font-size: $font-size-small; font-size: $font-size-small;

View File

@ -8,13 +8,7 @@ export default class Popover extends PureComponent<{
style?: React.CSSProperties style?: React.CSSProperties
}> { }> {
public render() { public render() {
const { const { account, balance, network, isOceanNetwork } = this.context
account,
balance,
network,
isOceanNetwork,
isBurner
} = this.context
return ( return (
<div <div
@ -25,7 +19,7 @@ export default class Popover extends PureComponent<{
{ {
<> <>
<div className={styles.popoverInfoline}> <div className={styles.popoverInfoline}>
<Account account={account} isBurner={isBurner} /> <Account />
</div> </div>
{account && balance && ( {account && balance && (

View File

@ -9,7 +9,7 @@ export default class Web3message extends PureComponent<{ extended?: boolean }> {
public static contextType = User public static contextType = User
private message = () => { private message = () => {
const { isOceanNetwork, isLogged, isBurner } = this.context const { isOceanNetwork, isLogged, isBurner, network } = this.context
return !isOceanNetwork && !isBurner return !isOceanNetwork && !isBurner
? content.wrongNetworkPacific ? content.wrongNetworkPacific
@ -18,7 +18,7 @@ export default class Web3message extends PureComponent<{ extended?: boolean }> {
: isBurner : isBurner
? content.hasBurnerWallet ? content.hasBurnerWallet
: isLogged : isLogged
? content.hasMetaMaskWallet ? content.hasMetaMaskWallet.replace('NETWORK', network)
: '' : ''
} }
@ -28,11 +28,7 @@ export default class Web3message extends PureComponent<{ extended?: boolean }> {
return ( return (
<div className={styles.message}> <div className={styles.message}>
<div className={styles.account}> <div className={styles.account}>
<Account <Account />
account={this.context.account}
isBurner={this.context.isBurner}
extended={this.props.extended}
/>
</div> </div>
{(network !== 'Pacific' || this.props.extended) && ( {(network !== 'Pacific' || this.props.extended) && (

View File

@ -1,7 +1,7 @@
{ {
"noAccount": "No wallet selected. For publishing and downloading an asset you need to use one.", "noAccount": "No wallet selected. For publishing and downloading an asset you need to use one.",
"hasBurnerWallet": "We created a temporary burner wallet for you, allowing you to use all Commons functionality without any setup on your side, and without a Web3-capable browser. This wallet will persist in your browser across sessions, but not across different browsers or devices. <strong>Never use this burner wallet to send or receive any tokens.</strong> To personalize your experience and improve your security, <a href='https://docs.oceanprotocol.com/tutorials/metamask-setup/'>migrate to MetaMask</a>.", "hasBurnerWallet": "We created a temporary burner wallet for you, allowing you to use all Commons functionality without any setup on your side, and without a Web3-capable browser. This wallet will persist in your browser across sessions, but not across different browsers or devices. <strong>Never use this burner wallet to send or receive any tokens.</strong> To personalize your experience and improve your security, <a href='https://docs.oceanprotocol.com/tutorials/metamask-setup/'>migrate to MetaMask</a>.",
"hasMetaMaskWallet": "Connected with MetaMask. You're a Pro.", "hasMetaMaskWallet": "Connected with MetaMask to NETWORK. You're a Pro.",
"wrongNetworkPacific": "Not connected to Pacific network. Please connect in MetaMask with Custom RPC <code>https://pacific.oceanprotocol.com</code>", "wrongNetworkPacific": "Not connected to Pacific network. Please connect in MetaMask with Custom RPC <code>https://pacific.oceanprotocol.com</code>",
"wrongNetworkNile": "Not connected to Nile network. Please connect in MetaMask with Custom RPC <code>https://nile.dev-ocean.com</code>", "wrongNetworkNile": "Not connected to Nile network. Please connect in MetaMask with Custom RPC <code>https://nile.dev-ocean.com</code>",
"wrongNetworkDuero": "Not connected to Duero network. Please connect in MetaMask with Custom RPC <code>https://duero.dev-ocean.com</code>", "wrongNetworkDuero": "Not connected to Duero network. Please connect in MetaMask with Custom RPC <code>https://duero.dev-ocean.com</code>",

View File

@ -4,7 +4,6 @@ import Route from '../../components/templates/Route'
import Form from '../../components/atoms/Form/Form' import Form from '../../components/atoms/Form/Form'
import AssetModel from '../../models/AssetModel' import AssetModel from '../../models/AssetModel'
import { User, Market } from '../../context' import { User, Market } from '../../context'
import Web3message from '../../components/organisms/Web3message'
import Step from './Step' import Step from './Step'
import Progress from './Progress' import Progress from './Progress'
import ReactGA from 'react-ga' import ReactGA from 'react-ga'