Unverified Commit 9bda2031 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Spellchecking for examples + Fix master CI (#812)

* Spellcheck examples as well

* Remove non-existent method

* Fix language

* Fix clippy `needless_borrow`

https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow



* Fix spellchecking for examples

* Add `block_timestamp` in `engine`

* Update examples/erc721/lib.rs
Co-authored-by: default avatarRobin Freyler <robin.freyler@gmail.com>

* Find solution for words which are non-existent
Co-authored-by: default avatarRobin Freyler <robin.freyler@gmail.com>
parent 2458e0c0
Pipeline #141453 passed with stages
in 25 minutes and 21 seconds
......@@ -35,6 +35,7 @@ scalable
adjunctive
invariants
deserializes
DApp
hasher/S
hashmap/S
......@@ -48,3 +49,4 @@ defragment/SD
layout/JG
endian/P
accessor/S
NFT/S
......@@ -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
......
......@@ -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())
}
......@@ -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)
}
......@@ -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())
}
......@@ -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")
......@@ -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())
......
......@@ -294,7 +294,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.
......@@ -346,14 +346,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`");
}
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`");
}
......
......@@ -289,7 +289,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> {
......
......@@ -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 {
......
......@@ -37,7 +37,7 @@ pub struct ItemImpls<'a> {
impl AsRef<ir::Contract> for ItemImpls<'_> {
fn as_ref(&self) -> &ir::Contract {
&self.contract
self.contract
}
}
......
......@@ -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();
......@@ -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();
......
......@@ -101,35 +101,35 @@ 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)
}
}
......@@ -137,7 +137,7 @@ impl<'a, C> ::core::ops::Deref for CallableWithSelector<'a, C> {
type Target = C;
fn deref(&self) -> &Self::Target {
&self.callable
self.callable
}
}
......
......@@ -498,13 +498,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
......
......@@ -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 {
......@@ -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,
......@@ -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);
......
......@@ -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)
}
}
......
......@@ -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
......
......@@ -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.
......
......@@ -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(),
}
}
......@@ -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),
}
}
......@@ -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.
......@@ -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()
}
/// Take the ownership of the key and value from the map.
......
......@@ -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.
......
......@@ -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
......@@ -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);
}
}
......@@ -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());
}
}
......@@ -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);
}
}
......@@ -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);
}
}
......
......@@ -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.
......
......@@ -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);
}
}
......@@ -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.
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment