Brushfam / openbrush-contracts

https://openbrush.io
MIT License
25 stars 10 forks source link

RawMapping possible unnecessary #101

Closed deuszx closed 1 year ago

deuszx commented 1 year ago

RawMapping might be replaceable with pure ink! Mapping since ink! 4 .

It seems like RawMapping was introduced back in ink!3 times to fix some of ink::storage::Mapping 's deficiencies. Now, each Mapping value in contract's struct will get its own and unique (within that contract's scope) key in the underlying blockchain storage while just that key will be stored in the contract struct itself.

Looking at the code of RawMapping::insert and RawMapping::get it behaves similarly to Mapping::insert/Mapping::get - ie each entry will be stored in the enclosing contract's storage (ink_env::set_contract_storage) but also use its Mapping's unique key - similarly to how RawMapping uses its prefix.

If that's true, I'd suggest removal of RawMapping and using ink's built-in Mapping instead - the less complex code the better.

coreggon11 commented 1 year ago

Hi, thanks for your input. We are currently finishing a new major update of OB and also removing unnecessary code from ink! 3

coreggon11 commented 1 year ago

Hi @deuszx , in OB we have introduced our own restricted version of Mapping and also a MultiMapping struct, and RawMapping is used to ease the implementation of these structs.

deuszx commented 1 year ago

Hey @coreggon11 , can you give an example where OB's Mapping is superior to ink! ?