feat(sdk): Add MultiLocation override feature ⛓️ #199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR request adds a feature to allow integration of MultiLocation objects in the transfer process. Instead of passing currency, address and destination traditionally, you can pass a MultiLocation object instead which will override default behaviour. This brings flexibility and customization to our SDK.
The Builder methods to(), currency() and address() have been modified to accept a MultiLocation type.
The MultiLocation object has the following structure:
The interior has to have one of the following keys:
X1, X2, X3, X4, X5, X6, X7, X8
. The Junctions enum can represent zero to eight steps down the hierarchy.When using X1 ,pass the object as the value:
X1: {}
, otherwise use arrayX2: []
.Then in the object or array we can specify the junction type. We can only choose as many junctions as the number after X says. Otherwise a TS error will be thrown. These are available junctions:
An example of overriding address in ParaToPara call:
We can do the same with
currency()
andto()
(destination).An example of overriding currency in ParaToPara call:
An example of overriding destination in ParaToPara call:
However when the origin Parachain uses
XTokens
orXTransfer
pallet MultiLocation destinations are not supported. In this case you need to use the address multilocation for both destination and address. Here is an example of such MultiLocation:For PolkadotXCM you can use all 3 options separately.