Skip to content

Commit

Permalink
predict
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Dec 10, 2024
1 parent 14ae669 commit efad2c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/XAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "./utils/CREATE3.sol";
/// @dev XAccountFactory is a factory contract for create xAccount.
/// - 1 account can deploy multi xAccount on target chain for each factory.
contract XAccountFactory {
address public constant safeMsgportModule = 0x1899e901F53534489CEA580b6Ec688DddCcd0b91;
address public immutable SAFE_MSGPORT_MODULE;
/// Safe Deployment: https://github.com/safe-global/safe-deployments/tree/main/src/assets/v1.3.0
address public constant safeFallbackHandler = 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;
address public constant safeSingletonL2 = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E;
Expand All @@ -29,6 +29,10 @@ contract XAccountFactory {
address recovery
);

constructor(address safeMsgportModule) {
SAFE_MSGPORT_MODULE = safeMsgportModule;
}

/// @dev Create xAccount on target chain.
/// @notice Only could be called by source chain.
/// @param salt Pseudo random number.
Expand Down Expand Up @@ -89,7 +93,7 @@ contract XAccountFactory {
bytes memory creationCode1 = safeFactory.proxyCreationCode();
bytes memory deploymentCode1 = abi.encodePacked(creationCode1, uint256(uint160(safeSingletonL2)));

(proxy, module) = CREATE3.deploy(salt, deploymentCode1, safeMsgportModule);
(proxy, module) = CREATE3.deploy(salt, deploymentCode1, SAFE_MSGPORT_MODULE);
}

/// @dev Calculate xAccount address.
Expand Down
5 changes: 5 additions & 0 deletions src/XAccountUIFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ contract XAccountUIFactory {
function getDeployed(uint256 fromChainId, address owner) public view returns (address[] memory) {
return _xAccounts[fromChainId][owner].values();
}

function xAccountOf(address deployer, uint256 fromChainId, address owner) public view returns (address, address) {
bytes32 salt = keccak256(abi.encodePacked(deployer));
return FACTORY.xAccountOf(address(this), salt, fromChainId, owner);
}
}
5 changes: 5 additions & 0 deletions src/interfaces/IXAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ interface IXAccountFactory {
function create(bytes32 salt, uint256 fromChainId, address owner, address port, address recovery)
external
returns (address, address);

function xAccountOf(address deployer, bytes32 salt, uint256 fromChainId, address owner)
public
view
returns (address, address);
}

0 comments on commit efad2c0

Please sign in to comment.