diff --git a/Cargo.dev.toml b/Cargo.dev.toml index 2b30f836e..7ffc22886 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -23,22 +23,67 @@ members = [ ] resolver = "2" -[patch.crates-io] -frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -pallet-treasury = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } -sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +[patch.'https://github.com/paritytech/substrate'] +frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +frame-support = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +frame-system = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-balances = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-elections-phragmen = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-scheduler = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-treasury = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-authorship = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-vesting = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-timestamp = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-session = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-staking = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-offences = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +pallet-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-api = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-application-crypto = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-arithmetic = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-core = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-inherents = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-io = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-runtime = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-runtime-interface = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-std = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-trie = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-version = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-externalities = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-state-machine = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-wasm-interface = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-keystore = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-staking = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-storage = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-panic-handler = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-npos-elections = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-npos-elections-compact = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-debug-derive = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-allocator = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sc-executor-common = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sc-executor-wasmi = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sc-executor = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sc-client-api = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-tasks = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-authorship = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-consensus = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-timestamp = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-session = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-blockchain = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } +sp-transaction-pool = { git = "https://github.com/paritytech//substrate", rev = "3ec97a31b285181fb1beab426ee2a8e2cb1188ab" } + +[patch.'https://github.com/paritytech/cumulus'] +cumulus-primitives-core = { git = "https://github.com/paritytech//cumulus", rev = "c5be7306f425be9fcf3c6e0bc598c0f481588cd9" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech//cumulus", rev = "c5be7306f425be9fcf3c6e0bc598c0f481588cd9" } +parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "c5be7306f425be9fcf3c6e0bc598c0f481588cd9" } +cumulus-pallet-xcm-handler = { git = "https://github.com/paritytech//cumulus", rev = "c5be7306f425be9fcf3c6e0bc598c0f481588cd9" } + +[patch.'https://github.com/paritytech/polkadot'] +xcm = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +xcm-executor = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +xcm-builder = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +polkadot-core-primitives = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +polkadot-parachain = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } +polkadot-primitives = { git = "https://github.com/paritytech//polkadot", rev = "6b5b4a58a3f6a3fb647fec926609e04b7d5a336a" } diff --git a/unknown-tokens/src/lib.rs b/unknown-tokens/src/lib.rs index f162c91bb..e048ba370 100644 --- a/unknown-tokens/src/lib.rs +++ b/unknown-tokens/src/lib.rs @@ -26,12 +26,8 @@ pub mod module { pub enum Event { /// Deposit success. [asset, to] Deposited(MultiAsset, MultiLocation), - /// Deposit failed. [asset, to, error] - DepositFailed(MultiAsset, MultiLocation, DispatchError), /// Withdraw success. [asset, from] Withdrawn(MultiAsset, MultiLocation), - /// Withdraw failed. [asset, from, error] - WithdrawFailed(MultiAsset, MultiLocation, DispatchError), } #[pallet::error] @@ -74,7 +70,7 @@ pub mod module { impl UnknownAsset for Pallet { fn deposit(asset: &MultiAsset, to: &MultiLocation) -> DispatchResult { - let result = match asset { + match asset { MultiAsset::ConcreteFungible { id, amount } => { ConcreteFungibleBalances::::try_mutate(to, id, |b| -> DispatchResult { *b = b.checked_add(*amount).ok_or(Error::::BalanceOverflow)?; @@ -88,19 +84,15 @@ impl UnknownAsset for Pallet { }) } _ => Err(Error::::UnhandledAsset.into()), - }; + }?; - if let Err(err) = result { - Self::deposit_event(Event::DepositFailed(asset.clone(), to.clone(), err)); - } else { - Self::deposit_event(Event::Deposited(asset.clone(), to.clone())); - } + Self::deposit_event(Event::Deposited(asset.clone(), to.clone())); - result + Ok(()) } fn withdraw(asset: &MultiAsset, from: &MultiLocation) -> DispatchResult { - let result = match asset { + match asset { MultiAsset::ConcreteFungible { id, amount } => { ConcreteFungibleBalances::::try_mutate(from, id, |b| -> DispatchResult { *b = b.checked_sub(*amount).ok_or(Error::::BalanceTooLow)?; @@ -114,14 +106,10 @@ impl UnknownAsset for Pallet { }) } _ => Err(Error::::UnhandledAsset.into()), - }; + }?; - if let Err(err) = result { - Self::deposit_event(Event::WithdrawFailed(asset.clone(), from.clone(), err)); - } else { - Self::deposit_event(Event::Withdrawn(asset.clone(), from.clone())); - } + Self::deposit_event(Event::Withdrawn(asset.clone(), from.clone())); - result + Ok(()) } } diff --git a/unknown-tokens/src/tests.rs b/unknown-tokens/src/tests.rs index b2cb39627..cc5c60686 100644 --- a/unknown-tokens/src/tests.rs +++ b/unknown-tokens/src/tests.rs @@ -48,15 +48,6 @@ fn deposit_concrete_fungible_asset_works() { UnknownTokens::deposit(&max_asset, &MOCK_RECIPIENT), Error::::BalanceOverflow ); - - let deposit_failed_event = Event::unknown_tokens(crate::Event::DepositFailed( - max_asset, - MOCK_RECIPIENT, - Error::::BalanceOverflow.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == deposit_failed_event)); }); } @@ -83,15 +74,6 @@ fn deposit_abstract_fungible_asset() { UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id()), 3 ); - - let deposit_failed_event = Event::unknown_tokens(crate::Event::DepositFailed( - max_asset, - MOCK_RECIPIENT, - Error::::BalanceOverflow.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == deposit_failed_event)); }); } @@ -102,15 +84,6 @@ fn deposit_unhandled_asset_should_fail() { UnknownTokens::deposit(&MultiAsset::All, &MOCK_RECIPIENT), Error::::UnhandledAsset ); - - let deposit_failed_event = Event::unknown_tokens(crate::Event::DepositFailed( - MultiAsset::All, - MOCK_RECIPIENT, - Error::::UnhandledAsset.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == deposit_failed_event)); }); } @@ -134,15 +107,6 @@ fn withdraw_concrete_fungible_asset_works() { UnknownTokens::withdraw(&asset, &MOCK_RECIPIENT), Error::::BalanceTooLow ); - - let withdraw_failed_event = Event::unknown_tokens(crate::Event::WithdrawFailed( - asset, - MOCK_RECIPIENT, - Error::::BalanceTooLow.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == withdraw_failed_event)); }); } @@ -166,15 +130,6 @@ fn withdraw_abstract_fungible_asset_works() { UnknownTokens::withdraw(&asset, &MOCK_RECIPIENT), Error::::BalanceTooLow ); - - let withdraw_failed_event = Event::unknown_tokens(crate::Event::WithdrawFailed( - asset, - MOCK_RECIPIENT, - Error::::BalanceTooLow.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == withdraw_failed_event)); }); } @@ -185,14 +140,5 @@ fn withdraw_unhandled_asset_should_fail() { UnknownTokens::withdraw(&MultiAsset::All, &MOCK_RECIPIENT), Error::::UnhandledAsset ); - - let withdraw_failed_event = Event::unknown_tokens(crate::Event::WithdrawFailed( - MultiAsset::All, - MOCK_RECIPIENT, - Error::::UnhandledAsset.into(), - )); - assert!(System::events() - .iter() - .any(|record| record.event == withdraw_failed_event)); }); }