Skip to content

Commit

Permalink
👷🏻 🧹 Rename Account to MockAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrharper committed Jul 10, 2024
1 parent d73eb2b commit 5c3bab0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/MarginPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IPerpsMarketProxy} from "src/interfaces/external/IPerpsMarketProxy.sol";
import {IV3SwapRouter} from "src/interfaces/external/IV3SwapRouter.sol";
import {IWETH9} from "src/interfaces/external/IWETH9.sol";
import {IEngine} from "src/interfaces/IEngine.sol";
import {Account} from "src/Account.sol";
import {MockAccount} from "src/MockAccount.sol";
import {Zap} from "lib/zap/src/Zap.sol";
import {OracleLibrary} from "src/libraries/OracleLibrary.sol";
import {IUniswapV3Pool} from "src/interfaces/external/IUniswapV3Pool.sol";
Expand Down Expand Up @@ -101,7 +101,9 @@ contract MarginPaymaster is IPaymaster, Zap {
// pull funds from margin
uint256 sUSDToWithdrawFromMargin = (costOfGasInUSDC -
availableUSDCInWallet) * 1e12;
uint128 accountId = Account(sender).accountId();
// TODO: think, can this be pulled elsehow
// this current impl would require a custom account module
uint128 accountId = MockAccount(sender).accountId();
perpsMarketSNXV3.modifyCollateral(
accountId,
sUSDId,
Expand Down
5 changes: 2 additions & 3 deletions src/Account.sol → src/MockAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {IEngine} from "src/interfaces/IEngine.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {console} from "forge-std/console.sol";

// TODO: rename to mock account
contract Account is IAccount, IERC721Receiver {
contract MockAccount is IAccount, IERC721Receiver {
address public owner;
IPerpsMarketProxy public perpsMarketSNXV3;
address public marginPaymaster;
Expand Down Expand Up @@ -132,7 +131,7 @@ contract AccountFactory {
// amount, salt, bytecode
bytes32 salt = bytes32(uint256(uint160(owner)));
bytes memory bytecode = abi.encodePacked(
type(Account).creationCode,
type(MockAccount).creationCode,
abi.encode(
owner,
perpsMarketSNXV3,
Expand Down
8 changes: 4 additions & 4 deletions test/MarginPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.20;

import {Bootstrap} from "test/utils/Bootstrap.sol";
import {EntryPoint, UserOperation} from "lib/account-abstraction/contracts/core/EntryPoint.sol";
import {AccountFactory, Account} from "src/Account.sol";
import {AccountFactory, MockAccount} from "src/MockAccount.sol";
import {MarginPaymaster, IPaymaster} from "src/MarginPaymaster.sol";
import {console} from "forge-std/console.sol";

Expand Down Expand Up @@ -59,15 +59,15 @@ contract MarginPaymasterTest is Bootstrap {
}
sender = bytesToAddress(result);
}
account = Account(sender);
account = MockAccount(sender);

uint256 nonce = entryPoint.getNonce(sender, 0);
bytes memory signature;
userOp = UserOperation({
sender: sender,
nonce: nonce,
initCode: initCode,
callData: abi.encodeWithSelector(Account.setupAccount.selector),
callData: abi.encodeWithSelector(MockAccount.setupAccount.selector),
callGasLimit: 2_000_000,
verificationGasLimit: 2_000_000,
preVerificationGas: 200_000,
Expand Down Expand Up @@ -162,7 +162,7 @@ contract MarginPaymasterTest is Bootstrap {
type(uint256).max
);
userOp.callData = abi.encodeWithSelector(
Account.execute.selector,
MockAccount.execute.selector,
address(usdc),
0,
approvalCalldata
Expand Down
4 changes: 2 additions & 2 deletions test/utils/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {MarginPaymaster, OptimismGoerliParameters, OptimismParameters, BaseParam
import {IPerpsMarketProxy} from "src/interfaces/external/IPerpsMarketProxy.sol";
import {IV3SwapRouter} from "src/interfaces/external/IV3SwapRouter.sol";
import {IWETH9} from "src/interfaces/external/IWETH9.sol";
import {AccountFactory, Account} from "src/Account.sol";
import {AccountFactory, MockAccount} from "src/MockAccount.sol";
import {IUSDC} from "test/utils/interfaces/IUSDC.sol";
import {Test} from "lib/forge-std/src/Test.sol";
import {console} from "lib/forge-std/src/console.sol";
Expand All @@ -20,7 +20,7 @@ contract Bootstrap is Test {
address payable internal marginPaymasterAddress;
EntryPoint internal entryPoint;
AccountFactory internal accountFactory;
Account internal account;
MockAccount internal account;
uint256 userPk = 0x1234;
uint256 bundlerPk = 0x12345;
address payable user = payable(vm.addr(0x1234));
Expand Down

0 comments on commit 5c3bab0

Please sign in to comment.