Skip to content

Commit

Permalink
Hide collection and lazy modules (use-ink#1111)
Browse files Browse the repository at this point in the history
* Hide top level `collections` and `lazy` modules

* Ignore failing doc-tests

These use types from `collections` which are not available publicly
anymore.

* Stop using `Lazy` in `ERC-20` example

* Use `Mapping` re-export in `ERC-721` example

* Update UI tests to match updated examples

* Allow `dead_code` in `lazy` and `collections` modules

* Remove `Box` and `Pack` from top level `ink_storage` re-exports

* Stop using `Lazy` in `multisig` example

* Remove `Lazy` usage from DNS example

* Update path of `Mapping` in `ERC-1155` example

* Stop using `Lazy` in `trait-erc20` example

* Undo changes to `alloc` tests

* Add TODOs noting why we're ignoring certain doctests

* Remove references to `storage::Box` from doc comments

* Stop re-exporting `boxed::Box`

* Remove storage collection benches

It doesn't looks like there's a way to keep these compiling if we're
hiding the collection module, so the next best thing to do is to remove
them completely.

* Remove `Lazy` from `delegator` example

* Appease Clippy

* Mention tracking issue for code removal instead of blank TODO
  • Loading branch information
HCastano authored and xgreenx committed Feb 8, 2022
1 parent e6725b3 commit d873f3e
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 1,178 deletions.
7 changes: 5 additions & 2 deletions crates/lang/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream {
///
/// An example for this is the following type that could potentially be used
/// within a contract's storage struct definition:
/// ```
/// // A storage vector of storage vectors.
///
///
/// ```ignore
/// # // Tracking issue [#1119]: Right now we've hidden the `StorageVec` from public access so
/// # // this doesn't compile.
/// # use ink_storage as storage;
/// # type _unused =
/// storage::Vec<storage::Vec<i32>>
Expand Down
11 changes: 4 additions & 7 deletions crates/lang/tests/ui/contract/pass/example-erc20-works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ use ink_lang as ink;
#[ink::contract]
mod erc20 {
use ink_storage::{
lazy::{
Lazy,
Mapping,
},
traits::SpreadAllocate,
Mapping,
};

/// A simple ERC-20 contract.
#[ink(storage)]
#[derive(SpreadAllocate)]
pub struct Erc20 {
/// Total token supply.
total_supply: Lazy<Balance>,
total_supply: Balance,
/// Mapping from owner to number of owned token.
balances: Mapping<AccountId, Balance>,
/// Mapping of the token amount which an account is allowed to withdraw
Expand Down Expand Up @@ -70,7 +67,7 @@ mod erc20 {
fn new_init(&mut self, initial_supply: Balance) {
let caller = Self::env().caller();
self.balances.insert(&caller, &initial_supply);
Lazy::set(&mut self.total_supply, initial_supply);
self.total_supply = initial_supply;
Self::env().emit_event(Transfer {
from: None,
to: Some(caller),
Expand All @@ -81,7 +78,7 @@ mod erc20 {
/// Returns the total token supply.
#[ink(message)]
pub fn total_supply(&self) -> Balance {
*self.total_supply
self.total_supply
}

/// Returns the account balance for the specified `owner`.
Expand Down
2 changes: 1 addition & 1 deletion crates/lang/tests/ui/contract/pass/example-erc721-works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use ink_lang as ink;
#[ink::contract]
mod erc721 {
use ink_storage::{
lazy::Mapping,
traits::SpreadAllocate,
Mapping,
};

use scale::{
Expand Down
38 changes: 0 additions & 38 deletions crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"],
cfg-if = "1.0"
array-init = { version = "2.0", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Workaround: we actually just need criterion as a dev-dependency, but
# there is an issue with a doubly included std lib when executing
# `cargo check --no-default-features --target wasm32-unknown-unknown`.
# We haven't found a better solution yet.
criterion = { version = "0.3", optional = true }

[dev-dependencies]
quickcheck = "1.0"
quickcheck_macros = "1.0"
Expand All @@ -43,7 +36,6 @@ paste = "1.0"
[features]
default = ["std"]
std = [
"criterion",
"ink_metadata",
"ink_metadata/std",
"ink_env/std",
Expand All @@ -55,33 +47,3 @@ std = [
]
ink-fuzz-tests = ["std"]
ink-experimental-engine = ["ink_env/ink-experimental-engine"]

[[bench]]
name = "bench_lazy"
path = "benches/bench_lazy.rs"
harness = false

[[bench]]
name = "bench_vec"
path = "benches/bench_vec.rs"
harness = false

[[bench]]
name = "bench_stash"
path = "benches/bench_stash.rs"
harness = false

[[bench]]
name = "bench_bitstash"
path = "benches/bench_bitstash.rs"
harness = false

[[bench]]
name = "bench_hashmap"
path = "benches/bench_hashmap.rs"
harness = false

[[bench]]
name = "bench_binary_heap"
path = "benches/bench_binary_heap.rs"
harness = false
221 changes: 0 additions & 221 deletions crates/storage/benches/bench_binary_heap.rs

This file was deleted.

Loading

0 comments on commit d873f3e

Please sign in to comment.