pub struct CowHook {
pub target: String,
pub call_data: String,
pub gas_limit: String,
pub dapp_id: Option<String>,
}Expand description
A single CoW Protocol pre- or post-settlement interaction hook.
Hooks are arbitrary contract calls that the CoW settlement contract
executes before (pre) or after (post) the trade. Common use cases
include token approvals, NFT transfers, and flash-loan repayments.
§Fields
target— the contract address to call (0x-prefixed, 20 bytes).call_data— ABI-encoded function selector + arguments (0x-prefixed).gas_limit— maximum gas the hook may consume (decimal string).dapp_id— optional identifier for the dApp that registered the hook.
§Example
use cow_types::CowHook;
let hook = CowHook::new("0x1234567890abcdef1234567890abcdef12345678", "0xabcdef00", "100000")
.with_dapp_id("my-dapp");
assert!(hook.has_dapp_id());Fields§
§target: StringTarget contract address (checksummed hex with 0x prefix).
call_data: StringABI-encoded call data (hex with 0x prefix).
gas_limit: StringMaximum gas this hook may consume (decimal string, e.g. "100000").
dapp_id: Option<String>Optional dApp identifier for the hook’s origin.
Implementations§
Source§impl CowHook
impl CowHook
Sourcepub fn new(
target: impl Into<String>,
call_data: impl Into<String>,
gas_limit: impl Into<String>,
) -> Self
pub fn new( target: impl Into<String>, call_data: impl Into<String>, gas_limit: impl Into<String>, ) -> Self
Construct a new CowHook without a dApp identifier.
Sourcepub fn with_dapp_id(self, dapp_id: impl Into<String>) -> Self
pub fn with_dapp_id(self, dapp_id: impl Into<String>) -> Self
Attach a dApp identifier to this hook.
Sourcepub const fn has_dapp_id(&self) -> bool
pub const fn has_dapp_id(&self) -> bool
Returns true if a dApp identifier is set on this hook.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CowHook
impl<'de> Deserialize<'de> for CowHook
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CowHook
impl RefUnwindSafe for CowHook
impl Send for CowHook
impl Sync for CowHook
impl Unpin for CowHook
impl UnsafeUnpin for CowHook
impl UnwindSafe for CowHook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.