mirror of
https://github.com/getwax/zk-account-abstraction.git
synced 2026-01-09 20:47:58 -05:00
[N12] Not all state variables have explicit visibility (#70)
fixes #34 fixes #36 (remove OwnerNonce struct)
This commit is contained in:
@@ -30,10 +30,10 @@ contract DepositPaymaster is BasePaymaster {
|
||||
//calculated cost of the postOp
|
||||
uint constant COST_OF_POST = 35000;
|
||||
|
||||
IOracle constant nullOracle = IOracle(address(0));
|
||||
IOracle private constant nullOracle = IOracle(address(0));
|
||||
mapping(IERC20 => IOracle) public oracles;
|
||||
mapping(IERC20 => mapping(address => uint)) public balances;
|
||||
mapping(address => uint) unlockBlock;
|
||||
mapping(address => uint) public unlockBlock;
|
||||
|
||||
constructor(EntryPoint _entryPoint) BasePaymaster(_entryPoint) {
|
||||
//owner account is unblocked, to allow withdraw of paid tokens;
|
||||
|
||||
@@ -12,29 +12,20 @@ import "./ECDSA.sol";
|
||||
contract SimpleWallet is IWallet {
|
||||
using ECDSA for bytes32;
|
||||
using UserOperationLib for UserOperation;
|
||||
struct OwnerNonce {
|
||||
uint96 nonce;
|
||||
address owner;
|
||||
}
|
||||
|
||||
OwnerNonce ownerNonce;
|
||||
//explicit sizes of nonce, to fit a single storage cell with "owner"
|
||||
uint96 public nonce;
|
||||
address public owner;
|
||||
|
||||
EntryPoint public entryPoint;
|
||||
|
||||
function nonce() public view returns (uint) {
|
||||
return ownerNonce.nonce;
|
||||
}
|
||||
|
||||
function owner() public view returns (address) {
|
||||
return ownerNonce.owner;
|
||||
}
|
||||
|
||||
event EntryPointChanged(EntryPoint indexed oldEntryPoint, EntryPoint indexed newEntryPoint);
|
||||
|
||||
receive() external payable {}
|
||||
|
||||
constructor(EntryPoint _entryPoint, address _owner) {
|
||||
entryPoint = _entryPoint;
|
||||
ownerNonce.owner = _owner;
|
||||
owner = _owner;
|
||||
}
|
||||
|
||||
modifier onlyOwner() {
|
||||
@@ -44,7 +35,7 @@ contract SimpleWallet is IWallet {
|
||||
|
||||
function _onlyOwner() internal view {
|
||||
//directly from EOA owner, or through the entryPoint (which gets redirected through execFromEntryPoint)
|
||||
require(msg.sender == ownerNonce.owner || msg.sender == address(this), "only owner");
|
||||
require(msg.sender == owner || msg.sender == address(this), "only owner");
|
||||
}
|
||||
|
||||
function transfer(address payable dest, uint amount) external onlyOwner {
|
||||
@@ -98,13 +89,13 @@ contract SimpleWallet is IWallet {
|
||||
//during construction, the "nonce" field hold the salt.
|
||||
// if we assert it is zero, then we allow only a single wallet per owner.
|
||||
if (userOp.initCode.length == 0) {
|
||||
require(ownerNonce.nonce++ == userOp.nonce, "wallet: invalid nonce");
|
||||
require(nonce++ == userOp.nonce, "wallet: invalid nonce");
|
||||
}
|
||||
}
|
||||
|
||||
function _validateSignature(UserOperation calldata userOp, bytes32 requestId) internal view {
|
||||
bytes32 hash = requestId.toEthSignedMessageHash();
|
||||
require(owner() == hash.recover(userOp.signature), "wallet: wrong signature");
|
||||
require(owner == hash.recover(userOp.signature), "wallet: wrong signature");
|
||||
}
|
||||
|
||||
function _call(address sender, uint value, bytes memory data) internal {
|
||||
|
||||
@@ -21,7 +21,7 @@ contract TokenPaymaster is BasePaymaster, ERC20 {
|
||||
//calculated cost of the postOp
|
||||
uint constant COST_OF_POST = 15000;
|
||||
|
||||
bytes32 immutable knownWallet;
|
||||
bytes32 immutable public knownWallet;
|
||||
|
||||
constructor(string memory _symbol, EntryPoint _entryPoint) ERC20(_symbol, _symbol) BasePaymaster(_entryPoint) {
|
||||
knownWallet = _knownWallet();
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| EntryPoint · addStake · 29068 · 46168 · 34768 · 3 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| EntryPoint · handleOps · 98077 · 1182381 · 425030 · 27 · - │
|
||||
| EntryPoint · handleOps · 98035 · 1185457 · 425957 · 27 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| EntryPoint · simulateValidation · - · - · 996597 · 1 · - │
|
||||
| EntryPoint · simulateValidation · - · - · 999703 · 1 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| EntryPoint · unstakeDeposit · - · - · 28381 · 1 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
@@ -29,7 +29,7 @@
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| TokenPaymaster · transfer · - · - · 33549 · 1 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| TokenPaymaster · unstakeDeposit · - · - · 35731 · 1 · - │
|
||||
| TokenPaymaster · unstakeDeposit · - · - · 35709 · 1 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| TokenPaymaster · withdrawTo · - · - · 67004 · 1 · - │
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
@@ -37,9 +37,9 @@
|
||||
·······················|······················|············|··············|·············|···············|··············
|
||||
| Deployments · · % of limit · │
|
||||
··············································|············|··············|·············|···············|··············
|
||||
| DepositPaymaster · - · - · 1321315 · 4.4 % · - │
|
||||
| DepositPaymaster · - · - · 1333400 · 4.4 % · - │
|
||||
··············································|············|··············|·············|···············|··············
|
||||
| TokenPaymaster · - · - · 1548502 · 5.2 % · - │
|
||||
| TokenPaymaster · - · - · 1562094 · 5.2 % · - │
|
||||
··············································|············|··············|·············|···············|··············
|
||||
| VerifyingPaymaster · - · - · 1016710 · 3.4 % · - │
|
||||
·---------------------------------------------|------------|--------------|-------------|---------------|-------------·
|
||||
Reference in New Issue
Block a user