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

Commit

Permalink
nit: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubpark committed Feb 23, 2024
1 parent 9581a9f commit f7d9e86
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions contracts/interfaces/modules/external/ITokenManagementModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,40 @@ pragma solidity ^0.8.23;

import { IModule } from "../base/IModule.sol";

/// @title Token Management Module
/// @notice Module for transferring ERC20, ERC721, and ERC1155 tokens for IP Accounts.
/// @dev SECURITY RISK: An IPAccount can delegate to a frontend contract (not a registered module) to transfer tokens
/// on behalf of the IPAccount via the Token Management Module. This frontend contract can transfer any tokens that are
/// approved by the IPAccount for the Token Management Module. In other words, there's no mechanism for this module to
/// granularly control which token a caller (approved contract in this case) can transfer.
interface ITokenManagementModule is IModule {
/// @notice Transfers ERC20 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `transfer` via the IP account.
/// @dev Does not support transfer of multiple tokens at once.
/// @param ipAccount The IP account to transfer the ERC20 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC20 token contract
/// @param amount The amount of token to transfer
function transferERC20(address payable ipAccount, address to, address tokenContract, uint256 amount) external;

/// @notice Transfers ERC721 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `transferFrom` via the IP account.
/// @dev Does not support batch transfers.
/// @param ipAccount The IP account to transfer the ERC721 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC721 token contract
/// @param tokenId The ID of the token to transfer
function transferERC721(address payable ipAccount, address to, address tokenContract, uint256 tokenId) external;

/// @notice Transfers ERC1155 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `safeTransferFrom` via the IP
/// account.
/// @dev Does not support batch transfers.
/// @param ipAccount The IP account to transfer the ERC1155 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC1155 token contract
/// @param tokenId The ID of the token to transfer
/// @param amount The amount of token to transfer
function transferERC1155(
address payable ipAccount,
address to,
Expand Down
29 changes: 29 additions & 0 deletions contracts/modules/external/TokenManagementModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import { TOKEN_MANAGEMENT_MODULE_KEY } from "../../lib/modules/Module.sol";
import { BaseModule } from "../BaseModule.sol";
import { AccessControlled } from "../../access/AccessControlled.sol";

/// @title Token Management Module
/// @notice Module for transferring ERC20, ERC721, and ERC1155 tokens for IP Accounts.
/// @dev SECURITY RISK: An IPAccount can delegate to a frontend contract (not a registered module) to transfer tokens
/// on behalf of the IPAccount via the Token Management Module. This frontend contract can transfer any tokens that are
/// approved by the IPAccount for the Token Management Module. In other words, there's no mechanism for this module to
/// granularly control which token a caller (approved contract in this case) can transfer.
contract TokenManagementModule is AccessControlled, BaseModule, ITokenManagementModule {
using ERC165Checker for address;
using IPAccountChecker for IIPAccountRegistry;
Expand All @@ -22,6 +28,13 @@ contract TokenManagementModule is AccessControlled, BaseModule, ITokenManagement
address ipAccountRegistry
) AccessControlled(accessController, ipAccountRegistry) {}

/// @notice Transfers ERC20 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `transfer` via the IP account.
/// @dev Does not support transfer of multiple tokens at once.
/// @param ipAccount The IP account to transfer the ERC20 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC20 token contract
/// @param amount The amount of token to transfer
function transferERC20(
address payable ipAccount,
address to,
Expand All @@ -35,6 +48,13 @@ contract TokenManagementModule is AccessControlled, BaseModule, ITokenManagement
);
}

/// @notice Transfers ERC721 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `transferFrom` via the IP account.
/// @dev Does not support batch transfers.
/// @param ipAccount The IP account to transfer the ERC721 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC721 token contract
/// @param tokenId The ID of the token to transfer
function transferERC721(
address payable ipAccount,
address to,
Expand All @@ -48,6 +68,15 @@ contract TokenManagementModule is AccessControlled, BaseModule, ITokenManagement
);
}

/// @notice Transfers ERC1155 token from the IP account to the specified recipient.
/// @dev When calling this function, the caller must have the permission to call `safeTransferFrom` via the IP
/// account.
/// @dev Does not support batch transfers.
/// @param ipAccount The IP account to transfer the ERC1155 token from
/// @param to The recipient of the token
/// @param tokenContract The address of the ERC1155 token contract
/// @param tokenId The ID of the token to transfer
/// @param amount The amount of token to transfer
function transferERC1155(
address payable ipAccount,
address to,
Expand Down

0 comments on commit f7d9e86

Please sign in to comment.