From 76732db30fd8fe17359931a466919bbf7abc00c3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 29 Apr 2019 12:34:10 +0200 Subject: [PATCH] signature refactor --- client/src/routes/Details/AssetDetails.tsx | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/client/src/routes/Details/AssetDetails.tsx b/client/src/routes/Details/AssetDetails.tsx index bb98bf8..0606a69 100644 --- a/client/src/routes/Details/AssetDetails.tsx +++ b/client/src/routes/Details/AssetDetails.tsx @@ -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 (