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": {
|
"@types/prop-types": {
|
||||||
"version": "15.7.1",
|
"version": "15.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.1.tgz",
|
"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": {
|
"@types/q": {
|
||||||
"version": "1.5.2",
|
"version": "1.5.2",
|
||||||
@ -1696,6 +1697,7 @@
|
|||||||
"version": "16.8.22",
|
"version": "16.8.22",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.22.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.22.tgz",
|
||||||
"integrity": "sha512-C3O1yVqk4sUXqWyx0wlys76eQfhrQhiDhDlHBrjER76lR2S2Agiid/KpOU9oCqj1dISStscz7xXz1Cg8+sCQeA==",
|
"integrity": "sha512-C3O1yVqk4sUXqWyx0wlys76eQfhrQhiDhDlHBrjER76lR2S2Agiid/KpOU9oCqj1dISStscz7xXz1Cg8+sCQeA==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
"csstype": "^2.2.0"
|
"csstype": "^2.2.0"
|
||||||
@ -1742,6 +1744,7 @@
|
|||||||
"version": "3.8.2",
|
"version": "3.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react-modal/-/react-modal-3.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react-modal/-/react-modal-3.8.2.tgz",
|
||||||
"integrity": "sha512-/Drs+XfHg9M60fy2Q63UUlhECXSNknDu3tnwFnbOhcdDjq03VD3hLCfv3X+BBzRqgu4TOu+TwEwBhgI8qdVAAQ==",
|
"integrity": "sha512-/Drs+XfHg9M60fy2Q63UUlhECXSNknDu3tnwFnbOhcdDjq03VD3hLCfv3X+BBzRqgu4TOu+TwEwBhgI8qdVAAQ==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/react": "*"
|
"@types/react": "*"
|
||||||
}
|
}
|
||||||
@ -4883,7 +4886,8 @@
|
|||||||
"csstype": {
|
"csstype": {
|
||||||
"version": "2.6.5",
|
"version": "2.6.5",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.5.tgz",
|
"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": {
|
"currently-unhandled": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"@oceanprotocol/squid": "0.6.2",
|
"@oceanprotocol/squid": "0.6.2",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@sindresorhus/slugify": "^0.9.1",
|
"@sindresorhus/slugify": "^0.9.1",
|
||||||
"@types/react-modal": "^3.8.2",
|
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"bip39": "^3.0.2",
|
"bip39": "^3.0.2",
|
||||||
"classnames": "^2.2.6",
|
"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
|
style: React.CSSProperties
|
||||||
}> {
|
}> {
|
||||||
public render() {
|
public render() {
|
||||||
const {
|
const { account, balance, network, isOceanNetwork } = this.context
|
||||||
account,
|
|
||||||
balance,
|
|
||||||
network,
|
|
||||||
isOceanNetwork
|
|
||||||
} = this.context
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -33,7 +33,7 @@ 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/>
|
<WalletSelector />
|
||||||
<AccountStatus className={styles.accountStatus} />
|
<AccountStatus className={styles.accountStatus} />
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,7 +28,6 @@ export default class WalletSelector extends PureComponent<
|
|||||||
this.toggleModal()
|
this.toggleModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
@ -46,8 +45,12 @@ export default class WalletSelector extends PureComponent<
|
|||||||
toggleModal={this.toggleModal}
|
toggleModal={this.toggleModal}
|
||||||
>
|
>
|
||||||
<div className={styles.info}>
|
<div className={styles.info}>
|
||||||
<button onClick={this.loginBurnerWallet}>login BurnerWallet</button>
|
<button onClick={this.loginBurnerWallet}>
|
||||||
<button onClick={this.loginMetamask}>login Metamask</button>
|
login BurnerWallet
|
||||||
|
</button>
|
||||||
|
<button onClick={this.loginMetamask}>
|
||||||
|
login Metamask
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,10 +7,7 @@ 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 = (
|
private message = (message: string, account?: string) => (
|
||||||
message: string,
|
|
||||||
account?: string,
|
|
||||||
) => (
|
|
||||||
<div className={styles.message}>
|
<div className={styles.message}>
|
||||||
{account ? (
|
{account ? (
|
||||||
<Account account={account} />
|
<Account account={account} />
|
||||||
@ -18,19 +15,14 @@ export default class Web3message extends PureComponent {
|
|||||||
<div className={styles.warnings}>
|
<div className={styles.warnings}>
|
||||||
<AccountStatus className={styles.status} />
|
<AccountStatus className={styles.status} />
|
||||||
<span dangerouslySetInnerHTML={{ __html: message }} />{' '}
|
<span dangerouslySetInnerHTML={{ __html: message }} />{' '}
|
||||||
<WalletSelector/>
|
<WalletSelector />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {
|
const { isOceanNetwork, isLogged, isBurner, account } = this.context
|
||||||
isOceanNetwork,
|
|
||||||
isLogged,
|
|
||||||
isBurner,
|
|
||||||
account,
|
|
||||||
} = this.context
|
|
||||||
|
|
||||||
return !isOceanNetwork
|
return !isOceanNetwork
|
||||||
? this.message(content.wrongNetwork)
|
? this.message(content.wrongNetwork)
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { nodeUri } from '../config'
|
import { nodeUri } from '../config'
|
||||||
const bip39 = require('bip39')
|
import bip39 from 'bip39'
|
||||||
const HDWalletProvider = require('truffle-hdwallet-provider')
|
import HDWalletProvider from 'truffle-hdwallet-provider'
|
||||||
|
|
||||||
export class BurnerWalletProvider {
|
export class BurnerWalletProvider {
|
||||||
web3: Web3
|
private web3: Web3
|
||||||
|
|
||||||
constructor() {
|
public constructor() {
|
||||||
// Default
|
// Default
|
||||||
this.web3 = null as any
|
this.web3 = null as any
|
||||||
}
|
}
|
||||||
|
|
||||||
async isAvaliable() {
|
public async isAvailable() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async isLogged() {
|
public async isLogged() {
|
||||||
if (localStorage.getItem('seedphrase') !== null) {
|
if (localStorage.getItem('seedphrase') !== null) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async startLogin() {
|
public async startLogin() {
|
||||||
if (await this.isLogged()) {
|
if (await this.isLogged()) {
|
||||||
const mnemonic = localStorage.getItem('seedphrase') as string
|
const mnemonic = localStorage.getItem('seedphrase') as string
|
||||||
localStorage.setItem('logType', 'BurnerWallet')
|
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)
|
this.web3 = new Web3(provider)
|
||||||
} else {
|
} else {
|
||||||
const mnemonic = bip39.generateMnemonic()
|
const mnemonic = bip39.generateMnemonic()
|
||||||
localStorage.setItem('seedphrase', mnemonic)
|
localStorage.setItem('seedphrase', mnemonic)
|
||||||
localStorage.setItem('logType', 'BurnerWallet')
|
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)
|
this.web3 = new Web3(provider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async logout() {
|
public async logout() {
|
||||||
localStorage.removeItem('seedphrase')
|
localStorage.removeItem('seedphrase')
|
||||||
localStorage.removeItem('logType')
|
localStorage.removeItem('logType')
|
||||||
}
|
}
|
||||||
|
|
||||||
getProvider() {
|
public getProvider() {
|
||||||
return this.web3
|
return this.web3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
|
||||||
export class MetamaskProvider {
|
export class MetamaskProvider {
|
||||||
web3: Web3
|
private web3: Web3
|
||||||
|
|
||||||
constructor() {
|
public constructor() {
|
||||||
// Default
|
// Default
|
||||||
this.web3 = null as any
|
this.web3 = null as any
|
||||||
// Modern dapp browsers
|
// Modern dapp browsers
|
||||||
@ -16,19 +16,19 @@ export class MetamaskProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async isAvaliable() {
|
public async isAvailable() {
|
||||||
return this.web3 !== null
|
return this.web3 !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
async isLogged() {
|
public async isLogged() {
|
||||||
if(this.web3 === null) return false
|
if (this.web3 === null) return false
|
||||||
if((await this.web3.eth.getAccounts()).length > 0) {
|
if ((await this.web3.eth.getAccounts()).length > 0) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async startLogin() {
|
public async startLogin() {
|
||||||
try {
|
try {
|
||||||
await window.ethereum.enable()
|
await window.ethereum.enable()
|
||||||
localStorage.setItem('logType', 'Metamask')
|
localStorage.setItem('logType', 'Metamask')
|
||||||
@ -37,12 +37,12 @@ export class MetamaskProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async logout() {
|
public async logout() {
|
||||||
localStorage.removeItem('logType')
|
localStorage.removeItem('logType')
|
||||||
// reload page?
|
// reload page?
|
||||||
}
|
}
|
||||||
|
|
||||||
getProvider() {
|
public getProvider() {
|
||||||
return this.web3
|
return this.web3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,11 +164,12 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
|
|
||||||
private bootstrap = async () => {
|
private bootstrap = async () => {
|
||||||
const logType = localStorage.getItem('logType')
|
const logType = localStorage.getItem('logType')
|
||||||
|
const metamaskProvider = new MetamaskProvider()
|
||||||
|
|
||||||
switch (logType) {
|
switch (logType) {
|
||||||
case 'Metamask':
|
case 'Metamask':
|
||||||
const metamaskProvider = new MetamaskProvider()
|
|
||||||
if (
|
if (
|
||||||
(await metamaskProvider.isAvaliable()) &&
|
(await metamaskProvider.isAvailable()) &&
|
||||||
(await metamaskProvider.isLogged())
|
(await metamaskProvider.isLogged())
|
||||||
) {
|
) {
|
||||||
const web3 = metamaskProvider.getProvider()
|
const web3 = metamaskProvider.getProvider()
|
||||||
@ -249,7 +250,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
const isOceanNetwork = isPacific || isNile || isDuero || isSpree
|
const isOceanNetwork = isPacific || isNile || isDuero || isSpree
|
||||||
|
|
||||||
network !== this.state.network &&
|
network !== this.state.network &&
|
||||||
this.setState({ isOceanNetwork, network })
|
this.setState({ isOceanNetwork, network })
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
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
|
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)
|
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 }
|
return { ocean }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user