mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
rebase fixes
This commit is contained in:
parent
9e7df28b89
commit
ad454b9f8a
8
client/package-lock.json
generated
8
client/package-lock.json
generated
@ -1684,7 +1684,8 @@
|
||||
"@types/prop-types": {
|
||||
"version": "15.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.1.tgz",
|
||||
"integrity": "sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg=="
|
||||
"integrity": "sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/q": {
|
||||
"version": "1.5.2",
|
||||
@ -1696,6 +1697,7 @@
|
||||
"version": "16.8.22",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.22.tgz",
|
||||
"integrity": "sha512-C3O1yVqk4sUXqWyx0wlys76eQfhrQhiDhDlHBrjER76lR2S2Agiid/KpOU9oCqj1dISStscz7xXz1Cg8+sCQeA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/prop-types": "*",
|
||||
"csstype": "^2.2.0"
|
||||
@ -1742,6 +1744,7 @@
|
||||
"version": "3.8.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-modal/-/react-modal-3.8.2.tgz",
|
||||
"integrity": "sha512-/Drs+XfHg9M60fy2Q63UUlhECXSNknDu3tnwFnbOhcdDjq03VD3hLCfv3X+BBzRqgu4TOu+TwEwBhgI8qdVAAQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
@ -4883,7 +4886,8 @@
|
||||
"csstype": {
|
||||
"version": "2.6.5",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.5.tgz",
|
||||
"integrity": "sha512-JsTaiksRsel5n7XwqPAfB0l3TFKdpjW/kgAELf9vrb5adGA7UCPLajKK5s3nFrcFm3Rkyp/Qkgl73ENc1UY3cA=="
|
||||
"integrity": "sha512-JsTaiksRsel5n7XwqPAfB0l3TFKdpjW/kgAELf9vrb5adGA7UCPLajKK5s3nFrcFm3Rkyp/Qkgl73ENc1UY3cA==",
|
||||
"dev": true
|
||||
},
|
||||
"currently-unhandled": {
|
||||
"version": "0.4.1",
|
||||
|
@ -16,7 +16,6 @@
|
||||
"@oceanprotocol/squid": "0.6.2",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@sindresorhus/slugify": "^0.9.1",
|
||||
"@types/react-modal": "^3.8.2",
|
||||
"axios": "^0.19.0",
|
||||
"bip39": "^3.0.2",
|
||||
"classnames": "^2.2.6",
|
||||
|
1
client/src/@types/truffle-hdwallet-provider'/index.d.ts
vendored
Normal file
1
client/src/@types/truffle-hdwallet-provider'/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'truffle-hdwallet-provider'
|
@ -8,12 +8,7 @@ export default class Popover extends PureComponent<{
|
||||
style: React.CSSProperties
|
||||
}> {
|
||||
public render() {
|
||||
const {
|
||||
account,
|
||||
balance,
|
||||
network,
|
||||
isOceanNetwork
|
||||
} = this.context
|
||||
const { account, balance, network, isOceanNetwork } = this.context
|
||||
|
||||
return (
|
||||
<div
|
||||
|
@ -33,7 +33,7 @@ export default class Header extends PureComponent {
|
||||
{menu.map(item => (
|
||||
<MenuItem key={item.title} item={item} />
|
||||
))}
|
||||
<WalletSelector/>
|
||||
<WalletSelector />
|
||||
<AccountStatus className={styles.accountStatus} />
|
||||
</nav>
|
||||
</div>
|
||||
|
@ -28,7 +28,6 @@ export default class WalletSelector extends PureComponent<
|
||||
this.toggleModal()
|
||||
}
|
||||
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div className={styles.actions}>
|
||||
@ -46,8 +45,12 @@ export default class WalletSelector extends PureComponent<
|
||||
toggleModal={this.toggleModal}
|
||||
>
|
||||
<div className={styles.info}>
|
||||
<button onClick={this.loginBurnerWallet}>login BurnerWallet</button>
|
||||
<button onClick={this.loginMetamask}>login Metamask</button>
|
||||
<button onClick={this.loginBurnerWallet}>
|
||||
login BurnerWallet
|
||||
</button>
|
||||
<button onClick={this.loginMetamask}>
|
||||
login Metamask
|
||||
</button>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
|
@ -7,10 +7,7 @@ import WalletSelector from './WalletSelector'
|
||||
import content from '../../data/web3message.json'
|
||||
|
||||
export default class Web3message extends PureComponent {
|
||||
private message = (
|
||||
message: string,
|
||||
account?: string,
|
||||
) => (
|
||||
private message = (message: string, account?: string) => (
|
||||
<div className={styles.message}>
|
||||
{account ? (
|
||||
<Account account={account} />
|
||||
@ -18,19 +15,14 @@ export default class Web3message extends PureComponent {
|
||||
<div className={styles.warnings}>
|
||||
<AccountStatus className={styles.status} />
|
||||
<span dangerouslySetInnerHTML={{ __html: message }} />{' '}
|
||||
<WalletSelector/>
|
||||
<WalletSelector />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
public render() {
|
||||
const {
|
||||
isOceanNetwork,
|
||||
isLogged,
|
||||
isBurner,
|
||||
account,
|
||||
} = this.context
|
||||
const { isOceanNetwork, isLogged, isBurner, account } = this.context
|
||||
|
||||
return !isOceanNetwork
|
||||
? this.message(content.wrongNetwork)
|
||||
|
@ -1,48 +1,48 @@
|
||||
import Web3 from 'web3'
|
||||
import { nodeUri } from '../config'
|
||||
const bip39 = require('bip39')
|
||||
const HDWalletProvider = require('truffle-hdwallet-provider')
|
||||
import bip39 from 'bip39'
|
||||
import HDWalletProvider from 'truffle-hdwallet-provider'
|
||||
|
||||
export class BurnerWalletProvider {
|
||||
web3: Web3
|
||||
private web3: Web3
|
||||
|
||||
constructor() {
|
||||
public constructor() {
|
||||
// Default
|
||||
this.web3 = null as any
|
||||
}
|
||||
|
||||
async isAvaliable() {
|
||||
public async isAvailable() {
|
||||
return true
|
||||
}
|
||||
|
||||
async isLogged() {
|
||||
public async isLogged() {
|
||||
if (localStorage.getItem('seedphrase') !== null) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async startLogin() {
|
||||
public async startLogin() {
|
||||
if (await this.isLogged()) {
|
||||
const mnemonic = localStorage.getItem('seedphrase') as string
|
||||
localStorage.setItem('logType', 'BurnerWallet')
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1);
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1)
|
||||
this.web3 = new Web3(provider)
|
||||
} else {
|
||||
const mnemonic = bip39.generateMnemonic()
|
||||
localStorage.setItem('seedphrase', mnemonic)
|
||||
localStorage.setItem('logType', 'BurnerWallet')
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1);
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1)
|
||||
this.web3 = new Web3(provider)
|
||||
}
|
||||
}
|
||||
|
||||
async logout() {
|
||||
public async logout() {
|
||||
localStorage.removeItem('seedphrase')
|
||||
localStorage.removeItem('logType')
|
||||
}
|
||||
|
||||
getProvider() {
|
||||
public getProvider() {
|
||||
return this.web3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import Web3 from 'web3'
|
||||
|
||||
export class MetamaskProvider {
|
||||
web3: Web3
|
||||
private web3: Web3
|
||||
|
||||
constructor() {
|
||||
public constructor() {
|
||||
// Default
|
||||
this.web3 = null as any
|
||||
// Modern dapp browsers
|
||||
@ -16,19 +16,19 @@ export class MetamaskProvider {
|
||||
}
|
||||
}
|
||||
|
||||
async isAvaliable() {
|
||||
public async isAvailable() {
|
||||
return this.web3 !== null
|
||||
}
|
||||
|
||||
async isLogged() {
|
||||
if(this.web3 === null) return false
|
||||
if((await this.web3.eth.getAccounts()).length > 0) {
|
||||
public async isLogged() {
|
||||
if (this.web3 === null) return false
|
||||
if ((await this.web3.eth.getAccounts()).length > 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async startLogin() {
|
||||
public async startLogin() {
|
||||
try {
|
||||
await window.ethereum.enable()
|
||||
localStorage.setItem('logType', 'Metamask')
|
||||
@ -37,12 +37,12 @@ export class MetamaskProvider {
|
||||
}
|
||||
}
|
||||
|
||||
async logout() {
|
||||
public async logout() {
|
||||
localStorage.removeItem('logType')
|
||||
// reload page?
|
||||
}
|
||||
|
||||
getProvider() {
|
||||
public getProvider() {
|
||||
return this.web3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,11 +164,12 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
|
||||
private bootstrap = async () => {
|
||||
const logType = localStorage.getItem('logType')
|
||||
const metamaskProvider = new MetamaskProvider()
|
||||
|
||||
switch (logType) {
|
||||
case 'Metamask':
|
||||
const metamaskProvider = new MetamaskProvider()
|
||||
if (
|
||||
(await metamaskProvider.isAvaliable()) &&
|
||||
(await metamaskProvider.isAvailable()) &&
|
||||
(await metamaskProvider.isLogged())
|
||||
) {
|
||||
const web3 = metamaskProvider.getProvider()
|
||||
@ -249,7 +250,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
const isOceanNetwork = isPacific || isNile || isDuero || isSpree
|
||||
|
||||
network !== this.state.network &&
|
||||
this.setState({ isOceanNetwork, network })
|
||||
this.setState({ isOceanNetwork, network })
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
@ -1,44 +0,0 @@
|
||||
import Web3 from 'web3'
|
||||
import { nodeHost, nodePort, nodeScheme } from '../config'
|
||||
import bip39 from 'bip39'
|
||||
const HDWalletProvider = require('truffle-hdwallet-provider')
|
||||
|
||||
export class ZeroWalletProvider {
|
||||
web3: Web3
|
||||
|
||||
constructor() {
|
||||
// Default
|
||||
this.web3 = null as any
|
||||
}
|
||||
|
||||
async isLogged() {
|
||||
if (localStorage.getItem('seedphrase') !== null) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async restoreStoredLogin() {
|
||||
const mnemonic = localStorage.getItem('seedphrase') as string
|
||||
localStorage.setItem('seedphrase', mnemonic)
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeScheme}://${nodeHost}:${nodePort}`, 0, 1);
|
||||
this.web3 = new Web3(provider)
|
||||
}
|
||||
|
||||
async createLogin() {
|
||||
const mnemonic = bip39.generateMnemonic()
|
||||
localStorage.setItem('seedphrase', mnemonic)
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeScheme}://${nodeHost}:${nodePort}`, 0, 1);
|
||||
this.web3 = new Web3(provider)
|
||||
}
|
||||
|
||||
async restoreLogin(mnemonic: string) {
|
||||
localStorage.setItem('seedphrase', mnemonic)
|
||||
const provider = new HDWalletProvider(mnemonic, `${nodeScheme}://${nodeHost}:${nodePort}`, 0, 1);
|
||||
this.web3 = new Web3(provider)
|
||||
}
|
||||
|
||||
getProvider() {
|
||||
return this.web3
|
||||
}
|
||||
}
|
@ -22,11 +22,11 @@ export async function provideOcean(web3provider: Web3) {
|
||||
verbose
|
||||
}
|
||||
|
||||
console.log('accs web3:', (await web3provider.eth.getAccounts())[0])
|
||||
Logger.log('accs web3:', (await web3provider.eth.getAccounts())[0])
|
||||
|
||||
const ocean: any = await Ocean.getInstance(config)
|
||||
|
||||
console.log('accs ocean:', (await ocean.accounts.list())[0].id)
|
||||
Logger.log('accs ocean:', (await ocean.accounts.list())[0].id)
|
||||
|
||||
return { ocean }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user