Skip to content

Commit

Permalink
fix error format and bump (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Barbieri committed Nov 20, 2018
1 parent c446884 commit 8788c83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const {EventEmitter} = require('events')
const HDKey = require('hdkey')
const ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')
const Transaction = require('ethereumjs-tx')

const hdPathString = `m/44'/60'/0'`
const type = 'Ledger Hardware'
Expand Down Expand Up @@ -174,10 +173,10 @@ class LedgerBridgeKeyring extends EventEmitter {
if (valid) {
resolve(tx)
} else {
reject('The transaction signature is not valid')
reject(new Error('Ledger: The transaction signature is not valid'))
}
} else {
reject(payload)
reject(new Error(payload.error || 'Ledger: Unknown error while signing transaction'))
}
})
})
Expand Down Expand Up @@ -219,11 +218,11 @@ class LedgerBridgeKeyring extends EventEmitter {
const signature = `0x${payload['r']}${payload['s']}${v}`
const addressSignedWith = sigUtil.recoverPersonalSignature({data: message, sig: signature})
if (ethUtil.toChecksumAddress(addressSignedWith) !== ethUtil.toChecksumAddress(withAccount)) {
reject('signature doesnt match the right address')
reject(new Error('Ledger: The signature doesnt match the right address'))
}
resolve(signature)
} else {
reject(payload)
reject(new Error(payload.error || 'Ledger: Uknown error while signing message'))
}
})
})
Expand Down Expand Up @@ -289,9 +288,6 @@ class LedgerBridgeKeyring extends EventEmitter {
}
resolve(accounts)
})
.catch(e => {
reject(e)
})
})
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eth-ledger-bridge-keyring",
"version": "0.1.0",
"version": "0.1.1",
"description": "A MetaMask compatible keyring, for ledger hardware wallets",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,6 +32,7 @@
"hdkey": "0.8.0"
},
"devDependencies": {
"acorn": "^6.0.4",
"assert": "^1.4.1",
"babel-eslint": "^8.0.0",
"babel-runtime": "^6.26.0",
Expand Down

0 comments on commit 8788c83

Please sign in to comment.