From 0fb90b0978e85957992863cb84dd4b400a03f3f1 Mon Sep 17 00:00:00 2001 From: skoupidi Date: Mon, 20 May 2024 14:18:05 +0300 Subject: [PATCH] contract/deployooor/client: replaced asserts with error returns and added log targets --- src/contract/deployooor/src/client/deploy_v1.rs | 13 +++++++++---- src/contract/deployooor/src/client/lock_v1.rs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/contract/deployooor/src/client/deploy_v1.rs b/src/contract/deployooor/src/client/deploy_v1.rs index acb9b6a8f..b8536cb78 100644 --- a/src/contract/deployooor/src/client/deploy_v1.rs +++ b/src/contract/deployooor/src/client/deploy_v1.rs @@ -16,9 +16,11 @@ * along with this program. If not, see . */ -use darkfi::Result; +use darkfi::{ClientFailed, Result}; use darkfi_sdk::{crypto::Keypair, deploy::DeployParamsV1}; -use log::debug; +use log::{debug, error}; + +use crate::error::DeployError; pub struct DeployCallDebris { pub params: DeployParamsV1, @@ -36,8 +38,11 @@ pub struct DeployCallBuilder { impl DeployCallBuilder { pub fn build(&self) -> Result { - debug!("Building Deployooor::DeployV1 contract call"); - assert!(!self.wasm_bincode.is_empty()); + debug!(target: "contract::deployooor::client::deploy", "Building Deployooor::DeployV1 contract call"); + if self.wasm_bincode.is_empty() { + error!(target: "contract::deployooor::client::deploy", "Provided WASM bincode is empty"); + return Err(ClientFailed::VerifyError(DeployError::WasmBincodeInvalid.to_string()).into()) + } let params = DeployParamsV1 { wasm_bincode: self.wasm_bincode.clone(), diff --git a/src/contract/deployooor/src/client/lock_v1.rs b/src/contract/deployooor/src/client/lock_v1.rs index e6bffaf56..4d55b7b9e 100644 --- a/src/contract/deployooor/src/client/lock_v1.rs +++ b/src/contract/deployooor/src/client/lock_v1.rs @@ -34,7 +34,7 @@ pub struct LockCallBuilder { impl LockCallBuilder { pub fn build(&self) -> Result { - debug!("Building Deployooor::LockV1 contract call"); + debug!(target: "contract::deployooor::client::lock", "Building Deployooor::LockV1 contract call"); let params = LockParamsV1 { public_key: self.deploy_keypair.public }; let debris = LockCallDebris { params };