Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Introducing Protocol Interfaces and Implementations of IPAccount, IPAccountRegistry #1

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

kingster-will
Copy link
Contributor

This PR introduces interfaces for components of the beta protocol, including IPAccount, IPAccountRegistry, IModuleRegistry, and AccessController.
The PR includes implementations of IPAccount and IPAccountRegistry,

Changes

  1. IPAccount: The IPAccount interface has been introduced. The IPAccountImpl contract provides an implementation of this interface. IPAccount is a token-bound account that adopts the EIP-6551 standard. These accounts are deployed at deterministic addresses through the official 6551 account registry. IPAccount act as core identity for actions.

  2. IPAccountRegistry: The IPAccountRegistry interface and its implementation have been introduced. This contract is responsible for managing the registration and tracking of IP Accounts.

  3. AccessController: The AccessController interface has been introduced, which includes methods for setting and checking access permissions. The implementation will be added by the next PR.

  4. IModuleRegistry: The IModuleRegistry interface has been introduced, which includes methods for registering and getting modules.

  5. Also update the GitHub action workflow and remove unused sample code.

Test

Test cases have been added to ensure the correct functionality of the newly introduced code.

- IPAccount
- IPAccountRegistry
@kingster-will kingster-will changed the title Introducing Protocol Interfaces and Implementations of IPAccount, IPAccountRegistry with Test Coverage Introducing Protocol Interfaces and Implementations of IPAccount, IPAccountRegistry Jan 18, 2024
.github/workflows/test.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@Ramarti Ramarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

test/foundry/IPAccountRegistry.t.sol Outdated Show resolved Hide resolved
test/foundry/IPAccount.t.sol Outdated Show resolved Hide resolved
@kingster-will kingster-will merged commit 599731c into storyprotocol:main Jan 19, 2024
1 check passed
Comment on lines +36 to +37
require(accessController_ != address(0), "Invalid access controller");
require(accessController == address(0), "Already initialized");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should standardize use of custom errors throughout our codebase.

Also I think to replace line 37 it's more semantically clear to do

if (address(this).code.length > 0) {
    revert IPAccountImpl_AlreadyInitialized();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should move to custom universal errors instead of literal strings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// @param to_ The recipient of the transaction
/// @param data_ The calldata to check against
/// @return True if the signer is valid, false otherwise
function _isValidSigner(address signer_, address to_, bytes calldata data_) internal view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of to_? Is it supposed to be the module address? Given we are not using it right now, I think it would be simpler to just authenticate based on the caller (signer) and function selector.

/// @param signer_ The signer to check
/// @param data_ The data to check against
/// @return The function selector if the signer is valid, 0 otherwise
function isValidSigner(address signer_, bytes calldata data_) external view returns (bytes4) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the semantics of this function are slightly confusing, since for execute the internal _isValidSigner function is used for checking who is authorized to call a specific module.

Whereas for this we are checking if a signer is authorized to act on behalf of the account overall. Unless you are implying that address(0) represents "all modules"? If so could make that clearer

address internal immutable ERC6551_PUBLIC_REGISTRY;
address internal immutable ACCESS_CONTROLLER;

error NonExistIpAccountImpl();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the custom errors library again as before


import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC6551Account } from "contracts/interfaces/erc6551/IERC6551Account.sol";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to use the standard reference here? https://github.com/erc6551/reference/tree/main/src/interfaces

@kingster-will kingster-will self-assigned this Jan 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants