Merge pull request #935 from gnosis/fix/trezor-support

Add Trezor support
This commit is contained in:
Mati Dastugue 2020-05-28 12:23:13 -03:00 committed by GitHub
commit 7a20aaac42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 9 deletions

View File

@ -46,18 +46,16 @@ function getOpenedWindow(url,options) {
options.webPreferences.affinity = 'main-window';
if(url.includes('about:blank')){
/*
if(url.includes('trezor')){
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
details.requestHeaders['Origin'] = 'https://electron.trezor.io';
details.requestHeaders['Origin'] = 'https://connect.trezor.io';
callback({cancel: false, requestHeaders: details.requestHeaders});
});
*/
}
if(url.includes('wallet.portis') || url.includes('about:blank') || url.includes('app.tor.us')){
if(url.includes('wallet.portis') || url.includes('trezor') || url.includes('app.tor.us')){
const win = new BrowserWindow({
width:300,
width:350,
height:700,
x: width - 1300,
parent:mainWindow,
@ -66,7 +64,10 @@ function getOpenedWindow(url,options) {
fullscreen: false,
show: false,
});
win.webContents.on('new-window', function(event, url){
if(url.includes('trezor') && url.includes('bridge'))
open(url);
});
win.once('ready-to-show', () => win.show());
if(!options.webPreferences){

37
scripts/preload.js Normal file
View File

@ -0,0 +1,37 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const TransportNodeHid = require("@ledgerhq/hw-transport-node-hid").default;
const log = require('electron-log');
const isDev = require("electron-is-dev");
window.TransportNodeHid = TransportNodeHid;
window.isDesktop = true;
window.addEventListener('DOMContentLoaded', () => {
const origLog = console.log
const origError = console.error
const origWarn = console.warn
if(!isDev){
console.error = (...args) => {
origError(...args)
log.error(...args)
}
console.warn = (...args) => {
origWarn(...args)
log.warn(...args)
}
console.log = (...args) => {
origLog(...args)
log.info(...args)
}
}
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})

View File

@ -22,7 +22,7 @@ const wallets = [
appUrl: 'gnosis-safe.io',
preferred: true,
email: 'safe@gnosis.io',
desktop: false,
desktop: true,
rpcUrl: infuraUrl,
},
{

View File

@ -5,7 +5,6 @@ import { useSelector } from 'react-redux'
import Page from 'src/components/layout/Page'
import Layout from 'src/routes/safe/components/Layout'
import { safeParamAddressFromStateSelector } from 'src/routes/safe/store/selectors'
import { useLoadSafe } from './hooks/useLoadSafe'
import { useCheckForUpdates } from './hooks/useCheckForUpdates'