RealityETH / reality-eth-monorepo

Monorepo containing reality.eth contracts, UI code and everything else.
38 stars 22 forks source link

Keep a mapping of templates with the template hash as the key #122

Open edmundedgar opened 1 year ago

edmundedgar commented 1 year ago

We store the hash of new templates in template_hashes which maps template ID to its content.

We should probably have done this the other way around, stored the template hash against the template ID and added a check to make sure the templates are unique, either erroring out if they're not or just returning the existing template ID. This would make it easier to get the ID of a template automatically instead of having to worry about managing different template IDs on different chains.

Consider either adding an additional mapping or checking how much the current mapping is used, and replacing it if we don't need it.

edmundedgar commented 7 months ago

This turns out to be a little bit hairy because our templates start at 0 which makes checking them in a mapping slightly complicated. Booting it to v5, we may do a separate template manager contract while we're at it.