massalabs / massa-web3

Web3 libraries for Massa
31 stars 75 forks source link

528 2 convert coins to mas #531

Closed Thykof closed 8 months ago

Thykof commented 8 months ago

Warning: breaking change in the read smart contract function, you must now put the value in nanoMASSA.

Note: I can't convert the coins parameter in the call smart contract function because ICallData.coins is bigint, so the value in MASSA with a coma won't work. This is why I convert to MASSA in the read smart contract function. We can change the type of ICallData.coins to string or BigNumber if we don't want this breaking change.

Here is what we can do:

      try {
        const previousCoins = callData.coins;
        callData.coins = BigInt(toMAS(callData.coins).toString()); // error here, can't create a BigInt for a string with decimal part
        const response = await this.readSmartContract(callData)
        callData.maxGas = BigInt(response.info.gas_cost)
        callData.coins = previousCoins;
      } catch (error) {
        throw new Error(
          `Operation failed: Max gas unspecified and auto-estimation failed. Error details: ${error.message}`
        )
      }
sonarcloud[bot] commented 8 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud