From f7d9e8652be4fd6d934794c126a3d9d451bba86a Mon Sep 17 00:00:00 2001 From: Jongwon Park Date: Fri, 23 Feb 2024 01:56:28 -0800 Subject: [PATCH] nit: comments --- .../external/ITokenManagementModule.sol | 29 +++++++++++++++++++ .../external/TokenManagementModule.sol | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/contracts/interfaces/modules/external/ITokenManagementModule.sol b/contracts/interfaces/modules/external/ITokenManagementModule.sol index 0d7c2ac5..4cdf3e4a 100644 --- a/contracts/interfaces/modules/external/ITokenManagementModule.sol +++ b/contracts/interfaces/modules/external/ITokenManagementModule.sol @@ -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, diff --git a/contracts/modules/external/TokenManagementModule.sol b/contracts/modules/external/TokenManagementModule.sol index 249cfae8..4bad647e 100644 --- a/contracts/modules/external/TokenManagementModule.sol +++ b/contracts/modules/external/TokenManagementModule.sol @@ -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; @@ -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, @@ -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, @@ -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,