diff --git a/contracts/battleship/src/lib.rs b/contracts/battleship/src/lib.rs index 7c871fc77..1611e3004 100644 --- a/contracts/battleship/src/lib.rs +++ b/contracts/battleship/src/lib.rs @@ -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")); diff --git a/contracts/battleship/tests/load_testing.rs b/contracts/battleship/tests/load_testing.rs index ef2327be1..faefd32f9 100644 --- a/contracts/battleship/tests/load_testing.rs +++ b/contracts/battleship/tests/load_testing.rs @@ -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(); diff --git a/contracts/dao-light/src/lib.rs b/contracts/dao-light/src/lib.rs index b4c4db873..127a87c6a 100644 --- a/contracts/dao-light/src/lib.rs +++ b/contracts/dao-light/src/lib.rs @@ -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 @@ -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) { @@ -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 { @@ -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()) { diff --git a/contracts/dex/factory/io/src/lib.rs b/contracts/dex/factory/io/src/lib.rs index 6c51530b7..56aedc766 100644 --- a/contracts/dex/factory/io/src/lib.rs +++ b/contracts/dex/factory/io/src/lib.rs @@ -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), @@ -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), diff --git a/contracts/dex/io/src/lib.rs b/contracts/dex/io/src/lib.rs index 9e5494108..f35b3083a 100644 --- a/contracts/dex/io/src/lib.rs +++ b/contracts/dex/io/src/lib.rs @@ -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 { @@ -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`]. /// @@ -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`]. /// diff --git a/contracts/galactic-express/.binpath b/contracts/galactic-express/.binpath index 27edebedf..b4c198035 100644 --- a/contracts/galactic-express/.binpath +++ b/contracts/galactic-express/.binpath @@ -1 +1 @@ -../target/wasm32-unknown-unknown/debug/galactic_express \ No newline at end of file +../target/wasm32-unknown-unknown/release/galactic_express \ No newline at end of file diff --git a/contracts/galactic-express/tests/utils/common.rs b/contracts/galactic-express/tests/utils/common.rs index 5a2b5c68f..7064af081 100644 --- a/contracts/galactic-express/tests/utils/common.rs +++ b/contracts/galactic-express/tests/utils/common.rs @@ -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(); diff --git a/contracts/game-of-chance/io/src/lib.rs b/contracts/game-of-chance/io/src/lib.rs index 844960972..b3c974c32 100644 --- a/contracts/game-of-chance/io/src/lib.rs +++ b/contracts/game-of-chance/io/src/lib.rs @@ -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`]. /// diff --git a/contracts/game-of-chance/tests/utils/prelude.rs b/contracts/game-of-chance/tests/utils/prelude.rs index 73254509f..33ab122fb 100644 --- a/contracts/game-of-chance/tests/utils/prelude.rs +++ b/contracts/game-of-chance/tests/utils/prelude.rs @@ -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; diff --git a/contracts/gear-lib-old/src/fungible_token/ft_core.rs b/contracts/gear-lib-old/src/fungible_token/ft_core.rs index e5cf74ac8..7cb0f09e7 100644 --- a/contracts/gear-lib-old/src/fungible_token/ft_core.rs +++ b/contracts/gear-lib-old/src/fungible_token/ft_core.rs @@ -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() diff --git a/contracts/gear-lib-old/src/multitoken/mtk_core.rs b/contracts/gear-lib-old/src/multitoken/mtk_core.rs index f59c6fd6a..265a8c603 100644 --- a/contracts/gear-lib-old/src/multitoken/mtk_core.rs +++ b/contracts/gear-lib-old/src/multitoken/mtk_core.rs @@ -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) @@ -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, amounts: Vec) { @@ -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 @@ -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 { @@ -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() diff --git a/contracts/gear-lib/src/tokens/fungible.rs b/contracts/gear-lib/src/tokens/fungible.rs index 6c8ff607f..89f5d6854 100644 --- a/contracts/gear-lib/src/tokens/fungible.rs +++ b/contracts/gear-lib/src/tokens/fungible.rs @@ -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 { self.internal_approve(msg::source(), operator, amount) } @@ -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 { self.internal_transfer(msg::source(), to, amount) } @@ -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, @@ -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, @@ -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, @@ -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 { if to.is_zero() { return Err(FTError::ZeroRecipientAddress); @@ -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 { if from.is_zero() { return Err(FTError::ZeroSenderAddress); diff --git a/contracts/gear-lib/src/tokens/multi.rs b/contracts/gear-lib/src/tokens/multi.rs index 92dd07f62..c64b717cc 100644 --- a/contracts/gear-lib/src/tokens/multi.rs +++ b/contracts/gear-lib/src/tokens/multi.rs @@ -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 { self.mint_batch(to, vec![(id.clone(), amount)])?; @@ -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 { self.burn_batch(from, vec![(id.clone(), amount)])?; @@ -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, @@ -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( || { @@ -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 { self.transfer_batch(to, vec![(id.clone(), amount)])?; @@ -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, @@ -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, @@ -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, @@ -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) -> Result>, MTError> { self.tokens .get(id) @@ -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, diff --git a/contracts/gear-lib/src/tokens/non_fungible.rs b/contracts/gear-lib/src/tokens/non_fungible.rs index 9a706051e..b066f8eba 100644 --- a/contracts/gear-lib/src/tokens/non_fungible.rs +++ b/contracts/gear-lib/src/tokens/non_fungible.rs @@ -69,10 +69,10 @@ impl NFTState { /// tokens or the token with given `id`. /// /// - If `id` is [`Some`], firstly checks if `operator` is allowed for all - /// `owner`'s tokens, and if not, whether `operator` is allowed for the - /// token with this `id`. + /// `owner`'s tokens, and if not, whether `operator` is allowed for the + /// token with this `id`. /// - If `id` is [`None`], only checks if `operator` is allowed for all - /// `owner`'s tokens. + /// `owner`'s tokens. pub fn allowance(&self, owner: Owner, operator: Operator, id: Option<&Id>) -> bool { Self::inner_allowance( &self.owners, @@ -109,7 +109,7 @@ impl NFTState { /// - [`NFTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`]. /// - [`NFTError::TokenNotExists`] if the token doesn't exist. /// - [`NFTError::NotApproved`] if [`msg::source()`] isn't the owner of the - /// token and doesn't have any allowance for its transfer. + /// token and doesn't have any allowance for its transfer. pub fn transfer(&mut self, to: ActorId, id: Id) -> Result { if to.is_zero() { return Err(NFTError::ZeroRecipientAddress); @@ -141,19 +141,19 @@ impl NFTState { /// tokens or only the one with given `id`. /// /// - If `id` is [`Some`], sets an approval only for the token with this - /// `id`. + /// `id`. /// - If `id` is [`None`], sets an approval for all [`msg::source()`]'s - /// tokens. + /// tokens. /// /// If [`msg::source()`] is an operator of all tokens of the owner of the /// token with given `id`, [`msg::source()`] can also set approval for them. /// /// # Errors /// - [`NFTError::ZeroRecipientAddress`] if `operator` is - /// [`ActorId::zero()`]. + /// [`ActorId::zero()`]. /// - [`NFTError::TokenNotExists`] if the token doesn't exist. /// - [`NFTError::NotApproved`] if [`msg::source()`] isn't the owner of the - /// token and operator of token's owner's tokens. + /// token and operator of token's owner's tokens. pub fn approve( &mut self, operator: Operator, @@ -214,7 +214,7 @@ impl NFTState { /// # Errors /// - [`NFTError::ZeroRecipientAddress`] if `to` is [`ActorId::zero()`]. /// - [`NFTError::TokenNotExists`] if the total supply of tokens reached the - /// maximum limit of the [`Amount`] type. + /// maximum limit of the [`Amount`] type. /// - [`NFTError::TokenExists`] if the token with given `id` already exists. pub fn mint(&mut self, to: ActorId, id: Id) -> Result { if to.is_zero() { diff --git a/contracts/gear-lib/src/tokens/non_fungible/encodable.rs b/contracts/gear-lib/src/tokens/non_fungible/encodable.rs index e96a47799..fb22e06bf 100644 --- a/contracts/gear-lib/src/tokens/non_fungible/encodable.rs +++ b/contracts/gear-lib/src/tokens/non_fungible/encodable.rs @@ -42,10 +42,10 @@ impl NFTState { /// tokens or the token with given `id`. /// /// - If `id` is [`Some`], firstly checks if `operator` is allowed for all - /// `owner`'s tokens, and if not, whether `operator` is allowed for the - /// token with given `id`. + /// `owner`'s tokens, and if not, whether `operator` is allowed for the + /// token with given `id`. /// - If `id` is [`None`], only checks if `operator` is allowed for all - /// `owner`'s tokens. + /// `owner`'s tokens. pub fn allowance(&self, owner: Owner, operator: Operator, id: Option<&Id>) -> bool { self.owners .iter() diff --git a/contracts/gear-lib/src/tx_manager.rs b/contracts/gear-lib/src/tx_manager.rs index 30efabc06..3e1a3203f 100644 --- a/contracts/gear-lib/src/tx_manager.rs +++ b/contracts/gear-lib/src/tx_manager.rs @@ -109,14 +109,14 @@ impl TransactionManager { /// /// Important notes: /// - Only one transaction for each `msg_source` is cached. Hence an attempt - /// to save a [new](TransactionKind::New) transaction over a failed one will - /// delete the failed one, so it'll be **impossible** to - /// [retry](TransactionKind::Retry) the latter. + /// to save a [new](TransactionKind::New) transaction over a failed one will + /// delete the failed one, so it'll be **impossible** to + /// [retry](TransactionKind::Retry) the latter. /// - There's no guarantee every underprocessed asynchronous action will - /// result in a cached transaction. Usually caching occurs after the first - /// blocking `.await` during action processing. + /// result in a cached transaction. Usually caching occurs after the first + /// blocking `.await` during action processing. /// - The cache memory has a limit, so when it's reached every oldest cached - /// transaction is replaced with a new one. See also [`DEFAULT_TX_LIMIT`]. + /// transaction is replaced with a new one. See also [`DEFAULT_TX_LIMIT`]. /// /// # Errors /// [`TransactionManagerError::TransactionNotFound`] if `kind` is diff --git a/contracts/multi-token/io/src/lib.rs b/contracts/multi-token/io/src/lib.rs index c4a706dc3..14d3be6bd 100644 --- a/contracts/multi-token/io/src/lib.rs +++ b/contracts/multi-token/io/src/lib.rs @@ -117,8 +117,8 @@ pub enum MtkAction { /// /// # Requirements: /// * if minting an NFT with a specific TokenId at index `idx` - /// `amounts[idx]` MUST be equal to 1, - /// *`tokens_metadata` size MUST equal to the length of ids. + /// `amounts[idx]` MUST be equal to 1, + /// *`tokens_metadata` size MUST equal to the length of ids. /// * a sender MUST be an owner or an approved account. /// /// On success returns `MtkEvent::Transfer` diff --git a/contracts/multi-token/src/lib.rs b/contracts/multi-token/src/lib.rs index 5b3de41cd..eb046577a 100644 --- a/contracts/multi-token/src/lib.rs +++ b/contracts/multi-token/src/lib.rs @@ -243,7 +243,7 @@ impl SimpleMtk { /// * `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 @@ -306,7 +306,7 @@ impl SimpleMtk { /// 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) -> Result { if to == &ActorId::zero() { @@ -331,7 +331,7 @@ impl SimpleMtk { /// 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) -> Result { let msg_src = &msg::source(); diff --git a/contracts/nft-pixelboard/io/src/lib.rs b/contracts/nft-pixelboard/io/src/lib.rs index d5ac63662..d5d38159d 100644 --- a/contracts/nft-pixelboard/io/src/lib.rs +++ b/contracts/nft-pixelboard/io/src/lib.rs @@ -157,12 +157,12 @@ pub struct TokenInfo { /// * `block_side_length` must be more than 0. /// * `pixel_price` mustn't be more than [`MAX_PIXEL_PRICE`]. /// * A [width](`Resolution#structfield.width`) & -/// [height](`Resolution#structfield.height`) (`resolution`) of a canvas must be -/// more than 0. +/// [height](`Resolution#structfield.height`) (`resolution`) of a canvas must be +/// more than 0. /// * Each side of `resolution` must be a multiple of `block_side_length`. /// * `painting` length must equal a pixel count in a canvas (which can be -/// calculated by multiplying a [width](`Resolution#structfield.width`) & -/// [height](`Resolution#structfield.height`) from `resolution`). +/// calculated by multiplying a [width](`Resolution#structfield.width`) & +/// [height](`Resolution#structfield.height`) from `resolution`). /// * `commission_percentage` mustn't be more than 100. /// * `ft_program` address mustn't be [`ActorId::zero()`]. /// * `nft_program` address mustn't be [`ActorId::zero()`]. @@ -208,22 +208,22 @@ pub enum NFTPixelboardAction { /// # Requirements /// * `rectangle` coordinates mustn't be out of a canvas. /// * `rectangle` coordinates mustn't be mixed up or belong to wrong - /// corners. + /// corners. /// * `rectangle` coordinates must observe a block layout. In other words, - /// each `rectangle` coordinate must be a multiple of a block side length in - /// the canvas. The block side length can be obtained by - /// [`block_side_length()`](../nft_pixelboard_state/metafns/fn.block_side_length.html). + /// each `rectangle` coordinate must be a multiple of a block side length in + /// the canvas. The block side length can be obtained by + /// [`block_side_length()`](../nft_pixelboard_state/metafns/fn.block_side_length.html). /// * NFT `rectangle` mustn't collide with already minted one. /// * `painting` length must equal a pixel count in an NFT - /// (which can be calculated by multiplying a [width](`Rectangle::width`) & - /// [height](`Rectangle::height`) from `rectangle`). + /// (which can be calculated by multiplying a [width](`Rectangle::width`) & + /// [height](`Rectangle::height`) from `rectangle`). /// * [`msg::source()`] must have enough fungible tokens to buy all free - /// pixels that `rectangle` will occupy. An enough number of tokens can be - /// calculated by multiplying a `rectangle` area and the price of a free - /// pixel. The area can be calculated by multiplying a - /// [width](`Rectangle::width`) & [height](`Rectangle::height`) from - /// `rectangle`. The price of a free pixel can be obtained by - /// [`pixel_price()`](../nft_pixelboard_state/metafns/fn.pixel_price.html). + /// pixels that `rectangle` will occupy. An enough number of tokens can be + /// calculated by multiplying a `rectangle` area and the price of a free + /// pixel. The area can be calculated by multiplying a + /// [width](`Rectangle::width`) & [height](`Rectangle::height`) from + /// `rectangle`. The price of a free pixel can be obtained by + /// [`pixel_price()`](../nft_pixelboard_state/metafns/fn.pixel_price.html). /// /// On success, returns [`NFTPixelboardEvent::Minted`]. /// @@ -248,12 +248,12 @@ pub enum NFTPixelboardAction { /// # Requirements /// * An NFT must be minted on a pixelboard. /// * An NFT must be for sale. This can be found out by - /// [`token_info()`]. See also the documentation of - /// [`TokenInfo#structfield.pixel_price`]. + /// [`token_info()`]. See also the documentation of + /// [`TokenInfo#structfield.pixel_price`]. /// * [`msg::source()`] must have enough fungible tokens to buy all pixels - /// that an NFT occupies. This can be found out by - /// [`token_info()`]. See also the documentation of - /// [`TokenInfo#structfield.pixel_price`]. + /// that an NFT occupies. This can be found out by + /// [`token_info()`]. See also the documentation of + /// [`TokenInfo#structfield.pixel_price`]. /// /// On success, returns [`NFTPixelboardEvent::Bought`]. /// @@ -265,14 +265,14 @@ pub enum NFTPixelboardAction { /// /// There are 3 options of a sale state change: /// * Putting up for sale\ - /// If an NFT is **not** for sale, then assigning `pixel_price` to [`Some`] - /// price will transfer it to a pixelboard program & put it up for sale. + /// If an NFT is **not** for sale, then assigning `pixel_price` to [`Some`] + /// price will transfer it to a pixelboard program & put it up for sale. /// * Updating a pixel price\ - /// If an NFT is for sale, then assigning `pixel_price` to [`Some`] price - /// will update its pixel price. + /// If an NFT is for sale, then assigning `pixel_price` to [`Some`] price + /// will update its pixel price. /// * Removing from sale\ - /// Assigning the `pixel_price` to [`None`] will transfer an NFT back to its - /// owner & remove an NFT from sale. + /// Assigning the `pixel_price` to [`None`] will transfer an NFT back to its + /// owner & remove an NFT from sale. /// /// **Note:** A commission is included in each NFT resale, so a seller /// will receive not all fungible tokens but tokens with a commission @@ -299,9 +299,9 @@ pub enum NFTPixelboardAction { /// * An NFT must be minted on a pixelboard. /// * [`msg::source()`](gstd::msg::source) must be the owner of an NFT. /// * `painting` length must equal a pixel count in an NFT. The count can be - /// calculated by multiplying a [width](`Rectangle::width`) & - /// [height](`Rectangle::height`) from a rectangle of the NFT. The NFT - /// rectangle can be obtained by [`token_info()`](../nft_pixelboard_state/metafns/fn.token_info.html). + /// calculated by multiplying a [width](`Rectangle::width`) & + /// [height](`Rectangle::height`) from a rectangle of the NFT. The NFT + /// rectangle can be obtained by [`token_info()`](../nft_pixelboard_state/metafns/fn.token_info.html). /// /// On success, returns [`NFTPixelboardEvent::Painted`]. Paint { diff --git a/contracts/nft-pixelboard/tests/utils/pixelboard.rs b/contracts/nft-pixelboard/tests/utils/pixelboard.rs index fec612f4e..8a9efbc07 100644 --- a/contracts/nft-pixelboard/tests/utils/pixelboard.rs +++ b/contracts/nft-pixelboard/tests/utils/pixelboard.rs @@ -121,21 +121,6 @@ impl<'a> NFTPixelboard<'a> { } } -pub struct NFTPixelboardInit<'a>(InnerProgram<'a>, bool); - -impl<'a> NFTPixelboardInit<'a> { - #[track_caller] - pub fn failed(self) { - assert!(self.1) - } - - #[track_caller] - pub fn succeed(self) -> NFTPixelboard<'a> { - assert!(!self.1); - NFTPixelboard(self.0) - } -} - // # TODO: uncomment when new meta will be ready for gtest // pub fn meta_state(&self) -> NFTPixelboardMetaState { diff --git a/contracts/on-chain-nft/io/src/lib.rs b/contracts/on-chain-nft/io/src/lib.rs index 875f7c667..996085c17 100644 --- a/contracts/on-chain-nft/io/src/lib.rs +++ b/contracts/on-chain-nft/io/src/lib.rs @@ -53,7 +53,7 @@ pub enum OnChainNFTAction { /// Arguments: /// * `token_metadata` - is a default token metadata from gear-lib. /// * `description` - is the vector of layer's item id, where - /// the index i is the layer id. + /// the index i is the layer id. /// /// On success, returns NFTEvent::Mint from gear-lib. Mint { @@ -66,7 +66,7 @@ pub enum OnChainNFTAction { /// /// Requirements: /// * `token_id` MUST exist - /// Arguments: + /// Arguments: /// /// * `token_id` - is the id of the burnt token /// diff --git a/contracts/on-chain-nft/src/lib.rs b/contracts/on-chain-nft/src/lib.rs index aef36fedd..a4e80e3e3 100644 --- a/contracts/on-chain-nft/src/lib.rs +++ b/contracts/on-chain-nft/src/lib.rs @@ -162,8 +162,7 @@ impl OnChainNFTCore for OnChainNFT { .layers .get(&(layer_id as u128)) .expect("No such layer") - .iter() - .nth(*layer_item_id as usize) + .get(*layer_item_id as usize) .expect("No such layer item"); content.push(layer_content.clone()); } diff --git a/contracts/staking/tests/utils/common.rs b/contracts/staking/tests/utils/common.rs index 5cfe234a2..654a4a2a4 100644 --- a/contracts/staking/tests/utils/common.rs +++ b/contracts/staking/tests/utils/common.rs @@ -1,6 +1,6 @@ use convert::identity; -use gstd::{prelude::*, ActorId}; -use gtest::{Log, Program as InnerProgram, RunResult as InnerRunResult}; +use gstd::prelude::*; +use gtest::{Log, RunResult as InnerRunResult}; use marker::PhantomData; pub trait TransactionalProgram { diff --git a/contracts/staking/tests/utils/mod.rs b/contracts/staking/tests/utils/mod.rs index 47f183104..b64b89594 100644 --- a/contracts/staking/tests/utils/mod.rs +++ b/contracts/staking/tests/utils/mod.rs @@ -4,7 +4,5 @@ pub use ftoken::*; mod common; pub use common::*; -pub mod prelude; - pub const FOREIGN_USER: u64 = 12345678; pub const PROGRAMS: &[u64] = &[1, 2, 3]; diff --git a/contracts/staking/tests/utils/prelude.rs b/contracts/staking/tests/utils/prelude.rs deleted file mode 100644 index 9551b8ab4..000000000 --- a/contracts/staking/tests/utils/prelude.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub use gstd::prelude::*; -pub use staking_io::*; diff --git a/contracts/supply-chain/io/src/lib.rs b/contracts/supply-chain/io/src/lib.rs index b8a029523..421a9370d 100644 --- a/contracts/supply-chain/io/src/lib.rs +++ b/contracts/supply-chain/io/src/lib.rs @@ -96,7 +96,7 @@ pub type ItemId = TokenId; /// /// # Requirements /// - Each [`ActorId`] of `producers`, `distributors`, and `retailers` mustn't -/// equal [`ActorId::zero()`]. +/// equal [`ActorId::zero()`]. #[derive(Encode, Decode, Hash, TypeInfo, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Clone)] #[codec(crate = gstd::codec)] #[scale_info(crate = gstd::scale_info)] @@ -163,17 +163,17 @@ pub enum InnerAction { /// /// Important notes: /// - Only the last sent asynchronous action for -/// [`msg::source()`](gstd::msg::source) is cached. +/// [`msg::source()`](gstd::msg::source) is cached. /// - Non-asynchronous actions are never cached. /// - There's no guarantee every underprocessed asynchronous action will be -/// cached. Use -/// [`is_action_cached()`](../supply_chain_state/metafns/fn.is_action_cached.html) -/// to check if some action is cached for some [`ActorId`]. +/// cached. Use +/// [`is_action_cached()`](../supply_chain_state/metafns/fn.is_action_cached.html) +/// to check if some action is cached for some [`ActorId`]. /// - It's possible to send a retry action with a different payload, and it'll -/// continue with it because, for some action, not all payload is saved in the -/// cache (see [`CachedAction`]). +/// continue with it because, for some action, not all payload is saved in the +/// cache (see [`CachedAction`]). /// - The cache memory has a limit, so when it's reached every oldest cached -/// action is replaced with a new one. +/// action is replaced with a new one. #[derive( Default, Encode, Decode, TypeInfo, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, )] @@ -216,7 +216,7 @@ pub enum ProducerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the producer of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Produced`] & - /// [`Role::Producer`]. + /// [`Role::Producer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::ForSale`] & [`Role::Producer`]. @@ -238,7 +238,7 @@ pub enum ProducerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the producer of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Produced`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Approved`]/[`ItemEventState::ForSale`] & @@ -259,7 +259,7 @@ pub enum ProducerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the producer of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Approved`] & - /// [`Role::Producer`]. + /// [`Role::Producer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Shipped`] & [`Role::Producer`]. @@ -286,7 +286,7 @@ pub enum DistributorAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be a distributor. /// - Item's [`ItemState`] must contain [`ItemEventState::ForSale`] & - /// [`Role::Producer`]. + /// [`Role::Producer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Purchased`] & [`Role::Distributor`]. @@ -311,7 +311,7 @@ pub enum DistributorAction { /// - The item must exist in a supply chain. /// - [`msg::source()`] must be the distributor of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Shipped`] & - /// [`Role::Producer`]. + /// [`Role::Producer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Received`] & [`Role::Distributor`]. @@ -324,9 +324,9 @@ pub enum DistributorAction { /// # Requirements /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the distributor of the - /// item. + /// item. /// - Item's [`ItemState`] must contain [`ItemEventState::Received`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Processed`] & [`Role::Distributor`]. @@ -337,9 +337,9 @@ pub enum DistributorAction { /// # Requirements /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the distributor of the - /// item. + /// item. /// - Item's [`ItemState`] must contain [`ItemEventState::Processed`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Packaged`] & [`Role::Distributor`]. @@ -354,9 +354,9 @@ pub enum DistributorAction { /// # Requirements /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the distributor of the - /// item. + /// item. /// - Item's [`ItemState`] must contain [`ItemEventState::Packaged`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::ForSale`] & [`Role::Distributor`]. @@ -377,9 +377,9 @@ pub enum DistributorAction { /// # Requirements /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the distributor of the - /// item. + /// item. /// - Item's [`ItemState`] must contain [`ItemEventState::Purchased`] & - /// [`Role::Retailer`]. + /// [`Role::Retailer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Approved`]/[`ItemEventState::ForSale`] & @@ -399,9 +399,9 @@ pub enum DistributorAction { /// # Requirements /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the distributor of the - /// item. + /// item. /// - Item's [`ItemState`] must contain [`ItemEventState::Approved`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Shipped`] & [`Role::Distributor`]. @@ -428,7 +428,7 @@ pub enum RetailerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be a retailer. /// - Item's [`ItemState`] must contain [`ItemEventState::ForSale`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Purchased`] & [`Role::Retailer`]. @@ -454,7 +454,7 @@ pub enum RetailerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`] must be the retailer of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Shipped`] & - /// [`Role::Distributor`]. + /// [`Role::Distributor`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Received`] & [`Role::Retailer`]. @@ -472,7 +472,7 @@ pub enum RetailerAction { /// - The item must exist in a supply chain. /// - [`msg::source()`](gstd::msg::source) must be the retailer of the item. /// - Item's [`ItemState`] must contain [`ItemEventState::Received`] & - /// [`Role::Retailer`]. + /// [`Role::Retailer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::ForSale`] & [`Role::Retailer`]. @@ -496,7 +496,7 @@ pub enum ConsumerAction { /// # Requirements /// - The item must exist in a supply chain. /// - Item's [`ItemState`] must contain [`ItemEventState::ForSale`] & - /// [`Role::Retailer`]. + /// [`Role::Retailer`]. /// /// On success, replies with [`Event`] where [`ItemState`] contains /// [`ItemEventState::Purchased`] & [`Role::Consumer`]. diff --git a/contracts/syndote/src/strategic_actions.rs b/contracts/syndote/src/strategic_actions.rs index ce3068e4d..92c2b324a 100644 --- a/contracts/syndote/src/strategic_actions.rs +++ b/contracts/syndote/src/strategic_actions.rs @@ -292,11 +292,9 @@ impl Game { return; } - let rent = if let Some((_, _, _, rent)) = self.properties[position as usize] { - rent - } else { - 0 - }; + let (_, _, _, rent) = self.properties[position as usize] + .clone() + .unwrap_or_default(); if rent == 0 { // debug!("PENALTY: CELL WITH NO PROPERTIES"); player_info.penalty += 1; diff --git a/contracts/varatube/tests/utils.rs b/contracts/varatube/tests/utils.rs index f5ca81004..4874724bc 100644 --- a/contracts/varatube/tests/utils.rs +++ b/contracts/varatube/tests/utils.rs @@ -62,15 +62,11 @@ impl FTokenTestFuncs for Program<'_> { fn check_balance(&self, account: u64, expected_amount: u128) { let state: IoFungibleToken = self.read_state(false).expect("Unable to read token state"); - let balance = if let Some((_, balance)) = state + let (_, balance) = state .balances .into_iter() .find(|(id, _balance)| *id == account.into()) - { - balance - } else { - 0 - }; + .unwrap_or_default(); assert_eq!(balance, expected_amount, "Error in balances"); }