From 550d2d86efb9891c59b68508a23b1bdf4ab9e9d0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 Aug 2022 00:28:02 +0200 Subject: [PATCH] chore: seal extension traits (#1553) * chore: seal extension traits * chore: fmt Co-authored-by: Georgios Konstantopoulos --- ethers-core/src/abi/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ethers-core/src/abi/mod.rs b/ethers-core/src/abi/mod.rs index fdb6eb08..da12946b 100644 --- a/ethers-core/src/abi/mod.rs +++ b/ethers-core/src/abi/mod.rs @@ -26,8 +26,18 @@ pub use human_readable::{ use crate::types::{H256, H512, I256, U128, U256, U64}; +mod sealed { + use ethabi::{Event, Function}; + + /// private trait to ensure extension traits are used as intended + pub trait Sealed {} + impl Sealed for Function {} + impl Sealed for Event {} + impl Sealed for ethabi::AbiError {} +} + /// Extension trait for `ethabi::Function`. -pub trait FunctionExt { +pub trait FunctionExt: sealed::Sealed { /// Compute the method signature in the standard ABI format. This does not /// include the output types. fn abi_signature(&self) -> String; @@ -52,7 +62,7 @@ impl FunctionExt for Function { } /// Extension trait for `ethabi::Event`. -pub trait EventExt { +pub trait EventExt: sealed::Sealed { /// Compute the event signature in human-readable format. The `keccak256` /// hash of this value is the actual event signature that is used as topic0 /// in the transaction logs. @@ -71,7 +81,7 @@ impl EventExt for Event { } /// Extension trait for `ethabi::AbiError`. -pub trait ErrorExt { +pub trait ErrorExt: sealed::Sealed { /// Compute the method signature in the standard ABI format. fn abi_signature(&self) -> String;