From c039d88f549e27a8f352dabbe5d02a52a67ec3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 1 Feb 2024 08:42:03 +0100 Subject: [PATCH] Add helper. --- src/contract_client.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/contract_client.rs b/src/contract_client.rs index ff3def33b..7bb66c4d2 100644 --- a/src/contract_client.rs +++ b/src/contract_client.rs @@ -496,6 +496,16 @@ pub enum DryRunModuleDeployError { }, } +impl DryRunModuleDeployError { + /// Check whether dry-run failed because the module already exists. + pub fn already_exists(&self) -> bool { + let Self::Failed(reason) = self else { + return false; + }; + matches!(reason, RejectReason::ModuleHashAlreadyExists { .. }) + } +} + impl From for DryRunModuleDeployError { fn from(value: RejectReason) -> Self { Self::Failed(value) } }