1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

signature refactor

This commit is contained in:
Matthias Kretschmann 2019-04-29 12:34:10 +02:00
parent 3ca8fbba6f
commit 76732db30f
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -97,6 +97,7 @@ export default class AssetDetails extends PureComponent<
private updateAsset = async () => { private updateAsset = async () => {
this.setState({ isLoading: true, feedback: 'Updating asset...' }) this.setState({ isLoading: true, feedback: 'Updating asset...' })
const { web3, account } = this.context
const { id } = this.props.ddo const { id } = this.props.ddo
const { const {
dateCreated, dateCreated,
@ -105,6 +106,11 @@ export default class AssetDetails extends PureComponent<
categories categories
} = this.state } = this.state
const signature = await web3.eth.personal.sign(
`You are updating ${id}`,
account
)
const body = { const body = {
metadata: { metadata: {
base: { base: {
@ -114,9 +120,8 @@ export default class AssetDetails extends PureComponent<
categories categories
} }
}, },
signature: '' signature
} }
body.signature = await this.context.web3.eth.personal.sign('You are updating '+id, this.context.account)
const response = await this.fetch('PUT', body) const response = await this.fetch('PUT', body)
@ -130,12 +135,15 @@ export default class AssetDetails extends PureComponent<
private retireAsset = async () => { private retireAsset = async () => {
this.setState({ isLoading: true, feedback: 'Retiring asset...' }) this.setState({ isLoading: true, feedback: 'Retiring asset...' })
const { web3, account } = this.context
const { id } = this.props.ddo const { id } = this.props.ddo
const body = { const signature = await web3.eth.personal.sign(
signature: '' `You are retiring ${id}`,
} account
body.signature = await this.context.web3.eth.personal.sign('You are retiring '+id, this.context.account) )
const body = { signature }
const response = await this.fetch('DELETE', body) const response = await this.fetch('DELETE', body)
@ -208,7 +216,9 @@ export default class AssetDetails extends PureComponent<
private MetadataActions = () => { private MetadataActions = () => {
const isOwner = this.context.account === this.props.ddo.proof.creator const isOwner = this.context.account === this.props.ddo.proof.creator
if (!isOwner) { return null } if (!isOwner) {
return null
}
return ( return (
<div className={styles.metadataActions}> <div className={styles.metadataActions}>