mirror of https://github.com/embarklabs/embark.git
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:
parent
bd602b45ee
commit
70ff3c1825
|
@ -123,7 +123,8 @@ class ContractsManager {
|
||||||
|
|
||||||
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
|
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
|
||||||
try {
|
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 });
|
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]({
|
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({
|
||||||
from: account,
|
from: account,
|
||||||
|
|
Loading…
Reference in New Issue