Skip to content

Commit

Permalink
fix up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zsluedem committed Dec 19, 2022
1 parent ac02fef commit d618302
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 40 deletions.
24 changes: 8 additions & 16 deletions src/contracts/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,10 @@ impl<M: Middleware + 'static> EntryPoint<M> {
})
}

pub async fn get_user_op_hash<U: Into<UserOperation>>(
&self,
user_operation: U,
) -> Result<[u8; 32], EntryPointErr> {
let res: Result<[u8; 32], ContractError<M>> =
self.api.get_user_op_hash(user_operation.into()).await;
res.map_err(|e| EntryPointErr::UnknownErr(format!("Get user op hash error with {:?}", e)))
}

pub async fn simulate_validation<U: Into<UserOperation>>(
&self,
user_operation: U,
) -> Result<SimulateResult, EntryPointErr> {
) -> Result<SimulateValidationResult, EntryPointErr> {
let request_result = self.api.simulate_validation(user_operation.into()).await;
match request_result {
Ok(_) => Err(EntryPointErr::UnknownErr(
Expand All @@ -86,10 +77,12 @@ impl<M: Middleware + 'static> EntryPoint<M> {
Err(EntryPointErr::FailedOp(failed_op))
}
entry_point_api::EntryPointAPIErrors::SimulationResult(res) => {
Ok(SimulateResult::SimulationResult(res))
Ok(SimulateValidationResult::SimulationResult(res))
}
entry_point_api::EntryPointAPIErrors::SimulationResultWithAggregation(res) => {
Ok(SimulateResult::SimulationResultWithAggregation(res))
Ok(SimulateValidationResult::SimulationResultWithAggregation(
res,
))
}
_ => Err(EntryPointErr::UnknownErr(format!(
"Simulate validation with invalid error: {:?}",
Expand Down Expand Up @@ -166,7 +159,7 @@ pub enum EntryPointErr {
}

#[derive(Debug)]
pub enum SimulateResult {
pub enum SimulateValidationResult {
SimulationResult(entry_point_api::SimulationResult),
SimulationResultWithAggregation(entry_point_api::SimulationResultWithAggregation),
}
Expand Down Expand Up @@ -203,14 +196,13 @@ impl FromStr for JsonRpcError {
}

#[cfg(test)]
mod test {
use ethers::types::Bytes;
mod tests {

use super::JsonRpcError;
use std::str::FromStr;

#[test]
fn json_rpc_errpr_parse() {
fn json_rpc_err_parse() {
let some_data =
"(code: 3, message: execution reverted: , data: Some(String(\"0x00fa072b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000001941413230206163636f756e74206e6f74206465706c6f79656400000000000000\")))";
let err = JsonRpcError::from_str(some_data);
Expand Down
44 changes: 20 additions & 24 deletions src/contracts/gen.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
use crate::types::user_operation::UserOperation as UserOp;
use ethers::contract::abigen;
abigen!(
AggregatedAccount,
"$OUT_DIR/IAggregatedAccount.sol/IAggregatedAccount.json"
);

abigen!(Aggregator, "$OUT_DIR/IAggregator.sol/IAggregator.json");

abigen!(
Create2Deployer,
"$OUT_DIR/ICreate2Deployer.sol/ICreate2Deployer.json"
);

abigen!(EntryPointAPI, "$OUT_DIR/IEntryPoint.sol/IEntryPoint.json");

abigen!(Paymaster, "$OUT_DIR/IPaymaster.sol/IPaymaster.json");

abigen!(
StakeManager,
"$OUT_DIR/IStakeManager.sol/IStakeManager.json"
);

abigen!(Account, "$OUT_DIR/IAccount.sol/IAccount.json");

abigen!(
UserOperation,
"$OUT_DIR/UserOperation.sol/UserOperationLib.json"
);
// The below generations are not used now. So we comment them out for now.
// abigen!(
// AggregatedAccount,
// "$OUT_DIR/IAggregatedAccount.sol/IAggregatedAccount.json"
// );
// abigen!(Aggregator, "$OUT_DIR/IAggregator.sol/IAggregator.json");
// abigen!(
// Create2Deployer,
// "$OUT_DIR/ICreate2Deployer.sol/ICreate2Deployer.json"
// );
// abigen!(Paymaster, "$OUT_DIR/IPaymaster.sol/IPaymaster.json");
// abigen!(
// StakeManager,
// "$OUT_DIR/IStakeManager.sol/IStakeManager.json"
// );
// abigen!(Account, "$OUT_DIR/IAccount.sol/IAccount.json");
// abigen!(
// UserOperation,
// "$OUT_DIR/UserOperation.sol/UserOperationLib.json"
// );

impl From<UserOp> for entry_point_api::UserOperation {
fn from(value: UserOp) -> Self {
Expand Down

0 comments on commit d618302

Please sign in to comment.