Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Develop into master (#2804)
Browse files Browse the repository at this point in the history
* improve 'METHOD_DENIED' error message (#2127)

* improve 'METHOD_DENIED' error message

* fix

* upstream fixes

* Swarm additions (#2764)

* fixes batch requests on isolated preloaders

* added 404 page for not found swarm content

* fixed coide climate issues

* show custom 404 error only for bzz://

* Error page fixes and build errors (#2780)

* fixes batch requests on isolated preloaders

* added 404 page for not found swarm content

* fixed coide climate issues

* show custom 404 error only for bzz://

* fixed borwser.js issue and sound and error pages

* trigger travis

* trigger travis

* adding globals to ESLint whitelist

* Small refactor; Fixing 3/4 tests

* Adjusting spectron version

* ESLint

* [Spectron] New fixture server; Fixes 4/4 test.

* Wallet shouldn't start Swarm

* Wallet shouldn't start Swarm

* Adding exception to eslint

* Fix wallet preloader issue

* Mac release path (#2808)

* Adding gitter channel info (#2807)

* Add bzz and .eth to urls (#2792)

* add .eth

* refactor ifs

* solve for wallet.ethereum.org

* Fixing delay problem
  • Loading branch information
evertonfraga authored and frozeman committed Jul 24, 2017
1 parent 147a87b commit 16a9e07
Show file tree
Hide file tree
Showing 20 changed files with 173 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ globals: # don't warn about missing declarations
_: true
window: true
location: true

document: true
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Please note that this repository is the Electron host for the Meteor based walle

## Help and troubleshooting

Please check the [Mist troubleshooting guide](https://github.com/ethereum/mist/wiki) for help.
Please check the [Mist troubleshooting guide](https://github.com/ethereum/mist/wiki).

Or the [Gitter Channel](https://gitter.im/ethereum/mist), to connect with the community for instant help.

## Installation

Expand Down
4 changes: 3 additions & 1 deletion gulpTasks/building.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ gulp.task('copy-app-source-files', () => {
'!./tests/wallet/*',
`./icons/${type}/*`,
'./sounds/*',
'./errorPages/*',
'customProtocols.js'
], {
base: './'
Expand Down Expand Up @@ -214,7 +215,8 @@ gulp.task('release-dist', (done) => {
break;
case 'mac':
cp(
`${applicationName}-${version}.dmg`, `${appNameHypen}-macosx-${versionDashed}.dmg`);
path.join('mac', `${applicationName}-${version}.dmg`),
`${appNameHypen}-macosx-${versionDashed}.dmg`);
break;
case 'linux':
cp(
Expand Down
2 changes: 2 additions & 0 deletions gulpTasks/publishing.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ gulp.task('upload-binaries', (cb) => {
// personal access token (public_repo) must be set using travis' ENVs
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

console.info('Checking Github releases...');

// query github releases
got(`https://api.github.com/repos/ethereum/mist/releases?access_token=${GITHUB_TOKEN}`, { json: true })
// filter draft with current version's tag
Expand Down
12 changes: 10 additions & 2 deletions interface/client/lib/helpers/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ Format Urls, e.g add a default protocol if on is missing.
@param {String} url
**/
Helpers.formatUrl = function (url) {
if (!url) return;

// add http:// if no protocol is present
if (url && url.length === 64 && !!url.match(/^[0-9a-f]+$/)) {
if (url.length === 64 && !!url.match(/^[0-9a-f]+$/)) {
// if the url looks like a hash, add bzz
url = 'bzz://' + url;
} else if (url && url.indexOf('://') === -1) {
} else if (!!url.match(/^([a-z]*:\/\/)?[^/]*\.eth(\/.*)?$/i)) {
// if uses .eth as a TLD
url = 'bzz://' + url.replace(/^([a-z]*:\/\/)?/i, '');
} else if (!!url.match(/^[^\.\/]*$/i)) {
// doesn't have a protocol nor a TLD
url = 'bzz://' + url + '.eth';
} else if (url.indexOf('://') === -1) {
// if it doesn't have a protocol
url = 'http://' + url;
}
Expand Down
3 changes: 1 addition & 2 deletions interface/client/mistAPIBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ mistAPIBackend = function (event) {
appBar: (_.contains(allowedBrowserBarStyles, appBarClass) ? appBarClass : null)
}});
}

if (event.channel === 'mistAPI_sound') {
sound.pause();
sound.src = Blaze._escape(arg);
sound.src = Blaze._escape('file://'+ dirname +'/sounds/' + arg + '.mp3');
sound.play();
}

Expand Down
15 changes: 15 additions & 0 deletions interface/client/templates/views/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ Template['views_webview'].onRendered(function () {
webview.addEventListener('did-fail-load', showError.bind(webview, tabId));
webview.addEventListener('crashed', showError.bind(webview, tabId));

// Forward SWARM status code errors to showError
webview.addEventListener('did-get-response-details', function (e) {
if (e && e.resourceType === 'mainFrame' && /^bzz:\//i.test(e.newURL)) {
switch (e.httpResponseCode) {
case 500:
showError.call(webview, tabId, {
isMainFrame: true,
errorCode: 404
});
break;
}
}
});


// navigate page, and redirect to browser tab if necessary
webview.addEventListener('will-navigate', webviewLoadStart.bind(webview, tabId));
webview.addEventListener('did-get-redirect-request', webviewLoadStart.bind(webview, tabId));
Expand Down
5 changes: 4 additions & 1 deletion interface/client/templates/webviewEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ showError = function (tabId, e) {
case -105:
url = path + '404.html';
break;
case 404:
url = path + '404.html';
break;
case 500:
url = path + '500.html';
break;
Expand Down Expand Up @@ -41,7 +44,7 @@ webviewChangeUrl = function (tabId, e) {
}

// make sure to not store error pages in history
if (!url || url.indexOf('mist/errorPages/') !== -1) {
if (!url || url.indexOf('mist/errorPages/') !== -1 || url.indexOf('app.asar/errorPages/') !== -1) {
return;
}

Expand Down
5 changes: 3 additions & 2 deletions interface/i18n/mist.en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@
},
"help": {
"label": "Help",
"reportBug": "Report an issue on Github",
"mistWiki": "Troubleshooting and Help"
"mistWiki": "Troubleshooting and Help",
"gitter": "Mist channel on Gitter",
"reportBug": "Report an issue on Github"
}
},
"errors": {
Expand Down
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ onReady = () => {
return ethereumNode.init();
})
.then(() => {
// Wallet shouldn't start Swarm
if (Settings.uiMode === 'wallet') {
return Promise.resolve();
}
return swarmNode.init();
})
.then(function sanityCheck() {
Expand Down
7 changes: 3 additions & 4 deletions modules/ipc/ipcProviderBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ const log = require('../utils/logger').create('ipcProviderBackend');
const Sockets = require('../socketManager');
const Settings = require('../settings');
const ethereumNode = require('../ethereumNode');
const Windows = require('../windows');


const ERRORS = {
INVALID_PAYLOAD: { code: -32600, message: 'Payload, or some of its content properties are invalid. Please check if they are valid HEX with 0x prefix.' },
METHOD_DENIED: { code: -32601, message: "Method \'__method__\' not allowed." },
METHOD_TIMEOUT: { code: -32603, message: "Request timed out for method \'__method__\'." },
INVALID_PAYLOAD: { code: -32600, message: "Payload, or some of its content properties are invalid. Please check if they are valid HEX with '0x' prefix." },
METHOD_DENIED: { code: -32601, message: 'Method __method__ not allowed.' },
METHOD_TIMEOUT: { code: -32603, message: 'Request timed out for method __method__.' },
TX_DENIED: { code: -32603, message: 'Transaction denied' },
BATCH_TX_DENIED: { code: -32603, message: 'Transactions denied, sendTransaction is not allowed in batch requests.' },
BATCH_COMPILE_DENIED: { code: -32603, message: 'Compilation denied, compileSolidity is not allowed in batch requests.' },
Expand Down
8 changes: 4 additions & 4 deletions modules/ipc/methods/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ module.exports = class BaseProcessor {
}

// prevent dapps from acccesing admin endpoints
if (!/^eth_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
if (!/^eth_|^bzz_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
delete payload.result;

payload.error = this.ERRORS.METHOD_DENIED;
const err = _.clone(this.ERRORS.METHOD_DENIED);
err.message = err.message.replace('__method__', `"${payload.method}"`);
payload.error = err;
}
}
};

16 changes: 11 additions & 5 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,13 @@ let menuTempl = function (webviews) {
}});
LocalStore.set('selectedTab', 'browser');
`);
console.log('Hash uploaded:', hash);
}).catch(e => console.log(e));
}
}
}]
});

// EDIT
menu.push({
label: i18n.t('mist.applicationMenu.edit.label'),
Expand Down Expand Up @@ -624,14 +625,19 @@ let menuTempl = function (webviews) {
);
}
helpMenu.push({
label: i18n.t('mist.applicationMenu.help.reportBug'),
label: i18n.t('mist.applicationMenu.help.mistWiki'),
click() {
shell.openExternal('https://github.com/ethereum/mist/issues');
shell.openExternal('https://github.com/ethereum/mist/wiki');
},
}, {
label: i18n.t('mist.applicationMenu.help.mistWiki'),
label: i18n.t('mist.applicationMenu.help.gitter'),
click() {
shell.openExternal('https://github.com/ethereum/mist/wiki');
shell.openExternal('https://gitter.com/ethereum/mist');
},
}, {
label: i18n.t('mist.applicationMenu.help.reportBug'),
click() {
shell.openExternal('https://github.com/ethereum/mist/issues');
},
});

Expand Down
8 changes: 4 additions & 4 deletions modules/preloader/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ const postMessage = function (payload) {


// load ethereumProvider
const bignumber = fs.readFileSync(path.resolve('./modules/preloader/injected/BigNumber.js')).toString();
const eventEmitter3 = fs.readFileSync(path.resolve('./modules/preloader/injected/EventEmitter3.js')).toString();
let mistAPI = fs.readFileSync(path.resolve('./modules/preloader/injected/mistAPI.js')).toString();
const ethereumProvider = fs.readFileSync(path.resolve('./modules/preloader/injected/EthereumProvider.js')).toString();
const bignumber = fs.readFileSync(path.join(__dirname, '/injected/BigNumber.js')).toString();
const eventEmitter3 = fs.readFileSync(path.join(__dirname, '/injected/EventEmitter3.js')).toString();
let mistAPI = fs.readFileSync(path.join(__dirname, '/injected/mistAPI.js')).toString();
const ethereumProvider = fs.readFileSync(path.join(__dirname, '/injected/EthereumProvider.js')).toString();

mistAPI = mistAPI.replace('__version__', packageJson.version)
.replace('__license__', packageJson.license)
Expand Down
6 changes: 3 additions & 3 deletions modules/preloader/injected/mistAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@
bip: function playSound() {
postMessage({
type: 'mistAPI_sound',
message: 'file://'+ __dirname +'/../../../sounds/bip.mp3'
message: 'bip'
});
},
bloop: function playSound() {
postMessage({
type: 'mistAPI_sound',
message: 'file://'+ __dirname +'/../../../sounds/bloop.mp3'
message: 'bloop'
});
},
invite: function playSound() {
postMessage({
type: 'mistAPI_sound',
message: 'file://'+ __dirname +'/../../../sounds/invite.mp3'
message: 'invite'
});
},
},
Expand Down
3 changes: 2 additions & 1 deletion modules/preloader/walletMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
require('./dapps.js');
require('./include/openExternal.js');
require('./include/setBasePath')('interface/wallet');

const {webFrame} = require('electron');
const web3Admin = require('../web3Admin.js');

// make variables globally accessable
// window.dirname = __dirname;

webFrame.executeJavaScript("window.mistMode = 'wallet';");


// add admin later
setTimeout(() => {
web3Admin.extend(window.web3);
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"co-mocha": "^1.2.0",
"del": "^2.2.2",
"ecstatic": "^2.1.0",
Expand All @@ -52,22 +51,20 @@
"eslint": "^3.14.1",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
"express": "^4.15.3",
"genomatic": "^1.0.0",
"geth-private": "^1.3.0",
"gh-release-assets": "^1.1.0",
"gulp": "^3.9.0",
"gulp-spawn-mocha": "^3.3.0",
"istanbul": "^0.4.5",
"json-structure-diff": "^0.0.2",
"merge-stream": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.2.0",
"optimist": "^0.6.1",
"require-dir": "^0.3.2",
"run-sequence": "^1.2.1",
"semver-compare": "^1.0.0",
"shelljs": "^0.7.7",
"spectron": "3.6.0",
"spectron": "3.4.1",
"xml2js": "^0.4.17"
}
}
4 changes: 4 additions & 0 deletions tests/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ globals: # don't warn about missing declarations
it: true
expect: true
chai: true
$: true
LastVisitedPages: true
History: true
localStorage: true
Loading

0 comments on commit 16a9e07

Please sign in to comment.