Skip to content

Conversation

@zjb0807
Copy link
Contributor

@zjb0807 zjb0807 commented Sep 28, 2025

Closes: #2746

const assets = await api.call.xcmPaymentApi.queryAcceptablePaymentAssets(5);
const weightToAssets = await api.call.xcmPaymentApi.queryWeightToAssetFee(
  {
    refTime: 10_000_000_000n,
    profSize: 0n,
  },
  {
    V5: {
      parents: 1,
      interior: 'Here',
    }
  }
);

const xcmToWeight = await api.call.xcmPaymentApi.queryXcmWeight(
  {
    V5:
    [
          {
            Transact: {
              originKind: 'Superuser',
              requireWeightAtMost: {
                refTime: 200000000n,
                proofSize: 3000n,
              },
              call: {
                encoded: '0x0a040070617261d007000000000000000000000000000000000000000000000000000000',
              },
            }
          },
    ],
  },
);

const deliveryFees = await api.call.xcmPaymentApi.queryDeliveryFees(
    { v5: { parents: 1, interior: { x1: [{ parachain: 1000 }] } } },
    {
        V5: [
            {
            Transact: {
                originKind: 'SovereignAccount',
                requireWeightAtMost: {
                refTime: 200000000n,
                proofSize: 3000n
                },
                call: {
                encoded: '0x0000' // Simple call
                }
            }
            }
        ]
    },
);

console.log(
  'assets:', assets,
  '\nweightToAssets: ', weightToAssets,
  '\nxcmToWeight: ', xcmToWeight,
  '\ndeliveryFees: ', deliveryFees,
);


// dryRunCall & dryRunXcm
const transferCall = api.tx.balances.transferKeepAlive('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', '1000000000000');

const dryRunCallResult = await api.call.dryRunApi.dryRunCall(
  { system: { signed: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' } },
  transferCall.method.toHex(),
  5
);

const dryRunXcmResult = await api.call.dryRunApi.dryRunXcm(
  {
    v5: { parents: 1, interior: { x1: [{ parachain: 1000 }] } }
  },
  {
    V5:
    [
          {
            Transact: {
              originKind: 'Superuser',
              requireWeightAtMost: {
                refTime: 200000000n,
                proofSize: 3000n,
              },
              call: {
                encoded: '0x0a040070617261d007000000000000000000000000000000000000000000000000000000',
              },
            }
          },
    ],
  },
);

console.log(
  'dryRunCallResult:', dryRunCallResult,
  '\ndryRunXcmResult: ', dryRunXcmResult
);

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.92%. Comparing base (8a1b261) to head (82d9631).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2919      +/-   ##
==========================================
+ Coverage   61.90%   61.92%   +0.02%     
==========================================
  Files          69       69              
  Lines        9469     9469              
==========================================
+ Hits         5862     5864       +2     
+ Misses       3607     3605       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zjb0807 zjb0807 marked this pull request as ready for review September 28, 2025 08:35
@xlc xlc merged commit c7b8491 into master Sep 28, 2025
7 checks passed
@xlc xlc deleted the xcm-fee-api branch September 28, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

integrate XCM fee API

3 participants