import React, { ChangeEvent, Component, FormEvent } from 'react' import Button from '../components/atoms/Button' import { User } from '../context/User' import AssetModel from '../models/AssetModel' type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other' interface PublishState { name?: string dateCreated?: Date description?: string files?: string[] price?: number author?: string type?: AssetType license?: string copyrightHolder?: string categories?: string[] tags?: string[] } class Publish extends Component<{}, PublishState> { public state = { name: '', dateCreated: new Date(), description: '', files: [''], price: 0, author: '', type: 'dataset' as AssetType, license: '', copyrightHolder: '', categories: [''] } public render() { return (

Publish

Name:
Description:
Price:
Author:
Files:
Type:
License:
Category:
CopyrightHolder:
{(states /* tslint:disable-next-line */) => (
{states.isLogged ? (
) : (
)}
)}
) } private inputChange = ( event: ChangeEvent | ChangeEvent ) => { this.setState({ [event.target.name]: event.target.value }) } private inputToArrayChange = ( event: ChangeEvent | ChangeEvent ) => { this.setState({ [event.target.name]: [event.target.value] }) } private registerAsset = async (event: FormEvent) => { event.preventDefault() const account = await this.context.ocean.getAccounts() const newAsset = { // OEP-08 Attributes // https://github.com/oceanprotocol/OEPs/tree/master/8 base: Object.assign(AssetModel.base, { name: this.state.name, description: this.state.description, dateCreated: new Date().toString(), author: this.state.author, license: this.state.license, copyrightHolder: this.state.copyrightHolder, contentUrls: [this.state.files], price: this.state.price, type: this.state.type, size: '', encoding: '', compression: undefined, contentType: '', workExample: undefined, inLanguage: undefined, tags: '' }), curation: Object.assign(AssetModel.curation), additionalInformation: Object.assign( AssetModel.additionalInformation ) } const ddo = await this.context.ocean.registerAsset(newAsset, account[0]) } } Publish.contextType = User export default Publish