Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
fether
Commits
4ee1b308
Commit
4ee1b308
authored
Jun 28, 2018
by
Amaury Martiny
Browse files
Fix small bugs
parent
aa866a9d
Changes
14
Hide whitespace changes
Inline
Side-by-side
packages/fether-electron/package.json
View file @
4ee1b308
...
...
@@ -41,19 +41,11 @@
},
"dependencies"
:
{
"@parity/electron"
:
"^0.1.0"
,
"async-retry"
:
"^1.2.1"
,
"axios"
:
"^0.18.0"
,
"checksum"
:
"^0.1.1"
,
"command-exists"
:
"^1.2.6"
,
"commander"
:
"^2.15.1"
,
"debug"
:
"^3.1.0"
,
"electron-dl"
:
"^1.11.0"
,
"fether-react"
:
"^0.1.0"
,
"menubar"
:
"^5.2.3"
,
"pino"
:
"^4.16.1"
,
"pino-debug"
:
"^1.1.1"
,
"pino-multi-stream"
:
"^3.1.2"
,
"promise-any"
:
"^0.2.0"
,
"source-map-support"
:
"^0.5.6"
},
"devDependencies"
:
{
...
...
packages/fether-electron/src/main/index.js
View file @
4ee1b308
...
...
@@ -18,12 +18,13 @@ import cli from './cli';
import
handleError
from
'
./utils/handleError
'
;
import
messages
from
'
./messages
'
;
import
{
parity
}
from
'
../../package.json
'
;
import
p
ino
from
'
./utils/pino
'
;
import
P
ino
from
'
./utils/pino
'
;
import
{
productName
}
from
'
../../electron-builder.json
'
;
import
staticPath
from
'
./utils/staticPath
'
;
const
{
app
,
BrowserWindow
,
ipcMain
,
session
}
=
electron
;
let
mainWindow
;
const
pino
=
Pino
();
function
createWindow
()
{
pino
.
info
(
`Starting
${
productName
}
...`
);
...
...
packages/fether-electron/src/main/utils/handleError.js
View file @
4ee1b308
...
...
@@ -6,9 +6,10 @@
import
{
app
,
dialog
,
shell
}
from
'
electron
'
;
import
{
bugs
,
name
,
parity
}
from
'
../../../package.json
'
;
import
p
ino
from
'
./pino
'
;
import
P
ino
from
'
./pino
'
;
const
logFile
=
`
${
app
.
getPath
(
'
userData
'
)}
/
${
name
}
.log`
;
const
pino
=
Pino
();
export
default
(
err
,
message
=
'
An error occurred.
'
)
=>
{
pino
.
error
(
err
);
...
...
packages/fether-electron/src/main/utils/pino.js
View file @
4ee1b308
...
...
@@ -4,11 +4,9 @@
// SPDX-License-Identifier: BSD-3-Clause
import
{
app
}
from
'
electron
'
;
import
debug
from
'
debug
'
;
import
fs
from
'
fs
'
;
import
{
multistream
}
from
'
pino-multi-stream
'
;
import
Pino
from
'
pino
'
;
import
pinoDebug
from
'
pino-debug
'
;
import
{
name
}
from
'
../../../package.json
'
;
...
...
@@ -34,15 +32,4 @@ const streams = [
{
level
:
'
info
'
,
stream
:
pretty
}
];
const
pino
=
Pino
({
name
},
multistream
(
streams
));
// @parity/electron's debug logs are in namespace "@parity/log", we enable
// them by default.
debug
.
enable
(
'
@parity/electron
'
);
pinoDebug
(
pino
,
{
map
:
{
'
@parity/electron
'
:
'
debug
'
}
});
export
default
pino
;
export
default
opts
=>
Pino
({
name
,
...
opts
},
multistream
(
streams
));
packages/fether-react/src/Accounts/AccountsList/AccountsList.js
View file @
4ee1b308
...
...
@@ -9,6 +9,7 @@ import { accountsInfo$, defaultAccount$ } from '@parity/light.js';
import
{
inject
,
observer
}
from
'
mobx-react
'
;
import
light
from
'
light-hoc
'
;
import
debug
from
'
../../utils/debug
'
;
import
Health
from
'
../../Health
'
;
@
light
({
...
...
@@ -52,7 +53,7 @@ class AccountsList extends Component {
history
.
push
(
'
/tokens
'
,
{
address
});
})
.
catch
(
err
=>
console
.
error
(
`Error while selecting account,
${
err
.
message
}
.`
)
debug
(
'
AccountsList
'
)
(
`Error while selecting account,
${
err
.
message
}
.`
)
);
};
...
...
packages/parity-electron/package.json
View file @
4ee1b308
...
...
@@ -36,25 +36,14 @@
"axios"
:
"^0.18.0"
,
"checksum"
:
"^0.1.1"
,
"command-exists"
:
"^1.2.6"
,
"commander"
:
"^2.15.1"
,
"debug"
:
"^3.1.0"
,
"electron-dl"
:
"^1.11.0"
,
"fether-react"
:
"^0.1.0"
,
"menubar"
:
"^5.2.3"
,
"pino"
:
"^4.16.1"
,
"pino-multi-stream"
:
"^3.1.2"
,
"promise-any"
:
"^0.2.0"
,
"source-map-support"
:
"^0.5.6"
"promise-any"
:
"^0.2.0"
},
"devDependencies"
:
{
"@babel/plugin-transform-runtime"
:
"^7.0.0-beta.51"
,
"babel-eslint"
:
"^8.2.3"
,
"copyfiles"
:
"^2.0.0"
,
"cross-env"
:
"^5.2.0"
,
"electron"
:
"^2.0.2"
,
"electron-builder"
:
"^20.15.1"
,
"electron-webpack"
:
"^2.1.2"
,
"semistandard"
:
"^12.0.1"
,
"webpack"
:
"^4.7.0"
}
"semistandard"
:
"^12.0.1"
},
"peerDependencies"
:
{}
}
packages/parity-electron/src/fetchParity.js
View file @
4ee1b308
...
...
@@ -6,18 +6,16 @@
import
{
app
}
from
'
electron
'
;
import
axios
from
'
axios
'
;
import
cs
from
'
checksum
'
;
import
debug
from
'
debug
'
;
import
{
download
}
from
'
electron-dl
'
;
import
fs
from
'
fs
'
;
import
{
promisify
}
from
'
util
'
;
import
retry
from
'
async-retry
'
;
import
debug
from
'
./utils/debug
'
;
import
{
defaultParityPath
,
getParityPath
}
from
'
./getParityPath
'
;
import
{
name
}
from
'
../package.json
'
;
import
parityChannel
from
'
./utils/parityChannel
'
;
const
checksum
=
promisify
(
cs
.
file
);
const
logger
=
debug
(
`
${
name
}
:main`
);
const
fsChmod
=
promisify
(
fs
.
chmod
);
const
fsStat
=
promisify
(
fs
.
stat
);
const
fsUnlink
=
promisify
(
fs
.
unlink
);
...
...
@@ -72,12 +70,15 @@ export const fetchParity = (mainWindow, onProgress) => {
return
retry
(
async
(
_
,
attempt
)
=>
{
if
(
attempt
>
1
)
{
logger
(
'
Retrying.
'
);
debug
(
'
main
'
)
(
'
Retrying.
'
);
}
// Delete any old Parity if it exists
await
deleteParity
();
// Fetch the metadata of the correct version of parity
const
metadataUrl
=
`
${
VANITY_URL
}
?version=
${
parityChannel
}
&os=
${
getOs
()}
&architecture=
${
getArch
()}
`
;
logger
(
`Downloading from
${
metadataUrl
}
.`
);
const
metadataUrl
=
`
${
VANITY_URL
}
?version=
${
parityChannel
()
}
&os=
${
getOs
()}
&architecture=
${
getArch
()}
`
;
debug
(
'
main
'
)
(
`Downloading from
${
metadataUrl
}
.`
);
const
{
data
}
=
await
axios
.
get
(
metadataUrl
);
// Get the binary's url
...
...
@@ -112,14 +113,6 @@ export const fetchParity = (mainWindow, onProgress) => {
return
parityPath
;
},
{
onRetry
:
async
err
=>
{
debug
(
err
);
// Everytime we retry, we remove the parity file we just downloaded.
// This needs to be done syncly normally, since onRetry is sync
// https://github.com/zeit/async-retry/issues/43
return
deleteParity
();
},
retries
:
3
}
);
...
...
packages/parity-electron/src/getParityPath.js
View file @
4ee1b308
...
...
@@ -5,14 +5,12 @@
import
{
app
}
from
'
electron
'
;
import
commandExists
from
'
command-exists
'
;
import
debug
from
'
debug
'
;
import
fs
from
'
fs
'
;
import
promiseAny
from
'
promise-any
'
;
import
{
promisify
}
from
'
util
'
;
import
{
name
}
from
'
../package.json
'
;
import
debug
from
'
./utils/debug
'
;
const
logger
=
debug
(
`
${
name
}
:main`
);
const
fsStat
=
promisify
(
fs
.
stat
);
// The default path to install parity, in case there's no other instance found
...
...
@@ -98,10 +96,10 @@ export const getParityPath = async () => {
try
{
const
path
=
await
doesParityExist
();
parityPath
=
path
;
// Save the final result in module variable
logger
(
`Parity found on machine, can be run with "
${
path
}
".`
);
debug
(
'
main
'
)
(
`Parity found on machine, can be run with "
${
path
}
".`
);
return
path
;
}
catch
(
err
)
{
logger
(
`Parity not found on machine.`
);
debug
(
'
main
'
)
(
`Parity not found on machine.`
);
throw
err
;
}
};
packages/parity-electron/src/isParityRunning.js
View file @
4ee1b308
...
...
@@ -4,13 +4,10 @@
// SPDX-License-Identifier: BSD-3-Clause
import
axios
from
'
axios
'
;
import
debug
from
'
debug
'
;
import
retry
from
'
async-retry
'
;
import
{
cli
}
from
'
./utils/cli
'
;
import
{
name
}
from
'
../package.json
'
;
const
logger
=
debug
(
`
${
name
}
:main`
);
import
debug
from
'
./utils/debug
'
;
// Try to ping these hosts
const
hostsToPing
=
[
'
http://127.0.0.1:8545
'
,
'
http://127.0.0.1:8546
'
];
...
...
@@ -34,7 +31,7 @@ export const isParityRunning = async () => {
async
(
_
,
attempt
)
=>
{
const
host
=
hostsToPing
[
attempt
-
1
];
// Attempt starts with 1
await
axios
.
get
(
host
);
logger
(
debug
(
'
main
'
)
(
`Another instance of parity is already running on
${
host
}
, skip running local instance.`
);
},
...
...
packages/parity-electron/src/runParity.js
View file @
4ee1b308
...
...
@@ -4,18 +4,15 @@
// SPDX-License-Identifier: BSD-3-Clause
import
{
app
}
from
'
electron
'
;
import
debug
from
'
debug
'
;
import
fs
from
'
fs
'
;
import
{
spawn
}
from
'
child_process
'
;
import
{
promisify
}
from
'
util
'
;
import
{
cli
,
parityArgv
}
from
'
./utils/cli
'
;
import
debug
from
'
./utils/debug
'
;
import
{
getParityPath
}
from
'
./getParityPath
'
;
import
{
isParityRunning
}
from
'
./isParityRunning
'
;
import
logCommand
from
'
./utils/logCommand
'
;
import
{
name
}
from
'
../package.json
'
;
const
logger
=
debug
(
`
${
name
}
:main`
);
const
fsChmod
=
promisify
(
fs
.
chmod
);
...
...
@@ -55,14 +52,14 @@ export const runParity = async onParityError => {
// Run an instance of parity with the correct args
const
args
=
[...
parityArgv
(),
'
--light
'
];
parity
=
spawn
(
parityPath
,
args
);
logger
(
logCommand
(
parityPath
,
args
));
debug
(
'
main
'
)
(
logCommand
(
parityPath
,
args
));
// Save in memory the last line of the log file, for handling error
const
callback
=
data
=>
{
if
(
data
&&
data
.
length
)
{
logLastLine
=
data
.
toString
();
}
debug
(
`
${
name
}
:
parity
`
)(
data
.
toString
());
debug
(
'
parity
'
)(
data
.
toString
());
};
parity
.
stdout
.
on
(
'
data
'
,
callback
);
parity
.
stderr
.
on
(
'
data
'
,
callback
);
...
...
@@ -83,7 +80,9 @@ export const runParity = async onParityError => {
logLastLine
&&
catchableErrors
.
some
(
error
=>
logLastLine
.
includes
(
error
))
)
{
logger
(
'
Another instance of parity is running, closing local instance.
'
);
debug
(
'
main
'
)(
'
Another instance of parity is running, closing local instance.
'
);
return
;
}
...
...
packages/parity-electron/src/signerNewToken.js
View file @
4ee1b308
...
...
@@ -3,27 +3,24 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import
debug
from
'
debug
'
;
import
{
spawn
}
from
'
child_process
'
;
import
debug
from
'
./utils/debug
'
;
import
{
getParityPath
}
from
'
./getParityPath
'
;
import
logCommand
from
'
./utils/logCommand
'
;
import
{
name
}
from
'
../package.json
'
;
const
logger
=
debug
(
`
${
name
}
:main`
);
/**
* Launch a parity instance to get a secure token.
*/
export
const
signerNewToken
=
()
=>
new
Promise
(
async
(
resolve
,
reject
)
=>
{
logger
(
'
Requesting new token.
'
);
debug
(
'
main
'
)
(
'
Requesting new token.
'
);
const
parityPath
=
await
getParityPath
();
// Generate a new token
const
paritySigner
=
spawn
(
parityPath
,
[
'
signer
'
,
'
new-token
'
]);
logger
(
logCommand
(
parityPath
,
[
'
signer
'
,
'
new-token
'
]));
debug
(
'
main
'
)
(
logCommand
(
parityPath
,
[
'
signer
'
,
'
new-token
'
]));
// Listen to the output of the previous command
paritySigner
.
stdout
.
on
(
'
data
'
,
data
=>
{
...
...
@@ -37,7 +34,7 @@ export const signerNewToken = () =>
if
(
match
)
{
const
token
=
match
[
0
];
paritySigner
.
kill
();
// We don't need the signer anymore
logger
(
'
Successfully extracted token.
'
);
debug
(
'
main
'
)
(
'
Successfully extracted token.
'
);
resolve
(
token
);
}
});
...
...
packages/parity-electron/src/utils/debug.js
0 → 100644
View file @
4ee1b308
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import
debug
from
'
debug
'
;
import
{
name
}
from
'
../../package.json
'
;
export
default
namespace
=>
debug
(
`
${
name
}
:
${
namespace
}
`
);
packages/parity-electron/src/utils/parityChannel.js
View file @
4ee1b308
...
...
@@ -14,4 +14,4 @@ export const setParityChannel = channel => {
parityChannel
=
channel
;
};
export
default
parityChannel
;
export
default
()
=>
parityChannel
;
yarn.lock
View file @
4ee1b308
...
...
@@ -8826,13 +8826,6 @@ pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
pino-debug@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/pino-debug/-/pino-debug-1.1.1.tgz#7986a1b3de232ea4cee488a0ebcea7073772a622"
dependencies:
debug "^3.1.0"
pino "^4.0.2"
pino-multi-stream@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/pino-multi-stream/-/pino-multi-stream-3.1.2.tgz#261af1b66caf208abe9c97f1bad1990d5c25d303"
...
...
@@ -8843,7 +8836,7 @@ pino-std-serializers@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-2.1.0.tgz#01953dcaecd5f43b331ecf2e312a49c9fd64851c"
pino@^4.0.2,
pino@^4.16.1, pino@^4.7.1:
pino@^4.16.1, pino@^4.7.1:
version "4.17.3"
resolved "https://registry.yarnpkg.com/pino/-/pino-4.17.3.tgz#3536ea36f6258356ba8891d18dbf1afed41fcf09"
dependencies:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment