refactor: simplify blockchain and contract configs

Implements https://notes.status.im/yrfs8w87SZKfE2ft6MoFIg#
This commit is contained in:
Jonathan Rainville 2019-07-25 11:09:49 -04:00
parent 1491028665
commit af8a8ff4d0
40 changed files with 723 additions and 859 deletions

View File

@ -1,124 +1,56 @@
// This file contains only the basic configuration you need to run Embark's node
// For additional configurations, see: https://embark.status.im/docs/blockchain_configuration.html
module.exports = { module.exports = {
// applies to all environments // default applies to all environments
default: { default: {
enabled: true, enabled: true,
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost") client: "geth" // Can be geth or parity (default:geth)
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)
development: {
clientConfig: {
miningMode: 'dev' // Mode in which the node mines. Options: dev, auto, always, off
}
},
privatenet: {
// Accounts to use as node accounts // Accounts to use as node accounts
// The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount` // The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount`
/*,accounts: [ // For more account configurations, see: https://embark.status.im/docs/blockchain_accounts_configuration.html
accounts: [
{ {
nodeAccounts: true, // Accounts use for the node nodeAccounts: true, // Accounts use for the node
numAddresses: "1", // Number of addresses/accounts (defaults to 1) numAddresses: "1", // Number of addresses/accounts (defaults to 1)
password: "config/development/devpassword" // Password file for the accounts 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
{
privateKey: "your_private_key"
},
{
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
}
]*/
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run` and `embark blockchain`
development: {
ethereumClientName: "geth", // Can be geth or parity (default:geth)
//ethereumClientBin: "geth", // path to the client binary. Useful if it is not in the global PATH
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: 1337, // Network id used when networkType is custom
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
datadir: ".embark/development/datadir", // Data directory for the databases and keystore (Geth 1.8.15 and Parity 2.0.4 can use the same base folder, till now they does not conflict with each other)
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
proxy: true, // Proxy is used to present meaningful information about transactions
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
},
// 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, clientConfig: {
simulatorBlocktime: 0 datadir: ".embark/privatenet/datadir", // Data directory for the databases and keystore
miningMode: 'auto',
genesisBlock: "config/privatenet/genesis.json" // Genesis block to initiate on first creation of a development node
}
}, },
privateparitynet: { privateparitynet: {
ethereumClientName: "parity", client: "parity",
networkType: "custom", genesisBlock: "config/privatenet/genesis-parity.json",
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", datadir: ".embark/privatenet/datadir",
mineWhenNeeded: false, miningMode: 'off'
nodiscover: true, },
maxpeers: 0,
proxy: true, externalnode: {
accounts: [ endpoint: "URL_OF_THE_NODE", // Endpoint of an node to connect to. Can be on localhost or on the internet
{ accounts: [
nodeAccounts: true, {
password: "config/privatenet/password" mnemonic: "YOUR_MNEMONIC",
} hdpath: "m/44'/60'/0'/0/",
], numAddresses: "1"
targetGasLimit: 8000000, }
simulatorBlocktime: 0 ]
}, },
// merges with the settings in default
// used with "embark run testnet" and/or "embark blockchain testnet"
testnet: { testnet: {
networkType: "testnet", networkType: "testnet", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
syncMode: "light", syncMode: "light",
accounts: [ accounts: [
{ {
@ -128,13 +60,9 @@ module.exports = {
] ]
}, },
// merges with the settings in default
// used with "embark run livenet" and/or "embark blockchain livenet"
livenet: { livenet: {
networkType: "livenet", networkType: "livenet",
syncMode: "light", syncMode: "light",
rpcCorsDomain: "http://localhost:8000",
wsOrigins: "http://localhost:8000",
accounts: [ accounts: [
{ {
nodeAccounts: true, nodeAccounts: true,

View File

@ -1,34 +1,6 @@
module.exports = { module.exports = {
// default applies to all environments // default applies to all environments
default: { 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
}
]*/
},
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
"$WEB3", // uses pre existing web3 object if available (e.g in Mist) "$WEB3", // uses pre existing web3 object if available (e.g in Mist)
@ -49,9 +21,9 @@ module.exports = {
// when not specified // when not specified
// - explicit will only attempt to deploy the contracts that are explicitly specified inside the // - explicit will only attempt to deploy the contracts that are explicitly specified inside the
// contracts section. // contracts section.
//strategy: 'implicit', // strategy: 'implicit',
contracts: { deploy: {
// example: // example:
//SimpleStorage: { //SimpleStorage: {
// args: [ 100 ] // args: [ 100 ]
@ -71,21 +43,17 @@ module.exports = {
// merges with the settings in default // merges with the settings in default
// used with "embark run privatenet" // used with "embark run privatenet"
privatenet: { privatenet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run testnet" // used with "embark run testnet"
testnet: { testnet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run livenet" // used with "embark run livenet"
livenet: { livenet: {}
},
// you can name an environment with specific settings and then specify with // you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name" // "embark run custom_name" or "embark blockchain custom_name"
//custom_name: { // custom_name: {}
//}
}; };

View File

@ -1,124 +1,56 @@
// This file contains only the basic configuration you need to run Embark's node
// For additional configurations, see: https://embark.status.im/docs/blockchain_configuration.html
module.exports = { module.exports = {
// applies to all environments // default applies to all environments
default: { default: {
enabled: true, enabled: true,
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost") client: "geth" // Can be geth or parity (default:geth)
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)
development: {
clientConfig: {
miningMode: 'dev' // Mode in which the node mines. Options: dev, auto, always, off
}
},
privatenet: {
// Accounts to use as node accounts // Accounts to use as node accounts
// The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount` // The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount`
/*,accounts: [ // For more account configurations, see: https://embark.status.im/docs/blockchain_accounts_configuration.html
accounts: [
{ {
nodeAccounts: true, // Accounts use for the node nodeAccounts: true, // Accounts use for the node
numAddresses: "1", // Number of addresses/accounts (defaults to 1) numAddresses: "1", // Number of addresses/accounts (defaults to 1)
password: "config/development/devpassword" // Password file for the accounts 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
{
privateKey: "your_private_key"
},
{
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
}
]*/
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run` and `embark blockchain`
development: {
ethereumClientName: "geth", // Can be geth or parity (default:geth)
//ethereumClientBin: "geth", // path to the client binary. Useful if it is not in the global PATH
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: 1337, // Network id used when networkType is custom
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
datadir: ".embark/development/datadir", // Data directory for the databases and keystore (Geth 1.8.15 and Parity 2.0.4 can use the same base folder, till now they does not conflict with each other)
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
proxy: true, // Proxy is used to present meaningful information about transactions
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
},
// 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, clientConfig: {
simulatorBlocktime: 0 datadir: ".embark/privatenet/datadir", // Data directory for the databases and keystore
miningMode: 'auto',
genesisBlock: "config/privatenet/genesis.json" // Genesis block to initiate on first creation of a development node
}
}, },
privateparitynet: { privateparitynet: {
ethereumClientName: "parity", client: "parity",
networkType: "custom", genesisBlock: "config/privatenet/genesis-parity.json",
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", datadir: ".embark/privatenet/datadir",
mineWhenNeeded: false, miningMode: 'off'
nodiscover: true, },
maxpeers: 0,
proxy: true, externalnode: {
accounts: [ endpoint: "URL_OF_THE_NODE", // Endpoint of an node to connect to. Can be on localhost or on the internet
{ accounts: [
nodeAccounts: true, {
password: "config/privatenet/password" mnemonic: "YOUR_MNEMONIC",
} hdpath: "m/44'/60'/0'/0/",
], numAddresses: "1"
targetGasLimit: 8000000, }
simulatorBlocktime: 0 ]
}, },
// merges with the settings in default
// used with "embark run testnet" and/or "embark blockchain testnet"
testnet: { testnet: {
networkType: "testnet", networkType: "testnet", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
syncMode: "light", syncMode: "light",
accounts: [ accounts: [
{ {
@ -128,13 +60,9 @@ module.exports = {
] ]
}, },
// merges with the settings in default
// used with "embark run livenet" and/or "embark blockchain livenet"
livenet: { livenet: {
networkType: "livenet", networkType: "livenet",
syncMode: "light", syncMode: "light",
rpcCorsDomain: "http://localhost:8000",
wsOrigins: "http://localhost:8000",
accounts: [ accounts: [
{ {
nodeAccounts: true, nodeAccounts: true,

View File

@ -1,34 +1,6 @@
module.exports = { module.exports = {
// default applies to all environments // default applies to all environments
default: { 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
}
]*/
},
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
"$WEB3", // uses pre existing web3 object if available (e.g in Mist) "$WEB3", // uses pre existing web3 object if available (e.g in Mist)
@ -49,9 +21,9 @@ module.exports = {
// when not specified // when not specified
// - explicit will only attempt to deploy the contracts that are explicitly specified inside the // - explicit will only attempt to deploy the contracts that are explicitly specified inside the
// contracts section. // contracts section.
//strategy: 'implicit', // strategy: 'implicit',
contracts: { deploy: {
SimpleStorage: { SimpleStorage: {
fromIndex: 0, fromIndex: 0,
args: [100] args: [100]
@ -71,21 +43,17 @@ module.exports = {
// merges with the settings in default // merges with the settings in default
// used with "embark run privatenet" // used with "embark run privatenet"
privatenet: { privatenet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run testnet" // used with "embark run testnet"
testnet: { testnet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run livenet" // used with "embark run livenet"
livenet: { livenet: {}
},
// you can name an environment with specific settings and then specify with // you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name" // "embark run custom_name" or "embark blockchain custom_name"
//custom_name: { // custom_name: {}
//}
}; };

View File

@ -1,34 +1,6 @@
module.exports = { module.exports = {
// default applies to all environments // default applies to all environments
default: { 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
}
]*/
},
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
"$WEB3", // uses pre existing web3 object if available (e.g in Mist) "$WEB3", // uses pre existing web3 object if available (e.g in Mist)
@ -49,13 +21,13 @@ module.exports = {
// when not specified // when not specified
// - explicit will only attempt to deploy the contracts that are explicitly specified inside the // - explicit will only attempt to deploy the contracts that are explicitly specified inside the
// contracts section. // contracts section.
//strategy: 'implicit', // strategy: 'implicit',
contracts: { deploy: {
// example: // SimpleStorage: {
//SimpleStorage: { // fromIndex: 0,
// args: [ 100 ] // args: [100]
//} // }
} }
}, },
@ -71,21 +43,17 @@ module.exports = {
// merges with the settings in default // merges with the settings in default
// used with "embark run privatenet" // used with "embark run privatenet"
privatenet: { privatenet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run testnet" // used with "embark run testnet"
testnet: { testnet: {},
},
// merges with the settings in default // merges with the settings in default
// used with "embark run livenet" // used with "embark run livenet"
livenet: { livenet: {}
},
// you can name an environment with specific settings and then specify with // you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name" // "embark run custom_name" or "embark blockchain custom_name"
//custom_name: { // custom_name: {}
//}
}; };

View File

@ -0,0 +1,84 @@
// This file contains only the basic configuration you need to run Embark's node
// For additional configurations, see: https://embark.status.im/docs/blockchain_configuration.html
module.exports = {
// default applies to all environments
default: {
enabled: true,
client: "geth" // Can be geth or parity (default:geth)
},
development: {
clientConfig: {
miningMode: 'dev' // Mode in which the node mines. Options: dev, auto, always, off
},
"accounts": [
{
"mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
"balance": "5 ether"
}
]
},
privatenet: {
// Accounts to use as node accounts
// The order here corresponds to the order of `web3.eth.getAccounts`, so the first one is the `defaultAccount`
// For more account configurations, see: https://embark.status.im/docs/blockchain_accounts_configuration.html
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
}
],
clientConfig: {
datadir: ".embark/privatenet/datadir", // Data directory for the databases and keystore
miningMode: 'auto',
genesisBlock: "config/privatenet/genesis.json" // Genesis block to initiate on first creation of a development node
}
},
privateparitynet: {
client: "parity",
genesisBlock: "config/privatenet/genesis-parity.json",
datadir: ".embark/privatenet/datadir",
miningMode: 'off'
},
externalnode: {
endpoint: "URL_OF_THE_NODE", // Endpoint of an node to connect to. Can be on localhost or on the internet
accounts: [
{
mnemonic: "YOUR_MNEMONIC",
hdpath: "m/44'/60'/0'/0/",
numAddresses: "1"
}
]
},
testnet: {
networkType: "testnet", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
syncMode: "light",
accounts: [
{
nodeAccounts: true,
password: "config/testnet/password"
}
]
},
livenet: {
networkType: "livenet",
syncMode: "light",
accounts: [
{
nodeAccounts: true,
password: "config/livenet/password"
}
]
}
// 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,62 +0,0 @@
{
"default": {
"enabled": true,
"rpcHost": "localhost",
"rpcPort": 8545,
"rpcCorsDomain": "auto",
"wsRPC": true,
"wsHost": "localhost",
"wsPort": 8546,
"wsOrigins": "auto"
},
"development": {
"networkType": "custom",
"networkId": "1337",
"isDev": true,
"datadir": ".embark/development/datadir",
"mineWhenNeeded": true,
"nodiscover": true,
"maxpeers": 0,
"targetGasLimit": 8000000,
"proxy": true
},
"privatenet": {
"networkType": "custom",
"networkId": "1337",
"isDev": false,
"genesisBlock": "config/privatenet/genesis.json",
"datadir": ".embark/privatenet/datadir",
"mineWhenNeeded": true,
"nodiscover": true,
"maxpeers": 0,
"account": {
"numAccounts": 3,
"balance": "5 ether",
"password": "config/privatenet/password"
},
"targetGasLimit": 8000000,
"proxy": true
},
"testnet": {
"networkType": "testnet",
"syncMode": "fast",
"account": {
"password": "config/ropsten/password"
}
},
"rinkeby": {
"networkType": "rinkeby",
"syncMode": "fast",
"account": {
"password": "config/rinkeby/password"
}
},
"livenet": {
"networkType": "livenet",
"rpcCorsDomain": "http://localhost:8000",
"wsOrigins": "http://localhost:8000",
"account": {
"password": "config/livenet/password"
}
}
}

View File

@ -1,16 +1,5 @@
module.exports = { module.exports = {
default: { default: {
deployment: {
host: "localhost",
port: 8546,
type: "ws",
accounts: [
{
mnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm",
balance: "5 ether"
}
]
},
dappConnection: [ dappConnection: [
"ws://localhost:8546", "ws://localhost:8546",
"http://localhost:8550", "http://localhost:8550",
@ -19,7 +8,7 @@ module.exports = {
"$WEB3" "$WEB3"
], ],
gas: "auto", gas: "auto",
contracts: { deploy: {
Ownable: { Ownable: {
deploy: false deploy: false
}, },
@ -88,7 +77,7 @@ module.exports = {
] ]
}, },
development: { development: {
contracts: { deploy: {
MyToken2: { MyToken2: {
instanceOf: "Token", instanceOf: "Token",
args: [2000] args: [2000]

View File

@ -6,7 +6,7 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
let accounts; let accounts;
config({ config({
deployment: { blockchain: {
"accounts": [ "accounts": [
{ {
"mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
@ -15,11 +15,13 @@ config({
] ]
}, },
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
}, args: [100]
"AnotherStorage": { },
args: ["$SimpleStorage"] "AnotherStorage": {
args: ["$SimpleStorage"]
}
} }
} }
}, (err, theAccounts) => { }, (err, theAccounts) => {

View File

@ -5,19 +5,21 @@ const MyToken2 = require('Embark/contracts/MyToken2');
config({ config({
contracts: { contracts: {
"Token": { deploy: {
deploy: false, "Token": {
args: [1000] deploy: false,
}, args: [1000]
"MyToken2": { },
instanceOf: "Token", "MyToken2": {
args: [2000] instanceOf: "Token",
}, args: [2000]
"SomeContract": { },
"args": [ "SomeContract": {
["$MyToken2", "$accounts[0]"], "args": [
100 ["$MyToken2", "$accounts[0]"],
] 100
]
}
} }
} }
}); });

View File

@ -7,7 +7,7 @@ let gasPrice = 1;
let accounts; let accounts;
config({ config({
deployment: { blockchain: {
accounts: [ accounts: [
// you can configure custom accounts with a custom balance // you can configure custom accounts with a custom balance
// see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts // see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts
@ -18,22 +18,24 @@ config({
] ]
}, },
contracts: { contracts: {
"Token": { deploy: {
deploy: false, "Token": {
args: [1000] deploy: false,
}, args: [1000]
"MyToken2": { },
instanceOf: "Token", "MyToken2": {
args: [2000] instanceOf: "Token",
}, args: [2000]
"SomeContract": { },
"args": [ "SomeContract": {
["$MyToken2", "$accounts[0]"], "args": [
100 ["$MyToken2", "$accounts[0]"],
] 100
}, ]
"SimpleStorage": { },
args: [100] "SimpleStorage": {
args: [100]
}
} }
} }
}, (_err, web3_accounts) => { }, (_err, web3_accounts) => {

View File

@ -5,8 +5,10 @@ const EmbarkJS = require('Embark/EmbarkJS');
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
args: [100]
}
} }
} }
}); });

View File

@ -4,8 +4,10 @@ const AnotherStorage = require('Embark/contracts/AnotherStorage');
config({ config({
contracts: { contracts: {
AnotherStorage: { deploy: {
args: ['$ERC20'] AnotherStorage: {
args: ['$ERC20']
}
} }
} }
}); });

View File

@ -4,12 +4,12 @@ const Test2 = require('Embark/contracts/Test2');
config({ config({
contracts: { contracts: {
"Test2": { deploy: {
}, "Test2": {},
"ZAMyLib": { "ZAMyLib": {},
}, "ZAMyLib2": {
"ZAMyLib2": { "deploy": true
"deploy": true }
} }
} }
}); });

View File

@ -6,16 +6,18 @@ const EmbarkJS = require('Embark/EmbarkJS');
config({ config({
contracts: { contracts: {
"Token": { deploy: {
deploy: false, "Token": {
args: [1000] deploy: false,
}, args: [1000]
"MyToken": { },
instanceOf: "Token" "MyToken": {
}, instanceOf: "Token"
"MyToken2": { },
instanceOf: "Token", "MyToken2": {
args: [2000] instanceOf: "Token",
args: [2000]
}
} }
} }
}); });

View File

@ -5,11 +5,13 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
}, args: [100]
"PluginStorage": { },
args: ["$SimpleStorage"] "PluginStorage": {
args: ["$SimpleStorage"]
}
} }
} }
}); });

View File

@ -5,9 +5,11 @@ const {Utils} = require('Embark/EmbarkJS');
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100], "SimpleStorage": {
onDeploy: ["SimpleStorage.methods.setRegistar('$SimpleStorage').send()"] args: [100],
onDeploy: ["SimpleStorage.methods.setRegistar('$SimpleStorage').send()"]
}
} }
} }
}, (err, theAccounts) => { }, (err, theAccounts) => {

View File

@ -9,43 +9,45 @@ const SomeContract = require('Embark/contracts/SomeContract');
config({ config({
contracts: { contracts: {
ZAMyLib: {}, deploy: {
SimpleStorage: { ZAMyLib: {},
args: [100] SimpleStorage: {
}, args: [100]
AnotherStorage: { },
args: ["$SimpleStorage"] AnotherStorage: {
}, args: ["$SimpleStorage"]
Token: { },
deploy: false, Token: {
args: [1000] deploy: false,
}, args: [1000]
MyToken: { },
instanceOf: "Token" MyToken: {
}, instanceOf: "Token"
MyToken2: { },
instanceOf: "Token", MyToken2: {
args: [2000] instanceOf: "Token",
}, args: [2000]
AlreadyDeployedToken: { },
address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE", AlreadyDeployedToken: {
instanceOf: "Token" address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
}, instanceOf: "Token"
Test: { },
onDeploy: ["Test.methods.changeAddress('$MyToken').send()", "Test.methods.changeENS('embark.eth').send()"] Test: {
}, onDeploy: ["Test.methods.changeAddress('$MyToken').send()", "Test.methods.changeENS('embark.eth').send()"]
ContractArgs: { },
args: { ContractArgs: {
initialValue: 123, args: {
_addresses: ["$MyToken2", "$SimpleStorage"] initialValue: 123,
_addresses: ["$MyToken2", "$SimpleStorage"]
}
},
SomeContract: {
deployIf: "await MyToken.methods.isAvailable().call()",
args: [
["$MyToken2", "$SimpleStorage"],
100
]
} }
},
SomeContract: {
deployIf: "await MyToken.methods.isAvailable().call()",
args: [
["$MyToken2", "$SimpleStorage"],
100
]
} }
} }
}); });

View File

@ -3,11 +3,6 @@
"versions": { "versions": {
"solc": "0.4.24" "solc": "0.4.24"
}, },
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [ "dappConnection": [
"$WEB3", "$WEB3",
"ws://localhost:8546", "ws://localhost:8546",
@ -16,7 +11,7 @@
"http://localhost:8550" "http://localhost:8550"
], ],
"gas": "auto", "gas": "auto",
"contracts": { "deploy": {
"Ownable": { "Ownable": {
"deploy": false "deploy": false
}, },
@ -73,7 +68,7 @@
] ]
}, },
"development": { "development": {
"contracts": { "deploy": {
"MyToken2": { "MyToken2": {
"instanceOf": "Token", "instanceOf": "Token",
"args": [2000] "args": [2000]

View File

@ -6,11 +6,13 @@ let accounts;
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
}, args: [100]
"AnotherStorage": { },
args: ["$SimpleStorage", "embark.eth"] "AnotherStorage": {
args: ["$SimpleStorage", "embark.eth"]
}
} }
} }
}, (err, accs) => { }, (err, accs) => {

View File

@ -6,22 +6,24 @@ const MyToken2 = require('Embark/contracts/MyToken2');
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
}, args: [100]
"Token": { },
deploy: false, "Token": {
args: [1000] deploy: false,
}, args: [1000]
"MyToken2": { },
instanceOf: "Token", "MyToken2": {
args: [2000] instanceOf: "Token",
}, args: [2000]
"SomeContract": { },
"args": [ "SomeContract": {
["$MyToken2", "$SimpleStorage"], "args": [
100 ["$MyToken2", "$SimpleStorage"],
] 100
]
}
} }
} }
}); });

View File

@ -4,12 +4,12 @@ const Test2 = require('Embark/contracts/Test2');
config({ config({
contracts: { contracts: {
"Test2": { deploy: {
}, "Test2": {},
"ZAMyLib": { "ZAMyLib": {},
}, "ZAMyLib2": {
"ZAMyLib2": { "deploy": true
"deploy": true }
} }
} }
}); });

View File

@ -4,8 +4,10 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({ config({
contracts: { contracts: {
"SimpleStorage": { deploy: {
args: [100] "SimpleStorage": {
args: [100]
}
} }
} }
}); });

View File

@ -8,42 +8,44 @@ const Test = require('Embark/contracts/Test');
config({ config({
contracts: { contracts: {
ZAMyLib: {}, deploy: {
SimpleStorage: { ZAMyLib: {},
args: [100] SimpleStorage: {
}, args: [100]
AnotherStorage: { },
args: ["$SimpleStorage", "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE"] AnotherStorage: {
}, args: ["$SimpleStorage", "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE"]
Token: { },
deploy: false, Token: {
args: [1000] deploy: false,
}, args: [1000]
MyToken: { },
instanceOf: "Token" MyToken: {
}, instanceOf: "Token"
MyToken2: { },
instanceOf: "Token", MyToken2: {
args: [2000] instanceOf: "Token",
}, args: [2000]
AlreadyDeployedToken: { },
address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE", AlreadyDeployedToken: {
instanceOf: "Token" address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
}, instanceOf: "Token"
Test: { },
onDeploy: ["Test.methods.changeAddress('$MyToken').send()"] Test: {
}, onDeploy: ["Test.methods.changeAddress('$MyToken').send()"]
ContractArgs: { },
args: { ContractArgs: {
initialValue: 123, args: {
_addresses: ["$MyToken2", "$SimpleStorage"] initialValue: 123,
_addresses: ["$MyToken2", "$SimpleStorage"]
}
},
SomeContract: {
args: [
["$MyToken2", "$SimpleStorage"],
100
]
} }
},
SomeContract: {
args: [
["$MyToken2", "$SimpleStorage"],
100
]
} }
} }
}); });

View File

@ -7,11 +7,12 @@ const constants = require('embark-core/constants');
const embarkJsUtils = require('embarkjs').Utils; const embarkJsUtils = require('embarkjs').Utils;
const {bigNumberify} = require('ethers/utils/bignumber'); const {bigNumberify} = require('ethers/utils/bignumber');
const RLP = require('ethers/utils/rlp'); const RLP = require('ethers/utils/rlp');
import { buildUrl, dappPath } from 'embark-utils'; import {AccountParser, buildUrl, dappPath, deconstructUrl} from 'embark-utils';
const WEB3_READY = 'blockchain:ready'; const WEB3_READY = 'blockchain:ready';
const BLOCK_LIMIT = 100; const BLOCK_LIMIT = 100;
const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000';
// TODO: consider another name, this is the blockchain connector // TODO: consider another name, this is the blockchain connector
class BlockchainConnector { class BlockchainConnector {
@ -24,7 +25,6 @@ class BlockchainConnector {
this.config = embark.config; this.config = embark.config;
this.web3 = options.web3; this.web3 = options.web3;
this.isDev = options.isDev; this.isDev = options.isDev;
this.web3Endpoint = '';
this.isWeb3Ready = false; this.isWeb3Ready = false;
this.wait = options.wait; this.wait = options.wait;
this.contractsSubscriptions = []; this.contractsSubscriptions = [];
@ -97,7 +97,11 @@ class BlockchainConnector {
return cb(); return cb();
} }
let {type, host, port, accounts, protocol, coverage} = this.config.contractsConfig.deployment; if (this.config.blockchainConfig.type === 'vm') {
return this._setupVM(cb);
}
let {type, host, port, protocol} = deconstructUrl(this.config.blockchainConfig.endpoint);
if (!protocol) { if (!protocol) {
protocol = (type === "rpc") ? 'http' : 'ws'; protocol = (type === "rpc") ? 'http' : 'ws';
} }
@ -111,67 +115,17 @@ class BlockchainConnector {
this.logger.warn('Using RPC as deployment connection type is deprecated. It is recommended to use WS.'); this.logger.warn('Using RPC as deployment connection type is deprecated. It is recommended to use WS.');
} }
if (type === 'vm') {
const sim = self._getSimulator();
const options = Object.assign({}, self.config.contractsConfig.deployment, {
gasPrice: "0x01",
gasLimit: "0xfffffffffffff",
allowUnlimitedContractSize: coverage
});
self.provider = sim.provider(options);
if (coverage) {
// Here we patch the sendAsync method on the provider. The goal behind this is to force pure/constant/view calls to become
// transactions, so that we can pull in execution traces and account for those executions in code coverage.
//
// Instead of a simple call, here's what happens:
//
// 1) A transaction is sent with the same payload, and a pre-defined gas price;
// 2) We wait for the transaction to be mined by asking for the receipt;
// 3) Once we get the receipt back, we dispatch the real call and pass the original callback;
//
// This will still allow tests to get the return value from the call and run contracts unmodified.
self.provider.realSendAsync = self.provider.sendAsync.bind(self.provider);
self.provider.sendAsync = function(payload, cb) {
if(payload.method !== 'eth_call') {
return self.provider.realSendAsync(payload, cb);
}
self.events.request('reporter:toggleGasListener');
let newParams = Object.assign({}, payload.params[0]);
let newPayload = {
id: payload.id + 1,
method: constants.blockchain.transactionMethods.eth_sendTransaction,
params: [newParams],
jsonrpc: payload.jsonrpc
};
self.provider.realSendAsync(newPayload, (_err, response) => {
let txHash = response.result;
self.web3.eth.getTransactionReceipt(txHash, (_err, _res) => {
self.events.request('reporter:toggleGasListener');
self.provider.realSendAsync(payload, cb);
});
});
};
}
self.web3.setProvider(self.provider);
self._emitWeb3Ready();
return cb();
}
protocol = (type === "rpc") ? protocol : 'ws'; protocol = (type === "rpc") ? protocol : 'ws';
this.web3Endpoint = buildUrl(protocol, host, port); const web3Endpoint = buildUrl(protocol, host, port);
const providerOptions = { const providerOptions = {
web3: this.web3, web3: this.web3,
accountsConfig: accounts,
blockchainConfig: this.config.blockchainConfig, blockchainConfig: this.config.blockchainConfig,
logger: this.logger, logger: this.logger,
isDev: this.isDev, isDev: this.isDev,
type: type, type: type,
web3Endpoint: self.web3Endpoint, web3Endpoint,
events: this.events, events: this.events,
fs: this.fs fs: this.fs
}; };
@ -221,6 +175,69 @@ class BlockchainConnector {
}); });
} }
_setupVM(cb) {
const sim = this._getSimulator();
const coverage = !!this.config.blockchainConfig.coverage;
let accounts = null;
if (this.config.blockchainConfig.accounts) {
accounts = AccountParser.parseAccountsConfig(this.config.blockchainConfig.accounts, this.web3, dappPath());
accounts = accounts.map((account) => {
if (!account.hexBalance) {
account.hexBalance = BALANCE_10_ETHER_IN_HEX;
}
return {balance: account.hexBalance, secretKey: account.privateKey};
});
}
const options = Object.assign(this.config.blockchainConfig.endpoint ? deconstructUrl(this.config.blockchainConfig.endpoint): {}, {
gasPrice: "0x01",
gasLimit: "0xfffffffffffff",
allowUnlimitedContractSize: coverage,
accounts
});
this.provider = sim.provider(options);
if (coverage) {
// Here we patch the sendAsync method on the provider. The goal behind this is to force pure/constant/view calls to become
// transactions, so that we can pull in execution traces and account for those executions in code coverage.
//
// Instead of a simple call, here's what happens:
//
// 1) A transaction is sent with the same payload, and a pre-defined gas price;
// 2) We wait for the transaction to be mined by asking for the receipt;
// 3) Once we get the receipt back, we dispatch the real call and pass the original callback;
//
// This will still allow tests to get the return value from the call and run contracts unmodified.
this.provider.realSendAsync = this.provider.sendAsync.bind(this.provider);
this.provider.sendAsync = (payload, cb) => {
if(payload.method !== 'eth_call') {
return this.provider.realSendAsync(payload, cb);
}
this.events.request('reporter:toggleGasListener');
let newParams = Object.assign({}, payload.params[0]);
let newPayload = {
id: payload.id + 1,
method: constants.blockchain.transactionMethods.eth_sendTransaction,
params: [newParams],
jsonrpc: payload.jsonrpc
};
this.provider.realSendAsync(newPayload, (_err, response) => {
let txHash = response.result;
this.web3.eth.getTransactionReceipt(txHash, (_err, _res) => {
this.events.request('reporter:toggleGasListener');
this.provider.realSendAsync(payload, cb);
});
});
};
}
this.web3.setProvider(this.provider);
this._emitWeb3Ready();
cb();
}
_emitWeb3Ready() { _emitWeb3Ready() {
this.registerWeb3Object(() => { this.registerWeb3Object(() => {
this.isWeb3Ready = true; this.isWeb3Ready = true;

View File

@ -9,7 +9,6 @@ const ethUtil = require('ethereumjs-util');
class Provider { class Provider {
constructor(options) { constructor(options) {
this.web3 = options.web3; this.web3 = options.web3;
this.accountsConfig = options.accountsConfig;
this.blockchainConfig = options.blockchainConfig; this.blockchainConfig = options.blockchainConfig;
this.type = options.type; this.type = options.type;
this.web3Endpoint = options.web3Endpoint; this.web3Endpoint = options.web3Endpoint;
@ -76,11 +75,7 @@ class Provider {
} }
try { try {
self.blockchainAccounts = AccountParser.parseAccountsConfig(self.blockchainConfig.accounts, self.web3, dappPath(), self.logger, accounts); self.accounts = AccountParser.parseAccountsConfig(self.blockchainConfig.accounts, self.web3, dappPath(), self.logger, accounts);
accounts = accounts.concat(self.blockchainAccounts);
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, dappPath(), self.logger, accounts);
} catch (e) { } catch (e) {
return callback(e); return callback(e);
} }

View File

@ -34,8 +34,8 @@ var Blockchain = function(userConfig, clientClass) {
this.config = { this.config = {
silent: this.userConfig.silent, silent: this.userConfig.silent,
ethereumClientName: this.userConfig.ethereumClientName, client: this.userConfig.client,
ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.ethereumClientName, ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client,
networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE,
networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID,
genesisBlock: this.userConfig.genesisBlock || false, genesisBlock: this.userConfig.genesisBlock || false,
@ -77,7 +77,7 @@ var Blockchain = function(userConfig, clientClass) {
} }
} }
if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"ethereumClientName":"geth"}') { if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"client":"geth"}') {
if (this.env === 'development') { if (this.env === 'development') {
this.isDev = true; this.isDev = true;
} else { } else {
@ -461,12 +461,12 @@ export function BlockchainClient(userConfig, options) {
options.logger.info("===> " + __("warning: running default config on a non-development environment")); options.logger.info("===> " + __("warning: running default config on a non-development environment"));
} }
// if client is not set in preferences, default is geth // if client is not set in preferences, default is geth
if (!userConfig.ethereumClientName) userConfig.ethereumClientName = constants.blockchain.clients.geth; if (!userConfig.client) userConfig.client = constants.blockchain.clients.geth;
// if clientName is set, it overrides preferences // if clientName is set, it overrides preferences
if (options.clientName) userConfig.ethereumClientName = options.clientName; if (options.clientName) userConfig.client = options.clientName;
// Choose correct client instance based on clientName // Choose correct client instance based on clientName
let clientClass; let clientClass;
switch (userConfig.ethereumClientName) { switch (userConfig.client) {
case constants.blockchain.clients.geth: case constants.blockchain.clients.geth:
clientClass = GethClient; clientClass = GethClient;
break; break;
@ -475,7 +475,7 @@ export function BlockchainClient(userConfig, options) {
clientClass = ParityClient; clientClass = ParityClient;
break; break;
default: default:
console.error(__('Unknown client "%s". Please use one of the following: %s', userConfig.ethereumClientName, Object.keys(constants.blockchain.clients).join(', '))); console.error(__('Unknown client "%s". Please use one of the following: %s', userConfig.client, Object.keys(constants.blockchain.clients).join(', ')));
process.exit(1); process.exit(1);
} }
userConfig.isDev = (userConfig.isDev || userConfig.default); userConfig.isDev = (userConfig.isDev || userConfig.default);

View File

@ -1,6 +1,6 @@
import { __ } from 'embark-i18n'; import { __ } from 'embark-i18n';
const async = require('async'); const async = require('async');
const { normalizeInput, buildUrlFromConfig } = require('embark-utils'); const { normalizeInput, deconstructUrl } = require('embark-utils');
const constants = require('embark-core/constants'); const constants = require('embark-core/constants');
import { BlockchainProcessLauncher } from './blockchainProcessLauncher'; import { BlockchainProcessLauncher } from './blockchainProcessLauncher';
import { pingEndpoint } from './utils'; import { pingEndpoint } from './utils';
@ -15,7 +15,6 @@ export default class BlockchainModule {
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.blockchainConfig = embark.config.blockchainConfig; this.blockchainConfig = embark.config.blockchainConfig;
this.contractsConfig = embark.config.contractsConfig;
this.embark = embark; this.embark = embark;
this.locale = options.locale; this.locale = options.locale;
this.isDev = options.isDev; this.isDev = options.isDev;
@ -41,7 +40,7 @@ export default class BlockchainModule {
if (!this.ipc.isServer()) return; if (!this.ipc.isServer()) return;
this.ipc.on('blockchain:node', (_message, cb) => { this.ipc.on('blockchain:node', (_message, cb) => {
cb(null, buildUrlFromConfig(this.contractsConfig.deployment)); cb(null, this.blockchainConfig.endpoint);
}); });
} }
@ -89,10 +88,10 @@ export default class BlockchainModule {
}); });
}, },
function _pingEndpoint(next) { function _pingEndpoint(next) {
if (!self.contractsConfig || !self.contractsConfig.deployment || !self.contractsConfig.deployment.host) { if (!self.blockchainConfig || !self.blockchainConfig.endpoint) {
return next(); return next();
} }
const {host, port, type, protocol} = self.contractsConfig.deployment; const {host, port, type, protocol} = deconstructUrl(self.blockchainConfig.endpoint);
pingEndpoint(host, port, type, protocol, self.blockchainConfig.wsOrigins.split(',')[0], next); pingEndpoint(host, port, type, protocol, self.blockchainConfig.wsOrigins.split(',')[0], next);
} }
], function(err) { ], function(err) {

View File

@ -19,6 +19,7 @@ export class Simulator {
let useProxy = this.blockchainConfig.proxy || false; let useProxy = this.blockchainConfig.proxy || false;
let host = (dockerHostSwap(options.host || this.blockchainConfig.rpcHost) || defaultHost); let host = (dockerHostSwap(options.host || this.blockchainConfig.rpcHost) || defaultHost);
// TODO change this
const configPort = this.contractsConfig.deployment.type === 'rpc' ? this.blockchainConfig.rpcPort : this.blockchainConfig.wsPort; const configPort = this.contractsConfig.deployment.type === 'rpc' ? this.blockchainConfig.rpcPort : this.blockchainConfig.wsPort;
let port = (options.port || configPort || 8545); let port = (options.port || configPort || 8545);
port = parseInt(port, 10) + (useProxy ? constants.blockchain.servicePortOnProxy : 0); port = parseInt(port, 10) + (useProxy ? constants.blockchain.servicePortOnProxy : 0);

View File

@ -172,7 +172,7 @@ class CodeGenerator {
dappConnection: contractConfig.dappConnection, dappConnection: contractConfig.dappConnection,
dappAutoEnable: contractConfig.dappAutoEnable, dappAutoEnable: contractConfig.dappAutoEnable,
warnIfMetamask: this.blockchainConfig.isDev, warnIfMetamask: this.blockchainConfig.isDev,
blockchainClient: this.blockchainConfig.ethereumClientName blockchainClient: this.blockchainConfig.client
}; };
this.generateArtifact(this.dappConfigs.blockchain, constants.dappArtifacts.blockchain, constants.dappArtifacts.dir, (err, path, _updated) => { this.generateArtifact(this.dappConfigs.blockchain, constants.dappArtifacts.blockchain, constants.dappArtifacts.dir, (err, path, _updated) => {
callback(err, path); callback(err, path);

View File

@ -1,12 +1,10 @@
import { __ } from 'embark-i18n'; import { __ } from 'embark-i18n';
import { deconstructUrl, prepareContractsConfig, AccountParser } from 'embark-utils'; import { deconstructUrl, prepareContractsConfig, buildUrl } from 'embark-utils';
const async = require('async'); const async = require('async');
const web3Utils = require('web3-utils'); const web3Utils = require('web3-utils');
import { GAS_LIMIT } from './constants'; import { GAS_LIMIT } from './constants';
const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000';
class Test { class Test {
constructor(options) { constructor(options) {
this.options = options || {}; this.options = options || {};
@ -64,15 +62,6 @@ class Test {
} }
initWeb3Provider(callback) { initWeb3Provider(callback) {
if (this.simOptions.accounts) {
this.simOptions.accounts = this.simOptions.accounts.map((account) => {
if (!account.hexBalance) {
account.hexBalance = BALANCE_10_ETHER_IN_HEX;
}
return {balance: account.hexBalance, secretKey: account.privateKey};
});
}
if (!this.simOptions.host && (this.options.node && this.options.node === 'vm')) { if (!this.simOptions.host && (this.options.node && this.options.node === 'vm')) {
this.simOptions.type = 'vm'; this.simOptions.type = 'vm';
} else if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) { } else if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
@ -87,9 +76,12 @@ class Test {
Object.assign(this.simOptions, options); Object.assign(this.simOptions, options);
} }
this.configObj.contractsConfig.deployment = this.simOptions; this.configObj.blockchainConfig.endpoint = this.simOptions.host ? buildUrl(this.simOptions.protocol, this.simOptions.host, this.simOptions.port, this.simOptions.type) : null;
this.configObj.contractsConfig.deployment.coverage = this.options.coverage; this.configObj.blockchainConfig.type = this.simOptions.type;
this.events.request("config:contractsConfig:set", this.configObj.contractsConfig, () => { this.configObj.blockchainConfig.accounts = this.simOptions.accounts;
this.configObj.blockchainConfig.coverage = this.options.coverage;
this.logger.trace('Setting blockchain configs:', this.configObj.blockchainConfig);
this.events.request('config:blockchainConfig:set', this.configObj.blockchainConfig, () => {
this.events.request('blockchain:reset', (err) => { this.events.request('blockchain:reset', (err) => {
if (err) { if (err) {
this.logger.error('Error restarting the blockchain connection'); this.logger.error('Error restarting the blockchain connection');
@ -137,9 +129,10 @@ class Test {
} }
checkDeploymentOptions(options, callback) { checkDeploymentOptions(options, callback) {
const self = this;
let resetServices = false; let resetServices = false;
const {host, port, type, accounts} = options.deployment || {}; const blockchainConfig = options.blockchain || {};
const {host, port, type, protocol} = blockchainConfig.endpoint ? deconstructUrl(blockchainConfig.endpoint) : {};
const accounts = blockchainConfig.accounts;
if (host && port && !['rpc', 'ws'].includes(type)) { if (host && port && !['rpc', 'ws'].includes(type)) {
return callback(__("contracts config error: unknown deployment type %s", type)); return callback(__("contracts config error: unknown deployment type %s", type));
@ -155,36 +148,21 @@ class Test {
resetServices = true; resetServices = true;
} }
this.events.request("blockchain:get", (web3) => { Object.assign(this.simOptions, {host, port, type, protocol});
if (accounts) { this.simOptions.accounts = accounts;
try {
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath); if (!resetServices && !this.firstRunConfig) {
} catch (e) { return callback();
return callback(e); }
}
} else { this.initWeb3Provider((err) => {
self.simOptions.accounts = null; if (err) {
return callback(err);
} }
this.firstRunConfig = false;
Object.assign(self.simOptions, { this.events.request("blockchain:ready", () => {
host, this.events.request("code-generator:embarkjs:build", () => {
port, this.events.request("runcode:embarkjs:reset", callback);
type
});
if (!resetServices && !self.firstRunConfig) {
return callback();
}
self.initWeb3Provider((err) => {
if (err) {
return callback(err);
}
self.firstRunConfig = false;
self.events.request("blockchain:ready", () => {
self.events.request("code-generator:embarkjs:build", () => {
self.events.request("runcode:embarkjs:reset", callback);
});
}); });
}); });
}); });
@ -280,11 +258,13 @@ class Test {
async _deploy(config, callback) { async _deploy(config, callback) {
const self = this; const self = this;
let contractConfig = config.contracts || {};
async.waterfall([ async.waterfall([
function setConfig(next) { function setConfig(next) {
prepareContractsConfig(config); contractConfig = prepareContractsConfig(contractConfig);
self.events.request('config:contractsConfig:set', self.events.request('config:contractsConfig:set',
{contracts: config.contracts, versions: self.versions_default}, next); // TODO find out what versions_default is where it went
{contracts: contractConfig.contracts, versions: self.versions_default}, next);
}, },
function getAccounts(next) { function getAccounts(next) {
self.events.request('blockchain:getAccounts', (err, accounts) => { self.events.request('blockchain:getAccounts', (err, accounts) => {

View File

@ -154,16 +154,20 @@ function toposort(graph) {
} }
function deconstructUrl(endpoint) { function deconstructUrl(endpoint) {
const matches = endpoint.match(/(ws|https?):\/\/([a-zA-Z0-9_.-]*):?([0-9]*)?/); const matches = endpoint.match(/(wss?|https?):\/\/([a-zA-Z0-9_.-]*):?([0-9]*)?/);
return { return {
protocol: matches[1], protocol: matches[1],
host: matches[2], host: matches[2],
port: matches[3], port: matches[3],
type: matches[1] === 'ws' ? 'ws' : 'rpc' type: matches[1] === 'ws' || matches[1] === 'wss' ? 'ws' : 'rpc'
}; };
} }
function prepareContractsConfig(config) { function prepareContractsConfig(config) {
if (config.deploy) {
config.contracts = config.deploy;
delete config.deploy;
}
Object.keys(config.contracts).forEach((contractName) => { Object.keys(config.contracts).forEach((contractName) => {
const gas = config.contracts[contractName].gas; const gas = config.contracts[contractName].gas;
const gasPrice = config.contracts[contractName].gasPrice; const gasPrice = config.contracts[contractName].gasPrice;

View File

@ -2,7 +2,6 @@ import { __, setOrDetectLocale } from 'embark-i18n';
import { diagramPath } from 'embark-utils'; import { diagramPath } from 'embark-utils';
const program = require('commander'); const program = require('commander');
const EmbarkController = require('./cmd_controller.js'); const EmbarkController = require('./cmd_controller.js');
const fs = require('../lib/core/fs.js');
let embark = new EmbarkController(); let embark = new EmbarkController();

View File

@ -23,6 +23,8 @@ import {
const cloneDeep = require('lodash.clonedeep'); const cloneDeep = require('lodash.clonedeep');
const { replaceZeroAddressShorthand } = AddressUtils; const { replaceZeroAddressShorthand } = AddressUtils;
import {getBlockchainDefaults, getContractDefaults} from './configDefaults';
const DEFAULT_CONFIG_PATH = 'config/'; const DEFAULT_CONFIG_PATH = 'config/';
const PACKAGE = require('../../../package.json'); const PACKAGE = require('../../../package.json');
@ -62,6 +64,11 @@ var Config = function(options) {
cb(); cb();
}); });
self.events.setCommandHandler("config:blockchainConfig:set", (config, cb) => {
self.blockchainConfig = config;
cb();
});
self.events.setCommandHandler("config:contractsFiles", (cb) => { self.events.setCommandHandler("config:contractsFiles", (cb) => {
cb(self.contractsFiles); cb(self.contractsFiles);
}); });
@ -217,38 +224,42 @@ Config.prototype._updateBlockchainCors = function(){
} }
}; };
Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, enabledByDefault) { Config.prototype._loadConfigFile = function (configFilePath, defaultConfig, enabledByDefault) {
if (!configFilePath) { if (!configFilePath) {
let configToReturn = defaultConfig['default'] || {}; const configToReturn = defaultConfig['default'] || {};
configToReturn.enabled = enabledByDefault || false; configToReturn.enabled = enabledByDefault || false;
return configToReturn; return configToReturn;
} }
// due to embark.json; TODO: refactor this
configFilePath = configFilePath.replace('.json','').replace('.js', ''); configFilePath = configFilePath.replace('.json','').replace('.js', '');
if (!fs.existsSync(configFilePath + '.js') && !fs.existsSync(configFilePath + '.json')) {
// TODO: remove this if
if (this.logger) {
this.logger.warn(__("no config file found at %s using default config", configFilePath));
}
return defaultConfig['default'] || {};
}
let config; let config;
if (fs.existsSync(configFilePath + '.js')) { if (fs.existsSync(configFilePath + '.js')) {
delete require.cache[configFilePath + '.js']; delete require.cache[configFilePath + '.js'];
config = require(configFilePath + '.js'); config = require(configFilePath + '.js');
} else { } else if (fs.existsSync(configFilePath + '.json')) {
config = fs.readJSONSync(configFilePath + '.json'); config = fs.readJSONSync(configFilePath + '.json');
} else {
this.logger.warn(__("no config file found at %s using default config", configFilePath));
return defaultConfig['default'] || {};
} }
return config;
};
Config.prototype._doMergeConfig = function(config, defaultConfig, env) {
let configObject = recursiveMerge(defaultConfig, config); let configObject = recursiveMerge(defaultConfig, config);
if (env) { if (env) {
return recursiveMerge(configObject['default'] || {}, configObject[env]); return recursiveMerge(configObject['default'] || {}, configObject[env]);
} else if (env !== false) {
this.logger.warn(__("No environment called %s found. Using defaults.", env));
} }
return configObject; return configObject;
}; };
Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, enabledByDefault) {
const config = this._loadConfigFile(configFilePath, defaultConfig, enabledByDefault);
return this._doMergeConfig(config, defaultConfig, env, enabledByDefault);
};
Config.prototype._getFileOrObject = function(object, filePath, property) { Config.prototype._getFileOrObject = function(object, filePath, property) {
if (typeof object === 'object') { if (typeof object === 'object') {
return object[property] ? dappPath(object[property]) : object[property]; return object[property] ? dappPath(object[property]) : object[property];
@ -256,21 +267,47 @@ Config.prototype._getFileOrObject = function(object, filePath, property) {
return dappPath(object, filePath); return dappPath(object, filePath);
}; };
/*eslint complexity: ["error", 30]*/
Config.prototype.loadBlockchainConfigFile = function() { Config.prototype.loadBlockchainConfigFile = function() {
var configObject = { const blockchainDefaults = getBlockchainDefaults(this.env);
default: { const configFilePath = this._getFileOrObject(this.configDir, 'blockchain', 'blockchain');
enabled: true,
ethereumClientName: constants.blockchain.clients.geth, const userConfig = this._loadConfigFile(configFilePath, blockchainDefaults, true);
rpcCorsDomain: "auto", const envConfig = userConfig[this.env];
wsOrigins: "auto",
proxy: true, if (envConfig) {
datadir: '.embark/' + this.env + '/datadir' if (envConfig.clientConfig) {
Object.assign(envConfig, envConfig.clientConfig);
delete envConfig.clientConfig;
}
switch (envConfig.miningMode) {
case 'dev': envConfig.isDev = true; break;
case 'auto': envConfig.isDev = false; envConfig.mineWhenNeeded = true; break;
case 'always': envConfig.isDev = false; envConfig.mineWhenNeeded = false; envConfig.mine = true; break;
case 'off': envConfig.isDev = false; envConfig.mineWhenNeeded = false; envConfig.mine = false; break;
default: envConfig.isDev = false;
}
if (envConfig.cors) {
const autoIndex = envConfig.cors.indexOf('auto');
envConfig.rpcCorsDomain = {};
envConfig.wsOrigins = {};
if (autoIndex > -1) {
envConfig.rpcCorsDomain.auto = true;
envConfig.wsOrigins.auto = true;
envConfig.cors.splice(autoIndex, 1);
} else {
envConfig.rpcCorsDomain.auto = false;
envConfig.wsOrigins.auto = false;
}
envConfig.rpcCorsDomain.additionalCors = envConfig.cors;
envConfig.wsOrigins.additionalCors = envConfig.cors;
delete envConfig.cors;
} }
};
let configFilePath = this._getFileOrObject(this.configDir, 'blockchain', 'blockchain'); userConfig[this.env] = envConfig;
}
this.blockchainConfig = this._mergeConfig(configFilePath, configObject, this.env, true); this.blockchainConfig = this._doMergeConfig(userConfig, blockchainDefaults, this.env);
if (!configFilePath) { if (!configFilePath) {
this.blockchainConfig.default = true; this.blockchainConfig.default = true;
} }
@ -291,6 +328,19 @@ Config.prototype.loadBlockchainConfigFile = function() {
}); });
} }
if (!this.blockchainConfig.endpoint) {
const urlConfig = (this.blockchainConfig.wsHost) ? {
host: this.blockchainConfig.wsHost,
port: this.blockchainConfig.wsPort,
type: 'ws'
} : {
host: this.blockchainConfig.rpcHost,
port: this.blockchainConfig.rpcPort,
type: 'rpc'
};
this.blockchainConfig.endpoint = buildUrlFromConfig(urlConfig);
}
if ( if (
!this.shownNoAccountConfigMsg && !this.shownNoAccountConfigMsg &&
(/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) && (/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) &&
@ -333,31 +383,9 @@ Config.prototype.loadBlockchainConfigFile = function() {
}; };
Config.prototype.loadContractsConfigFile = function() { Config.prototype.loadContractsConfigFile = function() {
var defaultVersions = { let configObject = getContractDefaults(this.embarkConfig.versions);
"web3": "1.0.0-beta",
"solc": "0.5.0"
};
var versions = recursiveMerge(defaultVersions, this.embarkConfig.versions || {});
var configObject = { const contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs');
"default": {
"versions": versions,
"deployment": {
"host": "localhost", "port": 8545, "type": "rpc"
},
"dappConnection": [
"$WEB3",
"localhost:8545"
],
"dappAutoEnable": true,
"strategy": constants.deploymentStrategy.implicit,
"gas": "auto",
"contracts": {
}
}
};
var contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs');
contractsConfigs.forEach(function(pluginConfig) { contractsConfigs.forEach(function(pluginConfig) {
configObject = recursiveMerge(configObject, pluginConfig); configObject = recursiveMerge(configObject, pluginConfig);
}); });
@ -367,13 +395,6 @@ Config.prototype.loadContractsConfigFile = function() {
if (newContractsConfig.gas.match(unitRegex)) { if (newContractsConfig.gas.match(unitRegex)) {
newContractsConfig.gas = getWeiBalanceFromString(newContractsConfig.gas, web3); newContractsConfig.gas = getWeiBalanceFromString(newContractsConfig.gas, web3);
} }
if (newContractsConfig.deployment && 'accounts' in newContractsConfig.deployment) {
newContractsConfig.deployment.accounts.forEach((account) => {
if (account.balance && account.balance.match(unitRegex)) {
account.balance = getWeiBalanceFromString(account.balance, web3);
}
});
}
newContractsConfig = prepareContractsConfig(newContractsConfig); newContractsConfig = prepareContractsConfig(newContractsConfig);

View File

@ -0,0 +1,57 @@
import {recursiveMerge} from "embark-utils";
const constants = require('embark-core/constants');
export function getBlockchainDefaults(env) {
return {
default: {
enabled: true,
client: constants.blockchain.clients.geth,
proxy: true,
datadir: `.embark/${env}/datadir`,
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: {
auto: true,
additionalCors: []
},
wsRPC: true,
wsOrigins: {
auto: true,
additionalCors: []
},
wsHost: "localhost",
wsPort: 8546,
networkType: "custom",
isDev: false,
mineWhenNeeded: false,
nodiscover: true,
maxpeers: 0,
targetGasLimit: 8000000,
simulatorBlocktime: 0
}
};
}
export function getContractDefaults(embarkConfigVersions) {
const defaultVersions = {
"web3": "1.0.0-beta",
"solc": "0.5.0"
};
const versions = recursiveMerge(defaultVersions, embarkConfigVersions || {});
return {
"default": {
"versions": versions,
"dappConnection": [
"$WEB3",
"localhost:8545"
],
"dappAutoEnable": true,
"strategy": constants.deploymentStrategy.implicit,
"gas": "auto",
"deploy": {
}
}
};
}

View File

@ -17,7 +17,7 @@ describe('embark.Blockchain', function() {
const expectedConfig = { const expectedConfig = {
networkType: 'custom', networkType: 'custom',
genesisBlock: false, genesisBlock: false,
ethereumClientName: 'geth', client: 'geth',
ethereumClientBin: 'geth', ethereumClientBin: 'geth',
datadir: dappPath(".embark/development/datadir"), datadir: dappPath(".embark/development/datadir"),
mineWhenNeeded: false, mineWhenNeeded: false,
@ -56,7 +56,7 @@ describe('embark.Blockchain', function() {
let config = { let config = {
networkType: 'livenet', networkType: 'livenet',
genesisBlock: 'foo/bar/genesis.json', genesisBlock: 'foo/bar/genesis.json',
ethereumClientName: 'parity', client: 'parity',
ethereumClientBin: 'parity', ethereumClientBin: 'parity',
datadir: '/foo/datadir/', datadir: '/foo/datadir/',
mineWhenNeeded: true, mineWhenNeeded: true,
@ -98,7 +98,7 @@ describe('embark.Blockchain', function() {
let expectedConfig = { let expectedConfig = {
networkType: 'livenet', networkType: 'livenet',
genesisBlock: 'foo/bar/genesis.json', genesisBlock: 'foo/bar/genesis.json',
ethereumClientName: 'parity', client: 'parity',
ethereumClientBin: 'parity', ethereumClientBin: 'parity',
datadir: '/foo/datadir/', datadir: '/foo/datadir/',
mineWhenNeeded: true, mineWhenNeeded: true,

View File

@ -5,7 +5,6 @@ const Plugins = require('../lib/core/plugins.js');
const assert = require('assert'); const assert = require('assert');
const TestLogger = require('../lib/utils/test_logger'); const TestLogger = require('../lib/utils/test_logger');
const Events = require('../lib/core/events'); const Events = require('../lib/core/events');
const fs = require('../lib/core/fs');
describe('embark.Config', function () { describe('embark.Config', function () {
let config = new Config({ let config = new Config({
@ -21,23 +20,33 @@ describe('embark.Config', function () {
config.loadBlockchainConfigFile(); config.loadBlockchainConfigFile();
let expectedConfig = { let expectedConfig = {
"enabled": true, "enabled": true,
"ethereumClientName": "geth", "client": "geth",
"networkType": "custom",
"genesisBlock": "config/development/genesis.json",
"datadir": ".embark/development/datadir",
"isDev": false,
"mineWhenNeeded": true,
"nodiscover": true,
"proxy": true, "proxy": true,
"datadir": ".embark/myenv/datadir",
"rpcHost": "localhost", "rpcHost": "localhost",
"rpcPort": 8545, "rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000", "rpcCorsDomain": {
"wsOrigins": "auto", "auto": true,
"accounts": [ "additionalCors": []
{ },
"password": "config/development/password" "wsRPC": true,
} "wsOrigins": {
] "auto": true,
"additionalCors": []
},
"wsHost": "localhost",
"wsPort": 8546,
"networkType": "custom",
"isDev": false,
"mineWhenNeeded": false,
"nodiscover": true,
"maxpeers": 0,
"targetGasLimit": 8000000,
"simulatorBlocktime": 0,
"clientMode": {
"miningMode": "auto"
},
"endpoint": "ws://localhost:8546"
}; };
assert.deepEqual(config.blockchainConfig, expectedConfig); assert.deepEqual(config.blockchainConfig, expectedConfig);
@ -46,26 +55,41 @@ describe('embark.Config', function () {
it('should convert Ether units', function () { it('should convert Ether units', function () {
let expectedConfig = { let expectedConfig = {
"enabled": true, "enabled": true,
"ethereumClientName": "geth", "client": "geth",
"networkType": "custom",
"genesisBlock": "config/development/genesis.json",
"datadir": ".embark/development/datadir",
"isDev": false,
"targetGasLimit": "300000",
"gasPrice": "8000000",
"mineWhenNeeded": true,
"nodiscover": true,
"proxy": true, "proxy": true,
"datadir": ".embark/unitenv/datadir",
"rpcHost": "localhost", "rpcHost": "localhost",
"rpcPort": 8545, "rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000", "rpcCorsDomain": {
"wsOrigins": "auto", "auto": true,
"additionalCors": []
},
"wsRPC": true,
"wsOrigins": {
"auto": true,
"additionalCors": []
},
"wsHost": "localhost",
"wsPort": 8546,
"networkType": "custom",
"isDev": false,
"mineWhenNeeded": false,
"nodiscover": true,
"maxpeers": 0,
"targetGasLimit": 8000000,
"simulatorBlocktime": 0,
"clientMode": {
"miningMode": "auto",
"gasPrice": "8 Mwei",
"targetGasLimit": "300 Kwei"
},
"accounts": [ "accounts": [
{ {
"password": "config/development/password", "password": "config/development/password",
"balance": "3000000000000000000" "balance": "3000000000000000000"
} }
] ],
"endpoint": "ws://localhost:8546"
}; };
let config = new Config({ let config = new Config({
@ -83,26 +107,41 @@ describe('embark.Config', function () {
it('should accept unitless gas values', function () { it('should accept unitless gas values', function () {
let expectedConfig = { let expectedConfig = {
"enabled": true, "enabled": true,
"ethereumClientName": "geth", "client": "geth",
"networkType": "custom",
"genesisBlock": "config/development/genesis.json",
"datadir": ".embark/development/datadir",
"isDev": false,
"targetGasLimit": "20000000",
"gasPrice": "8000000",
"mineWhenNeeded": true,
"nodiscover": true,
"proxy": true, "proxy": true,
"datadir": ".embark/unitlessenv/datadir",
"rpcHost": "localhost", "rpcHost": "localhost",
"rpcPort": 8545, "rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000", "rpcCorsDomain": {
"wsOrigins": "auto", "auto": true,
"additionalCors": []
},
"wsRPC": true,
"wsOrigins": {
"auto": true,
"additionalCors": []
},
"wsHost": "localhost",
"wsPort": 8546,
"networkType": "custom",
"isDev": false,
"mineWhenNeeded": false,
"nodiscover": true,
"maxpeers": 0,
"targetGasLimit": 8000000,
"simulatorBlocktime": 0,
"clientMode": {
"miningMode": "auto",
"gasPrice": "8000000",
"targetGasLimit": "20000000"
},
"accounts": [ "accounts": [
{ {
"password": "config/development/password", "password": "config/development/password",
"balance": "3000000000000000000" "balance": "3000000000000000000"
} }
] ],
"endpoint": "ws://localhost:8546"
}; };
let config = new Config({ let config = new Config({
@ -123,7 +162,6 @@ describe('embark.Config', function () {
config.loadContractsConfigFile(); config.loadContractsConfigFile();
let expectedConfig = { let expectedConfig = {
versions: {'web3': '1.0.0-beta', solc: '0.5.0'}, versions: {'web3': '1.0.0-beta', solc: '0.5.0'},
deployment: {host: 'localhost', port: 8545, type: 'rpc', "accounts": [{"mnemonic": "12 word mnemonic", "balance": "5000000000"}]},
dappConnection: ['$WEB3', 'localhost:8545'], dappConnection: ['$WEB3', 'localhost:8545'],
dappAutoEnable: true, dappAutoEnable: true,
"gas": "400000", "gas": "400000",
@ -146,7 +184,6 @@ describe('embark.Config', function () {
it('should replace occourences of `0x0` with full zero addresses', () => { it('should replace occourences of `0x0` with full zero addresses', () => {
let expectedConfig = { let expectedConfig = {
versions: {'web3': '1.0.0-beta', solc: '0.5.0'}, versions: {'web3': '1.0.0-beta', solc: '0.5.0'},
deployment: {host: 'localhost', port: 8545, type: 'rpc'},
dappConnection: ['$WEB3', 'localhost:8545'], dappConnection: ['$WEB3', 'localhost:8545'],
dappAutoEnable: true, dappAutoEnable: true,
"gas": "auto", "gas": "auto",

View File

@ -1,32 +1,15 @@
{ {
"myenv": { "myenv": {
"networkType": "custom", "clientMode": {
"genesisBlock": "config/development/genesis.json", "miningMode": "auto"
"datadir": ".embark/development/datadir", }
"isDev": false,
"mineWhenNeeded": true,
"nodiscover": true,
"rpcHost": "localhost",
"rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000",
"accounts": [
{
"password": "config/development/password"
}
]
}, },
"unitenv": { "unitenv": {
"networkType": "custom", "clientMode": {
"genesisBlock": "config/development/genesis.json", "miningMode": "auto",
"datadir": ".embark/development/datadir", "gasPrice": "8 Mwei",
"isDev": false, "targetGasLimit": "300 Kwei"
"gasPrice": "8 Mwei", },
"mineWhenNeeded": true,
"nodiscover": true,
"rpcHost": "localhost",
"rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000",
"targetGasLimit": "300 Kwei",
"accounts": [ "accounts": [
{ {
"password": "config/development/password", "password": "config/development/password",
@ -35,17 +18,12 @@
] ]
}, },
"unitlessenv": { "unitlessenv": {
"networkType": "custom",
"genesisBlock": "config/development/genesis.json", "clientMode": {
"datadir": ".embark/development/datadir", "miningMode": "auto",
"isDev": false,
"gasPrice": "8000000", "gasPrice": "8000000",
"mineWhenNeeded": true, "targetGasLimit": "20000000"
"nodiscover": true, },
"rpcHost": "localhost",
"rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000",
"targetGasLimit": "20000000",
"accounts": [ "accounts": [
{ {
"password": "config/development/password", "password": "config/development/password",
@ -54,15 +32,10 @@
] ]
}, },
"testnet": { "testnet": {
"networkType": "testnet", "networkType": "testnet"
"rpcHost": "localhost",
"rpcPort": 8545
}, },
"livenet": { "livenet": {
"networkType": "livenet", "networkType": "livenet",
"rpcHost": "localhost",
"rpcPort": 8545,
"rpcCorsDomain": "http://localhost:8000",
"accounts": [ "accounts": [
{ {
"password": "config/development/password" "password": "config/development/password"
@ -70,9 +43,6 @@
] ]
}, },
"privatenet": { "privatenet": {
"networkType": "custom",
"rpcHost": "localhost",
"rpcPort": 8545,
"datadir": "yourdatadir", "datadir": "yourdatadir",
"networkId": "123", "networkId": "123",
"nodes": [] "nodes": []

View File

@ -1,7 +1,7 @@
{ {
"default": { "default": {
"gas": "auto", "gas": "auto",
"contracts": { "deploy": {
"SimpleStorage": { "SimpleStorage": {
"args": [ "args": [
100 100
@ -11,7 +11,7 @@
}, },
"zeroaddress": { "zeroaddress": {
"gas": "auto", "gas": "auto",
"contracts": { "deploy": {
"SimpleStorage": { "SimpleStorage": {
"address": "0x0", "address": "0x0",
"args": [ "args": [
@ -30,7 +30,7 @@
}, },
"myenv": { "myenv": {
"gas": "400 Kwei", "gas": "400 Kwei",
"contracts": { "deploy": {
"SimpleStorage": { "SimpleStorage": {
"gas": "123 Kwei", "gas": "123 Kwei",
"gasPrice": "1 Kwei" "gasPrice": "1 Kwei"
@ -40,14 +40,6 @@
200 200
] ]
} }
},
"deployment": {
"accounts": [
{
"mnemonic": "12 word mnemonic",
"balance": "5000 Mwei"
}
]
} }
} }
} }

View File

@ -29,7 +29,7 @@ module.exports = {
wsPort: 8546 wsPort: 8546
}, },
development: { development: {
ethereumClientName: "geth", client: "geth",
ethereumClientBin: "geth", ethereumClientBin: "geth",
datadir: ".embark/development/datadir", datadir: ".embark/development/datadir",
networkType: "custom", networkType: "custom",
@ -61,7 +61,7 @@ Option | Type: `default` | Value
`wsOrigins` | object | Same as `rpcCorsDomain`, but for the Websocket server `wsOrigins` | object | Same as `rpcCorsDomain`, but for the Websocket server
`wsHost` | string: `localhost` | Same as `rpcHost`, but for the Websocket server `wsHost` | string: `localhost` | Same as `rpcHost`, but for the Websocket server
`wsPort` | number: `8546` | Same as `rpcPort`, but for the Websocket server `wsPort` | number: `8546` | Same as `rpcPort`, but for the Websocket server
`ethereumClientName` | string: `geth` | Client to use for the Ethereum node. Currently supported: `geth` and `parity` `client` | string: `geth` | Client to use for the Ethereum node. Currently supported: `geth` and `parity`
`ethereumClientBin` | string: `geth` | Path to the client binary. By default, Embark uses the client name as an executable (if it is in the PATH) `ethereumClientBin` | string: `geth` | Path to the client binary. By default, Embark uses the client name as an executable (if it is in the PATH)
`datadir` | string | Directory where to put the Node's data (eg: keystores) `datadir` | string | Directory where to put the Node's data (eg: keystores)
`networkType` | string: `custom` | Can be: `testnet`, `rinkeby`, `kovan` or custom, in which case, it will use the specified `networkId` `networkType` | string: `custom` | Can be: `testnet`, `rinkeby`, `kovan` or custom, in which case, it will use the specified `networkId`