mirror of https://github.com/embarklabs/embark.git
feat: enable ethereum manually
This commit is contained in:
parent
72f87012a9
commit
5a375d9a5e
|
@ -284,6 +284,7 @@ Config.prototype.loadContractsConfigFile = function() {
|
||||||
"$WEB3",
|
"$WEB3",
|
||||||
"localhost:8545"
|
"localhost:8545"
|
||||||
],
|
],
|
||||||
|
"dappAutoEnable": true,
|
||||||
"strategy": constants.deploymentStrategy.implicit,
|
"strategy": constants.deploymentStrategy.implicit,
|
||||||
"gas": "auto",
|
"gas": "auto",
|
||||||
"contracts": {
|
"contracts": {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
EmbarkJS.Blockchain.autoEnable = <%= autoEnable %>;
|
||||||
EmbarkJS.Blockchain.connect(<%- connectionList %>, {warnAboutMetamask: <%= warnAboutMetamask %>}, function(err) {
|
EmbarkJS.Blockchain.connect(<%- connectionList %>, {warnAboutMetamask: <%= warnAboutMetamask %>}, function(err) {
|
||||||
<%- done %>
|
<%- done %>
|
||||||
});
|
});
|
||||||
|
|
|
@ -120,7 +120,12 @@ class CodeGenerator {
|
||||||
} else {
|
} else {
|
||||||
let connectionList = "[" + this.contractsConfig.dappConnection.map((x) => '"' + x + '"').join(',') + "]";
|
let connectionList = "[" + this.contractsConfig.dappConnection.map((x) => '"' + x + '"').join(',') + "]";
|
||||||
let isDev = (self.env === 'development');
|
let isDev = (self.env === 'development');
|
||||||
web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done(err);', warnAboutMetamask: isDev});
|
web3Load = Templates.web3_connector({
|
||||||
|
autoEnable: this.contractsConfig.dappAutoEnable,
|
||||||
|
connectionList: connectionList,
|
||||||
|
done: 'done(err);',
|
||||||
|
warnAboutMetamask: isDev
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result += Templates.do_when_loaded({block: web3Load, environment: this.env});
|
result += Templates.do_when_loaded({block: web3Load, environment: this.env});
|
||||||
|
|
|
@ -114,6 +114,7 @@ describe('embark.Config', function () {
|
||||||
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"}]},
|
deployment: {host: 'localhost', port: 8545, type: 'rpc', "accounts": [{"mnemonic": "12 word mnemonic", "balance": "5000000000"}]},
|
||||||
dappConnection: ['$WEB3', 'localhost:8545'],
|
dappConnection: ['$WEB3', 'localhost:8545'],
|
||||||
|
dappAutoEnable: true,
|
||||||
"gas": "400000",
|
"gas": "400000",
|
||||||
"strategy": "implicit",
|
"strategy": "implicit",
|
||||||
"contracts": {
|
"contracts": {
|
||||||
|
@ -136,6 +137,7 @@ describe('embark.Config', function () {
|
||||||
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'},
|
deployment: {host: 'localhost', port: 8545, type: 'rpc'},
|
||||||
dappConnection: ['$WEB3', 'localhost:8545'],
|
dappConnection: ['$WEB3', 'localhost:8545'],
|
||||||
|
dappAutoEnable: true,
|
||||||
"gas": "auto",
|
"gas": "auto",
|
||||||
"strategy": "implicit",
|
"strategy": "implicit",
|
||||||
"contracts": {
|
"contracts": {
|
||||||
|
|
|
@ -32,6 +32,11 @@ module.exports = {
|
||||||
"http://localhost:8545"
|
"http://localhost:8545"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Automatically call `ethereum.enable` if true.
|
||||||
|
// If false, the following code must run before sending any transaction: `await EmbarkJS.enableEthereum();`
|
||||||
|
// Default value is true.
|
||||||
|
// dappAutoEnable: true,
|
||||||
|
|
||||||
gas: "auto",
|
gas: "auto",
|
||||||
|
|
||||||
// Strategy for the deployment of the contracts:
|
// Strategy for the deployment of the contracts:
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Blockchain extends React.Component {
|
||||||
valueSet: 10,
|
valueSet: 10,
|
||||||
valueGet: "",
|
valueGet: "",
|
||||||
logs: []
|
logs: []
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(e) {
|
handleChange(e) {
|
||||||
|
@ -27,9 +27,9 @@ class Blockchain extends React.Component {
|
||||||
func.apply(this, [e]);
|
func.apply(this, [e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(e) {
|
async setValue(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
await EmbarkJS.enableEthereum();
|
||||||
var value = parseInt(this.state.valueSet, 10);
|
var value = parseInt(this.state.valueSet, 10);
|
||||||
|
|
||||||
SimpleStorage.methods.set(value).send();
|
SimpleStorage.methods.set(value).send();
|
||||||
|
|
|
@ -32,6 +32,11 @@ module.exports = {
|
||||||
"http://localhost:8545"
|
"http://localhost:8545"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Automatically call `ethereum.enable` if true.
|
||||||
|
// If false, the following code must run before sending any transaction: `await EmbarkJS.enableEthereum();`
|
||||||
|
// Default value is true.
|
||||||
|
// dappAutoEnable: true,
|
||||||
|
|
||||||
gas: "auto",
|
gas: "auto",
|
||||||
|
|
||||||
// Strategy for the deployment of the contracts:
|
// Strategy for the deployment of the contracts:
|
||||||
|
|
|
@ -32,6 +32,11 @@ module.exports = {
|
||||||
"http://localhost:8545"
|
"http://localhost:8545"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Automatically call `ethereum.enable` if true.
|
||||||
|
// If false, the following code must run before sending any transaction: `await EmbarkJS.enableEthereum();`
|
||||||
|
// Default value is true.
|
||||||
|
// dappAutoEnable: true,
|
||||||
|
|
||||||
gas: "auto",
|
gas: "auto",
|
||||||
|
|
||||||
// Strategy for the deployment of the contracts:
|
// Strategy for the deployment of the contracts:
|
||||||
|
|
Loading…
Reference in New Issue