Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Osvaldo Vega
committed
Aug 26, 2019
1 parent
163e418
commit 72705a9
Showing
5 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import manufactures from './manufactures'; | ||
|
||
const isDataValid = (data) => { | ||
console.log('validating data => ', data); | ||
return true; | ||
}; | ||
|
||
const devicesListener = () => manufactures.devicesListener(); | ||
|
||
const getConnectedDevices = () => manufactures.getConnectedDevices(); | ||
|
||
const getDeviceById = ({ name, id }) => manufactures.getDeviceById(name, id); | ||
|
||
const getPublicKey = ({ name, id, data }) => { | ||
if (isDataValid(data)) { | ||
manufactures.getPublicKey({ name, id, data }); | ||
} else { | ||
console.log('DATA INVALID'); | ||
} | ||
}; | ||
|
||
const getAddress = ({ name, id, data }) => { | ||
if (isDataValid(data)) { | ||
manufactures.getAddress({ name, id, data }); | ||
} else { | ||
console.log('DATA INVALID'); | ||
} | ||
}; | ||
|
||
const getAccounts = ({ name, id, data }) => { | ||
if (isDataValid(data)) { | ||
manufactures.getAccounts({ name, id, data }); | ||
} else { | ||
console.log('DATA INVALID'); | ||
} | ||
}; | ||
|
||
const signInTransaction = ({ name, id, data }) => { | ||
if (isDataValid(data)) { | ||
manufactures.signInTransaction({ name, id, data }); | ||
} else { | ||
console.log('DATA INVALID'); | ||
} | ||
}; | ||
|
||
const signInMessage = ({ name, id, data }) => { | ||
if (isDataValid(data)) { | ||
manufactures.signInMessage({ name, id, data }); | ||
} else { | ||
console.log('DATA INVALID'); | ||
} | ||
}; | ||
|
||
const checkStatus = ({ name, id }) => manufactures.signInMessage({ name, id }); | ||
|
||
export default { | ||
checkStatus, | ||
devicesListener, | ||
getAccounts, | ||
getAddress, | ||
getConnectedDevices, | ||
getDeviceById, | ||
getPublicKey, | ||
signInMessage, | ||
signInTransaction, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ledger from './ledger'; | ||
import trezor from './trezor'; | ||
|
||
export default { | ||
ledger, | ||
trezor, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import vendor from './all'; | ||
|
||
const devicesListener = () => { | ||
vendor.ledger.listener(); | ||
vendor.trezor.listener(); | ||
}; | ||
|
||
const getConnectedDevices = () => { | ||
const ledger = vendor.ledger.getConnectedDevices(); | ||
const trezor = vendor.trezor.getConnectedDevices(); | ||
return [...ledger, ...trezor]; | ||
}; | ||
|
||
const getDeviceById = (name, id) => vendor[name].getDeviceById(id); | ||
|
||
const getPublicKey = ({ name, id, data }) => vendor[name].getPublicKey(id, data); | ||
|
||
const getAddress = ({ name, id, data }) => vendor[name].getAddress(id, data); | ||
|
||
const getAccounts = ({ name, id, data }) => vendor[name].getAccounts(id, data); | ||
|
||
const signInTransaction = ({ name, id, data }) => vendor[name].signInTransaction(id, data); | ||
|
||
const signInMessage = ({ name, id, data }) => vendor[name].signInMessage(id, data); | ||
|
||
const checkStatus = ({ name, id }) => vendor[name].checkStatus(id); | ||
|
||
export default { | ||
checkStatus, | ||
devicesListener, | ||
getAccounts, | ||
getAddress, | ||
getConnectedDevices, | ||
getDeviceById, | ||
getPublicKey, | ||
signInMessage, | ||
signInTransaction, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
/** | ||
* DEIVCES | ||
*/ | ||
|
||
const listener = () => { | ||
console.log('Listen for LEDGER connect/disconnect devices'); | ||
}; | ||
|
||
const getConnectedDevices = () => { | ||
console.log('return LEDGER devices list.'); | ||
return []; | ||
}; | ||
|
||
const getDeviceById = (id) => { | ||
console.log('Return LEDGER specific device by id', id); | ||
return ''; | ||
}; | ||
|
||
/** | ||
* COMMANDS | ||
*/ | ||
|
||
const getPublicKey = ({ name, id, data }) => { | ||
console.log('get public key LEDGER', name, id, data); | ||
}; | ||
|
||
const getAddress = ({ name, id, data }) => { | ||
console.log('get address LEDGER', name, id, data); | ||
}; | ||
|
||
const getAccounts = ({ name, id, data }) => { | ||
console.log('get accounts LEDGER', name, id, data); | ||
}; | ||
|
||
const signInTransaction = ({ name, id, data }) => { | ||
console.log('sign in trasaction LEDGER', name, id, data); | ||
}; | ||
|
||
const signInMessage = ({ name, id, data }) => { | ||
console.log('sign in message LEDGER', name, id, data); | ||
}; | ||
|
||
const checkStatus = ({ name, id }) => { | ||
console.log('check status LEDGER', name, id); | ||
}; | ||
|
||
export default { | ||
checkStatus, | ||
listener, | ||
getAccounts, | ||
getAddress, | ||
getConnectedDevices, | ||
getDeviceById, | ||
getPublicKey, | ||
signInMessage, | ||
signInTransaction, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
/** | ||
* DEIVCES | ||
*/ | ||
|
||
const listener = () => { | ||
console.log('Listen for TREZOR connect/disconnect devices'); | ||
}; | ||
|
||
const getConnectedDevices = () => { | ||
console.log('return TREZOR devices list.'); | ||
return []; | ||
}; | ||
|
||
const getDeviceById = (id) => { | ||
console.log('Return TREZOR specific device by id', id); | ||
return ''; | ||
}; | ||
|
||
/** | ||
* COMMANDS | ||
*/ | ||
|
||
const getPublicKey = ({ name, id, data }) => { | ||
console.log('get public key TREZOR', name, id, data); | ||
}; | ||
|
||
const getAddress = ({ name, id, data }) => { | ||
console.log('get address TREZOR', name, id, data); | ||
}; | ||
|
||
const getAccounts = ({ name, id, data }) => { | ||
console.log('get accounts TREZOR', name, id, data); | ||
}; | ||
|
||
const signInTransaction = ({ name, id, data }) => { | ||
console.log('sign in trasaction TREZOR', name, id, data); | ||
}; | ||
|
||
const signInMessage = ({ name, id, data }) => { | ||
console.log('sign in message TREZOR', name, id, data); | ||
}; | ||
|
||
const checkStatus = ({ name, id }) => { | ||
console.log('check status TREZOR', name, id); | ||
}; | ||
|
||
export default { | ||
checkStatus, | ||
listener, | ||
getAccounts, | ||
getAddress, | ||
getConnectedDevices, | ||
getDeviceById, | ||
getPublicKey, | ||
signInMessage, | ||
signInTransaction, | ||
}; |