Skip to content

Commit

Permalink
Merge 5753bb8 into 1c0fd0b
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises authored Aug 14, 2024
2 parents 1c0fd0b + 5753bb8 commit 59ffaa9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion contracts/Nexus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra
(address target, bytes memory data) = abi.decode(innerCall, (address, bytes));
bool success;
// Perform the call to the target contract with the decoded data.
(success, innerCallRet) = target.call(data);
(success, innerCallRet) = target.call{value: msg.value}(data);
// Ensure the call was successful.
require(success, InnerCallFailed());
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/ModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract contract ModuleManager is Storage, Receiver, EIP712, IModuleManagerEven
// Then the address without padding is stored right after the calldata
mstore(calldatasize(), shl(96, caller()))

if iszero(call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)) {
if iszero(call(gas(), handler, callvalue(), 0, add(calldatasize(), 20), 0, 0)) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/BiconomyMetaFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract BiconomyMetaFactory is Stakeable {
/// @return createdAccount The address of the newly created Nexus account.
function deployWithFactory(address factory, bytes calldata factoryData) external payable returns (address payable createdAccount) {
require(factoryWhitelist[address(factory)], FactoryNotWhitelisted());
(bool success, bytes memory returnData) = factory.call(factoryData);
(bool success, bytes memory returnData) = factory.call{ value: msg.value }(factoryData);

// Check if the call was successful
require(success, CallToDeployWithFactoryFailed());
Expand Down
3 changes: 3 additions & 0 deletions contracts/factory/K1ValidatorFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ contract K1ValidatorFactory is Stakeable {
/// @notice Error thrown when a zero address is provided for the implementation, K1 validator, or bootstrapper.
error ZeroAddressNotAllowed();

/// @notice Error thrown when an inner call fails.
error InnerCallFailed();

/// @notice Constructor to set the immutable variables.
/// @param implementation The address of the Nexus implementation to be used for all deployments.
/// @param factoryOwner The address of the factory owner.
Expand Down
2 changes: 2 additions & 0 deletions contracts/factory/NexusAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ contract NexusAccountFactory is Stakeable, INexusFactory {
if (!alreadyDeployed) {
INexus(account).initializeAccount(initData);
emit AccountCreated(account, initData, salt);
} else if (msg.value > 0) {
revert AccountAlreadyDeployed(account);
}
return payable(account);
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/factory/RegistryFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ contract RegistryFactory is Stakeable, INexusFactory {
if (!alreadyDeployed) {
INexus(account).initializeAccount(initData);
emit AccountCreated(account, initData, salt);
} else if (msg.value > 0) {
revert AccountAlreadyDeployed(account);
}
return payable(account);
}
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/factory/INexusFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ pragma solidity ^0.8.26;
/// Special thanks to the Solady team for foundational contributions: https://github.com/Vectorized/solady
interface INexusFactory {
/// @notice Emitted when a new Smart Account is created.
/// @param account The address of the newly created account.
/// @param initData Initialization data used for the new Smart Account.
/// @param salt Unique salt used during the creation of the Smart Account.
event AccountCreated(address indexed account, bytes indexed initData, bytes32 indexed salt);

/// @notice Error indicating that the account is already deployed
/// @param account The address of the account that is already deployed
error AccountAlreadyDeployed(address account);

/// @notice Error thrown when the owner address is zero.
error ZeroAddressNotAllowed();

Expand Down
10 changes: 5 additions & 5 deletions contracts/utils/RegistryBootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ contract Bootstrap is ModuleManager {
address[] calldata attesters,
uint8 threshold
) external {
_installValidator(address(validator), data);
_configureRegistry(registry, attesters, threshold);
_installValidator(address(validator), data);
}

/// @notice Initializes the Nexus account with multiple modules.
Expand All @@ -61,6 +61,8 @@ contract Bootstrap is ModuleManager {
address[] calldata attesters,
uint8 threshold
) external {
_configureRegistry(registry, attesters, threshold);

// Initialize validators
for (uint256 i = 0; i < validators.length; i++) {
_installValidator(validators[i].module, validators[i].data);
Expand All @@ -82,8 +84,6 @@ contract Bootstrap is ModuleManager {
if (fallbacks[i].module == address(0)) continue;
_installFallbackHandler(fallbacks[i].module, fallbacks[i].data);
}

_configureRegistry(registry, attesters, threshold);
}

/// @notice Initializes the Nexus account with a scoped set of modules.
Expand All @@ -97,6 +97,8 @@ contract Bootstrap is ModuleManager {
address[] calldata attesters,
uint8 threshold
) external {
_configureRegistry(registry, attesters, threshold);

// Initialize validators
for (uint256 i = 0; i < validators.length; i++) {
_installValidator(validators[i].module, validators[i].data);
Expand All @@ -106,8 +108,6 @@ contract Bootstrap is ModuleManager {
if (hook.module != address(0)) {
_installHook(hook.module, hook.data);
}

_configureRegistry(registry, attesters, threshold);
}

/// @notice Prepares calldata for the initNexus function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ contract TestK1ValidatorFactory_Deployments is NexusTest_Base {
address payable secondAccountAddress = validatorFactory.createAccount{ value: 1 ether }(expectedOwner, index, ATTESTERS, THRESHOLD);

assertEq(firstAccountAddress, secondAccountAddress, "Addresses should match for the same owner and index");
assertEq(firstAccountAddress.balance, 2 ether, "Account balance should be 2 ether");
}

/// @notice Tests that creating accounts with different indexes results in different addresses.
Expand Down

0 comments on commit 59ffaa9

Please sign in to comment.