massalabs / massa-web3

Web3 libraries for Massa
MIT License
29 stars 74 forks source link

callSmartContract should consider the candidate balance #601

Open Thykof opened 3 months ago

Thykof commented 3 months ago

here https://github.com/massalabs/massa-web3/blob/3bdb27acab89105e6511a95ec5402a97acc1b415/packages/massa-web3/src/web3/SmartContractsClient.ts#L153 we check if the caller has enough funds to call the smart contract but we check the final balance of the caller. It prevents from calling the smart contract whereas the call it actually possible and will succeed.

It should check the candidate balance

cc @AurelienFT @Ben-Rey WDYT?

Ben-Rey commented 3 months ago

here https://github.com/massalabs/massa-web3/blob/3bdb27acab89105e6511a95ec5402a97acc1b415/packages/massa-web3/src/web3/SmartContractsClient.ts#L153 we check if the caller has enough funds to call the smart contract but we check the final balance of the caller. It prevents from calling the smart contract whereas the call it actually possible and will succeed.

It should check the candidate balance

cc @AurelienFT @Ben-Rey WDYT?

Can you give an example?

Thykof commented 3 months ago

In anyway I think it's better to rely on the candidate balance in a more general case. I see no reason to enforce a final balance for a call sc, even more in massa-web3 lib.

Ben-Rey commented 3 months ago

Ok thanks, I agree