1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! EIP-712 domain separator for CoW Protocol orders.
//!
//! The settlement contract identifies itself with the EIP-712 domain
//! `name = "Gnosis Protocol"`, `version = "v2"`. Combined with the
//! deployment's `chainId` and `verifyingContract` address it scopes
//! every signed order hash to a specific chain.
//!
//! [`DomainSeparator`] is a type alias for
//! [`alloy_sol_types::Eip712Domain`]; the typed-data envelope is
//! normally supplied by [`alloy_sol_types::SolStruct::eip712_signing_hash`]
//! and the EIP-191 personal-sign wrap by
//! [`alloy_primitives::eip191_hash_message`]. There is no
//! `\x19Ethereum Signed Message:\n32` helper in this crate. The one
//! `keccak256(0x19 0x01 || ...)` helper that does exist,
//! [`eip712_message_hash`], is the JS/wasm interop boundary: callers
//! that already hold a raw 32-byte separator and struct hash (rather
//! than a typed [`DomainSeparator`] + [`alloy_sol_types::SolStruct`])
//! can fold them into the final typed-data hash without rebuilding an
//! `Eip712Domain`.
use ;
use Eip712Domain;
/// EIP-712 domain `name` for the CoW Protocol settlement contract.
/// Load-bearing: it feeds the domain separator the `GPv2Settlement`
/// contract verifies signatures against. Shared with the typed-data
/// builder so the two cannot drift.
pub const DOMAIN_NAME: &str = "Gnosis Protocol";
/// EIP-712 domain `version` for the CoW Protocol settlement contract.
/// See [`DOMAIN_NAME`] for why it is centralised here.
pub const DOMAIN_VERSION: &str = "v2";
/// EIP-712 domain for the CoW Protocol settlement contract. Re-exported
/// as a type alias so callers using `cowprotocol::DomainSeparator` do
/// not need to import the underlying alloy type, while getting all of
/// `Eip712Domain`'s `Debug`, `Display`, `Eq`, `Hash`, `Serialize`,
/// `Deserialize`, and `separator()` derivations for free.
pub type DomainSeparator = Eip712Domain;
/// Build the EIP-712 domain for the `GPv2Settlement` deployment on a
/// given chain. The Solidity domain string is `"Gnosis Protocol" v2`;
/// `contract_address` is the deployed `GPv2Settlement` for that chain.
/// EIP-712 typed-data hash `keccak256(0x19 || 0x01 || separator ||
/// struct_hash)`.
///
/// This is the JS/wasm interop boundary: callers that already hold a raw
/// 32-byte domain `separator` and `struct_hash` (for example a wallet
/// shim that produced them out-of-band) get the final signing hash
/// without having to rebuild a typed [`DomainSeparator`] and re-run
/// [`alloy_sol_types::SolStruct::eip712_signing_hash`]. Rust callers that
/// hold a typed [`DomainSeparator`] pass its [`Eip712Domain::separator`].