Skip to content

Commit

Permalink
Merge pull request #9 from superform-xyz/final-cleanup
Browse files Browse the repository at this point in the history
chore: final natspec review
  • Loading branch information
vikramarun authored Dec 25, 2023
2 parents 932abbf + 1562883 commit cae36fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/ERC1155A.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import { IERC1155A } from "./interfaces/IERC1155A.sol";
import { IaERC20 } from "./interfaces/IaERC20.sol";
import { Strings } from "openzeppelin-contracts/contracts/utils/Strings.sol";
import { IERC165 } from "openzeppelin-contracts/contracts/interfaces/IERC165.sol";
import { IERC1155 } from "openzeppelin-contracts/contracts/interfaces/IERC1155.sol";
import { IERC1155MetadataURI } from "openzeppelin-contracts/contracts/interfaces/IERC1155MetadataURI.sol";
import { IERC1155Errors } from "openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol";
import { IERC1155Receiver } from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC1155A } from "./interfaces/IERC1155A.sol";
import { IaERC20 } from "./interfaces/IaERC20.sol";

/// @title ERC1155A
/// @author Zeropoint Labs
/// @dev Single/range based id approve capability with conversion to ERC20s
/// @author Zeropoint Labs
abstract contract ERC1155A is IERC1155A, IERC1155Errors {

//////////////////////////////////////////////////////////////
Expand All @@ -25,10 +25,10 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors {
// STATE VARIABLES //
//////////////////////////////////////////////////////////////

/// @notice ERC20-like mapping for single id supply.
/// @dev ERC20-like mapping for single id supply.
mapping(uint256 => uint256) private _totalSupply;

/// @notice ERC20-like mapping for single id approvals.
/// @dev ERC20-like mapping for single id approvals.
mapping(address owner => mapping(address operator => mapping(uint256 id => uint256 amount))) private allowances;

/// @dev Implementation copied from solmate/ERC1155
Expand Down
4 changes: 2 additions & 2 deletions src/aERC20.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import { IaERC20 } from "./interfaces/IaERC20.sol";
import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";

/// @title aERC20
/// @dev ERC20 tokens out of 1155A
/// @author Zeropoint Labs
/// @dev ERC20 tokens out of 1155a
contract aERC20 is ERC20, IaERC20 {

//////////////////////////////////////////////////////////////
Expand Down
38 changes: 21 additions & 17 deletions src/interfaces/IERC1155A.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ interface IERC1155A is IERC1155 {
// EVENTS //
//////////////////////////////////////////////////////////////

/// @notice event emitted when single id approval is set
/// @dev emitted when single id approval is set
event ApprovalForOne(address indexed owner, address indexed spender, uint256 id, uint256 amount);

/// @notice event emitted when an ERC1155A id is transmuted to an aERC20
/// @dev emitted when an ERC1155A id is transmuted to an aERC20
event TransmutedToERC20(address indexed user, uint256 id, uint256 amount, address indexed receiver);

/// @notice event emitted when an aERC20 is transmuted to an ERC1155 id
/// @dev emitted when an aERC20 is transmuted to an ERC1155 id
event TransmutedToERC1155A(address indexed user, uint256 id, uint256 amount, address indexed receiver);

/// @notice event emitted when multiple ERC1155A ids are transmuted to aERC20s
/// @dev emitted when multiple ERC1155A ids are transmuted to aERC20s
event TransmutedBatchToERC20(address indexed user, uint256[] ids, uint256[] amounts, address indexed receiver);

/// @notice event emitted when multiple aERC20s are transmuted to ERC1155A ids
/// @dev emitted when multiple aERC20s are transmuted to ERC1155A ids
event TransmutedBatchToERC1155A(address indexed user, uint256[] ids, uint256[] amounts, address indexed receiver);

//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -71,7 +71,7 @@ interface IERC1155A is IERC1155 {
/// @param id id of the ERC1155A to approve
function allowance(address owner, address spender, uint256 id) external returns (uint256);

/// @dev handy helper to check if a AERC20 is registered
/// @notice handy helper to check if a AERC20 is registered
/// @param id id of the ERC1155
function aERC20Exists(uint256 id) external view returns (bool);

Expand All @@ -80,7 +80,7 @@ interface IERC1155A is IERC1155 {
/// @return aERC20 address of the aErc20 token for the given ERC1155 id
function getERC20TokenAddress(uint256 id) external view returns (address aERC20);

/// @dev Compute return string from baseURI set for this contract and unique vaultId
/// @notice Compute return string from baseURI set for this contract and unique vaultId
/// @param id id of the ERC1155
function uri(uint256 id) external view returns (string memory);

Expand Down Expand Up @@ -142,35 +142,39 @@ interface IERC1155A is IERC1155 {
external
returns (bool);

/// @notice Turn ERC1155A id into an aERC20
/// @dev allows owner to send ERC1155A id as an aERC20 to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param id id of the ERC20s to transmute to aErc20
/// @param amount amount of the ERC20s to transmute to aErc20
/// @param receiver address of the user to receive the aErc20 token
/// @param id id of the ERC20s to transmute to aERC20
/// @param amount amount of the ERC20s to transmute to aERC20
/// @param receiver address of the user to receive the aERC20 token
function transmuteToERC20(address owner, uint256 id, uint256 amount, address receiver) external;

/// @notice Turn aERC20 into an ERC1155A id
/// @dev allows owner to send ERC20 as an ERC1155A id to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param id id of the ERC20s to transmute to erc1155
/// @param amount amount of the ERC20s to transmute to erc1155
/// @param receiver address of the user to receive the erc1155 token id
function transmuteToERC1155A(address owner, uint256 id, uint256 amount, address receiver) external;

/// @notice Use transmuteBatchToERC20 to transmute multiple ERC1155 ids into separate ERC20
/// Easier to transmute to 1155A than to transmute back to aErc20 because of ERC1155 beauty!
/// @notice Turn ERC1155A ids into aERC20s
/// @dev allows owner to send ERC1155A ids as aERC20s to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param ids ids of the ERC1155A to transmute
/// @param amounts amounts of the ERC1155A to transmute
/// @param receiver address of the user to receive the aErc20 tokens
/// @param receiver address of the user to receive the aERC20 tokens
function transmuteBatchToERC20(address owner, uint256[] memory ids, uint256[] memory amounts, address receiver) external;

/// @notice Use transmuteBatchToERC1155A to transmute multiple ERC20 ids into separate ERC1155
/// @notice Turn aERC20s into ERC1155A ids
/// @dev allows owner to send aERC20s as ERC1155A ids to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param ids ids of the ERC20 to transmute
/// @param amounts amounts of the ERC20 to transmute
/// @param receiver address of the user to receive the erc1155 token ids
/// @param receiver address of the user to receive the ERC1155 token ids
function transmuteBatchToERC1155A(address owner, uint256[] memory ids, uint256[] memory amounts, address receiver) external;

/// @notice payable to allow any implementing cross-chain protocol to be paid for fees for relaying this action to
/// various chain
/// @notice payable to allow any implementing cross-chain protocol to be paid for fees for broadcasting
/// @dev should emit any required events inside _registerAERC20 internal function
/// @param id of the ERC1155 to create a ERC20 for
function registerAERC20(uint256 id) external payable returns (address);
Expand Down

0 comments on commit cae36fd

Please sign in to comment.