Skip to content

[FEATURE] Add ERC20 setMetadata #257

@Conight

Description

@Conight
bytes32 constant ERC20_METADATA_STORAGE_POSITION = keccak256("compose.erc20.metadata");

/**
 * @custom:storage-location erc8042:compose.erc20.metadata
 */
struct ERC20MetadataStorage {
    string name;
    string symbol;
    uint8 decimals;
}

function getERC20MetadataStorage() pure returns (ERC20MetadataStorage storage s) {
    bytes32 position = ERC20_METADATA_STORAGE_POSITION;
    assembly {
        s.slot := position
    }
}

function setMetadata(string memory _name, string memory _symbol, uint8 memory _decimals) {
    ERC721Storage storage s = getERC20MetadataStorage();
    s.name = _name;
    s.symbol = _symbol;
    s.decimals= _decimals;
}

I’m a bit confusing on the file structure. Should we use a full ERC20Metadata/ directory, or just an ERC20MetadataMod.sol file, or just add to exist ERC20Mod.sol contract? To stay consistent with the current setup, a dedicated folder probably makes more sense. Also, the ERC20Burn also needs better location maybe?

We may need to implement an improved directory hierarchy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions