api: AssetId always converted to Multilocation or errors with numbers other than 0

Bug report

At Zeitgeist we use pallet-asset-tx-payment to pay fees in other currencies. We use it like this:

const keyring = new Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice", { name: "Alice default" });
const signedTx = await tx.signAsync(alice, {assetId: 0});

However now that we are using the latest version assetId is being forced into a Multilocation or in other cases it just errors.

Here are some examples:

const signedTx = await tx.signAsync(alice, {assetId: 0});
console.log(signTx.assetId) // {"parents": "0","interior": "Here"}
const signedTx = await tx.signAsync(alice, {assetId: 1});
console.log(signTx.assetId) // "Error: Struct: failed on assetId: Option<MultiLocation>:: Struct: Cannot decode value 1 (typeof number), expected an input object, map or array"

Moving forward we would like to use arbitrary values like this but run into similar issues:

const signedTx = await tx.signAsync(alice, {assetId: { ForeignAsset: 0 }});
console.log(signTx.assetId) // {"parents": "0","interior": "Here"}
const signedTx = await tx.signAsync(alice, {assetId: { ForeignAsset: 1 }});
console.log(signTx.assetId) // {"parents": "0","interior": "Here"}

Seems related to the changes made in this pr: https://github.com/polkadot-js/api/pull/5752

  • Please tell us about your environment:
  • Version: 10.12.6

  • Environment:

    • Node.js
    • Browser
    • Other (limited support for other environments)
  • Language:

    • JavaScript
    • TypeScript (include tsc --version)
    • Other

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 16 (5 by maintainers)

Most upvoted comments

We are very close to releasing a new version of the extension.

Also it might be worth checking to see if this works against the most recent version of the extension in github, instructions on how to run it in the README

@gagi13 I’m not too sure about that as the correct overrides should already be there for the asset hubs. I would try different wallets and versions of polkadot js. It seems like there hasn’t been a release published for polkadot js extension for a while now.