Clock::get().unwrap().unix_timestamp.try_into().unwrap()
is too risky as it might fail
Clock::get()
returns Result<Clock, ProgramError>
, and calling .unwrap()
will panic if it fails. If used in an on-chain program, a panic will abort the transaction, which is not ideal
unix_timestamp
is already an i64
, so calling .try_into()
(which converts between integer types) is redundant unless you're converting to another type.
If try_into()
were converting to a different integer type (like u64
), it could fail (e.g., i64
→ u64
if the value is negative), leading to another panic.
Panic.
Manual Review/chatgpt
Replace it with:
Clock::get()?.unix_timestamp
It is very unlikely `Clock::get` to fail, therefore I think it is safe to use `unwrap` here. Consider this issue as informational.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.