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