diff --git a/src/components/Web3message.tsx b/src/components/Web3message.tsx
index 4338b9a..1d19888 100644
--- a/src/components/Web3message.tsx
+++ b/src/components/Web3message.tsx
@@ -16,36 +16,55 @@ export default class Web3message extends PureComponent {
{states =>
!states.isWeb3 ? (
-
-
No Web3 Browser. For
- publishing an asset you need to use a Web3-capable plugin or
- browser, like{' '}
-
- MetaMask
-
- .
-
+ this.noWeb3()
) : !states.isLogged ? (
-
- Account
- locked. For publishing an asset you need to unlock your Web3
- account.
-
-
+ this.unlockAccount(states)
) : states.isLogged ? (
-
- Connected with account
-
- 0xfehz2u89n...
-
-
+ this.haveAccount()
) : null
}
>
)
}
+
+ public noWeb3() {
+ return (
+
+
No Web3 Browser. For
+ publishing an asset you need to use a Web3-capable plugin or
+ browser, like{' '}
+
+ MetaMask
+
+ .
+
+ )
+ }
+
+ public unlockAccount(states: any) {
+ return (
+
+ Account
+ locked. For publishing an asset you need to unlock your Web3
+ account.
+
+
+ )
+ }
+
+ public haveAccount() {
+ return (
+
+ Connected with account
+
+ 0xfehz2u89n...
+
+
+ )
+ }
+
}
diff --git a/src/routes/Publish.tsx b/src/routes/Publish.tsx
index 707cf1e..f0708a1 100644
--- a/src/routes/Publish.tsx
+++ b/src/routes/Publish.tsx
@@ -23,8 +23,10 @@ interface PublishState {
license?: string
copyrightHolder?: string
categories?: string[]
- tags?: string[],
- isPublishing?: boolean,
+ tags?: string[]
+ isPublishing?: boolean
+ isPublished?: boolean
+ publishedDid?: string
publishingError?: string
}
@@ -41,6 +43,8 @@ class Publish extends Component<{}, PublishState> {
copyrightHolder: '',
categories: [''],
isPublishing: false,
+ isPublished: false,
+ publishedDid: '',
publishingError: ''
}
@@ -89,6 +93,23 @@ class Publish extends Component<{}, PublishState> {
this.setState({ publishingError: '' })
}
+ private toStart = () => {
+ this.setState({
+ name: '',
+ dateCreated: new Date(),
+ description: '',
+ files: [''],
+ price: 0,
+ author: '',
+ type: 'dataset' as AssetType,
+ license: '',
+ copyrightHolder: '',
+ categories: [''],
+ isPublishing: false,
+ isPublished: false
+ })
+ }
+
private registerAsset = async (event: FormEvent) => {
event.preventDefault()
this.setState({
@@ -123,7 +144,12 @@ class Publish extends Component<{}, PublishState> {
)
}
try {
- await this.context.ocean.registerAsset(newAsset, account[0])
+ const asset = await this.context.ocean.registerAsset(newAsset, account[0])
+ Logger.log('asset:', asset)
+ this.setState({
+ publishedDid: asset.id,
+ isPublished: true
+ })
} catch (e) {
// make readable errors
Logger.log('error:', e)
@@ -144,9 +170,11 @@ class Publish extends Component<{}, PublishState> {
{this.state.isPublishing ? (
- Please sign with ctypto wallet
+ this.publishingState()
) : this.state.publishingError ? (
-
+ this.errorState()
+ ) : this.state.isPublished ? (
+ this.publishedState()
) : (