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

Cross chain transactions #586

Open
wants to merge 111 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
dd378a1
created interfaces for Account recovery feature
alfheimrShiven Oct 16, 2023
37e2c9d
guardian interface and contract
alfheimrShiven Oct 17, 2023
1b09442
added test suite for Guardian.sol
alfheimrShiven Oct 20, 2023
3f4e74c
Merge branch 'thirdweb-dev:main' into account-social-recovery
alfheimrShiven Oct 20, 2023
a3cc320
AccountGuardian contract
alfheimrShiven Oct 20, 2023
f22fb72
added test suite for AccountGuardian contract
alfheimrShiven Oct 21, 2023
d3e6fe0
dependency injection for social recovery feature
alfheimrShiven Oct 21, 2023
3dba350
account lock req creation, signature validation and acceptance check
alfheimrShiven Oct 24, 2023
2ee0e32
Chainlink automation for lock request evaluation and lock account fea…
alfheimrShiven Oct 26, 2023
c642267
refactored deploy script for smart account util contracts
alfheimrShiven Oct 27, 2023
c476031
Deploy script for util contracts and its test
alfheimrShiven Oct 28, 2023
d7bd5d6
added link to feature doc in Readme
alfheimrShiven Oct 28, 2023
5bd148f
Merge pull request #1 from alfheimrShiven/account-social-recovery
alfheimrShiven Oct 30, 2023
14dfa8f
fixing..
alfheimrShiven Oct 30, 2023
8395b06
brought back DeployGuardian as DeploySmartAccountUtilContracts script…
alfheimrShiven Oct 30, 2023
b106090
Merge pull request #2 from alfheimrShiven/account-social-recovery
alfheimrShiven Oct 30, 2023
8001b8b
moved account util contract deployments to Account.sol, commented out…
alfheimrShiven Nov 1, 2023
c72f748
switched AccountLock to single instance deployment (as per the system…
alfheimrShiven Nov 2, 2023
a8ca25f
Merge pull request #3 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 2, 2023
19f18e3
restoring to util contract deployments to createAccount()
alfheimrShiven Nov 4, 2023
0ddb444
Changed the approach of calling Account.sol from AccountLock.sol
alfheimrShiven Nov 8, 2023
9c15308
added modifier to restrict an Account's lock status change by Account…
alfheimrShiven Nov 8, 2023
493001e
Merge pull request #4 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 8, 2023
f6b4843
made AccountGuardianTest compatible with deployment of AccountGuardia…
alfheimrShiven Nov 8, 2023
53b9588
replaced DeployGuardian script with DeploySmartAccountUtilContracts s…
alfheimrShiven Nov 10, 2023
38e568d
Merge pull request #5 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 10, 2023
3f763ed
sending AccountLock address while initilizing Account clones for acco…
alfheimrShiven Nov 14, 2023
665f243
Merge pull request #6 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 14, 2023
bb6c8ba
AccountLock tests: createLockRequest() unit tests
alfheimrShiven Nov 14, 2023
dc9a859
[Buggy] ECDSA.recover(hash, signature) throwing error
alfheimrShiven Nov 16, 2023
5a7d6aa
Merge pull request #7 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 16, 2023
a6f7e33
foundry error
codypharm Nov 17, 2023
82c9281
depencies added but errors persist
codypharm Nov 17, 2023
598de03
error comntinues
codypharm Nov 17, 2023
3be95eb
build error persists
codypharm Nov 17, 2023
896717d
updated chainlink remappings
alfheimrShiven Nov 17, 2023
b15ce17
ECDSA.recover(...) bug fixed, made lockRequest hash EIP 191 compatibl…
alfheimrShiven Nov 17, 2023
fe87435
Merge pull request #8 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 17, 2023
819a0a7
unlock request feature, refactored concensys evaluation to both lock/…
alfheimrShiven Nov 18, 2023
a764396
Merge pull request #9 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 18, 2023
4ae52bb
added unit tests for account unlock feature
alfheimrShiven Nov 18, 2023
a50e537
Merge pull request #10 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 19, 2023
0aee37b
Makefile
alfheimrShiven Nov 21, 2023
ad2a9b1
Merge pull request #11 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 22, 2023
cb6691e
cross chain transaction now includes estimated amount deposit
codypharm Nov 28, 2023
11c2173
slippage calvualtion added
codypharm Nov 29, 2023
1687b2f
bugs fixed
codypharm Nov 30, 2023
0bc9b51
stopped at this stage
codypharm Dec 4, 2023
20e1477
added IAccountRecovery
alfheimrShiven Dec 5, 2023
ecab36c
native payment intiation done
codypharm Dec 5, 2023
c3c5a31
link transfer initiator done
codypharm Dec 5, 2023
e822483
Account Recovery interface
alfheimrShiven Dec 5, 2023
42322c5
stock with userOp
codypharm Dec 5, 2023
0f95847
external signing implemented
codypharm Dec 5, 2023
37c3a36
recovery request guardian signature collection & concensus evaluation
alfheimrShiven Dec 7, 2023
78bb350
used isValidSignature but review is needed
codypharm Dec 7, 2023
7ceeb42
comments added and code made more dynamic
codypharm Dec 7, 2023
0bf4596
private key restoration
alfheimrShiven Dec 8, 2023
fc7af00
now using just one estimate function
codypharm Dec 9, 2023
4d4a248
proceed now has _
codypharm Dec 9, 2023
5c6ada8
Merge pull request #13 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 9, 2023
aaee738
Merge branch 'main' into cross-chain-transactions
codypharm Dec 9, 2023
b81a628
cross chain contracts deployed with accessible address
codypharm Dec 10, 2023
921b5c8
merge added
codypharm Dec 10, 2023
706d43e
getter added for account lock
codypharm Dec 10, 2023
c48ef73
Merge pull request #12 from alfheimrShiven/cross-chain-transactions
codypharm Dec 10, 2023
b818a8b
cross chain script sample added
codypharm Dec 10, 2023
faed719
Merge pull request #14 from alfheimrShiven/cross-chain-script
codypharm Dec 10, 2023
67ab98b
interface changes
alfheimrShiven Dec 10, 2023
e838c6d
Updated contract deploy script, fixed backward compatibility issues d…
alfheimrShiven Dec 10, 2023
318e840
Code optimized
codypharm Dec 10, 2023
7ec5c55
restructured functions
codypharm Dec 10, 2023
c036372
link address also added to constructot
codypharm Dec 10, 2023
3ad8a0b
master deployment updated
codypharm Dec 11, 2023
648be6c
one step skipped
codypharm Dec 11, 2023
e426334
last trial
codypharm Dec 11, 2023
21c1db4
Merge pull request #16 from alfheimrShiven/Fix-compilation
alfheimrShiven Dec 11, 2023
13454b1
Merge pull request #15 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 11, 2023
9994ac3
Update README.md
alfheimrShiven Dec 11, 2023
ddf5634
building cancelling
codypharm Dec 16, 2023
4e07d7c
resolved conflicts with main
alfheimrShiven Dec 18, 2023
4d11bd3
added AccountRecovery to deploy script
alfheimrShiven Dec 19, 2023
d968a8b
commented out both CCIP contracts [build still failing]
alfheimrShiven Dec 19, 2023
b17bd89
[FIX]: Fixed the stack too deep error by removing the _router, _link …
alfheimrShiven Dec 19, 2023
4b0133d
updating owner of smart account
alfheimrShiven Dec 22, 2023
89d12a4
Email verification to generate recovery request
alfheimrShiven Dec 24, 2023
669d16f
uncommented the CCIP contracts
alfheimrShiven Dec 24, 2023
15718b2
moved the deployment of CCIP contracts from BaseAccountFactory to non…
alfheimrShiven Dec 24, 2023
6a28d89
Merge pull request #17 from alfheimrShiven/revert/debugging
alfheimrShiven Dec 24, 2023
6413321
merged with main
alfheimrShiven Dec 24, 2023
14cc533
Merge pull request #18 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 24, 2023
a91ba30
updated account util deploy script and test
alfheimrShiven Dec 25, 2023
e12640a
Moved smart account creation to deploy script, updated deployment scr…
alfheimrShiven Dec 27, 2023
ab94b18
Merge pull request #19 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 27, 2023
17ed4de
generateRecoveryReq(..) tests
alfheimrShiven Dec 31, 2023
b9b472e
collectGuardianSignaturesOnRecoveryRequest(..) unit tests
alfheimrShiven Dec 31, 2023
b5490d4
refactored AccountRecovery unit tests
alfheimrShiven Dec 31, 2023
6abbb81
Consensus evaluation tests
alfheimrShiven Dec 31, 2023
f694b4f
Merge pull request #20 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 31, 2023
abbeeff
fixed Account::updateAdmin() function signature and call from Account…
alfheimrShiven Jan 3, 2024
6454a6c
Merge pull request #21 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 3, 2024
625340b
removed _generateSalt dependency on account admin, as it can get upda…
alfheimrShiven Jan 4, 2024
b0d399a
finished AccountRecovery unit tests. Coverage: 92%
alfheimrShiven Jan 4, 2024
af976db
Merge pull request #22 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 4, 2024
faf0a62
reduced params for commitEmailVerificationHash()
alfheimrShiven Jan 5, 2024
41099ca
Merge pull request #23 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 5, 2024
047eac0
updated Readme: Problem statement, Architecture
alfheimrShiven Jan 6, 2024
548776e
Merge pull request #24 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 6, 2024
d4162c5
updated Readme: Benefits of smart wallets
alfheimrShiven Jan 8, 2024
d54fdb5
Readme touchups
alfheimrShiven Jan 8, 2024
8b9536a
Merge pull request #25 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

4 changes: 4 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ANVIL_PRIVATE_KEY=
ANVIL_PUBLIC_KEY=
ANVIL_RPC_URL=http://127.0.0.1:8545

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
[submodule "lib/dynamic-contracts"]
path = lib/dynamic-contracts
url = https://github.com/thirdweb-dev/dynamic-contracts
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-include .env

.PHONY: all test test_anvil clean deploy fund help install snapshot format anvil

help:
@echo "Usage:"
@echo " make deploy [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""
@echo ""
@echo " make fund [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""

all: clean remove update build deploy

# Clean the repo
clean :; forge clean

# Remove modules
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules"

# Update Dependencies
update:; forge update

build:; forge build

test :; forge test

test_anvil :; forge test --rpc-url $(ANVIL_RPC_URL)

snapshot :; forge snapshot

format :; forge fmt

anvil :; anvil -m 'test test test test test test test test test test test junk' --steps-tracing --block-time 1

NETWORK_ARGS := --rpc-url $(ANVIL_RPC_URL) --private-key $(ANVIL_PRIVATE_KEY) --broadcast

ifeq ($(findstring --network sepolia,$(ARGS)),--network sepolia)
NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(SEPOLIA_PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
endif

ifeq ($(findstring --network ganache,$(ARGS)),--network ganache)
NETWORK_ARGS := --rpc-url $(GANACHE_RPC_URL) --private-key $(GANACHE_PRIVATE_KEY) --broadcast -vvvv
endif

deploy:
@forge script scripts/DeploySmartAccountUtilContracts.s.sol:DeploySmartAccountUtilContracts $(NETWORK_ARGS)
185 changes: 55 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,143 +1,68 @@
<p align="center">
<h1 align="center">CryptoPhoenix Smart Wallet Contracts</h1>
<p>CryptoPhoenix Wallet SDK is a rollup to thirdweb's smart wallet contracts and offers: <br />
<ol>
<li>Smart Accounts</li>
<li>Social Account Locking</li>
<li>Social Account Recovery</li>
<li>Guardian Management</li>
</ol>

## Problem Statement
As we all know, a wallet is a gateway to web3 but the wallet experience is unfortunately broken! For a user to interact with a blockchain, they not only have to **create a wallet but also secure their private keys and seed phrase, purchase native tokes to pay for gas, and sign every single action** that they take on a dApp.

Such an intimidating user experience for newcomers is a big obstacle in the mass adoption of web3 and CryptoPhoenix Wallet SDK is here to change this through its **Account abstraction technology.**

## Smart wallets and its features
Smart wallets are wallets that are controlled by a smart contract and have the following key benefits-
<ol>
<li>
<h4>Abstracted user experience: </h4>
Eliminates the need to manage private keys or seed phrase, making it easier and safer for users to experience Dapps.
</li>
<li>
<h4>Enable gasless transactions:</h4>
Dapps providing smart account can sponser gas on behalf of their users therefore reducing investment to entry and drastically improving user experience as users now don't have to approve each transaction they make with the Dapp.
</li>
<li>
<h4>Enhanced security through account locking, social recovery and multisig: </h4>
In case the user lose access to their wallet, they can immediately lock their account assets, holding all withdrawal transactions, and can even recover access to their accounts through concensus of their account guardians (trusted people who the user allots to help recover their account in case required). <br />
Smart accounts can also provide multisig capabilities, requiring multiple signatures on a transaction, before it's executed, thus enchancing security.

<li><h4>Automation of transactions</h4>
Enables self executing transactions when certain defined conditions are met like approving a predefined number of tokens to an entity based on fixed time intervals, stop loss and take profit orders, recurring subscriptions, etc.
</li>
</ol>

## Architecture

<img src="./images/architecture.png" width="600" alt="cryptophoenix_architecture">
<br/>
<br />
<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/typescript-sdk/blob/main/logo.svg?raw=true" width="200" alt=""/></a>
<br />
</p>
<h1 align="center">thirdweb Contracts</h1>
<p align="center">
<a href="https://www.npmjs.com/package/@thirdweb-dev/contracts"><img src="https://img.shields.io/npm/v/@thirdweb-dev/contracts?color=red&logo=npm" alt="npm version"/></a>
<a href="https://github.com/thirdweb-dev/contracts/actions"><img alt="Build Status" src="https://github.com/thirdweb-dev/contracts/actions/workflows/tests.yml/badge.svg"/></a>
<a href="https://discord.gg/thirdweb"><img alt="Join our Discord!" src="https://img.shields.io/discord/834227967404146718.svg?color=7289da&label=discord&logo=discord&style=flat"/></a>

</p>
<p align="center"><strong>Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI</strong></p>
<br />

## Installation

```shell
# Forge projects
forge install https://github.com/thirdweb-dev/contracts

# Hardhat / npm based projects
npm i @thirdweb-dev/contracts
```

```bash
contracts
|
|-- extension: "extensions that can be inherited by NON-upgradeable contracts"
| |-- interface: "interfaces of all extension contracts"
| |-- upgradeable: "extensions that can be inherited by upgradeable contracts"
| |-- [$prebuilt-category]: "legacy extensions written specifically for a prebuilt contract"
|
|-- base: "NON-upgradeable base contracts to build on top of"
| |-- interface: "interfaces for all base contracts"
| |-- upgradeable: "upgradeable base contracts to build on top of"
|
|-- prebuilt: "audited, ready-to-deploy thirdweb smart contracts"
| |-- interface: "interfaces for all prebuilt contracts"
| |--[$prebuilt-category]: "feature-based group of prebuilt contracts"
| |-- unaudited: "yet-to-audit thirdweb smart contracts"
| |-- [$prebuilt-category]: "feature-based group of prebuilt contracts"
|
|-- infra: "onchain infrastructure contracts"
| |-- interface: "interfaces for all infrastructure contracts"
|
|-- eip: "implementations of relevant EIP standards"
| |-- interface "all interfaces of relevant EIP standards"
|
|-- lib: "Solidity libraries"
|
|-- external-deps: "modified / copied over external dependencies"
| |-- openzeppelin: "modified / copied over openzeppelin dependencies"
| |-- chainlink: "modified / copied over chainlink dependencies"
|
|-- legacy-contracts: "maintained legacy thirdweb contracts"
```

## Running Tests

1. `yarn`: install contracts dependencies
2. `forge install`: install tests dependencies
3. `forge test`: run the tests

This repository is a [forge](https://github.com/foundry-rs/foundry/tree/master/forge) project.

First install the relevant dependencies of the project:

```bash
yarn

forge install
```

To compile contracts, run:

```bash
forge build
```

To run tests:

```bash
forge test
```

## Pre-built Contracts

Pre-built contracts are written by the thirdweb team, and cover the most common use cases for smart contracts.

- [DropERC20](https://thirdweb.com/deployer.thirdweb.eth/DropERC20)
- [DropERC721](https://thirdweb.com/deployer.thirdweb.eth/DropERC721)
- [DropERC1155](https://thirdweb.com/deployer.thirdweb.eth/DropERC1155)
- [SignatureDrop](https://thirdweb.com/deployer.thirdweb.eth/SignatureDrop)
- [Marketplace](https://thirdweb.com/deployer.thirdweb.eth/Marketplace)
- [Multiwrap](https://thirdweb.com/deployer.thirdweb.eth/Multiwrap)
- [TokenERC20](https://thirdweb.com/deployer.thirdweb.eth/TokenERC20)
- [TokenERC721](https://thirdweb.com/deployer.thirdweb.eth/TokenERC721)
- [TokenERC1155](https://thirdweb.com/deployer.thirdweb.eth/TokenERC1155)
- [VoteERC20](https://thirdweb.com/deployer.thirdweb.eth/VoteERC20)
- [Split](https://thirdweb.com/deployer.thirdweb.eth/Split)

[Learn more about pre-built contracts](https://portal.thirdweb.com/pre-built-contracts)

## Extensions

Extensions are building blocks that help enrich smart contracts with features.

Some blocks come packaged together as Base Contracts, which come with a full set of features out of the box that you can modify and extend. These contracts are available at `contracts/base/`.

Other (smaller) blocks are Features, which provide a way for you to pick and choose which individual pieces you want to put into your contract; with full customization of how those features work. These are available at `contracts/extension/`.

[Learn more about extensions](https://portal.thirdweb.com/extensions)

## Contract Audits
[![YouTube](https://img.shields.io/badge/YouTube-Video-red?style=for-the-badge&logo=youtube)](https://youtu.be/0zq2YdOYFUo?si=Ng6favRkGL9faG_Y)

- [Audit 1](audit-reports/audit-1.pdf)
- [Audit 2](audit-reports/audit-2.pdf)
- [Audit 3](audit-reports/audit-3.pdf)
- [Audit 4](audit-reports/audit-4.pdf)
- [Audit 5](audit-reports/audit-5.pdf)
- [Audit 6](audit-reports/audit-6.pdf)
- [Audit 7](audit-reports/audit-7.pdf)
- [Audit 8](audit-reports/audit-8.pdf)
- [Audit 9](audit-reports/audit-9.pdf)
- [Audit 10](audit-reports/audit-10.pdf)
- [Audit 11](audit-reports/audit-11.pdf)
- [Audit 12](audit-reports/audit-12.pdf)

## Bug reports
## Contracts
The wallet SDK is a rollup to thirdweb's smart wallet (ERC-4337) contracts. We've added the following contracts to extend it's functionality:
<li> <b>Account.sol:</b>This is the smart contract that powers the smart wallet by offering features like executing single or batched transactions, locking account assets and updating the owner of the smart account incase of an account recovery is made.</li>
<li> <b>AccountGuardian.sol:</b> Used by the user to assign guardians for smart wallet accounts. </li>
<li> <b>Guardian.sol:</b> Powers the guardian interactions, like attending to account lock & recovery requests for the account they are guarding. </li>
<li> <b>AccountLock.sol:</b> Adds features like creating account lock requests and evaluating concensus on them followed by locking/unlocking the account assets.</li>
<li> <b>AccountRecovery.sol:</b> One of the most important contracts adding features like creating account recovery requests and evaluating concensus on them. Once the concensus is achieved, a new embedded wallet is created and made the owner of the smart contract holding all user assets, thus recovering the account.</li>

Found a security issue with our smart contracts? Send bug reports to [email protected] and we'll continue communicating with you from there. We're actively developing a bug bounty program; bug report payouts happen on a case by case basis, for now.

## Feedback
## Documentation

If you have any feedback, please reach out to us at [email protected].
[**CryptoPhoenix Smart Wallet Contract Docs**](https://0xshiven.gitbook.io/cryptophoenix/)

## Authors
## Author:
### Shivendra Singh
[![GitHub](https://img.shields.io/badge/GitHub-Profile-black?logo=github)](https://github.com/alfheimrShiven)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Profile-blue?logo=linkedin)](https://www.linkedin.com/in/shivends)
[![Twitter](https://img.shields.io/badge/Twitter-Profile-blue?logo=twitter)](https://twitter.com/0xShiven)
[![Substack](https://img.shields.io/badge/Substack-Newsletter-orange?logo=substack)](https://0xshiven.substack.com/)

- [thirdweb](https://thirdweb.com)

## License

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

167 changes: 167 additions & 0 deletions broadcast/DeploySmartAccountUtilContracts.s.sol/31337/run-latest.json

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions contracts/extension/upgradeable/AccountPermissions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract contract AccountPermissions is IAccountPermissions, EIP712 {
//isAdmin > 1, remove admin
bool _isAdmin = _req.isAdmin == 1;

_setAdmin(targetSigner, _isAdmin);
_setAdmin(targetSigner, _isAdmin, bytes(""));
return;
}

Expand Down Expand Up @@ -138,12 +138,10 @@ abstract contract AccountPermissions is IAccountPermissions, EIP712 {
}

/// @dev Verifies that a request is signed by an authorized account.
function verifySignerPermissionRequest(SignerPermissionRequest calldata req, bytes calldata signature)
public
view
virtual
returns (bool success, address signer)
{
function verifySignerPermissionRequest(
SignerPermissionRequest calldata req,
bytes calldata signature
) public view virtual returns (bool success, address signer) {
signer = _recoverAddress(_encodeRequest(req), signature);
success = !_accountPermissionsStorage().executed[req.uid] && isAdmin(signer);
}
Expand Down Expand Up @@ -214,7 +212,7 @@ abstract contract AccountPermissions is IAccountPermissions, EIP712 {
function _afterSignerPermissionsUpdate(SignerPermissionRequest calldata _req) internal virtual;

/// @notice Makes the given account an admin.
function _setAdmin(address _account, bool _isAdmin) internal virtual {
function _setAdmin(address _account, bool _isAdmin, bytes memory _data) internal virtual {
_accountPermissionsStorage().isAdmin[_account] = _isAdmin;

if (_isAdmin) {
Expand Down
17 changes: 11 additions & 6 deletions contracts/prebuilts/account/dynamic/DynamicAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ contract DynamicAccount is AccountCore, BaseRouter {
Constructor and Initializer
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, Extension[] memory _defaultExtensions)
AccountCore(_entrypoint, msg.sender)
BaseRouter(_defaultExtensions)
{
constructor(
IEntryPoint _entrypoint,
Extension[] memory _defaultExtensions
) AccountCore(_entrypoint, msg.sender) BaseRouter(_defaultExtensions) {
_disableInitializers();
}

/// @notice Initializes the smart contract wallet.
function initialize(address _defaultAdmin, bytes calldata) public override initializer {
function initialize(
address _defaultAdmin,
address _commonGuardian,
address _accountLock,
bytes calldata
) public override initializer {
__BaseRouter_init();
AccountCoreStorage.data().firstAdmin = _defaultAdmin;
_setAdmin(_defaultAdmin, true);
_setAdmin(_defaultAdmin, true, "");
}

/*///////////////////////////////////////////////////////////////
Expand Down
10 changes: 6 additions & 4 deletions contracts/prebuilts/account/dynamic/DynamicAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, IExtension.Extension[] memory _defaultExtensions)
BaseAccountFactory(payable(address(new DynamicAccount(_entrypoint, _defaultExtensions))), address(_entrypoint))
{
constructor(
IEntryPoint _entrypoint,
IExtension.Extension[] memory _defaultExtensions
) BaseAccountFactory(payable(address(new DynamicAccount(_entrypoint, _defaultExtensions))), address(_entrypoint)) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

Expand All @@ -40,9 +41,10 @@ contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
function _initializeAccount(
address _account,
address _admin,
address _commonGuardian,
bytes calldata _data
) internal override {
DynamicAccount(payable(_account)).initialize(_admin, _data);
DynamicAccount(payable(_account)).initialize(_admin, _commonGuardian, address(accountLock), _data);
}

/// @dev Returns whether contract metadata can be set in the given execution context.
Expand Down
6 changes: 6 additions & 0 deletions contracts/prebuilts/account/interface/IAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ pragma solidity ^0.8.12;
import "../utils/UserOperation.sol";

interface IAccount {
///////////////////////
//// Events //////////
///////////////////////
event AccountLocked(address indexed account);
event AdminUpdated(address indexed newAdmin);

/**
* Validate user's signature and nonce
* the entryPoint will make the call to the recipient only if this validation call returns successfully.
Expand Down
Loading