Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LocationToAccountId converter for GlobalConsensus(..) #986

Closed
2 tasks
green-jay opened this issue Jan 10, 2025 · 1 comment
Closed
2 tasks

Add LocationToAccountId converter for GlobalConsensus(..) #986

green-jay opened this issue Jan 10, 2025 · 1 comment

Comments

@green-jay
Copy link
Contributor

green-jay commented Jan 10, 2025

Description

Currently there is no way of translating foreign consensus xcm origins to AccountIds. There are two scenarios at hand where this will be useful:

1. Transacting on Hydration from Kusama accounts
E.g. Adding KSM to Omnipool from Kusama treasury. It will be assigned the ownership of the LP position so it can trustlessly control it. But also any signed origin, parachain, etc. should be able to operate on Hydration remotely from Kusama.

2. BSX listing
Similar case as above, BSX can be listed from Basilisk treasury and controlled remotely via XCM.

Will be done via GlobalConsensusParachainConvertsFor once we upgrade to newer SDK.

Tasklist:

  • GlobalConsensus(Kusama) is supported

Future work:

  • GlobalConsensus(Parachain(Root)) is supported

Auxiliary info

Relevant configuration:

pub type LocationToAccountId = (

We could use/inspire by GlobalConsensusConvertsFor for Kusama and GlobalConsensusParachainConvertsFor for Parachains on Kusama.

Test snippet (failing currently, should pass):

#[test]
fn assert_kusama_root_account() {
    // Initialize the Externalities environment
    sp_io::TestExternalities::new_empty().execute_with(|| {
        let ksm_root_location = Location::new(2, [GlobalConsensus(Kusama)]);
        let ksm_root_account = GlobalConsensusConvertsFor::<UniversalLocation, AccountId>::convert_location(&ksm_root_location)
            .expect("Failed to convert location");

        // // Example treasury account, replace with the actual expected value
        let expected_account = AccountId::from_ss58check("5G4KKqSKDkiMGiPzCQY12dSB15aBikyNQJL9VDmbMH4SxiWD")
            .expect("Invalid SS58 address format");
        assert_eq!(ksm_root_account, expected_account);

        // // Example of a wrong account
        let wrong_account = AccountId::from_ss58check("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY")
            .expect("Invalid SS58 address format");
        assert_ne!(ksm_root_account, wrong_account);
    });
}
@green-jay green-jay changed the title Add LocationToAccountId converter for GlobalConsensus(..) xcm origin Add LocationToAccountId converter for GlobalConsensus(..) Jan 10, 2025
@jak-pan
Copy link
Contributor

jak-pan commented Jan 21, 2025

done in #990

@jak-pan jak-pan closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants