-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert interpret as ETH for null address
- Loading branch information
1 parent
981d6c0
commit b985619
Showing
3 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::inbound::{MessageToXcm, TokenId}; | ||
use frame_support::parameter_types; | ||
use sp_runtime::{ | ||
traits::{IdentifyAccount, MaybeEquivalence, Verify}, | ||
MultiSignature, | ||
}; | ||
use xcm::prelude::*; | ||
|
||
pub const CHAIN_ID: u64 = 11155111; | ||
pub const NETWORK: NetworkId = Ethereum { chain_id: CHAIN_ID }; | ||
|
||
parameter_types! { | ||
pub EthereumNetwork: NetworkId = NETWORK; | ||
|
||
pub const CreateAssetCall: [u8;2] = [53, 0]; | ||
pub const CreateAssetExecutionFee: u128 = 2_000_000_000; | ||
pub const CreateAssetDeposit: u128 = 100_000_000_000; | ||
pub const SendTokenExecutionFee: u128 = 1_000_000_000; | ||
pub const InboundQueuePalletInstance: u8 = 80; | ||
pub UniversalLocation: InteriorLocation = | ||
[GlobalConsensus(Westend), Parachain(1002)].into(); | ||
pub AssetHubFromEthereum: Location = Location::new(1,[GlobalConsensus(Westend),Parachain(1000)]); | ||
} | ||
|
||
type Signature = MultiSignature; | ||
type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId; | ||
type Balance = u128; | ||
|
||
pub(crate) struct MockTokenIdConvert; | ||
impl MaybeEquivalence<TokenId, Location> for MockTokenIdConvert { | ||
fn convert(_id: &TokenId) -> Option<Location> { | ||
Some(Location::parent()) | ||
} | ||
fn convert_back(_loc: &Location) -> Option<TokenId> { | ||
None | ||
} | ||
} | ||
|
||
pub(crate) type MessageConverter = MessageToXcm< | ||
CreateAssetCall, | ||
CreateAssetDeposit, | ||
InboundQueuePalletInstance, | ||
AccountId, | ||
Balance, | ||
MockTokenIdConvert, | ||
UniversalLocation, | ||
AssetHubFromEthereum, | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
//! Converts messages from Ethereum to XCM messages | ||
#[cfg(test)] | ||
mod mock; | ||
#[cfg(test)] | ||
mod tests; | ||
|
||
|
@@ -168,7 +170,8 @@ impl< | |
ConvertAssetId, | ||
EthereumUniversalLocation, | ||
GlobalAssetHubLocation, | ||
> where | ||
> | ||
where | ||
CreateAssetCall: Get<CallIndex>, | ||
CreateAssetDeposit: Get<u128>, | ||
InboundQueuePalletInstance: Get<u8>, | ||
|
@@ -226,7 +229,8 @@ impl< | |
ConvertAssetId, | ||
EthereumUniversalLocation, | ||
GlobalAssetHubLocation, | ||
> where | ||
> | ||
where | ||
CreateAssetCall: Get<CallIndex>, | ||
CreateAssetDeposit: Get<u128>, | ||
InboundQueuePalletInstance: Get<u8>, | ||
|
@@ -390,10 +394,14 @@ impl< | |
|
||
// Convert ERC20 token address to a location that can be understood by Assets Hub. | ||
fn convert_token_address(network: NetworkId, token: H160) -> Location { | ||
Location::new( | ||
2, | ||
[GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }], | ||
) | ||
if token == H160([0; 20]) { | ||
Location::new(2, [GlobalConsensus(network)]) | ||
} else { | ||
Location::new( | ||
2, | ||
[GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }], | ||
) | ||
} | ||
} | ||
|
||
/// Constructs an XCM message destined for AssetHub that withdraws assets from the sovereign | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters