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

fix: balance transfer & deployed txn #14

Merged
merged 5 commits into from
Sep 10, 2024
Merged

Conversation

chris13524
Copy link
Member

Adds test coverage for transferring native token balance from the smart account to another account. It does this transfer twice, the first time as part of the account deployment, and the second against the deployed account.

This fixes some issues in the process:

  • Sponsor transaction should have undefined factory and factoryData when working against a deployed account
  • Switch to manual CREATE2 implementation as getSenderAddress() only works when the account isn't yet deployed
  • General code refactors and cleanup

@chris13524 chris13524 self-assigned this Sep 9, 2024
Comment on lines +63 to +65
// Note: you may need to static call getSenderAddress() not call() as per
// the spec. Leaving as-is for now.
// let call = call_builder.call_raw().await;
Copy link
Contributor

Choose a reason for hiding this comment

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

are you saying this is not correct and shouldn't work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the entry point says to do a staticcall when calling getSenderAddress. Here it's currently doing a regular call I think.

Not sure exactly the difference but it seems to work as-is for now for simple account so I'm leaving it as-is. But something to be aware of if there are issues in the future

Comment on lines +466 to +468
// TODO test/fix: if invalid call data (e.g. sending balance that you don't
// have), the account will still be deployed but the transfer won't happen.
// Why can't we detect this?
Copy link
Contributor

Choose a reason for hiding this comment

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

We should know the balance of the smart account. If the smart account has not been deployed then the balance would be 0, if it has been deployed we can get the balance of the contract before sending the user operation I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah we can get the balance, my point was that the UserOperation went through even though the transaction was invalid. Not what I was expecting. I would've expected the whole thing to revert

@chris13524 chris13524 merged commit cf7c229 into main Sep 10, 2024
4 checks passed
@chris13524 chris13524 deleted the chore/more-safe-tests branch September 10, 2024 13:39
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