mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
adapt messaging for wallet types, output wallet type
This commit is contained in:
parent
ad454b9f8a
commit
8d23868a9d
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
.account {
|
.account {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
|
flex: 0 0 80%;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@ -14,6 +16,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.accountType {
|
||||||
|
width: 100%;
|
||||||
|
margin-left: calc(1.5rem + #{$spacer / 3});
|
||||||
|
font-size: $font-size-mini;
|
||||||
|
}
|
||||||
|
|
||||||
.blockies {
|
.blockies {
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
|
@ -3,13 +3,22 @@ import Dotdotdot from 'react-dotdotdot'
|
|||||||
import { toDataUrl } from 'ethereum-blockies'
|
import { toDataUrl } from 'ethereum-blockies'
|
||||||
import styles from './Account.module.scss'
|
import styles from './Account.module.scss'
|
||||||
|
|
||||||
const Account = ({ account }: { account: string }) => {
|
const Account = ({
|
||||||
|
account,
|
||||||
|
isBurner
|
||||||
|
}: {
|
||||||
|
account: string
|
||||||
|
isBurner: boolean
|
||||||
|
}) => {
|
||||||
const blockies = account && toDataUrl(account)
|
const blockies = account && toDataUrl(account)
|
||||||
|
|
||||||
return account && blockies ? (
|
return account && blockies ? (
|
||||||
<div className={styles.account}>
|
<div className={styles.account}>
|
||||||
<img className={styles.blockies} src={blockies} alt="Blockies" />
|
<img className={styles.blockies} src={blockies} alt="Blockies" />
|
||||||
<Dotdotdot clamp={2}>{account}</Dotdotdot>
|
<Dotdotdot clamp={2}>{account}</Dotdotdot>
|
||||||
|
{isBurner && (
|
||||||
|
<span className={styles.accountType}>Burner Wallet</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<em>No account selected</em>
|
<em>No account selected</em>
|
||||||
|
@ -50,6 +50,10 @@ $popoverWidth: 18rem;
|
|||||||
margin-left: $spacer / 2;
|
margin-left: $spacer / 2;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
color: $brand-grey-lighter;
|
||||||
|
}
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,17 @@ import { User } from '../../../context'
|
|||||||
import styles from './Popover.module.scss'
|
import styles from './Popover.module.scss'
|
||||||
|
|
||||||
export default class Popover extends PureComponent<{
|
export default class Popover extends PureComponent<{
|
||||||
forwardedRef: (ref: HTMLElement | null) => void
|
forwardedRef?: (ref: HTMLElement | null) => void
|
||||||
style: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
}> {
|
}> {
|
||||||
public render() {
|
public render() {
|
||||||
const { account, balance, network, isOceanNetwork } = this.context
|
const {
|
||||||
|
account,
|
||||||
|
balance,
|
||||||
|
network,
|
||||||
|
isOceanNetwork,
|
||||||
|
isBurner
|
||||||
|
} = this.context
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -19,7 +25,7 @@ export default class Popover extends PureComponent<{
|
|||||||
{
|
{
|
||||||
<>
|
<>
|
||||||
<div className={styles.popoverInfoline}>
|
<div className={styles.popoverInfoline}>
|
||||||
<Account account={account} />
|
<Account account={account} isBurner={isBurner} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{account && balance && (
|
{account && balance && (
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
@import '../../../styles/variables';
|
@import '../../../styles/variables';
|
||||||
|
|
||||||
.versions {
|
|
||||||
margin-top: $spacer * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.versionsTitle {
|
.versionsTitle {
|
||||||
font-size: $font-size-large;
|
font-size: $font-size-large;
|
||||||
margin-bottom: $spacer / 2;
|
margin-bottom: $spacer / 2;
|
||||||
|
margin-top: $spacer * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.versionsMinimal {
|
.versionsMinimal {
|
||||||
|
@ -149,13 +149,13 @@ export default class VersionNumbers extends PureComponent<
|
|||||||
return minimal ? (
|
return minimal ? (
|
||||||
<this.MinimalOutput />
|
<this.MinimalOutput />
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.versions} id="#oceanversions">
|
<>
|
||||||
<h2 className={styles.versionsTitle}>
|
<h2 className={styles.versionsTitle} id="#oceanversions">
|
||||||
Ocean Components Status
|
Ocean Components Status
|
||||||
</h2>
|
</h2>
|
||||||
<VersionStatus status={this.state.status} />
|
<VersionStatus status={this.state.status} />
|
||||||
<VersionTable data={this.state} />
|
<VersionTable data={this.state} />
|
||||||
</div>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import React, { PureComponent } from 'react'
|
|||||||
import { NavLink } from 'react-router-dom'
|
import { NavLink } from 'react-router-dom'
|
||||||
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
||||||
import AccountStatus from '../molecules/AccountStatus'
|
import AccountStatus from '../molecules/AccountStatus'
|
||||||
import WalletSelector from './WalletSelector'
|
|
||||||
import styles from './Header.module.scss'
|
import styles from './Header.module.scss'
|
||||||
|
|
||||||
import menu from '../../data/menu.json'
|
import menu from '../../data/menu.json'
|
||||||
@ -33,7 +32,6 @@ export default class Header extends PureComponent {
|
|||||||
{menu.map(item => (
|
{menu.map(item => (
|
||||||
<MenuItem key={item.title} item={item} />
|
<MenuItem key={item.title} item={item} />
|
||||||
))}
|
))}
|
||||||
<WalletSelector />
|
|
||||||
<AccountStatus className={styles.accountStatus} />
|
<AccountStatus className={styles.accountStatus} />
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
@import '../../styles/variables';
|
@import '../../styles/variables';
|
||||||
|
|
||||||
.actions {
|
|
||||||
text-align: right;
|
|
||||||
margin-top: $spacer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.openLink {
|
.openLink {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: $font-size-small;
|
margin-top: $spacer / 2;
|
||||||
|
margin-left: $spacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
|
@ -6,10 +6,10 @@ import Button from '../atoms/Button'
|
|||||||
|
|
||||||
export default class WalletSelector extends PureComponent<
|
export default class WalletSelector extends PureComponent<
|
||||||
{},
|
{},
|
||||||
{
|
{ isModalOpen: boolean }
|
||||||
isModalOpen: boolean
|
|
||||||
}
|
|
||||||
> {
|
> {
|
||||||
|
public static contextType = User
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
isModalOpen: false
|
isModalOpen: false
|
||||||
}
|
}
|
||||||
@ -25,12 +25,13 @@ export default class WalletSelector extends PureComponent<
|
|||||||
|
|
||||||
private loginMetamask = () => {
|
private loginMetamask = () => {
|
||||||
this.context.loginMetamask()
|
this.context.loginMetamask()
|
||||||
|
this.context.logoutBurnerWallet()
|
||||||
this.toggleModal()
|
this.toggleModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.actions}>
|
<>
|
||||||
<Button
|
<Button
|
||||||
link
|
link
|
||||||
className={styles.openLink}
|
className={styles.openLink}
|
||||||
@ -53,9 +54,7 @@ export default class WalletSelector extends PureComponent<
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletSelector.contextType = User
|
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.warnings {
|
.text {
|
||||||
padding-left: $spacer;
|
margin-left: $spacer;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
margin-left: -($spacer);
|
position: absolute;
|
||||||
margin-right: $spacer / 2;
|
left: 0;
|
||||||
|
top: $spacer / 1.5;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
@ -7,33 +7,39 @@ import WalletSelector from './WalletSelector'
|
|||||||
import content from '../../data/web3message.json'
|
import content from '../../data/web3message.json'
|
||||||
|
|
||||||
export default class Web3message extends PureComponent {
|
export default class Web3message extends PureComponent {
|
||||||
private message = (message: string, account?: string) => (
|
public static contextType = User
|
||||||
<div className={styles.message}>
|
|
||||||
{account ? (
|
private message = () => {
|
||||||
<Account account={account} />
|
const { isOceanNetwork, isLogged, isBurner } = this.context
|
||||||
) : (
|
|
||||||
<div className={styles.warnings}>
|
return !isOceanNetwork && !isBurner
|
||||||
<AccountStatus className={styles.status} />
|
? content.wrongNetwork
|
||||||
<span dangerouslySetInnerHTML={{ __html: message }} />{' '}
|
: !isLogged
|
||||||
<WalletSelector />
|
? content.noAccount
|
||||||
</div>
|
: isBurner
|
||||||
)}
|
? content.hasBurnerWallet
|
||||||
</div>
|
: isLogged
|
||||||
)
|
? content.hasMetaMaskWallet
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { isOceanNetwork, isLogged, isBurner, account } = this.context
|
return (
|
||||||
|
<div className={styles.message}>
|
||||||
return !isOceanNetwork
|
{this.context.account ? (
|
||||||
? this.message(content.wrongNetwork)
|
<Account
|
||||||
: !isLogged
|
account={this.context.account}
|
||||||
? this.message(content.noAccount)
|
isBurner={this.context.isBurner}
|
||||||
: isBurner
|
/>
|
||||||
? this.message(content.burnerWallet)
|
) : (
|
||||||
: isLogged
|
<AccountStatus className={styles.status} />
|
||||||
? this.message(content.hasAccount, account)
|
)}
|
||||||
: null
|
<em
|
||||||
|
className={styles.text}
|
||||||
|
dangerouslySetInnerHTML={{ __html: this.message() }}
|
||||||
|
/>{' '}
|
||||||
|
<WalletSelector />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Web3message.contextType = User
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { nodeUri } from '../config'
|
import { nodeUri } from '../config'
|
||||||
import bip39 from 'bip39'
|
|
||||||
import HDWalletProvider from 'truffle-hdwallet-provider'
|
import HDWalletProvider from 'truffle-hdwallet-provider'
|
||||||
|
const bip39 = require('bip39') // eslint-disable-line @typescript-eslint/no-var-requires
|
||||||
|
|
||||||
export class BurnerWalletProvider {
|
export class BurnerWalletProvider {
|
||||||
private web3: Web3
|
private web3: Web3
|
||||||
|
@ -62,6 +62,7 @@ interface UserProviderState {
|
|||||||
requestFromFaucet(account: string): Promise<FaucetResponse>
|
requestFromFaucet(account: string): Promise<FaucetResponse>
|
||||||
loginMetamask(): Promise<any>
|
loginMetamask(): Promise<any>
|
||||||
loginBurnerWallet(): Promise<any>
|
loginBurnerWallet(): Promise<any>
|
||||||
|
logoutBurnerWallet(): Promise<any>
|
||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +99,11 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private logoutBurnerWallet = async () => {
|
||||||
|
const burnerwalletProvider = new BurnerWalletProvider()
|
||||||
|
await burnerwalletProvider.logout()
|
||||||
|
}
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
isLogged: false,
|
isLogged: false,
|
||||||
isBurner: false,
|
isBurner: false,
|
||||||
@ -114,6 +120,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
requestFromFaucet: () => requestFromFaucet(''),
|
requestFromFaucet: () => requestFromFaucet(''),
|
||||||
loginMetamask: () => this.loginMetamask(),
|
loginMetamask: () => this.loginMetamask(),
|
||||||
loginBurnerWallet: () => this.loginBurnerWallet(),
|
loginBurnerWallet: () => this.loginBurnerWallet(),
|
||||||
|
logoutBurnerWallet: () => this.logoutBurnerWallet(),
|
||||||
message: 'Connecting to Ocean...'
|
message: 'Connecting to Ocean...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"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.",
|
||||||
"burnerWallet": "You are using temporary burner wallet. Improve your security by migrating to Metamask",
|
"hasBurnerWallet": "<p>We created a temporary burner wallet for you, allowing you to use all Commons functionality without any setup on your side. This wallet will persist in your browser across sessions, but not across different browsers or devices.</p>To personalize your experience and improve your security, <a href='https://docs.oceanprotocol.com/tutorials/metamask-setup/'>migrate to MetaMask</a>.",
|
||||||
"hasAccount": "",
|
"hasMetaMaskWallet": "Connected with MetaMask.",
|
||||||
"wrongNetwork": "Not connected to Pacific network.<br />Please connect in MetaMask with Custom RPC <code>https://pacific.oceanprotocol.com</code>"
|
"wrongNetwork": "Not connected to Pacific network.<br />Please connect in MetaMask with Custom RPC <code>https://pacific.oceanprotocol.com</code>"
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ import React, { Component } from 'react'
|
|||||||
import Route from '../components/templates/Route'
|
import Route from '../components/templates/Route'
|
||||||
import Content from '../components/atoms/Content'
|
import Content from '../components/atoms/Content'
|
||||||
import VersionNumbers from '../components/molecules/VersionNumbers'
|
import VersionNumbers from '../components/molecules/VersionNumbers'
|
||||||
|
import Web3message from '../components/organisms/Web3message'
|
||||||
|
import stylesVersionNumbers from '../components/molecules/VersionNumbers/index.module.scss'
|
||||||
|
|
||||||
class About extends Component {
|
class About extends Component {
|
||||||
public render() {
|
public render() {
|
||||||
@ -37,6 +39,10 @@ class About extends Component {
|
|||||||
</Content>
|
</Content>
|
||||||
|
|
||||||
<Content>
|
<Content>
|
||||||
|
<h2 className={stylesVersionNumbers.versionsTitle}>
|
||||||
|
Your Web3 Account Status
|
||||||
|
</h2>
|
||||||
|
<Web3message />
|
||||||
<VersionNumbers />
|
<VersionNumbers />
|
||||||
</Content>
|
</Content>
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -140,6 +140,11 @@ em,
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: $font-size-small;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
abbr[title],
|
abbr[title],
|
||||||
dfn {
|
dfn {
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
|
Loading…
Reference in New Issue
Block a user