Skip to content

Commit

Permalink
add transferAssetsUsingTypeAndThen function to xcmPallet and implemen…
Browse files Browse the repository at this point in the history
…t it to relay chains
  • Loading branch information
mmaurello committed Sep 10, 2024
1 parent f04570c commit afa59d7
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
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 afa59d7

Please sign in to comment.