Add signer constructors (#5757)
Co-authored-by: ernestognw <ernestognw@gmail.com> Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -38,10 +38,6 @@ abstract contract AccountMock is Account, ERC7739, ERC7821, ERC721Holder, ERC115
|
||||
}
|
||||
|
||||
abstract contract AccountECDSAMock is Account, SignerECDSA, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
|
||||
constructor(address signerAddr) {
|
||||
_setSigner(signerAddr);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
@ -53,10 +49,6 @@ abstract contract AccountECDSAMock is Account, SignerECDSA, ERC7739, ERC7821, ER
|
||||
}
|
||||
|
||||
abstract contract AccountP256Mock is Account, SignerP256, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
|
||||
constructor(bytes32 qx, bytes32 qy) {
|
||||
_setSigner(qx, qy);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
@ -68,10 +60,6 @@ abstract contract AccountP256Mock is Account, SignerP256, ERC7739, ERC7821, ERC7
|
||||
}
|
||||
|
||||
abstract contract AccountRSAMock is Account, SignerRSA, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
|
||||
constructor(bytes memory e, bytes memory n) {
|
||||
_setSigner(e, n);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
@ -141,10 +129,6 @@ abstract contract AccountERC7579HookedMock is AccountERC7579Hooked {
|
||||
}
|
||||
|
||||
abstract contract AccountERC7913Mock is Account, SignerERC7913, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
|
||||
constructor(bytes memory _signer) {
|
||||
_setSigner(_signer);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
@ -156,11 +140,6 @@ abstract contract AccountERC7913Mock is Account, SignerERC7913, ERC7739, ERC7821
|
||||
}
|
||||
|
||||
abstract contract AccountMultiSignerMock is Account, MultiSignerERC7913, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
|
||||
constructor(bytes[] memory signers, uint64 threshold) {
|
||||
_addSigners(signers);
|
||||
_setThreshold(threshold);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
@ -179,12 +158,6 @@ abstract contract AccountMultiSignerWeightedMock is
|
||||
ERC721Holder,
|
||||
ERC1155Holder
|
||||
{
|
||||
constructor(bytes[] memory signers, uint64[] memory weights, uint64 threshold) {
|
||||
_addSigners(signers);
|
||||
_setSignerWeights(signers, weights);
|
||||
_setThreshold(threshold);
|
||||
}
|
||||
|
||||
/// @inheritdoc ERC7821
|
||||
function _erc7821AuthorizedExecutor(
|
||||
address caller,
|
||||
|
||||
@ -3,26 +3,11 @@
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ECDSA} from "../../../utils/cryptography/ECDSA.sol";
|
||||
import {EIP712} from "../../../utils/cryptography/EIP712.sol";
|
||||
import {ERC7739} from "../../../utils/cryptography/signers/draft-ERC7739.sol";
|
||||
import {SignerECDSA} from "../../../utils/cryptography/signers/SignerECDSA.sol";
|
||||
import {SignerP256} from "../../../utils/cryptography/signers/SignerP256.sol";
|
||||
import {SignerRSA} from "../../../utils/cryptography/signers/SignerRSA.sol";
|
||||
|
||||
contract ERC7739ECDSAMock is ERC7739, SignerECDSA {
|
||||
constructor(address signerAddr) EIP712("ERC7739ECDSA", "1") {
|
||||
_setSigner(signerAddr);
|
||||
}
|
||||
}
|
||||
|
||||
contract ERC7739P256Mock is ERC7739, SignerP256 {
|
||||
constructor(bytes32 qx, bytes32 qy) EIP712("ERC7739P256", "1") {
|
||||
_setSigner(qx, qy);
|
||||
}
|
||||
}
|
||||
|
||||
contract ERC7739RSAMock is ERC7739, SignerRSA {
|
||||
constructor(bytes memory e, bytes memory n) EIP712("ERC7739RSA", "1") {
|
||||
_setSigner(e, n);
|
||||
}
|
||||
}
|
||||
abstract contract ERC7739ECDSAMock is ERC7739, SignerECDSA {}
|
||||
abstract contract ERC7739P256Mock is ERC7739, SignerP256 {}
|
||||
abstract contract ERC7739RSAMock is ERC7739, SignerRSA {}
|
||||
|
||||
@ -70,6 +70,11 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
|
||||
/// @dev The `threshold` is unreachable given the number of `signers`.
|
||||
error MultiSignerERC7913UnreachableThreshold(uint64 signers, uint64 threshold);
|
||||
|
||||
constructor(bytes[] memory signers_, uint64 threshold_) {
|
||||
_addSigners(signers_);
|
||||
_setThreshold(threshold_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns a slice of the set of authorized signers.
|
||||
*
|
||||
|
||||
@ -68,6 +68,11 @@ abstract contract MultiSignerERC7913Weighted is MultiSignerERC7913 {
|
||||
/// @dev Thrown when the arrays lengths don't match. See {_setSignerWeights}.
|
||||
error MultiSignerERC7913WeightedMismatchedLength();
|
||||
|
||||
constructor(bytes[] memory signers_, uint64[] memory weights_, uint64 threshold_) MultiSignerERC7913(signers_, 1) {
|
||||
_setSignerWeights(signers_, weights_);
|
||||
_setThreshold(threshold_);
|
||||
}
|
||||
|
||||
/// @dev Gets the weight of a signer. Returns 0 if the signer is not authorized.
|
||||
function signerWeight(bytes memory signer) public view virtual returns (uint64) {
|
||||
unchecked {
|
||||
|
||||
@ -28,6 +28,10 @@ import {ECDSA} from "../ECDSA.sol";
|
||||
abstract contract SignerECDSA is AbstractSigner {
|
||||
address private _signer;
|
||||
|
||||
constructor(address signerAddr) {
|
||||
_setSigner(signerAddr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets the signer with the address of the native signer. This function should be called during construction
|
||||
* or through an initializer.
|
||||
|
||||
@ -32,6 +32,10 @@ import {SignatureChecker} from "../SignatureChecker.sol";
|
||||
abstract contract SignerERC7913 is AbstractSigner {
|
||||
bytes private _signer;
|
||||
|
||||
constructor(bytes memory signer_) {
|
||||
_setSigner(signer_);
|
||||
}
|
||||
|
||||
/// @dev Return the ERC-7913 signer (i.e. `verifier || key`).
|
||||
function signer() public view virtual returns (bytes memory) {
|
||||
return _signer;
|
||||
|
||||
@ -31,6 +31,10 @@ abstract contract SignerP256 is AbstractSigner {
|
||||
|
||||
error SignerP256InvalidPublicKey(bytes32 qx, bytes32 qy);
|
||||
|
||||
constructor(bytes32 qx, bytes32 qy) {
|
||||
_setSigner(qx, qy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets the signer with a P256 public key. This function should be called during construction
|
||||
* or through an initializer.
|
||||
|
||||
@ -29,6 +29,10 @@ abstract contract SignerRSA is AbstractSigner {
|
||||
bytes private _e;
|
||||
bytes private _n;
|
||||
|
||||
constructor(bytes memory e, bytes memory n) {
|
||||
_setSigner(e, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets the signer with a RSA public key. This function should be called during construction
|
||||
* or through an initializer.
|
||||
|
||||
Reference in New Issue
Block a user