Skip to content

Commit e5e9103

Browse files
committed
Merge branch 'master' into utils/memory
2 parents f03d149 + fd9bbae commit e5e9103

File tree

22 files changed

+1115
-31
lines changed

22 files changed

+1115
-31
lines changed

.changeset/wild-baths-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`IERC7786`: Add the (draft) interface for ERC-7786 "Cross-Chain Messaging Gateway"

contracts/account/extensions/draft-AccountERC7579.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75
237237
*
238238
* Requirements:
239239
*
240-
* * Module type must be supported. See {supportsModule}. Reverts with {ERC7579UnsupportedModuleType}.
241-
* * Module must be of the given type. Reverts with {ERC7579MismatchedModuleTypeId}.
242-
* * Module must not be already installed. Reverts with {ERC7579AlreadyInstalledModule}.
240+
* * Module type must be supported. See {supportsModule}. Reverts with {ERC7579Utils-ERC7579UnsupportedModuleType}.
241+
* * Module must be of the given type. Reverts with {ERC7579Utils-ERC7579MismatchedModuleTypeId}.
242+
* * Module must not be already installed. Reverts with {ERC7579Utils-ERC7579AlreadyInstalledModule}.
243243
*
244-
* Emits a {ModuleInstalled} event.
244+
* Emits a {IERC7579ModuleConfig-ModuleInstalled} event.
245245
*/
246246
function _installModule(uint256 moduleTypeId, address module, bytes memory initData) internal virtual {
247247
require(supportsModule(moduleTypeId), ERC7579Utils.ERC7579UnsupportedModuleType(moduleTypeId));
@@ -276,7 +276,7 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75
276276
*
277277
* Requirements:
278278
*
279-
* * Module must be already installed. Reverts with {ERC7579UninstalledModule} otherwise.
279+
* * Module must be already installed. Reverts with {ERC7579Utils-ERC7579UninstalledModule} otherwise.
280280
*/
281281
function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData) internal virtual {
282282
require(supportsModule(moduleTypeId), ERC7579Utils.ERC7579UnsupportedModuleType(moduleTypeId));

contracts/governance/extensions/GovernorNoncesKeyed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {NoncesKeyed} from "../../utils/NoncesKeyed.sol";
88
import {SignatureChecker} from "../../utils/cryptography/SignatureChecker.sol";
99

1010
/**
11-
* @dev An extension of {Governor} that extends existing nonce management to use {NoncesKeyed}, where the key is the first 192 bits of the `proposalId`.
11+
* @dev An extension of {Governor} that extends existing nonce management to use {NoncesKeyed}, where the key is the low-order 192 bits of the `proposalId`.
1212
* This is useful for voting by signature while maintaining separate sequences of nonces for each proposal.
1313
*
1414
* NOTE: Traditional (un-keyed) nonces are still supported and can continue to be used as if this extension was not present.

contracts/interfaces/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ are useful to interact with third party contracts that implement them.
4545
- {IERC6909Metadata}
4646
- {IERC6909TokenSupply}
4747
- {IERC7674}
48+
- {IERC7786}
4849
- {IERC7802}
4950

5051
== Detailed ABI
@@ -99,4 +100,6 @@ are useful to interact with third party contracts that implement them.
99100

100101
{{IERC7674}}
101102

103+
{{IERC7786}}
104+
102105
{{IERC7802}}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity >=0.8.4;
4+
5+
/**
6+
* @dev Interface for ERC-7786 source gateways.
7+
*
8+
* See ERC-7786 for more details
9+
*/
10+
interface IERC7786GatewaySource {
11+
/**
12+
* @dev Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary. If
13+
* `outboxId` is not zero, then further (gateway specific, and non-standardized) action is required.
14+
*/
15+
event MessageSent(
16+
bytes32 indexed sendId,
17+
bytes sender, // Binary Interoperable Address
18+
bytes receiver, // Binary Interoperable Address
19+
bytes payload,
20+
uint256 value,
21+
bytes[] attributes
22+
);
23+
24+
/// @dev This error is thrown when a message creation fails because of an unsupported attribute being specified.
25+
error UnsupportedAttribute(bytes4 selector);
26+
27+
/// @dev Getter to check whether an attribute is supported or not.
28+
function supportsAttribute(bytes4 selector) external view returns (bool);
29+
30+
/**
31+
* @dev Endpoint for creating a new message. If the message requires further (gateway specific) processing before
32+
* it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the
33+
* message MUST be sent and this function must return 0.
34+
*
35+
* * MUST emit a {MessageSent} event.
36+
*
37+
* If any of the `attributes` is not supported, this function SHOULD revert with an {UnsupportedAttribute} error.
38+
* Other errors SHOULD revert with errors not specified in ERC-7786.
39+
*/
40+
function sendMessage(
41+
bytes calldata recipient, // Binary Interoperable Address
42+
bytes calldata payload,
43+
bytes[] calldata attributes
44+
) external payable returns (bytes32 sendId);
45+
}
46+
47+
/**
48+
* @dev Interface for the ERC-7786 client contract (receiver).
49+
*
50+
* See ERC-7786 for more details
51+
*/
52+
interface IERC7786Receiver {
53+
/**
54+
* @dev Endpoint for receiving cross-chain message.
55+
*
56+
* This function may be called directly by the gateway.
57+
*/
58+
function executeMessage(
59+
bytes32 receiveId,
60+
bytes calldata sender, // Binary Interoperable Address
61+
bytes calldata payload,
62+
bytes[] calldata attributes
63+
) external payable returns (bytes4);
64+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// contracts/MyAccountERC7702.sol
2+
// SPDX-License-Identifier: MIT
3+
pragma solidity ^0.8.20;
4+
5+
import {Account} from "../../../account/Account.sol";
6+
import {ERC721Holder} from "../../../token/ERC721/utils/ERC721Holder.sol";
7+
import {ERC1155Holder} from "../../../token/ERC1155/utils/ERC1155Holder.sol";
8+
import {ERC7821} from "../../../account/extensions/draft-ERC7821.sol";
9+
import {SignerERC7702} from "../../../utils/cryptography/signers/SignerERC7702.sol";
10+
11+
contract MyAccountERC7702 is Account, SignerERC7702, ERC7821, ERC721Holder, ERC1155Holder {
12+
/// @dev Allows the entry point as an authorized executor.
13+
function _erc7821AuthorizedExecutor(
14+
address caller,
15+
bytes32 mode,
16+
bytes calldata executionData
17+
) internal view virtual override returns (bool) {
18+
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
19+
}
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// contracts/MyFactoryAccount.sol
2+
// SPDX-License-Identifier: MIT
3+
4+
pragma solidity ^0.8.20;
5+
6+
import {Clones} from "../../../proxy/Clones.sol";
7+
import {Address} from "../../../utils/Address.sol";
8+
9+
/**
10+
* @dev A factory contract to create accounts on demand.
11+
*/
12+
contract MyFactoryAccount {
13+
using Clones for address;
14+
using Address for address;
15+
16+
address private immutable _impl;
17+
18+
constructor(address impl_) {
19+
require(impl_.code.length > 0);
20+
_impl = impl_;
21+
}
22+
23+
/// @dev Predict the address of the account
24+
function predictAddress(bytes calldata callData) public view returns (address) {
25+
return _impl.predictDeterministicAddress(keccak256(callData), address(this));
26+
}
27+
28+
/// @dev Create clone accounts on demand
29+
function cloneAndInitialize(bytes calldata callData) public returns (address) {
30+
address predicted = predictAddress(callData);
31+
if (predicted.code.length == 0) {
32+
_impl.cloneDeterministic(keccak256(callData));
33+
predicted.functionCall(callData);
34+
}
35+
return predicted;
36+
}
37+
}

contracts/utils/cryptography/signers/MultiSignerERC7913.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
160160
*
161161
* Requirements:
162162
*
163-
* * The {signers}'s length must be `>=` to the {threshold}. Throws {MultiSignerERC7913UnreachableThreshold} if not.
163+
* * The {getSignerCount} must be greater or equal than to the {threshold}. Throws
164+
* {MultiSignerERC7913UnreachableThreshold} if not.
164165
*/
165166
function _validateReachableThreshold() internal view virtual {
166167
uint256 signersLength = _signers.length();
@@ -225,7 +226,7 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
225226
*
226227
* Requirements:
227228
*
228-
* * The `signatures` arrays must be at least as large as the `signers` arrays. Panics otherwise.
229+
* * The `signatures` and `signers` arrays must be equal in length. Returns false otherwise.
229230
*/
230231
function _validateSignatures(
231232
bytes32 hash,

contracts/utils/cryptography/signers/MultiSignerERC7913Weighted.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ abstract contract MultiSignerERC7913Weighted is MultiSignerERC7913 {
129129
_validateReachableThreshold();
130130
}
131131

132+
/**
133+
* @dev See {MultiSignerERC7913-_addSigners}.
134+
*
135+
* In cases where {totalWeight} is almost `type(uint64).max` (due to a large `_totalExtraWeight`), adding new
136+
* signers could cause the {totalWeight} computation to overflow. Adding a {totalWeight} calls after the new
137+
* signers are added ensures no such overflow happens.
138+
*/
139+
function _addSigners(bytes[] memory newSigners) internal virtual override {
140+
super._addSigners(newSigners);
141+
142+
// This will revert if the new signers cause an overflow
143+
_validateReachableThreshold();
144+
}
145+
132146
/**
133147
* @dev See {MultiSignerERC7913-_removeSigners}.
134148
*

contracts/utils/cryptography/signers/SignerERC7913.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import {SignatureChecker} from "../SignatureChecker.sol";
2121
* function initialize(bytes memory signer_) public initializer {
2222
* _setSigner(signer_);
2323
* }
24+
*
25+
* function setSigner(bytes memory signer_) public onlyEntryPointOrSelf {
26+
* _setSigner(signer_);
27+
* }
2428
* }
2529
* ```
2630
*

0 commit comments

Comments
 (0)