Skip to content

Commit

Permalink
add KSM to AssetHub configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Oct 9, 2024
1 parent 423871a commit e93e44d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
31 changes: 31 additions & 0 deletions packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,36 @@ export function polkadotXcm() {
}),
};
},
trasferAssets: () => {
const func = 'transferAssets';

return {
here: (): ExtrinsicConfigBuilder => ({
build: (params) =>
new ExtrinsicConfig({
module: pallet,
func,
getArgs: (extrinsicFunction) =>
getPolkadotXcmExtrinsicArgs({
...params,
func: extrinsicFunction,
asset: [
{
id: {
Concrete: {
parents: 1,
interior: 'Here',
},
},
fun: {
Fungible: params.amount,
},
},
],
}),
}),
}),
};
},
};
}
1 change: 1 addition & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ export const kusamaAssetHub = new Parachain({
metadataId: 9999999,
},
],
checkSovereignAccountBalances: true,
ecosystem: Ecosystem.Kusama,
genesisHash:
'0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a',
Expand Down
18 changes: 18 additions & 0 deletions packages/config/src/configs/kusamaAssetHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ export const kusamaAssetHubConfig = new ChainConfig({
},
min: AssetMinBuilder().assets().asset(),
}),
new AssetConfig({
asset: ksm,
balance: BalanceBuilder().substrate().system().account(),
destination: moonriver,
destinationFee: {
amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({
isAssetReserveChain: false,
}),
asset: ksm,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilder().polkadotXcm().trasferAssets().here(),
fee: {
asset: ksm,
balance: BalanceBuilder().substrate().system().account(),
xcmDeliveryFeeAmount,
},
}),
],
chain: kusamaAssetHub,
});
15 changes: 15 additions & 0 deletions packages/config/src/configs/moonriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ export const moonriverConfig = new ChainConfig({
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: ksm,
balance: BalanceBuilder().substrate().assets().account(),
contract: ContractBuilder().Xtokens().transfer(),
destination: kusamaAssetHub,
destinationFee: {
amount: 0.0003,
asset: ksm,
balance: BalanceBuilder().substrate().assets().account(),
},
fee: {
asset: movr,
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: mgx,
balance: BalanceBuilder().substrate().assets().account(),
Expand Down
9 changes: 2 additions & 7 deletions packages/sdk/src/getTransferData/getTransferData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
ContractConfig,
SubstrateQueryConfig,
} from '@moonbeam-network/xcm-builder';
import {
AssetConfig,
FeeAssetConfig,
polkadotAssetHub,
} from '@moonbeam-network/xcm-config';
import { AssetConfig, FeeAssetConfig } from '@moonbeam-network/xcm-config';
import { AnyChain, Asset, EvmParachain } from '@moonbeam-network/xcm-types';
import { convertDecimals, toBigInt } from '@moonbeam-network/xcm-utils';
import {
Expand Down Expand Up @@ -125,8 +121,7 @@ export function validateSovereignAccountBalances({
destination,
}: ValidateSovereignAccountBalancesProps): void {
if (
destination.chain.key !== polkadotAssetHub.key ||
// currently we want this only for this chain
!destination.chain.checkSovereignAccountBalances ||
!destination.sovereignAccountBalances
) {
return;
Expand Down

0 comments on commit e93e44d

Please sign in to comment.