Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC6909 Implementation along with extensions #5394

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

arr00
Copy link
Contributor

@arr00 arr00 commented Dec 20, 2024

Fixes #????

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: 673124c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

error ERC6909InvalidReceiver(address receiver);
error ERC6909InvalidSender(address sender);

mapping(uint256 id => mapping(address owner => uint256)) private _balances;
Copy link
Member

Choose a reason for hiding this comment

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

Why not mapping(address owner => mapping(uint256 id => uint256))? I feel is more consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is following ERC1155 impl. Given that we've strayed pretty far from storage parity at this point its probably not necessary.

contracts/token/ERC6909/draft-ERC6909.sol Outdated Show resolved Hide resolved
contracts/token/ERC6909/draft-ERC6909.sol Outdated Show resolved Hide resolved
contracts/token/ERC6909/draft-ERC6909.sol Outdated Show resolved Hide resolved
contracts/token/ERC6909/draft-ERC6909.sol Outdated Show resolved Hide resolved
}
}
if (to != address(0)) {
_balances[id][to] += amount;
Copy link
Member

Choose a reason for hiding this comment

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

Just realized this can't be unchecked given it's not bound by a totalSupply as ERC20 does, which means that multiple accounts can hold more than the maximum uint256 value.

I wonder if this is an issue we should worry about. An example where it can break is for off-chain indexers who may want to track the total supply but are restricted to an uint256 (as the graph)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ERC1155 is the same by default. Given that the ERC doesn't restrict this at all, and that it is already done in ERC1155, I think it is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants