Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ithaca-account",
"version": "0.4.2",
"version": "0.4.3",
"description": "EIP-7702 account for Ithaca Porto",
"license": "MIT",
"scripts": {
Expand Down
50 changes: 48 additions & 2 deletions src/IthacaAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
/// @dev The `msg.senders` that can use `isValidSignature`
/// to successfully validate a signature for a given key hash.
EnumerableSetLib.AddressSet checkers;
/// @dev The subaccounts (msg.senders) that can use this account and keyhash as a signer.
EnumerableSetLib.AddressSet subaccounts;
}

/// @dev Holds the storage.
Expand Down Expand Up @@ -140,13 +142,18 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
event Authorized(bytes32 indexed keyHash, Key key);

/// @dev The `implementation` has been authorized.
event ImplementationApprovalSet(address indexed implementation, bool isApproved);
event ImplementationApprovalSet(address indexed implementation, bool Approved);

/// @dev The `caller` has been authorized to delegate call into `implementation`.
event ImplementationCallerApprovalSet(
address indexed implementation, address indexed caller, bool isApproved
);

/// @dev The `subaccount` has been authorized to use `keyHash` as a signer.
event SubAccountApprovalSet(
bytes32 indexed keyHash, address indexed subaccount, bool isApproved
);

/// @dev The key with a corresponding `keyHash` has been revoked.
event Revoked(bytes32 indexed keyHash);

Expand Down Expand Up @@ -213,6 +220,28 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
ORCHESTRATOR = orchestrator;
}

////////////////////////////////////////////////////////////////////////
// SubAccount Signer Functions
////////////////////////////////////////////////////////////////////////

/// @dev MUST return the magic value `0x8afc93b4` if the signature is valid.
/// @dev This function is used for subaccounts to validate signatures using main account keys.
function isValidSignatureWithKeyHash(bytes32 digest, bytes32 keyHash, bytes calldata signature)
external
view
returns (bytes4 magicValue)
{
(bool isValid, bytes32 sigKeyHash) = unwrapAndValidateSignature(digest, signature);

if (isValid && _getKeyExtraStorage(sigKeyHash).subaccounts.contains(msg.sender)) {
// For subaccounts, the keyHash parameter is the external key hash on the subaccount
// that points to the main account, sigKeyHash is the actual key that signs the digest.
return 0x8afc93b4;
}

return 0xffffffff;
}

////////////////////////////////////////////////////////////////////////
// ERC1271
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -276,6 +305,18 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
emit SignatureCheckerApprovalSet(keyHash, checker, isApproved);
}

/// @dev Sets whether `subaccount` can use `keyHash` as a signer.
function setSubAccountApproval(bytes32 keyHash, address subaccount, bool isApproved)
public
virtual
onlyThis
{
if (_getAccountStorage().keyStorage[keyHash].isEmpty()) revert KeyDoesNotExist();
// TODO: Do we need a cap of more than 512 subaccounts?
_getKeyExtraStorage(keyHash).subaccounts.update(subaccount, isApproved, _CAP);
emit SubAccountApprovalSet(keyHash, subaccount, isApproved);
}

/// @dev Increments the sequence for the `seqKey` in nonce (i.e. upper 192 bits).
/// This invalidates the nonces for the `seqKey`, up to (inclusive) `uint64(nonce)`.
function invalidateNonce(uint256 nonce) public virtual onlyThis {
Expand Down Expand Up @@ -415,6 +456,11 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
return _getKeyExtraStorage(keyHash).checkers.values();
}

/// @dev Returns the list of approved subaccounts for `keyHash`.
function approvedSubaccounts(bytes32 keyHash) public view virtual returns (address[] memory) {
return _getKeyExtraStorage(keyHash).subaccounts.values();
}

/// @dev Computes the EIP712 digest for `calls`.
/// If the the nonce starts with `MULTICHAIN_NONCE_PREFIX`,
/// the digest will be computed without the chain ID.
Expand Down Expand Up @@ -726,6 +772,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
returns (string memory name, string memory version)
{
name = "IthacaAccount";
version = "0.4.2";
version = "0.4.3";
}
}
2 changes: 1 addition & 1 deletion src/Orchestrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ contract Orchestrator is
returns (string memory name, string memory version)
{
name = "Orchestrator";
version = "0.4.2";
version = "0.4.3";
}

////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleFunder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contract SimpleFunder is EIP712, Ownable, IFunder {
returns (string memory name, string memory version)
{
name = "SimpleFunder";
version = "0.1.0";
version = "0.4.3";
}

////////////////////////////////////////////////////////////////////////
Expand Down
Loading