Skip to content

Commit

Permalink
mac ledger fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan James committed Sep 15, 2018
1 parent aa4676d commit a179a95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/models/hardware/LedgerWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const LEDGER_PATHS = {
[Blockchains.EOSIO]:"44'/194'/0'/0/0",
}

const cache = {};

export default class LedgerWallet {

constructor(blockchain){
Expand All @@ -34,7 +36,8 @@ export default class LedgerWallet {
}

static typeToInterface(blockchain){
return new LedgerWallet(blockchain);
if(!cache.hasOwnProperty(blockchain)) cache[blockchain] = new LedgerWallet(blockchain);
return cache[blockchain];
};

async init(){
Expand All @@ -54,6 +57,7 @@ export default class LedgerWallet {
if(store.state.hardware.subscriber)
await store.state.hardware.subscriber.unsubscribe();
store.dispatch(Actions.SET_HARDWARE, null);
delete cache[this.blockchain];
}
}
store.dispatch(Actions.SET_HARDWARE, hardware);
Expand All @@ -68,9 +72,10 @@ export default class LedgerWallet {
async add(device){
const {path} = device;

const clone = Object.assign(store.state.hardware, {transport: await Transport.open(path)});
const clone = Object.assign(store.state.hardware, {transport:await Transport.open(path)});
store.dispatch(Actions.SET_HARDWARE, clone);


this.api = new LedgerAPI(store.state.hardware.transport, this.blockchain);
this.getPublicKey = this.api.getPublicKey;
this.sign = this.api.signTransaction;
Expand Down Expand Up @@ -235,6 +240,7 @@ class LedgerAPI {
'exclamation-triangle',
'Okay'
));
delete cache[this.blockchain];
return false;
})
}
Expand Down

0 comments on commit a179a95

Please sign in to comment.