Update to Embark v5 (#62)

* chore: update to Embark v5

* fix: fix tests for Embark 5

* update Embark version and remove Geth client

* change contracts to deploy and add cross-env for Windows support

* feat: upgrade to Embark 5.1.nightly2

Fixes the problem of not exiting on build end

* update to Embark 5.1

Fixes issue where artifacts are not built
This commit is contained in:
Jonathan Rainville 2020-01-30 04:45:09 -05:00 committed by GitHub
parent 20970ee8e5
commit 863d9ea8e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 4263 additions and 2724 deletions

View File

@ -1,149 +1,30 @@
if (process.env.WALLET_PASSWORD == undefined) {
throw Error('Env variable WALLET_PASSWORD not defined!')
if (!process.env.WALLET_MNEMONIC) {
throw Error('Env variable WALLET_MNEMONIC not defined!')
}
module.exports = {
// applies to all environments
default: {
enabled: true,
rpcHost: 'localhost', // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: {
// Domains from which to accept cross origin requests (browser enforced). This can also be a comma separated list
auto: true, // When "auto" is true, Embark will automatically set the cors to the address of the webserver
additionalCors: [], // Additional CORS domains to add to the list. If "auto" is false, only those will be added
},
wsRPC: true, // Enable the WS-RPC server
wsOrigins: {
// Same thing as "rpcCorsDomain", but for WS origins
auto: true,
additionalCors: [],
},
wsHost: 'localhost', // WS-RPC server listening interface (default: "localhost")
wsPort: 8546, // WS-RPC server listening port (default: 8546)
// Accounts to use as node accounts
// The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount`
// accounts: [
// {
// nodeAccounts: true, // Accounts use for the node
// numAddresses: '1', // Number of addresses/accounts (defaults to 1)
// password: 'config/development/password', // Password file for the accounts
// },
// Below are additional accounts that will count as `nodeAccounts` in the `deployment` section of your contract config
// Those will not be unlocked in the node itself
// {
// privateKeyFile: 'path/to/file', // Either a keystore or a list of keys, separated by , or ;
// password: 'passwordForTheKeystore', // Needed to decrypt the keystore file
// },
// {
// mnemonic: '12 word mnemonic',
// addressIndex: '0', // Optional. The index to start getting the address
// numAddresses: '1', // Optional. The number of addresses to get
// hdpath: "m/44'/60'/0'/0/", // Optional. HD derivation path
// },
// ],
accounts: [
{
mnemonic: process.env.WALLET_MNEMONIC,
hdpath: process.env.HD_PATH, // If undefined, it will default to the default hd path
balance: '1534983463450 ether',
},
],
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run` and `embark blockchain`
development: {
networkType: 'testnet',
syncMode: 'light',
accounts: [
{
nodeAccounts: true,
password: process.env.WALLET_PASSWORD,
},
],
endpoint: `https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
},
// merges with the settings in default
// used with "embark run privatenet" and/or "embark blockchain privatenet"
privatenet: {
networkType: 'custom',
networkId: 1337,
isDev: false,
datadir: '.embark/privatenet/datadir',
// -- mineWhenNeeded --
// This options is only valid when isDev is false.
// Enabling this option uses our custom script to mine only when needed.
// Embark creates a development account for you (using `geth account new`) and funds the account. This account can be used for
// development (and even imported in to MetaMask). To enable correct usage, a password for this account must be specified
// in the `account > password` setting below.
// NOTE: once `mineWhenNeeded` is enabled, you must run an `embark reset` on your dApp before running
// `embark blockchain` or `embark run` for the first time.
mineWhenNeeded: true,
// -- genesisBlock --
// This option is only valid when mineWhenNeeded is true (which is only valid if isDev is false).
// When enabled, geth uses POW to mine transactions as it would normally, instead of using POA as it does in --dev mode.
// On the first `embark blockchain or embark run` after this option is enabled, geth will create a new chain with a
// genesis block, which can be configured using the `genesisBlock` configuration option below.
genesisBlock: 'config/privatenet/genesis.json', // Genesis block to initiate on first creation of a development node
nodiscover: true,
maxpeers: 0,
proxy: true,
accounts: [
{
nodeAccounts: true,
password: 'config/privatenet/password', // Password to unlock the account
},
],
targetGasLimit: 8000000,
simulatorBlocktime: 0,
},
privateparitynet: {
ethereumClientName: 'parity',
networkType: 'custom',
networkId: 1337,
isDev: false,
genesisBlock: 'config/privatenet/genesis-parity.json', // Genesis block to initiate on first creation of a development node
datadir: '.embark/privatenet/datadir',
mineWhenNeeded: false,
nodiscover: true,
maxpeers: 0,
proxy: true,
accounts: [
{
nodeAccounts: true,
password: 'config/privatenet/password',
},
],
targetGasLimit: 8000000,
simulatorBlocktime: 0,
},
// merges with the settings in default
// used with "embark run testnet" and/or "embark blockchain testnet"
testnet: {
networkType: 'testnet',
syncMode: 'light',
accounts: [
{
nodeAccounts: true,
password: process.env.WALLET_PASSWORD,
},
],
endpoint: `https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
},
// merges with the settings in default
// used with "embark run livenet" and/or "embark blockchain livenet"
livenet: {
networkType: 'livenet',
syncMode: 'light',
rpcCorsDomain: 'http://localhost:8000',
wsOrigins: 'http://localhost:8000',
accounts: [
{
nodeAccounts: true,
password: process.env.WALLET_PASSWORD,
},
],
endpoint: `https://mainnet.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name"
// custom_name: {
// }
}

View File

@ -1,46 +1,15 @@
module.exports = {
// default applies to all environments
default: {
enabled: false,
provider: "whisper", // Communication provider. Currently, Embark only supports whisper
available_providers: ["whisper"], // Array of available providers
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
connection: {
host: "localhost", // Host of the blockchain node
port: 8546, // Port of the blockchain node
port: 8547, // Port of the blockchain node
type: "ws" // Type of connection (ws or rpc)
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name"
//custom_name: {
//}
// Use this section when you need a specific symmetric or private keys in whisper
/*
,keys: {
symmetricKey: "your_symmetric_key",// Symmetric key for message decryption
privateKey: "your_private_key" // Private Key to be used as a signing key and for message decryption
}
*/
//}
};

View File

@ -1,103 +1,25 @@
if (process.env.WALLET_MNEMONIC == undefined) {
throw Error('Env variable WALLET_MNEMONIC not defined!')
}
module.exports = {
// default applies to all environments
default: {
// Blockchain node to deploy the contracts
deployment: {
host: 'localhost', // Host of the blockchain node
port: 8546, // Port of the blockchain node
type: 'ws', // Type of connection (ws or rpc),
// Accounts to use instead of the default account to populate your wallet
// The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount`
/* ,accounts: [
{
privateKey: "your_private_key",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
},
{
privateKeyFile: "path/to/file", // Either a keystore or a list of keys, separated by , or ;
password: "passwordForTheKeystore" // Needed to decrypt the keystore file
},
{
mnemonic: "12 word mnemonic",
addressIndex: "0", // Optional. The index to start getting the address
numAddresses: "1", // Optional. The number of addresses to get
hdpath: "m/44'/60'/0'/0/" // Optional. HD derivation path
},
{
"nodeAccounts": true // Uses the Ethereum node's accounts
}
] */
accounts: [
{
mnemonic: process.env.WALLET_MNEMONIC,
balance: '1534983463450 ether',
},
],
},
// order of connections the dapp should connect to
dappConnection: [
'$WEB3', // uses pre existing web3 object if available (e.g in Mist)
'ws://localhost:8546',
'http://localhost:8545',
],
// Automatically call `ethereum.enable` if true.
// If false, the following code must run before sending any transaction: `await EmbarkJS.enableEthereum();`
// Default value is true.
dappAutoEnable: false,
gas: 'auto',
gasPrice: '10000000000', // 10gwei. TODO: Set a proper gas price for deployment. See ethgasstation.info
// Strategy for the deployment of the contracts:
// - implicit will try to deploy all the contracts located inside the contracts directory
// or the directory configured for the location of the contracts. This is default one
// when not specified
// - explicit will only attempt to deploy the contracts that are explicitly specified inside the
// contracts section.
strategy: 'explicit',
// contracts: {
// Discover: {
// args: { _SNT: '0x744d70fdbe2ba4cf95131626614a1763df805b9e' },
// },
// MiniMeToken: { deploy: false },
// TestBancorFormula: { deploy: false },
// },
contracts: {
deploy: {
Discover: {
args: ['$MiniMeToken'],
},
},
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
deployment: {
accounts: [
{
mnemonic: process.env.WALLET_MNEMONIC,
},
],
host: `ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
port: false,
type: 'rpc',
protocol: 'https',
},
dappConnection: [
'$WEB3',
'https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a',
],
dappAutoEnable: false,
gasPrice: "10000000000",
contracts: {
deploy: {
MiniMeToken: {
address: '0xc55cf4b03948d7ebc8b9e8bad92643703811d162',
},
@ -105,31 +27,12 @@ module.exports = {
tracking: 'shared.development.chains.json',
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
deployment: {
accounts: [
{
mnemonic: process.env.WALLET_MNEMONIC,
},
],
host: `ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
port: false,
type: 'rpc',
protocol: 'https',
},
dappConnection: [
'$WEB3',
'https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a',
],
dappAutoEnable: false,
gasPrice: "10000000000",
contracts: {
deploy: {
MiniMeTokenFactory: {
deploy: false,
},
@ -143,27 +46,12 @@ module.exports = {
tracking: 'shared.testnet.chains.json',
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
deployment: {
accounts: [
{
mnemonic: process.env.WALLET_MNEMONIC,
},
],
host: `mainnet.infura.io/v3/8675214b97b44e96b70d05326c61fd6a`,
port: false,
type: 'rpc',
protocol: 'https',
},
dappConnection: [
'$WEB3',
'https://mainnet.infura.io/v3/8675214b97b44e96b70d05326c61fd6a',
],
dappAutoEnable: false,
gasPrice: "10000000000", // 10gwei. TODO: Set a proper gas price for deployment. See ethgasstation.info
contracts: {
deploy: {
MiniMeTokenFactory: {
deploy: false,
},
@ -176,9 +64,4 @@ module.exports = {
},
tracking: 'shared.mainnet.chains.json',
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name"
// custom_name: {
// }
}

View File

@ -5,13 +5,10 @@
"buildDir": "dist/",
"config": "config/",
"versions": {
"web3": "1.2.4",
"solc": "0.5.2",
"ipfs-api": "17.2.4"
"solc": "0.5.2"
},
"plugins": {
"embark-solium": {},
"embarkjs-connector-web3": {},
"embark-etherscan-verifier": {},
"@trailofbits/embark-contract-info": {
"flags": ""

View File

@ -13,9 +13,16 @@
"connected-react-router": "^6.3.2",
"debounce": "^1.2.0",
"decimal.js": "^10.0.2",
"embark": "4.2.0",
"embark": "5.1.0",
"embark-etherscan-verifier": "^4.0.0",
"embark-solium": "0.0.1",
"embark-solc": "5.1.0",
"embark-solium": "0.1.0",
"embarkjs": "5.1.0",
"embarkjs-ens": "5.1.0",
"embarkjs-ipfs": "5.1.0",
"embarkjs-swarm": "5.1.0",
"embarkjs-web3": "5.1.0",
"embarkjs-whisper": "5.1.0",
"history": "^4.7.2",
"idb": "4.0.3",
"moment": "^2.24.0",
@ -31,9 +38,9 @@
"web3-utils": "^1.0.0-beta.35"
},
"scripts": {
"build:localhost": "NODE_ENV=localhost make all",
"build:dev": "NODE_ENV=development make all",
"build:prod": "NODE_ENV=production make all",
"build:localhost": "cross-env NODE_ENV=localhost make all",
"build:dev": "cross-env NODE_ENV=development make all",
"build:prod": "cross-env NODE_ENV=production make all",
"start": "./node_modules/.bin/react-scripts start",
"server-start": "node ./full-build/server.js",
"build": "./node_modules/.bin/react-scripts build",
@ -63,6 +70,7 @@
],
"devDependencies": {
"bignumber.js": "^8.1.1",
"cross-env": "^6.0.3",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",

View File

@ -2,24 +2,26 @@
const BigNumber = require('bignumber.js');
const constants = require('../utils/FormulaConstants.js');
const catchRevert = require("../utils/Utils").catchRevert;
const TestBancorFormula = embark.require('Embark/contracts/TestBancorFormula');
const TestBancorFormula = require('Embark/contracts/TestBancorFormula');
config({
deployment: {
accounts: [
{
mnemonic: "foster gesture flock merge beach plate dish view friend leave drink valley shield list enemy",
balance: "5 ether",
numAddresses: "10"
}
]
blockchain: {
accounts: [
{
mnemonic: 'foster gesture flock merge beach plate dish view friend leave drink valley shield list enemy',
balance: '5 ether',
numAddresses: '10',
},
],
},
contracts: {
deploy: {
'TestBancorFormula': {},
},
contracts: {
"TestBancorFormula": { }
}
}, (_err, web3_accounts) => {
accounts = web3_accounts
});
},
}, (_err, web3_accounts) => {
accounts = web3_accounts
})
contract('TestBancorFormula', function () {
let ILLEGAL_VAL = new BigNumber(2).exponentiatedBy(256);
@ -255,4 +257,4 @@ contract('TestBancorFormula', function () {
});
}
}
});
});

View File

@ -1,39 +1,40 @@
const TestUtils = require("../utils/testUtils");
const BN = require('bn.js');
const Discover = require('Embark/contracts/Discover');
const SNT = embark.require('Embark/contracts/SNT');
const SNT = require('Embark/contracts/SNT');
config({
deployment: {
blockchain: {
accounts: [
{
mnemonic: "foster gesture flock merge beach plate dish view friend leave drink valley shield list enemy",
balance: "5 ether",
numAddresses: "10"
}
]
mnemonic: 'foster gesture flock merge beach plate dish view friend leave drink valley shield list enemy',
balance: '5 ether',
numAddresses: '10',
},
],
},
contracts: {
"MiniMeToken": { "deploy": false },
"MiniMeTokenFactory": {},
"SNT": {
"instanceOf": "MiniMeToken",
"args": [
"$MiniMeTokenFactory",
"0x0000000000000000000000000000000000000000",
0,
"TestMiniMeToken",
18,
"SNT",
true
]
deploy: {
'MiniMeToken': { 'deploy': false },
'MiniMeTokenFactory': {},
'SNT': {
'instanceOf': 'MiniMeToken',
'args': [
'$MiniMeTokenFactory',
'0x0000000000000000000000000000000000000000',
0,
'TestMiniMeToken',
18,
'SNT',
true,
],
},
'Discover': {
args: ['$SNT'],
},
'TestBancorFormula': {},
},
"Discover": {
args: ["$SNT"]
},
"TestBancorFormula": {}
}
},
}, (_err, web3_accounts) => {
accounts = web3_accounts
});
@ -673,7 +674,7 @@ contract("Discover", function () {
assert.ok(returned <= votes_minted);
})
// Comment out line 263 in the contract to run this test properly and see
// Comment out line 263 in the contract to run this test properly and see
// the BancorFormula fail to find a suitable position in the maxExponentArray
it("should prove we have the highest safeMax allowed for by Bancor's power approximation", async function () {
let id = "0x0000000000000000000000000000000000000000000000000000000000000002";

View File

@ -9,7 +9,7 @@ function ensureException(error) {
assert(isException(error), error.toString());
}
const PREFIX = "VM Exception while processing transaction: ";
const PREFIX = "Returned error: VM Exception while processing transaction: ";
async function tryCatch(promise, message) {
try {
@ -33,4 +33,4 @@ module.exports = {
catchStackOverflow : async function(promise) {await tryCatch(promise, "stack overflow" );},
catchStackUnderflow : async function(promise) {await tryCatch(promise, "stack underflow" );},
catchStaticStateChange : async function(promise) {await tryCatch(promise, "static state change");},
};
};

View File

@ -81,7 +81,7 @@ exports.expectThrow = async promise => {
exports.assertJump = error => {
assert(
error.message.search('VM Exception while processing transaction: revert') >
error.message.search('Returned error: VM Exception while processing transaction: revert') >
-1,
'Revert should happen',
)

6566
yarn.lock

File diff suppressed because it is too large Load Diff