Skip to content
Permalink
Browse files

feat(Auth): use personal sign from web3 1.0 for token sig

  • Loading branch information...
satello committed May 3, 2018
1 parent 9d0aa14 commit 12cbaac1e0c184fc712c3c3a72173fc35f7e4f40
@@ -9,7 +9,11 @@
],
"main": "lib/index.js",
"module": "es/index.js",
"files": ["es", "lib", "umd"],
"files": [
"es",
"lib",
"umd"
],
"homepage": "https://kleros.io",
"repository": "github:kleros/kleros-api",
"bugs": "https://github.com/kleros/kleros-api/issues",
@@ -32,11 +36,12 @@
"commitmsg": "kleros-scripts commitmsg",
"cz": "kleros-scripts cz",
"start": "babel src --out-dir ./es --watch --source-maps",
"build":
"rimraf ./umd ./es ./lib && webpack --env.NODE_ENV=production -p && babel src --out-dir ./es --source-maps && cross-env BABEL_ENV=commonjs babel src --out-dir ./lib --source-maps"
"build": "rimraf ./umd ./es ./lib && webpack --env.NODE_ENV=production -p && babel src --out-dir ./es --source-maps && cross-env BABEL_ENV=commonjs babel src --out-dir ./lib --source-maps"
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"babel-cli": "^6.26.0",
@@ -67,6 +72,7 @@
"kleros-interaction": "^0.0.8",
"lodash": "^4.17.4",
"truffle-contract": "^2.0.5",
"web3": "^0.20.1"
"web3": "^0.20.1",
"web3-eth-personal": "^1.0.0-beta.34"
}
}
@@ -160,10 +160,12 @@ class ArbitrableContract extends AbstractContract {
getData = async account => {
const contractData = await this._contractImplementation.getData()

const storeData = await this._StoreProvider.getContractByAddress(
account,
this._contractImplementation.contractAddress
)
let storeData = {}
if (account)
storeData = await this._StoreProvider.getContractByAddress(
account,
this._contractImplementation.contractAddress
)

return Object.assign({}, storeData, contractData)
}
@@ -1,3 +1,5 @@
import Personal from 'web3-eth-personal'

import isRequired from '../utils/isRequired'

class Auth {
@@ -43,12 +45,21 @@ class Auth {
}

/**
* Sign a message with your private key.
* Sign a message with your private key. Uses web3 1.0 personal sign
* @param {string} userAddress - The address with which we want to sign the message
* @param {string} data - Hex encoded data to sign
* @returns {string} signed data
*/
signMessage = (userAddress, data) => this._Web3Wrapper.sign(userAddress, data)
signMessage = (userAddress, data) => {
const ethPersonal = new Personal(this._Web3Wrapper.getProvider())
return new Promise((resolve, reject) => {
ethPersonal.sign(data, userAddress, (error, result) => {
if (error) reject(error)

resolve(result)
})
})
}
}

export default Auth
@@ -93,7 +93,9 @@ class Disputes {
await this._ArbitrableInstance.setContractInstance(
disputeData.arbitrableContractAddress
)
const arbitrableContractData = await this._ArbitrableInstance.getData()
const arbitrableContractData = await this._ArbitrableInstance.getData(
account
)
// timestamp
const blockTimestamp = (await this._ArbitratorInstance.getBlock(
event.blockNumber
@@ -281,7 +283,7 @@ class Disputes {
arbitrableContractAddress
)
const [arbitrableContractData, evidence] = await Promise.all([
this._ArbitrableInstance.getData(),
this._ArbitrableInstance.getData(account),
this._ArbitrableInstance.getEvidenceForArbitrableContract(
arbitrableContractAddress
)
@@ -147,7 +147,9 @@ class Notifications {
contracts.map(async contract => {
// load arbitrable contract
await this._ArbitrableInstance.setContractInstance(contract.address)
const contractData = await this._ArbitrableInstance.getData()
const contractData = await this._ArbitrableInstance.getData(
contract.partyA
)
const arbitrationCost = await this._ArbitratorInstance.getArbitrationCost(
contractData.arbitratorExtraData
)
@@ -109,6 +109,7 @@ class StoreProviderWrapper {

return newTokenResponse.body
}

// **************************** //
// * Read * //
// **************************** //
Oops, something went wrong.

0 comments on commit 12cbaac

Please sign in to comment.
You can’t perform that action at this time.