Skip to content

Commit

Permalink
List all contracts in excluded packages (#725)
Browse files Browse the repository at this point in the history
* List all contracts in excluded packages

... so that they will be checked on CI.

* Fix clippy in contracts
  • Loading branch information
obrok authored Nov 14, 2022
1 parent 0fe3706 commit 8e4dcf7
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-excluded-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
pushd "$p"
cargo fmt --all --check
cargo clippy --all-features -- --no-deps -D warnings
cargo test
popd
done
Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ exclude = [
"fork-off",
"benches/payout-stakers",
"bin/cliain",
"contracts",
"contracts/access_control",
"contracts/button",
"contracts/game_token",
"contracts/marketplace",
"contracts/simple_dex",
"contracts/ticket_token",
"contracts/wrapped_azero"
]

[profile.release]
Expand Down
9 changes: 8 additions & 1 deletion contracts/access_control/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::let_unit_value)]

pub use crate::access_control::{
AccessControlError, ACCESS_CONTROL_PUBKEY, CHECK_ROLE_SELECTOR, HAS_ROLE_SELECTOR,
Expand Down Expand Up @@ -68,7 +69,7 @@ mod access_control {
pub fn new() -> Self {
// This call is required in order to correctly initialize the
// `Mapping`s of our contract.
ink_lang::utils::initialize_contract(|contract| Self::new_init(contract))
ink_lang::utils::initialize_contract(Self::new_init)
}

/// Initializes the contract.
Expand Down Expand Up @@ -157,6 +158,12 @@ mod access_control {
}
}

impl Default for AccessControl {
fn default() -> Self {
Self::new()
}
}

#[cfg(test)]
mod tests {
use ink_lang as ink;
Expand Down
1 change: 1 addition & 0 deletions contracts/button/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::let_unit_value)]

mod errors;

Expand Down
1 change: 1 addition & 0 deletions contracts/game_token/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![allow(clippy::let_unit_value)]

pub use crate::game_token::{
ALLOWANCE_SELECTOR, BALANCE_OF_SELECTOR, BURN_SELECTOR, MINT_SELECTOR, TRANSFER_FROM_SELECTOR,
Expand Down
7 changes: 4 additions & 3 deletions contracts/marketplace/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![allow(clippy::let_unit_value)]

use ink_lang as ink;

Expand Down Expand Up @@ -198,7 +199,7 @@ pub mod marketplace {
/// current price is greater than that.
#[ink(message)]
pub fn buy(&mut self, max_price: Option<Balance>) -> Result<(), Error> {
if self.ticket_balance()? <= 0 {
if self.ticket_balance()? == 0 {
return Err(Error::MarketplaceEmpty);
}

Expand Down Expand Up @@ -250,7 +251,7 @@ pub mod marketplace {

fn current_price(&self) -> Balance {
let block = self.env().block_number();
let elapsed = block.saturating_sub(self.current_start_block.into());
let elapsed = block.saturating_sub(self.current_start_block);
self.average_price()
.saturating_mul(self.sale_multiplier)
.saturating_sub(self.per_block_reduction().saturating_mul(elapsed.into()))
Expand Down Expand Up @@ -312,7 +313,7 @@ pub mod marketplace {
Self::env().caller(),
role,
|reason| reason.into(),
|role| Error::MissingRole(role),
Error::MissingRole,
)
}

Expand Down
74 changes: 64 additions & 10 deletions contracts/simple_dex/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion contracts/simple_dex/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::let_unit_value)]

use ink_lang as ink;

Expand Down Expand Up @@ -133,7 +134,7 @@ mod simple_dex {
);

match role_check {
Ok(_) => initialize_contract(|contract| Self::new_init(contract)),
Ok(_) => initialize_contract(Self::new_init),
Err(why) => panic!("Could not initialize the contract {:?}", why),
}
}
Expand Down Expand Up @@ -506,4 +507,10 @@ mod simple_dex {
emitter.emit_event(event);
}
}

impl Default for SimpleDex {
fn default() -> Self {
SimpleDex::new()
}
}
}
1 change: 1 addition & 0 deletions contracts/ticket_token/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![allow(clippy::let_unit_value)]

pub use crate::ticket_token::{BALANCE_OF_SELECTOR, TRANSFER_FROM_SELECTOR, TRANSFER_SELECTOR};

Expand Down
1 change: 1 addition & 0 deletions contracts/wrapped_azero/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![allow(clippy::let_unit_value)]

pub use crate::wrapped_azero::{
ALLOWANCE_SELECTOR, BALANCE_OF_SELECTOR, TRANSFER_FROM_SELECTOR, TRANSFER_SELECTOR,
Expand Down

0 comments on commit 8e4dcf7

Please sign in to comment.