mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
Merge branch 'feature/wallets' of https://github.com/oceanprotocol/commons into feature/wallets
This commit is contained in:
commit
69d8c28858
41
client/package-lock.json
generated
41
client/package-lock.json
generated
@ -11006,9 +11006,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mixin-deep": {
|
"mixin-deep": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
|
||||||
"integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
|
"integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"for-in": "^1.0.2",
|
"for-in": "^1.0.2",
|
||||||
"is-extendable": "^1.0.1"
|
"is-extendable": "^1.0.1"
|
||||||
@ -14825,9 +14825,9 @@
|
|||||||
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
|
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
|
||||||
},
|
},
|
||||||
"set-value": {
|
"set-value": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
|
||||||
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
|
"integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"extend-shallow": "^2.0.1",
|
"extend-shallow": "^2.0.1",
|
||||||
"is-extendable": "^0.1.1",
|
"is-extendable": "^0.1.1",
|
||||||
@ -16419,35 +16419,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"union-value": {
|
"union-value": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
"integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
|
"integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"arr-union": "^3.1.0",
|
"arr-union": "^3.1.0",
|
||||||
"get-value": "^2.0.6",
|
"get-value": "^2.0.6",
|
||||||
"is-extendable": "^0.1.1",
|
"is-extendable": "^0.1.1",
|
||||||
"set-value": "^0.4.3"
|
"set-value": "^2.0.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"extend-shallow": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
|
||||||
"requires": {
|
|
||||||
"is-extendable": "^0.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"set-value": {
|
|
||||||
"version": "0.4.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
|
|
||||||
"integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
|
|
||||||
"requires": {
|
|
||||||
"extend-shallow": "^2.0.1",
|
|
||||||
"is-extendable": "^0.1.1",
|
|
||||||
"is-plain-object": "^2.0.1",
|
|
||||||
"to-object-path": "^0.3.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uniq": {
|
"uniq": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { render } from '@testing-library/react'
|
import { render, fireEvent } from '@testing-library/react'
|
||||||
import { toDataUrl } from 'ethereum-blockies'
|
import { toDataUrl } from 'ethereum-blockies'
|
||||||
import Account from './Account'
|
import Account from './Account'
|
||||||
import { User } from '../../context'
|
import { User } from '../../context'
|
||||||
@ -18,12 +18,13 @@ describe('Account', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('outputs empty state without account', () => {
|
it('outputs empty state without account', () => {
|
||||||
const { container } = render(
|
const { container, getByText } = render(
|
||||||
<User.Provider value={{ ...userMockConnected, account: '' }}>
|
<User.Provider value={{ ...userMockConnected, account: '' }}>
|
||||||
<Account />
|
<Account />
|
||||||
</User.Provider>
|
</User.Provider>
|
||||||
)
|
)
|
||||||
expect(container.firstChild).toHaveTextContent('No account selected')
|
expect(container.firstChild).toHaveTextContent('No account selected')
|
||||||
|
fireEvent.click(getByText('Unlock Account'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('outputs blockie img', () => {
|
it('outputs blockie img', () => {
|
||||||
@ -41,4 +42,20 @@ describe('Account', () => {
|
|||||||
blockies
|
blockies
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Account info can be toggled', () => {
|
||||||
|
const { container, getByText } = render(
|
||||||
|
<User.Provider
|
||||||
|
value={{
|
||||||
|
...userMockConnected,
|
||||||
|
isBurner: true,
|
||||||
|
account: '0xxxxxxxxxxxxxxx'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Account />
|
||||||
|
</User.Provider>
|
||||||
|
)
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
fireEvent.click(getByText('Burner Wallet'))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -3,13 +3,13 @@ import { Logger, DDO, File } from '@oceanprotocol/squid'
|
|||||||
import filesize from 'filesize'
|
import filesize from 'filesize'
|
||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import Spinner from '../../atoms/Spinner'
|
import Spinner from '../../atoms/Spinner'
|
||||||
import { User } from '../../../context'
|
import { User, Market } from '../../../context'
|
||||||
import styles from './AssetFile.module.scss'
|
import styles from './AssetFile.module.scss'
|
||||||
import ReactGA from 'react-ga'
|
import ReactGA from 'react-ga'
|
||||||
import cleanupContentType from '../../../utils/cleanupContentType'
|
import cleanupContentType from '../../../utils/cleanupContentType'
|
||||||
|
|
||||||
export const messages = {
|
export const messages: any = {
|
||||||
start: 'Decrypting file URL...',
|
99: 'Decrypting file URL...',
|
||||||
0: '1/3<br />Asking for agreement signature...',
|
0: '1/3<br />Asking for agreement signature...',
|
||||||
1: '1/3<br />Agreement initialized.',
|
1: '1/3<br />Agreement initialized.',
|
||||||
2: '2/3<br />Asking for two payment confirmations...',
|
2: '2/3<br />Asking for two payment confirmations...',
|
||||||
@ -25,24 +25,26 @@ interface AssetFileProps {
|
|||||||
interface AssetFileState {
|
interface AssetFileState {
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
error: string
|
error: string
|
||||||
step: number | string | null
|
step: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class AssetFile extends PureComponent<
|
export default class AssetFile extends PureComponent<
|
||||||
AssetFileProps,
|
AssetFileProps,
|
||||||
AssetFileState
|
AssetFileState
|
||||||
> {
|
> {
|
||||||
|
public static contextType = User
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: '',
|
error: '',
|
||||||
step: null
|
step: 99
|
||||||
}
|
}
|
||||||
|
|
||||||
private resetState = () =>
|
private resetState = () =>
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
error: '',
|
error: '',
|
||||||
step: null
|
step: 99
|
||||||
})
|
})
|
||||||
|
|
||||||
private purchaseAsset = async (ddo: DDO, index: number) => {
|
private purchaseAsset = async (ddo: DDO, index: number) => {
|
||||||
@ -134,28 +136,28 @@ export default class AssetFile extends PureComponent<
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<Spinner
|
<Spinner message={messages[step]} />
|
||||||
message={
|
|
||||||
step === null ? messages.start : messages[step]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
|
<Market.Consumer>
|
||||||
|
{market => (
|
||||||
<Button
|
<Button
|
||||||
primary
|
primary
|
||||||
className={styles.buttonMain}
|
className={styles.buttonMain}
|
||||||
// weird 0 hack so TypeScript is happy
|
// weird 0 hack so TypeScript is happy
|
||||||
onClick={() => this.purchaseAsset(ddo, index || 0)}
|
onClick={() =>
|
||||||
disabled={!isLogged}
|
this.purchaseAsset(ddo, index || 0)
|
||||||
|
}
|
||||||
|
disabled={!isLogged || !market.networkMatch}
|
||||||
name="Download"
|
name="Download"
|
||||||
>
|
>
|
||||||
Get file
|
Get file
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
</Market.Consumer>
|
||||||
|
)}
|
||||||
|
|
||||||
{error !== '' && <div className={styles.error}>{error}</div>}
|
{error !== '' && <div className={styles.error}>{error}</div>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetFile.contextType = User
|
|
||||||
|
@ -3,7 +3,7 @@ import Input from '../../components/atoms/Form/Input'
|
|||||||
import Label from '../../components/atoms/Form/Label'
|
import Label from '../../components/atoms/Form/Label'
|
||||||
import Row from '../../components/atoms/Form/Row'
|
import Row from '../../components/atoms/Form/Row'
|
||||||
import Button from '../../components/atoms/Button'
|
import Button from '../../components/atoms/Button'
|
||||||
import { User } from '../../context'
|
import { User, Market } from '../../context'
|
||||||
import Files from './Files/'
|
import Files from './Files/'
|
||||||
import StepRegisterContent from './StepRegisterContent'
|
import StepRegisterContent from './StepRegisterContent'
|
||||||
import styles from './Step.module.scss'
|
import styles from './Step.module.scss'
|
||||||
@ -43,6 +43,8 @@ interface StepProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class Step extends PureComponent<StepProps, {}> {
|
export default class Step extends PureComponent<StepProps, {}> {
|
||||||
|
public static contextType = User
|
||||||
|
|
||||||
public previousButton() {
|
public previousButton() {
|
||||||
const { currentStep, prev } = this.props
|
const { currentStep, prev } = this.props
|
||||||
|
|
||||||
@ -152,9 +154,12 @@ export default class Step extends PureComponent<StepProps, {}> {
|
|||||||
{this.nextButton()}
|
{this.nextButton()}
|
||||||
|
|
||||||
{lastStep && (
|
{lastStep && (
|
||||||
|
<Market.Consumer>
|
||||||
|
{market => (
|
||||||
<Button
|
<Button
|
||||||
disabled={
|
disabled={
|
||||||
!this.context.isLogged ||
|
!this.context.isLogged ||
|
||||||
|
!market.networkMatch ||
|
||||||
this.props.state.isPublishing
|
this.props.state.isPublishing
|
||||||
}
|
}
|
||||||
primary
|
primary
|
||||||
@ -162,13 +167,13 @@ export default class Step extends PureComponent<StepProps, {}> {
|
|||||||
Register asset
|
Register asset
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
</Market.Consumer>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.account}>
|
<div className={styles.account}>
|
||||||
<Web3message />
|
{!lastStep && <Web3message />}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Step.contextType = User
|
|
||||||
|
43
server/package-lock.json
generated
43
server/package-lock.json
generated
@ -4096,9 +4096,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mixin-deep": {
|
"mixin-deep": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
|
||||||
"integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
|
"integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"for-in": "^1.0.2",
|
"for-in": "^1.0.2",
|
||||||
@ -5107,9 +5107,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"set-value": {
|
"set-value": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
|
||||||
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
|
"integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"extend-shallow": "^2.0.1",
|
"extend-shallow": "^2.0.1",
|
||||||
@ -5856,38 +5856,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"union-value": {
|
"union-value": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
"integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
|
"integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"arr-union": "^3.1.0",
|
"arr-union": "^3.1.0",
|
||||||
"get-value": "^2.0.6",
|
"get-value": "^2.0.6",
|
||||||
"is-extendable": "^0.1.1",
|
"is-extendable": "^0.1.1",
|
||||||
"set-value": "^0.4.3"
|
"set-value": "^2.0.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"extend-shallow": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"is-extendable": "^0.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"set-value": {
|
|
||||||
"version": "0.4.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
|
|
||||||
"integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"extend-shallow": "^2.0.1",
|
|
||||||
"is-extendable": "^0.1.1",
|
|
||||||
"is-plain-object": "^2.0.1",
|
|
||||||
"to-object-path": "^0.3.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"unique-string": {
|
"unique-string": {
|
||||||
|
Loading…
Reference in New Issue
Block a user