mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
add active account to user context, output in Web3 message
This commit is contained in:
parent
c54cf45b12
commit
0b7e602606
@ -22,6 +22,7 @@ interface AppState {
|
||||
isLogged: boolean
|
||||
isLoading: boolean
|
||||
isWeb3: boolean
|
||||
account: string
|
||||
web3: Web3
|
||||
ocean: {}
|
||||
startLogin: () => void
|
||||
@ -44,6 +45,7 @@ class App extends Component<{}, AppState> {
|
||||
`${nodeScheme}://${nodeHost}:${nodePort}`
|
||||
)
|
||||
),
|
||||
account: '',
|
||||
ocean: {},
|
||||
startLogin: this.startLogin
|
||||
}
|
||||
@ -61,6 +63,7 @@ class App extends Component<{}, AppState> {
|
||||
this.setState({
|
||||
isLogged: true,
|
||||
isWeb3: true,
|
||||
account: accounts[0],
|
||||
web3
|
||||
})
|
||||
} else {
|
||||
@ -69,6 +72,7 @@ class App extends Component<{}, AppState> {
|
||||
this.setState({
|
||||
isLogged: true,
|
||||
isWeb3: true,
|
||||
account: accounts[0],
|
||||
web3
|
||||
})
|
||||
}
|
||||
@ -90,6 +94,7 @@ class App extends Component<{}, AppState> {
|
||||
if (accounts.length > 0) {
|
||||
this.setState({
|
||||
isLogged: true,
|
||||
account: accounts[0],
|
||||
web3
|
||||
})
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
.account {
|
||||
font-family: $font-family-monospace;
|
||||
display: inline-block;
|
||||
margin-left: $spacer / 8;
|
||||
background: none;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export default class Web3message extends PureComponent {
|
||||
: !states.isLogged
|
||||
? this.unlockAccount(states)
|
||||
: states.isLogged
|
||||
? this.haveAccount()
|
||||
? this.haveAccount(states.account)
|
||||
: null
|
||||
}
|
||||
</User.Consumer>
|
||||
@ -48,17 +48,14 @@ export default class Web3message extends PureComponent {
|
||||
)
|
||||
}
|
||||
|
||||
public haveAccount() {
|
||||
public haveAccount(account: string) {
|
||||
return (
|
||||
<div className={styles.message}>
|
||||
<span className={styles.indicatorActive} /> Connected with
|
||||
account
|
||||
<span
|
||||
className={styles.account}
|
||||
title="0xfehz2u89nfewhji432ntio43huof42huifewhnuefwo"
|
||||
>
|
||||
0xfehz2u89n...
|
||||
</span>
|
||||
<code className={styles.account} title={account}>
|
||||
{`${account.substring(0, 20)}...`}
|
||||
</code>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ export const User = React.createContext({
|
||||
isLogged: false,
|
||||
isLoading: false,
|
||||
isWeb3: false,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
startLogin: () => {
|
||||
|
Loading…
Reference in New Issue
Block a user