hackbg / fadroma

Magical flying bulldozer for the Cosmosverse. Contains clients for Tendermint-based chains in various degrees of completeness, and a mini build system for deploying systems of multiple interdependent smart contracts from source.
https://fadroma.tech
GNU Affero General Public License v3.0
51 stars 15 forks source link

WIP: Storage refactor #143

Closed aakamenov closed 1 year ago

aakamenov commented 1 year ago

Reworks and extends the Fadroma storage functionality by introducing a flexible storage key building system and storage types built on top of that. All keys are built using a single allocation. The storage types allow a single declaration, similar to the CW Plus types, but due to the key system we allow for customizing how the type is stored and also the types from which the keys are created can now be expressed in code now which introduces the concept of strongly-typed keys. For example, if we store data under an address + an index we can now express that as TypedKey2<CanonicalAddr, u64>. In addition, the existing Canonize/Humanize traits allow us to extend the new storage types to accept types that canonize to the given type T and inversely, load and humanize the type T to the given type requested. This means we can canonize and store in a single call (and load and humanize).