Skip to content

ERC1155: reorder of KeyTypes in _balances #5023

Open
@pcaversaccio

Description

@pcaversaccio

It might be nit, but you define _balances in your ERC1155 implementation accordingly:

mapping(uint256 id => mapping(address account => uint256)) private _balances;

but the balanceOf function uses the (switched) EIP-1155-compliant way as function arguments:

function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
    return _balances[id][account];
}

I would propose to change _balances to:

mapping(address account => mapping(uint256 id => uint256)) private _balances;

in order to avoid confusion and to keep consistency with the balanceOf function. My guess, why it has been implemented like this in OZ, is the official EIP implementation here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeChanges that break backwards compatibility of the public API.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions