Skip to content

Commit df5589e

Browse files
committed
refactor(tap-aggregator): propagates errors for eip712 domain to user
Signed-off-by: Bryan Cole <[email protected]>
1 parent 3a5e8b5 commit df5589e

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

tap_aggregator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ lazy_static = "1.4.0"
3030
alloy-sol-types = { version = "0.3.1", features = ["eip712-serde"]}
3131
alloy-primitives = { version = "0.3.1", features = ["serde"]}
3232
ethereum-types = "0.14.1"
33+
ruint = "1.10.1"
3334

3435
[dev-dependencies]
3536
jsonrpsee = { version = "0.18.0", features = ["http-client", "jsonrpsee-core"] }

tap_aggregator/src/main.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)