ton-blockchain / stablecoin-contract

Sample code for centralised stablecoin jetton. TEP-74 and TEP-89 compatible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential problem with getRandomInt

grannnsacker opened this issue · comments

Hello, I want to apologize right away for my speech. English is not my native language.
image (pict 1)
Math.random() returns a number in the range [0;1). In the getRandomInt method, you round the resulting number using Math.round. With a sufficiently large number obtained from Math.random, getRandomInt can return a number equal to max. Example in JettonWallet.spec.ts (pict 2)
image
Proofs (pict 3)
image

if I really helped in any way, my telegram @grannsacker

This is code of tests, not code of smart contract. Max value is also valid for tests