Skip to content

Commit

Permalink
Fixed xcm config for PINK
Browse files Browse the repository at this point in the history
  • Loading branch information
ekenigs committed Mar 12, 2024
1 parent b1e51b8 commit 7bd7269
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
74 changes: 51 additions & 23 deletions packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,61 @@ export function polkadotXcm() {
new ExtrinsicConfig({
module: pallet,
func,
getArgs: (extrinsicFunction) =>
getPolkadotXcmExtrinsicArgs({
...params,
func: extrinsicFunction,
asset: [
{
id: {
Concrete: {
parents: 0,
interior: {
X2: [
{
PalletInstance: params.palletInstance,
},
{
GeneralIndex: params.asset,
},
],
},
getArgs: (extrinsicFunction) => {
const isAssetDifferent = params.asset !== params.feeAsset;
const asset = [
{
id: {
Concrete: {
parents: 0,
interior: {
X2: [
{
PalletInstance: params.palletInstance,
},
{
GeneralIndex: params.asset,
},
],
},
},
fun: {
Fungible: params.amount,
},
fun: {
Fungible: params.amount,
},
},
];

if (isAssetDifferent) {
asset.push({
id: {
Concrete: {
parents: 0,
interior: {
X2: [
{
PalletInstance: params.palletInstance,
},
{
GeneralIndex: params.feeAsset,
},
],
},
},
},
],
}),
fun: {
Fungible: params.fee,
},
});
}

return getPolkadotXcmExtrinsicArgs({
...params,
func: extrinsicFunction,
asset,
feeIndex: isAssetDifferent ? 1 : 0,
});
},
}),
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface GetExtrinsicParams extends ExtrinsicConfigBuilderPrams {
asset: any;
func?: SubmittableExtrinsicFunction<'promise'>;
parents?: Parents;
feeIndex?: number;
}

export function getPolkadotXcmExtrinsicArgs({
Expand All @@ -21,6 +22,7 @@ export function getPolkadotXcmExtrinsicArgs({
destination,
func,
parents = 1,
feeIndex = 0,
}: GetExtrinsicParams): any[] {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const version = getExtrinsicArgumentVersion(func);
Expand All @@ -47,7 +49,7 @@ export function getPolkadotXcmExtrinsicArgs({
{
[version]: asset,
},
0,
feeIndex,
'Unlimited',
];
}
4 changes: 2 additions & 2 deletions packages/config/src/configs/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ export const moonbeamConfig = new ChainConfig({
contract: ContractBuilder().Xtokens().transfer(),
destination: polkadotAssetHub,
destinationFee: {
amount: 0.7, // TODO
asset: pink,
amount: 0.7,
asset: usdt,
balance: BalanceBuilder().substrate().assets().account(),
},
fee: {
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/configs/polkadotAssetHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export const polkadotAssetHubConfig = new ChainConfig({
balance: BalanceBuilder().substrate().assets().account(),
destination: moonbeam,
destinationFee: {
amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), // TODO confirm
asset: pink,
amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(),
asset: usdt,
balance: BalanceBuilder().substrate().assets().account(),
},
extrinsic: ExtrinsicBuilder()
Expand Down

0 comments on commit 7bd7269

Please sign in to comment.