Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "framenode"
version = "3.0.1"
version = "3.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion node/chain_spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "framenode-chain-spec"
version = "3.0.1"
version = "3.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

Expand Down
11 changes: 5 additions & 6 deletions pallets/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ fn bob<T: Config>() -> T::AccountId {
fn add_assets<T: Config>(n: u32) -> Result<(), &'static str> {
let owner = alice::<T>();
frame_system::Pallet::<T>::inc_providers(&owner);
let owner_origin: <T as frame_system::Config>::RuntimeOrigin =
RawOrigin::Signed(owner.clone()).into();
let owner_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(owner).into();
for _i in 0..n {
Assets::<T>::register(
owner_origin.clone(),
Expand Down Expand Up @@ -174,7 +173,7 @@ benchmarks! {
}: _(
RawOrigin::Root,
USDT.into(),
caller.clone(),
caller,
100_u32.into()
)
verify {
Expand Down Expand Up @@ -229,9 +228,9 @@ benchmarks! {
).unwrap();
}: _(
RawOrigin::Root,
caller.clone(),
caller,
USDT.into(),
100_i128.into()
100_i128
)
verify {
let usdt_issuance = Assets::<T>::total_issuance(&USDT.into())?;
Expand Down Expand Up @@ -266,7 +265,7 @@ benchmarks! {
let caller = alice::<T>();
frame_system::Pallet::<T>::inc_providers(&caller);
Assets::<T>::register_asset_id(
caller.clone(),
caller,
USDT.into(),
AssetSymbol(b"USDT".to_vec()),
AssetName(b"USDT".to_vec()),
Expand Down
45 changes: 22 additions & 23 deletions pallets/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
//! - `register` - registers new asset by a given ID.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO #167: fix clippy warnings
#![allow(clippy::all)]

#[allow(unused_imports)]
#[macro_use]
extern crate alloc;

pub mod weights;

Expand Down Expand Up @@ -179,6 +173,7 @@ impl<T: Config> GetTotalBalance<T> for () {
pub use pallet::*;

#[frame_support::pallet]
#[allow(clippy::too_many_arguments)]
pub mod pallet {
use super::*;
use common::{ContentSource, Description};
Expand Down Expand Up @@ -354,7 +349,7 @@ pub mod pallet {
let issuer = ensure_signed(origin.clone())?;

Self::mint_to(&asset_id, &issuer, &to, amount)?;
Self::deposit_event(Event::Mint(issuer, to, asset_id.clone(), amount));
Self::deposit_event(Event::Mint(issuer, to, asset_id, amount));
Ok(().into())
}

Expand Down Expand Up @@ -412,7 +407,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let issuer = ensure_signed(origin.clone())?;
Self::burn_from(&asset_id, &issuer, &issuer, amount)?;
Self::deposit_event(Event::Burn(issuer, asset_id.clone(), amount));
Self::deposit_event(Event::Burn(issuer, asset_id, amount));
Ok(().into())
}

Expand Down Expand Up @@ -448,7 +443,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin.clone())?;
Self::set_non_mintable_from(&asset_id, &who)?;
Self::deposit_event(Event::AssetSetNonMintable(asset_id.clone()));
Self::deposit_event(Event::AssetSetNonMintable(asset_id));
Ok(().into())
}

Expand All @@ -468,7 +463,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
Self::ensure_asset_exists(&asset_id)?;
AssetInfos::<T>::mutate(&asset_id, |(ref mut symbol, ref mut name, ..)| {
AssetInfos::<T>::mutate(asset_id, |(ref mut symbol, ref mut name, ..)| {
if let Some(new_name) = new_name.clone() {
ensure!(new_name.is_valid(), Error::<T>::InvalidAssetName);
*name = new_name;
Expand Down Expand Up @@ -561,6 +556,7 @@ pub mod pallet {
pub type AssetRecordAssetId<T: Config> =
StorageMap<_, Twox64Concat, T::AssetId, AssetRecord<T>>;

#[allow(clippy::type_complexity)]
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub endowed_assets: Vec<(
Expand Down Expand Up @@ -650,7 +646,7 @@ impl<T: Config> Pallet<T> {
let mut keccak = Keccak::v256();
keccak.update(b"Sora Asset Id");
keccak.update(&account_id.encode());
keccak.update(&frame_system::Pallet::<T>::account_nonce(&account_id).encode());
keccak.update(&frame_system::Pallet::<T>::account_nonce(account_id).encode());
let mut output = [0u8; 32];
keccak.finalize(&mut output);
// More safe to escape.
Expand All @@ -659,6 +655,7 @@ impl<T: Config> Pallet<T> {
}

/// Register the given `AssetId`.
#[allow(clippy::too_many_arguments)]
pub fn register_asset_id(
account_id: T::AccountId,
asset_id: T::AssetId,
Expand Down Expand Up @@ -716,7 +713,7 @@ impl<T: Config> Pallet<T> {
}

if !initial_supply.is_zero() {
T::Currency::deposit(asset_id.clone(), &account_id, initial_supply)?;
T::Currency::deposit(asset_id, &account_id, initial_supply)?;
}

frame_system::Pallet::<T>::inc_account_nonce(&account_id);
Expand All @@ -725,6 +722,7 @@ impl<T: Config> Pallet<T> {
}

/// Generates new `AssetId` and registers it from the `account_id`.
#[allow(clippy::too_many_arguments)]
pub fn register_from(
account_id: &T::AccountId,
symbol: AssetSymbol,
Expand Down Expand Up @@ -785,7 +783,7 @@ impl<T: Config> Pallet<T> {
to: &T::AccountId,
amount: Balance,
) -> DispatchResult {
let r = T::Currency::transfer(asset_id.clone(), from, to, amount);
let r = T::Currency::transfer(*asset_id, from, to, amount);
if r.is_err() {
Self::ensure_asset_exists(asset_id)?;
}
Expand All @@ -812,7 +810,7 @@ impl<T: Config> Pallet<T> {
to: &T::AccountId,
amount: Balance,
) -> DispatchResult {
T::Currency::deposit(asset_id.clone(), to, amount)
T::Currency::deposit(*asset_id, to, amount)
}

pub fn burn_from(
Expand All @@ -836,7 +834,7 @@ impl<T: Config> Pallet<T> {
) -> DispatchResult {
let r = T::Currency::withdraw(*asset_id, from, amount);
if r.is_err() {
Self::ensure_asset_exists(&asset_id)?;
Self::ensure_asset_exists(asset_id)?;
}
r
}
Expand All @@ -846,7 +844,7 @@ impl<T: Config> Pallet<T> {
let technical_account = T::GetBuyBackAccountId::get();
let buy_back_asset_id = T::GetBuyBackAssetId::get();

Self::mint_unchecked(&asset_id, &technical_account, amount)?;
Self::mint_unchecked(asset_id, &technical_account, amount)?;
let outcome = T::BuyBackLiquidityProxy::exchange(
dex_id,
&technical_account,
Expand Down Expand Up @@ -874,7 +872,7 @@ impl<T: Config> Pallet<T> {
if by_amount.is_positive() {
Self::ensure_asset_is_mintable(asset_id)?;
}
T::Currency::update_balance(asset_id.clone(), who, by_amount)
T::Currency::update_balance(*asset_id, who, by_amount)
}

pub fn can_reserve(asset_id: T::AssetId, who: &T::AccountId, amount: Balance) -> bool {
Expand All @@ -884,7 +882,7 @@ impl<T: Config> Pallet<T> {
pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: Balance) -> DispatchResult {
let r = T::Currency::reserve(*asset_id, who, amount);
if r.is_err() {
Self::ensure_asset_exists(&asset_id)?;
Self::ensure_asset_exists(asset_id)?;
}
r
}
Expand All @@ -896,7 +894,7 @@ impl<T: Config> Pallet<T> {
) -> Result<Balance, DispatchError> {
let amount = T::Currency::unreserve(*asset_id, who, amount);
if amount != Default::default() {
Self::ensure_asset_exists(&asset_id)?;
Self::ensure_asset_exists(asset_id)?;
}
Ok(amount)
}
Expand All @@ -917,6 +915,7 @@ impl<T: Config> Pallet<T> {
AssetInfos::<T>::iter().map(|(key, _)| key).collect()
}

#[allow(clippy::type_complexity)]
pub fn list_registered_asset_infos() -> Vec<(
T::AssetId,
AssetSymbol,
Expand Down Expand Up @@ -1010,23 +1009,23 @@ impl<T: Config>
}

fn total_issuance(asset_id: &T::AssetId) -> Result<Balance, DispatchError> {
let r = T::Currency::total_issuance(asset_id.clone());
let r = T::Currency::total_issuance(*asset_id);
if r == Default::default() {
Self::ensure_asset_exists(asset_id)?;
}
Ok(r)
}

fn total_balance(asset_id: &T::AssetId, who: &T::AccountId) -> Result<Balance, DispatchError> {
let r = T::Currency::total_balance(asset_id.clone(), who);
let r = T::Currency::total_balance(*asset_id, who);
if r == Default::default() {
Self::ensure_asset_exists(asset_id)?;
}
Ok(r + T::GetTotalBalance::total_balance(asset_id, who)?)
}

fn free_balance(asset_id: &T::AssetId, who: &T::AccountId) -> Result<Balance, DispatchError> {
let r = T::Currency::free_balance(asset_id.clone(), who);
let r = T::Currency::free_balance(*asset_id, who);
if r == Default::default() {
Self::ensure_asset_exists(asset_id)?;
}
Expand All @@ -1038,7 +1037,7 @@ impl<T: Config>
who: &T::AccountId,
amount: Balance,
) -> DispatchResult {
let r = T::Currency::ensure_can_withdraw(asset_id.clone(), who, amount);
let r = T::Currency::ensure_can_withdraw(*asset_id, who, amount);
if r.is_err() {
Self::ensure_asset_exists(asset_id)?;
}
Expand Down
1 change: 0 additions & 1 deletion pallets/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use currencies::BasicCurrencyAdapter;
use frame_support::traits::{Everything, GenesisBuild};
use frame_support::weights::Weight;
use frame_support::{construct_runtime, parameter_types};
use frame_system;
use sp_core::H256;
use sp_runtime::testing::Header;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
Expand Down
Loading