Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.11;
/* solhint-disable no-inline-assembly */
/* solhint-disable reason-string */

import "../non-upgradeable/TWAccount.sol";
import "../non-upgradeable/Account.sol";
import "../utils/BaseRouter.sol";

// $$\ $$\ $$\ $$\ $$\
Expand All @@ -17,7 +17,7 @@ import "../utils/BaseRouter.sol";
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract TWDynamicAccount is TWAccount, BaseRouter {
contract DynamicAccount is Account, BaseRouter {
/*///////////////////////////////////////////////////////////////
Constants
//////////////////////////////////////////////////////////////*/
Expand All @@ -28,9 +28,9 @@ contract TWDynamicAccount is TWAccount, BaseRouter {
Constructor and Initializer
//////////////////////////////////////////////////////////////*/

receive() external payable override(Router, TWAccount) {}
receive() external payable override(Router, Account) {}

constructor(IEntryPoint _entrypoint) TWAccount(_entrypoint) {}
constructor(IEntryPoint _entrypoint) Account(_entrypoint) {}

function initialize(address _defaultAdmin) public override initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
Expand All @@ -42,7 +42,7 @@ contract TWDynamicAccount is TWAccount, BaseRouter {
//////////////////////////////////////////////////////////////*/

/// @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override(TWAccount, BaseRouter) returns (bool) {
function supportsInterface(bytes4 interfaceId) public view virtual override(Account, BaseRouter) returns (bool) {
return
interfaceId == type(IBaseRouter).interfaceId ||
interfaceId == type(IRouter).interfaceId ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import "@openzeppelin/contracts/proxy/Clones.sol";
import "../../lib/TWStringSet.sol";

// Interface
import "./../interfaces/ITWAccountFactory.sol";
import "./../interfaces/IAccountFactory.sol";

// Smart wallet implementation
import "./TWDynamicAccount.sol";
import "./DynamicAccount.sol";

// $$\ $$\ $$\ $$\ $$\
// $$ | $$ | \__| $$ | $$ |
Expand All @@ -21,21 +21,21 @@ import "./TWDynamicAccount.sol";
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract TWDynamicAccountFactory is ITWAccountFactory, Multicall {
contract DynamicAccountFactory is IAccountFactory, Multicall {
using TWStringSet for TWStringSet.Set;

/*///////////////////////////////////////////////////////////////
State
//////////////////////////////////////////////////////////////*/

TWDynamicAccount private immutable _accountImplementation;
DynamicAccount private immutable _accountImplementation;

/*///////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint) {
_accountImplementation = new TWDynamicAccount(_entrypoint);
_accountImplementation = new DynamicAccount(_entrypoint);
}

/*///////////////////////////////////////////////////////////////
Expand All @@ -54,7 +54,7 @@ contract TWDynamicAccountFactory is ITWAccountFactory, Multicall {

account = Clones.cloneDeterministic(impl, salt);

TWAccount(payable(account)).initialize(_admin);
Account(payable(account)).initialize(_admin);

emit AccountCreated(account, _admin, _accountId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

interface ITWAccountFactory {
interface IAccountFactory {
/*///////////////////////////////////////////////////////////////
Events
//////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ import "../../dynamic-contracts/extension/PermissionsEnumerable.sol";
Storage layout
//////////////////////////////////////////////////////////////*/

library TWAccountStorage {
bytes32 internal constant TWACCOUNT_STORAGE_POSITION = keccak256("twaccount.storage");
library AccountStorage {
bytes32 internal constant ACCOUNT_STORAGE_POSITION = keccak256("account.storage");

struct Data {
uint256 nonce;
}

function accountStorage() internal pure returns (Data storage twaccountData) {
bytes32 position = TWACCOUNT_STORAGE_POSITION;
function accountStorage() internal pure returns (Data storage accountData) {
bytes32 position = ACCOUNT_STORAGE_POSITION;
assembly {
twaccountData.slot := position
accountData.slot := position
}
}
}

contract TWAccountCore is Initializable, Multicall, BaseAccount {
contract AccountCore is Initializable, Multicall, BaseAccount {
using ECDSA for bytes32;

/*///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -79,8 +79,8 @@ contract TWAccountCore is Initializable, Multicall, BaseAccount {

/// @notice Returns the nonce of the account.
function nonce() public view virtual override returns (uint256) {
TWAccountStorage.Data storage twaccountData = TWAccountStorage.accountStorage();
return twaccountData.nonce;
AccountStorage.Data storage accountData = AccountStorage.accountStorage();
return accountData.nonce;
}

/// @notice Returns the EIP 4337 entrypoint contract.
Expand Down Expand Up @@ -109,7 +109,7 @@ contract TWAccountCore is Initializable, Multicall, BaseAccount {

/// @notice Withdraw funds for this account from Entrypoint.
function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public {
require(_hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "TWAccount: not admin");
require(_hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Account: not admin");
entryPoint().withdrawTo(withdrawAddress, amount);
}

Expand All @@ -119,8 +119,8 @@ contract TWAccountCore is Initializable, Multicall, BaseAccount {

/// @dev Validates the nonce of a user operation and updates account nonce.
function _validateAndUpdateNonce(UserOperation calldata userOp) internal override {
TWAccountStorage.Data storage data = TWAccountStorage.accountStorage();
require(data.nonce == userOp.nonce, "TWAccount: invalid nonce");
AccountStorage.Data storage data = AccountStorage.accountStorage();
require(data.nonce == userOp.nonce, "Account: invalid nonce");

data.nonce += 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import "../../openzeppelin-presets/utils/cryptography/ECDSA.sol";
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract TWAccountExtension is ContractMetadata, PermissionsEnumerable, ERC721Holder, ERC1155Holder {
contract AccountExtension is ContractMetadata, PermissionsEnumerable, ERC721Holder, ERC1155Holder {
using ECDSA for bytes32;

/*///////////////////////////////////////////////////////////////
Expand All @@ -50,7 +50,7 @@ contract TWAccountExtension is ContractMetadata, PermissionsEnumerable, ERC721Ho
modifier onlyAdminOrEntrypoint() {
require(
msg.sender == entrypointContract || hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
"TWAccount: not admin or EntryPoint."
"Account: not admin or EntryPoint."
);
_;
}
Expand Down Expand Up @@ -86,10 +86,7 @@ contract TWAccountExtension is ContractMetadata, PermissionsEnumerable, ERC721Ho
uint256[] calldata _value,
bytes[] calldata _calldata
) external virtual onlyAdminOrEntrypoint {
require(
_target.length == _calldata.length && _target.length == _value.length,
"TWAccount: wrong array lengths."
);
require(_target.length == _calldata.length && _target.length == _value.length, "Account: wrong array lengths.");
for (uint256 i = 0; i < _target.length; i++) {
_call(_target[i], _value[i], _calldata[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pragma solidity ^0.8.11;
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

import "./TWAccountCore.sol";
import "./AccountCore.sol";
import "lib/dynamic-contracts/src/core/Router.sol";

contract TWManagedAccount is TWAccountCore, Router {
contract ManagedAccount is AccountCore, Router {
address public factory;

constructor(IEntryPoint _entrypoint) TWAccountCore(_entrypoint) {}
constructor(IEntryPoint _entrypoint) AccountCore(_entrypoint) {}

/// @notice Initializes the smart contract wallet.
function initialize(address _defaultAdmin) public virtual override initializer {
Expand All @@ -29,7 +29,7 @@ contract TWManagedAccount is TWAccountCore, Router {
}

// solhint-disable-next-line no-empty-blocks
receive() external payable virtual override(Router, TWAccountCore) {}
receive() external payable virtual override(Router, AccountCore) {}

/// @notice Returns the implementation contract address for a given function signature.
function getImplementationForFunction(bytes4) public view virtual override returns (address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import "@openzeppelin/contracts/proxy/Clones.sol";
import "../../dynamic-contracts/extension/PermissionsEnumerable.sol";

// Interface
import "../interfaces/ITWAccountFactory.sol";
import "../interfaces/IAccountFactory.sol";

// Smart wallet implementation
import "./TWManagedAccount.sol";
import "./ManagedAccount.sol";

// $$\ $$\ $$\ $$\ $$\
// $$ | $$ | \__| $$ | $$ |
Expand All @@ -23,20 +23,20 @@ import "./TWManagedAccount.sol";
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract TWManagedAccountFactory is ITWAccountFactory, Multicall, PermissionsEnumerable, BaseRouter {
contract TWManagedAccountFactory is IAccountFactory, Multicall, PermissionsEnumerable, BaseRouter {
/*///////////////////////////////////////////////////////////////
State
//////////////////////////////////////////////////////////////*/

TWManagedAccount private immutable _accountImplementation;
ManagedAccount private immutable _accountImplementation;

/*///////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_accountImplementation = new TWManagedAccount(_entrypoint);
_accountImplementation = new ManagedAccount(_entrypoint);
}

/*///////////////////////////////////////////////////////////////
Expand All @@ -55,7 +55,7 @@ contract TWManagedAccountFactory is ITWAccountFactory, Multicall, PermissionsEnu

account = Clones.cloneDeterministic(impl, salt);

TWManagedAccount(payable(account)).initialize(_admin);
ManagedAccount(payable(account)).initialize(_admin);

emit AccountCreated(account, _admin, _accountId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ import "../../openzeppelin-presets/utils/cryptography/ECDSA.sol";
Storage layout
//////////////////////////////////////////////////////////////*/

library TWAccountStorage {
bytes32 internal constant TWACCOUNT_STORAGE_POSITION = keccak256("twaccount.storage");
library AccountStorage {
bytes32 internal constant ACCOUNT_STORAGE_POSITION = keccak256("account.storage");

struct Data {
uint256 nonce;
}

function accountStorage() internal pure returns (Data storage twaccountData) {
bytes32 position = TWACCOUNT_STORAGE_POSITION;
function accountStorage() internal pure returns (Data storage accountData) {
bytes32 position = ACCOUNT_STORAGE_POSITION;
assembly {
twaccountData.slot := position
accountData.slot := position
}
}
}

contract TWAccount is
contract Account is
Initializable,
Multicall,
BaseAccount,
Expand Down Expand Up @@ -87,7 +87,7 @@ contract TWAccount is
modifier onlyAdminOrEntrypoint() {
require(
msg.sender == address(entryPoint()) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
"TWAccount: not admin or EntryPoint."
"Account: not admin or EntryPoint."
);
_;
}
Expand All @@ -106,8 +106,8 @@ contract TWAccount is

/// @notice Returns the nonce of the account.
function nonce() public view virtual override returns (uint256) {
TWAccountStorage.Data storage twaccountData = TWAccountStorage.accountStorage();
return twaccountData.nonce;
AccountStorage.Data storage accountData = AccountStorage.accountStorage();
return accountData.nonce;
}

/// @notice Returns the EIP 4337 entrypoint contract.
Expand Down Expand Up @@ -144,10 +144,7 @@ contract TWAccount is
uint256[] calldata _value,
bytes[] calldata _calldata
) external virtual onlyAdminOrEntrypoint {
require(
_target.length == _calldata.length && _target.length == _value.length,
"TWAccount: wrong array lengths."
);
require(_target.length == _calldata.length && _target.length == _value.length, "Account: wrong array lengths.");
for (uint256 i = 0; i < _target.length; i++) {
_call(_target[i], _value[i], _calldata[i]);
}
Expand Down Expand Up @@ -183,8 +180,8 @@ contract TWAccount is

/// @dev Validates the nonce of a user operation and updates account nonce.
function _validateAndUpdateNonce(UserOperation calldata userOp) internal override {
TWAccountStorage.Data storage data = TWAccountStorage.accountStorage();
require(data.nonce == userOp.nonce, "TWAccount: invalid nonce");
AccountStorage.Data storage data = AccountStorage.accountStorage();
require(data.nonce == userOp.nonce, "Account: invalid nonce");

data.nonce += 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import "@openzeppelin/contracts/proxy/Clones.sol";
import "../../lib/TWStringSet.sol";

// Interface
import "./../interfaces/ITWAccountFactory.sol";
import "./../interfaces/IAccountFactory.sol";

// Smart wallet implementation
import "./TWAccount.sol";
import "./Account.sol";

// $$\ $$\ $$\ $$\ $$\
// $$ | $$ | \__| $$ | $$ |
Expand All @@ -21,21 +21,21 @@ import "./TWAccount.sol";
// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract TWAccountFactory is ITWAccountFactory, Multicall {
contract AccountFactory is IAccountFactory, Multicall {
using TWStringSet for TWStringSet.Set;

/*///////////////////////////////////////////////////////////////
State
//////////////////////////////////////////////////////////////*/

TWAccount private immutable _accountImplementation;
Account private immutable _accountImplementation;

/*///////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint) {
_accountImplementation = new TWAccount(_entrypoint);
_accountImplementation = new Account(_entrypoint);
}

/*///////////////////////////////////////////////////////////////
Expand All @@ -54,7 +54,7 @@ contract TWAccountFactory is ITWAccountFactory, Multicall {

account = Clones.cloneDeterministic(impl, salt);

TWAccount(payable(account)).initialize(_admin);
Account(payable(account)).initialize(_admin);

emit AccountCreated(account, _admin, _accountId);

Expand Down
Loading