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

feat: upgrades ganache to 7.5.0 #5070

Merged
merged 18 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.21.1
6,198 changes: 3,088 additions & 3,110 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"fix-path": "^2.1.0",
"follow-redirects": "1.9.0",
"fs-extra": "9.0.0",
"ganache": "7.5.0",
"ganache-core": "2.13.1",
"get-port": "^5.0.0",
"history": "4.10.1",
"lodash.assign": "4.2.0",
Expand Down Expand Up @@ -108,7 +110,7 @@
"@babel/register": "^7.0.0",
"@filecoin-shipyard/lotus-client-provider-browser": "0.0.14",
"@filecoin-shipyard/lotus-client-rpc": "0.2.0",
"@ganache/filecoin": "0.1.5",
"@ganache/filecoin": "0.6.0",
"@ganache/filecoin-options": "0.1.3",
"babel-eslint": "10.0.3",
"cache-loader": "4.1.0",
Expand All @@ -126,8 +128,6 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^2.1.0",
"ganache": "7.0.0-filecoin.6",
"ganache-core": "2.13.1",
davidmurdoch marked this conversation as resolved.
Show resolved Hide resolved
"html-loader": "^1.3.2",
"husky": "^3.0.5",
"ipfs-http-client": "^49.0.2",
Expand Down
65 changes: 0 additions & 65 deletions src/common/services/ChainService.js

This file was deleted.

51 changes: 30 additions & 21 deletions src/integrations/ethereum/common/services/EthereumChainService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import path from "path";
import cloneDeep from "lodash.clonedeep";

// https://github.com/electron/electron/blob/cd0aa4a956cb7a13cbe0e12029e6156c3e892924/docs/api/process.md#process-object
const CHAIN_PATH = path.join(__static, "node", "chain", "chain.js");
const PATH_BY_LIBVERSION = {
"2": path.join(__static, "node", "chain", "chain.ethereum.v2.js"),
"7": path.join(__static, "node", "chain", "chain.ethereum.js"),
};
const CHAIN_OPTIONS = {
stdio: ["pipe", "pipe", "pipe", "ipc"],
execArgv: process.env.NODE_ENV === "development" ? ["--inspect=40895"] : undefined
execArgv:
process.env.NODE_ENV === "development" ? ["--inspect=40895"] : undefined,
};

/**
Expand All @@ -18,23 +22,25 @@ const CHAIN_OPTIONS = {
* interpreting messages from that child process, and solving any data
* representation mismatches between Ganache and the child process.
*/
class EthereumChainService extends EventEmitter {
constructor(config) {
export default class EthereumChainService extends EventEmitter {
constructor(workspace, config) {
super();
this.config = config;
const libVersion = workspace.settings.get("libVersion");
this.chainPath = PATH_BY_LIBVERSION[libVersion];
}

start() {
if (this._child && this._child.connected) {
this.emit("message", "start");
} else {
const child = this._child = fork(CHAIN_PATH, [], CHAIN_OPTIONS);
const child = (this._child = fork(this.chainPath, [], CHAIN_OPTIONS));
child.on("message", (msg) => {
if (!msg || !msg.type){
if (!msg || !msg.type) {
return;
}

const {type, data} = msg || {};
const { type, data } = msg || {};
switch (type) {
case "process-started":
this.emit("message", "start");
Expand All @@ -54,7 +60,7 @@ class EthereumChainService extends EventEmitter {
}
this.emit("message", type, data);
});
child.on("error", error => {
child.on("error", (error) => {
this.emit("error", error);
this.emit("message", "error", error);
});
Expand All @@ -66,7 +72,9 @@ class EthereumChainService extends EventEmitter {

async startServer(settings) {
if (this._child) {
const options = this._ganacheCoreOptionsFromGanacheSettingsObject(settings);
const options = this._ganacheCoreOptionsFromGanacheSettingsObject(
settings
);
return new Promise((resolve, reject) => {
const handleServerStarted = () => {
this.removeListener("error", handleServerError);
Expand All @@ -90,10 +98,10 @@ class EthereumChainService extends EventEmitter {

stopServer() {
if (this._child && this._child.connected) {
return new Promise(resolve => {
return new Promise((resolve) => {
this.once("server-stopped", resolve);
this._child.send({
type: "stop-server"
type: "stop-server",
});
});
}
Expand All @@ -102,7 +110,7 @@ class EthereumChainService extends EventEmitter {
getDbLocation() {
if (this._child) {
if (this.isServerStarted()) {
return new Promise(resolve => {
return new Promise((resolve) => {
this.once("db-location", resolve);
this._child.send({
type: "get-db-location",
Expand Down Expand Up @@ -149,28 +157,29 @@ class EthereumChainService extends EventEmitter {
_exitHandler(code, signal) {
this._child = null;
if (code != null) {
this.emit("message",
this.emit(
"message",
"error",
`Blockchain process exited prematurely with code '${code}', due to signal '${signal}'.`,
`Blockchain process exited prematurely with code '${code}', due to signal '${signal}'.`
);
} else {
this.emit("message",
this.emit(
"message",
"error",
`Blockchain process exited prematurely due to signal '${signal}'.`,
`Blockchain process exited prematurely due to signal '${signal}'.`
);
}
}

_stdHandler (stdio, data) {
_stdHandler(stdio, data) {
// Remove all \r's and the final line ending
this.emit("message",
this.emit(
"message",
stdio,
data
.toString()
// we don't care enough to handling carriage returns :-|
// we don't care enough to handling carriage returns :-|
.replace(/\r/g, "")
);
}
}

export default EthereumChainService;
Loading