Account abstraction
Context (Problem, Motivation, Solution)
https://github.com/0xFableOrg/0xFable/issues/31 and https://github.com/0xFableOrg/0xFable/issues/32 (Issue 31 is dependent on issue 32 as account abstraction toolings cannot work on Anvil node)
Describe Your Changes
- Use rollop to be the dev node rather than Anvil. Include Makefile commands to start rollop node and account abstraction toolings.
- Integrate permissionlessjs to deal with smart contract account
- Users can opt to use a burner account which generates a private key and store on browser. The private key is then used as the signer of the smart contract account. Transactions are sponsored by the paymaster. (So the notion of "accounts" are abstracted away from end users)
Checklist
- [ ] I have performed a self-review of my code
- [ ] I ran
make checkand fixed resulting issues - [ ] I ran the relevant tests and they all pass
- [ ] I wrote tests for my new features, or added regression tests for the bug I fixed
Testing
If you didn't write tests, explain how you made sure the code was correct and working as intended.
Just opening this as a draft PR - there are still a bunch of things to be done. Will be easier to collaborate and might need some help too.
Currently main thing to figure out is how to connect smartAccountClient (defined here) to wagmi config. I think the idea is make it into a connector, though there are some typing incompatibility issues.
Once that is figured out and tested, a bunch of other things to be done are:
- Clean up all use of Anvil
- Remove hardcoded values of localhost port (probably better to manage them through environment variables)
- Private key management and storage on the browser
- Some other clean up
In the BurnerConnector, the wallet client is set here: https://github.com/0xFableOrg/0xFable/blob/master/packages/webapp/src/wagmi/BurnerConnector.ts#L63-L67
So you could assign the client there for that connector.
Connectors are set here: https://github.com/0xFableOrg/0xFable/blob/account-abstraction/packages/webapp/src/chain.ts#L78-L79
getDefaultConnectors in ConnectKit: https://github.com/family/connectkit/blob/35aeecd0cf12ef265beba724ae9b01fdc34b19b6/packages/connectkit/src/defaultConnectors.ts, populates them with a bunch of connectors defined in wagmi itself.
Here's the one used for Metamask: https://github.com/wevm/wagmi/blob/1.x/packages/connectors/src/injected.ts#L167-L181
The one from Coinbase Wallet is identical, but does not inherit InjectedConnector: https://github.com/wevm/wagmi/blob/1.x/packages/connectors/src/injected.ts#L167-L181 (the other ones, WalletConnect, Safe, ... seem similar, though maybe there's some slight subtlety I missed).
I think the move might be to monkey patch those to replace their getWalletClient function to return the original when not using account abstraction, and the AA one otherwise.