fix(@embark/contracts-manager): ensure ETH values sent through APIs are converted to string

This is due to a bug that has been introduced in d10c0b7951 where we end up
sending values as numbers to web3's `toWei()` utility. The `value` is always sent as number
and in fact always defined, so we just need to check for it's type and convert it to a string
according to `toWei()`'s API.
This commit is contained in:
Pascal Precht 2019-07-01 13:54:56 +02:00 committed by Michael Bradley
parent bd602b45ee
commit 70ff3c1825
1 changed files with 2 additions and 1 deletions

View File

@ -123,7 +123,8 @@ class ContractsManager {
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
try {
const value = req.body.value !== undefined ? web3.utils.toWei(req.body.value, 'ether') : 0;
let value = typeof req.body.value === "number" ? req.body.value.toString() : req.body.value;
value = web3.utils.toWei(value, 'ether');
const gas = await contractObj.methods[req.body.method].apply(this, req.body.inputs).estimateGas({ value });
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({
from: account,