@@ -39,15 +39,35 @@ fn get_current_timestamp_u64_ns() -> Result<u64> {
3939/// You can take a look on deployed [TAPVerfiers](https://github.com/semiotic-ai/timeline-aggregation-protocol-contracts/blob/4dc87fc616680c924b99dbaf285bdd449c777261/src/TAPVerifier.sol)
4040/// contracts [here](https://github.com/semiotic-ai/timeline-aggregation-protocol-contracts/blob/4dc87fc616680c924b99dbaf285bdd449c777261/addresses.json)
4141///
42+ /// TAP protocol version for EIP-712 domain separator
43+ #[ derive( Debug , Clone , Copy ) ]
44+ pub enum TapVersion {
45+ V1 ,
46+ V2 ,
47+ }
48+
49+ impl TapVersion {
50+ pub fn as_str ( & self ) -> & ' static str {
51+ match self {
52+ TapVersion :: V1 => "1" ,
53+ TapVersion :: V2 => "2" ,
54+ }
55+ }
56+ }
57+
4258/// The domain separator is defined as:
4359/// - `name`: "TAP"
44- /// - `version`: "1"
60+ /// - `version`: "1" or "2" depending on protocol version
4561/// - `chain_id`: The chain ID of the chain where the domain separator is deployed.
4662/// - `verifying_contract`: The address of the contract that is verifying the signature.
47- pub fn tap_eip712_domain ( chain_id : u64 , verifying_contract_address : Address ) -> Eip712Domain {
63+ pub fn tap_eip712_domain (
64+ chain_id : u64 ,
65+ verifying_contract_address : Address ,
66+ version : TapVersion ,
67+ ) -> Eip712Domain {
4868 eip712_domain ! {
4969 name: "TAP" ,
50- version: "1" ,
70+ version: version . as_str ( ) ,
5171 chain_id: chain_id,
5272 verifying_contract: verifying_contract_address,
5373 }
@@ -63,7 +83,7 @@ mod tap_tests {
6383 dyn_abi:: Eip712Domain , primitives:: Address , signers:: local:: PrivateKeySigner ,
6484 } ;
6585
66- use crate :: { signed_message:: Eip712SignedMessage , tap_eip712_domain} ;
86+ use crate :: { signed_message:: Eip712SignedMessage , tap_eip712_domain, TapVersion } ;
6787
6888 #[ fixture]
6989 fn keys ( ) -> ( PrivateKeySigner , Address ) {
@@ -85,7 +105,7 @@ mod tap_tests {
85105
86106 #[ fixture]
87107 fn domain_separator ( ) -> Eip712Domain {
88- tap_eip712_domain ( 1 , Address :: from ( [ 0x11u8 ; 20 ] ) )
108+ tap_eip712_domain ( 1 , Address :: from ( [ 0x11u8 ; 20 ] ) , TapVersion :: V1 )
89109 }
90110
91111 #[ rstest]
0 commit comments