executeFunction will not accept a false bool param

Using the Moralis SDK, we attempt to make a call to our function like so.

  await Moralis.enableWeb3();
  let contractAddress = process.env.REACT_APP_INFO_ADDRESS;

  const infoContract = {
    abi: infoABI,
    contractAddress: contractAddress,
    functionName: 'exampleFunc',
    params: {
      _setRoyalty: false,
    }
  }; 

However, Moralis is unable to accept false as a parameter. Tested the contract with false and true in etherscan and the input works fine there. Our abi accepts the type like so:

{ "internalType": "bool", "name": "_setRoyalty", "type": "bool" }, 

When false, I receive an error that requires the parameter.
image

When set to true, Moralis will accept the parameter and execute the function. I have tried with integers as well as string inputs, neither of which have had any success in accepting a false parameter. (integers will return error above for 0, and work for true as 1, string inputs will return error for empty string, and accept any non-empty string as true)

Any input on this?

would you know what is wrong in the main Moralis SDK code: https://github.com/MoralisWeb3/Moralis-JS-SDK/blob/d3e2c7a70ae95bc284793b9edd78cbc68fc7a3b6/src/MoralisWeb3.js#L531 ?

is this a known issue currently? or an isolated event for my project.

my current interpretation of the issue is that when setting a field in the params object to false, the parameter is not being read in. i have limited time to look over this but will see if I can detect the issue in your code base.

image

At line 564 it appears that an error will be pushed if the value is false. This should be the problem.

1 Like

thanks, it looks like weโ€™ll have to fix that part of the code that checks the value of the parameter

thanks. can I get an estimate of when this should be resolved? have to manage our timeline as well.

I donโ€™t know exactly, if you are in a hurry you could also make a PR to Moralis SDK with the fix

thanks. will wait for your fix. currently not in the capacity to make a PR and test the implicating functionalities so for now it would be best for someone more knowledgeable about the code base to make the change. it would be very pleasing to see this take priority as it doesnโ€™t seem to be a large issue on inspection :face_with_monocle: :blush:

Hey @fost

It was fixed on the latest version

1 Like