Skip to content

Commit

Permalink
Change relay chains configuration (#345)
Browse files Browse the repository at this point in the history
* add transferAssetsUsingTypeAndThen function to xcmPallet and implement it to relay chains

* add changeset
  • Loading branch information
mmaurello authored Sep 10, 2024
1 parent f04570c commit 6fe69b2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/orange-lemons-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@moonbeam-network/xcm-builder': patch
'@moonbeam-network/xcm-config': patch
---

Add transferAssetsUsingTypeAndThen function to xcmPallet and implement it to relay chains
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum XcmVersion {
v1 = 'V1',
v2 = 'V2',
v3 = 'V3',
v4 = 'V4',
}

export type Parents = 0 | 1;
71 changes: 71 additions & 0 deletions packages/builder/src/extrinsic/pallets/xcmPallet/xcmPallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import {
ExtrinsicConfigBuilder,
Parents,
XcmVersion,
} from '../../ExtrinsicBuilder.interfaces';
import { getExtrinsicAccount } from '../../ExtrinsicBuilder.utils';
import { ExtrinsicConfig } from '../../ExtrinsicConfig';
import { getPolkadotXcmExtrinsicArgs } from '../polkadotXcm/polkadotXcm.util';

Expand Down Expand Up @@ -42,5 +44,74 @@ export function xcmPallet() {
}),
};
},
transferAssetsUsingTypeAndThen: () => {
const func = 'transferAssetsUsingTypeAndThen';

return {
here: (): ExtrinsicConfigBuilder => ({
build: (params) =>
new ExtrinsicConfig({
module: pallet,
func,
getArgs: () => {
const version = XcmVersion.v4;
return [
{
[version]: {
parents: 0,
interior: {
X1: [
{
Parachain: params.destination.parachainId,
},
],
},
},
},
{
[version]: [
{
id: {
parents: 0,
interior: 'Here',
},
fun: {
Fungible: params.amount,
},
},
],
},
'LocalReserve',
{
[version]: {
parents: 0,
interior: 'Here',
},
},
'LocalReserve',
{
[version]: [
{
DepositAsset: {
assets: {
Wild: { AllCounted: 1 },
},
beneficiary: {
parents: 0,
interior: {
X1: [getExtrinsicAccount(params.address)],
},
},
},
},
],
},
'Unlimited',
];
},
}),
}),
};
},
};
}
2 changes: 1 addition & 1 deletion packages/config/src/configs/alphanetRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const alphanetRelayConfig = new ChainConfig({
},
extrinsic: ExtrinsicBuilder()
.xcmPallet()
.limitedReserveTransferAssets(0)
.transferAssetsUsingTypeAndThen()
.here(),
}),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/configs/kusama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const kusamaConfig = new ChainConfig({
},
extrinsic: ExtrinsicBuilder()
.xcmPallet()
.limitedReserveTransferAssets(0)
.transferAssetsUsingTypeAndThen()
.here(),
fee: {
asset: ksm,
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/configs/polkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const polkadotConfig = new ChainConfig({
},
extrinsic: ExtrinsicBuilder()
.xcmPallet()
.limitedReserveTransferAssets(0)
.transferAssetsUsingTypeAndThen()
.here(),
fee: {
asset: dot,
Expand Down

0 comments on commit 6fe69b2

Please sign in to comment.