aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno <brunobar79@gmail.com>2018-06-11 06:48:42 +0800
committerBruno <brunobar79@gmail.com>2018-06-11 06:48:42 +0800
commitf5f66f59d7d215adf402a1e580c452e634480f69 (patch)
tree09390fa9c2595eda1b4a97424da3dea41a52a049
parent8c4d58aa4508e3d54c3f69847347e78d09c63b97 (diff)
downloadtangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar.gz
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar.bz2
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar.lz
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar.xz
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.tar.zst
tangerine-wallet-browser-f5f66f59d7d215adf402a1e580c452e634480f69.zip
clean up
-rw-r--r--app/scripts/lib/trezorKeyring.js16
-rw-r--r--app/scripts/metamask-controller.js7
2 files changed, 15 insertions, 8 deletions
diff --git a/app/scripts/lib/trezorKeyring.js b/app/scripts/lib/trezorKeyring.js
index d99f384f2..83787f3d2 100644
--- a/app/scripts/lib/trezorKeyring.js
+++ b/app/scripts/lib/trezorKeyring.js
@@ -1,10 +1,9 @@
const { EventEmitter } = require('events')
const ethUtil = require('ethereumjs-util')
// const sigUtil = require('eth-sig-util')
-//const { Lock } = require('semaphore-async-await')
const hdPathString = `m/44'/60'/0'/0`
-const keyringType = 'Trezor Hardware Keyring'
+const keyringType = 'Trezor Hardware'
const TrezorConnect = require('./trezor-connect.js')
const HDKey = require('hdkey')
@@ -15,7 +14,6 @@ class TrezorKeyring extends EventEmitter {
constructor (opts = {}) {
super()
this.type = keyringType
- //this.lock = new Lock()
this.accounts = []
this.hdk = new HDKey()
this.deserialize(opts)
@@ -24,16 +22,22 @@ class TrezorKeyring extends EventEmitter {
}
serialize () {
- return Promise.resolve({ hdPath: this.hdPath, accounts: this.accounts })
+ return Promise.resolve({
+ hdPath: this.hdPath,
+ accounts: this.accounts,
+ page: this.page,
+ })
}
deserialize (opts = {}) {
this.hdPath = opts.hdPath || hdPathString
this.accounts = opts.accounts || []
+ this.page = opts.page || 0
return Promise.resolve()
}
unlock () {
+
if (this.hdk.publicKey) return Promise.resolve()
return new Promise((resolve, reject) => {
@@ -56,6 +60,7 @@ class TrezorKeyring extends EventEmitter {
}
addAccounts (n = 1) {
+
return new Promise((resolve, reject) => {
return this.unlock()
.then(_ => {
@@ -82,6 +87,7 @@ class TrezorKeyring extends EventEmitter {
}
async getPage () {
+
return new Promise((resolve, reject) => {
return this.unlock()
.then(_ => {
@@ -252,4 +258,4 @@ class TrezorKeyring extends EventEmitter {
}
TrezorKeyring.type = keyringType
-module.exports = TrezorKeyring \ No newline at end of file
+module.exports = TrezorKeyring
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index dd5a5616f..081c2e2db 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -48,7 +48,7 @@ const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
const cleanErrorStack = require('./lib/cleanErrorStack')
const DiagnosticsReporter = require('./lib/diagnostics-reporter')
const log = require('loglevel')
-const TrezorKeyring = require("./lib/trezorKeyring");
+const TrezorKeyring = require('./lib/trezorKeyring')
module.exports = class MetamaskController extends EventEmitter {
@@ -540,9 +540,10 @@ module.exports = class MetamaskController extends EventEmitter {
* @returns [] accounts
*/
async connectHardware (deviceName, page) {
+
const keyringController = this.keyringController
const keyring = await keyringController.getKeyringsByType(
- 'Trezor Hardware Keyring'
+ 'Trezor Hardware'
)[0]
if (!keyring) {
throw new Error('MetamaskController - No Trezor Hardware Keyring found')
@@ -562,7 +563,7 @@ module.exports = class MetamaskController extends EventEmitter {
async unlockTrezorAccount (index) {
const keyringController = this.keyringController
const keyring = await keyringController.getKeyringsByType(
- 'Trezor Hardware Keyring'
+ 'Trezor Hardware'
)[0]
if (!keyring) {
throw new Error('MetamaskController - No Trezor Hardware Keyring found')