Please pass numbers as strings or BigNumber objects to avoid precision errors

by Kevvv   Last Updated May 22, 2020 22:28 PM - source

I'm getting the following error:

Error: Please pass numbers as strings or BigNumber objects to avoid precision errors.

Most of the answers to this question on here recommended converting the argument to a string, but it didn't work for me.

testing

   let airline = accounts[7];
   const retrievedFund = await config.flightSuretyData.getFunds({
      from: airline,
      gasPrice: 0,
    });
    const convertedRetrievedFund = web3.utils.fromWei(retrievedFund, "ether");

contract

    function getFunds() external view returns (uint256) {
        return funds[msg.sender];
    }

I've also tried:

const convertedRetrievedFund = new BigNumber(web3.utils.fromWei(retrievedFund, "ether"));

but, the error seems to be stemming from the type of retrievedFund. As I mentioned, retrievedFund.toString() doesn't seem to work.

Logging retrievedFund shows:

{ tx: '0xe9208ba419ccc3ff6cf84a134c4cc8490d8f32ffbb6e01d961db65ca6867e473',
     receipt: 
      { transactionHash: '0xe9208ba419ccc3324a134c4cc849dfs2ffbb6e01d961db65ca6867e473',
        transactionIndex: 0,
        blockHash: '0x805561b488b8e9166d74b49dfs58f0763451d26061d2de2d833bedfc04a33',
        blockNumber: 472,
        from: '0x5f73f001383gc8ca6b812353063e470b5accb65e5',
        to: '0x89815b3c4f085aedfs0ed01427213aa2674d448',
        gasUsed: 24168,
        cumulativeGasUsed: 24168,
        contractAddress: null,
        logs: [],
        status: true,
        logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
        rawLogs: [] },
     logs: [] }


Related Questions




Contract state won't change during Truffle tests

Updated September 17, 2018 14:28 PM