-
Notifications
You must be signed in to change notification settings - Fork 73
/
IMultiOwnedECDSAModule.sol
107 lines (97 loc) · 4.04 KB
/
IMultiOwnedECDSAModule.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
/**
* @title ECDSA Multi Ownership Authorization Module for Biconomy Smart Accounts.
* @dev Compatible with Biconomy Modular Interface v 0.1
* - It allows to validate user operations signed by EOA private key.
* - EIP-1271 compatible (ensures Smart Account can validate signed messages).
* - Multiple owners per Smart Account.
* - Does not support outdated eth_sign flow for cheaper validations
* (see https://support.metamask.io/hc/en-us/articles/14764161421467-What-is-eth-sign-and-why-is-it-a-risk-)
* !!!!!!! Only EOA owners supported, no Smart Account Owners
* @author Fil Makarov - <filipp.makarov@biconomy.io>
*/
interface IMultiOwnedECDSAModule {
event OwnershipTransferred(
address indexed smartAccount,
address indexed oldOwner,
address indexed newOwner
);
error AlreadyInitedForSmartAccount(address smartAccount);
error NoOwnersToAdd();
error WrongSignatureLength();
error NotEOA(address account);
error ZeroAddressNotAllowedAsOwner();
error OwnerAlreadyUsedForSmartAccount(address owner, address smartAccount);
error NotAnOwner(address owner, address smartAccount);
/**
* @dev Initializes the module for a Smart Account.
* Should be used at a time of first enabling the module for a Smart Account.
* @param eoaOwners The owner of the Smart Account. Should be EOA!
*/
function initForSmartAccount(
address[] calldata eoaOwners
) external returns (address);
/**
* @dev Sets/changes an for a Smart Account.
* Should be called by Smart Account itself.
* @param owner The current owner of the Smart Account to be replaced.
* @param newOwner The new owner of the Smart Account.
*/
function transferOwnership(address owner, address newOwner) external;
/**
* @dev Adds owner for Smart Account.
* should be called by Smart Account.
* @param owner The owner of the Smart Account.
*/
function addOwner(address owner) external;
/**
* @dev Renounces ownership from owner
* should be called by Smart Account.
* @param owner The owner to be removed
*/
function removeOwner(address owner) external;
/**
* @dev Returns the if the address provided is one of owners of the Smart Account.
* @param smartAccount Smart Account address.
* @param eoaAddress The address to check for ownership
*/
function isOwner(
address smartAccount,
address eoaAddress
) external view returns (bool);
/**
* @dev Returns the number of owners of the Smart Account.
* @param smartAccount Smart Account address.
* @return The number of owners of the Smart Account.
*/
function getNumberOfOwners(
address smartAccount
) external view returns (uint256);
/**
* @dev Validates a signature for a message signed by address.
* @dev Also try dataHash.toEthSignedMessageHash()
* @param dataHash hash of the data
* @param moduleSignature Signature to be validated.
* @param smartAccount expected signer Smart Account address.
* @return EIP1271_MAGIC_VALUE if signature is valid, 0xffffffff otherwise.
*/
function isValidSignatureForAddress(
bytes32 dataHash,
bytes memory moduleSignature,
address smartAccount
) external view returns (bytes4);
/**
* @dev Same as isValidSignatureForAddress but does not append Smart Account address to the hash
* @dev Expects the data Hash to already include smart account address information
* @param dataHash hash of the data which includes smart account address
* @param moduleSignature Signature to be validated.
* @param smartAccount expected signer Smart Account address.
* @return EIP1271_MAGIC_VALUE if signature is valid, 0xffffffff otherwise.
*/
function isValidSignatureForAddressUnsafe(
bytes32 dataHash,
bytes memory moduleSignature,
address smartAccount
) external view returns (bytes4);
}