pub struct OrderTypedData {
pub domain: OrderDomain,
pub primary_type: &'static str,
pub order: UnsignedOrder,
}Expand description
The full EIP-712 typed data envelope for a CoW Protocol order.
Mirrors OrderTypedData from the TypeScript SDK. Pass this to a hardware
wallet or any EIP-712-aware signer that needs the structured domain and types
alongside the order message.
Fields§
§domain: OrderDomainThe EIP-712 domain for CoW Protocol.
primary_type: &'static strEIP-712 primary type name ("GPv2Order.Data").
order: UnsignedOrderThe order message to sign.
Implementations§
Source§impl OrderTypedData
impl OrderTypedData
Sourcepub const fn new(domain: OrderDomain, order: UnsignedOrder) -> OrderTypedData
pub const fn new(domain: OrderDomain, order: UnsignedOrder) -> OrderTypedData
Construct an OrderTypedData envelope for the given domain and order.
The primary type is always "GPv2Order.Data" per the CoW Protocol EIP-712 spec.
§Arguments
domain- The EIP-712 domain for the target chain.order- The unsigned order to wrap.
§Returns
An OrderTypedData envelope ready for signing.
Sourcepub const fn order_ref(&self) -> &UnsignedOrder
pub const fn order_ref(&self) -> &UnsignedOrder
Returns a reference to the underlying UnsignedOrder.
use alloy_primitives::{Address, U256};
use cow_signing::types::{OrderDomain, OrderTypedData};
use cow_types::UnsignedOrder;
let order = UnsignedOrder::sell(Address::ZERO, Address::ZERO, U256::ZERO, U256::ZERO);
let typed = OrderTypedData::new(OrderDomain::for_chain(1), order.clone());
assert_eq!(typed.order_ref().kind, order.kind);Sourcepub const fn domain_ref(&self) -> &OrderDomain
pub const fn domain_ref(&self) -> &OrderDomain
Sourcepub fn signing_digest(&self) -> FixedBytes<32>
pub fn signing_digest(&self) -> FixedBytes<32>
Compute the full EIP-712 signing digest for this typed data.
This is the keccak256("\x19\x01" ‖ domainSep ‖ orderHash) value that
must be signed with a private key to produce a signature accepted by the
CoW Protocol settlement contract.
use alloy_primitives::{Address, U256};
use cow_signing::types::{OrderDomain, OrderTypedData};
use cow_types::UnsignedOrder;
let order = UnsignedOrder::sell(Address::ZERO, Address::ZERO, U256::ZERO, U256::ZERO);
let typed = OrderTypedData::new(OrderDomain::for_chain(11_155_111), order);
let digest = typed.signing_digest();
assert_ne!(digest, alloy_primitives::B256::ZERO);Trait Implementations§
Source§impl Clone for OrderTypedData
impl Clone for OrderTypedData
Source§fn clone(&self) -> OrderTypedData
fn clone(&self) -> OrderTypedData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrderTypedData
impl Debug for OrderTypedData
Auto Trait Implementations§
impl Freeze for OrderTypedData
impl RefUnwindSafe for OrderTypedData
impl Send for OrderTypedData
impl Sync for OrderTypedData
impl Unpin for OrderTypedData
impl UnsafeUnpin for OrderTypedData
impl UnwindSafe for OrderTypedData
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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.