1

我正在用墨水调整!智能合约并通过https://polkadot.js.org/部署了一些测试合约。然而,尽管在智能合约中设置了条件语句,对它们的调用仍然通过而不会恢复。我在错误处理方面做错了吗?

示例代码:

  #[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(())
    }
4

0 回答 0