33
44#![ doc = include_str ! ( "../README.md" ) ]
55
6- use std:: borrow:: Cow ;
7- use std:: collections:: HashSet ;
8- use std:: str:: FromStr ;
9-
10- use alloy:: dyn_abi:: Eip712Domain ;
11- use alloy:: primitives:: Address ;
12- use alloy:: primitives:: FixedBytes ;
13- use alloy:: signers:: local:: PrivateKeySigner ;
6+ use std:: { collections:: HashSet , str:: FromStr } ;
7+
8+ use alloy:: { dyn_abi:: Eip712Domain , primitives:: Address , signers:: local:: PrivateKeySigner } ;
149use anyhow:: Result ;
1510use clap:: Parser ;
16- use ruint:: aliases:: U256 ;
17- use tokio:: signal:: unix:: { signal, SignalKind } ;
18-
1911use log:: { debug, info} ;
20- use tap_aggregator:: metrics;
21- use tap_aggregator:: server;
12+ use tap_core:: tap_eip712_domain;
13+
14+ use tap_aggregator:: { metrics, server} ;
2215
2316#[ derive( Parser , Debug ) ]
2417#[ command( author, version, about, long_about = None ) ]
@@ -126,37 +119,22 @@ async fn main() -> Result<()> {
126119 . await ?;
127120 info ! ( "Server started. Listening on port {}." , args. port) ;
128121
129- // Have tokio wait for SIGTERM or SIGINT.
130- let mut signal_sigint = signal ( SignalKind :: interrupt ( ) ) ?;
131- let mut signal_sigterm = signal ( SignalKind :: terminate ( ) ) ?;
132- tokio:: select! {
133- _ = signal_sigint. recv( ) => debug!( "Received SIGINT." ) ,
134- _ = signal_sigterm. recv( ) => debug!( "Received SIGTERM." ) ,
135- }
122+ let _ = handle. await ;
136123
137124 // If we're here, we've received a signal to exit.
138125 info ! ( "Shutting down..." ) ;
139-
140- // Stop the server and wait for it to finish gracefully.
141- handle. stop ( ) ?;
142- handle. stopped ( ) . await ;
143-
144- debug ! ( "Goodbye!" ) ;
145126 Ok ( ( ) )
146127}
147128
148129fn create_eip712_domain ( args : & Args ) -> Result < Eip712Domain > {
149130 // Transfrom the args into the types expected by Eip712Domain::new().
150131
151132 // Transform optional strings into optional Cow<str>.
152- let name = args. domain_name . clone ( ) . map ( Cow :: Owned ) ;
153- let version = args. domain_version . clone ( ) . map ( Cow :: Owned ) ;
154-
155133 // Transform optional strings into optional U256.
156134 if args. domain_chain_id . is_some ( ) {
157135 debug ! ( "Parsing domain chain ID..." ) ;
158136 }
159- let chain_id: Option < U256 > = args
137+ let chain_id: Option < u64 > = args
160138 . domain_chain_id
161139 . as_ref ( )
162140 . map ( |s| s. parse ( ) )
@@ -165,17 +143,13 @@ fn create_eip712_domain(args: &Args) -> Result<Eip712Domain> {
165143 if args. domain_salt . is_some ( ) {
166144 debug ! ( "Parsing domain salt..." ) ;
167145 }
168- let salt: Option < FixedBytes < 32 > > = args. domain_salt . as_ref ( ) . map ( |s| s. parse ( ) ) . transpose ( ) ?;
169146
170147 // Transform optional strings into optional Address.
171148 let verifying_contract: Option < Address > = args. domain_verifying_contract ;
172149
173150 // Create the EIP-712 domain separator.
174- Ok ( Eip712Domain :: new (
175- name,
176- version,
177- chain_id,
178- verifying_contract,
179- salt,
151+ Ok ( tap_eip712_domain (
152+ chain_id. unwrap_or ( 1 ) ,
153+ verifying_contract. unwrap_or_default ( ) ,
180154 ) )
181155}
0 commit comments