diff --git a/Cargo.lock b/Cargo.lock index 00b5c982c..ed5bdc6d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1756,11 +1756,11 @@ dependencies = [ [[package]] name = "ethabi" -version = "17.2.0" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4966fba78396ff92db3b817ee71143eccd98acf0f876b8d600e585a670c5d1b" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" dependencies = [ - "ethereum-types 0.13.1", + "ethereum-types 0.14.1", "hex", "once_cell", "regex", @@ -1781,7 +1781,6 @@ dependencies = [ "fixed-hash 0.7.0", "impl-codec", "impl-rlp", - "impl-serde 0.3.2", "scale-info", "tiny-keccak", ] @@ -1848,7 +1847,6 @@ dependencies = [ "fixed-hash 0.7.0", "impl-codec", "impl-rlp", - "impl-serde 0.3.2", "primitive-types 0.11.1", "scale-info", "uint", @@ -5543,7 +5541,7 @@ name = "pallet-ethy" version = "1.0.1" dependencies = [ "ethabi", - "ethereum-types 0.13.1", + "ethereum-types 0.14.1", "frame-support", "frame-system", "hex", @@ -5670,7 +5668,7 @@ dependencies = [ name = "pallet-evm-precompiles-erc1155" version = "2.0.0" dependencies = [ - "ethereum-types 0.13.1", + "ethereum-types 0.14.1", "fp-evm", "frame-support", "frame-system", @@ -9087,7 +9085,7 @@ version = "0.1.0" dependencies = [ "doughnut-rs", "ethabi", - "ethereum 0.12.0", + "ethereum 0.14.0", "evm 0.36.0", "fp-evm", "fp-rpc", @@ -12029,7 +12027,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] diff --git a/ethy-gadget/Cargo.toml b/ethy-gadget/Cargo.toml index b5251afb2..5139df87e 100644 --- a/ethy-gadget/Cargo.toml +++ b/ethy-gadget/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" license = "Apache-2.0" [dependencies] -ethabi = { version = "17.1.0" } +ethabi = { version = "18.0.0" } futures = "0.3.25" futures-timer = "3.0.1" hex = "0.4" diff --git a/evm-precompiles/erc1155/Cargo.toml b/evm-precompiles/erc1155/Cargo.toml index 42708a877..0817d0dd3 100644 --- a/evm-precompiles/erc1155/Cargo.toml +++ b/evm-precompiles/erc1155/Cargo.toml @@ -16,7 +16,7 @@ codec = { version = "3.0.0", package = "parity-scale-codec", default-features = num_enum = { version = "0.5.3", default-features = false } precompile-utils = { path = "../utils", default-features = false } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } -ethereum-types = { version = "0.13.1", default-features = false, features = ["serialize", "codec"] } +ethereum-types = { version = "0.14.1", default-features = false } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } diff --git a/pallet/assets-ext/src/impls.rs b/pallet/assets-ext/src/impls.rs index 3a035b793..e67d8e3b7 100644 --- a/pallet/assets-ext/src/impls.rs +++ b/pallet/assets-ext/src/impls.rs @@ -23,8 +23,10 @@ use sp_std::marker::PhantomData; use frame_support::traits::{ fungible, - fungibles::{self, Inspect, Transfer, Unbalanced}, - tokens::{DepositConsequence, WithdrawConsequence}, + fungibles::{self, Inspect, Mutate, Unbalanced}, + tokens::{ + DepositConsequence, Fortitude, Precision, Preservation, Provenance, WithdrawConsequence, + }, }; use seed_primitives::{AssetId, Balance}; @@ -48,24 +50,41 @@ where >::total_issuance(U::get()) } + fn active_issuance() -> Self::Balance { + >::active_issuance(U::get()) + } + fn minimum_balance() -> Balance { >::minimum_balance(U::get()) } + fn total_balance(who: &T::AccountId) -> Self::Balance { + >::total_balance(U::get(), who) + } + fn balance(who: &T::AccountId) -> Balance { >::balance(U::get(), who) } - fn reducible_balance(who: &T::AccountId, keep_alive: bool) -> Balance { + fn reducible_balance( + who: &T::AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Balance { as fungibles::Inspect<_>>::reducible_balance( U::get(), who, - keep_alive, + preservation, + force, ) } - fn can_deposit(who: &T::AccountId, amount: Balance, mint: bool) -> DepositConsequence { - >::can_deposit(U::get(), who, amount, mint) + fn can_deposit( + who: &T::AccountId, + amount: Balance, + provenance: Provenance, + ) -> DepositConsequence { + >::can_deposit(U::get(), who, amount, provenance) } fn can_withdraw(who: &T::AccountId, amount: Balance) -> WithdrawConsequence { @@ -83,7 +102,12 @@ where type PositiveImbalance = imbalances::PositiveImbalance; fn free_balance(who: &T::AccountId) -> Self::Balance { - >::reducible_balance(U::get(), who, false) + >::reducible_balance( + U::get(), + who, + Preservation::Expendable, + Fortitude::Polite, + ) } fn total_issuance() -> Self::Balance { >::total_issuance(U::get()) @@ -101,11 +125,11 @@ where req: ExistenceRequirement, ) -> DispatchResult { // used by evm - let keep_alive = match req { - ExistenceRequirement::KeepAlive => true, - ExistenceRequirement::AllowDeath => false, + let preservation = match req { + ExistenceRequirement::KeepAlive => Preservation::Preserve, + ExistenceRequirement::AllowDeath => Preservation::Expendable, }; - as Transfer>::transfer(U::get(), from, to, value, keep_alive) + as Mutate>::transfer(U::get(), from, to, value, preservation) .map(|_| ()) } fn ensure_can_withdraw( @@ -128,10 +152,21 @@ where who: &T::AccountId, value: Self::Balance, _reasons: WithdrawReasons, - _req: ExistenceRequirement, + req: ExistenceRequirement, ) -> Result { + let preservation = match req { + ExistenceRequirement::KeepAlive => Preservation::Preserve, + ExistenceRequirement::AllowDeath => Preservation::Expendable, + }; // used by pallet-transaction payment & pallet-evm - >::decrease_balance(U::get(), who, value)?; + >::decrease_balance( + U::get(), + who, + value, + Precision::Exact, + preservation, + Fortitude::Polite, + )?; >::deposit_event(Event::InternalWithdraw { asset_id: U::get(), @@ -151,7 +186,7 @@ where if value.is_zero() { return Ok(PositiveImbalance::new(0, U::get())) } - >::increase_balance(U::get(), who, value)?; + >::increase_balance(U::get(), who, value, Precision::Exact)?; >::deposit_event(Event::InternalDeposit { asset_id: U::get(), who: who.clone(), diff --git a/pallet/assets-ext/src/lib.rs b/pallet/assets-ext/src/lib.rs index 3e440da10..a984c3661 100644 --- a/pallet/assets-ext/src/lib.rs +++ b/pallet/assets-ext/src/lib.rs @@ -33,8 +33,10 @@ use frame_support::{ pallet_prelude::*, traits::{ fungible::{self, Inspect as _, Mutate as _}, - fungibles::{self, roles::Inspect as InspectRole, Inspect, Mutate, Transfer}, - tokens::{DepositConsequence, WithdrawConsequence}, + fungibles::{self, roles::Inspect as InspectRole, Dust, Inspect, Mutate, Unbalanced}, + tokens::{ + DepositConsequence, Fortitude, Precision, Preservation, Provenance, WithdrawConsequence, + }, Currency, ReservableCurrency, }, transactional, PalletId, @@ -90,7 +92,6 @@ pub mod pallet { _phantom: sp_std::marker::PhantomData, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { _phantom: Default::default() } @@ -98,7 +99,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { NextAssetId::::put(1_u32); } @@ -137,7 +138,7 @@ pub mod pallet { AssetId, Blake2_128Concat, T::AccountId, - BoundedVec<(PalletIdValue, Balance), T::MaxHolds>, + BoundedVec<(PalletIdValue, Balance), ::MaxHolds>, ValueQuery, >; @@ -264,7 +265,7 @@ pub mod pallet { // We do not allow minting of the ROOT token Err(Error::::NoPermission)?; } else { - >::mint(origin, asset_id, beneficiary, amount)?; + >::mint(origin, asset_id.into(), beneficiary, amount)?; } Ok(()) } @@ -280,12 +281,16 @@ pub mod pallet { keep_alive: bool, ) -> DispatchResult { let who = ensure_signed(origin)?; - >::transfer( + let preservation = match keep_alive { + true => Preservation::Preserve, + false => Preservation::Expendable, + }; + >::transfer( asset_id, &who, &destination, amount, - keep_alive, + preservation, )?; Ok(()) } @@ -304,7 +309,7 @@ pub mod pallet { // We do not allow burning of the ROOT token Err(Error::::NoPermission)?; } else { - >::burn(origin, asset_id, who, amount)?; + >::burn(origin, asset_id.into(), who, amount)?; } Ok(()) } @@ -361,6 +366,14 @@ impl Inspect for Pallet { } } + fn total_balance(asset_id: Self::AssetId, who: &T::AccountId) -> Self::Balance { + if asset_id == T::NativeAssetId::get() { + as fungible::Inspect<_>>::total_balance(who) + } else { + >::total_balance(asset_id, who) + } + } + fn balance(asset_id: AssetId, who: &T::AccountId) -> Balance { if asset_id == T::NativeAssetId::get() { >::balance(who) @@ -369,14 +382,24 @@ impl Inspect for Pallet { } } - fn reducible_balance(asset_id: AssetId, who: &T::AccountId, keep_alive: bool) -> Balance { + fn reducible_balance( + asset_id: AssetId, + who: &T::AccountId, + preservation: Preservation, + force: Fortitude, + ) -> Balance { if asset_id == T::NativeAssetId::get() { as fungible::Inspect<_>>::reducible_balance( - who, keep_alive, + who, + preservation, + force, ) } else { as fungibles::Inspect<_>>::reducible_balance( - asset_id, who, keep_alive, + asset_id, + who, + preservation, + force, ) } } @@ -385,12 +408,12 @@ impl Inspect for Pallet { asset_id: AssetId, who: &T::AccountId, amount: Balance, - mint: bool, + provenance: Provenance, ) -> DepositConsequence { if asset_id == T::NativeAssetId::get() { - >::can_deposit(who, amount, mint) + >::can_deposit(who, amount, provenance) } else { - >::can_deposit(asset_id, who, amount, mint) + >::can_deposit(asset_id, who, amount, provenance) } } @@ -405,10 +428,41 @@ impl Inspect for Pallet { >::can_withdraw(asset_id, who, amount) } } + + fn asset_exists(asset: Self::AssetId) -> bool { + if asset == T::NativeAssetId::get() { + // native token always exists + true + } else { + >::asset_exists(asset) + } + } +} + +impl Unbalanced for Pallet { + fn handle_dust(dust: Dust) { + >::handle_dust(Dust(dust.0, dust.1)) + } + + fn write_balance( + asset: Self::AssetId, + who: &T::AccountId, + amount: Self::Balance, + ) -> Result, DispatchError> { + >::write_balance(asset, who, amount) + } + + fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance) { + >::set_total_issuance(asset, amount) + } } impl Mutate for Pallet { - fn mint_into(asset_id: AssetId, who: &T::AccountId, amount: Balance) -> DispatchResult { + fn mint_into( + asset_id: AssetId, + who: &T::AccountId, + amount: Balance, + ) -> Result { if asset_id == T::NativeAssetId::get() { >::mint_into(who, amount) } else { @@ -420,33 +474,42 @@ impl Mutate for Pallet { asset_id: AssetId, who: &T::AccountId, amount: Balance, + precision: Precision, + force: Fortitude, ) -> Result { if asset_id == T::NativeAssetId::get() { - >::burn_from(who, amount) + >::burn_from(who, amount, precision, force) } else { - >::burn_from(asset_id, who, amount) + >::burn_from(asset_id, who, amount, precision, force) } } -} -impl Transfer for Pallet { fn transfer( asset_id: AssetId, source: &T::AccountId, dest: &T::AccountId, amount: Balance, - keep_alive: bool, + preservation: Preservation, ) -> Result { if asset_id == T::NativeAssetId::get() { - as fungible::Transfer<_>>::transfer( - source, dest, amount, keep_alive, + as fungible::Mutate<_>>::transfer( + source, + dest, + amount, + preservation, ) } else { - as fungibles::Transfer>::transfer( - asset_id, source, dest, amount, keep_alive, + as fungibles::Mutate>::transfer( + asset_id, + source, + dest, + amount, + preservation, ) } } + + // TODO - implement callback functions? } impl TransferExt for Pallet { @@ -459,10 +522,20 @@ impl TransferExt for Pallet { ) -> DispatchResult { let total = transfers.iter().map(|x| x.1).sum::(); // This check will fail before making any transfers to restrict partial transfers - ensure!(Self::reducible_balance(asset_id, who, false) >= total, Error::::BalanceLow); + ensure!( + Self::reducible_balance(asset_id, who, Preservation::Expendable, Fortitude::Polite) >= + total, + Error::::BalanceLow + ); for (payee, amount) in transfers.into_iter() { - >::transfer(asset_id, who, payee, *amount, false)?; + >::transfer( + asset_id, + who, + payee, + *amount, + Preservation::Expendable, + )?; } Self::deposit_event(Event::SplitTransfer { @@ -502,12 +575,12 @@ impl Hold for Pallet { }, } - let _ = >::transfer( + let _ = >::transfer( asset_id, who, &T::PalletId::get().into_account_truncating(), amount, - false, + Preservation::Expendable, )?; Holds::::insert(asset_id, who.clone(), holds); @@ -538,12 +611,12 @@ impl Hold for Pallet { holds[index].1 = decreased_hold; } - let _ = >::transfer( + let _ = >::transfer( asset_id, &T::PalletId::get().into_account_truncating(), who, amount, - false, + Preservation::Expendable, ) .map(|_| ())?; @@ -664,7 +737,7 @@ impl CreateExt for Pallet { // set metadata for new asset - as root origin >::force_set_metadata( frame_system::RawOrigin::Root.into(), - new_asset_id, + new_asset_id.into(), name, symbol, decimals, @@ -674,16 +747,16 @@ impl CreateExt for Pallet { } } -impl fungibles::InspectMetadata for Pallet { - fn name(asset: &Self::AssetId) -> Vec { - as fungibles::InspectMetadata>::name(asset) +impl fungibles::metadata::Inspect for Pallet { + fn name(asset: Self::AssetId) -> Vec { + as fungibles::metadata::Inspect>::name(asset) } - fn symbol(asset: &Self::AssetId) -> Vec { - as fungibles::InspectMetadata>::symbol(asset) + fn symbol(asset: Self::AssetId) -> Vec { + as fungibles::metadata::Inspect>::symbol(asset) } - fn decimals(asset: &Self::AssetId) -> u8 { - as fungibles::InspectMetadata>::decimals(asset) + fn decimals(asset: Self::AssetId) -> u8 { + as fungibles::metadata::Inspect>::decimals(asset) } -} \ No newline at end of file +} diff --git a/pallet/assets-ext/src/mock.rs b/pallet/assets-ext/src/mock.rs index a06652376..e0dd712b7 100644 --- a/pallet/assets-ext/src/mock.rs +++ b/pallet/assets-ext/src/mock.rs @@ -15,10 +15,10 @@ //! A mock runtime for integration testing common runtime functionality use crate::{self as pallet_assets_ext}; -use frame_support::traits::FindAuthor; +use frame_support::{pallet_prelude::BuildGenesisConfig, traits::FindAuthor}; use pallet_evm::{AddressMapping, BlockHashMapping, EnsureAddressNever, GasWeightMapping}; use seed_pallet_common::test_prelude::*; -use sp_runtime::ConsensusEngineId; +use sp_runtime::{BuildStorage, ConsensusEngineId}; use std::marker::PhantomData; construct_runtime!( @@ -100,7 +100,7 @@ impl TestExt { self } pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); if !self.assets.is_empty() { let mut metadata = Vec::with_capacity(self.assets.len()); diff --git a/pallet/assets-ext/src/tests.rs b/pallet/assets-ext/src/tests.rs index 9820bfeb6..9698bca22 100644 --- a/pallet/assets-ext/src/tests.rs +++ b/pallet/assets-ext/src/tests.rs @@ -17,7 +17,13 @@ use crate::{ mock::{test_ext, AssetsExt, AssetsExtPalletId, Balances, NativeAssetId, System, Test}, AssetDeposit, Config, Error, Holds, NextAssetId, }; -use frame_support::traits::fungibles::{Inspect, InspectMetadata, Transfer}; +use frame_support::{ + macro_magic::__private::syn::token::For, + traits::{ + fungibles::{metadata::Inspect as InspectMetadata, Inspect, Mutate}, + tokens::{Fortitude, Preservation}, + }, +}; use seed_pallet_common::{test_prelude::*, CreateExt, Hold, TransferExt}; use sp_runtime::traits::{AccountIdConversion, Zero}; @@ -32,23 +38,23 @@ fn transfer() { .execute_with(|| { // native token transfer let alice_balance = AssetsExt::balance(NativeAssetId::get(), &alice()); - assert_ok!(>::transfer( + assert_ok!(>::transfer( NativeAssetId::get(), &alice(), &bob(), 100, - true + Preservation::Preserve )); assert_eq!(alice_balance - 100, AssetsExt::balance(NativeAssetId::get(), &alice()),); assert_eq!(100, AssetsExt::balance(NativeAssetId::get(), &bob()),); // XRP transfer - assert_ok!(>::transfer( + assert_ok!(>::transfer( XRP_ASSET_ID, &alice(), &bob(), 100, - true + Preservation::Preserve )); assert_eq!(alice_balance - 100, AssetsExt::balance(XRP_ASSET_ID, &alice()),); assert_eq!(100, AssetsExt::balance(XRP_ASSET_ID, &bob()),); @@ -82,7 +88,7 @@ fn transfer_extrinsic() { ); // XRP transfer - assert_ok!(AssetsExt::transfer(Some(alice()).into(), XRP_ASSET_ID, bob(), 100, false)); + assert_ok!(AssetsExt::transfer(Some(alice()).into(), XRP_ASSET_ID, bob(), 100, false,)); assert_eq!(alice_balance - 100, AssetsExt::balance(XRP_ASSET_ID, &alice()),); assert_eq!(100, AssetsExt::balance(XRP_ASSET_ID, &bob()),); @@ -108,13 +114,13 @@ fn transfer_extrinsic_low_balance() { .execute_with(|| { // native token transfer with insufficient balance assert_noop!( - AssetsExt::transfer(Some(alice()).into(), NativeAssetId::get(), bob(), 100, false), + AssetsExt::transfer(Some(alice()).into(), NativeAssetId::get(), bob(), 100, false,), pallet_balances::Error::::InsufficientBalance ); // XRP transfer with insufficient balance assert_noop!( - AssetsExt::transfer(Some(alice()).into(), XRP_ASSET_ID, bob(), 100, false), + AssetsExt::transfer(Some(alice()).into(), XRP_ASSET_ID, bob(), 100, false,), pallet_assets::Error::::BalanceLow ); }); @@ -224,7 +230,7 @@ fn mint_extrinsic() { pallet_assets::Event::::Issued { asset_id: XRP_ASSET_ID, owner: xrp_owner, - total_supply: 100, + amount: 100, } .into(), ); @@ -345,22 +351,22 @@ fn transfer_insufficient_funds() { .build() .execute_with(|| { assert_noop!( - >::transfer( + >::transfer( NativeAssetId::get(), &alice(), &bob(), initial_balance + 1, - true + Preservation::Preserve ), pallet_balances::Error::::InsufficientBalance ); assert_noop!( - >::transfer( + >::transfer( XRP_ASSET_ID, &alice(), &bob(), initial_balance + 1, - true + Preservation::Preserve ), pallet_assets::Error::::BalanceLow ); @@ -384,12 +390,12 @@ fn transfer_held_funds() { hold_amount )); assert_noop!( - >::transfer( + >::transfer( NativeAssetId::get(), &alice(), &bob(), hold_amount, - true + Preservation::Preserve ), pallet_balances::Error::::InsufficientBalance ); @@ -402,12 +408,12 @@ fn transfer_held_funds() { hold_amount )); assert_noop!( - >::transfer( + >::transfer( XRP_ASSET_ID, &alice(), &bob(), hold_amount, - true + Preservation::Preserve ), pallet_assets::Error::::BalanceLow ); @@ -571,7 +577,12 @@ fn release_hold_partial() { 5 )); assert_eq!( - AssetsExt::reducible_balance(NativeAssetId::get(), &alice(), false), + AssetsExt::reducible_balance( + NativeAssetId::get(), + &alice(), + Preservation::Expendable, + Fortitude::Polite, + ), initial_balance - hold_amount + 5 + 5, ); @@ -595,7 +606,12 @@ fn release_hold_partial() { 5 )); assert_eq!( - AssetsExt::reducible_balance(XRP_ASSET_ID, &alice(), false), + AssetsExt::reducible_balance( + XRP_ASSET_ID, + &alice(), + Preservation::Expendable, + Fortitude::Polite + ), initial_balance - hold_amount + 5 + 5, ); assert_eq!( @@ -1047,12 +1063,12 @@ fn place_hold_asset_does_not_exist() { fn transfer_asset_does_not_exist() { test_ext().build().execute_with(|| { assert_noop!( - >::transfer( + >::transfer( NativeAssetId::get() + 1, &alice(), &bob(), 100, - true, + Preservation::Preserve, ), pallet_assets::Error::::Unknown, ); @@ -1152,9 +1168,9 @@ fn create_asset() { )); assert_eq!(AssetsExt::minimum_balance(usdc), min_balance); assert_eq!(AssetsExt::total_issuance(usdc), 0); - assert_eq!(>::name(&usdc), name); - assert_eq!(>::symbol(&usdc), symbol); - assert_eq!(>::decimals(&usdc), decimals); + assert_eq!(>::name(usdc), name); + assert_eq!(>::symbol(usdc), symbol); + assert_eq!(>::decimals(usdc), decimals); // create Weth token and verify metadata let name: Vec = b"Wrapd-Eth".to_vec(); @@ -1171,9 +1187,9 @@ fn create_asset() { )); assert_eq!(AssetsExt::minimum_balance(weth), 1); // Defaults to 1 if None is set assert_eq!(AssetsExt::total_issuance(weth), 0); - assert_eq!(>::name(&weth), name); - assert_eq!(>::symbol(&weth), symbol); - assert_eq!(>::decimals(&weth), decimals); + assert_eq!(>::name(weth), name); + assert_eq!(>::symbol(weth), symbol); + assert_eq!(>::decimals(weth), decimals); }); } @@ -1286,7 +1302,12 @@ fn set_asset_deposit_reserves_the_correct_amount() { )); // Alice balance should now be reduced by deposit amount - let alice_balance = AssetsExt::reducible_balance(NativeAssetId::get(), &alice(), false); + let alice_balance = AssetsExt::reducible_balance( + NativeAssetId::get(), + &alice(), + Preservation::Expendable, + Fortitude::Polite, + ); assert_eq!(alice_balance, initial_balance - deposit); // The deposit should be reserved diff --git a/pallet/common/src/lib.rs b/pallet/common/src/lib.rs index 388371a86..e20125f4e 100644 --- a/pallet/common/src/lib.rs +++ b/pallet/common/src/lib.rs @@ -22,7 +22,7 @@ pub use frame_support::log as logger; use frame_support::{ dispatch::{DispatchError, DispatchResult, GetCallMetadata}, sp_runtime::{traits::AccountIdConversion, Perbill}, - traits::{fungibles::Transfer, Get}, + traits::{fungibles::Mutate, Get}, weights::{constants::RocksDbWeight as DbWeight, Weight}, PalletId, }; @@ -55,7 +55,7 @@ macro_rules! log { } /// Extended transfer functionality for assets -pub trait TransferExt: Transfer { +pub trait TransferExt: Mutate { /// The ID type for an account in the system type AccountId; /// Perform a split transfer from `source` to many destinations diff --git a/pallet/crowdsale/src/lib.rs b/pallet/crowdsale/src/lib.rs index 1d7f69761..fd7ec1f55 100644 --- a/pallet/crowdsale/src/lib.rs +++ b/pallet/crowdsale/src/lib.rs @@ -789,4 +789,4 @@ pub mod pallet { Ok(()) } } -} \ No newline at end of file +} diff --git a/pallet/dex/src/lib.rs b/pallet/dex/src/lib.rs index 93d07bb09..0b765492f 100644 --- a/pallet/dex/src/lib.rs +++ b/pallet/dex/src/lib.rs @@ -24,7 +24,10 @@ pub use pallet::*; use alloc::string::ToString; use frame_support::{ pallet_prelude::*, - traits::fungibles::{self, Inspect, InspectMetadata, Mutate, Transfer}, + traits::{ + fungibles::{self, metadata::Inspect as MetadataInspect, Inspect, Mutate}, + tokens::{Fortitude, Precision, Preservation}, + }, transactional, PalletId, }; use frame_system::pallet_prelude::*; @@ -126,10 +129,9 @@ pub mod pallet { /// Currency implementation to deal with assets on DEX. type MultiCurrency: CreateExt - + fungibles::Transfer + fungibles::Inspect - + fungibles::InspectMetadata - + fungibles::Mutate; + + fungibles::metadata::Inspect + + fungibles::Mutate; } #[pallet::error] @@ -541,9 +543,9 @@ where fn create_lp_token(trading_pair: &TradingPair) -> Result { let symbol_a_truncated: Vec = - T::MultiCurrency::symbol(&trading_pair.0).into_iter().take(20).collect(); + T::MultiCurrency::symbol(trading_pair.0).into_iter().take(20).collect(); let symbol_b_truncated: Vec = - T::MultiCurrency::symbol(&trading_pair.1).into_iter().take(20).collect(); + T::MultiCurrency::symbol(trading_pair.1).into_iter().take(20).collect(); // name: b"LP " + symbol_a_truncated + b" " + symbol_b_truncated let mut lp_token_name = @@ -664,8 +666,20 @@ where }; let pool_address = trading_pair.pool_address(); - T::MultiCurrency::transfer(token_a, who, &pool_address, amount_a.saturated_into(), false)?; - T::MultiCurrency::transfer(token_b, who, &pool_address, amount_b.saturated_into(), false)?; + T::MultiCurrency::transfer( + token_a, + who, + &pool_address, + amount_a.saturated_into(), + Preservation::Expendable, + )?; + T::MultiCurrency::transfer( + token_b, + who, + &pool_address, + amount_b.saturated_into(), + Preservation::Expendable, + )?; let balance_0 = T::MultiCurrency::balance(token_a, &pool_address); let balance_1 = T::MultiCurrency::balance(token_b, &pool_address); @@ -761,7 +775,13 @@ where // transfer lp tokens to dex let pool_address = trading_pair.pool_address(); - T::MultiCurrency::transfer(lp_share_asset_id, &who, &pool_address, liquidity, false)?; + T::MultiCurrency::transfer( + lp_share_asset_id, + &who, + &pool_address, + liquidity, + Preservation::Expendable, + )?; // match trading-pair to inputs - to match reserves in liquidity pool let (token_a, token_b, amount_a_min, amount_b_min, is_swapped) = @@ -793,9 +813,27 @@ where ensure!(amount_0 >= amount_a_min, Error::::InsufficientWithdrawnAmountA); ensure!(amount_1 >= amount_b_min, Error::::InsufficientWithdrawnAmountB); - T::MultiCurrency::burn_from(lp_share_asset_id, &pool_address, liquidity)?; - T::MultiCurrency::transfer(token_a, &pool_address, &to, amount_0, false)?; - T::MultiCurrency::transfer(token_b, &pool_address, &to, amount_1, false)?; + T::MultiCurrency::burn_from( + lp_share_asset_id, + &pool_address, + liquidity, + Precision::Exact, + Fortitude::Polite, + )?; + T::MultiCurrency::transfer( + token_a, + &pool_address, + &to, + amount_0, + Preservation::Expendable, + )?; + T::MultiCurrency::transfer( + token_b, + &pool_address, + &to, + amount_1, + Preservation::Expendable, + )?; balance_0 = T::MultiCurrency::balance(token_a, &pool_address); balance_1 = T::MultiCurrency::balance(token_b, &pool_address); @@ -1047,7 +1085,7 @@ where &pool_address, &to, amount_0_out, - false, + Preservation::Expendable, )?; } if amount_1_out > 0 { @@ -1057,7 +1095,7 @@ where &pool_address, &to, amount_1_out, - false, + Preservation::Expendable, )?; } @@ -1178,7 +1216,13 @@ where // transfer tokens to module account (uniswapv2 trading pair) let pool_address = trading_pair.pool_address(); - T::MultiCurrency::transfer(path[0], who, &pool_address, amounts[0], false)?; + T::MultiCurrency::transfer( + path[0], + who, + &pool_address, + amounts[0], + Preservation::Expendable, + )?; let swap_res = Self::_swap(&amounts, &path, &to)?; Self::deposit_event(Event::Swap( @@ -1216,7 +1260,13 @@ where ensure!(amounts[0] <= amount_in_max, Error::::ExcessiveSupplyAmount); let trading_pair = TradingPair::new(path[0], path[1]); let pool_address = trading_pair.pool_address(); - T::MultiCurrency::transfer(path[0], who, &pool_address, amounts[0], false)?; + T::MultiCurrency::transfer( + path[0], + who, + &pool_address, + amounts[0], + Preservation::Expendable, + )?; let swap_res = Self::_swap(&amounts, &path, &to)?; Self::deposit_event(Event::Swap(who.clone(), path.to_vec(), amounts[0], amount_out, to)); @@ -1267,4 +1317,4 @@ where Ok(false) } } -} \ No newline at end of file +} diff --git a/pallet/dex/src/mock.rs b/pallet/dex/src/mock.rs index baff4fbf7..e3580179d 100644 --- a/pallet/dex/src/mock.rs +++ b/pallet/dex/src/mock.rs @@ -18,6 +18,7 @@ use super::*; use crate::{self as pallet_dex}; use seed_pallet_common::test_prelude::*; +use sp_runtime::BuildStorage; construct_runtime!( pub enum Test where @@ -62,7 +63,7 @@ pub struct TestExt; impl TestExt { pub fn build(self) -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext: sp_io::TestExternalities = storage.into(); ext.execute_with(|| System::initialize(&1, &[0u8; 32].into(), &Default::default())); diff --git a/pallet/dex/src/tests.rs b/pallet/dex/src/tests.rs index bd30c8015..b08ae6f9d 100644 --- a/pallet/dex/src/tests.rs +++ b/pallet/dex/src/tests.rs @@ -214,8 +214,8 @@ fn create_lp_token() { assert_eq!(usdc, 1124); assert_eq!(weth, 2148); - let usdc_symbol_bytes = AssetsExt::symbol(&usdc); - let weth_symbol_bytes = AssetsExt::symbol(&weth); + let usdc_symbol_bytes = AssetsExt::symbol(usdc); + let weth_symbol_bytes = AssetsExt::symbol(weth); let usdc_symbol = sp_std::str::from_utf8(&usdc_symbol_bytes).unwrap(); let weth_symbol = sp_std::str::from_utf8(&weth_symbol_bytes).unwrap(); @@ -228,10 +228,10 @@ fn create_lp_token() { assert_eq!(lp_token, 3172); let lp_token_name_bytes = - >::name( - &lp_token, + >::name( + lp_token, ); - let lp_token_symbol_bytes = AssetsExt::symbol(&lp_token); + let lp_token_symbol_bytes = AssetsExt::symbol(lp_token); let lp_token_name = sp_std::str::from_utf8(&lp_token_name_bytes).unwrap(); let lp_token_symbol = sp_std::str::from_utf8(&lp_token_symbol_bytes).unwrap(); @@ -265,8 +265,8 @@ fn create_lp_token_long_symbol() { assert_eq!(usdc, 1124); assert_eq!(weth, 2148); - let usdc_symbol_bytes = AssetsExt::symbol(&usdc); - let weth_symbol_bytes = AssetsExt::symbol(&weth); + let usdc_symbol_bytes = AssetsExt::symbol(usdc); + let weth_symbol_bytes = AssetsExt::symbol(weth); let usdc_symbol = sp_std::str::from_utf8(&usdc_symbol_bytes).unwrap(); let weth_symbol = sp_std::str::from_utf8(&weth_symbol_bytes).unwrap(); @@ -279,10 +279,10 @@ fn create_lp_token_long_symbol() { assert_eq!(lp_token, 3172); let lp_token_name_bytes = - >::name( - &lp_token, + >::name( + lp_token, ); - let lp_token_symbol_bytes = AssetsExt::symbol(&lp_token); + let lp_token_symbol_bytes = AssetsExt::symbol(lp_token); let lp_token_name = sp_std::str::from_utf8(&lp_token_name_bytes).unwrap(); let lp_token_symbol = sp_std::str::from_utf8(&lp_token_symbol_bytes).unwrap(); diff --git a/pallet/doughnut/src/lib.rs b/pallet/doughnut/src/lib.rs index 7c62ec506..a378d9575 100644 --- a/pallet/doughnut/src/lib.rs +++ b/pallet/doughnut/src/lib.rs @@ -76,13 +76,13 @@ impl Call where T: Send + Sync + Config, ::RuntimeCall: Dispatchable, - ::Index : Into, + ::Nonce : Into, T::AccountId: From + Into, T: pallet_transaction_payment::Config, <::OnChargeTransaction as OnChargeTransaction>::Balance: Send + Sync + FixedPointOperand + From, ::RuntimeCall: From<::RuntimeCall>, PostDispatchInfo: From<<::RuntimeCall as Dispatchable>::PostInfo>, - ::Index: From, + ::Nonce: From, ::RuntimeCall: GetCallMetadata, { pub fn is_self_contained(&self) -> bool { @@ -573,4 +573,4 @@ where Ok(doughnut_decoded) } -} \ No newline at end of file +} diff --git a/pallet/echo/Cargo.toml b/pallet/echo/Cargo.toml index 0993029ec..298131972 100644 --- a/pallet/echo/Cargo.toml +++ b/pallet/echo/Cargo.toml @@ -12,7 +12,7 @@ seed-primitives = { path = "../../primitives", default-features = false } seed-pallet-common = { path = "../common", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -ethabi = { version = "17.1.0", default-features = false} +ethabi = { version = "18.0.0", default-features = false} sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } diff --git a/pallet/echo/src/lib.rs b/pallet/echo/src/lib.rs index 341d797e9..1fac82074 100644 --- a/pallet/echo/src/lib.rs +++ b/pallet/echo/src/lib.rs @@ -215,4 +215,4 @@ impl EthereumEventSubscriber for Pallet { Ok(Weight::zero()) } } -} \ No newline at end of file +} diff --git a/pallet/erc20-peg/Cargo.toml b/pallet/erc20-peg/Cargo.toml index 3bc850882..1ded5d46e 100644 --- a/pallet/erc20-peg/Cargo.toml +++ b/pallet/erc20-peg/Cargo.toml @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = serde = { version = "1.0.145", optional = true, default-features = false } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } log = "0.4" -ethabi = { version = "17.1.0", default-features = false } +ethabi = { version = "18.0.0", default-features = false } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } diff --git a/pallet/erc20-peg/src/lib.rs b/pallet/erc20-peg/src/lib.rs index 07b726f92..49c89e449 100644 --- a/pallet/erc20-peg/src/lib.rs +++ b/pallet/erc20-peg/src/lib.rs @@ -22,7 +22,8 @@ use frame_support::{ pallet_prelude::*, traits::{ fungibles, - fungibles::{Mutate, Transfer}, + fungibles::Mutate, + tokens::{Fortitude, Precision, Preservation}, Get, IsType, }, transactional, @@ -60,8 +61,7 @@ pub trait Config: frame_system::Config { /// Currency functions type MultiCurrency: CreateExt + fungibles::Inspect - + fungibles::Transfer - + fungibles::Mutate; + + fungibles::Mutate; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -346,10 +346,22 @@ impl Module { if asset_id == T::NativeAssetId::get() { // transfer all ROOT tokens to the peg address let pallet_address: T::AccountId = T::PegPalletId::get().into_account_truncating(); - T::MultiCurrency::transfer(asset_id, origin, &pallet_address, amount, false)?; + T::MultiCurrency::transfer( + asset_id, + origin, + &pallet_address, + amount, + Preservation::Expendable, + )?; } else { // burn all other tokens - T::MultiCurrency::burn_from(asset_id, origin, amount)?; + T::MultiCurrency::burn_from( + asset_id, + origin, + amount, + Precision::Exact, + Fortitude::Polite, + )?; } Ok(()) } @@ -540,7 +552,13 @@ impl Module { if asset_id == T::NativeAssetId::get() { // Transfer all ROOT tokens from the peg address let pallet_address: T::AccountId = T::PegPalletId::get().into_account_truncating(); - T::MultiCurrency::transfer(asset_id, &pallet_address, beneficiary, amount, false)?; + T::MultiCurrency::transfer( + asset_id, + &pallet_address, + beneficiary, + amount, + Preservation::Expendable, + )?; } else { // Mint all other tokens T::MultiCurrency::mint_into(asset_id, beneficiary, amount)?; diff --git a/pallet/ethy/Cargo.toml b/pallet/ethy/Cargo.toml index 675cadc91..dac3fb7cd 100644 --- a/pallet/ethy/Cargo.toml +++ b/pallet/ethy/Cargo.toml @@ -8,8 +8,8 @@ license = "Apache-2.0" [dependencies] codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false } -ethabi = { version = "17.1.0", default-features = false} -ethereum-types = { version = "0.13.1", default-features = false, features = ["serialize", "codec"] } +ethabi = { version = "18.0.0", default-features = false} +ethereum-types = { version = "0.14.1", default-features = false } hex = { version = "0.4.3", default-features = false } hex-literal = { version = "0.3.4", default-features = false } rustc-hex = { version = "2.1.0", default-features = false } diff --git a/pallet/ethy/src/lib.rs b/pallet/ethy/src/lib.rs index ffb93c22e..8d3216282 100644 --- a/pallet/ethy/src/lib.rs +++ b/pallet/ethy/src/lib.rs @@ -41,7 +41,7 @@ use frame_support::{ decl_error, decl_event, decl_module, decl_storage, pallet_prelude::*, traits::{ - fungibles::Transfer, + fungibles::Mutate, schedule::{Anon, DispatchTime}, UnixTime, ValidatorSet as ValidatorSetT, }, @@ -126,7 +126,7 @@ pub trait Config: frame_system::Config + CreateSignedTransaction> { /// Max amount of new signers that can be set an in extrinsic type MaxNewSigners: Get; /// Handles a multi-currency fungible asset system - type MultiCurrency: Transfer + Hold; + type MultiCurrency: Mutate + Hold; /// The native token asset Id (managed by pallet-balances) type NativeAssetId: Get; /// The threshold of notarizations required to approve an Ethereum event diff --git a/pallet/evm-chain-id/src/lib.rs b/pallet/evm-chain-id/src/lib.rs index 1795d4fae..51a8b48dd 100644 --- a/pallet/evm-chain-id/src/lib.rs +++ b/pallet/evm-chain-id/src/lib.rs @@ -97,4 +97,4 @@ pub mod pallet { Ok(()) } } -} \ No newline at end of file +} diff --git a/pallet/fee-control/src/lib.rs b/pallet/fee-control/src/lib.rs index fe1403c12..477fef336 100644 --- a/pallet/fee-control/src/lib.rs +++ b/pallet/fee-control/src/lib.rs @@ -161,4 +161,4 @@ impl fp_evm::FeeCalculator for Pallet { fn min_gas_price() -> (U256, Weight) { (Self::base_fee_per_gas(), T::DbWeight::get().reads(1)) } -} \ No newline at end of file +} diff --git a/pallet/fee-control/src/mock.rs b/pallet/fee-control/src/mock.rs index a6fd31823..c30f02d4c 100644 --- a/pallet/fee-control/src/mock.rs +++ b/pallet/fee-control/src/mock.rs @@ -77,7 +77,6 @@ pub mod mock_pallet { _marker: PhantomData, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { _marker: Default::default() } @@ -85,7 +84,7 @@ pub mod mock_pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { unimplemented!() } @@ -104,4 +103,4 @@ pub mod mock_pallet { } } } -} \ No newline at end of file +} diff --git a/pallet/fee-proxy/Cargo.toml b/pallet/fee-proxy/Cargo.toml index 9505da74a..cef878f5c 100644 --- a/pallet/fee-proxy/Cargo.toml +++ b/pallet/fee-proxy/Cargo.toml @@ -17,7 +17,7 @@ precompile-utils = { path = "../../evm-precompiles/utils", default-features = fa codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } -ethabi = { version = "17.1.0", default-features = false } +ethabi = { version = "18.0.0", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v1.0.0" } diff --git a/pallet/fee-proxy/src/lib.rs b/pallet/fee-proxy/src/lib.rs index 38a6c87e2..33d4dc023 100644 --- a/pallet/fee-proxy/src/lib.rs +++ b/pallet/fee-proxy/src/lib.rs @@ -132,4 +132,4 @@ pub mod pallet { Ok(()) } } -} \ No newline at end of file +} diff --git a/pallet/futurepass/src/lib.rs b/pallet/futurepass/src/lib.rs index efbdaef26..7c21830fa 100644 --- a/pallet/futurepass/src/lib.rs +++ b/pallet/futurepass/src/lib.rs @@ -739,4 +739,4 @@ where fn primary_proxy(who: &T::AccountId) -> Option { >::get(who) } -} \ No newline at end of file +} diff --git a/pallet/maintenance-mode/src/lib.rs b/pallet/maintenance-mode/src/lib.rs index 58046a312..d642ef48e 100644 --- a/pallet/maintenance-mode/src/lib.rs +++ b/pallet/maintenance-mode/src/lib.rs @@ -406,4 +406,4 @@ where ) -> Result { self.validate(who, call, info, len).map(|_| ()) } -} \ No newline at end of file +} diff --git a/pallet/marketplace/src/lib.rs b/pallet/marketplace/src/lib.rs index c37bf4065..11d588020 100644 --- a/pallet/marketplace/src/lib.rs +++ b/pallet/marketplace/src/lib.rs @@ -66,7 +66,6 @@ pub mod pallet { _phantom: sp_std::marker::PhantomData, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { _phantom: Default::default() } @@ -74,7 +73,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { NextMarketplaceId::::put(1 as MarketplaceId); NextListingId::::put(1 as ListingId); @@ -605,4 +604,4 @@ pub mod pallet { Self::do_set_fee_to(fee_to) } } -} \ No newline at end of file +} diff --git a/pallet/nft-peg/Cargo.toml b/pallet/nft-peg/Cargo.toml index 593361c0d..55dc69537 100644 --- a/pallet/nft-peg/Cargo.toml +++ b/pallet/nft-peg/Cargo.toml @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = serde = { version = "1.0.145", optional = true, default-features = false } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } log = "0.4" -ethabi = { version = "17.1.0", default-features = false } +ethabi = { version = "18.0.0", default-features = false } pallet-nft = { path = "../nft", default-features = false } # Substrate diff --git a/pallet/nft-peg/src/lib.rs b/pallet/nft-peg/src/lib.rs index 7d3958a94..91bb8599f 100644 --- a/pallet/nft-peg/src/lib.rs +++ b/pallet/nft-peg/src/lib.rs @@ -527,4 +527,4 @@ where return Err((weight, Error::::InvalidAbiPrefix.into())) } } -} \ No newline at end of file +} diff --git a/pallet/nft/src/impls.rs b/pallet/nft/src/impls.rs index ac6ea434d..2d2c54da1 100644 --- a/pallet/nft/src/impls.rs +++ b/pallet/nft/src/impls.rs @@ -14,7 +14,11 @@ // You may obtain a copy of the License at the root of this project source code use crate::{traits::NFTCollectionInfo, *}; -use frame_support::{ensure, traits::Get, weights::Weight}; +use frame_support::{ + ensure, + traits::{tokens::Preservation, Get}, + weights::Weight, +}; use frame_system::RawOrigin; use precompile_utils::constants::ERC721_PRECOMPILE_ADDRESS_PREFIX; use seed_pallet_common::{ @@ -258,7 +262,13 @@ impl Pallet { }; // Charge the fee if there is a fee set if let Some((asset, total_fee)) = total_fee { - T::MultiCurrency::transfer(asset, who, &collection_owner, total_fee, false)?; + T::MultiCurrency::transfer( + asset, + who, + &collection_owner, + total_fee, + Preservation::Expendable, + )?; // Deposit event Self::deposit_event(Event::::MintFeePaid { who: who.clone(), diff --git a/pallet/nft/src/lib.rs b/pallet/nft/src/lib.rs index 351f7998d..38bf32e54 100644 --- a/pallet/nft/src/lib.rs +++ b/pallet/nft/src/lib.rs @@ -30,7 +30,7 @@ use frame_support::{ ensure, - traits::{fungibles::Transfer, Get}, + traits::{fungibles::Mutate, Get}, transactional, PalletId, }; use seed_pallet_common::{OnNewAssetSubscriber, OnTransferSubscriber, Xls20MintRequest}; @@ -87,7 +87,6 @@ pub mod pallet { _phantom: sp_std::marker::PhantomData, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { _phantom: Default::default() } @@ -95,7 +94,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { NextCollectionId::::put(1_u32); } @@ -114,7 +113,7 @@ pub mod pallet { /// Handler for when an NFT collection has been created type OnNewAssetSubscription: OnNewAssetSubscriber; /// Handles a multi-currency fungible asset system - type MultiCurrency: Transfer; + type MultiCurrency: Mutate; /// This pallet's Id, used for deriving a sovereign account ID #[pallet::constant] type PalletId: Get; @@ -638,4 +637,4 @@ impl From for Error { TokenOwnershipError::TokenLimitExceeded => Error::::TokenLimitExceeded, } } -} \ No newline at end of file +} diff --git a/pallet/sft/src/impls.rs b/pallet/sft/src/impls.rs index 68d0788fd..5aa64ba25 100644 --- a/pallet/sft/src/impls.rs +++ b/pallet/sft/src/impls.rs @@ -14,7 +14,7 @@ // You may obtain a copy of the License at the root of this project source code use crate::*; -use frame_support::ensure; +use frame_support::{ensure, traits::tokens::Preservation}; use precompile_utils::constants::ERC1155_PRECOMPILE_ADDRESS_PREFIX; use seed_pallet_common::{utils::PublicMintInformation, SFTExt}; use seed_primitives::{CollectionUuid, MAX_COLLECTION_ENTITLEMENTS}; @@ -147,7 +147,13 @@ impl Pallet { }; // Charge the fee if there is a fee set if let Some((asset, total_fee)) = total_fee { - T::MultiCurrency::transfer(asset, who, &collection_owner, total_fee, false)?; + T::MultiCurrency::transfer( + asset, + who, + &collection_owner, + total_fee, + Preservation::Expendable, + )?; // Deposit event Self::deposit_event(Event::::MintFeePaid { who: who.clone(), diff --git a/pallet/sft/src/lib.rs b/pallet/sft/src/lib.rs index 0302e07c5..f9f3c219d 100644 --- a/pallet/sft/src/lib.rs +++ b/pallet/sft/src/lib.rs @@ -478,4 +478,4 @@ pub mod pallet { Ok(()) } } -} \ No newline at end of file +} diff --git a/pallet/token-approvals/src/lib.rs b/pallet/token-approvals/src/lib.rs index 0d634f887..82898288f 100644 --- a/pallet/token-approvals/src/lib.rs +++ b/pallet/token-approvals/src/lib.rs @@ -296,4 +296,4 @@ impl OnTransferSubscriber for Pallet { // Set approval to none Self::remove_erc721_approval(token_id); } -} \ No newline at end of file +} diff --git a/pallet/vortex-distribution/src/lib.rs b/pallet/vortex-distribution/src/lib.rs index 52fe50dce..ff6a5a8e4 100644 --- a/pallet/vortex-distribution/src/lib.rs +++ b/pallet/vortex-distribution/src/lib.rs @@ -34,7 +34,7 @@ use frame_support::{ log, pallet_prelude::*, traits::{ - tokens::fungibles::{self, Inspect, Mutate, Transfer}, + tokens::fungibles::{self, Inspect, Mutate}, Get, }, PalletId, @@ -77,8 +77,10 @@ type AccountIdLookupOf = <::Lookup as StaticLookup #[frame_support::pallet] pub mod pallet { - - use frame_support::transactional; + use frame_support::{ + traits::tokens::{Fortitude, Precision, Preservation}, + transactional, + }; use sp_runtime::traits::AtLeast32BitUnsigned; use super::*; @@ -95,10 +97,9 @@ pub mod pallet { /// Multi currency type MultiCurrency: CreateExt - + fungibles::Transfer> + fungibles::Inspect - + fungibles::InspectMetadata - + fungibles::Mutate; + + fungibles::metadata::Inspect + + fungibles::Mutate>; /// The native token asset Id (managed by pallet-balances) #[pallet::constant] @@ -620,7 +621,13 @@ pub mod pallet { } // Burn the vortex token - T::MultiCurrency::burn_from(T::VtxAssetId::get(), &who, vortex_token_amount)?; + T::MultiCurrency::burn_from( + T::VtxAssetId::get(), + &who, + vortex_token_amount, + Precision::Exact, + Fortitude::Polite, + )?; Ok(()) } } @@ -773,8 +780,13 @@ pub mod pallet { amount: BalanceOf, _keep_live: bool, ) -> DispatchResult { - let transfer_result = - T::MultiCurrency::transfer(asset_id, source, dest, amount, false)?; + let transfer_result = T::MultiCurrency::transfer( + asset_id, + source, + dest, + amount, + Preservation::Expendable, + )?; ensure!(transfer_result == amount, Error::::InvalidAmount); Ok(()) } @@ -794,4 +806,4 @@ pub mod pallet { } } } -} \ No newline at end of file +} diff --git a/pallet/vortex-distribution/src/mock.rs b/pallet/vortex-distribution/src/mock.rs index 980ef7896..0eb9bea0c 100644 --- a/pallet/vortex-distribution/src/mock.rs +++ b/pallet/vortex-distribution/src/mock.rs @@ -16,7 +16,10 @@ use crate as pallet_vortex; use frame_support::traits::{ConstU32, Hooks}; use seed_pallet_common::test_prelude::*; -use sp_runtime::testing::{Header, TestXt}; +use sp_runtime::{ + testing::{Header, TestXt}, + BuildStorage, +}; pub type Extrinsic = TestXt; pub const MILLISECS_PER_BLOCK: u64 = 4_000; @@ -194,7 +197,7 @@ impl TestExt { } pub fn build(self) -> sp_io::TestExternalities { - let mut ext = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut ext = frame_system::GenesisConfig::::default().build_storage().unwrap(); if !self.assets.is_empty() { let mut metadata = Vec::with_capacity(self.assets.len()); diff --git a/pallet/xls20/src/lib.rs b/pallet/xls20/src/lib.rs index a7a3e2bf5..9bb839d21 100644 --- a/pallet/xls20/src/lib.rs +++ b/pallet/xls20/src/lib.rs @@ -321,4 +321,4 @@ impl Xls20MintRequest for Pallet { Self::send_xls20_requests(collection_id, serial_numbers, metadata_scheme); Ok(()) } -} \ No newline at end of file +} diff --git a/pallet/xrpl-bridge/src/lib.rs b/pallet/xrpl-bridge/src/lib.rs index a959d22af..e4b0a5911 100644 --- a/pallet/xrpl-bridge/src/lib.rs +++ b/pallet/xrpl-bridge/src/lib.rs @@ -243,8 +243,12 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn process_xrp_transaction)] /// Temporary storage to set the transactions ready to be processed at specified block number - pub type ProcessXRPTransaction = - StorageMap<_, Twox64Concat, BlockNumberFor, BoundedVec>; + pub type ProcessXRPTransaction = StorageMap< + _, + Twox64Concat, + BlockNumberFor, + BoundedVec, + >; #[pallet::storage] #[pallet::getter(fn process_xrp_transaction_details)] @@ -374,7 +378,6 @@ pub mod pallet { pub xrp_relayers: Vec, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { xrp_relayers: vec![] } @@ -382,7 +385,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_relayer(&self.xrp_relayers); } @@ -1172,4 +1175,4 @@ impl EthyToXrplBridgeAdapter for Pallet { T::EthyAdapter::sign_xrpl_transaction(tx_blob.as_slice()) } -} \ No newline at end of file +} diff --git a/pallet/xrpl-bridge/src/tests.rs b/pallet/xrpl-bridge/src/tests.rs index 6d8c1c082..ade23c7c9 100644 --- a/pallet/xrpl-bridge/src/tests.rs +++ b/pallet/xrpl-bridge/src/tests.rs @@ -904,8 +904,7 @@ fn clear_storages_returns_zero_if_not_enough_weight() { // Call on idle to prune the settled data with JUST enough weight to settle one tx let remaining_weight = DbWeight::get().reads_writes(4, 3); - let idle_weight = - XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); + let idle_weight = XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); assert_eq!(idle_weight, remaining_weight); // Data updated assert!(>::get(ledger_index).is_none()); @@ -944,8 +943,7 @@ fn clear_storages_doesnt_exceed_on_idle_weight() { // Call on idle with enough weight to clear only 1 tx let remaining_weight = DbWeight::get().reads_writes(4, 2 + 1); - let idle_weight = - XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); + let idle_weight = XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); // We subtract 1 from as we did not end up updating HighestPrunedLedgerIndex assert_eq!(idle_weight, remaining_weight - DbWeight::get().writes(1)); // One settledXRPTransaction should have been removed @@ -965,8 +963,7 @@ fn clear_storages_doesnt_exceed_on_idle_weight() { // Call on idle with enough weight to clear 4 more txs let remaining_weight = DbWeight::get().reads_writes(4, 2 + 4); - let idle_weight = - XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); + let idle_weight = XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); // We subtract 1 from as we did not end up updating HighestPrunedLedgerIndex assert_eq!(idle_weight, remaining_weight - DbWeight::get().writes(1)); // 5 settledXRPTransaction should have been removed total @@ -986,8 +983,7 @@ fn clear_storages_doesnt_exceed_on_idle_weight() { // Call on idle with enough weight to clear the last 5 txs let remaining_weight = DbWeight::get().reads_writes(4, 2 + 5); - let idle_weight = - XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); + let idle_weight = XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); assert_eq!(idle_weight, remaining_weight); // SettledXRPTransactionDetails should now be cleared assert!(>::get(ledger_index).is_none()); @@ -1041,8 +1037,7 @@ fn clear_storages_across_multiple_ledger_indices() { let weight_per_index = DbWeight::get().reads_writes(1, 1); let weight_per_hash = DbWeight::get().writes(1); let remaining_weight = base_weight + (weight_per_index * 2) + (weight_per_hash * 10); - let idle_weight = - XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); + let idle_weight = XRPLBridge::clear_storages(remaining_weight + Weight::from_all(1u64)); assert_eq!(idle_weight, remaining_weight); // SettledXRPTransactionDetails should now be cleared @@ -1488,10 +1483,8 @@ fn process_delayed_payments_works() { // Set next process block to this block NextDelayProcessBlock::::put(1001); // Call process delayed payments with enough weight to process the delayed payment - let weight_used = XRPLBridge::process_delayed_payments( - 1001, - Weight::from_all(1_000_000_000_000), - ); + let weight_used = + XRPLBridge::process_delayed_payments(1001, Weight::from_all(1_000_000_000_000)); // Assert weight used is as expected assert_eq!(weight_used, DbWeight::get().reads_writes(6, 4)); @@ -1629,15 +1622,13 @@ fn process_delayed_payments_multiple_withdrawals() { // Set next process block to this block NextDelayProcessBlock::::put(1001); // Call process delayed payments with enough weight to process all delayed payments - let weight_used = XRPLBridge::process_delayed_payments( - 1001, - Weight::from_all(1_000_000_000_000), - ); + let weight_used = + XRPLBridge::process_delayed_payments(1001, Weight::from_all(1_000_000_000_000)); // Assert weight used is as expected let weight_per_tx = DbWeight::get().reads_writes(3u64, 2u64); let base_weight = DbWeight::get().reads_writes(7u64, 1u64); - let total_weight = base_weight + - Weight::from_all(weight_per_tx.ref_time() * withdrawal_count as u64); + let total_weight = + base_weight + Weight::from_all(weight_per_tx.ref_time() * withdrawal_count as u64); assert_eq!(weight_used, total_weight); // Storage should now be updated @@ -1702,15 +1693,13 @@ fn process_delayed_payments_multiple_withdrawals_across_multiple_blocks() { NextDelayProcessBlock::::put(1001); // Call process delayed payments with enough weight to process all delayed payments // Set block number to the last block we need to process - let weight_used = XRPLBridge::process_delayed_payments( - 1101, - Weight::from_all(1_000_000_000_000), - ); + let weight_used = + XRPLBridge::process_delayed_payments(1101, Weight::from_all(1_000_000_000_000)); // Assert weight used is as expected let weight_per_tx = DbWeight::get().reads_writes(4u64, 3u64); let base_weight = DbWeight::get().reads_writes(3u64, 1u64); - let total_weight = base_weight + - Weight::from_all(weight_per_tx.ref_time() * withdrawal_count as u64); + let total_weight = + base_weight + Weight::from_all(weight_per_tx.ref_time() * withdrawal_count as u64); assert_eq!(weight_used, total_weight); // Storage should now be updated diff --git a/pallet/xrpl/src/lib.rs b/pallet/xrpl/src/lib.rs index 6d378aa43..b63e9fe48 100644 --- a/pallet/xrpl/src/lib.rs +++ b/pallet/xrpl/src/lib.rs @@ -77,13 +77,13 @@ impl Call where T: Send + Sync + Config, ::RuntimeCall: Dispatchable, - ::Index: Into, + ::Nonce: Into, T::AccountId: From, T: pallet_transaction_payment::Config, <::OnChargeTransaction as OnChargeTransaction>::Balance: Send + Sync + FixedPointOperand + From, ::RuntimeCall: From<::RuntimeCall>, PostDispatchInfo: From<<::RuntimeCall as Dispatchable>::PostInfo>, - ::Index: From, + ::Nonce: From, { pub fn is_self_contained(&self) -> bool { @@ -482,4 +482,4 @@ pub mod pallet { Ok(().into()) } } -} \ No newline at end of file +} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2884f659f..7d9df2b2a 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -129,9 +129,9 @@ pallet-election-provider-support-benchmarking = { git = "https://github.com/pari substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } [dev-dependencies] -ethereum = { version = "0.12.0", features = ["with-codec"] } +ethereum = { version = "0.14.0", features = ["with-codec"] } seed-client = { path = "../client" } -ethabi = { version = "17.1.0" } +ethabi = { version = "18.0.0" } frame-remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } tokio = { version = "1.19.2", features = ["macros"] } substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } diff --git a/runtime/src/impls.rs b/runtime/src/impls.rs index f7ae9886b..99ff46050 100644 --- a/runtime/src/impls.rs +++ b/runtime/src/impls.rs @@ -783,9 +783,9 @@ where let amount = as fungibles::Inspect< ::AccountId, >>::reducible_balance(asset_id, current_owner, false); - as fungibles::Transfer< + as fungibles::Mutate< ::AccountId, - >>::transfer(asset_id, current_owner, new_owner, amount, false)?; + >>::transfer(asset_id, current_owner, new_owner, amount, Preservation::Expendable)?; Ok(()) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a3454a206..42477ca20 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -282,8 +282,8 @@ impl frame_system::Config for Runtime { type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = IdentityLookup; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; + /// The nonce type for storing how many extrinsics an account has signed. + type Nonce = Index; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used.