Skip to content

Commit

Permalink
audit external vs. public
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsoncusack committed Apr 19, 2024
1 parent ceb82f2 commit 8faed5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
39 changes: 22 additions & 17 deletions src/CoinbaseSmartWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,6 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
_initializeOwners(owners);
}

/// @notice Initializes the account with the the given owners.
///
/// @dev Reverts if the account has already been initialized.
///
/// @param owners The initial array of owners to initialize this account with.
function initialize(bytes[] calldata owners) public payable virtual {
if (nextOwnerIndex() != 0) {
revert Initialized();
}

_initializeOwners(owners);
}

/// @notice Custom implemenentation of the ERC-4337 `validateUserOp` method. The EntryPoint will
/// make the call to the recipient only if this validation call returns successfully.
/// See `IAccount.validateUserOp()`.
Expand All @@ -135,7 +122,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
///
/// @return validationData The encoded `ValidationData` structure.
function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
public
external
payable
virtual
onlyEntryPoint
Expand Down Expand Up @@ -178,7 +165,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
/// useful for syncing owner changes.
///
/// @param calls An array of calldata to use for separate self calls.
function executeWithoutChainIdValidation(bytes[] calldata calls) public payable virtual onlyEntryPoint {
function executeWithoutChainIdValidation(bytes[] calldata calls) external payable virtual onlyEntryPoint {
for (uint256 i; i < calls.length; i++) {
bytes calldata call = calls[i];
bytes4 selector = bytes4(call[0:4]);
Expand All @@ -197,7 +184,12 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
/// @param target The target call address.
/// @param value The call value to user.
/// @param data The raw call data.
function execute(address target, uint256 value, bytes calldata data) public payable virtual onlyEntryPointOrOwner {
function execute(address target, uint256 value, bytes calldata data)
external
payable
virtual
onlyEntryPointOrOwner
{
_call(target, value, data);
}

Expand All @@ -206,12 +198,25 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
/// @dev Can only be called by the Entrypoint or an owner of this account (including itself).
///
/// @param calls The list of `Call`s to execute.
function executeBatch(Call[] calldata calls) public payable virtual onlyEntryPointOrOwner {
function executeBatch(Call[] calldata calls) external payable virtual onlyEntryPointOrOwner {
for (uint256 i; i < calls.length; i++) {
_call(calls[i].target, calls[i].value, calls[i].data);
}
}

/// @notice Initializes the account with the the given owners.
///
/// @dev Reverts if the account has already been initialized.
///
/// @param owners The initial array of owners to initialize this account with.
function initialize(bytes[] calldata owners) public payable virtual {
if (nextOwnerIndex() != 0) {
revert Initialized();
}

_initializeOwners(owners);
}

/// @notice Returns the address of the EntryPoint v0.6.
///
/// @return The address of the EntryPoint v0.6
Expand Down
2 changes: 1 addition & 1 deletion src/CoinbaseSmartWalletFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract CoinbaseSmartWalletFactory {
/// @param nonce The nonce of the account, allowing multiple accounts with the same set of initial
/// owners to exist.
function createAccount(bytes[] calldata owners, uint256 nonce)
public
external
payable
virtual
returns (CoinbaseSmartWallet account)
Expand Down
4 changes: 3 additions & 1 deletion test/mocks/MockCoinbaseSmartWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ contract MockCoinbaseSmartWallet is CoinbaseSmartWallet {
assembly {
mstore(0x40, add(mload(0x40), mod(filler, 0x40)))
}
return super.executeBatch(calls);
for (uint256 i; i < calls.length; i++) {
_call(calls[i].target, calls[i].value, calls[i].data);
}
}
}

0 comments on commit 8faed5a

Please sign in to comment.