-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR also includes the rework of 712.
- Loading branch information
Showing
68 changed files
with
1,112 additions
and
998 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[submodule "lib/account-abstraction"] | ||
path = lib/account-abstraction | ||
url = https://github.com/eth-infinitism/account-abstraction | ||
branch = releases/v0.7 | ||
branch = releases/v0.6 |
Submodule account-abstraction
updated
109 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2024 Circle Internet Group, Inc. All rights reserved. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
pragma solidity 0.8.24; | ||
|
||
import {MessageHashUtils} from "../libs/MessageHashUtils.sol"; | ||
|
||
abstract contract BaseERC712CompliantAccount { | ||
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") | ||
bytes32 private constant _DOMAIN_SEPARATOR_TYPEHASH = | ||
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); | ||
|
||
/// @notice Wraps a replay safe hash in an EIP-712 envelope to prevent cross-account replay attacks. | ||
/// domainSeparator = hashStruct(eip712Domain). | ||
/// eip712Domain = (string name,string version,uint256 chainId,address verifyingContract) | ||
/// hashStruct(s) = keccak256(typeHash ‖ encodeData(s)) where typeHash = keccak256(encodeType(typeOf(s))) | ||
/// @param hash Message that should be hashed. | ||
/// @return Replay safe message hash. | ||
function getReplaySafeMessageHash(bytes32 hash) public view returns (bytes32) { | ||
return MessageHashUtils.toTypedDataHash({ | ||
domainSeparator: keccak256( | ||
abi.encode( | ||
_DOMAIN_SEPARATOR_TYPEHASH, _getAccountName(), _getAccountVersion(), block.chainid, address(this) | ||
) | ||
), | ||
structHash: keccak256(abi.encode(_getAccountTypeHash(), hash)) | ||
}); | ||
} | ||
|
||
/// @dev Returns the account message typehash. | ||
function _getAccountTypeHash() internal pure virtual returns (bytes32); | ||
|
||
/// @dev Returns the account name. | ||
function _getAccountName() internal pure virtual returns (bytes32); | ||
|
||
/// @dev Returns the account version. | ||
function _getAccountVersion() internal pure virtual returns (bytes32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 Circle Internet Group, Inc. All rights reserved. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
pragma solidity 0.8.24; | ||
|
||
/** | ||
* @notice Forked from OZ V5 as it doesn't exist in V4. | ||
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. | ||
* | ||
* The library provides methods for generating a hash of a message that conforms to the | ||
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] | ||
* specifications. | ||
*/ | ||
library MessageHashUtils { | ||
/** | ||
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). | ||
* | ||
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with | ||
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the | ||
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. | ||
* | ||
* See {ECDSA-recover}. | ||
*/ | ||
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
let ptr := mload(0x40) | ||
mstore(ptr, hex"1901") | ||
mstore(add(ptr, 0x02), domainSeparator) | ||
mstore(add(ptr, 0x22), structHash) | ||
digest := keccak256(ptr, 0x42) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2024 Circle Internet Group, Inc. All rights reserved. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
pragma solidity 0.8.24; | ||
|
||
import {MessageHashUtils} from "../../../../libs/MessageHashUtils.sol"; | ||
|
||
// @notice Inspired by 6900 reference implementation with some modifications. | ||
// A base contract for modules that use EIP-712 structured data signing. | ||
// Unlike other EIP712 libraries, this base contract uses the salt field (bytes32(bytes20(account)) to hold the | ||
// account address | ||
// and uses the verifyingContract field to hold module address. | ||
// This abstract contract does not implement EIP-5267, as the domain retrieval function eip712Domain() does not provide | ||
// a parameter to hold the account address. | ||
// If we use verifyingContract to hold account address, then `msg.sender` would be address(0) for an `eth_call` without | ||
// an override. | ||
abstract contract BaseERC712CompliantModule { | ||
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)") | ||
bytes32 private constant _DOMAIN_SEPARATOR_TYPEHASH = | ||
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); | ||
|
||
/// @notice Wraps a replay safe hash in an EIP-712 envelope to prevent cross-account replay attacks. | ||
/// domainSeparator = hashStruct(eip712Domain). | ||
/// eip712Domain = (string name,string version,uint256 chainId,address verifyingContract,bytes32 salt) | ||
/// The domain separator includes the chainId, module address and account address. | ||
/// hashStruct(s) = keccak256(typeHash ‖ encodeData(s)) where typeHash = keccak256(encodeType(typeOf(s))) | ||
/// @param account SCA to build the message hash for. | ||
/// @param hash Message that should be hashed. | ||
/// @return Replay safe message hash. | ||
function getReplaySafeMessageHash(address account, bytes32 hash) public view returns (bytes32) { | ||
return MessageHashUtils.toTypedDataHash({ | ||
domainSeparator: keccak256( | ||
abi.encode( | ||
_DOMAIN_SEPARATOR_TYPEHASH, _getModuleIdHash(), block.chainid, address(this), bytes32(bytes20(account)) | ||
) | ||
), | ||
structHash: keccak256(abi.encode(_getModuleTypeHash(), hash)) | ||
}); | ||
} | ||
|
||
/// @dev Returns the module typehash. | ||
function _getModuleTypeHash() internal pure virtual returns (bytes32); | ||
|
||
/// @dev Returns the module id. | ||
function _getModuleIdHash() internal pure virtual returns (bytes32); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.