Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

TypeError: Cannot read property 'toNumber' of null when click "Scan" to send transaction from Parity Signer account #361

Closed
ltfschoen opened this issue Jan 16, 2019 · 6 comments
Assignees
Labels

Comments

@ltfschoen
Copy link
Contributor

ltfschoen commented Jan 16, 2019

I just tried using the latest 'master' branch with yarn; yarn start to send a transaction with some ETH from a Parity Signer account that I had imported. When I clicked the "Scan" button it displayed the following error message.

And when I restarted Fether I then did the same steps (but ran yarn; yarn build; yarn start), when I clicked the "Scan" button it worked and opened the QR page without the error.

screen shot 2019-01-16 at 11 59 17 am

screen shot 2019-01-16 at 11 59 34 am

screen shot 2019-01-16 at 12 21 54 pm

EDIT:
Regarding the padding around the Electron frame, I think I must have accidentally changed the zoom level of the Electron app, so I just fixed it by going to View > Actual

@ltfschoen ltfschoen changed the title TypeError: Cannot read property 'toNumber' of null TypeError: Cannot read property 'toNumber' of null when click "Scan" to send transaction from Parity Signer account Jan 16, 2019
@ltfschoen
Copy link
Contributor Author

It may be because the macOS FaceTime HD Webcam has issues, because after I clicked "Next Step" after scanning the QR code with Parity Signer, my webcam wasn't working

screen shot 2019-01-16 at 12 28 59 pm

So I may need to restart my computer.

@Tbaut Tbaut added the F2-bug label Jan 16, 2019
@Tbaut Tbaut added this to the 0.3-beta Mainnet milestone Jan 16, 2019
@axelchalon
Copy link
Contributor

axelchalon commented Jan 18, 2019

I also had this issue, don't think it's related to the webcam. I think it's related to gas/gasPrice somehow not being defined in the values submitted by TxForm.

@axelchalon axelchalon self-assigned this Jan 21, 2019
@ltfschoen
Copy link
Contributor Author

I also had this issue, don't think it's related to the webcam. I think it's related to gas/gasPrice somehow not being defined in the values submitted by TxForm.

Agreed. I was just able to replicate the same issue multiple times just by completing the TxForm page too quickly. i.e. pasting a recipient, entering a value, and pressing the "Scan" button as soon as the scan button appeared

@ltfschoen
Copy link
Contributor Author

ltfschoen commented Jan 22, 2019

I've discovered that it's caused when it lets you click "Send" when in the "Transaction Details" section still says "Missing input fields...".
So to replicate, go to the "Send Ether" page, click the "Details" button, paste a recipient address, and enter an amount. Keep changing the amount value from a valid amount to an invalid amount (i.e. 0.00) and wait each time you do to see if it still says "Missing input fields..." after it has already changed to "Send". If you click "Send" at this stage it will display the error page, but if you wait until it's calculated and shown the transaction details it won't error

@ltfschoen
Copy link
Contributor Author

It appears to be Parity Signer-specific, it seems that when you click "Scan" it tries to go to the paritytech/fether/packages/fether-react/src/Send/TxQrCode/TxQrCode.js, where it calls getRlp() to get teh value for the rlp prop of the QrSigner component, which calls transactionToRlp(this.tx) to get the RLP of the unsigned tx that is provided as an argument paritytech/fether/packages/fether-react/src/stores/sendStore.js, but it crashes if this.tx contains a gas property that's undefined.
So we need to prevent the user from clicking "Scan" before the gas property has been determined

@axelchalon
Copy link
Contributor

axelchalon commented Jan 23, 2019

I investigated as well and this is what I got:

  • The form is valid (validateForm) when !estimatedTxFee.
  • !estimatedTxFee when no amount/gas/gasPrice
  • gas is set asynchronously when amount/to changes
  • if amount/to changes and validateForm is called before gas is set, then we can send the form (deemed valid) without gas (in other terms: if fetching the gas takes more time than the 1s debounce)

This can be reproduced by changing the line with:

newGasEstimate = await estimateGas(
              allValues,
              token,
              parityStore.api
            ).then(x => 
              new Promise((resolve,reject) => {
                setTimeout(() => {resolve(x)}, 15000);
              })
            );

This only triggers an error for Parity Signer accounts, but for node accounts it means that the gas isn't sent with the transaction, which isn't intended either.

amaury1093 added a commit that referenced this issue Feb 11, 2019
…gas-calculated

fix: Fixes #361. Restrict user from clicking "Scan" to process tx before gas is calculated
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants