Fix warnings when compiling runtime. (#4332)

* Remove warnings when compiling runtime.

* Remove dispatch::Result imports.

* Add missing imports.

* Fix missing vecs. #4333

* Fix oom function.

* Remove superfluous import.

* More warnings.
This commit is contained in:
Tomasz Drwięga
2019-12-10 14:21:34 +01:00
committed by Bastian Köcher
parent 057e298b1f
commit 1f84d6d41d
25 changed files with 104 additions and 87 deletions
+26 -17
View File
@@ -115,15 +115,15 @@
//!
//! ```
//! use support::{
//! dispatch,
//! traits::{Currency, ExistenceRequirement, WithdrawReason},
//! dispatch::Result,
//! };
//! # pub trait Trait: system::Trait {
//! # type Currency: Currency<Self::AccountId>;
//! # }
//! type AssetOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
//!
//! fn charge_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> Result {
//! fn charge_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> dispatch::Result {
//! // ...
//! T::Currency::withdraw(
//! transactor,
@@ -135,7 +135,7 @@
//! Ok(())
//! }
//!
//! fn refund_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> Result {
//! fn refund_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> dispatch::Result {
//! // ...
//! T::Currency::deposit_into_existing(transactor, amount)?;
//! // ...
@@ -161,9 +161,8 @@ use sp_runtime::traits::{
use sp_std::prelude::*;
use sp_std::{cmp, result, fmt::Debug};
use support::dispatch::Result;
use support::{
decl_event, decl_module, decl_storage, ensure,
decl_event, decl_module, decl_storage, ensure, dispatch,
traits::{
Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, ReservableCurrency,
SignedImbalance, UpdateBalanceOutcome, WithdrawReason, WithdrawReasons, TryDrop,
@@ -326,7 +325,7 @@ decl_module! {
fn deposit_event() = default;
/// Create a new kind of asset.
fn create(origin, options: AssetOptions<T::Balance, T::AccountId>) -> Result {
fn create(origin, options: AssetOptions<T::Balance, T::AccountId>) -> dispatch::Result {
let origin = ensure_signed(origin)?;
let id = Self::next_asset_id();
@@ -359,7 +358,7 @@ decl_module! {
origin,
#[compact] asset_id: T::AssetId,
new_permission: PermissionLatest<T::AccountId>
) -> Result {
) -> dispatch::Result {
let origin = ensure_signed(origin)?;
let permissions: PermissionVersions<T::AccountId> = new_permission.into();
@@ -377,7 +376,9 @@ decl_module! {
/// Mints an asset, increases its total issuance.
/// The origin must have `mint` permissions.
fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> Result {
fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance)
-> dispatch::Result
{
let origin = ensure_signed(origin)?;
if Self::check_permission(&asset_id, &origin, &PermissionType::Mint) {
let original_free_balance = Self::free_balance(&asset_id, &to);
@@ -401,7 +402,9 @@ decl_module! {
/// Burns an asset, decreases its total issuance.
///
/// The `origin` must have `burn` permissions.
fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> Result {
fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance)
-> dispatch::Result
{
let origin = ensure_signed(origin)?;
if Self::check_permission(&asset_id, &origin, &PermissionType::Burn) {
@@ -427,7 +430,11 @@ decl_module! {
/// Can be used to create reserved tokens.
/// Requires Root call.
fn create_reserved(origin, asset_id: T::AssetId, options: AssetOptions<T::Balance, T::AccountId>) -> Result {
fn create_reserved(
origin,
asset_id: T::AssetId,
options: AssetOptions<T::Balance, T::AccountId>
) -> dispatch::Result {
ensure_root(origin)?;
Self::create_asset(Some(asset_id), None, options)
}
@@ -536,7 +543,7 @@ impl<T: Trait> Module<T> {
asset_id: Option<T::AssetId>,
from_account: Option<T::AccountId>,
options: AssetOptions<T::Balance, T::AccountId>,
) -> Result {
) -> dispatch::Result {
let asset_id = if let Some(asset_id) = asset_id {
ensure!(!<TotalIssuance<T>>::exists(&asset_id), "Asset id already taken.");
ensure!(asset_id < Self::next_asset_id(), "Asset id not available.");
@@ -569,7 +576,7 @@ impl<T: Trait> Module<T> {
from: &T::AccountId,
to: &T::AccountId,
amount: T::Balance
) -> Result {
) -> dispatch::Result {
let new_balance = Self::free_balance(asset_id, from)
.checked_sub(&amount)
.ok_or_else(|| "balance too low to send amount")?;
@@ -590,7 +597,7 @@ impl<T: Trait> Module<T> {
from: &T::AccountId,
to: &T::AccountId,
amount: T::Balance,
) -> Result {
) -> dispatch::Result {
Self::make_transfer(asset_id, from, to, amount)?;
if from != to {
@@ -604,7 +611,9 @@ impl<T: Trait> Module<T> {
///
/// If the free balance is lower than `amount`, then no funds will be moved and an `Err` will
/// be returned. This is different behavior than `unreserve`.
pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) -> Result {
pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance)
-> dispatch::Result
{
// Do we need to consider that this is an atomic transaction?
let original_reserve_balance = Self::reserved_balance(asset_id, who);
let original_free_balance = Self::free_balance(asset_id, who);
@@ -742,7 +751,7 @@ impl<T: Trait> Module<T> {
_amount: T::Balance,
reasons: WithdrawReasons,
new_balance: T::Balance,
) -> Result {
) -> dispatch::Result {
if asset_id != &Self::staking_asset_id() {
return Ok(());
}
@@ -1124,7 +1133,7 @@ where
dest: &T::AccountId,
value: Self::Balance,
_: ExistenceRequirement, // no existential deposit policy for generic asset
) -> Result {
) -> dispatch::Result {
<Module<T>>::make_transfer(&U::asset_id(), transactor, dest, value)
}
@@ -1133,7 +1142,7 @@ where
amount: Self::Balance,
reasons: WithdrawReasons,
new_balance: Self::Balance,
) -> Result {
) -> dispatch::Result {
<Module<T>>::ensure_can_withdraw(&U::asset_id(), who, amount, reasons, new_balance)
}