mirror of https://github.com/embarklabs/embark.git
refactor: simplify blockchain and contract configs
Implements https://notes.status.im/yrfs8w87SZKfE2ft6MoFIg#
This commit is contained in:
parent
1491028665
commit
af8a8ff4d0
|
@ -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 = {
|
||||
// applies to all environments
|
||||
// default 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
|
||||
client: "geth" // Can be geth or parity (default:geth)
|
||||
},
|
||||
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
|
||||
// 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
|
||||
numAddresses: "1", // Number of addresses/accounts (defaults to 1)
|
||||
password: "config/development/devpassword" // 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
|
||||
password: "config/development/password" // Password file for the accounts
|
||||
}
|
||||
],
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
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: {
|
||||
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
|
||||
client: "parity",
|
||||
genesisBlock: "config/privatenet/genesis-parity.json",
|
||||
datadir: ".embark/privatenet/datadir",
|
||||
mineWhenNeeded: false,
|
||||
nodiscover: true,
|
||||
maxpeers: 0,
|
||||
proxy: true,
|
||||
accounts: [
|
||||
{
|
||||
nodeAccounts: true,
|
||||
password: "config/privatenet/password"
|
||||
}
|
||||
],
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run testnet" and/or "embark blockchain testnet"
|
||||
testnet: {
|
||||
networkType: "testnet",
|
||||
networkType: "testnet", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
|
||||
syncMode: "light",
|
||||
accounts: [
|
||||
{
|
||||
|
@ -128,13 +60,9 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
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
|
||||
}
|
||||
]*/
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
|
@ -51,7 +23,7 @@ module.exports = {
|
|||
// contracts section.
|
||||
// strategy: 'implicit',
|
||||
|
||||
contracts: {
|
||||
deploy: {
|
||||
// example:
|
||||
//SimpleStorage: {
|
||||
// args: [ 100 ]
|
||||
|
@ -71,21 +43,17 @@ module.exports = {
|
|||
|
||||
// merges with the settings in default
|
||||
// used with "embark run privatenet"
|
||||
privatenet: {
|
||||
},
|
||||
privatenet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run testnet"
|
||||
testnet: {
|
||||
},
|
||||
testnet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run livenet"
|
||||
livenet: {
|
||||
},
|
||||
livenet: {}
|
||||
|
||||
// you can name an environment with specific settings and then specify with
|
||||
// "embark run custom_name" or "embark blockchain custom_name"
|
||||
//custom_name: {
|
||||
//}
|
||||
// custom_name: {}
|
||||
};
|
||||
|
|
|
@ -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 = {
|
||||
// applies to all environments
|
||||
// default 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
|
||||
client: "geth" // Can be geth or parity (default:geth)
|
||||
},
|
||||
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
|
||||
// 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
|
||||
numAddresses: "1", // Number of addresses/accounts (defaults to 1)
|
||||
password: "config/development/devpassword" // 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
|
||||
password: "config/development/password" // Password file for the accounts
|
||||
}
|
||||
],
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
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: {
|
||||
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
|
||||
client: "parity",
|
||||
genesisBlock: "config/privatenet/genesis-parity.json",
|
||||
datadir: ".embark/privatenet/datadir",
|
||||
mineWhenNeeded: false,
|
||||
nodiscover: true,
|
||||
maxpeers: 0,
|
||||
proxy: true,
|
||||
accounts: [
|
||||
{
|
||||
nodeAccounts: true,
|
||||
password: "config/privatenet/password"
|
||||
}
|
||||
],
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run testnet" and/or "embark blockchain testnet"
|
||||
testnet: {
|
||||
networkType: "testnet",
|
||||
networkType: "testnet", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
|
||||
syncMode: "light",
|
||||
accounts: [
|
||||
{
|
||||
|
@ -128,13 +60,9 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
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
|
||||
}
|
||||
]*/
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
|
@ -51,7 +23,7 @@ module.exports = {
|
|||
// contracts section.
|
||||
// strategy: 'implicit',
|
||||
|
||||
contracts: {
|
||||
deploy: {
|
||||
SimpleStorage: {
|
||||
fromIndex: 0,
|
||||
args: [100]
|
||||
|
@ -71,21 +43,17 @@ module.exports = {
|
|||
|
||||
// merges with the settings in default
|
||||
// used with "embark run privatenet"
|
||||
privatenet: {
|
||||
},
|
||||
privatenet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run testnet"
|
||||
testnet: {
|
||||
},
|
||||
testnet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run livenet"
|
||||
livenet: {
|
||||
},
|
||||
livenet: {}
|
||||
|
||||
// you can name an environment with specific settings and then specify with
|
||||
// "embark run custom_name" or "embark blockchain custom_name"
|
||||
//custom_name: {
|
||||
//}
|
||||
// custom_name: {}
|
||||
};
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
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
|
||||
}
|
||||
]*/
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
|
@ -51,9 +23,9 @@ module.exports = {
|
|||
// contracts section.
|
||||
// strategy: 'implicit',
|
||||
|
||||
contracts: {
|
||||
// example:
|
||||
deploy: {
|
||||
// SimpleStorage: {
|
||||
// fromIndex: 0,
|
||||
// args: [100]
|
||||
// }
|
||||
}
|
||||
|
@ -71,21 +43,17 @@ module.exports = {
|
|||
|
||||
// merges with the settings in default
|
||||
// used with "embark run privatenet"
|
||||
privatenet: {
|
||||
},
|
||||
privatenet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run testnet"
|
||||
testnet: {
|
||||
},
|
||||
testnet: {},
|
||||
|
||||
// merges with the settings in default
|
||||
// used with "embark run livenet"
|
||||
livenet: {
|
||||
},
|
||||
livenet: {}
|
||||
|
||||
// you can name an environment with specific settings and then specify with
|
||||
// "embark run custom_name" or "embark blockchain custom_name"
|
||||
//custom_name: {
|
||||
//}
|
||||
// custom_name: {}
|
||||
};
|
||||
|
|
|
@ -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: {
|
||||
//}
|
||||
};
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,5 @@
|
|||
module.exports = {
|
||||
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: [
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8550",
|
||||
|
@ -19,7 +8,7 @@ module.exports = {
|
|||
"$WEB3"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
deploy: {
|
||||
Ownable: {
|
||||
deploy: false
|
||||
},
|
||||
|
@ -88,7 +77,7 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
development: {
|
||||
contracts: {
|
||||
deploy: {
|
||||
MyToken2: {
|
||||
instanceOf: "Token",
|
||||
args: [2000]
|
||||
|
|
|
@ -6,7 +6,7 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
|||
let accounts;
|
||||
|
||||
config({
|
||||
deployment: {
|
||||
blockchain: {
|
||||
"accounts": [
|
||||
{
|
||||
"mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
|
||||
|
@ -15,6 +15,7 @@ config({
|
|||
]
|
||||
},
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
},
|
||||
|
@ -22,6 +23,7 @@ config({
|
|||
args: ["$SimpleStorage"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (err, theAccounts) => {
|
||||
accounts = theAccounts;
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ const MyToken2 = require('Embark/contracts/MyToken2');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"Token": {
|
||||
deploy: false,
|
||||
args: [1000]
|
||||
|
@ -20,6 +21,7 @@ config({
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contract("SomeContract", function() {
|
||||
|
|
|
@ -7,7 +7,7 @@ let gasPrice = 1;
|
|||
let accounts;
|
||||
|
||||
config({
|
||||
deployment: {
|
||||
blockchain: {
|
||||
accounts: [
|
||||
// you can configure custom accounts with a custom balance
|
||||
// see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts
|
||||
|
@ -18,6 +18,7 @@ config({
|
|||
]
|
||||
},
|
||||
contracts: {
|
||||
deploy: {
|
||||
"Token": {
|
||||
deploy: false,
|
||||
args: [1000]
|
||||
|
@ -36,6 +37,7 @@ config({
|
|||
args: [100]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (_err, web3_accounts) => {
|
||||
accounts = web3_accounts;
|
||||
});
|
||||
|
|
|
@ -5,10 +5,12 @@ const EmbarkJS = require('Embark/EmbarkJS');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("EmbarkJS functions", function() {
|
||||
|
|
|
@ -4,10 +4,12 @@ const AnotherStorage = require('Embark/contracts/AnotherStorage');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
AnotherStorage: {
|
||||
args: ['$ERC20']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ const Test2 = require('Embark/contracts/Test2');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
"Test2": {
|
||||
},
|
||||
"ZAMyLib": {
|
||||
},
|
||||
deploy: {
|
||||
"Test2": {},
|
||||
"ZAMyLib": {},
|
||||
"ZAMyLib2": {
|
||||
"deploy": true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contract("Test", function() {
|
||||
|
|
|
@ -6,6 +6,7 @@ const EmbarkJS = require('Embark/EmbarkJS');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"Token": {
|
||||
deploy: false,
|
||||
args: [1000]
|
||||
|
@ -18,6 +19,7 @@ config({
|
|||
args: [2000]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("ENS functions", function() {
|
||||
|
|
|
@ -5,6 +5,7 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
},
|
||||
|
@ -12,6 +13,7 @@ config({
|
|||
args: ["$SimpleStorage"]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -5,11 +5,13 @@ const {Utils} = require('Embark/EmbarkJS');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100],
|
||||
onDeploy: ["SimpleStorage.methods.setRegistar('$SimpleStorage').send()"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (err, theAccounts) => {
|
||||
accounts = theAccounts;
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ const SomeContract = require('Embark/contracts/SomeContract');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
ZAMyLib: {},
|
||||
SimpleStorage: {
|
||||
args: [100]
|
||||
|
@ -48,6 +49,7 @@ config({
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("Token", function () {
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
"versions": {
|
||||
"solc": "0.4.24"
|
||||
},
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"ws://localhost:8546",
|
||||
|
@ -16,7 +11,7 @@
|
|||
"http://localhost:8550"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"Ownable": {
|
||||
"deploy": false
|
||||
},
|
||||
|
@ -73,7 +68,7 @@
|
|||
]
|
||||
},
|
||||
"development": {
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"MyToken2": {
|
||||
"instanceOf": "Token",
|
||||
"args": [2000]
|
||||
|
|
|
@ -6,6 +6,7 @@ let accounts;
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
},
|
||||
|
@ -13,6 +14,7 @@ config({
|
|||
args: ["$SimpleStorage", "embark.eth"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (err, accs) => {
|
||||
accounts = accs;
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ const MyToken2 = require('Embark/contracts/MyToken2');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
},
|
||||
|
@ -24,6 +25,7 @@ config({
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contract("SomeContract", function() {
|
||||
|
|
|
@ -4,14 +4,14 @@ const Test2 = require('Embark/contracts/Test2');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
"Test2": {
|
||||
},
|
||||
"ZAMyLib": {
|
||||
},
|
||||
deploy: {
|
||||
"Test2": {},
|
||||
"ZAMyLib": {},
|
||||
"ZAMyLib2": {
|
||||
"deploy": true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contract("Test", function() {
|
||||
|
|
|
@ -4,10 +4,12 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contract("SimpleStorage", function () {
|
||||
|
|
|
@ -8,6 +8,7 @@ const Test = require('Embark/contracts/Test');
|
|||
|
||||
config({
|
||||
contracts: {
|
||||
deploy: {
|
||||
ZAMyLib: {},
|
||||
SimpleStorage: {
|
||||
args: [100]
|
||||
|
@ -46,6 +47,7 @@ config({
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("Token", function () {
|
||||
|
|
|
@ -7,11 +7,12 @@ const constants = require('embark-core/constants');
|
|||
const embarkJsUtils = require('embarkjs').Utils;
|
||||
const {bigNumberify} = require('ethers/utils/bignumber');
|
||||
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 BLOCK_LIMIT = 100;
|
||||
const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000';
|
||||
|
||||
// TODO: consider another name, this is the blockchain connector
|
||||
class BlockchainConnector {
|
||||
|
@ -24,7 +25,6 @@ class BlockchainConnector {
|
|||
this.config = embark.config;
|
||||
this.web3 = options.web3;
|
||||
this.isDev = options.isDev;
|
||||
this.web3Endpoint = '';
|
||||
this.isWeb3Ready = false;
|
||||
this.wait = options.wait;
|
||||
this.contractsSubscriptions = [];
|
||||
|
@ -97,7 +97,11 @@ class BlockchainConnector {
|
|||
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) {
|
||||
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.');
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
this.web3Endpoint = buildUrl(protocol, host, port);
|
||||
const web3Endpoint = buildUrl(protocol, host, port);
|
||||
|
||||
const providerOptions = {
|
||||
web3: this.web3,
|
||||
accountsConfig: accounts,
|
||||
blockchainConfig: this.config.blockchainConfig,
|
||||
logger: this.logger,
|
||||
isDev: this.isDev,
|
||||
type: type,
|
||||
web3Endpoint: self.web3Endpoint,
|
||||
web3Endpoint,
|
||||
events: this.events,
|
||||
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() {
|
||||
this.registerWeb3Object(() => {
|
||||
this.isWeb3Ready = true;
|
||||
|
|
|
@ -9,7 +9,6 @@ const ethUtil = require('ethereumjs-util');
|
|||
class Provider {
|
||||
constructor(options) {
|
||||
this.web3 = options.web3;
|
||||
this.accountsConfig = options.accountsConfig;
|
||||
this.blockchainConfig = options.blockchainConfig;
|
||||
this.type = options.type;
|
||||
this.web3Endpoint = options.web3Endpoint;
|
||||
|
@ -76,11 +75,7 @@ class Provider {
|
|||
}
|
||||
|
||||
try {
|
||||
self.blockchainAccounts = 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);
|
||||
self.accounts = AccountParser.parseAccountsConfig(self.blockchainConfig.accounts, self.web3, dappPath(), self.logger, accounts);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ var Blockchain = function(userConfig, clientClass) {
|
|||
|
||||
this.config = {
|
||||
silent: this.userConfig.silent,
|
||||
ethereumClientName: this.userConfig.ethereumClientName,
|
||||
ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.ethereumClientName,
|
||||
client: this.userConfig.client,
|
||||
ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client,
|
||||
networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE,
|
||||
networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID,
|
||||
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') {
|
||||
this.isDev = true;
|
||||
} else {
|
||||
|
@ -461,12 +461,12 @@ export function BlockchainClient(userConfig, options) {
|
|||
options.logger.info("===> " + __("warning: running default config on a non-development environment"));
|
||||
}
|
||||
// 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 (options.clientName) userConfig.ethereumClientName = options.clientName;
|
||||
if (options.clientName) userConfig.client = options.clientName;
|
||||
// Choose correct client instance based on clientName
|
||||
let clientClass;
|
||||
switch (userConfig.ethereumClientName) {
|
||||
switch (userConfig.client) {
|
||||
case constants.blockchain.clients.geth:
|
||||
clientClass = GethClient;
|
||||
break;
|
||||
|
@ -475,7 +475,7 @@ export function BlockchainClient(userConfig, options) {
|
|||
clientClass = ParityClient;
|
||||
break;
|
||||
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);
|
||||
}
|
||||
userConfig.isDev = (userConfig.isDev || userConfig.default);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { __ } from 'embark-i18n';
|
||||
const async = require('async');
|
||||
const { normalizeInput, buildUrlFromConfig } = require('embark-utils');
|
||||
const { normalizeInput, deconstructUrl } = require('embark-utils');
|
||||
const constants = require('embark-core/constants');
|
||||
import { BlockchainProcessLauncher } from './blockchainProcessLauncher';
|
||||
import { pingEndpoint } from './utils';
|
||||
|
@ -15,7 +15,6 @@ export default class BlockchainModule {
|
|||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.blockchainConfig = embark.config.blockchainConfig;
|
||||
this.contractsConfig = embark.config.contractsConfig;
|
||||
this.embark = embark;
|
||||
this.locale = options.locale;
|
||||
this.isDev = options.isDev;
|
||||
|
@ -41,7 +40,7 @@ export default class BlockchainModule {
|
|||
|
||||
if (!this.ipc.isServer()) return;
|
||||
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) {
|
||||
if (!self.contractsConfig || !self.contractsConfig.deployment || !self.contractsConfig.deployment.host) {
|
||||
if (!self.blockchainConfig || !self.blockchainConfig.endpoint) {
|
||||
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);
|
||||
}
|
||||
], function(err) {
|
||||
|
|
|
@ -19,6 +19,7 @@ export class Simulator {
|
|||
|
||||
let useProxy = this.blockchainConfig.proxy || false;
|
||||
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;
|
||||
let port = (options.port || configPort || 8545);
|
||||
port = parseInt(port, 10) + (useProxy ? constants.blockchain.servicePortOnProxy : 0);
|
||||
|
|
|
@ -172,7 +172,7 @@ class CodeGenerator {
|
|||
dappConnection: contractConfig.dappConnection,
|
||||
dappAutoEnable: contractConfig.dappAutoEnable,
|
||||
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) => {
|
||||
callback(err, path);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { __ } from 'embark-i18n';
|
||||
import { deconstructUrl, prepareContractsConfig, AccountParser } from 'embark-utils';
|
||||
import { deconstructUrl, prepareContractsConfig, buildUrl } from 'embark-utils';
|
||||
|
||||
const async = require('async');
|
||||
const web3Utils = require('web3-utils');
|
||||
import { GAS_LIMIT } from './constants';
|
||||
|
||||
const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000';
|
||||
|
||||
class Test {
|
||||
constructor(options) {
|
||||
this.options = options || {};
|
||||
|
@ -64,15 +62,6 @@ class Test {
|
|||
}
|
||||
|
||||
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')) {
|
||||
this.simOptions.type = 'vm';
|
||||
} else if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
|
||||
|
@ -87,9 +76,12 @@ class Test {
|
|||
Object.assign(this.simOptions, options);
|
||||
}
|
||||
|
||||
this.configObj.contractsConfig.deployment = this.simOptions;
|
||||
this.configObj.contractsConfig.deployment.coverage = this.options.coverage;
|
||||
this.events.request("config:contractsConfig:set", this.configObj.contractsConfig, () => {
|
||||
this.configObj.blockchainConfig.endpoint = this.simOptions.host ? buildUrl(this.simOptions.protocol, this.simOptions.host, this.simOptions.port, this.simOptions.type) : null;
|
||||
this.configObj.blockchainConfig.type = this.simOptions.type;
|
||||
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) => {
|
||||
if (err) {
|
||||
this.logger.error('Error restarting the blockchain connection');
|
||||
|
@ -137,9 +129,10 @@ class Test {
|
|||
}
|
||||
|
||||
checkDeploymentOptions(options, callback) {
|
||||
const self = this;
|
||||
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)) {
|
||||
return callback(__("contracts config error: unknown deployment type %s", type));
|
||||
|
@ -155,36 +148,21 @@ class Test {
|
|||
resetServices = true;
|
||||
}
|
||||
|
||||
this.events.request("blockchain:get", (web3) => {
|
||||
if (accounts) {
|
||||
try {
|
||||
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
} else {
|
||||
self.simOptions.accounts = null;
|
||||
}
|
||||
Object.assign(this.simOptions, {host, port, type, protocol});
|
||||
this.simOptions.accounts = accounts;
|
||||
|
||||
Object.assign(self.simOptions, {
|
||||
host,
|
||||
port,
|
||||
type
|
||||
});
|
||||
|
||||
if (!resetServices && !self.firstRunConfig) {
|
||||
if (!resetServices && !this.firstRunConfig) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
self.initWeb3Provider((err) => {
|
||||
this.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);
|
||||
});
|
||||
this.firstRunConfig = false;
|
||||
this.events.request("blockchain:ready", () => {
|
||||
this.events.request("code-generator:embarkjs:build", () => {
|
||||
this.events.request("runcode:embarkjs:reset", callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -280,11 +258,13 @@ class Test {
|
|||
|
||||
async _deploy(config, callback) {
|
||||
const self = this;
|
||||
let contractConfig = config.contracts || {};
|
||||
async.waterfall([
|
||||
function setConfig(next) {
|
||||
prepareContractsConfig(config);
|
||||
contractConfig = prepareContractsConfig(contractConfig);
|
||||
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) {
|
||||
self.events.request('blockchain:getAccounts', (err, accounts) => {
|
||||
|
|
|
@ -154,16 +154,20 @@ function toposort(graph) {
|
|||
}
|
||||
|
||||
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 {
|
||||
protocol: matches[1],
|
||||
host: matches[2],
|
||||
port: matches[3],
|
||||
type: matches[1] === 'ws' ? 'ws' : 'rpc'
|
||||
type: matches[1] === 'ws' || matches[1] === 'wss' ? 'ws' : 'rpc'
|
||||
};
|
||||
}
|
||||
|
||||
function prepareContractsConfig(config) {
|
||||
if (config.deploy) {
|
||||
config.contracts = config.deploy;
|
||||
delete config.deploy;
|
||||
}
|
||||
Object.keys(config.contracts).forEach((contractName) => {
|
||||
const gas = config.contracts[contractName].gas;
|
||||
const gasPrice = config.contracts[contractName].gasPrice;
|
||||
|
|
|
@ -2,7 +2,6 @@ import { __, setOrDetectLocale } from 'embark-i18n';
|
|||
import { diagramPath } from 'embark-utils';
|
||||
const program = require('commander');
|
||||
const EmbarkController = require('./cmd_controller.js');
|
||||
const fs = require('../lib/core/fs.js');
|
||||
|
||||
let embark = new EmbarkController();
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import {
|
|||
const cloneDeep = require('lodash.clonedeep');
|
||||
const { replaceZeroAddressShorthand } = AddressUtils;
|
||||
|
||||
import {getBlockchainDefaults, getContractDefaults} from './configDefaults';
|
||||
|
||||
const DEFAULT_CONFIG_PATH = 'config/';
|
||||
const PACKAGE = require('../../../package.json');
|
||||
|
||||
|
@ -62,6 +64,11 @@ var Config = function(options) {
|
|||
cb();
|
||||
});
|
||||
|
||||
self.events.setCommandHandler("config:blockchainConfig:set", (config, cb) => {
|
||||
self.blockchainConfig = config;
|
||||
cb();
|
||||
});
|
||||
|
||||
self.events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||
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) {
|
||||
let configToReturn = defaultConfig['default'] || {};
|
||||
const configToReturn = defaultConfig['default'] || {};
|
||||
configToReturn.enabled = enabledByDefault || false;
|
||||
return configToReturn;
|
||||
}
|
||||
|
||||
// due to embark.json; TODO: refactor this
|
||||
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;
|
||||
if (fs.existsSync(configFilePath + '.js')) {
|
||||
delete require.cache[configFilePath + '.js'];
|
||||
config = require(configFilePath + '.js');
|
||||
} else {
|
||||
} else if (fs.existsSync(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);
|
||||
|
||||
if (env) {
|
||||
return recursiveMerge(configObject['default'] || {}, configObject[env]);
|
||||
} else if (env !== false) {
|
||||
this.logger.warn(__("No environment called %s found. Using defaults.", env));
|
||||
}
|
||||
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) {
|
||||
if (typeof object === 'object') {
|
||||
return object[property] ? dappPath(object[property]) : object[property];
|
||||
|
@ -256,21 +267,47 @@ Config.prototype._getFileOrObject = function(object, filePath, property) {
|
|||
return dappPath(object, filePath);
|
||||
};
|
||||
|
||||
/*eslint complexity: ["error", 30]*/
|
||||
Config.prototype.loadBlockchainConfigFile = function() {
|
||||
var configObject = {
|
||||
default: {
|
||||
enabled: true,
|
||||
ethereumClientName: constants.blockchain.clients.geth,
|
||||
rpcCorsDomain: "auto",
|
||||
wsOrigins: "auto",
|
||||
proxy: true,
|
||||
datadir: '.embark/' + this.env + '/datadir'
|
||||
const blockchainDefaults = getBlockchainDefaults(this.env);
|
||||
const configFilePath = this._getFileOrObject(this.configDir, 'blockchain', 'blockchain');
|
||||
|
||||
const userConfig = this._loadConfigFile(configFilePath, blockchainDefaults, true);
|
||||
const envConfig = userConfig[this.env];
|
||||
|
||||
if (envConfig) {
|
||||
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) {
|
||||
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 (
|
||||
!this.shownNoAccountConfigMsg &&
|
||||
(/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) &&
|
||||
|
@ -333,31 +383,9 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
|||
};
|
||||
|
||||
Config.prototype.loadContractsConfigFile = function() {
|
||||
var defaultVersions = {
|
||||
"web3": "1.0.0-beta",
|
||||
"solc": "0.5.0"
|
||||
};
|
||||
var versions = recursiveMerge(defaultVersions, this.embarkConfig.versions || {});
|
||||
let configObject = getContractDefaults(this.embarkConfig.versions);
|
||||
|
||||
var configObject = {
|
||||
"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');
|
||||
const contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs');
|
||||
contractsConfigs.forEach(function(pluginConfig) {
|
||||
configObject = recursiveMerge(configObject, pluginConfig);
|
||||
});
|
||||
|
@ -367,13 +395,6 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
if (newContractsConfig.gas.match(unitRegex)) {
|
||||
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);
|
||||
|
||||
|
|
|
@ -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": {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
|
@ -17,7 +17,7 @@ describe('embark.Blockchain', function() {
|
|||
const expectedConfig = {
|
||||
networkType: 'custom',
|
||||
genesisBlock: false,
|
||||
ethereumClientName: 'geth',
|
||||
client: 'geth',
|
||||
ethereumClientBin: 'geth',
|
||||
datadir: dappPath(".embark/development/datadir"),
|
||||
mineWhenNeeded: false,
|
||||
|
@ -56,7 +56,7 @@ describe('embark.Blockchain', function() {
|
|||
let config = {
|
||||
networkType: 'livenet',
|
||||
genesisBlock: 'foo/bar/genesis.json',
|
||||
ethereumClientName: 'parity',
|
||||
client: 'parity',
|
||||
ethereumClientBin: 'parity',
|
||||
datadir: '/foo/datadir/',
|
||||
mineWhenNeeded: true,
|
||||
|
@ -98,7 +98,7 @@ describe('embark.Blockchain', function() {
|
|||
let expectedConfig = {
|
||||
networkType: 'livenet',
|
||||
genesisBlock: 'foo/bar/genesis.json',
|
||||
ethereumClientName: 'parity',
|
||||
client: 'parity',
|
||||
ethereumClientBin: 'parity',
|
||||
datadir: '/foo/datadir/',
|
||||
mineWhenNeeded: true,
|
||||
|
|
|
@ -5,7 +5,6 @@ const Plugins = require('../lib/core/plugins.js');
|
|||
const assert = require('assert');
|
||||
const TestLogger = require('../lib/utils/test_logger');
|
||||
const Events = require('../lib/core/events');
|
||||
const fs = require('../lib/core/fs');
|
||||
|
||||
describe('embark.Config', function () {
|
||||
let config = new Config({
|
||||
|
@ -21,23 +20,33 @@ describe('embark.Config', function () {
|
|||
config.loadBlockchainConfigFile();
|
||||
let expectedConfig = {
|
||||
"enabled": true,
|
||||
"ethereumClientName": "geth",
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"client": "geth",
|
||||
"proxy": true,
|
||||
"datadir": ".embark/myenv/datadir",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password"
|
||||
}
|
||||
]
|
||||
"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,
|
||||
"clientMode": {
|
||||
"miningMode": "auto"
|
||||
},
|
||||
"endpoint": "ws://localhost:8546"
|
||||
};
|
||||
|
||||
assert.deepEqual(config.blockchainConfig, expectedConfig);
|
||||
|
@ -46,26 +55,41 @@ describe('embark.Config', function () {
|
|||
it('should convert Ether units', function () {
|
||||
let expectedConfig = {
|
||||
"enabled": true,
|
||||
"ethereumClientName": "geth",
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
"targetGasLimit": "300000",
|
||||
"gasPrice": "8000000",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"client": "geth",
|
||||
"proxy": true,
|
||||
"datadir": ".embark/unitenv/datadir",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"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,
|
||||
"clientMode": {
|
||||
"miningMode": "auto",
|
||||
"gasPrice": "8 Mwei",
|
||||
"targetGasLimit": "300 Kwei"
|
||||
},
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password",
|
||||
"balance": "3000000000000000000"
|
||||
}
|
||||
]
|
||||
],
|
||||
"endpoint": "ws://localhost:8546"
|
||||
};
|
||||
|
||||
let config = new Config({
|
||||
|
@ -83,26 +107,41 @@ describe('embark.Config', function () {
|
|||
it('should accept unitless gas values', function () {
|
||||
let expectedConfig = {
|
||||
"enabled": true,
|
||||
"ethereumClientName": "geth",
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
"targetGasLimit": "20000000",
|
||||
"gasPrice": "8000000",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"client": "geth",
|
||||
"proxy": true,
|
||||
"datadir": ".embark/unitlessenv/datadir",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"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,
|
||||
"clientMode": {
|
||||
"miningMode": "auto",
|
||||
"gasPrice": "8000000",
|
||||
"targetGasLimit": "20000000"
|
||||
},
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password",
|
||||
"balance": "3000000000000000000"
|
||||
}
|
||||
]
|
||||
],
|
||||
"endpoint": "ws://localhost:8546"
|
||||
};
|
||||
|
||||
let config = new Config({
|
||||
|
@ -123,7 +162,6 @@ describe('embark.Config', function () {
|
|||
config.loadContractsConfigFile();
|
||||
let expectedConfig = {
|
||||
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'],
|
||||
dappAutoEnable: true,
|
||||
"gas": "400000",
|
||||
|
@ -146,7 +184,6 @@ describe('embark.Config', function () {
|
|||
it('should replace occourences of `0x0` with full zero addresses', () => {
|
||||
let expectedConfig = {
|
||||
versions: {'web3': '1.0.0-beta', solc: '0.5.0'},
|
||||
deployment: {host: 'localhost', port: 8545, type: 'rpc'},
|
||||
dappConnection: ['$WEB3', 'localhost:8545'],
|
||||
dappAutoEnable: true,
|
||||
"gas": "auto",
|
||||
|
|
|
@ -1,32 +1,15 @@
|
|||
{
|
||||
"myenv": {
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password"
|
||||
"clientMode": {
|
||||
"miningMode": "auto"
|
||||
}
|
||||
]
|
||||
},
|
||||
"unitenv": {
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
"clientMode": {
|
||||
"miningMode": "auto",
|
||||
"gasPrice": "8 Mwei",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"targetGasLimit": "300 Kwei",
|
||||
"targetGasLimit": "300 Kwei"
|
||||
},
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password",
|
||||
|
@ -35,17 +18,12 @@
|
|||
]
|
||||
},
|
||||
"unitlessenv": {
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": false,
|
||||
|
||||
"clientMode": {
|
||||
"miningMode": "auto",
|
||||
"gasPrice": "8000000",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"targetGasLimit": "20000000",
|
||||
"targetGasLimit": "20000000"
|
||||
},
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password",
|
||||
|
@ -54,15 +32,10 @@
|
|||
]
|
||||
},
|
||||
"testnet": {
|
||||
"networkType": "testnet",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545
|
||||
"networkType": "testnet"
|
||||
},
|
||||
"livenet": {
|
||||
"networkType": "livenet",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"accounts": [
|
||||
{
|
||||
"password": "config/development/password"
|
||||
|
@ -70,9 +43,6 @@
|
|||
]
|
||||
},
|
||||
"privatenet": {
|
||||
"networkType": "custom",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"datadir": "yourdatadir",
|
||||
"networkId": "123",
|
||||
"nodes": []
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"default": {
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"SimpleStorage": {
|
||||
"args": [
|
||||
100
|
||||
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
"zeroaddress": {
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"SimpleStorage": {
|
||||
"address": "0x0",
|
||||
"args": [
|
||||
|
@ -30,7 +30,7 @@
|
|||
},
|
||||
"myenv": {
|
||||
"gas": "400 Kwei",
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"SimpleStorage": {
|
||||
"gas": "123 Kwei",
|
||||
"gasPrice": "1 Kwei"
|
||||
|
@ -40,14 +40,6 @@
|
|||
200
|
||||
]
|
||||
}
|
||||
},
|
||||
"deployment": {
|
||||
"accounts": [
|
||||
{
|
||||
"mnemonic": "12 word mnemonic",
|
||||
"balance": "5000 Mwei"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
wsPort: 8546
|
||||
},
|
||||
development: {
|
||||
ethereumClientName: "geth",
|
||||
client: "geth",
|
||||
ethereumClientBin: "geth",
|
||||
datadir: ".embark/development/datadir",
|
||||
networkType: "custom",
|
||||
|
@ -61,7 +61,7 @@ Option | Type: `default` | Value
|
|||
`wsOrigins` | object | Same as `rpcCorsDomain`, 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
|
||||
`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)
|
||||
`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`
|
||||
|
|
Loading…
Reference in New Issue