Files
pezkuwi-sdk/pezbridges/pezsnowbridge/test-utils/src/mock_swap_executor.rs
T
pezkuwichain 6b597bebcf fix: EnsureOrigin try_successful_origin and snowbridge rename
- Fix pezpallet-welati EnsureOrigin implementations (3 fixes)
  - Remove incorrect #[cfg(not(feature = "runtime-benchmarks"))] blocks
  - Affects EnsureSerok, EnsureParlementer, EnsureDiwan

- Fix asset-hub-zagros governance origins macros (2 fixes)
  - Remove non-benchmark try_successful_origin from decl_unit_ensures!
  - Remove non-benchmark try_successful_origin from decl_ensure!

- Rename snowbridge -> pezsnowbridge for consistency

- Update WORKFLOW_PLAN.md with build status and package names
  - Correct package names: pezkuwi-teyrchain-bin, pezstaging-node-cli
  - Mark completed builds: pezkuwi, pezkuwi-teyrchain-bin,
    pezstaging-node-cli, teyrchain-template-node
2025-12-25 01:26:18 +03:00

49 lines
1.2 KiB
Rust

// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
use pezframe_support::pezpallet_prelude::DispatchError;
use pezpallet_asset_conversion::Swap;
use xcm::opaque::latest::Location;
pub struct SwapExecutor;
pub const TRIGGER_SWAP_ERROR_AMOUNT: u128 = 12345;
impl<AccountId> Swap<AccountId> for SwapExecutor
where
AccountId: AsRef<[u8; 32]>,
{
type Balance = u128;
type AssetKind = Location;
fn max_path_len() -> u32 {
2
}
fn swap_exact_tokens_for_tokens(
_sender: AccountId,
_path: Vec<Self::AssetKind>,
amount_in: Self::Balance,
_amount_out_min: Option<Self::Balance>,
_send_to: AccountId,
_keep_alive: bool,
) -> Result<Self::Balance, DispatchError> {
// Special case for testing SwapError:
// If amount_in is exactly 12345, return an error
if amount_in == TRIGGER_SWAP_ERROR_AMOUNT {
return Err(DispatchError::Other("Swap failed for test"));
}
Ok(1_000_000_000u128)
}
fn swap_tokens_for_exact_tokens(
_sender: AccountId,
_path: Vec<Self::AssetKind>,
_amount_out: Self::Balance,
_amount_in_max: Option<Self::Balance>,
_send_to: AccountId,
_keep_alive: bool,
) -> Result<Self::Balance, DispatchError> {
unimplemented!()
}
}