Skip to content

Commit

Permalink
WIP: query_xcm_weight_to_asset_fee estimates wrongly
Browse files Browse the repository at this point in the history
  • Loading branch information
x3c41a committed Nov 26, 2024
1 parent 443fc85 commit 274debb
Showing 1 changed file with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,83 @@ test("Initiate Teleport XCM v4", async () => {
})

test("Initiate Teleport XCM v5", async () => {
const xcm_origin_msg = Enum('V5', [
XcmV4Instruction.WithdrawAsset([
{
id: { parents: 1, interior: XcmV3Junctions.Here() },
fun: XcmV3MultiassetFungibility.Fungible(5_000_000_000_000n),
},

]),

Enum('PayFees', {
asset: {
id: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
}
}),
Enum('InitiateTransfer', {
destination: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
// optional field. an example of usage:
// remote_fees: Enum('Teleport', {
// type: 'Wild',
// value: {
// type: 'All',
// value: undefined,
// },
// }),
preserve_origin: false,
assets: [Enum('Teleport', {
type: 'Wild',
value: {
type: 'All',
value: undefined,
},
})],
remote_xcm: [
Enum('PayFees', {
asset: {
id: {
parents: 0,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
}
}),
XcmV4Instruction.DepositAsset({
assets: XcmV3MultiassetMultiAssetFilter.Definite([{
fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
id: { parents: 0, interior: XcmV3Junctions.Here() },
}]),
beneficiary: {
parents: 0,
interior: XcmV3Junctions.X1(XcmV3Junction.AccountId32({
network: undefined,
id: Binary.fromBytes(hdkdKeyPairBob.publicKey),
})),
},
}),
],
}),
]);

const xcm_origin_weight = await AHApi.apis.XcmPaymentApi.query_xcm_weight(xcm_origin_msg);
const weight_to_asset_fee = await AHApi.apis.XcmPaymentApi.query_weight_to_asset_fee(
{ ref_time: xcm_origin_weight.value.ref_time, proof_size: xcm_origin_weight.value.proof_size },
Enum('V5', {
parents: 1,
interior: XcmV3Junctions.Here(),
}),
);



const msg = Enum('V5', [
XcmV4Instruction.WithdrawAsset([
{
Expand All @@ -183,7 +260,7 @@ test("Initiate Teleport XCM v5", async () => {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(2_000_000_000_000n),
fun: XcmV3MultiassetFungibility.Fungible(weight_to_asset_fee.value),
}
}),
Enum('InitiateTransfer', {
Expand Down

0 comments on commit 274debb

Please sign in to comment.