I'm tweaking with ink! Smart contracts and deployed some test contracts through https://polkadot.js.org/. However, despite setting conditional statements within smart contracts, calls to them still pass without reverting. Am I doing something wrong with the error handling?
Example code:
#[ink(message)]
pub fn withdraw_(&mut self, value: Balance) -> Result<()> {
let caller= self.env().caller();
let contract_address = self.env().account_id();
let ticket_count = self.tickets_of_or_zero(caller);
if ticket_count <= 0 {
return Err(Error::InsufficientTickets)
}
self.tickets.insert(caller, ticket_count - 1);
let transfer_status = self.transfer_from_to_reentrant(contract_address,caller,value);
if !transfer_status {
return Err(Error::UnsucceededTransfer)
}
Ok(())
}