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
16 changes: 6 additions & 10 deletions packages/evm/contracts/smart-accounts/SmartAccountsHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ pragma solidity ^0.8.20;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165Checker.sol';

import '../interfaces/ISafe.sol';
import '../interfaces/ISmartAccount.sol';
import '../interfaces/ISmartAccountsHandler.sol';
import '../utils/Denominations.sol';

contract SmartAccountsHandler is ISmartAccountsHandler {
using ERC165Checker for address;

/**
* @dev Tells whether an account is a supported smart account
* @param account Address of the account being queried
Expand Down Expand Up @@ -90,22 +93,15 @@ contract SmartAccountsHandler is ISmartAccountsHandler {
* @param account Address of the account being queried
*/
function _isMimicSmartAccount(address account) internal view returns (bool) {
try ISmartAccount(account).supportsInterface(type(ISmartAccount).interfaceId) returns (bool ok) {
return ok;
} catch {
return false;
}
return account.supportsInterface(type(ISmartAccount).interfaceId);
}

/**
* @dev Tells whether an account is a Gnosis Safe
* @param account Address of the account being queried
*/
function _isSafe(address account) internal view returns (bool) {
try ISafe(account).getThreshold() returns (uint256) {
return true;
} catch {
return false;
}
(bool success, bytes memory data) = account.staticcall(abi.encodeWithSelector(ISafe.getThreshold.selector));
return success && data.length == 32;
}
}
9 changes: 9 additions & 0 deletions packages/evm/contracts/test/smart-accounts/FallbackMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

contract FallbackMock {
fallback() external payable {}

receive() external payable {}
}
6 changes: 6 additions & 0 deletions packages/evm/test/smart-accounts/SmartAccountsHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe('SmartAccountsHandler', () => {
expect(await handler.isSmartAccount(handler)).to.be.false
})

it('returns false for contracts with a fallback only', async () => {
const fallback = await ethers.deployContract('FallbackMock')

expect(await handler.isSmartAccount(fallback)).to.be.false
})

it('returns true for a Mimic SmartAccount', async () => {
expect(await handler.isSmartAccount(smartAccountContract)).to.be.true
})
Expand Down
Loading