-
Notifications
You must be signed in to change notification settings - Fork 350
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
Problem using ChargeAssetTxPayment SignedExtension #5710
Comments
TLDR:
|
As a possible solution we can apply a fix here:
By unwrapping the optional value we'll get the proper value we need:
|
Great investigation! We are seeing the same issue at Zeitgeist, we have added |
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. |
I was trying to check the
ChargeAssetTxPayment
SignedExtension and noticed an issue with the data encoding/decoding, which prevents us from using such an extension.In the beginning, I've noticed the tx goes through and works well when I use the KeyPair and submit it in this way:
Next, I tried to use a similar approach and inject a signer (could be from web extension or simulated like in the code below):
And that tx fails!
By logging the received data in the node, I discovered that instead of assetId=1 the runtime receives assetId=16777216.
After days of debugging, I was able to reconstruct the whole data-flow:
const payload = this.registry.createTypeUnsafe<SignerPayload>('SignerPayload'....
if (isFunction(signer.signPayload)) { result = await signer.signPayload(payload.toPayload()); }
super.addSignature(address, result.signature, payload.toPayload());
if we log the assetId (
console.log(payload.toPayload().assetId);
) it will print0x01000000
.That's because it converts all the values to hex here and
api.createType('Option<u32>', 1).toHex()
returns0x01000000
.ExtrinsicPayload
:const extrinsicPayload = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version });
Once I logged the asset id from
extrinsicPayload
I received 16777216console.log(extrinsicPayload.toHuman().assetId.toString());
I assume this is because
api.createType('Option<u32>', '0x01000000').toString()
returns 16777216A quick way to reproduce (e.g. put the code below into this spec file):
The text was updated successfully, but these errors were encountered: