Skip to content

Commit

Permalink
support native eth in outbound queue
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Dec 17, 2024
1 parent 41bed52 commit dd51d23
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions bridges/snowbridge/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ where
match inner_location.unpack() {
(0, [AccountKey20 { network, key }]) if self.network_matches(network) =>
Some((H160(*key), *amount)),
(0, []) => Some((H160([0; 20]), *amount)),
_ => None,
},
_ => None,
Expand Down
35 changes: 35 additions & 0 deletions bridges/snowbridge/primitives/router/src/outbound/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,41 @@ fn xcm_converter_convert_with_wildcard_all_asset_filter_succeeds() {
assert_eq!(result, Ok((expected_payload, [0; 32])));
}

#[test]
fn xcm_converter_convert_with_native_eth_succeeds() {
let network = BridgedNetwork::get();

let token_address: [u8; 20] = [0; 20];
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");

let assets: Assets = vec![Asset { id: AssetId([].into()), fun: Fungible(1000) }].into();
let filter: AssetFilter = Wild(All);

let message: Xcm<()> = vec![
WithdrawAsset(assets.clone()),
ClearOrigin,
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
DepositAsset {
assets: filter,
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
},
SetTopic([0; 32]),
]
.into();
let mut converter =
XcmConverter::<MockTokenIdConvert, ()>::new(&message, network, Default::default());
let expected_payload = Command::AgentExecute {
agent_id: Default::default(),
command: AgentExecuteCommand::TransferToken {
token: token_address.into(),
recipient: beneficiary_address.into(),
amount: 1000,
},
};
let result = converter.convert();
assert_eq!(result, Ok((expected_payload, [0; 32])));
}

#[test]
fn xcm_converter_convert_with_fees_less_than_reserve_yields_success() {
let network = BridgedNetwork::get();
Expand Down

0 comments on commit dd51d23

Please sign in to comment.