Skip to content

Commit

Permalink
fix getAddressForSalt return
Browse files Browse the repository at this point in the history
  • Loading branch information
coffeexcoin committed Jan 6, 2025
1 parent e93ccfa commit fd7efef
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions contracts/AccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,17 @@ contract AccountFactory is Ownable2Step {
* @return accountAddress address - Address of the AGW account that would be created with the given salt
*/
function getAddressForSalt(bytes32 salt) external view returns (address accountAddress) {
address existingAccount = saltToAccount[salt];
if (existingAccount != address(0)) {
return accountAddress;
// Check if the account is already deployed
accountAddress = saltToAccount[salt];
if (accountAddress == address(0)) {
// If not, get the deterministic account address for the current implementation
accountAddress = IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).getNewAddressCreate2(
address(this),
proxyBytecodeHash,
salt,
abi.encode(implementationAddress)
);
}
return IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).getNewAddressCreate2(
address(this),
proxyBytecodeHash,
salt,
abi.encode(implementationAddress)
);
}

/**
Expand Down

0 comments on commit fd7efef

Please sign in to comment.