Skip to content

Commit

Permalink
Port multisig example to low level data structures (use-ink#1078)
Browse files Browse the repository at this point in the history
* Fix `Default` impl of `Mapping`

* Replace HashMap by Mapping

* Use initialize_contract

* Initialize everything within `initialize_contract`

* Make owners lazy

* Remove commented out code

There's no way to get the length of a `Mapping` so it doesn't make sense
to check this in tests anymore

* Fix - + bug

* No need to make a primitive lazy

* Clippy

Co-authored-by: Hernando Castano <hernando@hcastano.com>
  • Loading branch information
2 people authored and xgreenx committed Feb 8, 2022
1 parent 5018edf commit 9890126
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 119 deletions.
11 changes: 10 additions & 1 deletion crates/storage/src/lazy/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ use ink_primitives::Key;

/// A mapping of key-value pairs directly into contract storage.
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
#[derive(Default)]
pub struct Mapping<K, V> {
offset_key: Key,
_marker: PhantomData<fn() -> (K, V)>,
}

/// We implement this manually because the derived implementation adds trait bounds.
impl<K, V> Default for Mapping<K, V> {
fn default() -> Self {
Self {
offset_key: Default::default(),
_marker: Default::default(),
}
}
}

impl<K, V> core::fmt::Debug for Mapping<K, V> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mapping")
Expand Down
Loading

0 comments on commit 9890126

Please sign in to comment.