diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 54f7716b..a901dd07 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -113,14 +113,14 @@ export const contractFile = { export const CONTRACT_FUNCTION = createRequestTypes('CONTRACT_FUNCTION'); export const contractFunction = { - post: (contractName, method, inputs) => action(CONTRACT_FUNCTION[REQUEST], {contractName, method, inputs}), + post: (contractName, method, inputs, gasPrice) => action(CONTRACT_FUNCTION[REQUEST], {contractName, method, inputs, gasPrice}), success: (result, payload) => action(CONTRACT_FUNCTION[SUCCESS], {contractFunctions: [{...result, ...payload}]}), failure: (error) => action(CONTRACT_FUNCTION[FAILURE], {error}) }; export const CONTRACT_DEPLOY = createRequestTypes('CONTRACT_DEPLOY'); export const contractDeploy = { - post: (contractName, method, inputs) => action(CONTRACT_DEPLOY[REQUEST], {contractName, method, inputs}), + post: (contractName, method, inputs, gasPrice) => action(CONTRACT_DEPLOY[REQUEST], {contractName, method, inputs, gasPrice}), success: (result, payload) => action(CONTRACT_DEPLOY[SUCCESS], {contractDeploys: [{...result, ...payload}]}), failure: (error) => action(CONTRACT_DEPLOY[FAILURE], {error}) }; diff --git a/embark-ui/src/components/ContractFunctions.js b/embark-ui/src/components/ContractFunctions.js index 47383689..5c3a9c26 100644 --- a/embark-ui/src/components/ContractFunctions.js +++ b/embark-ui/src/components/ContractFunctions.js @@ -15,13 +15,17 @@ class ContractFunction extends Component { this.state = {inputs: {}}; } + static isPureCall(method) { + return (method.mutability === 'view' || method.mutability === 'pure'); + } + buttonTitle() { const {method} = this.props; if (method.name === 'constructor') { return 'Deploy'; } - return (method.mutability === 'view' || method.mutability === 'pure') ? 'Call' : 'Send'; + return ContractFunction.isPureCall(method) ? 'Call' : 'Send'; } inputsAsArray() { @@ -38,7 +42,7 @@ class ContractFunction extends Component { handleCall(e) { e.preventDefault(); - this.props.postContractFunction(this.props.contractProfile.name, this.props.method.name, this.inputsAsArray()); + this.props.postContractFunction(this.props.contractProfile.name, this.props.method.name, this.inputsAsArray(), this.state.inputs.gasPrice * 1000000000); } callDisabled() { @@ -59,6 +63,11 @@ class ContractFunction extends Component { this.handleChange(e, input.name)}/> ))} + {!ContractFunction.isPureCall(this.props.method) && + + this.handleChange(e, 'gasPrice')}/> + + } diff --git a/embark-ui/src/components/GasStation.js b/embark-ui/src/components/GasStation.js index f306f9a0..c7b20807 100644 --- a/embark-ui/src/components/GasStation.js +++ b/embark-ui/src/components/GasStation.js @@ -73,7 +73,7 @@ class GasStation extends Component { - Gas Price Estimator + Gas Price Estimator (for Mainnet) this.setState({copied: true})} diff --git a/lib/modules/contracts_manager/index.js b/lib/modules/contracts_manager/index.js index 8cd39979..4e5d49a5 100644 --- a/lib/modules/contracts_manager/index.js +++ b/lib/modules/contracts_manager/index.js @@ -112,7 +112,7 @@ class ContractsManager { self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, (contractObj) => { try { - contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account}, (error, result) => { + contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice}, (error, result) => { if (error) { return res.send({result: error.message}); } @@ -148,7 +148,7 @@ class ContractsManager { try { const params = {data: `0x${contract.code}`, arguments: req.body.inputs}; let gas = await contractObj.deploy(params).estimateGas(); - let newContract = await contractObj.deploy(params).send({from: account, gas}); + let newContract = await contractObj.deploy(params).send({from: account, gas, gasPrice: req.body.gasPrice}); res.send({result: newContract._address}); } catch (e) { res.send({result: e.message});