Skip to content

Commit 695e490

Browse files
authored
AA-61 rename wallet to account (eth-infinitism#134)
* rename IWallet to IAccount (and all other contracts, e.g. SimpleWallet to SimpleAccount, etc..)
1 parent 49cec09 commit 695e490

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+734
-739
lines changed

contracts/bls/BLSWallet.sol renamed to contracts/bls/BLSAccount.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.12;
33

4-
import "../samples/SimpleWallet.sol";
5-
import "./IBLSWallet.sol";
4+
import "../samples/SimpleAccount.sol";
5+
import "./IBLSAccount.sol";
66

77
/**
8-
* Minimal BLS-based wallet that uses an aggregated signature.
9-
* The wallet must maintain its own BLS public-key, and expose its trusted signature aggregator.
10-
* Note that unlike the "standard" SimpleWallet, this wallet can't be called directly
11-
* (normal SimpleWallet uses its "signer" address as both the ecrecover signer, and as a legitimate
8+
* Minimal BLS-based account that uses an aggregated signature.
9+
* The account must maintain its own BLS public-key, and expose its trusted signature aggregator.
10+
* Note that unlike the "standard" SimpleAccount, this account can't be called directly
11+
* (normal SimpleAccount uses its "signer" address as both the ecrecover signer, and as a legitimate
1212
* Ethereum sender address. Obviously, a BLS public is not a valid Ethereum sender address.)
1313
*/
14-
contract BLSWallet is SimpleWallet, IBLSWallet {
14+
contract BLSAccount is SimpleAccount, IBLSAccount {
1515
address public immutable aggregator;
1616
uint256[4] private publicKey;
1717

1818
constructor(IEntryPoint anEntryPoint, address anAggregator, uint256[4] memory aPublicKey)
19-
SimpleWallet(anEntryPoint, address(0)) {
19+
SimpleAccount(anEntryPoint, address(0)) {
2020
publicKey = aPublicKey;
2121
aggregator = anAggregator;
2222
}
@@ -25,7 +25,7 @@ contract BLSWallet is SimpleWallet, IBLSWallet {
2525
internal override view returns (uint256 deadline) {
2626

2727
(userOp, userOpHash);
28-
require(userOpAggregator == aggregator, "BLSWallet: wrong aggregator");
28+
require(userOpAggregator == aggregator, "BLSAccount: wrong aggregator");
2929
return 0;
3030
}
3131

@@ -46,9 +46,9 @@ contract BLSWallet is SimpleWallet, IBLSWallet {
4646
}
4747

4848

49-
contract BLSWalletDeployer {
49+
contract BLSAccountDeployer {
5050

51-
function deployWallet(IEntryPoint anEntryPoint, address anAggregator, uint salt, uint256[4] memory aPublicKey) public returns (BLSWallet) {
52-
return new BLSWallet{salt : bytes32(salt)}(anEntryPoint, anAggregator, aPublicKey);
51+
function deployAccount(IEntryPoint anEntryPoint, address anAggregator, uint salt, uint256[4] memory aPublicKey) public returns (BLSAccount) {
52+
return new BLSAccount{salt : bytes32(salt)}(anEntryPoint, anAggregator, aPublicKey);
5353
}
5454
}

contracts/bls/BLSSignatureAggregator.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ pragma abicoder v2;
55
import "../interfaces/IAggregator.sol";
66
import "../interfaces/IEntryPoint.sol";
77
import {BLSOpen} from "./lib/BLSOpen.sol";
8-
import "./IBLSWallet.sol";
8+
import "./IBLSAccount.sol";
99
import "./BLSHelper.sol";
1010
import "hardhat/console.sol";
1111

1212
/**
13-
* A BLS-based signature aggregator, to validate aggregated signature of multiple UserOps if BLSWallet
13+
* A BLS-based signature aggregator, to validate aggregated signature of multiple UserOps if BLSAccount
1414
*/
1515
contract BLSSignatureAggregator is IAggregator {
1616
using UserOperationLib for UserOperation;
@@ -22,7 +22,7 @@ contract BLSSignatureAggregator is IAggregator {
2222
if (initCode.length > 0) {
2323
publicKey = getTrailingPublicKey(initCode);
2424
} else {
25-
return IBLSWallet(userOp.sender).getBlsPublicKey();
25+
return IBLSAccount(userOp.sender).getBlsPublicKey();
2626
}
2727
}
2828

@@ -55,9 +55,9 @@ contract BLSSignatureAggregator is IAggregator {
5555
for (uint256 i = 0; i < userOpsLen; i++) {
5656

5757
UserOperation memory userOp = userOps[i];
58-
IBLSWallet blsWallet = IBLSWallet(userOp.sender);
58+
IBLSAccount blsAccount = IBLSAccount(userOp.sender);
5959

60-
blsPublicKeys[i] = blsWallet.getBlsPublicKey{gas : 30000}();
60+
blsPublicKeys[i] = blsAccount.getBlsPublicKey{gas : 30000}();
6161

6262
messages[i] = _userOpToMessage(userOp, keccak256(abi.encode(blsPublicKeys[i])));
6363
}
@@ -86,16 +86,16 @@ contract BLSSignatureAggregator is IAggregator {
8686

8787
/**
8888
* return the BLS "message" for the given UserOp.
89-
* the wallet should sign this value using its public-key
89+
* the account checks the signature over this value using its public-key
9090
*/
9191
function userOpToMessage(UserOperation memory userOp) public view returns (uint256[2] memory) {
9292
bytes32 hashPublicKey = _getUserOpPubkeyHash(userOp);
9393
return _userOpToMessage(userOp, hashPublicKey);
9494
}
9595

9696
function _userOpToMessage(UserOperation memory userOp, bytes32 publicKeyHash) internal view returns (uint256[2] memory) {
97-
bytes32 requestId = _getUserOpHash(userOp, publicKeyHash);
98-
return BLSOpen.hashToPoint(BLS_DOMAIN, abi.encodePacked(requestId));
97+
bytes32 userOpHash = _getUserOpHash(userOp, publicKeyHash);
98+
return BLSOpen.hashToPoint(BLS_DOMAIN, abi.encodePacked(userOpHash));
9999
}
100100

101101
//return the public-key hash of a userOp.
@@ -118,7 +118,7 @@ contract BLSSignatureAggregator is IAggregator {
118118
* First it validates the signature over the userOp. then it return data to be used when creating the handleOps:
119119
* @param userOp the userOperation received from the user.
120120
* @return sigForUserOp the value to put into the signature field of the userOp when calling handleOps.
121-
* (usually empty, unless wallet and aggregator support some kind of "multisig"
121+
* (usually empty, unless account and aggregator support some kind of "multisig"
122122
*/
123123
function validateUserOpSignature(UserOperation calldata userOp)
124124
external view returns (bytes memory sigForUserOp) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: GPL-3.0-only
22
pragma solidity >=0.7.6;
33

4-
import "../interfaces/IAggregatedWallet.sol";
4+
import "../interfaces/IAggregatedAccount.sol";
55

66
/**
7-
* a BLS wallet should expose its own public key.
7+
* a BLS account should expose its own public key.
88
*/
9-
interface IBLSWallet is IAggregatedWallet {
9+
interface IBLSAccount is IAggregatedAccount {
1010
function getBlsPublicKey() external view returns (uint256[4] memory);
1111
}

contracts/core/BaseWallet.sol renamed to contracts/core/BaseAccount.sol

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,56 @@ pragma solidity ^0.8.12;
55
/* solhint-disable no-inline-assembly */
66
/* solhint-disable reason-string */
77

8-
import "../interfaces/IWallet.sol";
8+
import "../interfaces/IAccount.sol";
99
import "../interfaces/IEntryPoint.sol";
1010

1111
/**
12-
* Basic wallet implementation.
13-
* this contract provides the basic logic for implementing the IWallet interface - validateUserOp
14-
* specific wallet implementation should inherit it and provide the wallet-specific logic
12+
* Basic account implementation.
13+
* this contract provides the basic logic for implementing the IAccount interface - validateUserOp
14+
* specific account implementation should inherit it and provide the account-specific logic
1515
*/
16-
abstract contract BaseWallet is IWallet {
16+
abstract contract BaseAccount is IAccount {
1717
using UserOperationLib for UserOperation;
1818

1919
/**
20-
* return the wallet nonce.
20+
* return the account nonce.
2121
* subclass should return a nonce value that is used both by _validateAndUpdateNonce, and by the external provider (to read the current nonce)
2222
*/
2323
function nonce() public view virtual returns (uint256);
2424

2525
/**
26-
* return the entryPoint used by this wallet.
27-
* subclass should return the current entryPoint used by this wallet.
26+
* return the entryPoint used by this account.
27+
* subclass should return the current entryPoint used by this account.
2828
*/
2929
function entryPoint() public view virtual returns (IEntryPoint);
3030

3131
/**
3232
* Validate user's signature and nonce.
3333
* subclass doesn't need to override this method. Instead, it should override the specific internal validation methods.
3434
*/
35-
function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, address aggregator, uint256 missingWalletFunds)
35+
function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, address aggregator, uint256 missingAccountFunds)
3636
external override virtual returns (uint256 deadline) {
3737
_requireFromEntryPoint();
3838
deadline = _validateSignature(userOp, userOpHash, aggregator);
3939
if (userOp.initCode.length == 0) {
4040
_validateAndUpdateNonce(userOp);
4141
}
42-
_payPrefund(missingWalletFunds);
42+
_payPrefund(missingAccountFunds);
4343
}
4444

4545
/**
4646
* ensure the request comes from the known entrypoint.
4747
*/
4848
function _requireFromEntryPoint() internal virtual view {
49-
require(msg.sender == address(entryPoint()), "wallet: not from EntryPoint");
49+
require(msg.sender == address(entryPoint()), "account: not from EntryPoint");
5050
}
5151

5252
/**
5353
* validate the signature is valid for this message.
5454
* @param userOp validate the userOp.signature field
5555
* @param userOpHash convenient field: the hash of the request, to check the signature against
5656
* (also hashes the entrypoint and chain-id)
57-
* @param aggregator the current aggregator. can be ignored by wallets that don't use aggregators
57+
* @param aggregator the current aggregator. can be ignored by accounts that don't use aggregators
5858
* @return deadline the last block timestamp this operation is valid, or zero if it is valid indefinitely.
5959
* Note that the validation code cannot use block.timestamp (or block.number) directly.
6060
*/
@@ -63,8 +63,8 @@ abstract contract BaseWallet is IWallet {
6363

6464
/**
6565
* validate the current nonce matches the UserOperation nonce.
66-
* then it should update the wallet's state to prevent replay of this UserOperation.
67-
* called only if initCode is empty (since "nonce" field is used as "salt" on wallet creation)
66+
* then it should update the account's state to prevent replay of this UserOperation.
67+
* called only if initCode is empty (since "nonce" field is used as "salt" on account creation)
6868
* @param userOp the op to validate.
6969
*/
7070
function _validateAndUpdateNonce(UserOperation calldata userOp) internal virtual;
@@ -74,20 +74,20 @@ abstract contract BaseWallet is IWallet {
7474
* subclass MAY override this method for better funds management
7575
* (e.g. send to the entryPoint more than the minimum required, so that in future transactions
7676
* it will not be required to send again)
77-
* @param missingWalletFunds the minimum value this method should send the entrypoint.
77+
* @param missingAccountFunds the minimum value this method should send the entrypoint.
7878
* this value MAY be zero, in case there is enough deposit, or the userOp has a paymaster.
7979
*/
80-
function _payPrefund(uint256 missingWalletFunds) internal virtual {
81-
if (missingWalletFunds != 0) {
82-
(bool success,) = payable(msg.sender).call{value : missingWalletFunds, gas : type(uint256).max}("");
80+
function _payPrefund(uint256 missingAccountFunds) internal virtual {
81+
if (missingAccountFunds != 0) {
82+
(bool success,) = payable(msg.sender).call{value : missingAccountFunds, gas : type(uint256).max}("");
8383
(success);
84-
//ignore failure (its EntryPoint's job to verify, not wallet.)
84+
//ignore failure (its EntryPoint's job to verify, not account.)
8585
}
8686
}
8787

8888
/**
8989
* expose an api to modify the entryPoint.
90-
* must be called by current "admin" of the wallet.
90+
* must be called by current "admin" of the account.
9191
* @param newEntryPoint the new entrypoint to trust.
9292
*/
9393
function updateEntryPoint(address newEntryPoint) external {
@@ -97,7 +97,7 @@ abstract contract BaseWallet is IWallet {
9797

9898
/**
9999
* ensure the caller is allowed "admin" operations (such as changing the entryPoint)
100-
* default implementation trust the wallet itself (or any signer that passes "validateUserOp")
100+
* default implementation trust the account itself (or any signer that passes "validateUserOp")
101101
* to be the "admin"
102102
*/
103103
function _requireFromAdmin() internal view virtual {

0 commit comments

Comments
 (0)