Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Fix error format and bump minor version #8

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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