For my dapp I need storage which can reference a mutable amount of events, all of which have their own orderbook. Expanded, it looks something like this:
CoreStorage {
coin_storage: CoinStore, //not the issue
event_storage: {
event_type_1: Mapping<EventId, EventType1>,
event_type_2: Mapping<EventId, EventType2>,
}
EventType1 {
event_info: EventInfo,
event_orderbook: EventOrderBook //where the issue lies
}
EventOrderbook {
orders_0: Mapping<AccountId, Order>, //this is impossible from what I can tell
orders_1: Mapping<AccountId, Order>
}
Nested Mapping
structures are not supported by design. Likely the final data structure will not be a Mapping
type, something much more performant for sorted lookups, but regardless it will not be able to adhere to the PackedLayout
trait (this is just what I assume with my current knowledge).
My only thought I have to make this work is to have a separate smart contract for every EventOrderbook
that communicates back to the main smart contract, so the storage structure will be replaced with something like:
use event_contract::EventContract
EventType1 {
event_info: EventInfo,
event_contract: EventContract
}
and in another crate I would have a contract that is compiled as a dependency that I can instantiate when I instantiate this main contract.
Is this the correct approach? Or is there some more efficient way I should be doing this?
Thank you! Any help or documentation would be appreciated.