@@ -91,7 +91,7 @@ async fn main() -> Result<()> {
9191 . build ( ) ?;
9292
9393 // Create the EIP-712 domain separator.
94- let domain_separator = create_eip712_domain ( & args) ;
94+ let domain_separator = create_eip712_domain ( & args) ? ;
9595
9696 // Start the JSON-RPC server.
9797 // This await is non-blocking
@@ -125,20 +125,30 @@ async fn main() -> Result<()> {
125125 Ok ( ( ) )
126126}
127127
128- fn create_eip712_domain ( args : & Args ) -> Eip712Domain {
128+ fn create_eip712_domain ( args : & Args ) -> Result < Eip712Domain > {
129129 // Transfrom the args into the types expected by Eip712Domain::new().
130130
131131 // Transform optional strings into optional Cow<str>.
132132 let name = args. domain_name . clone ( ) . map ( Cow :: Owned ) ;
133133 let version = args. domain_version . clone ( ) . map ( Cow :: Owned ) ;
134134
135135 // Transform optional strings into optional U256.
136- let chain_id: Option < U256 > = args. domain_chain_id . as_ref ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ;
137- let salt: Option < FixedBytes < 32 > > = args. domain_salt . as_ref ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ;
136+ let chain_id: Option < U256 > = args
137+ . domain_chain_id
138+ . as_ref ( )
139+ . map ( |s| s. parse ( ) )
140+ . transpose ( ) ?;
141+ let salt: Option < FixedBytes < 32 > > = args. domain_salt . as_ref ( ) . map ( |s| s. parse ( ) ) . transpose ( ) ?;
138142
139143 // Transform optional strings into optional Address.
140144 let verifying_contract: Option < Address > = args. domain_verifying_contract ;
141145
142146 // Create the EIP-712 domain separator.
143- Eip712Domain :: new ( name, version, chain_id, verifying_contract, salt)
147+ Ok ( Eip712Domain :: new (
148+ name,
149+ version,
150+ chain_id,
151+ verifying_contract,
152+ salt,
153+ ) )
144154}
0 commit comments