Skip to content

Commit

Permalink
Fix clippy (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
MedovTimur authored Jun 12, 2024
1 parent ad0e90f commit 3121563
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 164 deletions.
2 changes: 0 additions & 2 deletions contracts/battleship/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![no_std]

#[cfg(not(feature = "binary-vendor"))]
mod contract;

#[cfg(feature = "binary-vendor")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
2 changes: 1 addition & 1 deletion contracts/battleship/tests/load_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn transfer_balances_to_account(accounts: &[String], nonce: u32) -> Result
// let mut api = GearApi::dev().await?;
let mut api = GearApi::init(WSAddress::new("wss://testnet.vara.rs", 443)).await?;
let accounts = accounts.to_vec();
for (_, account) in accounts.iter().enumerate() {
for account in accounts.iter() {
let account = api.get_specific_actor_id(account);

let account: [u8; 32] = account.into();
Expand Down
8 changes: 4 additions & 4 deletions contracts/dao-light/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Dao {
/// * The proposal can be submitted only by the existing members or their delegate addresses
/// * The applicant ID can't be the zero
/// * The DAO must have enough funds to finance the proposal
/// Arguments:
/// Arguments:
/// * `applicant`: an actor that will be funded
/// * `amount`: the number of fungible tokens that will be sent to the applicant
/// * `quorum`: a certain threshold of YES votes in order for the proposal to pass
Expand Down Expand Up @@ -155,7 +155,7 @@ impl Dao {
/// * The proposal can be submitted only by the existing members or their delegate addresses
/// * The member can vote on the proposal only once
/// * Proposal must exist, the voting period must has started and not expired
/// Arguments:
/// Arguments:
/// * `proposal_id`: the proposal ID
/// * `vote`: the member a member vote (YES or NO)
fn submit_vote(&mut self, proposal_id: u128, vote: Vote) {
Expand Down Expand Up @@ -216,7 +216,7 @@ impl Dao {
/// * The previous proposal must be processed
/// * The proposal must exist and be ready for processing
/// * The proposal must not be already be processed
/// Arguments:
/// Arguments:
/// * `proposal_id`: the proposal ID
async fn process_proposal(&mut self, proposal_id: u128) {
if proposal_id > 0 && !self.proposals.get(&(&proposal_id - 1)).unwrap().processed {
Expand Down Expand Up @@ -277,7 +277,7 @@ impl Dao {
/// * `msg::source()` must be DAO member
/// * The member must have sufficient amount of shares
/// * The latest proposal the member voted YES must be processed
/// Arguments:
/// Arguments:
/// * `amount`: The amount of shares the member would like to withdraw
async fn ragequit(&mut self, amount: u128) {
if !self.members.contains_key(&msg::source()) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/dex/factory/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum Action {
///
/// # Requirements:
/// - [`msg::source`](gstd::msg::source) must have the right to set the fee
/// receiver (must be equal to `fee_to_setter`).
/// receiver (must be equal to `fee_to_setter`).
///
/// On success, replies with [`Event::FeeToSet`].
FeeTo(ActorId),
Expand All @@ -91,7 +91,7 @@ pub enum Action {
///
/// # Requirements:
/// - [`msg::source`](gstd::msg::source) must be equal to current
/// `fee_to_setter`.
/// `fee_to_setter`.
///
/// On success, replies with [`Event::FeeToSetterSet`].
FeeToSetter(ActorId),
Expand Down
6 changes: 3 additions & 3 deletions contracts/dex/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum InnerAction {
/// # Requirements
/// - `amount_a_desired` & `amount_b_desired` mustn't equal to 0.
/// - On the first addition (first mint), a resulted amount of pool tokens
/// must be more than [`MINIMUM_LIQUIDITY`].
/// must be more than [`MINIMUM_LIQUIDITY`].
///
/// On success, replies with [`Event::AddedLiquidity`].
AddLiquidity {
Expand Down Expand Up @@ -105,7 +105,7 @@ pub enum InnerAction {
///
/// # Requirements
/// - [`msg::source()`] must have the same or a greater amount of liquidity
/// tokens than a given one.
/// tokens than a given one.
///
/// On success, replies with [`Event::RemovedLiquidity`].
///
Expand Down Expand Up @@ -184,7 +184,7 @@ pub enum InnerAction {
///
/// # Requirements
/// - [`msg::source()`] must have the same or a greater amount of liquidity
/// tokens than a given one.
/// tokens than a given one.
///
/// On success, replies with [`Event::Transfer`].
///
Expand Down
2 changes: 1 addition & 1 deletion contracts/galactic-express/.binpath
Original file line number Diff line number Diff line change
@@ -1 +1 @@
../target/wasm32-unknown-unknown/debug/galactic_express
../target/wasm32-unknown-unknown/release/galactic_express
4 changes: 2 additions & 2 deletions contracts/galactic-express/tests/utils/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gstd::{fmt::Debug, marker::PhantomData, prelude::*, ActorId};
use gtest::{Log, Program as InnerProgram, RunResult as InnerRunResult, System};
use gstd::{fmt::Debug, marker::PhantomData, prelude::*};
use gtest::{Log, RunResult as InnerRunResult, System};

pub fn initialize_system() -> System {
let system = System::new();
Expand Down
6 changes: 3 additions & 3 deletions contracts/game-of-chance/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ pub enum Action {
/// - The players entry stage mustn't be over.
/// - [`msg::source()`] mustn't already participate.
/// - [`msg::source()`] must have enough currency to pay a participation
/// cost.
/// cost.
/// - If the current game round currency is the native value
/// (`fungible_token` is [`None`]), [`msg::source()`] must send this action
/// with the amount of the value exactly equal to a participation cost.
/// (`fungible_token` is [`None`]), [`msg::source()`] must send this action
/// with the amount of the value exactly equal to a participation cost.
///
/// On success, replies with [`Event::PlayerAdded`].
///
Expand Down
1 change: 0 additions & 1 deletion contracts/game-of-chance/tests/utils/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub use super::{common::Program, Goc, FOREIGN_USER};
pub use game_of_chance_io::*;
pub use gstd::{prelude::*, ActorId};
pub use sharded_fungible_token_io::FTokenEvent;
4 changes: 2 additions & 2 deletions contracts/gear-lib-old/src/fungible_token/ft_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub trait FTCore: FTStateKeeper {
///
/// Requirements:
/// * `msg::source()` MUST have enough tokens on his balance
/// Arguments:
/// `amount`: The amount of token to be burnt
/// Arguments:
/// `amount`: The amount of token to be burnt
fn burn(&mut self, amount: u128) {
if self
.get()
Expand Down
10 changes: 5 additions & 5 deletions contracts/gear-lib-old/src/multitoken/mtk_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait MTKCore: StateKeeper + MTKTokenState {
/// Requirements:
/// * `ids` element must a unique value
/// * `account` must be a non-zero account
/// Arguments:
/// Arguments:
/// * `account`: An account to which minted token will be assigned
/// * `ids`: The vector of IDs of minted tokens
/// * `amounts`: The vector of amounts of tokens to mint (1 in case of an NFT)
Expand Down Expand Up @@ -100,7 +100,7 @@ pub trait MTKCore: StateKeeper + MTKTokenState {
/// * Only token owner can perform this action
/// * `ids` element must be the ID of the existing token
/// * `amounts` element must not exceed user's token balance
/// Arguments:
/// Arguments:
/// * `ids`: The vector of ids of the token to be burnt
/// * `amounts`: The vector of amounts of token to be burnt
fn burn(&mut self, ids: Vec<TokenId>, amounts: Vec<u128>) {
Expand Down Expand Up @@ -147,7 +147,7 @@ pub trait MTKCore: StateKeeper + MTKTokenState {
/// * `to` must be a non-zero account
/// * `ids` element must be the ID of the existing token
/// * `amounts` element must not exceed from's balance
/// Arguments:
/// Arguments:
/// * `from`: An account from which token will be transferred
/// * `to`: An account to which token will be transferred
/// * `ids`: The vector of IDs of transferred token
Expand Down Expand Up @@ -200,7 +200,7 @@ pub trait MTKCore: StateKeeper + MTKTokenState {
/// Requirements:
/// * Only the token owner can call that action
/// * `to` must be a non-zero account
/// Arguments:
/// Arguments:
/// * `to`: An account that will be approved to manage the tokens
fn approve(&mut self, to: &ActorId) {
if to == &ZERO_ID {
Expand All @@ -225,7 +225,7 @@ pub trait MTKCore: StateKeeper + MTKTokenState {
/// Requirements:
/// * Only the token owner can call that action
/// * `to` must be a non-zero account
/// Arguments:
/// Arguments:
/// * `to`: An account that won't be able to manage the tokens
fn revoke_approval(&mut self, to: &ActorId) {
self.get_mut()
Expand Down
16 changes: 8 additions & 8 deletions contracts/gear-lib/src/tokens/fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl FTState {
///
/// # Errors
/// - [`FTError::ZeroRecipientAddress`] if `operator` is
/// [`ActorId::zero()`].
/// [`ActorId::zero()`].
pub fn approve(&mut self, operator: Operator, amount: Amount) -> Result<FTApproval, FTError> {
self.internal_approve(msg::source(), operator, amount)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ impl FTState {
/// # Errors
/// - [`FTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`FTError::InsufficientAmount`] if [`msg::source()`] doesn't have
/// given `amount` of tokens.
/// given `amount` of tokens.
pub fn transfer(&mut self, to: ActorId, amount: Amount) -> Result<FTTransfer, FTError> {
self.internal_transfer(msg::source(), to, amount)
}
Expand Down Expand Up @@ -146,9 +146,9 @@ impl FTState {
/// - [`FTError::ZeroSenderAddress`] if `from` is [`ActorId::zero()`].
/// - [`FTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`FTError::InsufficientAllowance`] if [`msg::source()`] doesn't have
/// an allowance for given `amount` of tokens.
/// an allowance for given `amount` of tokens.
/// - [`FTError::InsufficientAmount`] if `from` doesn't have given `amount`
/// of tokens.
/// of tokens.
pub fn transfer_from(
&mut self,
from: Owner,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl FTState {
///
/// # Errors
/// - [`FTError::InsufficientAllowance`] if given `delta_amount` with the
/// current allowance overflows the [`Amount`] type.
/// current allowance overflows the [`Amount`] type.
pub fn increase_allowance(
&mut self,
operator: Operator,
Expand All @@ -204,7 +204,7 @@ impl FTState {
///
/// # Errors
/// - [`FTError::InsufficientAllowance`] if `operator` doesn't have given
/// `delta_amount` of an allowance.
/// `delta_amount` of an allowance.
pub fn decrease_allowance(
&mut self,
operator: Operator,
Expand All @@ -222,7 +222,7 @@ impl FTState {
/// # Errors
/// - [`FTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`FTError::InsufficientAmount`] if given `amount` with the current
/// total token supply overflows the [`Amount`] type.
/// total token supply overflows the [`Amount`] type.
pub fn mint(&mut self, to: ActorId, amount: Amount) -> Result<FTTransfer, FTError> {
if to.is_zero() {
return Err(FTError::ZeroRecipientAddress);
Expand All @@ -248,7 +248,7 @@ impl FTState {
/// # Errors
/// - [`FTError::ZeroSenderAddress`] if `from` is [`ActorId::zero()`].
/// - [`FTError::InsufficientAmount`] if `from` doesn't have given `amount`
/// of tokens.
/// of tokens.
pub fn burn(&mut self, from: Owner, amount: Amount) -> Result<FTTransfer, FTError> {
if from.is_zero() {
return Err(FTError::ZeroSenderAddress);
Expand Down
28 changes: 14 additions & 14 deletions contracts/gear-lib/src/tokens/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl MTState {
/// # Errors
/// - [`MTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`MTError::InsufficientAmount`] if given `amount` with the total
/// supply of all the tokens overflows the [`Amount`] type.
/// supply of all the tokens overflows the [`Amount`] type.
pub fn mint(&mut self, to: ActorId, id: Id, amount: Amount) -> Result<MTTransfer, MTError> {
self.mint_batch(to, vec![(id.clone(), amount)])?;

Expand Down Expand Up @@ -141,7 +141,7 @@ impl MTState {
/// # Errors
/// - [`MTError::ZeroSenderAddress`] if `from` is [`ActorId::zero()`].
/// - [`MTError::InsufficientAmount`] if `from` doesn't have given `amount`
/// of the tokens.
/// of the tokens.
pub fn burn(&mut self, from: Owner, id: Id, amount: Amount) -> Result<MTTransfer, MTError> {
self.burn_batch(from, vec![(id.clone(), amount)])?;

Expand Down Expand Up @@ -228,9 +228,9 @@ impl MTState {
///
/// # Errors
/// - [`MTError::ZeroRecipientAddress`] if `operator` is
/// [`ActorId::zero()`].
/// [`ActorId::zero()`].
/// - [`MTError::InsufficientAmount`] if [`msg::source()`] doesn't have any
/// tokens or there are no tokens with given `id`.
/// tokens or there are no tokens with given `id`.
pub fn approve(
&mut self,
operator: Operator,
Expand Down Expand Up @@ -276,9 +276,9 @@ impl MTState {
/// Returns an allowance of `owner`'s tokens for `operator`.
///
/// - If `id` is [`Some`], returns an approved amount of the tokens with
/// this `id`.
/// this `id`.
/// - If `id` is [`None`], returns [`Amount::MAX`] if `operator` is approved
/// for all `owner`s tokens, otherwise returns 0.
/// for all `owner`s tokens, otherwise returns 0.
pub fn allowance(&self, owner: Owner, operator: Operator, id: Option<&Id>) -> Amount {
id.map_or_else(
|| {
Expand Down Expand Up @@ -307,7 +307,7 @@ impl MTState {
/// # Errors
/// - [`MTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`MTError::InsufficientAmount`] if [`msg::source()`] doesn't have
/// given `amount` of the tokens.
/// given `amount` of the tokens.
pub fn transfer(&mut self, to: ActorId, id: Id, amount: Amount) -> Result<MTTransfer, MTError> {
self.transfer_batch(to, vec![(id.clone(), amount)])?;

Expand All @@ -325,7 +325,7 @@ impl MTState {
/// # Errors
/// - [`MTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`MTError::InsufficientAmount`] if [`msg::source()`] doesn't have
/// given amount of one of given tokens.
/// given amount of one of given tokens.
pub fn transfer_batch(
&mut self,
to: ActorId,
Expand Down Expand Up @@ -401,9 +401,9 @@ impl MTState {
/// - [`MTError::ZeroSenderAddress`] if `from` is [`ActorId::zero()`].
/// - [`MTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`MTError::NotApproved`] if [`msg::source()`] doesn't have any
/// allowance for given `amount` of the tokens.
/// allowance for given `amount` of the tokens.
/// - [`MTError::InsufficientAmount`] if `from` doesn't have given `amount`
/// of the tokens.
/// of the tokens.
pub fn transfer_from(
&mut self,
from: Owner,
Expand Down Expand Up @@ -437,9 +437,9 @@ impl MTState {
/// - [`MTError::ZeroSenderAddress`] if `from` is [`ActorId::zero()`].
/// - [`MTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`].
/// - [`MTError::NotApproved`] if [`msg::source()`] doesn't have any
/// allowance for given amounts of tokens.
/// allowance for given amounts of tokens.
/// - [`MTError::InsufficientAmount`] if `from` doesn't have given amount of
/// one of given tokens.
/// one of given tokens.
pub fn transfer_from_batch(
&mut self,
from: Owner,
Expand Down Expand Up @@ -548,7 +548,7 @@ impl MTState {
///
/// # Errors
/// - [`MTError::InsufficientAmount`] if there are no tokens with given
/// `id`.
/// `id`.
pub fn get_attribute(&self, id: &Id, key: &Vec<u8>) -> Result<Option<&Vec<u8>>, MTError> {
self.tokens
.get(id)
Expand All @@ -569,7 +569,7 @@ impl MTState {
///
/// # Errors
/// - [`MTError::InsufficientAmount`] if there are no tokens with given
/// `id`.
/// `id`.
pub fn set_attribute(
&mut self,
id: &Id,
Expand Down
Loading

0 comments on commit 3121563

Please sign in to comment.