Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entry point api #25

Merged
merged 3 commits into from
Dec 20, 2022
Merged

Entry point api #25

merged 3 commits into from
Dec 20, 2022

Conversation

zsluedem
Copy link
Collaborator

@zsluedem zsluedem commented Dec 19, 2022

Introduce a wrapped entry point api that handle the error in our own way.

"$OUT_DIR/UserOperation.sol/UserOperationLib.json"
);

impl From<UserOp> for entry_point_api::UserOperation {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dup to the pr #24 . Just want to put it here to compile well. Should be removed later.

}

#[derive(Debug, Deserialize, PartialEq)]
pub struct JsonRpcError {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the same as https://github.com/gakonst/ethers-rs/blob/master/ethers-providers/src/transports/common.rs#L14-L22. But sadly, ethers-rs doesn't expose this type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if there is any specific reason why that type is not exposed? Maybe we should update ethers-rs to expose it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides JsonRpcError, there are a lot of middleware error types in ethers-rs. What kind of error you get depends on the middleware and it is dynamic dispatch. The ethers-rs team told me it is going to change in version 2. I didn't explore how difficult to fix it in the current version.

FYI, the current solution is not handling all the situations well. I haven't met any network errors (or middleware error) yet. And we need to improve this in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it, thanks for the explanation

type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let re = Regex::new(
r###"code: (\d+), message: ([^,]*), data: (None|Some\(String\("([^)]*)"\))"###,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zsluedem zsluedem requested a review from Vid201 December 19, 2022 05:08
ops_per_aggregator: Vec<U>,
beneficiary: Address,
) -> Result<(), EntryPointErr> {
todo!()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found good test cases for this. I would make it work in another pr.

src/contracts/entrypoint.rs Outdated Show resolved Hide resolved
src/contracts/gen.rs Outdated Show resolved Hide resolved
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct JsonRpcError {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if there is any specific reason why that type is not exposed? Maybe we should update ethers-rs to expose it.

src/contracts/entrypoint.rs Outdated Show resolved Hide resolved
src/contracts/entrypoint.rs Outdated Show resolved Hide resolved
@Vid201
Copy link
Member

Vid201 commented Dec 19, 2022

This looks good; good job! Left some comments

src/contracts/entrypoint.rs Outdated Show resolved Hide resolved
@Vid201
Copy link
Member

Vid201 commented Dec 19, 2022

@zsluedem It's ready for merge unless you plan to make any additional changes.

@zsluedem zsluedem merged commit b4ed6c5 into silius-rs:main Dec 20, 2022
@zsluedem
Copy link
Collaborator Author

@Vid201 Thanks

@zsluedem zsluedem deleted the entry-point-api branch December 20, 2022 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants