polkadot-js / extension

Simple browser extension for managing Polkadot and Substrate network accounts in a browser. Allows the signing of extrinsics using these accounts. Also provides a simple interface for compliant extensions for dapps.
Apache License 2.0
968 stars 405 forks source link

Unable to sign transactions from extension but works with keyring #1269

Open Leouarz opened 1 year ago

Leouarz commented 1 year ago

Now the chain has a signed extensions but no additional signed. When debugging in the extension, i don't see any missing data. From the node itself, i compared correct and incorrect data and the only difference is in the signature (quite obvious I guess)

Working: AppUncheckedExtrinsic: Signed: 0687ecfe54a6970a799958522f58646c446891535cc54fa5cd0d7c3a8f6ab105 (5CDGXH8Q...), Signature: MultiSignature::Sr25519(7c01d7eb3ed15dbfa674c42555204c620592e9be10527cb2dea4a45bbf313b48e4d9ccd5f88a4f51f8cd2ea95def17d428819b6536fde28f15552dae54fcf98d), RawPayload: SignedPayload(call: RuntimeCall::Balances(Call::transfer_keep_alive { dest: MultiAddress::Id(581fc8e1118518d6073c2800a3e2dadac231e45eb8c73367bc24fb67e429fc4f (5E4FWi7V...)), value: 1000000000000000000 }), extra: (CheckNonZeroSender, CheckSpecVersion, CheckTxVersion, CheckGenesis, CheckMortality(Era::Mortal(64, 49)), CheckNonce(0), CheckWeight, ChargeTransactionPayment<0>, CheckAppId: 0), additional_signed: ((), 9, 1, 0x0692a0b7fa1b54f57f0f1e5c341231f8c56431b1c1ca45d23b94f57e21ff1272, 0xe9b397dc7e6cbbd596588a2562af0cc05d2608d91956218f54d7bbc5542b0ade, (), (), (), ()))

Non working: AppUncheckedExtrinsic: Signed: 0687ecfe54a6970a799958522f58646c446891535cc54fa5cd0d7c3a8f6ab105 (5CDGXH8Q...), Signature: MultiSignature::Sr25519(620c04627e7195b03ad21f5454830887fcbd6cf0b005bc1f6b7bfab63ca72e3122f3114bf6a5e776f747135818a3b6c8d72cd84be92016fccea993ca4f16e984), RawPayload: SignedPayload(call: RuntimeCall::Balances(Call::transfer_keep_alive { dest: MultiAddress::Id(581fc8e1118518d6073c2800a3e2dadac231e45eb8c73367bc24fb67e429fc4f (5E4FWi7V...)), value: 1000000000000000000 }), extra: (CheckNonZeroSender, CheckSpecVersion, CheckTxVersion, CheckGenesis, CheckMortality(Era::Mortal(64, 55)), CheckNonce(1), CheckWeight, ChargeTransactionPayment<0>, CheckAppId: 0), additional_signed: ((), 9, 1, 0x0692a0b7fa1b54f57f0f1e5c341231f8c56431b1c1ca45d23b94f57e21ff1272, 0x297ea3d04c56ffce1739904318c4bd566afac8fdd49f3baaf92a9a3ae8c53146, (), (), (), ()))

I tried testing from a test app, signing payload direct and setting up the types / registry and I have the same results. Using the keyring works, using the extension yields the same error.

The script can be found here. I pointed the function that does not work but the working one can be found. For reproduction, some test tokens can be given using this faucet and typing /deposit <address>

The initialisation of the API Promise can be found here.

Here's also the corresponding stalled stackexchange post

I was wondering if the chain was too heavily modified or if there is something I did not understand regarding the data that are signed.

Leouarz commented 1 year ago

It turns out, the extension even if aware that there is a signedExtension, does not know how to encode it, I had to use injector.metadata.provide(metadata) with the default metadata + the corresponding userExtensions.

My questions are:

Thanks for the time !!