Skip to content

Commit

Permalink
fix the substrate dependency compile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy Li authored and Freddy Li committed Jan 5, 2024
1 parent 9fb92c9 commit be06eff
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions bridge-forwarder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ std = [
"xcm/std",
"xcm-builder/std",
"xcm-executor/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"cumulus-pallet-xcm/std",
"sygma-traits/std",
]
runtime-benchmarks = [
Expand Down
5 changes: 5 additions & 0 deletions bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ std = [
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"cumulus-pallet-xcm/std",
"xcm/std",
"xcm-builder/std",
"xcm-executor/std",
Expand All @@ -106,5 +109,7 @@ std = [
"sygma-basic-feehandler/std",
"sygma-percentage-feehandler/std",
"sygma-fee-handler-router/std",
"sygma-bridge-forwarder/std",
"sygma-xcm-bridge/std",
]
try-runtime = ["frame-support/try-runtime"]
12 changes: 6 additions & 6 deletions bridge/src/xcm_asset_transactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use codec::Encode;
use xcm::latest::{Junction, MultiAsset, MultiLocation, XcmContext};
use xcm::prelude::*;
use xcm_executor::{Assets, traits::TransactAsset};

use hex_literal::hex;
use sygma_traits::{AssetTypeIdentifier, TransactorForwarder};

use crate::mock::slice_to_generalkey;

pub struct XCMAssetTransactor<CurrencyTransactor, FungiblesTransactor, AssetTypeChecker, Forwarder>(PhantomData<(CurrencyTransactor, FungiblesTransactor, AssetTypeChecker, Forwarder)>);

impl<CurrencyTransactor: TransactAsset, FungiblesTransactor: TransactAsset, AssetTypeChecker: AssetTypeIdentifier, Forwarder: TransactorForwarder> TransactAsset for XCMAssetTransactor<CurrencyTransactor, FungiblesTransactor, AssetTypeChecker, Forwarder> {
Expand All @@ -32,7 +30,9 @@ impl<CurrencyTransactor: TransactAsset, FungiblesTransactor: TransactAsset, Asse
(1, Some(Parachain(_))) => {
// 2. recipient is on non-substrate chain(evm, cosmos, etc.), will forward to sygma bridge pallet
match who.interior {
(X5(Parachain(1000), slice_to_generalkey(b"sygma"), slice_to_generalkey(b"sygma-bridge"), GeneralIndex(..), GeneralKey { .. })) => {
// sygma: 7379676d61000000000000000000000000000000000000000000000000000000
// sygma-bridge: 7379676d612d6272696467650000000000000000000000000000000000000000
X5(Parachain(1000), GeneralKey { length: 5, data: hex!["7379676d61000000000000000000000000000000000000000000000000000000"]}, GeneralKey { length: 12, data: hex!["7379676d612d6272696467650000000000000000000000000000000000000000"]}, GeneralIndex(..), GeneralKey { .. }) => {
// check if the asset is native or foreign, and deposit the asset to a tmp account first
let tmp_account = sp_io::hashing::blake2_256(&MultiLocation::new(0, X1(GeneralKey { length: 8, data: [2u8; 32] })).encode());
if AssetTypeChecker::is_native_asset(what) {
Expand All @@ -41,7 +41,7 @@ impl<CurrencyTransactor: TransactAsset, FungiblesTransactor: TransactAsset, Asse
FungiblesTransactor::deposit_asset(&what.clone(), &Junction::AccountId32 { network: None, id: tmp_account }.into(), context)?
}

Forwarder::other_world_transactor_forwarder(tmp_account, what.clone(), who.into()).map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Forwarder::other_world_transactor_forwarder(tmp_account, what.clone(), *who).map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
}
_ => {
// 3. recipient is on remote parachain
Expand All @@ -56,7 +56,7 @@ impl<CurrencyTransactor: TransactAsset, FungiblesTransactor: TransactAsset, Asse
FungiblesTransactor::deposit_asset(&what.clone(), &Junction::AccountId32 { network: None, id: tmp_account }.into(), context)?
}

Forwarder::xcm_transactor_forwarder(tmp_account, what.clone(), who.into()).map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Forwarder::xcm_transactor_forwarder(tmp_account, what.clone(), *who).map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions xcm-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ std = [
"xcm/std",
"xcm-builder/std",
"xcm-executor/std",
"pallet-balances/std",
"pallet-assets/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"cumulus-pallet-xcm/std",
"sygma-traits/std",
"sygma-bridge-forwarder/std",

]
runtime-benchmarks = [
'frame-support/runtime-benchmarks',
Expand Down
1 change: 1 addition & 0 deletions xcm-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub mod pallet {
Some(TransferKind::ToNonReserve)
}
}

fn create_instructions(&self) -> Result<Xcm<T::RuntimeCall>, DispatchError> {
let kind = Self::transfer_kind(self).ok_or(Error::<T>::UnknownTransferType)?;

Expand Down

0 comments on commit be06eff

Please sign in to comment.