Skip to content

refactor(erc1155): modular facet architecture with exportSelectors#286

Draft
aapsi wants to merge 4 commits intoPerfect-Abstractions:mainfrom
aapsi:refactor/erc1155
Draft

refactor(erc1155): modular facet architecture with exportSelectors#286
aapsi wants to merge 4 commits intoPerfect-Abstractions:mainfrom
aapsi:refactor/erc1155

Conversation

@aapsi
Copy link
Contributor

@aapsi aapsi commented Mar 6, 2026

Summary

Refactors the ERC1155 implementation to match the modular facet pattern established by ERC20
and ERC721. Splits the monolithic ERC1155Facet.sol into focused facets and modules per
concern, and adds exportSelectors() to each facet as a selector discovery mechanism per
EIP-8153.

Changes Made

  • Deleted pre-refactor root-level files: ERC1155Facet.sol, ERC1155DataFacet.sol,
    ERC1155Mod.sol
  • Added Approve/ERC1155ApproveFacet.sol — external setApprovalForAll
  • Added Approve/ERC1155ApproveMod.sol — internal free function for approval logic
  • Added Burn/ERC1155BurnFacet.sol — external burnERC1155 and burnERC1155Batch with
    owner/operator authorization
  • Added Burn/ERC1155BurnMod.sol — internal free functions for burn logic
  • Added Data/ERC1155DataFacet.sol — external read-only functions: balanceOf,
    balanceOfBatch, isApprovedForAll
  • Added Metadata/ERC1155MetadataFacet.sol — external uri with per-token and base URI
    support
  • Added Metadata/ERC1155MetadataMod.sol — internal free functions: setURI, setBaseURI,
    setTokenURI
  • Added Mint/ERC1155MintMod.sol — internal free functions: mintERC1155,
    mintERC1155Batch with ERC1155Receiver validation
  • Added Transfer/ERC1155TransferFacet.sol — external safeTransferFrom and
    safeBatchTransferFrom with ERC1155Receiver validation
  • Added Transfer/ERC1155TransferMod.sol — internal free functions for transfer logic
  • Added exportSelectors() to all 5 facets (Approve, Burn, Data, Metadata, Transfer)
  • Function naming follows token-prefixed convention: mintERC1155, burnERC1155, etc.
    (consistent with mintERC20, burnERC721)
  • Two diamond storage slots: keccak256("erc1155") for core token data,
    keccak256("erc1155.metadata") for metadata
  • ERC-6093 compliant error names throughout
  • ERC-8042 compliant storage struct annotations

Checklist

Before submitting this PR, please ensure:

  • Code follows the Solidity feature ban - No inheritance, constructors, modifiers,
    public/private variables, external library functions, using for directives, or
    selfdestruct

  • Code follows Design Principles - Readable, uses diamond storage, favors composition
    over inheritance

  • Code matches the codebase style - Consistent formatting, documentation, and
    patterns (e.g. ERC20Facet.sol)

  • Code is formatted with forge fmt

  • Existing tests pass - Run tests to be sure existing tests pass.

  • All tests pass - Run forge test and ensure everything works

  • Documentation updated - If applicable, update relevant documentation

Make sure to follow the
contributing guidelines.

Additional Notes

Existing test files still reference the deleted pre-refactor files and will need to be
updated.

agent-cli and others added 4 commits March 6, 2026 07:32
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@netlify
Copy link

netlify bot commented Mar 6, 2026

👷 Deploy request for compose-diamonds pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e246e59

@aapsi aapsi marked this pull request as draft March 6, 2026 09:20
@maxnorm maxnorm linked an issue Mar 6, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Refactor ERC1155

2 participants