Skip to content

Commit 3422f01

Browse files
author
Freddy Li
authored
feat: Change generalIndex to generalKey in extract dest data method (#62)
1 parent 798236c commit 3422f01

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

bridge/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ pub mod pallet {
11361136
GeneralKey(
11371137
WeakBoundedVec::try_from(b"ethereum recipient".to_vec()).unwrap()
11381138
),
1139-
GeneralIndex(1)
1139+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
11401140
)
11411141
)
11421142
.into(),
@@ -1245,7 +1245,7 @@ pub mod pallet {
12451245
GeneralKey(
12461246
WeakBoundedVec::try_from(b"ethereum recipient".to_vec()).unwrap()
12471247
),
1248-
GeneralIndex(1)
1248+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
12491249
)
12501250
)
12511251
.into(),
@@ -1302,7 +1302,7 @@ pub mod pallet {
13021302
WeakBoundedVec::try_from(b"ethereum recipient".to_vec())
13031303
.unwrap()
13041304
),
1305-
GeneralIndex(1)
1305+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
13061306
)
13071307
)
13081308
.into(),
@@ -1374,7 +1374,7 @@ pub mod pallet {
13741374
WeakBoundedVec::try_from(b"ethereum recipient".to_vec())
13751375
.unwrap()
13761376
),
1377-
GeneralIndex(1)
1377+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
13781378
)
13791379
)
13801380
.into(),
@@ -1414,7 +1414,7 @@ pub mod pallet {
14141414
WeakBoundedVec::try_from(b"ethereum recipient".to_vec())
14151415
.unwrap()
14161416
),
1417-
GeneralIndex(1)
1417+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
14181418
)
14191419
)
14201420
.into(),
@@ -1459,7 +1459,7 @@ pub mod pallet {
14591459
WeakBoundedVec::try_from(b"ethereum recipient".to_vec())
14601460
.unwrap()
14611461
),
1462-
GeneralIndex(1)
1462+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
14631463
)
14641464
)
14651465
.into(),
@@ -1478,7 +1478,7 @@ pub mod pallet {
14781478
GeneralKey(
14791479
WeakBoundedVec::try_from(b"ethereum recipient".to_vec()).unwrap()
14801480
),
1481-
GeneralIndex(1)
1481+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
14821482
)
14831483
)
14841484
.into(),
@@ -1509,7 +1509,7 @@ pub mod pallet {
15091509
WeakBoundedVec::try_from(b"ethereum recipient".to_vec())
15101510
.unwrap()
15111511
),
1512-
GeneralIndex(1)
1512+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
15131513
)
15141514
)
15151515
.into(),
@@ -1613,7 +1613,7 @@ pub mod pallet {
16131613
GeneralKey(
16141614
WeakBoundedVec::try_from(b"ethereum recipient".to_vec()).unwrap()
16151615
),
1616-
GeneralIndex(1)
1616+
GeneralKey(WeakBoundedVec::try_from(vec![1]).unwrap())
16171617
)
16181618
)
16191619
.into(),

bridge/src/mock.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use frame_support::{
1010
PalletId,
1111
};
1212
use frame_system::{self as system, EnsureSigned};
13-
use funty::Fundamental;
1413
use polkadot_parachain::primitives::Sibling;
1514
use sp_core::hash::H256;
1615
use sp_runtime::{
@@ -348,8 +347,14 @@ pub struct DestinationDataParser;
348347
impl ExtractDestinationData for DestinationDataParser {
349348
fn extract_dest(dest: &MultiLocation) -> Option<(Vec<u8>, DomainID)> {
350349
match (dest.parents, &dest.interior) {
351-
(0, Junctions::X2(GeneralKey(recipient), GeneralIndex(dest_domain_id))) =>
352-
Some((recipient.to_vec(), dest_domain_id.as_u8())),
350+
(0, Junctions::X2(GeneralKey(recipient), GeneralKey(dest_domain_id))) => {
351+
let d = u8::default();
352+
let domain_id = dest_domain_id.as_slice().first().unwrap_or(&d);
353+
if *domain_id == d {
354+
return None
355+
}
356+
Some((recipient.to_vec(), *domain_id))
357+
},
353358
_ => None,
354359
}
355360
}

substrate-node/runtime/src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
1111

1212
use frame_support::{pallet_prelude::*, PalletId};
13-
use funty::Fundamental;
1413
use pallet_grandpa::{
1514
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
1615
};
@@ -415,7 +414,7 @@ parameter_types! {
415414
// NativeResourceId is the resourceID that mapping with the current parachain native asset
416415
pub NativeResourceId: ResourceId = hex_literal::hex!("0000000000000000000000000000000000000000000000000000000000000001");
417416
// UsdcResourceId is the resourceID that mapping with the foreign asset USDC
418-
pub UsdcResourceId: ResourceId = hex_literal::hex!("0000000000000000000000000000000000000000000000000000000000000000");
417+
pub UsdcResourceId: ResourceId = hex_literal::hex!("0000000000000000000000000000000000000000000000000000000000000300");
419418
// UsdcAssetId is the substrate assetID of USDC
420419
pub UsdcAssetId: AssetId = 2000;
421420
// ResourcePairs is where all supported assets and their associated resourceID are binding
@@ -568,8 +567,14 @@ pub struct DestinationDataParser;
568567
impl ExtractDestinationData for DestinationDataParser {
569568
fn extract_dest(dest: &MultiLocation) -> Option<(Vec<u8>, DomainID)> {
570569
match (dest.parents, &dest.interior) {
571-
(0, Junctions::X2(GeneralKey(recipient), GeneralIndex(dest_domain_id))) =>
572-
Some((recipient.to_vec(), dest_domain_id.as_u8())),
570+
(0, Junctions::X2(GeneralKey(recipient), GeneralKey(dest_domain_id))) => {
571+
let d = u8::default();
572+
let domain_id = dest_domain_id.as_slice().first().unwrap_or(&d);
573+
if *domain_id == d {
574+
return None
575+
}
576+
Some((recipient.to_vec(), *domain_id))
577+
},
573578
_ => None,
574579
}
575580
}

0 commit comments

Comments
 (0)