Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincburns committed Jan 8, 2018
2 parents a77eb2c + 3a1de9b commit 295dd2b
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ out
package-lock.json
node_modules
.DS_Store
.vscode

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Ganache is your personal blockchain for Ethereum development.
<img src="https://github.com/trufflesuite/ganache/blob/new_ui/.github/images/ganache_screenshot.jpg?raw=true"/>
</p>

### Getting started

You can download a self-contained prebuilt Ganache binary for your platform of choice using the "Download" button on the [Ganache](http://truffleframework.com/ganache/) website, or from this repository's [releases](https://github.com/trufflesuite/ganache/releases) page.

### Contributing

Please open issues and pull requests for new features, questions, and bug fixes.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@
"electron-forge-maker-appimage": "^19.30.3",
"electron-settings": "^3.1.2",
"electron-squirrel-startup": "^1.0.0",
"ethereumjs-testrpc": "^6.0.3",
"ethereumjs-units": "^0.2.0",
"find-process": "^1.1.0",
"ganache-cli": "^6.0.3",
"lodash": "^3.10.1",
"moment": "^2.17.1",
"moment-timezone": "^0.5.11",
Expand Down
73 changes: 4 additions & 69 deletions src/Components/AppShell/AppShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import * as AppShellActions from '../../Actions/AppShell'

import TopNavbar from './TopNavbar'
import OnlyIf from '../../Elements/OnlyIf'
import Modal from '../../Elements/Modal'

import BugIcon from '../../Elements/icons/errorant.svg'

import BugModal from './BugModal'
import ua from 'universal-analytics'
import ElectronCookies from '@exponent/electron-cookies'

Expand Down Expand Up @@ -110,81 +107,19 @@ class AppShell extends Component {

render () {
const path = this.props.location.pathname
const segment = path.replace(/^\//g, '').replace(/\//g, '-') || 'root'
let systemError = this.props.core.systemError

if (systemError) {
systemError = systemError.stack || systemError

// Remove any user-specific paths in exception messages
// Prepare our paths so we *always* will get a match no matter
// path separator (oddly, on Windows, different errors will give
// us different path separators)
var appPath = app.getAppPath().replace(/\\/g, "/")
systemError = systemError.replace(/\\/g, "/")

// I couldn't figure out the regex, so a loop will do.
while (systemError.indexOf(appPath) >= 0) {
systemError = systemError.replace(appPath, "")
}
}

return (
<div className="AppShell">
<TopNavbar {...this.props} />

<div className="ShellContainer" ref="shellcontainer">
{this.props.children}
</div>

<OnlyIf test={systemError != null}>
<Modal>
<section className="Bug">
<BugIcon /*size={192}*/ />
<h4>Uh Oh... That's a bug.</h4>
<p>
Ganache encountered an error. Help us fix it by raising a GitHub issue!<br/><br/> Mention the following error information when writing your ticket, and please include as much information as possible. Sorry about that!
</p>
<textarea disabled={true} value={systemError} />
<footer>
<button
onClick={() => {
const title = encodeURIComponent(
`System Error when running Ganache ${app.getVersion()} on ${process.platform}`
)

const body = encodeURIComponent(
`<!-- Please give us as much detail as you can about what you were doing at the time of the error, and any other relevant information -->
PLATFORM: ${process.platform}
GANACHE VERSION: ${app.getVersion()}
EXCEPTION:
${systemError}`
).replace(/%09/g, '')

shell.openExternal(
`https://github.com/trufflesuite/ganache/issues/new?title=${title}&body=${body}`
)
}}
>
Raise Github Issue
</button>
<button
onClick={() => {
app.relaunch()
app.exit()
}}
>
RELAUNCH
</button>
</footer>
</section>
</Modal>
<OnlyIf test={this.props.core.systemError != null}>
<BugModal systemError={this.props.core.systemError} logs={this.props.logs} />
</OnlyIf>
</div>
)
}
}

export default connect(AppShell, "core", "settings")
export default connect(AppShell, "core", "settings", "logs");
15 changes: 0 additions & 15 deletions src/Components/AppShell/AppShell.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
flex-direction: column;
height: 100%;

.Bug {
textarea {
min-height: 5rem; /* Overwrite Modal textarea styles */
max-height: 5rem;
background-color: var(--app-button-primary-disabled-border-color);
width: 100%;
margin-bottom: 1rem;
}

svg {
width: 192px;
height: 192px;
}
}

.ShellContainer {
display: flex;
flex-grow: 1;
Expand Down
118 changes: 118 additions & 0 deletions src/Components/AppShell/BugModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { Component } from 'react'

import connect from '../Helpers/connect'

import Modal from '../../Elements/Modal'

import BugIcon from '../../Elements/icons/errorant.svg'

import { sanitizeError, sanitizePaths } from '../Helpers/sanitize.js'

import { shell } from 'electron'

const { app } = require('electron').remote

class BugModal extends Component {
constructor () {
super()
this.scrollDedupeTimeout = null
}

// grabs the last 500 log lines as a string formatted for inclusion as a github issue
renderAndSanitizeLogLines () {
let result = ''
if (this.props.logs && this.props.logs.lines && this.props.logs.lines.length > 0) {
let maxLines = -175 // negative because Array.slice -- we want the last 175 lines, not the first 175

// GitHub has a max URL length of ~8KiB, so we truncate logs to fit within that
while (encodeURIComponent(result = _getLastNLogLines(maxLines, this.props.logs)).length > 7500) {
maxLines++ // reduces number of lines we get next time
}
}
return sanitizePaths(result)
}

renderIssueBody(sanitizedSystemError, sanitizedLogLines) {
let issueBody =
"<!-- Please give us as much detail as you can about what you were doing at the time of the error, and any other relevant information -->\n" +
"\n" +
"\n" +
`PLATFORM: ${process.platform}\n` +
`GANACHE VERSION: ${app.getVersion()}\n` +
"\n" +
"EXCEPTION:\n" +
"```\n" +
`${sanitizedSystemError}\n` +
"```"

if (sanitizedLogLines) {
issueBody += "\n" +
"\n" +
"APPLICATION LOG:\n" +
"```\n" +
`${sanitizedLogLines}\n` +
"```"
}
return encodeURIComponent(issueBody).replace(/%09/g, '')
}

render () {
let unsanitizedSystemError = this.props.systemError
let sanitizedSystemError = ''
let sanitizedLogLines = ''

if (unsanitizedSystemError) {
sanitizedSystemError = sanitizeError(unsanitizedSystemError)
sanitizedLogLines = this.renderAndSanitizeLogLines()
}

return (
<Modal className="BugModal">
<section className="Bug">
<BugIcon /*size={192}*/ />
<h4>Uh Oh... That's a bug.</h4>
<p>
Ganache encountered an error. Help us fix it by raising a GitHub issue!<br /><br /> Mention the following error information when writing your ticket, and please include as much information as possible. Sorry about that!
</p>
<textarea disabled={true} value={sanitizedSystemError} />
<footer>
<button
onClick={() => {
const title = encodeURIComponent(
`System Error when running Ganache ${app.getVersion()} on ${process.platform}`
)

const body = this.renderIssueBody(sanitizedSystemError, sanitizedLogLines)

shell.openExternal(
`https://github.com/trufflesuite/ganache/issues/new?title=${title}&body=${body}`
)
}}
>
Raise Github Issue
</button>
<button
onClick={() => {
app.relaunch()
app.exit()
}}
>
RELAUNCH
</button>
</footer>
</section>
</Modal>
)
}
}

function _getLastNLogLines(maxLines, logs) {
let firstLogTime = logs.lines[0].time.getTime()
return logs.lines
.slice(maxLines)
.map(v => `T+${v.time.getTime() - firstLogTime}ms: ${v.line}`)
.join('\n')
}


export default connect(BugModal)
18 changes: 18 additions & 0 deletions src/Components/AppShell/BugModal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.Modal {
&.BugModal {
.Bug {
textarea {
min-height: 5rem; /* Overwrite Modal textarea styles */
max-height: 5rem;
background-color: var(--app-button-primary-disabled-border-color);
width: 100%;
margin-bottom: 1rem;
}

svg {
width: 192px;
height: 192px;
}
}
}
}
23 changes: 23 additions & 0 deletions src/Components/Helpers/sanitize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

const { app } = require('electron').remote

// return a sanitized error string from an Error object or string which contains an error message
export function sanitizeError(errorUnsanitized) {
return sanitizePaths(errorUnsanitized.stack || errorUnsanitized)
}

// Remove any user-specific paths in exception messages
export function sanitizePaths (message) {
// Prepare our paths so we *always* will get a match no matter
// path separator (oddly, on Windows, different errors will give
// us different path separators)
var appPath = app.getAppPath().replace(/\\/g, "/")

// I couldn't figure out the regex, so a loop will do.
while (message.indexOf(appPath) >= 0) {
message = message.replace(appPath, "")
}

return message
}

4 changes: 2 additions & 2 deletions src/chain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
var TestRPC = require("ethereumjs-testrpc")
var ganacheLib = require("ganache-cli")
var path = require("path")
var Web3 = require("web3")

Expand Down Expand Up @@ -41,7 +41,7 @@ function startServer(options) {
}
}

server = TestRPC.server(options);
server = ganacheLib.server(options);

// We'll also log all methods that aren't marked internal by Ganache
var oldSendAsync = server.provider.sendAsync.bind(server.provider)
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const stylesheets = [
"./Components/FirstRun/FirstRunScreen.scss",
"./Components/AppShell/AppShell.scss",
"./Components/AppShell/TopNavbar.scss",
"./Components/AppShell/BugModal.scss",
"./Components/Accounts/AccountsScreen.scss",
"./Components/Accounts/AccountList.scss",
"./Components/Accounts/KeyModal.scss",
Expand Down

0 comments on commit 295dd2b

Please sign in to comment.