Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spellchecking for examples + Fix master CI #812

Merged
merged 8 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .config/cargo_spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ scalable
adjunctive
invariants
deserializes
DApp

hasher/S
hashmap/S
Expand All @@ -48,3 +49,4 @@ defragment/SD
layout/JG
endian/P
accessor/S
NFT/S
6 changes: 6 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ spellcheck:
when: never
script:
- cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1
- for example in examples/*/; do
cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 ${example};
done
- for contract in ${DELEGATOR_SUBCONTRACTS}; do
cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/;
done

codecov:
stage: workspace
Expand Down
10 changes: 5 additions & 5 deletions crates/engine/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Database {
account_id: &[u8],
key: &[u8],
) -> Option<&Vec<u8>> {
let hashed_key = storage_of_contract_key(&account_id, key);
let hashed_key = storage_of_contract_key(account_id, key);
self.hmap.get(&hashed_key.to_vec())
}

Expand All @@ -80,7 +80,7 @@ impl Database {
key: &[u8],
value: Vec<u8>,
) -> Option<Vec<u8>> {
let hashed_key = storage_of_contract_key(&account_id, key);
let hashed_key = storage_of_contract_key(account_id, key);
self.hmap.insert(hashed_key.to_vec(), value)
}

Expand All @@ -90,7 +90,7 @@ impl Database {
account_id: &[u8],
key: &[u8],
) -> Option<Vec<u8>> {
let hashed_key = storage_of_contract_key(&account_id, key);
let hashed_key = storage_of_contract_key(account_id, key);
self.hmap.remove(&hashed_key.to_vec())
}

Expand All @@ -112,7 +112,7 @@ impl Database {

/// Returns the balance of `account_id`, if available.
pub fn get_balance(&self, account_id: &[u8]) -> Option<Balance> {
let hashed_key = balance_of_key(&account_id);
let hashed_key = balance_of_key(account_id);
self.get(&hashed_key).map(|encoded_balance| {
scale::Decode::decode(&mut &encoded_balance[..])
.expect("unable to decode balance from database")
Expand All @@ -121,7 +121,7 @@ impl Database {

/// Sets the balance of `account_id` to `new_balance`.
pub fn set_balance(&mut self, account_id: &[u8], new_balance: Balance) {
let hashed_key = balance_of_key(&account_id);
let hashed_key = balance_of_key(account_id);
let encoded_balance = scale::Encode::encode(&new_balance);
self.hmap
.entry(hashed_key.to_vec())
Expand Down
10 changes: 5 additions & 5 deletions crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Engine {
.as_ref()
.expect("no callee has been set")
.as_bytes();
set_output(output, &callee)
set_output(output, callee)
}

/// Restores a tombstone to the original smart contract.
Expand Down Expand Up @@ -343,14 +343,14 @@ impl Engine {
super::hashing::keccak_256(input, output);
}

pub fn now(&self, _output: &mut &mut [u8]) {
unimplemented!("off-chain environment does not yet support `now`");
}

Robbepop marked this conversation as resolved.
Show resolved Hide resolved
pub fn block_number(&self, _output: &mut &mut [u8]) {
unimplemented!("off-chain environment does not yet support `block_number`");
}

pub fn block_timestamp(&self, _output: &mut &mut [u8]) {
unimplemented!("off-chain environment does not yet support `block_timestamp`");
}

pub fn gas_left(&self, _output: &mut &mut [u8]) {
unimplemented!("off-chain environment does not yet support `gas_left`");
}
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/engine/experimental_off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl TypedEnvBackend for EnvInstance {
}

fn block_timestamp<T: Environment>(&mut self) -> Result<T::Timestamp> {
self.get_property::<T::Timestamp>(Engine::now)
self.get_property::<T::Timestamp>(Engine::block_timestamp)
}

fn account_id<T: Environment>(&mut self) -> Result<T::AccountId> {
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/engine/off_chain/db/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl AccountsDb {
// the borrow-checker somehow cannot make sense of it according
// to its lifetime analysis. Consider this to be a hack until
// the borrow-checker eventually let's us do this.
if self.get_account::<T>(&at).is_some() {
if self.get_account::<T>(at).is_some() {
self.get_account_mut::<T>(at)
.expect("just checked that account exists")
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/lang/codegen/src/generator/item_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct ItemImpls<'a> {

impl AsRef<ir::Contract> for ItemImpls<'_> {
fn as_ref(&self) -> &ir::Contract {
&self.contract
self.contract
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/lang/codegen/src/generator/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Metadata<'_> {
.map(|(trait_ident, constructor)| {
let span = constructor.span();
let attrs = constructor.attrs();
let docs = Self::extract_doc_comments(&attrs);
let docs = Self::extract_doc_comments(attrs);
let selector = constructor.composed_selector();
let selector_bytes = selector.as_bytes();
let constructor = constructor.callable();
Expand Down Expand Up @@ -216,7 +216,7 @@ impl Metadata<'_> {
.map(|(trait_ident, message)| {
let span = message.span();
let attrs = message.attrs();
let docs = Self::extract_doc_comments(&attrs);
let docs = Self::extract_doc_comments(attrs);
let selector = message.composed_selector();
let selector_bytes = selector.as_bytes();
let is_payable = message.is_payable();
Expand Down
18 changes: 9 additions & 9 deletions crates/lang/ir/src/ir/item_impl/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,43 @@ where
C: Callable,
{
fn kind(&self) -> CallableKind {
<C as Callable>::kind(&self.callable)
<C as Callable>::kind(self.callable)
}

fn ident(&self) -> &Ident {
<C as Callable>::ident(&self.callable)
<C as Callable>::ident(self.callable)
}

fn user_provided_selector(&self) -> Option<&ir::Selector> {
<C as Callable>::user_provided_selector(&self.callable)
<C as Callable>::user_provided_selector(self.callable)
}

fn is_payable(&self) -> bool {
<C as Callable>::is_payable(&self.callable)
<C as Callable>::is_payable(self.callable)
}

fn visibility(&self) -> Visibility {
<C as Callable>::visibility(&self.callable)
<C as Callable>::visibility(self.callable)
}

fn inputs(&self) -> InputsIter {
<C as Callable>::inputs(&self.callable)
<C as Callable>::inputs(self.callable)
}

fn inputs_span(&self) -> Span {
<C as Callable>::inputs_span(&self.callable)
<C as Callable>::inputs_span(self.callable)
}

fn statements(&self) -> &[syn::Stmt] {
<C as Callable>::statements(&self.callable)
<C as Callable>::statements(self.callable)
}
}

impl<'a, C> ::core::ops::Deref for CallableWithSelector<'a, C> {
type Target = C;

fn deref(&self) -> &Self::Target {
&self.callable
self.callable
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/lang/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,13 @@ use proc_macro::TokenStream;
/// Self { value: init_value }
/// }
///
/// /// Flips the current value of the Flipper's bool.
/// /// Flips the current value of the Flipper's boolean.
/// #[ink(message)]
/// pub fn flip(&mut self) {
/// self.value = !self.value;
/// }
///
/// /// Returns the current value of the Flipper's bool.
/// /// Returns the current value of the Flipper's boolean.
/// #[ink(message)]
/// pub fn get(&self) -> bool {
/// self.value
Expand Down
6 changes: 3 additions & 3 deletions crates/lang/macro/tests/ui/pass/05-erc721-contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod erc721 {
}

impl Erc721 {
/// Creates a new ERC721 token contract.
/// Creates a new ERC-721 token contract.
#[ink(constructor)]
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -193,7 +193,7 @@ mod erc721 {
Ok(())
}

/// Transfers token `id` `from` the sender to the `to` AccountId.
/// Transfers token `id` `from` the sender to the `to` `AccountId`.
fn transfer_token_from(
&mut self,
from: &AccountId,
Expand Down Expand Up @@ -336,7 +336,7 @@ mod erc721 {
.unwrap_or(&false)
}

/// Returns true if the AccountId `from` is the owner of token `id`
/// Returns true if the `AccountId` `from` is the owner of token `id`
/// or it has been approved on behalf of the token `id` owner.
fn approved_or_owner(&self, from: Option<AccountId>, id: TokenId) -> bool {
let owner = self.owner_of(id);
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/src/alloc/boxed/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ where
}

fn push_spread(&self, ptr: &mut KeyPtr) {
forward_push_packed::<Self>(&self, ptr)
forward_push_packed::<Self>(self, ptr)
}

fn clear_spread(&self, ptr: &mut KeyPtr) {
forward_clear_packed::<Self>(&self, ptr)
forward_clear_packed::<Self>(self, ptr)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/alloc/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl DynamicAllocatorState {
// Push all state of the global dynamic storage allocator
// instance back onto the contract storage.
push_spread_root::<DynamicAllocator>(
&allocator,
allocator,
&Key::from(DYNAMIC_ALLOCATOR_KEY_OFFSET),
);
// Prevent calling `drop` on the dynamic storage allocator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ where
/// Prefer using methods like `Iterator::take` in order to limit the number
/// of yielded elements.
pub fn iter(&self) -> Iter<T> {
Iter::new(&self)
Iter::new(self)
}

/// Returns a shared reference to the first element if any.
Expand Down
10 changes: 5 additions & 5 deletions crates/storage/src/collections/hashmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ where
/// Returns a reference to this entry's key.
pub fn key(&self) -> &K {
match self {
Entry::Occupied(entry) => &entry.values_entry.key(),
Entry::Vacant(entry) => &entry.values_entry.key(),
Entry::Occupied(entry) => entry.values_entry.key(),
Entry::Vacant(entry) => entry.values_entry.key(),
}
}

Expand Down Expand Up @@ -459,7 +459,7 @@ where
{
match self {
Entry::Occupied(entry) => &mut entry.values_entry.into_mut().value,
Entry::Vacant(entry) => Entry::insert(default(&entry.key()), entry),
Entry::Vacant(entry) => Entry::insert(default(entry.key()), entry),
}
}

Expand Down Expand Up @@ -494,7 +494,7 @@ where
{
/// Gets a reference to the key that would be used when inserting a value through the `VacantEntry`.
pub fn key(&self) -> &K {
&self.values_entry.key()
self.values_entry.key()
}

/// Take ownership of the key.
Expand All @@ -520,7 +520,7 @@ where
{
/// Gets a reference to the key in the entry.
pub fn key(&self) -> &K {
&self.values_entry.key()
self.values_entry.key()
Robbepop marked this conversation as resolved.
Show resolved Hide resolved
}

/// Take the ownership of the key and value from the map.
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/collections/stash/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ink_primitives::Key;

#[test]
fn regression_stash_unreachable_minified() {
// This regression has been discovered in the ERC721 example implementation
// This regression has been discovered in the ERC-721 example implementation
// `approved_for_all_works` unit test. The fix was to adjust
// `Stash::remove_vacant_entry` to update `header.last_vacant` if the
// removed index was the last remaining vacant index in the stash.
Expand Down
10 changes: 5 additions & 5 deletions crates/storage/src/lazy/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ where
/// Mainly used by lazy storage abstractions that only allow operating on
/// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
pub fn pull_spread_root(root_key: &Key) -> Self {
Self::new(pull_spread_root_opt::<T>(&root_key), EntryState::Preserved)
Self::new(pull_spread_root_opt::<T>(root_key), EntryState::Preserved)
}

/// Pushes the underlying associated data to the contract storage using
Expand All @@ -198,7 +198,7 @@ where
pub fn push_spread_root(&self, root_key: &Key) {
let old_state = self.replace_state(EntryState::Preserved);
if old_state.is_mutated() {
push_spread_root_opt::<T>(self.value().into(), &root_key);
push_spread_root_opt::<T>(self.value().into(), root_key);
}
}

Expand All @@ -209,7 +209,7 @@ where
/// Mainly used by lazy storage abstractions that only allow operating on
/// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
pub fn clear_spread_root(&self, root_key: &Key) {
clear_spread_root_opt::<T, _>(&root_key, || self.value().into());
clear_spread_root_opt::<T, _>(root_key, || self.value().into());
}
}

Expand Down Expand Up @@ -238,7 +238,7 @@ where
pub fn push_packed_root(&self, root_key: &Key) {
let old_state = self.replace_state(EntryState::Preserved);
if old_state.is_mutated() {
push_packed_root_opt::<T>(self.value().into(), &root_key);
push_packed_root_opt::<T>(self.value().into(), root_key);
}
}

Expand All @@ -250,7 +250,7 @@ where
/// packed storage entities such as [`LazyIndexMap`][`crate::lazy::LazyIndexMap`]
/// or [`LazyArray`][`crate::lazy::LazyArray`].
pub fn clear_packed_root(&self, root_key: &Key) {
clear_packed_root::<Option<T>>(self.value(), &root_key);
clear_packed_root::<Option<T>>(self.value(), root_key);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/lazy/lazy_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ where
// because it requires a deep clean-up which propagates clearing to its fields,
// for example in the case of `T` being a `storage::Box`.
let entity = self.get(index).expect("cannot clear a non existing entity");
clear_packed_root::<T>(&entity, &root_key);
clear_packed_root::<T>(entity, &root_key);
} else {
// The type does not require deep clean-up so we can simply clean-up
// its associated storage cell and be done without having to load it first.
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/src/lazy/lazy_hmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
fn push_spread(&self, ptr: &mut KeyPtr) {
let offset_key = ExtKeyPtr::next_for::<Self>(ptr);
for (index, entry) in self.entries().iter() {
let root_key = self.to_offset_key(&offset_key, index);
let root_key = self.to_offset_key(offset_key, index);
entry.push_packed_root(&root_key);
}
}
Expand Down Expand Up @@ -638,7 +638,7 @@ where
// because it requires a deep clean-up which propagates clearing to its fields,
// for example in the case of `T` being a `storage::Box`.
let entity = self.get(index).expect("cannot clear a non existing entity");
clear_packed_root::<V>(&entity, &root_key);
clear_packed_root::<V>(entity, &root_key);
} else {
// The type does not require deep clean-up so we can simply clean-up
// its associated storage cell and be done without having to load it first.
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/lazy/lazy_imap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ where
// because it requires a deep clean-up which propagates clearing to its fields,
// for example in the case of `T` being a `storage::Box`.
let entity = self.get(index).expect("cannot clear a non existing entity");
clear_packed_root::<V>(&entity, &root_key);
clear_packed_root::<V>(entity, &root_key);
} else {
// The type does not require deep clean-up so we can simply clean-up
// its associated storage cell and be done without having to load it first.
Expand Down
Loading