dojoengine / origami

The magic of origami is in seeing a single piece of cairo evolve into a masterpiece through careful folds.
MIT License
32 stars 16 forks source link

[Feature]: ERC-721 Enumerable protection #81

Open rsodre opened 3 weeks ago

rsodre commented 3 weeks ago

Feature Request

For theerc721_enumerable_component to work, its logic must be included in the contract, adding sensitive code into mint(), burn(), and re-implementing functions transfer_from() and safe_transfer_from (). The erc721:: enumerable_mintable_burnable preset exemplifies it.

This logic should be insideerc721_enumerable_component, and not exposed to the contract creator. Any changes to that could make the components behave erratically.

Proposed Solution

By using existing SRC5 introspection, erc721_balance_component can understand if the contract is using erc721_enumerable_component or not, and ask it to do what it has to do inside transfer_from() and safe_transfer_from (). Contracts that do not require this component should still include them, but not expose its functions.

Alternatives

Adding before_update() and after_update() hooks to erc721_balance_component, like OpenZeppelin does. but implementing that inside another component is not possible, and should be included inside the token contract, which takes us back to the original problem we're trying to solve.

Related Code

No response

Additional context

No response

If the feature is accepted, would you be willing to contribute it?

rsodre commented 3 weeks ago

already working on this, will open PR as soon as #79 is closed.