Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode overlaps "X3" with enum variant number of "JunctionV3" after extension sign #1503

Closed
Chralt98 opened this issue Jan 24, 2025 · 4 comments

Comments

@Chralt98
Copy link

Error: Struct: failed on assetId: Option<MultiLocationV3>:: decodeU8aStruct: failed at 0x010300a10f043205e514… on interior (index 2/2): {"_enum":{"Here":"Null","X1":"JunctionV3","X2":"(JunctionV3,JunctionV3)","X3":"(JunctionV3,JunctionV3,JunctionV3)","X4":"(JunctionV3,JunctionV3,JunctionV3,JunctionV3)","X5":"(JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3)","X6":"(JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3)","X7":"(JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3)","X8":"(JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3,JunctionV3)"}}:: decodeU8aStruct: failed at 0xa10f043205e514… on key (index 2/2): [u8;20]:: Expected input with 20 bytes (160 bits), found 7 bytes

In the above error it expects AccountKey20 (derived from [u8;20]). The index of this is 3 in JunctionV3. The assetId hex string always starts with 0x0103, in which 0x01 is used for parent: 1 and 0x03 should be used for X3 of JunctionsV3. However, the 0x03 occurs to be used not only for JunctionsV3 but also for the first entry into the tuple of X3, which is JunctionV3. So, it seems to be like a mistaken overlap for the decode functionality.

Image

I want to use the following assetId (which is USDC on AssetHub for our Zeitgeist Parachain):

let parentsNumber = api.registry.createType('u8', 1);
let parachainCompactNumber = api.registry.createType('Compact<u32>', 1000);
// let parachain = api.registry.createType('JunctionV3', { Parachain: parachainCompactNumber });
let palletInstanceNumber = api.registry.createType('u8', 50);
// let palletInstance = api.registry.createType('JunctionV3', { PalletInstance: palletInstanceNumber });
let generalIndexNumber = api.registry.createType('Compact<u128>', 1337);
// let generalIndex = api.registry.createType('JunctionV3', { GeneralIndex: generalIndexNumber });
let assetId = api.registry.createType('TAssetConversion', {
  // eslint-disable-next-line sort-keys
  // 0x010300a10f043205e514 (parachain, palletInstance, generalIndex) [1,1,3,0,161,15,4,50,5,229,20]
  // 0x010305e51400a10f0432 (generalIndex, parachain, palletInstance) [1,1,3,5,229,20,0,161,15,4,50]
  // 0x010300a10f05e5140432 (parachain, generalindex, palletInstance) [1,1,3,0,161,15,5,229,20,4,50]
  // 0x0103043200a10f05e514 (palletInstance, parachain, generalIndex) [1,1,3,4,50,0,161,15,5,229,20]
  // 0x0103043205e51400a10f (palletInstance, generalIndex, parachain) [1,1,3,4,50,5,229,20,0,161,15]
  // 0x010305e514043200a10f (generalindex, palletInstance, parachain) [1,1,3,5,229,20,4,50,0,161,15]
  // parents: 0x01 or [1,1]
  // interior x3: 0x03 or [3]
  // generalIndex: 0x05e514 or [5,229,20]; the 5 is the index of JunctionV3 enum
  // palletInstance: 0x0432 or [4,50]; the 4 is the index of JunctionV3 enum; 50 is the palletInstance number
  // parachain: 0x0a10f or [0,161,15]; the 0 is the index of JunctionV3 enum
  parents: parentsNumber,
  interior: {
    x3: [
      { parachain: parachainCompactNumber },
      { palletInstance: palletInstanceNumber },
      { generalIndex: generalIndexNumber },
    ],
  },
});

Here is some useful debug output of @polkadot/types-codec:

Image

Btw. I used a local fork of @polkadot/api and @polkadot/known-types to override the TAssetConversion for zeitgeist to be Option<MultiLocationV3>.

@Chralt98
Copy link
Author

Related to polkadot-js/api#6074

@TarikGul
Copy link
Member

Hey @Chralt98, Thanks for the PR. I saw the one in the api as well. I'll get to properly reviewing it Monday or Tuesday next week. Thanks for the patience.

@Chralt98
Copy link
Author

Oh, I've found the issue now. It is related to the SignerPayload assetId in signViaSigner. This is located in @polkadot/api, not in polkadot-js/extension. So, I'll close this issue here and reopen the same issue in the Polkadot API repository.

@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants