zilpay / zil-pay

ZilPay browser extension enables browsing Zilliqa blockchain enabled websites.
https://zilpay.io
Other
3 stars 1 forks source link

submitting transaction on another page doesn't continue logic in app #25

Closed VexyCats closed 4 years ago

VexyCats commented 4 years ago

The issue is - if the user submits the zilpay transaction when NOT on the page for the app - the app doesn't fire off the next cpde/events/actions to be done to track the transaction. Not sure why - as with metamask, this doesn't happen. But with metamask we can use .on().then() for transactions. Can we do the same with zilpay?

contract.call().subscribe()

or

contract.call().on(receipt){}.then((data) => {
      console.log(data);
    });

Example of what is happening:

Code is written such that the transaction is sent to the user and then, lets say consoles logs the tx hash until its confirmed. If the zilpay pop up comes up and the user goes to another tab and then submits the transaction, the original tab will not console log any txhash and no code is executed after the transaction is sent.

hicaru commented 4 years ago

Thanks for your issue. It will release in new version ZIlPay.

VexyCats commented 4 years ago

Hey @lich666dead the new release was pushed out a few days ago but the issue still persists.

When on another tab or page and the tx pops up, if a user submits it, the app doesn't properly return the tx hash.

The newest changes to add a subscribe function are great - but there is never a txhash returned in this case to subscribe to.

There needs to be a subscribe to the transaction event itself.

    const contractCall = await contractInstance.call(
      methodName,
      params,
      {
        version: VERSION,
        amount: new BN(0),
        gasPrice: myGasPrice,
        gasLimit: Long.fromNumber(10000),
      },
      66,
      1000,
      true
    ).on("transactionHash", () = {
//handle logic 
})

Maybe this doesn't help solve the problem though - I don't know why it doesn't return a txhash in the code logic if the tab is on another page. You can try it yourself with a js app.

Have js logic submit a transaction like the code above Open a new tab and navigate somewhere else before accepting the transaction. Send the transaction from zilpay, while on another tab than the one that submitting the transaction. Go back to the first tab and see that there is no logic/code continuing - as if the transaction was never accepted.

hicaru commented 4 years ago

Hello @VexyCats i started to rewrite code for inpage script. because Zilliqa-js cannot do it.

contractInstance.call return promise with the TX hash, now you can observe via

const subscriber = window
  .zilPay
  .wallet
  .observableTransaction('1c8da22d431bf411a9732d91ef89252f4b949215bdaaa4011ecfe753cfe50ec5')
  .subscribe(txns => / do something.../)