git.delta.rocks / unique-network / refs/commits / b12d77148755

difftreelog

fix make pallets build on 0.9.42

Yaroslav Bolyukin2023-05-22parent: #09fadf7.patch.diff
in: master

9 files changed

modifiedpallets/app-promotion/Cargo.tomldiffbeforeafterboth
--- a/pallets/app-promotion/Cargo.toml
+++ b/pallets/app-promotion/Cargo.toml
@@ -48,7 +48,7 @@
 frame-benchmarking = { workspace = true, optional = true }
 frame-support = { workspace = true }
 frame-system = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-evm = { workspace = true }
 sp-core = { workspace = true }
 sp-runtime = { workspace = true }
modifiedpallets/collator-selection/Cargo.tomldiffbeforeafterboth
--- a/pallets/collator-selection/Cargo.toml
+++ b/pallets/collator-selection/Cargo.toml
@@ -33,7 +33,7 @@
 
 [dev-dependencies]
 pallet-aura = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-timestamp = { workspace = true }
 sp-consensus-aura = { workspace = true }
 sp-core = { workspace = true }
modifiedpallets/foreign-assets/Cargo.tomldiffbeforeafterboth
--- a/pallets/foreign-assets/Cargo.toml
+++ b/pallets/foreign-assets/Cargo.toml
@@ -15,7 +15,7 @@
 frame-system = { workspace = true }
 log = { workspace = true }
 orml-tokens = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-common = { workspace = true }
 pallet-fungible = { workspace = true }
 serde = { workspace = true, optional = true }
modifiedpallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth
19use super::*;19use super::*;
20use frame_system::Config as SystemConfig;20use frame_system::Config as SystemConfig;
2121
22use frame_support::traits::tokens::{DepositConsequence, WithdrawConsequence};22use frame_support::traits::tokens::{
23 DepositConsequence, WithdrawConsequence, Preservation, Fortitude, Provenance, Precision,
24};
23use pallet_common::CollectionHandle;25use pallet_common::CollectionHandle;
24use pallet_fungible::FungibleHandle;26use pallet_fungible::FungibleHandle;
25use pallet_common::CommonCollectionOperations;27use pallet_common::CommonCollectionOperations;
118 }120 }
119 }121 }
120122
123 fn total_balance(asset: Self::AssetId, who: &<T as SystemConfig>::AccountId) -> Self::Balance {
124 Self::balance(asset, who)
125 }
126
121 fn reducible_balance(127 fn reducible_balance(
122 asset: Self::AssetId,128 asset: Self::AssetId,
123 who: &<T as SystemConfig>::AccountId,129 who: &<T as SystemConfig>::AccountId,
124 keep_alive: bool,130 preservation: Preservation,
131 fortitude: Fortitude,
125 ) -> Self::Balance {132 ) -> Self::Balance {
126 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible reducible_balance");133 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible reducible_balance");
127134
128 match asset {135 match asset {
129 AssetIds::NativeAssetId(NativeCurrency::Here) => {136 AssetIds::NativeAssetId(NativeCurrency::Here) => {
130 <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::reducible_balance(137 <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::reducible_balance(
131 who, keep_alive,138 who,
139 preservation,
140 fortitude,
132 )141 )
133 .into()142 .into()
134 }143 }
135 AssetIds::NativeAssetId(NativeCurrency::Parent) => {144 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
136 <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::reducible_balance(145 <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::reducible_balance(
137 AssetIds::NativeAssetId(NativeCurrency::Parent),146 AssetIds::NativeAssetId(NativeCurrency::Parent),
138 who,147 who,
139 keep_alive,148 preservation,
149 fortitude,
140 )150 )
141 .into()151 .into()
142 }152 }
148 asset: Self::AssetId,158 asset: Self::AssetId,
149 who: &<T as SystemConfig>::AccountId,159 who: &<T as SystemConfig>::AccountId,
150 amount: Self::Balance,160 amount: Self::Balance,
151 mint: bool,161 provenance: Provenance,
152 ) -> DepositConsequence {162 ) -> DepositConsequence {
153 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_deposit");163 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_deposit");
154164
157 <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_deposit(167 <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_deposit(
158 who,168 who,
159 amount.into(),169 amount.into(),
160 mint,170 provenance,
161 )171 )
162 }172 }
163 AssetIds::NativeAssetId(NativeCurrency::Parent) => {173 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
164 <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_deposit(174 <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_deposit(
165 AssetIds::NativeAssetId(NativeCurrency::Parent),175 AssetIds::NativeAssetId(NativeCurrency::Parent),
166 who,176 who,
167 amount.into(),177 amount.into(),
168 mint,178 provenance,
169 )179 )
170 }180 }
171 _ => {181 _ => {
220 who,230 who,
221 this_amount,231 this_amount,
222 ) {232 ) {
223 WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,233 WithdrawConsequence::BalanceLow => WithdrawConsequence::BalanceLow,
224 WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,234 WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,
225 WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,235 WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,
226 WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,236 WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,
227 WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,237 WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,
228 WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,238 WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,
229 WithdrawConsequence::Success => WithdrawConsequence::Success,239 WithdrawConsequence::Success => WithdrawConsequence::Success,
230 _ => WithdrawConsequence::NoFunds,240 _ => WithdrawConsequence::BalanceLow,
231 }241 }
232 }242 }
233 AssetIds::NativeAssetId(NativeCurrency::Parent) => {243 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
242 who,252 who,
243 parent_amount,253 parent_amount,
244 ) {254 ) {
245 WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,255 WithdrawConsequence::BalanceLow => WithdrawConsequence::BalanceLow,
246 WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,256 WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,
247 WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,257 WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,
248 WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,258 WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,
249 WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,259 WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,
250 WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,260 WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,
251 WithdrawConsequence::Success => WithdrawConsequence::Success,261 WithdrawConsequence::Success => WithdrawConsequence::Success,
252 _ => WithdrawConsequence::NoFunds,262 _ => WithdrawConsequence::BalanceLow,
253 }263 }
254 }264 }
255 _ => match Self::balance(asset, who).checked_sub(&amount) {265 _ => match Self::balance(asset, who).checked_sub(&amount) {
256 Some(_) => WithdrawConsequence::Success,266 Some(_) => WithdrawConsequence::Success,
257 None => WithdrawConsequence::NoFunds,267 None => WithdrawConsequence::BalanceLow,
258 },268 },
259 }269 }
260 }270 }
280 asset: Self::AssetId,290 asset: Self::AssetId,
281 who: &<T as SystemConfig>::AccountId,291 who: &<T as SystemConfig>::AccountId,
282 amount: Self::Balance,292 amount: Self::Balance,
283 ) -> DispatchResult {293 ) -> Result<BalanceOf<T>, DispatchError> {
284 //Self::do_mint(asset, who, amount, None)294 //Self::do_mint(asset, who, amount, None)
285 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible mint_into {:?}", asset);295 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible mint_into {:?}", asset);
286296
290 who,300 who,
291 amount.into(),301 amount.into(),
292 )302 )
293 .into()303 .map(Into::into)
294 }304 }
295 AssetIds::NativeAssetId(NativeCurrency::Parent) => {305 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
296 <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::mint_into(306 <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::mint_into(
297 AssetIds::NativeAssetId(NativeCurrency::Parent),307 AssetIds::NativeAssetId(NativeCurrency::Parent),
298 who,308 who,
299 amount.into(),309 amount.into(),
300 )310 )
301 .into()311 .map(Into::into)
302 }312 }
303 AssetIds::ForeignAssetId(fid) => {313 AssetIds::ForeignAssetId(fid) => {
304 let target_collection_id = match <AssetBinding<T>>::get(fid) {314 let target_collection_id = match <AssetBinding<T>>::get(fid) {
323 &Value::new(0),333 &Value::new(0),
324 )?;334 )?;
325335
326 Ok(())336 Ok(amount.into())
327 }337 }
328 }338 }
329 }339 }
332 asset: Self::AssetId,342 asset: Self::AssetId,
333 who: &<T as SystemConfig>::AccountId,343 who: &<T as SystemConfig>::AccountId,
334 amount: Self::Balance,344 amount: Self::Balance,
345 precision: Precision,
346 fortitude: Fortitude,
335 ) -> Result<Self::Balance, DispatchError> {347 ) -> Result<Self::Balance, DispatchError> {
336 // let f = DebitFlags { keep_alive: false, best_effort: false };348 // let f = DebitFlags { keep_alive: false, best_effort: false };
337 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible burn_from");349 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible burn_from");
338350
339 match asset {351 match asset {
340 AssetIds::NativeAssetId(NativeCurrency::Here) => {352 AssetIds::NativeAssetId(NativeCurrency::Here) => {
341 match <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::burn_from(353 <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::burn_from(
342 who,354 who,
343 amount.into(),355 amount.into(),
344 ) {356 precision,
345 Ok(v) => Ok(v.into()),357 fortitude,
346 Err(e) => Err(e),358 )
347 }359 .map(Into::into)
348 }360 }
349 AssetIds::NativeAssetId(NativeCurrency::Parent) => {361 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
350 match <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::burn_from(362 <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::burn_from(
351 AssetIds::NativeAssetId(NativeCurrency::Parent),363 AssetIds::NativeAssetId(NativeCurrency::Parent),
352 who,364 who,
353 amount.into(),365 amount.into(),
354 ) {366 precision,
355 Ok(v) => Ok(v.into()),367 fortitude,
356 Err(e) => Err(e),368 )
357 }369 .map(Into::into)
358 }370 }
359 AssetIds::ForeignAssetId(fid) => {371 AssetIds::ForeignAssetId(fid) => {
360 let target_collection_id = match <AssetBinding<T>>::get(fid) {372 let target_collection_id = match <AssetBinding<T>>::get(fid) {
378 }390 }
379 }391 }
380392
381 fn slash(
382 asset: Self::AssetId,
383 who: &<T as SystemConfig>::AccountId,
384 amount: Self::Balance,
385 ) -> Result<Self::Balance, DispatchError> {
386 // let f = DebitFlags { keep_alive: false, best_effort: true };
387 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible slash");
388 Ok(Self::burn_from(asset, who, amount)?)
389 }
390}
391
392impl<T: Config> fungibles::Transfer<T::AccountId> for Pallet<T>
393where
394 T: orml_tokens::Config<CurrencyId = AssetIds>,
395 BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,
396 BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,
397 <T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,
398 <T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,
399 u128: From<BalanceOf<T>>,
400{
401 fn transfer(393 fn transfer(
402 asset: Self::AssetId,394 asset: Self::AssetId,
403 source: &<T as SystemConfig>::AccountId,395 source: &<T as SystemConfig>::AccountId,
404 dest: &<T as SystemConfig>::AccountId,396 dest: &<T as SystemConfig>::AccountId,
405 amount: Self::Balance,397 amount: Self::Balance,
406 keep_alive: bool,398 preservation: Preservation,
407 ) -> Result<Self::Balance, DispatchError> {399 ) -> Result<Self::Balance, DispatchError> {
408 // let f = TransferFlags { keep_alive, best_effort: false, burn_dust: false };400 // let f = TransferFlags { keep_alive, best_effort: false, burn_dust: false };
409 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible transfer");401 log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible transfer");
410402
411 match asset {403 match asset {
412 AssetIds::NativeAssetId(NativeCurrency::Here) => {404 AssetIds::NativeAssetId(NativeCurrency::Here) => {
413 match <pallet_balances::Pallet<T> as fungible::Transfer<T::AccountId>>::transfer(405 match <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::transfer(
414 source,406 source,
415 dest,407 dest,
416 amount.into(),408 amount.into(),
417 keep_alive,409 preservation,
418 ) {410 ) {
419 Ok(_) => Ok(amount),411 Ok(_) => Ok(amount),
420 Err(_) => Err(DispatchError::Other(412 Err(_) => Err(DispatchError::Other(
423 }415 }
424 }416 }
425 AssetIds::NativeAssetId(NativeCurrency::Parent) => {417 AssetIds::NativeAssetId(NativeCurrency::Parent) => {
426 match <orml_tokens::Pallet<T> as fungibles::Transfer<T::AccountId>>::transfer(418 match <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::transfer(
427 AssetIds::NativeAssetId(NativeCurrency::Parent),419 AssetIds::NativeAssetId(NativeCurrency::Parent),
428 source,420 source,
429 dest,421 dest,
430 amount.into(),422 amount.into(),
431 keep_alive,423 preservation,
432 ) {424 ) {
433 Ok(_) => Ok(amount),425 Ok(_) => Ok(amount),
434 Err(e) => Err(e),426 Err(e) => Err(e),
458 Ok(amount)450 Ok(amount)
459 }451 }
460 }452 }
453 }
454}
455
456#[cfg(not(debug_assertions))]
457extern "C" {
458 // This function does not exists, thus compilation will fail, if its call is
459 // not optimized away, which is only possible if it's not called at all.
460 //
461 // not(debug_assertions) is used to ensure compiler is dropping unused functions, as
462 // this option is enabled in release by defailt
463 //
464 // FIXME: maybe use build.rs, to ensure it will fail even in release with debug_assertions
465 // enabled?
466 fn unbalanced_fungible_is_called();
467}
468macro_rules! ensure_balanced {
469 () => {{
470 #[cfg(debug_assertions)]
471 panic!("unbalanced fungible methods should not be used");
472 #[cfg(not(debug_assertions))]
473 {
474 unsafe { unbalanced_fungible_is_called() };
475 unreachable!();
476 }
477 }};
478}
479
480impl<T: Config> fungibles::Unbalanced<<T as SystemConfig>::AccountId> for Pallet<T>
481where
482 T: orml_tokens::Config<CurrencyId = AssetIds>,
483 BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,
484 BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,
485 <T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,
486 <T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,
487 u128: From<BalanceOf<T>>,
488{
489 fn handle_dust(_dust: fungibles::Dust<<T as SystemConfig>::AccountId, Self>) {
490 ensure_balanced!();
491 }
492 fn write_balance(
493 _asset: Self::AssetId,
494 _who: &<T as SystemConfig>::AccountId,
495 _amount: Self::Balance,
496 ) -> Result<Option<Self::Balance>, DispatchError> {
497 ensure_balanced!();
498 }
499 fn set_total_issuance(_asset: Self::AssetId, _amount: Self::Balance) {
500 ensure_balanced!();
461 }501 }
462}502}
463503
modifiedpallets/foreign-assets/src/lib.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/lib.rs
+++ b/pallets/foreign-assets/src/lib.rs
@@ -448,9 +448,7 @@
 
 pub use frame_support::{
 	traits::{
-		fungibles::{Balanced, CreditOf},
-		tokens::currency::Currency as CurrencyT,
-		OnUnbalanced as OnUnbalancedT,
+		fungibles::Balanced, tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT,
 	},
 	weights::{WeightToFeePolynomial, WeightToFee},
 };
modifiedpallets/identity/Cargo.tomldiffbeforeafterboth
--- a/pallets/identity/Cargo.toml
+++ b/pallets/identity/Cargo.toml
@@ -26,7 +26,7 @@
 sp-std = { workspace = true }
 
 [dev-dependencies]
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 sp-core = { workspace = true }
 
 [features]
modifiedpallets/inflation/Cargo.tomldiffbeforeafterboth
--- a/pallets/inflation/Cargo.toml
+++ b/pallets/inflation/Cargo.toml
@@ -37,7 +37,7 @@
 frame-benchmarking = { workspace = true, optional = true }
 frame-support = { workspace = true }
 frame-system = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 sp-core = { workspace = true }
 sp-io = { workspace = true }
 sp-runtime = { workspace = true }
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -114,12 +114,26 @@
 );
 
 pub trait TryPass {
+<<<<<<< HEAD
 	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()>;
+=======
+	fn try_pass<Call>(
+		origin: &MultiLocation,
+		message: &mut [Instruction<Call>],
+	) -> Result<(), ProcessMessageError>;
+>>>>>>> fd33b0ac (fixup pallets)
 }
 
 #[impl_trait_for_tuples::impl_for_tuples(30)]
 impl TryPass for Tuple {
+<<<<<<< HEAD
 	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()> {
+=======
+	fn try_pass<Call>(
+		origin: &MultiLocation,
+		message: &mut [Instruction<Call>],
+	) -> Result<(), ProcessMessageError> {
+>>>>>>> fd33b0ac (fixup pallets)
 		for_tuples!( #(
 			Tuple::try_pass(origin, message)?;
 		)* );
modifiedtest-pallets/utils/src/lib.rsdiffbeforeafterboth
--- a/test-pallets/utils/src/lib.rs
+++ b/test-pallets/utils/src/lib.rs
@@ -20,7 +20,7 @@
 use frame_support::pallet_prelude::*;
 use frame_system::pallet_prelude::*;
 
-#[frame_support::pallet]
+#[frame_support::pallet(dev_mode)]
 pub mod pallet {
 	use frame_support::{
 		pallet_prelude::*,