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

XCM MultiLocation Written Format #188

Closed
ryanleecode opened this issue Mar 23, 2024 · 10 comments · Fixed by #189
Closed

XCM MultiLocation Written Format #188

ryanleecode opened this issue Mar 23, 2024 · 10 comments · Fixed by #189
Labels
enhancement New feature or request

Comments

@ryanleecode
Copy link
Contributor

Given a scale or JSON encoded XCM MultiLocation, there should be a tool that converts it into its human readable written format.

@dudo50
Copy link
Contributor

dudo50 commented Mar 23, 2024

Hey @ryanleecode, thank you for your suggestion! We will look into this shortly and let you know if we have any questions for you regarding this feature/tool you requested.

With kind regards,
Team ParaSpell

@dudo50 dudo50 added enhancement New feature or request good first issue Good for newcomers labels Mar 23, 2024
@dudo50
Copy link
Contributor

dudo50 commented Mar 23, 2024

@ryanleecode , we had deep dive to this issue. Could you please confirm us, if we understand correctly?

So you wish us to create function/tool/package, that converts lenghty JSON to something like this? :
../Parachain(2OO6)/Account(randomAddr)/PalletInstance(50)/GeneralIndex(1984)/Amount(randomAmount)

The above would be translated from :

//Parachain multilocation
V3:
    parents: '1'
    interior:
      X1:
        Parachain: 2,006

//Address multilocation
  V3:
    parents: '0'
    interior:
      X1:
        AccountId32:
          network: null
          id: 'accountID'

//Currency and amount multilocation
  V3:
    - id:
        Concrete:
          parents: '0'
          interior:
            X2:
              - PalletInstance: '50'
              - GeneralIndex: 1,984
      fun:
        Fungible: amount

If we understand your request correctly, could you please specify if the output format we mentioned suits your needs and if not, how would you format the output of the tool? Thanks you!

@ryanleecode
Copy link
Contributor Author

ryanleecode commented Mar 23, 2024

Is that an yaml array? I'm not sure what the structure is between the comments. But from what I understand there should be 1 parent and the interior field should be an array.

For example

{
  "parents": "0",
  "interior": {
    "X2": [
      {
        "PalletInstance": "50"
      },
      {
        "GeneralIndex": "41"
      }
    ]
  }
}

is equal to ./PalletInstance(50)/GeneralIndex(41)

If it had parent field set to "1", then it would be ../PalletInstance(50)/GeneralIndex(41).


If i were to take your example at then that looks like 3 separate XCM paths to me

../Parachain(2006)`
./AccountId32(null, accountID)
./PalletInstance(50)/GeneralIndex(1984)

There are also some examples in the PBA book. Make sure to use the down arrow on your keyboard instead of the right arrow: https://polkadot-blockchain-academy.github.io/pba-content/hong-kong-2024/syllabus/8-XCM/1-Core_Concepts_of_XCM/Core_Concepts_of_XCM_slides.html#/6

@dudo50
Copy link
Contributor

dudo50 commented Mar 23, 2024

Great, this helps a lot. We will work hard to bring this tool asap. We will ping you once it is ready.

With kind regards,
Team ParaSpell

@ryanleecode
Copy link
Contributor Author

@dudo50

Can you make this functionality its own separate package in the monorepo with minimal dependencies?

See the discussion here: polkadot-js/extension#1331 (comment)

@dudo50
Copy link
Contributor

dudo50 commented Mar 28, 2024

@ryanleecode , yes that is the plan. It is scheduled for development in pipeline for early april.

Will ping you afterward.

With kind regards,
Team ParaSpell

@dudo50
Copy link
Contributor

dudo50 commented Apr 7, 2024

@ryanleecode here is PR for the tool you requested: #189
The tool bears name XCM-Analyser and is standalone package with no PolkadotJS dependencies, only basic typescript deps as you requested.

We will let you know soon how you can try it. Please let us know then, if it works as you expected and if not, let us know what we can change.

@michaeldev5
Copy link
Collaborator

michaeldev5 commented Apr 7, 2024

Hello @ryanleecode,
I have added a script with an example code where you can see the output of the function based on provided MultiLocation object.

Instructions:

  1. Clone the xcm-tools monorepo
  2. Run pnpm install
  3. Run the example script with command pnpm --filter=xcm-analyser runExample

The file is located in the folder packages/xcm-analyser/scripts/example.ts. You can edit the file to try different multilocations.

There first example shows converting a single MultiLocation to URL. The second example shows how an XCM call arguments can be converted into an array of URLs where MultiLocations are automatically found using object comparison. These XCM arguments can be extracted from Extrinsics object using .args property.

Let us know your opinion.

With kind regards,
Team ParaSpell✨

@dudo50
Copy link
Contributor

dudo50 commented Apr 11, 2024

@ryanleecode one more thing, the package name is @paraspell/xcm-analyser

We will ping you once it is released (Should be within hour or two).

@dudo50 dudo50 removed the good first issue Good for newcomers label Apr 11, 2024
@michaeldev5
Copy link
Collaborator

@ryanleecode The XCM analyser package has been released:

https://www.npmjs.com/package/@paraspell/xcm-analyser

Let us know if you have any more concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants